Commit dcd41a85 authored by pengjun's avatar pengjun

init collateralize contract

parent 10ae4b09
all:
chmod +x ./build.sh
./build.sh $(OUT) $(FLAG)
\ No newline at end of file
#!/bin/sh
strpwd=$(pwd)
strcmd=${strpwd##*dapp/}
strapp=${strcmd%/cmd*}
OUT_DIR="${1}/$strapp"
#FLAG=$2
mkdir -p "${OUT_DIR}"
cp ./build/* "${OUT_DIR}"
OUT_TESTDIR="${1}/dapptest/$strapp"
mkdir -p "${OUT_TESTDIR}"
cp ./build/test-rpc.sh "${OUT_TESTDIR}"
// Copyright Fuzamei Corp. 2018 All Rights Reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package executor
import (
log "github.com/33cn/chain33/common/log/log15"
drivers "github.com/33cn/chain33/system/dapp"
"github.com/33cn/chain33/types"
pty "github.com/33cn/plugin/plugin/dapp/collateralize/types"
)
var clog = log.New("module", "execs.collateralize")
var driverName = pty.CollateralizeX
func init() {
ety := types.LoadExecutorType(driverName)
ety.InitFuncList(types.ListMethod(&Collateralize{}))
}
type subConfig struct {
ParaRemoteGrpcClient string `json:"paraRemoteGrpcClient"`
}
var cfg subConfig
// Init collateralize
func Init(name string, sub []byte) {
driverName := GetName()
if name != driverName {
panic("system dapp can't be rename")
}
if sub != nil {
types.MustDecode(sub, &cfg)
}
drivers.Register(driverName, newCollateralize, types.GetDappFork(driverName, "Enable"))
}
// GetName for Collateralize
func GetName() string {
return newCollateralize().GetName()
}
// Collateralize driver
type Collateralize struct {
drivers.DriverBase
}
func newCollateralize() drivers.Driver {
c := &Collateralize{}
c.SetChild(c)
c.SetExecutorType(types.LoadExecutorType(driverName))
return c
}
// GetDriverName for Collateralize
func (Coll *Collateralize) GetDriverName() string {
return pty.CollateralizeX
}
func (Coll *Collateralize) saveCollateralizeBorrow(collateralizelog *pty.ReceiptCollateralize) (kvs []*types.KeyValue) {
key := calcCollateralizeBorrowKey(collateralizelog.CollateralizeId, collateralizelog.AccountAddr)
record := &pty.CollateralizeBorrowRecord{CollateralizeId:collateralizelog.CollateralizeId,}
kv := &types.KeyValue{Key: key, Value: types.Encode(record)}
kvs = append(kvs, kv)
return kvs
}
func (Coll *Collateralize) deleteCollateralizeBorrow(collateralizelog *pty.ReceiptCollateralize) (kvs []*types.KeyValue) {
key := calcCollateralizeBorrowKey(collateralizelog.CollateralizeId, collateralizelog.AccountAddr)
kv := &types.KeyValue{Key: key, Value: nil}
kvs = append(kvs, kv)
return kvs
}
func (Coll *Collateralize) saveCollateralizeRepay(collateralizelog *pty.ReceiptCollateralize) (kvs []*types.KeyValue) {
key := calcCollateralizeRepayKey(collateralizelog.CollateralizeId)
record := &pty.CollateralizeRepayRecord{}
kv := &types.KeyValue{Key: key, Value: types.Encode(record)}
kvs = append(kvs, kv)
return kvs
}
func (Coll *Collateralize) deleteCollateralizeRepay(collateralizelog *pty.ReceiptCollateralize) (kvs []*types.KeyValue) {
key := calcCollateralizeRepayKey(collateralizelog.CollateralizeId)
kv := &types.KeyValue{Key: key, Value: nil}
kvs = append(kvs, kv)
return kvs
}
func (Coll *Collateralize) saveCollateralize(collateralizelog *pty.ReceiptCollateralize) (kvs []*types.KeyValue) {
if collateralizelog.PreStatus > 0 {
kv := delCollateralize(collateralizelog.CollateralizeId, collateralizelog.PreStatus)
kvs = append(kvs, kv)
}
kvs = append(kvs, addCollateralize(collateralizelog.CollateralizeId, collateralizelog.Status))
return kvs
}
func (Coll *Collateralize) deleteCollateralize(collateralizelog *pty.ReceiptCollateralize) (kvs []*types.KeyValue) {
if collateralizelog.PreStatus > 0 {
kv := addCollateralize(collateralizelog.CollateralizeId, collateralizelog.PreStatus)
kvs = append(kvs, kv)
}
kvs = append(kvs, delCollateralize(collateralizelog.CollateralizeId, collateralizelog.Status))
return kvs
}
func addCollateralize(collateralizeID string, status int32) *types.KeyValue {
kv := &types.KeyValue{}
kv.Key = calcCollateralizeKey(collateralizeID)
kv.Value = []byte(collateralizeID)
return kv
}
func delCollateralize(collateralizeID string, status int32) *types.KeyValue {
kv := &types.KeyValue{}
kv.Key = calcCollateralizeKey(collateralizeID)
kv.Value = nil
return kv
}
// GetPayloadValue CollateralizeAction
func (Coll *Collateralize) GetPayloadValue() types.Message {
return &pty.CollateralizeAction{}
}
// CheckReceiptExecOk return true to check if receipt ty is ok
func (Coll *Collateralize) CheckReceiptExecOk() bool {
return true
}
// Copyright Fuzamei Corp. 2018 All Rights Reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package executor
import (
"github.com/33cn/chain33/account"
"github.com/33cn/chain33/common"
dbm "github.com/33cn/chain33/common/db"
"github.com/33cn/chain33/system/dapp"
"github.com/33cn/chain33/types"
pty "github.com/33cn/plugin/plugin/dapp/collateralize/types"
tokenE "github.com/33cn/plugin/plugin/dapp/token/executor"
)
// List control
const (
ListDESC = int32(0)
ListASC = int32(1)
DefultCount = int32(20) //默认一次取多少条记录
MaxCount = int32(100) //最多取100条
)
const (
decimal = types.Coin // 1e8
MaxDebtCeiling = 10000 // 最大借贷限额
MinLiquidationRatio = 0.3 // 最小质押比
MaxStabilityFee = 1000 // 最大稳定费
MaxLiquidationPenalty = 1000 // 最大清算罚金
MinCreatorAccount = 1000000 // 借贷创建者账户最小ccny余额
)
// CollateralizeDB def
type CollateralizeDB struct {
pty.Collateralize
}
// GetKVSet for CollateralizeDB
func (coll *CollateralizeDB) GetKVSet() (kvset []*types.KeyValue) {
value := types.Encode(&coll.Collateralize)
kvset = append(kvset, &types.KeyValue{Key: Key(coll.CollateralizeId), Value: value})
return kvset
}
// Save for CollateralizeDB
func (coll *CollateralizeDB) Save(db dbm.KV) {
set := coll.GetKVSet()
for i := 0; i < len(set); i++ {
db.Set(set[i].GetKey(), set[i].Value)
}
}
// Key for Collateralize
func Key(id string) (key []byte) {
key = append(key, []byte("mavl-"+pty.CollateralizeX+"-")...)
key = append(key, []byte(id)...)
return key
}
// Action struct
type Action struct {
coinsAccount *account.DB // bty账户
tokenAccount *account.DB // ccny账户
db dbm.KV
txhash []byte
fromaddr string
blocktime int64
height int64
execaddr string
difficulty uint64
index int
Collateralize *Collateralize
}
// NewCollateralizeAction generate New Action
func NewCollateralizeAction(c *Collateralize, tx *types.Transaction, index int) *Action {
hash := tx.Hash()
fromaddr := tx.From()
tokenDb, err := account.NewAccountDB(tokenE.GetName(), pty.CCNYTokenName, c.GetStateDB())
if err != nil {
clog.Error("NewCollateralizeAction", "Get Account DB error", "err", err)
return nil
}
return &Action{
coinsAccount: c.GetCoinsAccount(), tokenAccount:tokenDb, db: c.GetStateDB(),
txhash: hash, fromaddr: fromaddr, blocktime: c.GetBlockTime(),
height: c.GetHeight(), 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, preStatus int32) *pty.ReceiptCollateralize {
c := &pty.ReceiptCollateralize{}
c.CollateralizeId = collateralize.CollateralizeId
c.PreStatus = preStatus
c.Status = collateralize.Status
return c
}
// GetCreateReceiptLog generate logs for Collateralize create action
func (action *Action) GetCreateReceiptLog(collateralize *pty.Collateralize, preStatus int32) *types.ReceiptLog {
log := &types.ReceiptLog{}
log.Ty = pty.TyLogCollateralizeCreate
c := action.GetCollCommonRecipt(collateralize, preStatus)
c.CreateAddr = action.fromaddr
log.Log = types.Encode(c)
return log
}
// GetBorrowReceiptLog generate logs for Collateralize borrow action
// TODO
func (action *Action) GetBorrowReceiptLog(collateralize *pty.Collateralize, preStatus int32) *types.ReceiptLog {
log := &types.ReceiptLog{}
log.Ty = pty.TyLogCollateralizeBorrow
c := action.GetCollCommonRecipt(collateralize, preStatus)
c.AccountAddr = action.fromaddr
log.Log = types.Encode(c)
return log
}
// GetRepayReceiptLog generate logs for Collateralize Repay action
// TODO
func (action *Action) GetRepayReceiptLog(Collateralize *pty.Collateralize, preStatus int32) *types.ReceiptLog {
log := &types.ReceiptLog{}
log.Ty = pty.TyLogCollateralizeRepay
c := action.GetCollCommonRecipt(Collateralize, preStatus)
log.Log = types.Encode(c)
return log
}
// GetAppendReceiptLog generate logs for Collateralize Repay action
// TODO
func (action *Action) GetAppendReceiptLog(Collateralize *pty.Collateralize, preStatus int32) *types.ReceiptLog {
return nil
}
// GetCloseReceiptLog generate logs for Collateralize close action
// TODO
func (action *Action) GetCloseReceiptLog(Collateralize *pty.Collateralize, preStatus int32) *types.ReceiptLog {
return nil
}
// GetIndex returns index in block
func (action *Action) GetIndex() int64 {
return action.height*types.MaxTxsPerBlock + int64(action.index)
}
// CollateralizeCreate 创建借贷,持有一定数量ccny的用户可创建借贷,提供给其他用户借贷
func (action *Action) CollateralizeCreate(create *pty.CollateralizeCreate) (*types.Receipt, error) {
var logs []*types.ReceiptLog
var kv []*types.KeyValue
var receipt *types.Receipt
collateralizeID := common.ToHex(action.txhash)
// 参数校验
if create.DebtCeiling > MaxDebtCeiling || create.DebtCeiling < 0 ||
create.LiquidationRatio < MinLiquidationRatio || create.LiquidationRatio >= 1 ||
create.StabilityFee > MaxStabilityFee || create.StabilityFee < 0 ||
create.LiquidationPenalty > MaxLiquidationPenalty || create.LiquidationPenalty < 0 {
return nil, pty.ErrRiskParam
}
// 检查ccny余额
if !action.CheckExecTokenAccount(action.fromaddr, MinCreatorAccount, false) {
return nil, types.ErrInsufficientBalance
}
// 查找ID是否重复
_, err := findCollateralize(action.db, collateralizeID)
if err != types.ErrNotFound {
clog.Error("CollateralizeCreate", "CollateralizeCreate repeated", collateralizeID)
return nil, pty.ErrCollateralizeRepeatHash
}
// TODO ccny是否需要冻结
// 构造coll结构
coll := &CollateralizeDB{}
coll.CollateralizeId = collateralizeID
coll.LiquidationRatio = create.LiquidationRatio
coll.TotalBalance = create.TotalBalance
coll.DebtCeiling = create.DebtCeiling
coll.LiquidationPenalty = create.LiquidationPenalty
coll.StabilityFee = create.StabilityFee
coll.CreateAddr = action.fromaddr
coll.Status = pty.CollateralizeActionCreate
clog.Debug("CollateralizeCreate created", "CollateralizeID", collateralizeID, "TotalBalance", coll.TotalBalance)
// 保存
coll.Save(action.db)
kv = append(kv, coll.GetKVSet()...)
receiptLog := action.GetCreateReceiptLog(&coll.Collateralize, 0)
logs = append(logs, receiptLog)
receipt = &types.Receipt{Ty: types.ExecOk, KV: kv, Logs: logs}
return receipt, nil
}
// 根据最近抵押物价格计算需要冻结的BTY数量
func getBtyNumToFrozen(value int64, price float32, ratio float32) (int64,error) {
if price == 0 {
clog.Error("Bty price should greate to 0")
return 0, pty.ErrPriceZero
}
btyValue := float32(value)/ratio
btyNum := int64(btyValue/price) + 1
return btyNum, nil
}
// 计算清算价格
// value:借出ccny数量, colValue:抵押物数量, price:抵押物价格
func calcRepayPrice(value int64, colValue int64) float32 {
liquidationRation := float32(value) / float32(colValue)
repayPrice := liquidationRation * pty.CollateralizeRepayRatio
return repayPrice
}
// 获取最近抵押物价格
func (action *Action)getLatestPrice(db dbm.KV, assetType int32) (float32, error) {
data, err := db.Get(calcCollateralizeLatestPriceKey())
if err != nil {
clog.Debug("getLatestPrice", "get", err)
return -1, err
}
var price pty.AssetPriceRecord
//decode
err = types.Decode(data, &price)
if err != nil {
clog.Debug("getLatestPrice", "decode", err)
return -1, err
}
switch assetType {
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 检查账户抵押物余额
func (action *Action) CheckExecAccountBalance(fromAddr string, ToFrozen, ToActive int64) bool {
acc := action.coinsAccount.LoadExecAccount(fromAddr, action.execaddr)
if acc.GetBalance() >= ToFrozen && acc.GetFrozen() >= ToActive {
return true
}
return false
}
// CheckExecAccount 检查账户token余额
func (action *Action) CheckExecTokenAccount(addr string, amount int64, isFrozen bool) bool {
acc := action.tokenAccount.LoadExecAccount(addr, action.execaddr)
if isFrozen {
if acc.GetFrozen() >= amount {
return true
}
} else {
if acc.GetBalance() >= amount {
return true
}
}
return false
}
// CollateralizeBorrow 用户质押bty借出ccny
// TODO 考虑同一用户多次借贷的场景
func (action *Action) CollateralizeBorrow(borrow *pty.CollateralizeBorrow) (*types.Receipt, error) {
var logs []*types.ReceiptLog
var kv []*types.KeyValue
// 查找对应的借贷ID
// TODO 是否需要合约自动查找?
collateralize, err := findCollateralize(action.db, borrow.CollateralizeId)
if err != nil {
clog.Error("CollateralizeBorrow", "CollateralizeId", borrow.CollateralizeId)
return nil, err
}
coll := &CollateralizeDB{*collateralize}
preStatus := coll.Status
// 状态检查
if coll.Status == pty.CollateralizeStatusClose {
clog.Error("CollateralizeBorrow", "CollID", coll.CollateralizeId, "addr", action.fromaddr, "execaddr", action.execaddr, "status", coll.Status, "err", pty.ErrCollateralizeStatus)
return nil, pty.ErrCollateralizeStatus
}
// 借贷金额检查
if borrow.GetValue() <= 0 || borrow.GetValue() > coll.DebtCeiling {
clog.Error("CollateralizeBorrow", "CollID", coll.CollateralizeId, "addr", action.fromaddr, "execaddr", action.execaddr, "borrow value", borrow.GetValue(), "err", pty.ErrCollateralizeExceedDebtCeiling)
return nil, pty.ErrCollateralizeExceedDebtCeiling
}
clog.Debug("CollateralizeBorrow", "value", borrow.GetValue())
// 获取抵押物价格
lastPrice, err := action.getLatestPrice(action.db, coll.CollType)
if err != nil {
clog.Error("CollateralizeBorrow", "CollID", coll.CollateralizeId, "addr", action.fromaddr, "execaddr", action.execaddr, "err", err)
return nil, err
}
// 根据价格和需要借贷的金额,计算需要质押的抵押物数量
btyFrozen, err := getBtyNumToFrozen(borrow.Value, lastPrice, coll.LiquidationRatio)
if err != nil {
clog.Error("CollateralizeBorrow", "CollID", coll.CollateralizeId, "addr", action.fromaddr, "execaddr", action.execaddr, "err", err)
return nil, err
}
// 检查抵押物账户余额
if !action.CheckExecAccountBalance(action.fromaddr, btyFrozen, 0) {
clog.Error("CollateralizeBorrow", "CollID", coll.CollateralizeId, "addr", action.fromaddr, "execaddr", action.execaddr, "err", types.ErrNoBalance)
return nil, types.ErrNoBalance
}
// 抵押物转账
receipt, err := action.coinsAccount.ExecTransfer(action.fromaddr, coll.CreateAddr, action.execaddr, btyFrozen*decimal)
if err != nil {
clog.Error("CollateralizeBorrow.ExecTransfer", "addr", action.fromaddr, "execaddr", action.execaddr, "amount", btyFrozen)
return nil, err
}
logs = append(logs, receipt.Logs...)
kv = append(kv, receipt.KV...)
// 抵押物冻结
receipt, err = action.coinsAccount.ExecFrozen(coll.CreateAddr, action.execaddr, btyFrozen)
if err != nil {
clog.Error("CollateralizeBorrow.Frozen", "addr", coll.CreateAddr, "execaddr", action.execaddr, "amount", btyFrozen)
return nil, err
}
logs = append(logs, receipt.Logs...)
kv = append(kv, receipt.KV...)
// 借出ccny
receipt, err = action.tokenAccount.ExecTransfer(coll.CreateAddr, action.fromaddr, action.execaddr, borrow.Value)
if err != nil {
clog.Error("CollateralizeBorrow.ExecTokenTransfer", "addr", action.fromaddr, "execaddr", action.execaddr, "amount", borrow.Value)
return nil, err
}
logs = append(logs, receipt.Logs...)
kv = append(kv, receipt.KV...)
// 构造借出记录
borrowRecord := &pty.BorrowRecord{}
borrowRecord.AccountAddr = action.fromaddr
borrowRecord.CollateralValue = btyFrozen
borrowRecord.StartTime = action.blocktime
borrowRecord.CollateralPrice = lastPrice
borrowRecord.DebtValue = borrow.Value
borrowRecord.LiquidationPrice = coll.LiquidationRatio * lastPrice * pty.CollateralizeRepayRatio
borrowRecord.Status = pty.CollateralizeUserStatusCreate
// 记录当前借贷的最高自动清算价格
if coll.LatestRepayPrice < borrowRecord.LiquidationPrice {
coll.LatestRepayPrice = borrowRecord.LiquidationPrice
}
// 保存
coll.BorrowRecords = append(coll.BorrowRecords, borrowRecord)
coll.Status = pty.CollateralizeStatusCreated
coll.Save(action.db)
kv = append(kv, coll.GetKVSet()...)
receiptLog := action.GetBorrowReceiptLog(&coll.Collateralize, preStatus)
logs = append(logs, receiptLog)
receipt = &types.Receipt{Ty: types.ExecOk, KV: kv, Logs: logs}
return receipt, nil
}
// CollateralizeRepay 用户主动清算
func (action *Action) CollateralizeRepay(repay *pty.CollateralizeRepay) (*types.Receipt, error) {
var logs []*types.ReceiptLog
var kv []*types.KeyValue
var receipt *types.Receipt
// 找到相应的借贷
// TODO 是否需要合约自动查找
Collateralize, err := findCollateralize(action.db, repay.CollateralizeId)
if err != nil {
clog.Error("CollateralizeRepay", "CollID", repay.CollateralizeId, "addr", action.fromaddr, "execaddr", action.execaddr, "err", "Can not find collateralize Id")
return nil, err
}
coll := &CollateralizeDB{*Collateralize}
preStatus := coll.Status
// 状态检查
if coll.Status != pty.CollateralizeStatusCreated {
clog.Error("CollateralizeRepay", "CollID", repay.CollateralizeId, "addr", action.fromaddr, "execaddr", action.execaddr, "err", "status error", "Status", coll.Status)
return nil, pty.ErrCollateralizeStatus
}
// 查找借出记录
var borrowRecord *pty.BorrowRecord
for _, record := range coll.BorrowRecords {
if record.AccountAddr == action.fromaddr {
borrowRecord = record
}
}
if borrowRecord == nil {
clog.Error("CollateralizeRepay", "CollID", repay.CollateralizeId, "addr", action.fromaddr, "execaddr", action.execaddr, "err", "Can not find borrow record")
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
}
// 检查
// TODO 暂时未考虑利息
if !action.CheckExecTokenAccount(action.fromaddr, repay.Value, 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, repay.Value)
if err != nil {
clog.Error("CollateralizeRepay.ExecTokenTransfer", "addr", action.fromaddr, "execaddr", action.execaddr, "amount", repay.Value)
return nil, err
}
logs = append(logs, receipt.Logs...)
kv = append(kv, receipt.KV...)
// 抵押物归还
receipt, err = action.coinsAccount.ExecTransferFrozen(coll.CreateAddr, action.execaddr, action.execaddr, borrowRecord.CollateralValue)
if err != nil {
clog.Error("CollateralizeRepay.ExecTransferFrozen", "addr", coll.CreateAddr, "execaddr", action.execaddr, "amount", borrowRecord.CollateralValue)
return nil, err
}
logs = append(logs, receipt.Logs...)
kv = append(kv, receipt.KV...)
// 借贷记录关闭
borrowRecord.Status = pty.CollateralizeUserStatusClose
// 保存
coll.Save(action.db)
kv = append(kv, coll.GetKVSet()...)
receiptLog := action.GetRepayReceiptLog(&coll.Collateralize, preStatus)
logs = append(logs, receiptLog)
receipt = &types.Receipt{Ty: types.ExecOk, KV: kv, Logs: logs}
return receipt, nil
}
// CollateralizeAppend 追加抵押物
func (action *Action) CollateralizeAppend(cAppend *pty.CollateralizeAppend) (*types.Receipt, error) {
var logs []*types.ReceiptLog
var kv []*types.KeyValue
// 查找对应的借贷ID
// TODO 是否需要合约自动查找?
collateralize, err := findCollateralize(action.db, cAppend.CollateralizeId)
if err != nil {
clog.Error("CollateralizeAppend", "CollateralizeId", cAppend.CollateralizeId)
return nil, err
}
coll := &CollateralizeDB{*collateralize}
preStatus := coll.Status
// 状态检查
if coll.Status != pty.CollateralizeStatusCreated {
clog.Error("CollateralizeAppend", "CollID", coll.CollateralizeId, "addr", action.fromaddr, "execaddr", action.execaddr, "status", coll.Status, "err", pty.ErrCollateralizeStatus)
return nil, pty.ErrCollateralizeStatus
}
// 查找借出记录
var borrowRecord *pty.BorrowRecord
for _, record := range coll.BorrowRecords {
if record.AccountAddr == action.fromaddr {
borrowRecord = record
}
}
if borrowRecord == nil {
clog.Error("CollateralizeAppend", "CollID", cAppend.CollateralizeId, "addr", action.fromaddr, "execaddr", action.execaddr, "err", "Can not find borrow record")
return nil, pty.ErrRecordNotExist
}
clog.Debug("CollateralizeAppend", "value", cAppend.CollateralValue)
// 获取抵押物价格
lastPrice, err := action.getLatestPrice(action.db, coll.CollType)
if err != nil {
clog.Error("CollateralizeBorrow", "CollID", coll.CollateralizeId, "addr", action.fromaddr, "execaddr", action.execaddr, "err", err)
return nil, err
}
// 检查抵押物账户余额
if !action.CheckExecAccountBalance(action.fromaddr, cAppend.CollateralValue, 0) {
clog.Error("CollateralizeBorrow", "CollID", coll.CollateralizeId, "addr", action.fromaddr, "execaddr", action.execaddr, "err", types.ErrNoBalance)
return nil, types.ErrNoBalance
}
// 抵押物转账
receipt, err := action.coinsAccount.ExecTransfer(action.fromaddr, coll.CreateAddr, action.execaddr, cAppend.CollateralValue*decimal)
if err != nil {
clog.Error("CollateralizeBorrow.ExecTransfer", "addr", action.fromaddr, "execaddr", action.execaddr, "amount", cAppend.CollateralValue)
return nil, err
}
logs = append(logs, receipt.Logs...)
kv = append(kv, receipt.KV...)
// 抵押物冻结
receipt, err = action.coinsAccount.ExecFrozen(coll.CreateAddr, action.execaddr, cAppend.CollateralValue)
if err != nil {
clog.Error("CollateralizeBorrow.Frozen", "addr", coll.CreateAddr, "execaddr", action.execaddr, "amount", cAppend.CollateralValue)
return nil, err
}
logs = append(logs, receipt.Logs...)
kv = append(kv, receipt.KV...)
// 构造借出记录
borrowRecord.CollateralValue += cAppend.CollateralValue
borrowRecord.CollateralPrice = lastPrice
borrowRecord.LiquidationPrice = calcRepayPrice(borrowRecord.DebtValue, borrowRecord.CollateralValue)
// 记录当前借贷的最高自动清算价格
if coll.LatestRepayPrice < borrowRecord.LiquidationPrice {
coll.LatestRepayPrice = borrowRecord.LiquidationPrice
}
// 保存
coll.BorrowRecords = append(coll.BorrowRecords, borrowRecord)
coll.Status = pty.CollateralizeStatusCreated
coll.Save(action.db)
kv = append(kv, coll.GetKVSet()...)
receiptLog := action.GetAppendReceiptLog(&coll.Collateralize, preStatus)
logs = append(logs, receiptLog)
receipt = &types.Receipt{Ty: types.ExecOk, KV: kv, Logs: logs}
return receipt, nil
}
// TODO 部分清算
// CollateralizeFeed 喂价
func (action *Action) CollateralizeFeed(repay *pty.CollateralizeFeed) (*types.Receipt, error) {
//TODO
return nil, nil
}
// CollateralizeClose 终止借贷
func (action *Action) CollateralizeClose(draw *pty.CollateralizeClose) (*types.Receipt, error) {
//TODO
var logs []*types.ReceiptLog
var kv []*types.KeyValue
//var receipt *types.Receipt
Collateralize, err := findCollateralize(action.db, draw.CollateralizeId)
if err != nil {
clog.Error("CollateralizeBuy", "CollateralizeId", draw.CollateralizeId)
return nil, err
}
coll := &CollateralizeDB{*Collateralize}
preStatus := coll.Status
if action.fromaddr != coll.CreateAddr {
return nil, pty.ErrCollateralizeErrCloser
}
if coll.Status == pty.CollateralizeStatusClose {
return nil, pty.ErrCollateralizeStatus
}
clog.Debug("CollateralizeClose", )
//TODO
coll.Save(action.db)
kv = append(kv, coll.GetKVSet()...)
receiptLog := action.GetCloseReceiptLog(&coll.Collateralize, preStatus)
logs = append(logs, receiptLog)
return &types.Receipt{Ty: types.ExecOk, KV: kv, Logs: logs}, nil
}
// 查找借贷
func findCollateralize(db dbm.KV, CollateralizeID string) (*pty.Collateralize, error) {
data, err := db.Get(Key(CollateralizeID))
if err != nil {
clog.Debug("findCollateralize", "get", err)
return nil, err
}
var coll pty.Collateralize
//decode
err = types.Decode(data, &coll)
if err != nil {
clog.Debug("findCollateralize", "decode", err)
return nil, err
}
return &coll, nil
}
// Copyright Fuzamei Corp. 2018 All Rights Reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package executor
/*
waiting for update
*/
// Copyright Fuzamei Corp. 2018 All Rights Reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package executor
import (
"github.com/33cn/chain33/types"
pty "github.com/33cn/plugin/plugin/dapp/collateralize/types"
)
// Exec_Create Action
func (c *Collateralize) Exec_Create(payload *pty.CollateralizeCreate, tx *types.Transaction, index int) (*types.Receipt, error) {
actiondb := NewCollateralizeAction(c, tx, index)
return actiondb.CollateralizeCreate(payload)
}
// Exec_Borrow Action
func (c *Collateralize) Exec_Borrow(payload *pty.CollateralizeBorrow, tx *types.Transaction, index int) (*types.Receipt, error) {
actiondb := NewCollateralizeAction(c, tx, index)
return actiondb.CollateralizeBorrow(payload)
}
// Exec_Repay Action
func (c *Collateralize) Exec_Repay(payload *pty.CollateralizeRepay, tx *types.Transaction, index int) (*types.Receipt, error) {
actiondb := NewCollateralizeAction(c, tx, index)
return actiondb.CollateralizeRepay(payload)
}
// Exec_Repay Action
func (c *Collateralize) Exec_Append(payload *pty.CollateralizeAppend, tx *types.Transaction, index int) (*types.Receipt, error) {
actiondb := NewCollateralizeAction(c, tx, index)
return actiondb.CollateralizeAppend(payload)
}
// Exec_Feed Action
func (c *Collateralize) Exec_Feed(payload *pty.CollateralizeFeed, tx *types.Transaction, index int) (*types.Receipt, error) {
actiondb := NewCollateralizeAction(c, tx, index)
return actiondb.CollateralizeFeed(payload)
}
// Exec_Close Action
func (c *Collateralize) Exec_Close(payload *pty.CollateralizeClose, tx *types.Transaction, index int) (*types.Receipt, error) {
actiondb := NewCollateralizeAction(c, tx, index)
return actiondb.CollateralizeClose(payload)
}
// Copyright Fuzamei Corp. 2018 All Rights Reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package executor
import (
//"github.com/33cn/chain33/common"
"github.com/33cn/chain33/types"
pty "github.com/33cn/plugin/plugin/dapp/collateralize/types"
)
func (c *Collateralize) execDelLocal(tx *types.Transaction, receiptData *types.ReceiptData) (*types.LocalDBSet, error) {
set := &types.LocalDBSet{}
for _, item := range receiptData.Logs {
switch item.Ty {
case pty.TyLogCollateralizeCreate, pty.TyLogCollateralizeBorrow, pty.TyLogCollateralizeAppend,
pty.TyLogCollateralizeRepay, pty.TyLogCollateralizeFeed, pty.TyLogCollateralizeClose:
var collateralizelog pty.ReceiptCollateralize
err := types.Decode(item.Log, &collateralizelog)
if err != nil {
return nil, err
}
kv := c.deleteCollateralize(&collateralizelog)
set.KV = append(set.KV, kv...)
if item.Ty == pty.TyLogCollateralizeBorrow {
kv := c.deleteCollateralizeBorrow(&collateralizelog)
set.KV = append(set.KV, kv...)
} else if item.Ty == pty.TyLogCollateralizeAppend {
kv := c.deleteCollateralizeRepay(&collateralizelog)
set.KV = append(set.KV, kv...)
//TODO
}
}
}
return set, nil
}
// ExecDelLocal_Create Action
func (c *Collateralize) ExecDelLocal_Create(payload *pty.CollateralizeCreate, tx *types.Transaction, receiptData *types.ReceiptData, index int) (*types.LocalDBSet, error) {
return c.execDelLocal(tx, receiptData)
}
// ExecDelLocal_Borrow Action
func (c *Collateralize) ExecDelLocal_Borrow(payload *pty.CollateralizeBorrow, tx *types.Transaction, receiptData *types.ReceiptData, index int) (*types.LocalDBSet, error) {
return c.execDelLocal(tx, receiptData)
}
// ExecDelLocal_Repay Action
func (c *Collateralize) ExecDelLocal_Repay(payload *pty.CollateralizeRepay, tx *types.Transaction, receiptData *types.ReceiptData, index int) (*types.LocalDBSet, error) {
return c.execDelLocal(tx, receiptData)
}
// ExecDelLocal_Append Action
func (c *Collateralize) ExecDelLocal_Append(payload *pty.CollateralizeAppend, tx *types.Transaction, receiptData *types.ReceiptData, index int) (*types.LocalDBSet, error) {
return c.execDelLocal(tx, receiptData)
}
// ExecDelLocal_Feed Action
func (c *Collateralize) ExecDelLocal_Feed(payload *pty.CollateralizeFeed, tx *types.Transaction, receiptData *types.ReceiptData, index int) (*types.LocalDBSet, error) {
return c.execDelLocal(tx, receiptData)
}
// ExecDelLocal_Close Action
func (c *Collateralize) ExecDelLocal_Close(payload *pty.CollateralizeClose, tx *types.Transaction, receiptData *types.ReceiptData, index int) (*types.LocalDBSet, error) {
return c.execDelLocal(tx, receiptData)
}
\ No newline at end of file
// Copyright Fuzamei Corp. 2018 All Rights Reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package executor
import (
//"github.com/33cn/chain33/common"
"github.com/33cn/chain33/types"
pty "github.com/33cn/plugin/plugin/dapp/collateralize/types"
)
func (c *Collateralize) execLocal(tx *types.Transaction, receipt *types.ReceiptData) (*types.LocalDBSet, error) {
set := &types.LocalDBSet{}
for _, item := range receipt.Logs {
switch item.Ty {
case pty.TyLogCollateralizeCreate, pty.TyLogCollateralizeBorrow, pty.TyLogCollateralizeRepay, pty.TyLogCollateralizeAppend,
pty.TyLogCollateralizeFeed, pty.TyLogCollateralizeClose:
var Collateralizelog pty.ReceiptCollateralize
err := types.Decode(item.Log, &Collateralizelog)
if err != nil {
return nil, err
}
kv := c.saveCollateralize(&Collateralizelog)
set.KV = append(set.KV, kv...)
if item.Ty == pty.TyLogCollateralizeBorrow {
kv := c.saveCollateralizeBorrow(&Collateralizelog)
set.KV = append(set.KV, kv...)
} else if item.Ty == pty.TyLogCollateralizeRepay {
kv := c.saveCollateralizeRepay(&Collateralizelog)
set.KV = append(set.KV, kv...)
} else {
//TODO
}
}
}
return set, nil
}
// ExecLocal_Create Action
func (c *Collateralize) ExecLocal_Create(payload *pty.CollateralizeCreate, tx *types.Transaction, receiptData *types.ReceiptData, index int) (*types.LocalDBSet, error) {
return c.execLocal(tx, receiptData)
}
// ExecLocal_Borrow Action
func (c *Collateralize) ExecLocal_Borrow(payload *pty.CollateralizeBorrow, tx *types.Transaction, receiptData *types.ReceiptData, index int) (*types.LocalDBSet, error) {
return c.execLocal(tx, receiptData)
}
// ExecLocal_Repay Action
func (c *Collateralize) ExecLocal_Repay(payload *pty.CollateralizeRepay, tx *types.Transaction, receiptData *types.ReceiptData, index int) (*types.LocalDBSet, error) {
return c.execLocal(tx, receiptData)
}
// ExecLocal_Repay Action
func (c *Collateralize) ExecLocal_Append(payload *pty.CollateralizeAppend, tx *types.Transaction, receiptData *types.ReceiptData, index int) (*types.LocalDBSet, error) {
return c.execLocal(tx, receiptData)
}
// ExecLocal_Feed Action
func (c *Collateralize) ExecLocal_Feed(payload *pty.CollateralizeFeed, tx *types.Transaction, receiptData *types.ReceiptData, index int) (*types.LocalDBSet, error) {
return c.execLocal(tx, receiptData)
}
// ExecLocal_Close Action
func (c *Collateralize) ExecLocal_Close(payload *pty.CollateralizeClose, tx *types.Transaction, receiptData *types.ReceiptData, index int) (*types.LocalDBSet, error) {
return c.execLocal(tx, receiptData)
}
// Copyright Fuzamei Corp. 2018 All Rights Reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package executor
import "fmt"
func calcCollateralizeKey(CollateralizeID string) []byte {
key := fmt.Sprintf("LODB-Collateralize-create:%s", CollateralizeID)
return []byte(key)
}
func calcCollateralizeBorrowPrefix(CollateralizeID string, addr string) []byte {
key := fmt.Sprintf("LODB-Collateralize-borrow:%s:%s", CollateralizeID, addr)
return []byte(key)
}
func calcCollateralizeBorrowKey(CollateralizeID string, addr string) []byte {
key := fmt.Sprintf("LODB-Collateralize-buy:%s:%s:%18d", CollateralizeID, addr)
return []byte(key)
}
func calcCollateralizeRepayPrefix(CollateralizeID string, addr string) []byte {
key := fmt.Sprintf("LODB-Collateralize-repay:%s:%s", CollateralizeID, addr)
return []byte(key)
}
func calcCollateralizeRepayKey(CollateralizeID string) []byte {
key := fmt.Sprintf("LODB-Collateralize-repay:%s:%10d", CollateralizeID)
return []byte(key)
}
func calcCollateralizePriceKey(time string) []byte {
key := fmt.Sprintf("LODB-Collateralize-price:%s", time)
return []byte(key)
}
func calcCollateralizeLatestPriceKey() []byte {
key := fmt.Sprintf("LODB-Collateralize-latest-price")
return []byte(key)
}
// Copyright Fuzamei Corp. 2018 All Rights Reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package executor
// Copyright Fuzamei Corp. 2018 All Rights Reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package collateralize
import (
"github.com/33cn/chain33/pluginmgr"
"github.com/33cn/plugin/plugin/dapp/collateralize/executor"
"github.com/33cn/plugin/plugin/dapp/collateralize/types"
)
func init() {
pluginmgr.Register(&pluginmgr.PluginBase{
Name: types.CollateralizeX,
ExecName: executor.GetName(),
Exec: executor.Init,
Cmd: nil,
RPC: nil,
})
}
all:
sh ./create_protobuf.sh
syntax = "proto3";
package types;
message Collateralize {
string collateralizeId = 1; //借贷ID,一期借贷对应一个ID
int64 totalBalance = 2; //当期可借贷的总金额(ccny)
int64 debtCeiling = 3; //单用户可借出的限额(ccny)
float liquidationRatio = 4; //清算比例
int64 stabilityFee = 5; //稳定费
int64 liquidationPenalty = 6; //清算罚金
string createAddr = 7; //创建人地址
int64 balance = 8; //剩余可借贷金额(ccny)
repeated BorrowRecord borrowRecords = 9; //借贷记录
repeated BorrowRecord badRecords = 10;//被系统清算的借贷
int32 status = 11;//当期借贷的状态,是否关闭
int32 collType = 12;//质押资产类型(1,bty,2,btc,3,eth...)
float latestRepayPrice = 13;//最大清算价格
}
message BorrowRecord {
string accountAddr = 1; //借贷人地址
int64 startTime = 2; //借贷时间
int64 collateralValue = 3; //抵押物价值(bty)
float collateralPrice = 4; //抵押物价格
int64 debtValue = 5; //债务价值(ccny)
float liquidationPrice = 6; //抵押物清算价格
int32 status = 7; //抵押状态,是否被清算
}
message AssetPriceRecord {
string recordTime = 1; //价格记录时间
float btyPrice = 2; //bty价格
float btcPrice = 3; //btc价格
float ethPrice = 4; //eth价格
string preRecordTime = 5; //上一次记录时间
}
message CollateralizeAction {
oneof value {
CollateralizeCreate create = 1; //创建一期借贷
CollateralizeBorrow borrow = 2; //借贷
CollateralizeRepay repay = 3; //清算
CollateralizeAppend append = 4; //追加
CollateralizeFeed feed = 5; //喂价
CollateralizeClose close = 6; //关闭
}
int32 ty = 10;
}
message CollateralizeCreate {
int64 debtCeiling = 1; //单用户可借出的限额(ccny)
float liquidationRatio = 2; //清算比例
int64 stabilityFee = 3; //稳定费
int64 liquidationPenalty = 4; //清算罚金
int64 totalBalance = 5; //可借贷总金额
}
message CollateralizeBorrow {
string collateralizeId = 1; //借贷期数ID
int64 value = 2; //借贷价值(ccny)
}
message CollateralizeRepay {
string collateralizeId = 1; //借贷期数ID
int64 value = 2; //借贷价值(ccny)
}
message CollateralizeAppend {
string collateralizeId = 1; //借贷期数ID
int64 collateralValue = 2; //追加价值(bty)
}
message CollateralizeFeed {
repeated int64 price = 1; //喂价
repeated int64 volume = 2; //成交量
}
message CollateralizeClose {
string collateralizeId = 1; //借贷期数ID
}
message ReceiptCollateralize {
string collateralizeId = 1;
string createAddr = 3;
string accountAddr = 4;
int32 status = 9;
int32 preStatus = 10;
}
message ReqCollateralizeInfo {
string collateralizeId = 1;
}
message ReqCollateralizeBorrowInfo {
string collateralizeId = 1;
string addr = 2;
}
message ReqCollateralizeBadDebt {
string collateralizeId = 1;
}
message ReqCollateralizeBorrowHistory {
string collateralizeId = 1;
string addr = 2;
int32 count = 4;
int32 direction = 5;
int64 index = 6;
}
message ReplyCollateralizeCurrentInfo {
int32 status = 1;//当期借贷的状态,是否关闭
int64 totalBalance = 2; //当期可借贷的总金额(ccny)
int64 debtCeiling = 3; //单用户可借出的限额(ccny)
float liquidationRatio = 4; //清算比例
int64 stabilityFee = 5; //稳定费
int64 liquidationPenalty = 6; //清算罚金
string createAddr = 7; //创建人地址
int64 balance = 8; //剩余可借贷金额(ccny)
}
message ReplyCollateralizeBadDebt {
repeated BorrowRecord records = 1;
}
// used for execlocal
message CollateralizeBorrowRecord {
string collateralizeId = 1;
int64 value = 2;
int64 index = 3;
int64 time = 4;
string txHash = 5;
}
message CollateralizeBorrowRecords {
repeated CollateralizeBorrowRecord records = 1;
}
message CollateralizeRepayRecord {
string collateralizeId = 1;
int64 value = 2;
int64 index = 3;
int64 time = 4;
string txHash = 5;
}
message CollateralizeRepayRecords {
repeated CollateralizeRepayRecord records = 1;
}
#!/bin/sh
chain33_path=$(go list -f '{{.Dir}}' "github.com/33cn/chain33")
protoc --go_out=plugins=grpc:../types ./*.proto --proto_path=. --proto_path="${chain33_path}/types/proto/"
// Copyright Fuzamei Corp. 2018 All Rights Reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package types
import (
"encoding/json"
"reflect"
"github.com/33cn/chain33/common/address"
log "github.com/33cn/chain33/common/log/log15"
"github.com/33cn/chain33/types"
)
var (
llog = log.New("module", "exectype."+CollateralizeX)
)
func init() {
types.AllowUserExec = append(types.AllowUserExec, []byte(CollateralizeX))
types.RegistorExecutor(CollateralizeX, NewType())
types.RegisterDappFork(CollateralizeX, "Enable", 0)
}
// CollateralizeType def
type CollateralizeType struct {
types.ExecTypeBase
}
// NewType method
func NewType() *CollateralizeType {
c := &CollateralizeType{}
c.SetChild(c)
return c
}
// GetName 获取执行器名称
func (Collateralize *CollateralizeType) GetName() string {
return CollateralizeX
}
// GetLogMap method
func (Collateralize *CollateralizeType) GetLogMap() map[int64]*types.LogInfo {
return map[int64]*types.LogInfo{
TyLogCollateralizeCreate: {Ty: reflect.TypeOf(ReceiptCollateralize{}), Name: "LogCollateralizeCreate"},
TyLogCollateralizeBorrow: {Ty: reflect.TypeOf(ReceiptCollateralize{}), Name: "LogCollateralizeBorrow"},
TyLogCollateralizeRepay: {Ty: reflect.TypeOf(ReceiptCollateralize{}), Name: "LogCollateralizeRepay"},
TyLogCollateralizeAppend: {Ty: reflect.TypeOf(ReceiptCollateralize{}), Name: "LogCollateralizeAppend"},
TyLogCollateralizeFeed: {Ty: reflect.TypeOf(ReceiptCollateralize{}), Name: "LogCollateralizeFeed"},
TyLogCollateralizeClose: {Ty: reflect.TypeOf(ReceiptCollateralize{}), Name: "LogCollateralizeClose"},
}
}
// GetPayload method
func (Collateralize *CollateralizeType) GetPayload() types.Message {
return &CollateralizeAction{}
}
// CreateTx method
func (Collateralize CollateralizeType) CreateTx(action string, message json.RawMessage) (*types.Transaction, error) {
llog.Debug("Collateralize.CreateTx", "action", action)
if action == "CollateralizeCreate" {
var param CollateralizeCreateTx
err := json.Unmarshal(message, &param)
if err != nil {
llog.Error("CreateTx", "Error", err)
return nil, types.ErrInvalidParam
}
return CreateRawCollateralizeCreateTx(&param)
} else if action == "CollateralizeBorrow" {
var param CollateralizeBorrowTx
err := json.Unmarshal(message, &param)
if err != nil {
llog.Error("CreateTx", "Error", err)
return nil, types.ErrInvalidParam
}
return CreateRawCollateralizeBorrowTx(&param)
} else if action == "CollateralizeRepay" {
var param CollateralizeRepayTx
err := json.Unmarshal(message, &param)
if err != nil {
llog.Error("CreateTx", "Error", err)
return nil, types.ErrInvalidParam
}
return CreateRawCollateralizeRepayTx(&param)
} else if action == "CollateralizeAppend" {
var param CollateralizeAppendTx
err := json.Unmarshal(message, &param)
if err != nil {
llog.Error("CreateTx", "Error", err)
return nil, types.ErrInvalidParam
}
return CreateRawCollateralizeAppendTx(&param)
} else if action == "CollateralizeFeed" {
var param CollateralizeFeedTx
err := json.Unmarshal(message, &param)
if err != nil {
llog.Error("CreateTx", "Error", err)
return nil, types.ErrInvalidParam
}
return CreateRawCollateralizeFeedTx(&param)
} else if action == "CollateralizeClose" {
var param CollateralizeCloseTx
err := json.Unmarshal(message, &param)
if err != nil {
llog.Error("CreateTx", "Error", err)
return nil, types.ErrInvalidParam
}
return CreateRawCollateralizeCloseTx(&param)
} else {
return nil, types.ErrNotSupport
}
}
// GetTypeMap method
func (Collateralize CollateralizeType) GetTypeMap() map[string]int32 {
return map[string]int32{
"Create": CollateralizeActionCreate,
"Borrow": CollateralizeActionBorrow,
"Repay": CollateralizeActionRepay,
"Append": CollateralizeActionAppend,
"Feed": CollateralizeActionFeed,
"Close": CollateralizeActionClose,
}
}
// CreateRawCollateralizeCreateTx method
func CreateRawCollateralizeCreateTx(parm *CollateralizeCreateTx) (*types.Transaction, error) {
if parm == nil {
llog.Error("CreateRawCollateralizeCreateTx", "parm", parm)
return nil, types.ErrInvalidParam
}
v := &CollateralizeCreate{
DebtCeiling: parm.DebtCeiling,
LiquidationRatio: parm.LiquidationRatio,
StabilityFee: parm.StabilityFee,
LiquidationPenalty: parm.LiquidationPenalty,
TotalBalance: parm.TotalBalance,
}
create := &CollateralizeAction{
Ty: CollateralizeActionCreate,
Value: &CollateralizeAction_Create{v},
}
tx := &types.Transaction{
Execer: []byte(types.ExecName(CollateralizeX)),
Payload: types.Encode(create),
Fee: parm.Fee,
To: address.ExecAddress(types.ExecName(CollateralizeX)),
}
name := types.ExecName(CollateralizeX)
tx, err := types.FormatTx(name, tx)
if err != nil {
return nil, err
}
return tx, nil
}
// CreateRawCollateralizeBorrowTx method
func CreateRawCollateralizeBorrowTx(parm *CollateralizeBorrowTx) (*types.Transaction, error) {
if parm == nil {
llog.Error("CreateRawCollateralizeBorrowTx", "parm", parm)
return nil, types.ErrInvalidParam
}
v := &CollateralizeBorrow{
CollateralizeId: parm.CollateralizeID,
Value: parm.Value,
}
Borrow := &CollateralizeAction{
Ty: CollateralizeActionBorrow,
Value: &CollateralizeAction_Borrow{v},
}
tx := &types.Transaction{
Execer: []byte(types.ExecName(CollateralizeX)),
Payload: types.Encode(Borrow),
Fee: parm.Fee,
To: address.ExecAddress(types.ExecName(CollateralizeX)),
}
name := types.ExecName(CollateralizeX)
tx, err := types.FormatTx(name, tx)
if err != nil {
return nil, err
}
return tx, nil
}
// CreateRawCollateralizeRepayTx method
func CreateRawCollateralizeRepayTx(parm *CollateralizeRepayTx) (*types.Transaction, error) {
if parm == nil {
llog.Error("CreateRawCollateralizeRepayTx", "parm", parm)
return nil, types.ErrInvalidParam
}
v := &CollateralizeRepay{
CollateralizeId: parm.CollateralizeID,
Value: parm.Value,
}
Repay := &CollateralizeAction{
Ty: CollateralizeActionRepay,
Value: &CollateralizeAction_Repay{v},
}
tx := &types.Transaction{
Execer: []byte(types.ExecName(CollateralizeX)),
Payload: types.Encode(Repay),
Fee: parm.Fee,
To: address.ExecAddress(types.ExecName(CollateralizeX)),
}
name := types.ExecName(CollateralizeX)
tx, err := types.FormatTx(name, tx)
if err != nil {
return nil, err
}
return tx, nil
}
// CreateRawCollateralizeAppendTx method
func CreateRawCollateralizeAppendTx(parm *CollateralizeAppendTx) (*types.Transaction, error) {
if parm == nil {
llog.Error("CreateRawCollateralizeAppendTx", "parm", parm)
return nil, types.ErrInvalidParam
}
v := &CollateralizeAppend{
CollateralizeId: parm.CollateralizeID,
CollateralValue: parm.Value,
}
Repay := &CollateralizeAction{
Ty: CollateralizeActionAppend,
Value: &CollateralizeAction_Append{v},
}
tx := &types.Transaction{
Execer: []byte(types.ExecName(CollateralizeX)),
Payload: types.Encode(Repay),
Fee: parm.Fee,
To: address.ExecAddress(types.ExecName(CollateralizeX)),
}
name := types.ExecName(CollateralizeX)
tx, err := types.FormatTx(name, tx)
if err != nil {
return nil, err
}
return tx, nil
}
// CreateRawCollateralizeFeedTx method
func CreateRawCollateralizeFeedTx(parm *CollateralizeFeedTx) (*types.Transaction, error) {
if parm == nil {
llog.Error("CreateRawCollateralizePriceFeedTx", "parm", parm)
return nil, types.ErrInvalidParam
}
v := &CollateralizeFeed{
Price: parm.Price,
Volume: parm.Volume,
}
Feed := &CollateralizeAction{
Ty: CollateralizeActionFeed,
Value: &CollateralizeAction_Feed{v},
}
tx := &types.Transaction{
Execer: []byte(types.ExecName(CollateralizeX)),
Payload: types.Encode(Feed),
Fee: parm.Fee,
To: address.ExecAddress(types.ExecName(CollateralizeX)),
}
name := types.ExecName(CollateralizeX)
tx, err := types.FormatTx(name, tx)
if err != nil {
return nil, err
}
return tx, nil
}
// CreateRawCollateralizeCloseTx method
func CreateRawCollateralizeCloseTx(parm *CollateralizeCloseTx) (*types.Transaction, error) {
if parm == nil {
llog.Error("CreateRawCollateralizeCloseTx", "parm", parm)
return nil, types.ErrInvalidParam
}
v := &CollateralizeClose{
CollateralizeId: parm.CollateralizeID,
}
close := &CollateralizeAction{
Ty: CollateralizeActionClose,
Value: &CollateralizeAction_Close{v},
}
tx := &types.Transaction{
Execer: []byte(types.ExecName(CollateralizeX)),
Payload: types.Encode(close),
Fee: parm.Fee,
To: address.ExecAddress(types.ExecName(CollateralizeX)),
}
name := types.ExecName(CollateralizeX)
tx, err := types.FormatTx(name, tx)
if err != nil {
return nil, err
}
return tx, nil
}
// Code generated by protoc-gen-go. DO NOT EDIT.
// source: collateralize.proto
package types
import (
fmt "fmt"
proto "github.com/golang/protobuf/proto"
math "math"
)
// Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal
var _ = fmt.Errorf
var _ = math.Inf
// This is a compile-time assertion to ensure that this generated file
// is compatible with the proto package it is being compiled against.
// A compilation error at this line likely means your copy of the
// proto package needs to be updated.
const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package
type Collateralize struct {
CollateralizeId string `protobuf:"bytes,1,opt,name=collateralizeId,proto3" json:"collateralizeId,omitempty"`
TotalBalance int64 `protobuf:"varint,2,opt,name=totalBalance,proto3" json:"totalBalance,omitempty"`
DebtCeiling int64 `protobuf:"varint,3,opt,name=debtCeiling,proto3" json:"debtCeiling,omitempty"`
LiquidationRatio float32 `protobuf:"fixed32,4,opt,name=liquidationRatio,proto3" json:"liquidationRatio,omitempty"`
StabilityFee int64 `protobuf:"varint,5,opt,name=stabilityFee,proto3" json:"stabilityFee,omitempty"`
LiquidationPenalty int64 `protobuf:"varint,6,opt,name=liquidationPenalty,proto3" json:"liquidationPenalty,omitempty"`
CreateAddr string `protobuf:"bytes,7,opt,name=createAddr,proto3" json:"createAddr,omitempty"`
Balance int64 `protobuf:"varint,8,opt,name=balance,proto3" json:"balance,omitempty"`
BorrowRecords []*BorrowRecord `protobuf:"bytes,9,rep,name=borrowRecords,proto3" json:"borrowRecords,omitempty"`
BadRecords []*BorrowRecord `protobuf:"bytes,10,rep,name=badRecords,proto3" json:"badRecords,omitempty"`
Status int32 `protobuf:"varint,11,opt,name=status,proto3" json:"status,omitempty"`
CollType int32 `protobuf:"varint,12,opt,name=collType,proto3" json:"collType,omitempty"`
LatestRepayPrice float32 `protobuf:"fixed32,13,opt,name=latestRepayPrice,proto3" json:"latestRepayPrice,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *Collateralize) Reset() { *m = Collateralize{} }
func (m *Collateralize) String() string { return proto.CompactTextString(m) }
func (*Collateralize) ProtoMessage() {}
func (*Collateralize) Descriptor() ([]byte, []int) {
return fileDescriptor_a988fb4a61381972, []int{0}
}
func (m *Collateralize) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_Collateralize.Unmarshal(m, b)
}
func (m *Collateralize) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_Collateralize.Marshal(b, m, deterministic)
}
func (m *Collateralize) XXX_Merge(src proto.Message) {
xxx_messageInfo_Collateralize.Merge(m, src)
}
func (m *Collateralize) XXX_Size() int {
return xxx_messageInfo_Collateralize.Size(m)
}
func (m *Collateralize) XXX_DiscardUnknown() {
xxx_messageInfo_Collateralize.DiscardUnknown(m)
}
var xxx_messageInfo_Collateralize proto.InternalMessageInfo
func (m *Collateralize) GetCollateralizeId() string {
if m != nil {
return m.CollateralizeId
}
return ""
}
func (m *Collateralize) GetTotalBalance() int64 {
if m != nil {
return m.TotalBalance
}
return 0
}
func (m *Collateralize) GetDebtCeiling() int64 {
if m != nil {
return m.DebtCeiling
}
return 0
}
func (m *Collateralize) GetLiquidationRatio() float32 {
if m != nil {
return m.LiquidationRatio
}
return 0
}
func (m *Collateralize) GetStabilityFee() int64 {
if m != nil {
return m.StabilityFee
}
return 0
}
func (m *Collateralize) GetLiquidationPenalty() int64 {
if m != nil {
return m.LiquidationPenalty
}
return 0
}
func (m *Collateralize) GetCreateAddr() string {
if m != nil {
return m.CreateAddr
}
return ""
}
func (m *Collateralize) GetBalance() int64 {
if m != nil {
return m.Balance
}
return 0
}
func (m *Collateralize) GetBorrowRecords() []*BorrowRecord {
if m != nil {
return m.BorrowRecords
}
return nil
}
func (m *Collateralize) GetBadRecords() []*BorrowRecord {
if m != nil {
return m.BadRecords
}
return nil
}
func (m *Collateralize) GetStatus() int32 {
if m != nil {
return m.Status
}
return 0
}
func (m *Collateralize) GetCollType() int32 {
if m != nil {
return m.CollType
}
return 0
}
func (m *Collateralize) GetLatestRepayPrice() float32 {
if m != nil {
return m.LatestRepayPrice
}
return 0
}
type BorrowRecord struct {
AccountAddr string `protobuf:"bytes,1,opt,name=accountAddr,proto3" json:"accountAddr,omitempty"`
StartTime int64 `protobuf:"varint,2,opt,name=startTime,proto3" json:"startTime,omitempty"`
CollateralValue int64 `protobuf:"varint,3,opt,name=collateralValue,proto3" json:"collateralValue,omitempty"`
CollateralPrice float32 `protobuf:"fixed32,4,opt,name=collateralPrice,proto3" json:"collateralPrice,omitempty"`
DebtValue int64 `protobuf:"varint,5,opt,name=debtValue,proto3" json:"debtValue,omitempty"`
LiquidationPrice float32 `protobuf:"fixed32,6,opt,name=liquidationPrice,proto3" json:"liquidationPrice,omitempty"`
Status int32 `protobuf:"varint,7,opt,name=status,proto3" json:"status,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *BorrowRecord) Reset() { *m = BorrowRecord{} }
func (m *BorrowRecord) String() string { return proto.CompactTextString(m) }
func (*BorrowRecord) ProtoMessage() {}
func (*BorrowRecord) Descriptor() ([]byte, []int) {
return fileDescriptor_a988fb4a61381972, []int{1}
}
func (m *BorrowRecord) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_BorrowRecord.Unmarshal(m, b)
}
func (m *BorrowRecord) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_BorrowRecord.Marshal(b, m, deterministic)
}
func (m *BorrowRecord) XXX_Merge(src proto.Message) {
xxx_messageInfo_BorrowRecord.Merge(m, src)
}
func (m *BorrowRecord) XXX_Size() int {
return xxx_messageInfo_BorrowRecord.Size(m)
}
func (m *BorrowRecord) XXX_DiscardUnknown() {
xxx_messageInfo_BorrowRecord.DiscardUnknown(m)
}
var xxx_messageInfo_BorrowRecord proto.InternalMessageInfo
func (m *BorrowRecord) GetAccountAddr() string {
if m != nil {
return m.AccountAddr
}
return ""
}
func (m *BorrowRecord) GetStartTime() int64 {
if m != nil {
return m.StartTime
}
return 0
}
func (m *BorrowRecord) GetCollateralValue() int64 {
if m != nil {
return m.CollateralValue
}
return 0
}
func (m *BorrowRecord) GetCollateralPrice() float32 {
if m != nil {
return m.CollateralPrice
}
return 0
}
func (m *BorrowRecord) GetDebtValue() int64 {
if m != nil {
return m.DebtValue
}
return 0
}
func (m *BorrowRecord) GetLiquidationPrice() float32 {
if m != nil {
return m.LiquidationPrice
}
return 0
}
func (m *BorrowRecord) GetStatus() int32 {
if m != nil {
return m.Status
}
return 0
}
type AssetPriceRecord struct {
RecordTime string `protobuf:"bytes,1,opt,name=recordTime,proto3" json:"recordTime,omitempty"`
BtyPrice float32 `protobuf:"fixed32,2,opt,name=btyPrice,proto3" json:"btyPrice,omitempty"`
BtcPrice float32 `protobuf:"fixed32,3,opt,name=btcPrice,proto3" json:"btcPrice,omitempty"`
EthPrice float32 `protobuf:"fixed32,4,opt,name=ethPrice,proto3" json:"ethPrice,omitempty"`
PreRecordTime string `protobuf:"bytes,5,opt,name=preRecordTime,proto3" json:"preRecordTime,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *AssetPriceRecord) Reset() { *m = AssetPriceRecord{} }
func (m *AssetPriceRecord) String() string { return proto.CompactTextString(m) }
func (*AssetPriceRecord) ProtoMessage() {}
func (*AssetPriceRecord) Descriptor() ([]byte, []int) {
return fileDescriptor_a988fb4a61381972, []int{2}
}
func (m *AssetPriceRecord) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_AssetPriceRecord.Unmarshal(m, b)
}
func (m *AssetPriceRecord) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_AssetPriceRecord.Marshal(b, m, deterministic)
}
func (m *AssetPriceRecord) XXX_Merge(src proto.Message) {
xxx_messageInfo_AssetPriceRecord.Merge(m, src)
}
func (m *AssetPriceRecord) XXX_Size() int {
return xxx_messageInfo_AssetPriceRecord.Size(m)
}
func (m *AssetPriceRecord) XXX_DiscardUnknown() {
xxx_messageInfo_AssetPriceRecord.DiscardUnknown(m)
}
var xxx_messageInfo_AssetPriceRecord proto.InternalMessageInfo
func (m *AssetPriceRecord) GetRecordTime() string {
if m != nil {
return m.RecordTime
}
return ""
}
func (m *AssetPriceRecord) GetBtyPrice() float32 {
if m != nil {
return m.BtyPrice
}
return 0
}
func (m *AssetPriceRecord) GetBtcPrice() float32 {
if m != nil {
return m.BtcPrice
}
return 0
}
func (m *AssetPriceRecord) GetEthPrice() float32 {
if m != nil {
return m.EthPrice
}
return 0
}
func (m *AssetPriceRecord) GetPreRecordTime() string {
if m != nil {
return m.PreRecordTime
}
return ""
}
type CollateralizeAction struct {
// Types that are valid to be assigned to Value:
// *CollateralizeAction_Create
// *CollateralizeAction_Borrow
// *CollateralizeAction_Repay
// *CollateralizeAction_Append
// *CollateralizeAction_Feed
// *CollateralizeAction_Close
Value isCollateralizeAction_Value `protobuf_oneof:"value"`
Ty int32 `protobuf:"varint,10,opt,name=ty,proto3" json:"ty,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *CollateralizeAction) Reset() { *m = CollateralizeAction{} }
func (m *CollateralizeAction) String() string { return proto.CompactTextString(m) }
func (*CollateralizeAction) ProtoMessage() {}
func (*CollateralizeAction) Descriptor() ([]byte, []int) {
return fileDescriptor_a988fb4a61381972, []int{3}
}
func (m *CollateralizeAction) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_CollateralizeAction.Unmarshal(m, b)
}
func (m *CollateralizeAction) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_CollateralizeAction.Marshal(b, m, deterministic)
}
func (m *CollateralizeAction) XXX_Merge(src proto.Message) {
xxx_messageInfo_CollateralizeAction.Merge(m, src)
}
func (m *CollateralizeAction) XXX_Size() int {
return xxx_messageInfo_CollateralizeAction.Size(m)
}
func (m *CollateralizeAction) XXX_DiscardUnknown() {
xxx_messageInfo_CollateralizeAction.DiscardUnknown(m)
}
var xxx_messageInfo_CollateralizeAction proto.InternalMessageInfo
type isCollateralizeAction_Value interface {
isCollateralizeAction_Value()
}
type CollateralizeAction_Create struct {
Create *CollateralizeCreate `protobuf:"bytes,1,opt,name=create,proto3,oneof"`
}
type CollateralizeAction_Borrow struct {
Borrow *CollateralizeBorrow `protobuf:"bytes,2,opt,name=borrow,proto3,oneof"`
}
type CollateralizeAction_Repay struct {
Repay *CollateralizeRepay `protobuf:"bytes,3,opt,name=repay,proto3,oneof"`
}
type CollateralizeAction_Append struct {
Append *CollateralizeAppend `protobuf:"bytes,4,opt,name=append,proto3,oneof"`
}
type CollateralizeAction_Feed struct {
Feed *CollateralizeFeed `protobuf:"bytes,5,opt,name=feed,proto3,oneof"`
}
type CollateralizeAction_Close struct {
Close *CollateralizeClose `protobuf:"bytes,6,opt,name=close,proto3,oneof"`
}
func (*CollateralizeAction_Create) isCollateralizeAction_Value() {}
func (*CollateralizeAction_Borrow) isCollateralizeAction_Value() {}
func (*CollateralizeAction_Repay) isCollateralizeAction_Value() {}
func (*CollateralizeAction_Append) isCollateralizeAction_Value() {}
func (*CollateralizeAction_Feed) isCollateralizeAction_Value() {}
func (*CollateralizeAction_Close) isCollateralizeAction_Value() {}
func (m *CollateralizeAction) GetValue() isCollateralizeAction_Value {
if m != nil {
return m.Value
}
return nil
}
func (m *CollateralizeAction) GetCreate() *CollateralizeCreate {
if x, ok := m.GetValue().(*CollateralizeAction_Create); ok {
return x.Create
}
return nil
}
func (m *CollateralizeAction) GetBorrow() *CollateralizeBorrow {
if x, ok := m.GetValue().(*CollateralizeAction_Borrow); ok {
return x.Borrow
}
return nil
}
func (m *CollateralizeAction) GetRepay() *CollateralizeRepay {
if x, ok := m.GetValue().(*CollateralizeAction_Repay); ok {
return x.Repay
}
return nil
}
func (m *CollateralizeAction) GetAppend() *CollateralizeAppend {
if x, ok := m.GetValue().(*CollateralizeAction_Append); ok {
return x.Append
}
return nil
}
func (m *CollateralizeAction) GetFeed() *CollateralizeFeed {
if x, ok := m.GetValue().(*CollateralizeAction_Feed); ok {
return x.Feed
}
return nil
}
func (m *CollateralizeAction) GetClose() *CollateralizeClose {
if x, ok := m.GetValue().(*CollateralizeAction_Close); ok {
return x.Close
}
return nil
}
func (m *CollateralizeAction) GetTy() int32 {
if m != nil {
return m.Ty
}
return 0
}
// XXX_OneofWrappers is for the internal use of the proto package.
func (*CollateralizeAction) XXX_OneofWrappers() []interface{} {
return []interface{}{
(*CollateralizeAction_Create)(nil),
(*CollateralizeAction_Borrow)(nil),
(*CollateralizeAction_Repay)(nil),
(*CollateralizeAction_Append)(nil),
(*CollateralizeAction_Feed)(nil),
(*CollateralizeAction_Close)(nil),
}
}
type CollateralizeCreate struct {
DebtCeiling int64 `protobuf:"varint,1,opt,name=debtCeiling,proto3" json:"debtCeiling,omitempty"`
LiquidationRatio float32 `protobuf:"fixed32,2,opt,name=liquidationRatio,proto3" json:"liquidationRatio,omitempty"`
StabilityFee int64 `protobuf:"varint,3,opt,name=stabilityFee,proto3" json:"stabilityFee,omitempty"`
LiquidationPenalty int64 `protobuf:"varint,4,opt,name=liquidationPenalty,proto3" json:"liquidationPenalty,omitempty"`
TotalBalance int64 `protobuf:"varint,5,opt,name=totalBalance,proto3" json:"totalBalance,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *CollateralizeCreate) Reset() { *m = CollateralizeCreate{} }
func (m *CollateralizeCreate) String() string { return proto.CompactTextString(m) }
func (*CollateralizeCreate) ProtoMessage() {}
func (*CollateralizeCreate) Descriptor() ([]byte, []int) {
return fileDescriptor_a988fb4a61381972, []int{4}
}
func (m *CollateralizeCreate) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_CollateralizeCreate.Unmarshal(m, b)
}
func (m *CollateralizeCreate) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_CollateralizeCreate.Marshal(b, m, deterministic)
}
func (m *CollateralizeCreate) XXX_Merge(src proto.Message) {
xxx_messageInfo_CollateralizeCreate.Merge(m, src)
}
func (m *CollateralizeCreate) XXX_Size() int {
return xxx_messageInfo_CollateralizeCreate.Size(m)
}
func (m *CollateralizeCreate) XXX_DiscardUnknown() {
xxx_messageInfo_CollateralizeCreate.DiscardUnknown(m)
}
var xxx_messageInfo_CollateralizeCreate proto.InternalMessageInfo
func (m *CollateralizeCreate) GetDebtCeiling() int64 {
if m != nil {
return m.DebtCeiling
}
return 0
}
func (m *CollateralizeCreate) GetLiquidationRatio() float32 {
if m != nil {
return m.LiquidationRatio
}
return 0
}
func (m *CollateralizeCreate) GetStabilityFee() int64 {
if m != nil {
return m.StabilityFee
}
return 0
}
func (m *CollateralizeCreate) GetLiquidationPenalty() int64 {
if m != nil {
return m.LiquidationPenalty
}
return 0
}
func (m *CollateralizeCreate) GetTotalBalance() int64 {
if m != nil {
return m.TotalBalance
}
return 0
}
type CollateralizeBorrow struct {
CollateralizeId string `protobuf:"bytes,1,opt,name=collateralizeId,proto3" json:"collateralizeId,omitempty"`
Value int64 `protobuf:"varint,2,opt,name=value,proto3" json:"value,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *CollateralizeBorrow) Reset() { *m = CollateralizeBorrow{} }
func (m *CollateralizeBorrow) String() string { return proto.CompactTextString(m) }
func (*CollateralizeBorrow) ProtoMessage() {}
func (*CollateralizeBorrow) Descriptor() ([]byte, []int) {
return fileDescriptor_a988fb4a61381972, []int{5}
}
func (m *CollateralizeBorrow) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_CollateralizeBorrow.Unmarshal(m, b)
}
func (m *CollateralizeBorrow) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_CollateralizeBorrow.Marshal(b, m, deterministic)
}
func (m *CollateralizeBorrow) XXX_Merge(src proto.Message) {
xxx_messageInfo_CollateralizeBorrow.Merge(m, src)
}
func (m *CollateralizeBorrow) XXX_Size() int {
return xxx_messageInfo_CollateralizeBorrow.Size(m)
}
func (m *CollateralizeBorrow) XXX_DiscardUnknown() {
xxx_messageInfo_CollateralizeBorrow.DiscardUnknown(m)
}
var xxx_messageInfo_CollateralizeBorrow proto.InternalMessageInfo
func (m *CollateralizeBorrow) GetCollateralizeId() string {
if m != nil {
return m.CollateralizeId
}
return ""
}
func (m *CollateralizeBorrow) GetValue() int64 {
if m != nil {
return m.Value
}
return 0
}
type CollateralizeRepay struct {
CollateralizeId string `protobuf:"bytes,1,opt,name=collateralizeId,proto3" json:"collateralizeId,omitempty"`
Value int64 `protobuf:"varint,2,opt,name=value,proto3" json:"value,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *CollateralizeRepay) Reset() { *m = CollateralizeRepay{} }
func (m *CollateralizeRepay) String() string { return proto.CompactTextString(m) }
func (*CollateralizeRepay) ProtoMessage() {}
func (*CollateralizeRepay) Descriptor() ([]byte, []int) {
return fileDescriptor_a988fb4a61381972, []int{6}
}
func (m *CollateralizeRepay) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_CollateralizeRepay.Unmarshal(m, b)
}
func (m *CollateralizeRepay) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_CollateralizeRepay.Marshal(b, m, deterministic)
}
func (m *CollateralizeRepay) XXX_Merge(src proto.Message) {
xxx_messageInfo_CollateralizeRepay.Merge(m, src)
}
func (m *CollateralizeRepay) XXX_Size() int {
return xxx_messageInfo_CollateralizeRepay.Size(m)
}
func (m *CollateralizeRepay) XXX_DiscardUnknown() {
xxx_messageInfo_CollateralizeRepay.DiscardUnknown(m)
}
var xxx_messageInfo_CollateralizeRepay proto.InternalMessageInfo
func (m *CollateralizeRepay) GetCollateralizeId() string {
if m != nil {
return m.CollateralizeId
}
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"`
CollateralValue int64 `protobuf:"varint,2,opt,name=collateralValue,proto3" json:"collateralValue,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *CollateralizeAppend) Reset() { *m = CollateralizeAppend{} }
func (m *CollateralizeAppend) String() string { return proto.CompactTextString(m) }
func (*CollateralizeAppend) ProtoMessage() {}
func (*CollateralizeAppend) Descriptor() ([]byte, []int) {
return fileDescriptor_a988fb4a61381972, []int{7}
}
func (m *CollateralizeAppend) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_CollateralizeAppend.Unmarshal(m, b)
}
func (m *CollateralizeAppend) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_CollateralizeAppend.Marshal(b, m, deterministic)
}
func (m *CollateralizeAppend) XXX_Merge(src proto.Message) {
xxx_messageInfo_CollateralizeAppend.Merge(m, src)
}
func (m *CollateralizeAppend) XXX_Size() int {
return xxx_messageInfo_CollateralizeAppend.Size(m)
}
func (m *CollateralizeAppend) XXX_DiscardUnknown() {
xxx_messageInfo_CollateralizeAppend.DiscardUnknown(m)
}
var xxx_messageInfo_CollateralizeAppend proto.InternalMessageInfo
func (m *CollateralizeAppend) GetCollateralizeId() string {
if m != nil {
return m.CollateralizeId
}
return ""
}
func (m *CollateralizeAppend) GetCollateralValue() int64 {
if m != nil {
return m.CollateralValue
}
return 0
}
type CollateralizeFeed struct {
Price []int64 `protobuf:"varint,1,rep,packed,name=price,proto3" json:"price,omitempty"`
Volume []int64 `protobuf:"varint,2,rep,packed,name=volume,proto3" json:"volume,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *CollateralizeFeed) Reset() { *m = CollateralizeFeed{} }
func (m *CollateralizeFeed) String() string { return proto.CompactTextString(m) }
func (*CollateralizeFeed) ProtoMessage() {}
func (*CollateralizeFeed) Descriptor() ([]byte, []int) {
return fileDescriptor_a988fb4a61381972, []int{8}
}
func (m *CollateralizeFeed) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_CollateralizeFeed.Unmarshal(m, b)
}
func (m *CollateralizeFeed) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_CollateralizeFeed.Marshal(b, m, deterministic)
}
func (m *CollateralizeFeed) XXX_Merge(src proto.Message) {
xxx_messageInfo_CollateralizeFeed.Merge(m, src)
}
func (m *CollateralizeFeed) XXX_Size() int {
return xxx_messageInfo_CollateralizeFeed.Size(m)
}
func (m *CollateralizeFeed) XXX_DiscardUnknown() {
xxx_messageInfo_CollateralizeFeed.DiscardUnknown(m)
}
var xxx_messageInfo_CollateralizeFeed proto.InternalMessageInfo
func (m *CollateralizeFeed) GetPrice() []int64 {
if m != nil {
return m.Price
}
return nil
}
func (m *CollateralizeFeed) GetVolume() []int64 {
if m != nil {
return m.Volume
}
return nil
}
type CollateralizeClose struct {
CollateralizeId string `protobuf:"bytes,1,opt,name=collateralizeId,proto3" json:"collateralizeId,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *CollateralizeClose) Reset() { *m = CollateralizeClose{} }
func (m *CollateralizeClose) String() string { return proto.CompactTextString(m) }
func (*CollateralizeClose) ProtoMessage() {}
func (*CollateralizeClose) Descriptor() ([]byte, []int) {
return fileDescriptor_a988fb4a61381972, []int{9}
}
func (m *CollateralizeClose) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_CollateralizeClose.Unmarshal(m, b)
}
func (m *CollateralizeClose) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_CollateralizeClose.Marshal(b, m, deterministic)
}
func (m *CollateralizeClose) XXX_Merge(src proto.Message) {
xxx_messageInfo_CollateralizeClose.Merge(m, src)
}
func (m *CollateralizeClose) XXX_Size() int {
return xxx_messageInfo_CollateralizeClose.Size(m)
}
func (m *CollateralizeClose) XXX_DiscardUnknown() {
xxx_messageInfo_CollateralizeClose.DiscardUnknown(m)
}
var xxx_messageInfo_CollateralizeClose proto.InternalMessageInfo
func (m *CollateralizeClose) GetCollateralizeId() string {
if m != nil {
return m.CollateralizeId
}
return ""
}
type ReceiptCollateralize struct {
CollateralizeId string `protobuf:"bytes,1,opt,name=collateralizeId,proto3" json:"collateralizeId,omitempty"`
CreateAddr string `protobuf:"bytes,3,opt,name=createAddr,proto3" json:"createAddr,omitempty"`
AccountAddr string `protobuf:"bytes,4,opt,name=accountAddr,proto3" json:"accountAddr,omitempty"`
Status int32 `protobuf:"varint,9,opt,name=status,proto3" json:"status,omitempty"`
PreStatus int32 `protobuf:"varint,10,opt,name=preStatus,proto3" json:"preStatus,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *ReceiptCollateralize) Reset() { *m = ReceiptCollateralize{} }
func (m *ReceiptCollateralize) String() string { return proto.CompactTextString(m) }
func (*ReceiptCollateralize) ProtoMessage() {}
func (*ReceiptCollateralize) Descriptor() ([]byte, []int) {
return fileDescriptor_a988fb4a61381972, []int{10}
}
func (m *ReceiptCollateralize) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_ReceiptCollateralize.Unmarshal(m, b)
}
func (m *ReceiptCollateralize) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_ReceiptCollateralize.Marshal(b, m, deterministic)
}
func (m *ReceiptCollateralize) XXX_Merge(src proto.Message) {
xxx_messageInfo_ReceiptCollateralize.Merge(m, src)
}
func (m *ReceiptCollateralize) XXX_Size() int {
return xxx_messageInfo_ReceiptCollateralize.Size(m)
}
func (m *ReceiptCollateralize) XXX_DiscardUnknown() {
xxx_messageInfo_ReceiptCollateralize.DiscardUnknown(m)
}
var xxx_messageInfo_ReceiptCollateralize proto.InternalMessageInfo
func (m *ReceiptCollateralize) GetCollateralizeId() string {
if m != nil {
return m.CollateralizeId
}
return ""
}
func (m *ReceiptCollateralize) GetCreateAddr() string {
if m != nil {
return m.CreateAddr
}
return ""
}
func (m *ReceiptCollateralize) GetAccountAddr() string {
if m != nil {
return m.AccountAddr
}
return ""
}
func (m *ReceiptCollateralize) GetStatus() int32 {
if m != nil {
return m.Status
}
return 0
}
func (m *ReceiptCollateralize) GetPreStatus() int32 {
if m != nil {
return m.PreStatus
}
return 0
}
type ReqCollateralizeInfo struct {
CollateralizeId string `protobuf:"bytes,1,opt,name=collateralizeId,proto3" json:"collateralizeId,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *ReqCollateralizeInfo) Reset() { *m = ReqCollateralizeInfo{} }
func (m *ReqCollateralizeInfo) String() string { return proto.CompactTextString(m) }
func (*ReqCollateralizeInfo) ProtoMessage() {}
func (*ReqCollateralizeInfo) Descriptor() ([]byte, []int) {
return fileDescriptor_a988fb4a61381972, []int{11}
}
func (m *ReqCollateralizeInfo) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_ReqCollateralizeInfo.Unmarshal(m, b)
}
func (m *ReqCollateralizeInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_ReqCollateralizeInfo.Marshal(b, m, deterministic)
}
func (m *ReqCollateralizeInfo) XXX_Merge(src proto.Message) {
xxx_messageInfo_ReqCollateralizeInfo.Merge(m, src)
}
func (m *ReqCollateralizeInfo) XXX_Size() int {
return xxx_messageInfo_ReqCollateralizeInfo.Size(m)
}
func (m *ReqCollateralizeInfo) XXX_DiscardUnknown() {
xxx_messageInfo_ReqCollateralizeInfo.DiscardUnknown(m)
}
var xxx_messageInfo_ReqCollateralizeInfo proto.InternalMessageInfo
func (m *ReqCollateralizeInfo) GetCollateralizeId() string {
if m != nil {
return m.CollateralizeId
}
return ""
}
type ReqCollateralizeBorrowInfo struct {
CollateralizeId string `protobuf:"bytes,1,opt,name=collateralizeId,proto3" json:"collateralizeId,omitempty"`
Addr string `protobuf:"bytes,2,opt,name=addr,proto3" json:"addr,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *ReqCollateralizeBorrowInfo) Reset() { *m = ReqCollateralizeBorrowInfo{} }
func (m *ReqCollateralizeBorrowInfo) String() string { return proto.CompactTextString(m) }
func (*ReqCollateralizeBorrowInfo) ProtoMessage() {}
func (*ReqCollateralizeBorrowInfo) Descriptor() ([]byte, []int) {
return fileDescriptor_a988fb4a61381972, []int{12}
}
func (m *ReqCollateralizeBorrowInfo) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_ReqCollateralizeBorrowInfo.Unmarshal(m, b)
}
func (m *ReqCollateralizeBorrowInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_ReqCollateralizeBorrowInfo.Marshal(b, m, deterministic)
}
func (m *ReqCollateralizeBorrowInfo) XXX_Merge(src proto.Message) {
xxx_messageInfo_ReqCollateralizeBorrowInfo.Merge(m, src)
}
func (m *ReqCollateralizeBorrowInfo) XXX_Size() int {
return xxx_messageInfo_ReqCollateralizeBorrowInfo.Size(m)
}
func (m *ReqCollateralizeBorrowInfo) XXX_DiscardUnknown() {
xxx_messageInfo_ReqCollateralizeBorrowInfo.DiscardUnknown(m)
}
var xxx_messageInfo_ReqCollateralizeBorrowInfo proto.InternalMessageInfo
func (m *ReqCollateralizeBorrowInfo) GetCollateralizeId() string {
if m != nil {
return m.CollateralizeId
}
return ""
}
func (m *ReqCollateralizeBorrowInfo) GetAddr() string {
if m != nil {
return m.Addr
}
return ""
}
type ReqCollateralizeBadDebt struct {
CollateralizeId string `protobuf:"bytes,1,opt,name=collateralizeId,proto3" json:"collateralizeId,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *ReqCollateralizeBadDebt) Reset() { *m = ReqCollateralizeBadDebt{} }
func (m *ReqCollateralizeBadDebt) String() string { return proto.CompactTextString(m) }
func (*ReqCollateralizeBadDebt) ProtoMessage() {}
func (*ReqCollateralizeBadDebt) Descriptor() ([]byte, []int) {
return fileDescriptor_a988fb4a61381972, []int{13}
}
func (m *ReqCollateralizeBadDebt) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_ReqCollateralizeBadDebt.Unmarshal(m, b)
}
func (m *ReqCollateralizeBadDebt) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_ReqCollateralizeBadDebt.Marshal(b, m, deterministic)
}
func (m *ReqCollateralizeBadDebt) XXX_Merge(src proto.Message) {
xxx_messageInfo_ReqCollateralizeBadDebt.Merge(m, src)
}
func (m *ReqCollateralizeBadDebt) XXX_Size() int {
return xxx_messageInfo_ReqCollateralizeBadDebt.Size(m)
}
func (m *ReqCollateralizeBadDebt) XXX_DiscardUnknown() {
xxx_messageInfo_ReqCollateralizeBadDebt.DiscardUnknown(m)
}
var xxx_messageInfo_ReqCollateralizeBadDebt proto.InternalMessageInfo
func (m *ReqCollateralizeBadDebt) GetCollateralizeId() string {
if m != nil {
return m.CollateralizeId
}
return ""
}
type ReqCollateralizeBorrowHistory struct {
CollateralizeId string `protobuf:"bytes,1,opt,name=collateralizeId,proto3" json:"collateralizeId,omitempty"`
Addr string `protobuf:"bytes,2,opt,name=addr,proto3" json:"addr,omitempty"`
Count int32 `protobuf:"varint,4,opt,name=count,proto3" json:"count,omitempty"`
Direction int32 `protobuf:"varint,5,opt,name=direction,proto3" json:"direction,omitempty"`
Index int64 `protobuf:"varint,6,opt,name=index,proto3" json:"index,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *ReqCollateralizeBorrowHistory) Reset() { *m = ReqCollateralizeBorrowHistory{} }
func (m *ReqCollateralizeBorrowHistory) String() string { return proto.CompactTextString(m) }
func (*ReqCollateralizeBorrowHistory) ProtoMessage() {}
func (*ReqCollateralizeBorrowHistory) Descriptor() ([]byte, []int) {
return fileDescriptor_a988fb4a61381972, []int{14}
}
func (m *ReqCollateralizeBorrowHistory) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_ReqCollateralizeBorrowHistory.Unmarshal(m, b)
}
func (m *ReqCollateralizeBorrowHistory) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_ReqCollateralizeBorrowHistory.Marshal(b, m, deterministic)
}
func (m *ReqCollateralizeBorrowHistory) XXX_Merge(src proto.Message) {
xxx_messageInfo_ReqCollateralizeBorrowHistory.Merge(m, src)
}
func (m *ReqCollateralizeBorrowHistory) XXX_Size() int {
return xxx_messageInfo_ReqCollateralizeBorrowHistory.Size(m)
}
func (m *ReqCollateralizeBorrowHistory) XXX_DiscardUnknown() {
xxx_messageInfo_ReqCollateralizeBorrowHistory.DiscardUnknown(m)
}
var xxx_messageInfo_ReqCollateralizeBorrowHistory proto.InternalMessageInfo
func (m *ReqCollateralizeBorrowHistory) GetCollateralizeId() string {
if m != nil {
return m.CollateralizeId
}
return ""
}
func (m *ReqCollateralizeBorrowHistory) GetAddr() string {
if m != nil {
return m.Addr
}
return ""
}
func (m *ReqCollateralizeBorrowHistory) GetCount() int32 {
if m != nil {
return m.Count
}
return 0
}
func (m *ReqCollateralizeBorrowHistory) GetDirection() int32 {
if m != nil {
return m.Direction
}
return 0
}
func (m *ReqCollateralizeBorrowHistory) GetIndex() int64 {
if m != nil {
return m.Index
}
return 0
}
type ReplyCollateralizeCurrentInfo struct {
Status int32 `protobuf:"varint,1,opt,name=status,proto3" json:"status,omitempty"`
TotalBalance int64 `protobuf:"varint,2,opt,name=totalBalance,proto3" json:"totalBalance,omitempty"`
DebtCeiling int64 `protobuf:"varint,3,opt,name=debtCeiling,proto3" json:"debtCeiling,omitempty"`
LiquidationRatio float32 `protobuf:"fixed32,4,opt,name=liquidationRatio,proto3" json:"liquidationRatio,omitempty"`
StabilityFee int64 `protobuf:"varint,5,opt,name=stabilityFee,proto3" json:"stabilityFee,omitempty"`
LiquidationPenalty int64 `protobuf:"varint,6,opt,name=liquidationPenalty,proto3" json:"liquidationPenalty,omitempty"`
CreateAddr string `protobuf:"bytes,7,opt,name=createAddr,proto3" json:"createAddr,omitempty"`
Balance int64 `protobuf:"varint,8,opt,name=balance,proto3" json:"balance,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *ReplyCollateralizeCurrentInfo) Reset() { *m = ReplyCollateralizeCurrentInfo{} }
func (m *ReplyCollateralizeCurrentInfo) String() string { return proto.CompactTextString(m) }
func (*ReplyCollateralizeCurrentInfo) ProtoMessage() {}
func (*ReplyCollateralizeCurrentInfo) Descriptor() ([]byte, []int) {
return fileDescriptor_a988fb4a61381972, []int{15}
}
func (m *ReplyCollateralizeCurrentInfo) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_ReplyCollateralizeCurrentInfo.Unmarshal(m, b)
}
func (m *ReplyCollateralizeCurrentInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_ReplyCollateralizeCurrentInfo.Marshal(b, m, deterministic)
}
func (m *ReplyCollateralizeCurrentInfo) XXX_Merge(src proto.Message) {
xxx_messageInfo_ReplyCollateralizeCurrentInfo.Merge(m, src)
}
func (m *ReplyCollateralizeCurrentInfo) XXX_Size() int {
return xxx_messageInfo_ReplyCollateralizeCurrentInfo.Size(m)
}
func (m *ReplyCollateralizeCurrentInfo) XXX_DiscardUnknown() {
xxx_messageInfo_ReplyCollateralizeCurrentInfo.DiscardUnknown(m)
}
var xxx_messageInfo_ReplyCollateralizeCurrentInfo proto.InternalMessageInfo
func (m *ReplyCollateralizeCurrentInfo) GetStatus() int32 {
if m != nil {
return m.Status
}
return 0
}
func (m *ReplyCollateralizeCurrentInfo) GetTotalBalance() int64 {
if m != nil {
return m.TotalBalance
}
return 0
}
func (m *ReplyCollateralizeCurrentInfo) GetDebtCeiling() int64 {
if m != nil {
return m.DebtCeiling
}
return 0
}
func (m *ReplyCollateralizeCurrentInfo) GetLiquidationRatio() float32 {
if m != nil {
return m.LiquidationRatio
}
return 0
}
func (m *ReplyCollateralizeCurrentInfo) GetStabilityFee() int64 {
if m != nil {
return m.StabilityFee
}
return 0
}
func (m *ReplyCollateralizeCurrentInfo) GetLiquidationPenalty() int64 {
if m != nil {
return m.LiquidationPenalty
}
return 0
}
func (m *ReplyCollateralizeCurrentInfo) GetCreateAddr() string {
if m != nil {
return m.CreateAddr
}
return ""
}
func (m *ReplyCollateralizeCurrentInfo) GetBalance() int64 {
if m != nil {
return m.Balance
}
return 0
}
type ReplyCollateralizeBadDebt struct {
Records []*BorrowRecord `protobuf:"bytes,1,rep,name=records,proto3" json:"records,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *ReplyCollateralizeBadDebt) Reset() { *m = ReplyCollateralizeBadDebt{} }
func (m *ReplyCollateralizeBadDebt) String() string { return proto.CompactTextString(m) }
func (*ReplyCollateralizeBadDebt) ProtoMessage() {}
func (*ReplyCollateralizeBadDebt) Descriptor() ([]byte, []int) {
return fileDescriptor_a988fb4a61381972, []int{16}
}
func (m *ReplyCollateralizeBadDebt) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_ReplyCollateralizeBadDebt.Unmarshal(m, b)
}
func (m *ReplyCollateralizeBadDebt) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_ReplyCollateralizeBadDebt.Marshal(b, m, deterministic)
}
func (m *ReplyCollateralizeBadDebt) XXX_Merge(src proto.Message) {
xxx_messageInfo_ReplyCollateralizeBadDebt.Merge(m, src)
}
func (m *ReplyCollateralizeBadDebt) XXX_Size() int {
return xxx_messageInfo_ReplyCollateralizeBadDebt.Size(m)
}
func (m *ReplyCollateralizeBadDebt) XXX_DiscardUnknown() {
xxx_messageInfo_ReplyCollateralizeBadDebt.DiscardUnknown(m)
}
var xxx_messageInfo_ReplyCollateralizeBadDebt proto.InternalMessageInfo
func (m *ReplyCollateralizeBadDebt) GetRecords() []*BorrowRecord {
if m != nil {
return m.Records
}
return nil
}
// used for execlocal
type CollateralizeBorrowRecord struct {
CollateralizeId string `protobuf:"bytes,1,opt,name=collateralizeId,proto3" json:"collateralizeId,omitempty"`
Value int64 `protobuf:"varint,2,opt,name=value,proto3" json:"value,omitempty"`
Index int64 `protobuf:"varint,3,opt,name=index,proto3" json:"index,omitempty"`
Time int64 `protobuf:"varint,4,opt,name=time,proto3" json:"time,omitempty"`
TxHash string `protobuf:"bytes,5,opt,name=txHash,proto3" json:"txHash,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *CollateralizeBorrowRecord) Reset() { *m = CollateralizeBorrowRecord{} }
func (m *CollateralizeBorrowRecord) String() string { return proto.CompactTextString(m) }
func (*CollateralizeBorrowRecord) ProtoMessage() {}
func (*CollateralizeBorrowRecord) Descriptor() ([]byte, []int) {
return fileDescriptor_a988fb4a61381972, []int{17}
}
func (m *CollateralizeBorrowRecord) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_CollateralizeBorrowRecord.Unmarshal(m, b)
}
func (m *CollateralizeBorrowRecord) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_CollateralizeBorrowRecord.Marshal(b, m, deterministic)
}
func (m *CollateralizeBorrowRecord) XXX_Merge(src proto.Message) {
xxx_messageInfo_CollateralizeBorrowRecord.Merge(m, src)
}
func (m *CollateralizeBorrowRecord) XXX_Size() int {
return xxx_messageInfo_CollateralizeBorrowRecord.Size(m)
}
func (m *CollateralizeBorrowRecord) XXX_DiscardUnknown() {
xxx_messageInfo_CollateralizeBorrowRecord.DiscardUnknown(m)
}
var xxx_messageInfo_CollateralizeBorrowRecord proto.InternalMessageInfo
func (m *CollateralizeBorrowRecord) GetCollateralizeId() string {
if m != nil {
return m.CollateralizeId
}
return ""
}
func (m *CollateralizeBorrowRecord) GetValue() int64 {
if m != nil {
return m.Value
}
return 0
}
func (m *CollateralizeBorrowRecord) GetIndex() int64 {
if m != nil {
return m.Index
}
return 0
}
func (m *CollateralizeBorrowRecord) GetTime() int64 {
if m != nil {
return m.Time
}
return 0
}
func (m *CollateralizeBorrowRecord) GetTxHash() string {
if m != nil {
return m.TxHash
}
return ""
}
type CollateralizeBorrowRecords struct {
Records []*CollateralizeBorrowRecord `protobuf:"bytes,1,rep,name=records,proto3" json:"records,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *CollateralizeBorrowRecords) Reset() { *m = CollateralizeBorrowRecords{} }
func (m *CollateralizeBorrowRecords) String() string { return proto.CompactTextString(m) }
func (*CollateralizeBorrowRecords) ProtoMessage() {}
func (*CollateralizeBorrowRecords) Descriptor() ([]byte, []int) {
return fileDescriptor_a988fb4a61381972, []int{18}
}
func (m *CollateralizeBorrowRecords) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_CollateralizeBorrowRecords.Unmarshal(m, b)
}
func (m *CollateralizeBorrowRecords) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_CollateralizeBorrowRecords.Marshal(b, m, deterministic)
}
func (m *CollateralizeBorrowRecords) XXX_Merge(src proto.Message) {
xxx_messageInfo_CollateralizeBorrowRecords.Merge(m, src)
}
func (m *CollateralizeBorrowRecords) XXX_Size() int {
return xxx_messageInfo_CollateralizeBorrowRecords.Size(m)
}
func (m *CollateralizeBorrowRecords) XXX_DiscardUnknown() {
xxx_messageInfo_CollateralizeBorrowRecords.DiscardUnknown(m)
}
var xxx_messageInfo_CollateralizeBorrowRecords proto.InternalMessageInfo
func (m *CollateralizeBorrowRecords) GetRecords() []*CollateralizeBorrowRecord {
if m != nil {
return m.Records
}
return nil
}
type CollateralizeRepayRecord struct {
CollateralizeId string `protobuf:"bytes,1,opt,name=collateralizeId,proto3" json:"collateralizeId,omitempty"`
Value int64 `protobuf:"varint,2,opt,name=value,proto3" json:"value,omitempty"`
Index int64 `protobuf:"varint,3,opt,name=index,proto3" json:"index,omitempty"`
Time int64 `protobuf:"varint,4,opt,name=time,proto3" json:"time,omitempty"`
TxHash string `protobuf:"bytes,5,opt,name=txHash,proto3" json:"txHash,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *CollateralizeRepayRecord) Reset() { *m = CollateralizeRepayRecord{} }
func (m *CollateralizeRepayRecord) String() string { return proto.CompactTextString(m) }
func (*CollateralizeRepayRecord) ProtoMessage() {}
func (*CollateralizeRepayRecord) Descriptor() ([]byte, []int) {
return fileDescriptor_a988fb4a61381972, []int{19}
}
func (m *CollateralizeRepayRecord) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_CollateralizeRepayRecord.Unmarshal(m, b)
}
func (m *CollateralizeRepayRecord) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_CollateralizeRepayRecord.Marshal(b, m, deterministic)
}
func (m *CollateralizeRepayRecord) XXX_Merge(src proto.Message) {
xxx_messageInfo_CollateralizeRepayRecord.Merge(m, src)
}
func (m *CollateralizeRepayRecord) XXX_Size() int {
return xxx_messageInfo_CollateralizeRepayRecord.Size(m)
}
func (m *CollateralizeRepayRecord) XXX_DiscardUnknown() {
xxx_messageInfo_CollateralizeRepayRecord.DiscardUnknown(m)
}
var xxx_messageInfo_CollateralizeRepayRecord proto.InternalMessageInfo
func (m *CollateralizeRepayRecord) GetCollateralizeId() string {
if m != nil {
return m.CollateralizeId
}
return ""
}
func (m *CollateralizeRepayRecord) GetValue() int64 {
if m != nil {
return m.Value
}
return 0
}
func (m *CollateralizeRepayRecord) GetIndex() int64 {
if m != nil {
return m.Index
}
return 0
}
func (m *CollateralizeRepayRecord) GetTime() int64 {
if m != nil {
return m.Time
}
return 0
}
func (m *CollateralizeRepayRecord) GetTxHash() string {
if m != nil {
return m.TxHash
}
return ""
}
type CollateralizeRepayRecords struct {
Records []*CollateralizeRepayRecord `protobuf:"bytes,1,rep,name=records,proto3" json:"records,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *CollateralizeRepayRecords) Reset() { *m = CollateralizeRepayRecords{} }
func (m *CollateralizeRepayRecords) String() string { return proto.CompactTextString(m) }
func (*CollateralizeRepayRecords) ProtoMessage() {}
func (*CollateralizeRepayRecords) Descriptor() ([]byte, []int) {
return fileDescriptor_a988fb4a61381972, []int{20}
}
func (m *CollateralizeRepayRecords) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_CollateralizeRepayRecords.Unmarshal(m, b)
}
func (m *CollateralizeRepayRecords) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_CollateralizeRepayRecords.Marshal(b, m, deterministic)
}
func (m *CollateralizeRepayRecords) XXX_Merge(src proto.Message) {
xxx_messageInfo_CollateralizeRepayRecords.Merge(m, src)
}
func (m *CollateralizeRepayRecords) XXX_Size() int {
return xxx_messageInfo_CollateralizeRepayRecords.Size(m)
}
func (m *CollateralizeRepayRecords) XXX_DiscardUnknown() {
xxx_messageInfo_CollateralizeRepayRecords.DiscardUnknown(m)
}
var xxx_messageInfo_CollateralizeRepayRecords proto.InternalMessageInfo
func (m *CollateralizeRepayRecords) GetRecords() []*CollateralizeRepayRecord {
if m != nil {
return m.Records
}
return nil
}
func init() {
proto.RegisterType((*Collateralize)(nil), "types.Collateralize")
proto.RegisterType((*BorrowRecord)(nil), "types.BorrowRecord")
proto.RegisterType((*AssetPriceRecord)(nil), "types.AssetPriceRecord")
proto.RegisterType((*CollateralizeAction)(nil), "types.CollateralizeAction")
proto.RegisterType((*CollateralizeCreate)(nil), "types.CollateralizeCreate")
proto.RegisterType((*CollateralizeBorrow)(nil), "types.CollateralizeBorrow")
proto.RegisterType((*CollateralizeRepay)(nil), "types.CollateralizeRepay")
proto.RegisterType((*CollateralizeAppend)(nil), "types.CollateralizeAppend")
proto.RegisterType((*CollateralizeFeed)(nil), "types.CollateralizeFeed")
proto.RegisterType((*CollateralizeClose)(nil), "types.CollateralizeClose")
proto.RegisterType((*ReceiptCollateralize)(nil), "types.ReceiptCollateralize")
proto.RegisterType((*ReqCollateralizeInfo)(nil), "types.ReqCollateralizeInfo")
proto.RegisterType((*ReqCollateralizeBorrowInfo)(nil), "types.ReqCollateralizeBorrowInfo")
proto.RegisterType((*ReqCollateralizeBadDebt)(nil), "types.ReqCollateralizeBadDebt")
proto.RegisterType((*ReqCollateralizeBorrowHistory)(nil), "types.ReqCollateralizeBorrowHistory")
proto.RegisterType((*ReplyCollateralizeCurrentInfo)(nil), "types.ReplyCollateralizeCurrentInfo")
proto.RegisterType((*ReplyCollateralizeBadDebt)(nil), "types.ReplyCollateralizeBadDebt")
proto.RegisterType((*CollateralizeBorrowRecord)(nil), "types.CollateralizeBorrowRecord")
proto.RegisterType((*CollateralizeBorrowRecords)(nil), "types.CollateralizeBorrowRecords")
proto.RegisterType((*CollateralizeRepayRecord)(nil), "types.CollateralizeRepayRecord")
proto.RegisterType((*CollateralizeRepayRecords)(nil), "types.CollateralizeRepayRecords")
}
func init() { proto.RegisterFile("collateralize.proto", fileDescriptor_a988fb4a61381972) }
var fileDescriptor_a988fb4a61381972 = []byte{
// 959 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe4, 0x57, 0x4f, 0x8f, 0xdb, 0x44,
0x14, 0xaf, 0x9d, 0x38, 0x69, 0x5e, 0x76, 0xa1, 0xcc, 0x56, 0xe0, 0x5d, 0x95, 0x62, 0x8d, 0x38,
0x44, 0x48, 0x44, 0x62, 0xcb, 0xa5, 0x1c, 0x10, 0xd9, 0xa0, 0x6a, 0xcb, 0xa9, 0x32, 0x4b, 0x85,
0xb8, 0x8d, 0xed, 0x29, 0xb5, 0x64, 0x6c, 0x77, 0x3c, 0x29, 0x6b, 0xce, 0x5c, 0xf8, 0x0e, 0x70,
0xe6, 0xc2, 0x1d, 0xbe, 0x0b, 0x77, 0x3e, 0x07, 0x9a, 0x37, 0x93, 0xb5, 0x3d, 0x8e, 0xa5, 0x84,
0xbd, 0x20, 0xf5, 0xb2, 0xca, 0xbc, 0xf7, 0x7b, 0xf3, 0xfe, 0xfd, 0xfc, 0xe6, 0x2d, 0x9c, 0xc4,
0x45, 0x96, 0x31, 0xc9, 0x05, 0xcb, 0xd2, 0x9f, 0xf8, 0xb2, 0x14, 0x85, 0x2c, 0x88, 0x27, 0xeb,
0x92, 0x57, 0xf4, 0x97, 0x31, 0x1c, 0xaf, 0xdb, 0x6a, 0xb2, 0x80, 0xb7, 0x3b, 0xf8, 0xa7, 0x89,
0xef, 0x04, 0xce, 0x62, 0x16, 0xda, 0x62, 0x42, 0xe1, 0x48, 0x16, 0x92, 0x65, 0x17, 0x2c, 0x63,
0x79, 0xcc, 0x7d, 0x37, 0x70, 0x16, 0xa3, 0xb0, 0x23, 0x23, 0x01, 0xcc, 0x13, 0x1e, 0xc9, 0x35,
0x4f, 0xb3, 0x34, 0xff, 0xde, 0x1f, 0x21, 0xa4, 0x2d, 0x22, 0x1f, 0xc1, 0xbd, 0x2c, 0x7d, 0xb5,
0x49, 0x13, 0x26, 0xd3, 0x22, 0x0f, 0xd5, 0x5f, 0x7f, 0x1c, 0x38, 0x0b, 0x37, 0xec, 0xc9, 0x95,
0xc7, 0x4a, 0xb2, 0x28, 0xcd, 0x52, 0x59, 0x3f, 0xe1, 0xdc, 0xf7, 0xb4, 0xc7, 0xb6, 0x8c, 0x2c,
0x81, 0xb4, 0xec, 0x9e, 0xf1, 0x9c, 0x65, 0xb2, 0xf6, 0x27, 0x88, 0xdc, 0xa1, 0x21, 0x0f, 0x01,
0x62, 0xc1, 0x99, 0xe4, 0xab, 0x24, 0x11, 0xfe, 0x14, 0x53, 0x6d, 0x49, 0x88, 0x0f, 0xd3, 0xc8,
0x24, 0x78, 0x17, 0x2f, 0xd9, 0x1e, 0xc9, 0x63, 0x38, 0x8e, 0x0a, 0x21, 0x8a, 0x1f, 0x43, 0x1e,
0x17, 0x22, 0xa9, 0xfc, 0x59, 0x30, 0x5a, 0xcc, 0xcf, 0x4f, 0x96, 0x58, 0xda, 0xe5, 0x45, 0x4b,
0x17, 0x76, 0x91, 0xe4, 0x11, 0x40, 0xc4, 0x92, 0xad, 0x1d, 0x0c, 0xdb, 0xb5, 0x60, 0xe4, 0x5d,
0x98, 0x54, 0x92, 0xc9, 0x4d, 0xe5, 0xcf, 0x03, 0x67, 0xe1, 0x85, 0xe6, 0x44, 0xce, 0xe0, 0xae,
0x6a, 0xcd, 0x55, 0x5d, 0x72, 0xff, 0x08, 0x35, 0x37, 0x67, 0xac, 0x2e, 0x93, 0xbc, 0x92, 0x21,
0x2f, 0x59, 0xfd, 0x4c, 0xa4, 0x31, 0xf7, 0x8f, 0x4d, 0x75, 0x2d, 0x39, 0xfd, 0xd9, 0x85, 0xa3,
0xb6, 0x73, 0xd5, 0x3c, 0x16, 0xc7, 0xc5, 0x26, 0x97, 0x58, 0x1b, 0x4d, 0x83, 0xb6, 0x88, 0x3c,
0x80, 0x59, 0x25, 0x99, 0x90, 0x57, 0xe9, 0x0f, 0xdb, 0xfe, 0x37, 0x82, 0x2e, 0x95, 0x9e, 0xb3,
0x6c, 0xc3, 0x0d, 0x01, 0x6c, 0x71, 0x17, 0xa9, 0xa3, 0xd4, 0x1c, 0xb0, 0xc5, 0xca, 0xa3, 0x62,
0x8f, 0xbe, 0x4d, 0xf7, 0xbf, 0x11, 0x58, 0x64, 0xd2, 0x17, 0x4d, 0x7a, 0x64, 0xd2, 0x37, 0x35,
0xe5, 0x9c, 0xb6, 0xcb, 0x49, 0xff, 0x70, 0xe0, 0xde, 0xaa, 0xaa, 0xb8, 0x44, 0x98, 0x29, 0xc5,
0x43, 0x00, 0x81, 0xbf, 0x30, 0x53, 0x5d, 0x89, 0x96, 0x44, 0xf5, 0x20, 0x92, 0xa6, 0xbe, 0x2e,
0x3a, 0xbc, 0x39, 0x6b, 0x5d, 0xac, 0x75, 0xa3, 0xad, 0x2e, 0xbe, 0xd1, 0x71, 0xf9, 0xb2, 0x9d,
0xf1, 0xcd, 0x99, 0x7c, 0x08, 0xc7, 0xa5, 0x30, 0x01, 0xa0, 0x5b, 0x0f, 0xdd, 0x76, 0x85, 0xf4,
0x1f, 0x17, 0x4e, 0x3a, 0x5f, 0xf0, 0x2a, 0x56, 0x39, 0x92, 0x4f, 0x61, 0xa2, 0x59, 0x8c, 0xd1,
0xce, 0xcf, 0xcf, 0x0c, 0xbd, 0x3a, 0xd8, 0x35, 0x22, 0x2e, 0xef, 0x84, 0x06, 0xab, 0xac, 0x34,
0x53, 0x31, 0x8b, 0x01, 0x2b, 0x4d, 0x12, 0x65, 0xa5, 0xb1, 0xe4, 0x13, 0xf0, 0x84, 0xe2, 0x11,
0xa6, 0x37, 0x3f, 0x3f, 0xdd, 0x65, 0x84, 0x44, 0xbb, 0xbc, 0x13, 0x6a, 0xa4, 0x72, 0xc4, 0xca,
0x92, 0xe7, 0x09, 0xa6, 0x3d, 0xe0, 0x68, 0x85, 0x08, 0xe5, 0x48, 0x63, 0xc9, 0x12, 0xc6, 0x2f,
0x38, 0x4f, 0xb0, 0x12, 0xf3, 0x73, 0x7f, 0x97, 0xcd, 0x13, 0xce, 0x95, 0x05, 0xe2, 0x54, 0x60,
0x71, 0x56, 0x54, 0x9a, 0x04, 0x03, 0x81, 0xad, 0x15, 0x40, 0x05, 0x86, 0x48, 0xf2, 0x16, 0xb8,
0xb2, 0xf6, 0x01, 0x29, 0xe1, 0xca, 0xfa, 0x62, 0x0a, 0xde, 0x6b, 0xc5, 0x2d, 0xfa, 0xb7, 0x63,
0x15, 0x5a, 0x17, 0xcf, 0x1e, 0x71, 0xce, 0x7e, 0x23, 0xce, 0xdd, 0x73, 0xc4, 0x8d, 0xf6, 0x1e,
0x71, 0xe3, 0xc1, 0x11, 0x67, 0x0f, 0x6a, 0xaf, 0x3f, 0xa8, 0xe9, 0x37, 0x56, 0x72, 0xba, 0xc7,
0x07, 0xbc, 0x06, 0xf7, 0x4d, 0x9d, 0xcc, 0x18, 0x30, 0x45, 0xbb, 0x02, 0xd2, 0x67, 0xc1, 0xad,
0x6f, 0x4d, 0x6d, 0xca, 0x6b, 0x76, 0xec, 0x7f, 0xed, 0x8e, 0xc9, 0xe4, 0xee, 0x9c, 0x4c, 0x74,
0x05, 0xef, 0xf4, 0xe8, 0xa5, 0xa2, 0x2a, 0xf1, 0x93, 0x75, 0x82, 0x91, 0x8a, 0xaa, 0xdc, 0x0e,
0x94, 0xd7, 0x45, 0xb6, 0xc1, 0x49, 0xa8, 0xc4, 0xe6, 0x44, 0x3f, 0xb7, 0x6a, 0x80, 0x84, 0xdb,
0x3f, 0x58, 0xfa, 0x97, 0x03, 0xf7, 0x43, 0x1e, 0xf3, 0xb4, 0x94, 0xff, 0xf5, 0xa9, 0xee, 0x3e,
0x72, 0xa3, 0xde, 0x23, 0x67, 0x4d, 0xfa, 0x71, 0x7f, 0xd2, 0x37, 0xd3, 0x72, 0xd6, 0x79, 0x7c,
0x1e, 0xc0, 0xac, 0x14, 0xfc, 0x6b, 0xad, 0xd2, 0x5f, 0x4d, 0x23, 0xa0, 0x5f, 0xa8, 0xc8, 0x5f,
0x75, 0xa2, 0x7e, 0x9a, 0xbf, 0x28, 0x0e, 0x48, 0xfe, 0x3b, 0x38, 0xb3, 0x6f, 0xd0, 0xd4, 0x3c,
0xec, 0x1e, 0x42, 0x60, 0xcc, 0x54, 0x6a, 0x2e, 0xaa, 0xf1, 0x37, 0x5d, 0xc3, 0x7b, 0xbd, 0xbb,
0x59, 0xf2, 0x25, 0x8f, 0xe4, 0x01, 0x01, 0xfe, 0xee, 0xc0, 0xfb, 0xbb, 0x23, 0xbc, 0x4c, 0x2b,
0x59, 0x88, 0xfa, 0x76, 0x41, 0x2a, 0xae, 0x61, 0x17, 0xb0, 0x29, 0x5e, 0xa8, 0x0f, 0xf8, 0x0c,
0xa6, 0x82, 0xe3, 0xa8, 0xc7, 0xef, 0xd9, 0x0b, 0x1b, 0x81, 0xb2, 0x49, 0xf3, 0x84, 0x5f, 0x9b,
0xb5, 0x47, 0x1f, 0xe8, 0x9f, 0xae, 0x8a, 0xb4, 0xcc, 0xea, 0x2e, 0x1b, 0x37, 0x42, 0xf0, 0x5c,
0x62, 0x39, 0x9b, 0x26, 0x3b, 0x9d, 0x26, 0xbf, 0xe1, 0x9b, 0x1e, 0xfd, 0x0a, 0x4e, 0xfb, 0x85,
0xdb, 0x52, 0xe5, 0x63, 0x98, 0x0a, 0xb3, 0xc8, 0x39, 0xc3, 0x8b, 0xdc, 0x16, 0x43, 0x7f, 0x73,
0xe0, 0x74, 0x07, 0x59, 0xcc, 0x9e, 0x71, 0xcb, 0xc9, 0xd8, 0x74, 0x7e, 0xd4, 0xea, 0xbc, 0xe2,
0x95, 0x54, 0x0b, 0x84, 0x7e, 0x22, 0xf0, 0xb7, 0xea, 0xb5, 0xbc, 0xbe, 0x64, 0xd5, 0x4b, 0xb3,
0x56, 0x98, 0x13, 0xfd, 0x16, 0xce, 0x06, 0xc3, 0xab, 0xc8, 0x67, 0x76, 0xb2, 0xc1, 0xf0, 0x82,
0x60, 0x67, 0xfe, 0xab, 0x03, 0x7e, 0xff, 0x31, 0xf8, 0xdf, 0x24, 0xfe, 0xdc, 0xea, 0x4b, 0x2b,
0xba, 0x8a, 0x3c, 0xb6, 0xf3, 0xfe, 0x60, 0x70, 0xc7, 0xb1, 0xd2, 0x8e, 0x26, 0xf8, 0x0f, 0xd7,
0xa3, 0x7f, 0x03, 0x00, 0x00, 0xff, 0xff, 0x62, 0xe5, 0xa0, 0xb5, 0x87, 0x0d, 0x00, 0x00,
}
// Copyright Fuzamei Corp. 2018 All Rights Reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package types
import "errors"
// Errors for lottery
var (
ErrRiskParam = errors.New("ErrRiskParam")
ErrCollateralizeRepeatHash = errors.New("ErrCollateralizeRepeatHash")
ErrCollateralizeStatus = errors.New("ErrCollateralizeStatus")
ErrCollateralizeExceedDebtCeiling = errors.New("ErrCollateralizeExceedDebtCeiling")
ErrPriceZero = errors.New("ErrPriceZero")
ErrAssetType = errors.New("ErrAssetType")
ErrRecordNotExist = errors.New("ErrRecordNotExist")
ErrCollateralizeErrCloser = errors.New("ErrCollateralizeErrCloser")
ErrRepayValueInsufficient = errors.New("ErrRepayValueInsufficient")
)
// Copyright Fuzamei Corp. 2018 All Rights Reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package types
// CollateralizeCreateTx for construction
type CollateralizeCreateTx struct {
DebtCeiling int64 `json:"debtCeiling"`
LiquidationRatio float32 `json:"liquidationRatio"`
StabilityFee int64 `json:"stabilityFee"`
LiquidationPenalty int64 `json:"liquidationPenalty"`
TotalBalance int64 `json:"totalBalance"`
Fee int64 `json:"fee"`
}
// CollateralizeBorrowTx for construction
type CollateralizeBorrowTx struct {
CollateralizeID string `json:"collateralizeId"`
Value int64 `json:"value"`
Fee int64 `json:"fee"`
}
// CollateralizeRepayTx for construction
type CollateralizeRepayTx struct {
CollateralizeID string `json:"collateralizeId"`
Value int64 `json:"value"`
Fee int64 `json:"fee"`
}
// CollateralizeAppednTx for construction
type CollateralizeAppendTx struct {
CollateralizeID string `json:"collateralizeId"`
Value int64 `json:"value"`
Fee int64 `json:"fee"`
}
// CollateralizeFeedTx for construction
type CollateralizeFeedTx struct {
Price []int64 `json:"price"`
Volume []int64 `json:"volume"`
Fee int64 `json:"fee"`
}
// CollateralizeCloseTx for construction
type CollateralizeCloseTx struct {
CollateralizeID string `json:"CollateralizeId"`
Fee int64 `json:"fee"`
}
// Copyright Fuzamei Corp. 2018 All Rights Reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package types
//Collateralize op
const (
CollateralizeActionCreate = 1 + iota
CollateralizeActionBorrow
CollateralizeActionRepay
CollateralizeActionAppend
CollateralizeActionFeed
CollateralizeActionClose
//log for Collateralize
TyLogCollateralizeCreate = 801
TyLogCollateralizeBorrow = 802
TyLogCollateralizeRepay = 803
TyLogCollateralizeAppend = 804
TyLogCollateralizeFeed = 805
TyLogCollateralizeClose = 806
)
// Collateralize name
const (
CollateralizeX = "collateralize"
CCNYTokenName = "ccny"
CollateralizeRepayRatio = 1.1 //TODO 清算比例,抵押物价值跌到借出ccny价值110%的时候开始清算
)
//Collateralize status
const (
CollateralizeStatusCreated = 1 + iota
CollateralizeStatusClose
)
const (
CollateralizeAssetTypeBty = 1 + iota
CollateralizeAssetTypeBtc
CollateralizeAssetTypeEth
)
const (
CollateralizeUserStatusCreate = 1 + iota
CollateralizeUserStatusWarning
CollateralizeUserStatusSystemRepayed
CollateralizeUserStatusClose
)
\ 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