Commit 2f57d651 authored by pengjun's avatar pengjun

#627 update balance value to float64

parent 2e4b635d
......@@ -44,7 +44,7 @@ func CollateralizeCreateRawTxCmd() *cobra.Command {
}
func addCollateralizeCreateFlags(cmd *cobra.Command) {
cmd.Flags().Uint64P("balance", "b", 0, "balance")
cmd.Flags().Float64P("balance", "b", 0, "balance")
cmd.MarkFlagRequired("balance")
}
......@@ -56,12 +56,12 @@ func CollateralizeCreate(cmd *cobra.Command, args []string) {
}
rpcLaddr, _ := cmd.Flags().GetString("rpc_laddr")
balance, _ := cmd.Flags().GetUint64("balance")
balance, _ := cmd.Flags().GetFloat64("balance")
params := &rpctypes.CreateTxIn{
Execer: cfg.ExecName(pkt.CollateralizeX),
ActionName: "CollateralizeCreate",
Payload: []byte(fmt.Sprintf("{\"totalBalance\":%d}", balance)),
Payload: []byte(fmt.Sprintf("{\"totalBalance\":%f}", balance)),
}
var res string
......@@ -83,7 +83,7 @@ func CollateralizeBorrowRawTxCmd() *cobra.Command {
func addCollateralizeBorrowFlags(cmd *cobra.Command) {
cmd.Flags().StringP("collateralizeID", "g", "", "collateralize ID")
cmd.MarkFlagRequired("collateralizeID")
cmd.Flags().Uint64P("value", "v", 0, "value")
cmd.Flags().Float64P("value", "v", 0, "value")
cmd.MarkFlagRequired("value")
}
......@@ -96,12 +96,12 @@ func CollateralizeBorrow(cmd *cobra.Command, args []string) {
rpcLaddr, _ := cmd.Flags().GetString("rpc_laddr")
collateralizeID, _ := cmd.Flags().GetString("collateralizeID")
value, _ := cmd.Flags().GetUint64("value")
value, _ := cmd.Flags().GetFloat64("value")
params := &rpctypes.CreateTxIn{
Execer: cfg.ExecName(pkt.CollateralizeX),
ActionName: "CollateralizeBorrow",
Payload: []byte(fmt.Sprintf("{\"collateralizeID\":\"%s\",\"value\":%d}", collateralizeID, value)),
Payload: []byte(fmt.Sprintf("{\"collateralizeID\":\"%s\",\"value\":%f}", collateralizeID, value)),
}
var res string
......@@ -125,7 +125,7 @@ func addCollateralizeAppendFlags(cmd *cobra.Command) {
cmd.MarkFlagRequired("collateralizeID")
cmd.Flags().StringP("recordID", "r", "", "recordID")
cmd.MarkFlagRequired("recordID")
cmd.Flags().Uint64P("value", "v", 0, "value")
cmd.Flags().Float64P("value", "v", 0, "value")
cmd.MarkFlagRequired("value")
}
......@@ -139,12 +139,12 @@ func CollateralizeAppend(cmd *cobra.Command, args []string) {
rpcLaddr, _ := cmd.Flags().GetString("rpc_laddr")
collateralizeID, _ := cmd.Flags().GetString("collateralizeID")
recordID, _ := cmd.Flags().GetString("recordID")
value, _ := cmd.Flags().GetUint64("value")
value, _ := cmd.Flags().GetFloat64("value")
params := &rpctypes.CreateTxIn{
Execer: cfg.ExecName(pkt.CollateralizeX),
ActionName: "CollateralizeAppend",
Payload: []byte(fmt.Sprintf("{\"collateralizeID\":\"%s\", \"recordID\":\"%s\", \"value\":%d}", collateralizeID, recordID, value)),
Payload: []byte(fmt.Sprintf("{\"collateralizeID\":\"%s\", \"recordID\":\"%s\", \"value\":%f}", collateralizeID, recordID, value)),
}
var res string
......@@ -204,7 +204,7 @@ func CollateralizePriceFeedRawTxCmd() *cobra.Command {
}
func addCollateralizePriceFeedFlags(cmd *cobra.Command) {
cmd.Flags().Float32P("price", "p", 0, "price")
cmd.Flags().Float64P("price", "p", 0, "price")
cmd.MarkFlagRequired("price")
cmd.Flags().Uint64P("volume", "v", 0, "volume")
cmd.MarkFlagRequired("volume")
......@@ -246,7 +246,7 @@ func CollateralizeRetrieveRawTxCmd() *cobra.Command {
func addCollateralizeRetrieveFlags(cmd *cobra.Command) {
cmd.Flags().StringP("collateralizeID", "g", "", "collateralize ID")
cmd.MarkFlagRequired("collateralizeID")
cmd.Flags().StringP("balance", "b", "", "retrieve balance")
cmd.Flags().Float64P("balance", "b", 0, "retrieve balance")
cmd.MarkFlagRequired("balance")
}
......@@ -259,12 +259,12 @@ func CollateralizeRetrieve(cmd *cobra.Command, args []string) {
rpcLaddr, _ := cmd.Flags().GetString("rpc_laddr")
collateralizeID, _ := cmd.Flags().GetString("collateralizeID")
balance, _ := cmd.Flags().GetInt64("balance")
balance, _ := cmd.Flags().GetFloat64("balance")
params := &rpctypes.CreateTxIn{
Execer: cfg.ExecName(pkt.CollateralizeX),
ActionName: "CollateralizeRetrieve",
Payload: []byte(fmt.Sprintf("{\"collateralizeID\":\"%s\", \"balance\": %d}", collateralizeID, balance)),
Payload: []byte(fmt.Sprintf("{\"collateralizeID\":\"%s\", \"balance\": %f}", collateralizeID, balance)),
}
var res string
......@@ -284,11 +284,11 @@ func CollateralizeManageRawTxCmd() *cobra.Command {
}
func addCollateralizeManageFlags(cmd *cobra.Command) {
cmd.Flags().Uint64P("debtCeiling", "d", 0, "debtCeiling")
cmd.Flags().Float32P("liquidationRatio", "l", 0, "liquidationRatio")
cmd.Flags().Float32P("stabilityFeeRatio", "s", 0, "stabilityFeeRatio")
cmd.Flags().Float64P("debtCeiling", "d", 0, "debtCeiling")
cmd.Flags().Float64P("liquidationRatio", "l", 0, "liquidationRatio")
cmd.Flags().Float64P("stabilityFeeRatio", "s", 0, "stabilityFeeRatio")
cmd.Flags().Uint64P("period", "p", 0, "period")
cmd.Flags().Uint64P("totalBalance", "t", 0, "totalBalance")
cmd.Flags().Float64P("totalBalance", "t", 0, "totalBalance")
}
func CollateralizeManage(cmd *cobra.Command, args []string) {
......@@ -299,16 +299,16 @@ func CollateralizeManage(cmd *cobra.Command, args []string) {
}
rpcLaddr, _ := cmd.Flags().GetString("rpc_laddr")
debtCeiling, _ := cmd.Flags().GetUint64("debtCeiling")
debtCeiling, _ := cmd.Flags().GetFloat32("debtCeiling")
liquidationRatio, _ := cmd.Flags().GetFloat32("liquidationRatio")
stabilityFeeRatio, _ := cmd.Flags().GetFloat32("stabilityFeeRatio")
period, _ := cmd.Flags().GetUint64("period")
totalBalance, _ := cmd.Flags().GetUint64("totalBalance")
totalBalance, _ := cmd.Flags().GetFloat32("totalBalance")
params := &rpctypes.CreateTxIn{
Execer: cfg.ExecName(pkt.CollateralizeX),
ActionName: "CollateralizeManage",
Payload: []byte(fmt.Sprintf("{\"debtCeiling\":%d, \"liquidationRatio\":%f, \"stabilityFeeRatio\":%f, \"period\":%d, \"totalBalance\":%d}",
Payload: []byte(fmt.Sprintf("{\"debtCeiling\":%f, \"liquidationRatio\":%f, \"stabilityFeeRatio\":%f, \"period\":%d, \"totalBalance\":%f}",
debtCeiling, liquidationRatio, stabilityFeeRatio, period, totalBalance)),
}
......
......@@ -93,6 +93,11 @@ func initEnv() *execEnv {
Frozen: 0,
Addr: string(Nodes[1]),
}
accountBToken := types.Account{
Balance: types.Coin/10,
Frozen: 0,
Addr: string(Nodes[1]),
}
accountC := types.Account{
Balance: total,
Frozen: 0,
......@@ -117,6 +122,8 @@ func initEnv() *execEnv {
accB.SetDB(stateDB)
accB.SaveExecAccount(execAddr, &accountB)
manageKeySet("issuance-price-feed", accountB.Addr, stateDB)
tokenAccB,_ := account.NewAccountDB(cfg, tokenE.GetName(), pkt.CCNYTokenName, stateDB)
tokenAccB.SaveExecAccount(execAddr, &accountBToken)
accC := account.NewCoinsAccount(cfg)
accC.SetDB(stateDB)
......@@ -584,12 +591,3 @@ func signTx(tx *types.Transaction, hexPrivKey string) (*types.Transaction, error
tx.Sign(int32(signType), privKey)
return tx, nil
}
//func TestSlice(t *testing.T) {
// var a []int
// a = append(a, 1)
// fmt.Println(a)
//
// a = append(a[:0], a[1:]...)
// fmt.Println(a)
//}
\ No newline at end of file
......@@ -12,8 +12,9 @@ import (
"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"
issuanceE "github.com/33cn/plugin/plugin/dapp/issuance/types"
tokenE "github.com/33cn/plugin/plugin/dapp/token/executor"
"math"
)
// List control
......@@ -26,11 +27,11 @@ const (
const (
Coin = types.Coin // 1e8
DefaultDebtCeiling = 10000 // 默认借贷限额
DefaultDebtCeiling = 10000 * Coin // 默认借贷限额
DefaultLiquidationRatio = 0.4 // 默认质押比
DefaultStabilityFeeRation = 0.08 // 默认稳定费
DefaultPeriod = 3600 * 24 * 365 // 默认合约限期
DefaultCollTotalBalance = 0 // 默认放贷总额
DefaultTotalBalance = 0 // 默认放贷总额
PriceWarningRate = 1.3 // 价格提前预警率
ExpireWarningTime = 3600 * 24 * 10 // 提前10天超时预警
)
......@@ -226,8 +227,8 @@ func (action *Action) GetIndex() int64 {
return action.height*types.MaxTxsPerBlock + int64(action.index)
}
func getLatestLiquidationPrice(coll *pty.Collateralize) float32 {
var latest float32
func getLatestLiquidationPrice(coll *pty.Collateralize) float64 {
var latest float64
for _, collRecord := range coll.BorrowRecords {
if collRecord.LiquidationPrice > latest {
latest = collRecord.LiquidationPrice
......@@ -273,7 +274,7 @@ func (action *Action) CollateralizeManage(manage *pty.CollateralizeManage) (*typ
LiquidationRatio: DefaultLiquidationRatio,
StabilityFeeRatio: DefaultStabilityFeeRation,
Period: DefaultPeriod,
CollTotalBalance: DefaultCollTotalBalance,
TotalBalance: DefaultTotalBalance,
}
}
......@@ -302,10 +303,10 @@ func (action *Action) CollateralizeManage(manage *pty.CollateralizeManage) (*typ
collConfig.DebtCeiling = manConfig.DebtCeiling
}
if manage.CollTotalBalance != 0 {
collConfig.CollTotalBalance = manage.CollTotalBalance
if manage.TotalBalance != 0 {
collConfig.TotalBalance = manage.TotalBalance
} else {
collConfig.CollTotalBalance = manConfig.CollTotalBalance
collConfig.TotalBalance = manConfig.TotalBalance
}
collConfig.CurrentTime = action.blocktime
......@@ -376,13 +377,13 @@ func (action *Action) CollateralizeCreate(create *pty.CollateralizeCreate) (*typ
// 根据地址查找ID
collateralizeIDs, err := queryCollateralizeByAddr(action.localDB, action.fromaddr, pty.CollateralizeStatusCreated, 0)
if err != types.ErrNotFound {
clog.Error("CollateralizeCreate.queryCollateralizeByAddr", "addr", action.fromaddr)
return nil, pty.ErrCollateralizeRepeatHash
if err != nil && err != types.ErrNotFound {
clog.Error("CollateralizeCreate.queryCollateralizeByAddr", "addr", action.fromaddr, "err", err)
return nil, err
}
// 冻结ccny
receipt, err = action.tokenAccount.ExecFrozen(action.fromaddr, action.execaddr, create.TotalBalance * Coin)
receipt, err = action.tokenAccount.ExecFrozen(action.fromaddr, action.execaddr, create.TotalBalance)
if err != nil {
clog.Error("CollateralizeCreate.Frozen", "addr", action.fromaddr, "execaddr", action.execaddr, "amount", create.TotalBalance)
return nil, err
......@@ -403,7 +404,7 @@ func (action *Action) CollateralizeCreate(create *pty.CollateralizeCreate) (*typ
LiquidationRatio:DefaultLiquidationRatio,
StabilityFeeRatio:DefaultStabilityFeeRation,
Period:DefaultPeriod,
CollTotalBalance:DefaultCollTotalBalance,
TotalBalance:DefaultTotalBalance,
}
} else {
collcfg = cfg
......@@ -429,8 +430,9 @@ func (action *Action) CollateralizeCreate(create *pty.CollateralizeCreate) (*typ
}
coll.Collateralize = *collateralize
coll.TotalBalance += create.TotalBalance
coll.Balance += create.TotalBalance
}
clog.Debug("CollateralizeCreate created", "CollateralizeID", collateralizeID, "TotalBalance", coll.TotalBalance)
clog.Debug("CollateralizeCreate created", "CollateralizeID", collateralizeID, "TotalBalance", create.TotalBalance)
// 保存
coll.Save(action.db)
......@@ -444,29 +446,28 @@ func (action *Action) CollateralizeCreate(create *pty.CollateralizeCreate) (*typ
}
// 根据最近抵押物价格计算需要冻结的BTY数量
func getBtyNumToFrozen(value int64, price float32, ratio float32) (int64,error) {
func getBtyNumToFrozen(value int64, price float64, ratio float64) (int64,error) {
if price == 0 {
clog.Error("Bty price should greate to 0")
return 0, pty.ErrPriceInvalid
}
btyValue := float32(value)/ratio
btyNum := int64(btyValue/price) + 1
return btyNum, nil
valueReal := float64(value)/1e8
btyValue := valueReal/(price * ratio)
return int64(math.Trunc((btyValue+0.0000001)*1e4)) * 1e4, nil
}
// 计算清算价格
// value:借出ccny数量, colValue:抵押物数量, price:抵押物价格
func calcLiquidationPrice(value int64, colValue int64) float32 {
liquidationRation := float32(value) / float32(colValue)
func calcLiquidationPrice(value int64, colValue int64) float64 {
liquidationRation := float64(value) / float64(colValue)
liquidationPrice := liquidationRation * pty.CollateralizePreLiquidationRatio
return liquidationPrice
}
// 获取最近抵押物价格
func getLatestPrice(db dbm.KV) (float32, error) {
func getLatestPrice(db dbm.KV) (float64, error) {
data, err := db.Get(PriceKey())
if err != nil {
clog.Error("getLatestPrice", "get", err)
......@@ -526,10 +527,11 @@ func (action *Action) CollateralizeBorrow(borrow *pty.CollateralizeBorrow) (*typ
}
coll := &CollateralizeDB{*collateralize}
// 借贷金额检查
if borrow.GetValue() <= 0 {
clog.Error("CollateralizeBorrow", "CollID", coll.CollateralizeId, "addr", action.fromaddr, "execaddr", action.execaddr, "borrow value", borrow.GetValue(), "err", types.ErrInvalidParam)
return nil, types.ErrInvalidParam
return nil, types.ErrAmount
}
// 借贷金额不超过个人限额
......@@ -553,7 +555,7 @@ func (action *Action) CollateralizeBorrow(borrow *pty.CollateralizeBorrow) (*typ
}
// 根据价格和需要借贷的金额,计算需要质押的抵押物数量
btyFrozen, err := getBtyNumToFrozen(borrow.Value, lastPrice, coll.LiquidationRatio)
btyFrozen, err := getBtyNumToFrozen(borrow.GetValue(), lastPrice, coll.LiquidationRatio)
if err != nil {
clog.Error("CollateralizeBorrow.getBtyNumToFrozen", "CollID", coll.CollateralizeId, "addr", action.fromaddr, "execaddr", action.execaddr, "err", err)
return nil, err
......@@ -566,7 +568,7 @@ func (action *Action) CollateralizeBorrow(borrow *pty.CollateralizeBorrow) (*typ
}
// 抵押物转账
receipt, err := action.coinsAccount.ExecTransfer(action.fromaddr, coll.CreateAddr, action.execaddr, btyFrozen*Coin)
receipt, err := action.coinsAccount.ExecTransfer(action.fromaddr, coll.CreateAddr, action.execaddr, btyFrozen)
if err != nil {
clog.Error("CollateralizeBorrow.ExecTransfer", "addr", action.fromaddr, "execaddr", action.execaddr, "amount", btyFrozen)
return nil, err
......@@ -575,7 +577,7 @@ func (action *Action) CollateralizeBorrow(borrow *pty.CollateralizeBorrow) (*typ
kv = append(kv, receipt.KV...)
// 抵押物冻结
receipt, err = action.coinsAccount.ExecFrozen(coll.CreateAddr, action.execaddr, btyFrozen*Coin)
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
......@@ -584,9 +586,9 @@ func (action *Action) CollateralizeBorrow(borrow *pty.CollateralizeBorrow) (*typ
kv = append(kv, receipt.KV...)
// 借出ccny
receipt, err = action.tokenAccount.ExecTransferFrozen(coll.CreateAddr, action.fromaddr, action.execaddr, borrow.Value*Coin)
receipt, err = action.tokenAccount.ExecTransferFrozen(coll.CreateAddr, action.fromaddr, action.execaddr, borrow.GetValue())
if err != nil {
clog.Error("CollateralizeBorrow.ExecTokenTransfer", "addr", action.fromaddr, "execaddr", action.execaddr, "amount", borrow.Value)
clog.Error("CollateralizeBorrow.ExecTokenTransfer", "addr", action.fromaddr, "execaddr", action.execaddr, "amount", borrow.GetValue())
return nil, err
}
logs = append(logs, receipt.Logs...)
......@@ -600,7 +602,7 @@ func (action *Action) CollateralizeBorrow(borrow *pty.CollateralizeBorrow) (*typ
borrowRecord.CollateralValue = btyFrozen
borrowRecord.StartTime = action.blocktime
borrowRecord.CollateralPrice = lastPrice
borrowRecord.DebtValue = borrow.Value
borrowRecord.DebtValue = borrow.GetValue()
borrowRecord.LiquidationPrice = coll.LiquidationRatio * lastPrice * pty.CollateralizePreLiquidationRatio
borrowRecord.Status = pty.CollateralizeUserStatusCreate
borrowRecord.ExpireTime = action.blocktime + coll.Period
......@@ -614,7 +616,7 @@ func (action *Action) CollateralizeBorrow(borrow *pty.CollateralizeBorrow) (*typ
// 保存
coll.BorrowRecords = append(coll.BorrowRecords, borrowRecord)
coll.Status = pty.CollateralizeStatusCreated
coll.Balance -= borrow.Value
coll.Balance -= borrow.GetValue()
coll.CollBalance += btyFrozen
coll.LatestExpireTime = getLatestExpireTime(&coll.Collateralize)
coll.Save(action.db)
......@@ -665,16 +667,17 @@ func (action *Action) CollateralizeRepay(repay *pty.CollateralizeRepay) (*types.
}
// 借贷金额+利息
realRepay := borrowRecord.DebtValue + int64(float32(borrowRecord.DebtValue) * coll.StabilityFeeRatio)
fee := (float64(borrowRecord.DebtValue)/1e8) * float64(coll.StabilityFeeRatio)
realRepay := borrowRecord.DebtValue + int64(math.Trunc((fee+0.0000001)*1e4)) * 1e4
// 检查
if !action.CheckExecTokenAccount(action.fromaddr, realRepay*Coin, false) {
clog.Error("CollateralizeRepay", "CollID", coll.CollateralizeId, "addr", action.fromaddr, "execaddr", action.execaddr, "err", types.ErrInsufficientBalance)
if !action.CheckExecTokenAccount(action.fromaddr, realRepay, false) {
clog.Error("CollateralizeRepay.CheckExecTokenAccount", "CollID", coll.CollateralizeId, "addr", action.fromaddr, "execaddr", action.execaddr, "amount", realRepay, "err", types.ErrInsufficientBalance)
return nil, types.ErrNoBalance
}
// ccny转移
receipt, err = action.tokenAccount.ExecTransfer(action.fromaddr, coll.CreateAddr, action.execaddr, realRepay*Coin)
receipt, err = action.tokenAccount.ExecTransfer(action.fromaddr, coll.CreateAddr, action.execaddr, realRepay)
if err != nil {
clog.Error("CollateralizeRepay.ExecTokenTransfer", "addr", action.fromaddr, "execaddr", action.execaddr, "amount", realRepay)
return nil, err
......@@ -683,16 +686,16 @@ func (action *Action) CollateralizeRepay(repay *pty.CollateralizeRepay) (*types.
kv = append(kv, receipt.KV...)
// ccny冻结
receipt, err = action.tokenAccount.ExecFrozen(coll.CreateAddr, action.execaddr, realRepay * Coin)
receipt, err = action.tokenAccount.ExecFrozen(coll.CreateAddr, action.execaddr, borrowRecord.DebtValue)
if err != nil {
clog.Error("CollateralizeCreate.Frozen", "addr", action.fromaddr, "execaddr", action.execaddr, "amount", realRepay)
clog.Error("CollateralizeCreate.Frozen", "addr", action.fromaddr, "execaddr", action.execaddr, "amount", borrowRecord.DebtValue)
return nil, err
}
logs = append(logs, receipt.Logs...)
kv = append(kv, receipt.KV...)
// 抵押物归还
receipt, err = action.coinsAccount.ExecTransferFrozen(coll.CreateAddr, action.fromaddr, action.execaddr, borrowRecord.CollateralValue*Coin)
receipt, err = action.coinsAccount.ExecTransferFrozen(coll.CreateAddr, action.fromaddr, action.execaddr, borrowRecord.CollateralValue)
if err != nil {
clog.Error("CollateralizeRepay.ExecTransferFrozen", "addr", coll.CreateAddr, "execaddr", action.execaddr, "amount", borrowRecord.CollateralValue)
return nil, err
......@@ -766,13 +769,13 @@ func (action *Action) CollateralizeAppend(cAppend *pty.CollateralizeAppend) (*ty
}
// 检查抵押物账户余额
if !action.CheckExecAccountBalance(action.fromaddr, cAppend.CollateralValue*Coin, 0) {
clog.Error("CollateralizeBorrow", "CollID", coll.CollateralizeId, "addr", action.fromaddr, "execaddr", action.execaddr, "err", types.ErrNoBalance)
if !action.CheckExecAccountBalance(action.fromaddr, cAppend.CollateralValue, 0) {
clog.Error("CollateralizeBorrow.CheckExecAccountBalance", "CollID", coll.CollateralizeId, "addr", action.fromaddr, "execaddr", action.execaddr, "amount", cAppend.CollateralValue, "err", types.ErrNoBalance)
return nil, types.ErrNoBalance
}
// 抵押物转账
receipt, err := action.coinsAccount.ExecTransfer(action.fromaddr, coll.CreateAddr, action.execaddr, cAppend.CollateralValue*Coin)
receipt, err := action.coinsAccount.ExecTransfer(action.fromaddr, coll.CreateAddr, action.execaddr, cAppend.CollateralValue)
if err != nil {
clog.Error("CollateralizeBorrow.ExecTransfer", "addr", action.fromaddr, "execaddr", action.execaddr, "amount", cAppend.CollateralValue, "err", err)
return nil, err
......@@ -781,7 +784,7 @@ func (action *Action) CollateralizeAppend(cAppend *pty.CollateralizeAppend) (*ty
kv = append(kv, receipt.KV...)
// 抵押物冻结
receipt, err = action.coinsAccount.ExecFrozen(coll.CreateAddr, action.execaddr, cAppend.CollateralValue*Coin)
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, "err", err)
return nil, err
......@@ -877,7 +880,7 @@ func getGuarantorAddr(db dbm.KV) (string, error) {
}
// 系统清算
func (action *Action) systemLiquidation(coll *pty.Collateralize, price float32) (*types.Receipt, error) {
func (action *Action) systemLiquidation(coll *pty.Collateralize, price float64) (*types.Receipt, error) {
var logs []*types.ReceiptLog
var kv []*types.KeyValue
......@@ -900,7 +903,7 @@ func (action *Action) systemLiquidation(coll *pty.Collateralize, price float32)
}
// 抵押物转移
receipt, err := action.coinsAccount.ExecTransferFrozen(coll.CreateAddr, getGuarantorAddr, action.execaddr, borrowRecord.CollateralValue*Coin)
receipt, err := action.coinsAccount.ExecTransferFrozen(coll.CreateAddr, getGuarantorAddr, action.execaddr, borrowRecord.CollateralValue)
if err != nil {
clog.Error("systemLiquidation", "addr", action.fromaddr, "execaddr", action.execaddr, "amount", borrowRecord.CollateralValue, "err", err)
continue
......@@ -959,7 +962,7 @@ func (action *Action) expireLiquidation(coll *pty.Collateralize) (*types.Receipt
}
// 抵押物转移
receipt, err := action.coinsAccount.ExecTransferFrozen(coll.CreateAddr, getGuarantorAddr, action.execaddr, borrowRecord.CollateralValue*Coin)
receipt, err := action.coinsAccount.ExecTransferFrozen(coll.CreateAddr, getGuarantorAddr, action.execaddr, borrowRecord.CollateralValue)
if err != nil {
clog.Error("systemLiquidation", "addr", action.fromaddr, "execaddr", action.execaddr, "amount", borrowRecord.CollateralValue, "err", err)
continue
......@@ -999,8 +1002,8 @@ func (action *Action) expireLiquidation(coll *pty.Collateralize) (*types.Receipt
}
// 价格计算策略
func pricePolicy(feed *pty.CollateralizeFeed) float32 {
var totalPrice float32
func pricePolicy(feed *pty.CollateralizeFeed) float64 {
var totalPrice float64
var totalVolume int64
for _, volume := range feed.Volume {
totalVolume += volume
......@@ -1012,7 +1015,7 @@ func pricePolicy(feed *pty.CollateralizeFeed) float32 {
}
for i, price := range feed.Price {
totalPrice += price * float32(float64(feed.Volume[i])/float64(totalVolume))
totalPrice += price * (float64(feed.Volume[i])/float64(totalVolume))
}
return totalPrice
......@@ -1103,13 +1106,6 @@ func (action *Action) CollateralizeRetrieve(retrieve *pty.CollateralizeRetrieve)
return nil, pty.ErrPermissionDeny
}
//for _, borrowRecord := range collateralize.BorrowRecords {
// if borrowRecord.Status != pty.CollateralizeUserStatusClose {
// clog.Error("CollateralizeRetrieve", "CollateralizeId", retrieve.CollateralizeId, "addr", action.fromaddr, "execaddr", action.execaddr, "err", pty.ErrCollateralizeRecordNotEmpty)
// return nil, pty.ErrCollateralizeRecordNotEmpty
// }
//}
// 收回金额不能大于待放出金额
if retrieve.Balance > collateralize.Balance {
clog.Error("CollateralizeRetrieve", "CollateralizeId", retrieve.CollateralizeId, "err", "balance error", "retrieve balance", retrieve.Balance, "available balance", collateralize.Balance)
......@@ -1117,7 +1113,7 @@ func (action *Action) CollateralizeRetrieve(retrieve *pty.CollateralizeRetrieve)
}
// 解冻ccny
receipt, err = action.tokenAccount.ExecActive(action.fromaddr, action.execaddr, retrieve.Balance*Coin)
receipt, err = action.tokenAccount.ExecActive(action.fromaddr, action.execaddr, retrieve.Balance)
if err != nil {
clog.Error("IssuanceClose.ExecActive", "addr", action.fromaddr, "execaddr", action.execaddr, "balance", retrieve.Balance)
return nil, err
......
......@@ -144,7 +144,7 @@ func (c *Collateralize) Query_CollateralizeConfig(req *pty.ReqCollateralizeRecor
clog.Debug("Query_CollateralizeByStatus", "get collateralize record error", err)
}
collBalance := config.CollTotalBalance
balance := config.TotalBalance
for _, id := range collIDRecords {
coll, err := queryCollateralizeByID(c.GetStateDB(), id)
if err != nil {
......@@ -152,15 +152,15 @@ func (c *Collateralize) Query_CollateralizeConfig(req *pty.ReqCollateralizeRecor
return nil, err
}
collBalance -= coll.TotalBalance
balance -= coll.TotalBalance
}
ret := &pty.RepCollateralizeConfig{
CollTotalBalance:config.CollTotalBalance,
TotalBalance:config.TotalBalance,
DebtCeiling: config.DebtCeiling,
LiquidationRatio: config.LiquidationRatio,
StabilityFeeRatio: config.StabilityFeeRatio,
Period: config.Period,
CollBalance: collBalance,
Balance: balance,
CurrentTime: config.CurrentTime,
}
......
......@@ -7,14 +7,14 @@ message Collateralize {
string collateralizeId = 1; //放贷ID,一期放贷对应一个ID
int64 totalBalance = 2; //当期放贷的总金额(ccny)
int64 debtCeiling = 3; //单用户可借出的限额(ccny)
float liquidationRatio = 4; //清算比例
float stabilityFeeRatio = 5; //稳定费率
double liquidationRatio = 4; //清算比例
double stabilityFeeRatio = 5; //稳定费率
string createAddr = 6; //创建人地址
int64 balance = 7; //放贷剩余金额(ccny)
repeated BorrowRecord borrowRecords = 8; //借贷记录
repeated BorrowRecord InvalidRecords = 9; //失效的借贷记录
int32 status = 10;//当期借贷的状态,是否关闭
float latestLiquidationPrice = 11;//最高清算价格
double latestLiquidationPrice = 11;//最高清算价格
int64 period = 12;//借贷最大期限
int64 latestExpireTime = 13;//最近超期时间
int64 index = 14;//当前索引
......@@ -27,9 +27,9 @@ message BorrowRecord {
string accountAddr = 1; //借贷人地址
int64 startTime = 2; //借贷时间
int64 collateralValue = 3; //抵押物价值(bty)
float collateralPrice = 4; //抵押物价格
double collateralPrice = 4; //抵押物价格
int64 debtValue = 5; //债务价值(ccny)
float liquidationPrice = 6; //抵押物清算价格
double liquidationPrice = 6; //抵押物清算价格
int32 status = 7; //抵押状态,是否被清算
int64 liquidateTime = 8; //清算时间
int64 expireTime = 9; //超时清算时间
......@@ -43,9 +43,9 @@ message BorrowRecord {
// 资产价格记录
message AssetPriceRecord {
int64 recordTime = 1; //价格记录时间
float btyPrice = 2; //bty价格
float btcPrice = 3; //btc价格
float ethPrice = 4; //eth价格
double btyPrice = 2; //bty价格
double btcPrice = 3; //btc价格
double ethPrice = 4; //eth价格
}
// action
......@@ -63,12 +63,12 @@ message CollateralizeAction {
}
message CollateralizeManage {
int64 debtCeiling = 1; //单用户可借出的限额(ccny)
float liquidationRatio = 2; //清算比例
float stabilityFeeRatio = 3; //稳定费
int64 period = 4; //合约期限
int64 collTotalBalance = 5; //放贷总量
int64 currentTime = 6; //设置时间
int64 debtCeiling = 1; //单用户可借出的限额(ccny)
double liquidationRatio = 2; //清算比例
double stabilityFeeRatio = 3; //稳定费
int64 period = 4; //合约期限
int64 totalBalance = 5; //放贷总量
int64 currentTime = 6; //设置时间
}
message CollateralizeAddr {
......@@ -81,8 +81,8 @@ message CollateralizeCreate {
// 质押借出
message CollateralizeBorrow {
string collateralizeId = 1; //借贷期数ID
int64 value = 2; //借贷价值(ccny)
string collateralizeId = 1; //借贷期数ID
int64 value = 2; //借贷价值(ccny)
}
// 质押清算
......@@ -93,22 +93,22 @@ message CollateralizeRepay {
// 追加抵押物
message CollateralizeAppend {
string collateralizeId = 1; //借贷期数ID
string recordId = 2; //借贷ID
int64 collateralValue = 3; //追加价值(bty)
string collateralizeId = 1; //借贷期数ID
string recordId = 2; //借贷ID
int64 collateralValue = 3; //追加价值(bty)
}
// 喂价
message CollateralizeFeed {
int32 collType = 1; //抵押物价格类型(1,bty,2,btc,3,eth...)
repeated float price = 2; //喂价
repeated int64 volume = 3; //成交量
int32 collType = 1; //抵押物价格类型(1,bty,2,btc,3,eth...)
repeated double price = 2; //喂价
repeated int64 volume = 3; //成交量
}
// 收回
message CollateralizeRetrieve {
string collateralizeId = 1; //借贷期数ID
int64 balance = 2; //收回金额
string collateralizeId = 1; //借贷期数ID
int64 balance = 2; //收回金额
}
// exec_local 放贷信息
......@@ -147,8 +147,8 @@ message RepCollateralizeCurrentInfo {
int32 status = 1;//当期借贷的状态,是否关闭
int64 totalBalance = 2; //当期可借贷的总金额(ccny)
int64 debtCeiling = 3; //单用户可借出的限额(ccny)
float liquidationRatio = 4; //清算比例
float stabilityFeeRatio = 5; //稳定费
double liquidationRatio = 4; //清算比例
double stabilityFeeRatio = 5; //稳定费
string createAddr = 6; //创建人地址
int64 balance = 7; //剩余可借贷金额(ccny)
int64 period = 8; //合约期限
......@@ -218,16 +218,16 @@ message RepCollateralizeRecord {
// 返回放贷配置
message RepCollateralizeConfig {
int64 debtCeiling = 1; //单用户可借出的限额(ccny)
float liquidationRatio = 2; //清算比例
float stabilityFeeRatio = 3; //稳定费
int64 period = 4; //合约期限
int64 collTotalBalance = 5; //放贷总量
int64 collBalance = 6; //剩余放贷额度
int64 currentTime = 7; //设置时间
int64 debtCeiling = 1; //单用户可借出的限额(ccny)
double liquidationRatio = 2; //清算比例
double stabilityFeeRatio = 3; //稳定费
int64 period = 4; //合约期限
int64 totalBalance = 5; //放贷总量
int64 balance = 6; //剩余放贷额度
int64 currentTime = 7; //设置时间
}
// 返回最新抵押物价格
message RepCollateralizePrice {
float price = 1; //当前抵押物最新价格
double price = 1; //当前抵押物最新价格
}
\ No newline at end of file
......@@ -6,6 +6,7 @@ package types
import (
"encoding/json"
"math"
"reflect"
"github.com/33cn/chain33/common/address"
......@@ -111,7 +112,7 @@ func (collateralize CollateralizeType) CreateTx(action string, message json.RawM
return nil, types.ErrInvalidParam
}
return CreateRawCollateralizeFeedTx(cfg, &param)
} else if action == "CollateralizeRetrive" {
} else if action == "CollateralizeRetrieve" {
var param CollateralizeRetrieveTx
err := json.Unmarshal(message, &param)
if err != nil {
......@@ -153,7 +154,7 @@ func CreateRawCollateralizeCreateTx(cfg *types.Chain33Config, parm *Collateraliz
}
v := &CollateralizeCreate{
TotalBalance: parm.TotalBalance,
TotalBalance: int64(math.Trunc((parm.TotalBalance+0.0000001)*1e4)) * 1e4,
}
create := &CollateralizeAction{
Ty: CollateralizeActionCreate,
......@@ -182,7 +183,7 @@ func CreateRawCollateralizeBorrowTx(cfg *types.Chain33Config, parm *Collateraliz
v := &CollateralizeBorrow{
CollateralizeId: parm.CollateralizeID,
Value: parm.Value,
Value: int64(math.Trunc((parm.Value+0.0000001)*1e4)) * 1e4,
}
borrow := &CollateralizeAction{
Ty: CollateralizeActionBorrow,
......@@ -241,7 +242,7 @@ func CreateRawCollateralizeAppendTx(cfg *types.Chain33Config, parm *Collateraliz
v := &CollateralizeAppend{
CollateralizeId: parm.CollateralizeID,
RecordId:parm.RecordID,
CollateralValue: parm.Value,
CollateralValue: int64(math.Trunc((parm.Value+0.0000001)*1e4)) * 1e4,
}
append := &CollateralizeAction{
Ty: CollateralizeActionAppend,
......@@ -299,7 +300,7 @@ func CreateRawCollateralizeRetrieveTx(cfg *types.Chain33Config, parm *Collateral
v := &CollateralizeRetrieve{
CollateralizeId: parm.CollateralizeID,
Balance: parm.Balance,
Balance: int64(math.Trunc((parm.Balance+0.0000001)*1e4)) * 1e4,
}
close := &CollateralizeAction{
Ty: CollateralizeActionRetrieve,
......@@ -328,11 +329,11 @@ func CreateRawCollateralizeManageTx(cfg *types.Chain33Config, parm *Collateraliz
}
v := &CollateralizeManage{
DebtCeiling: parm.DebtCeiling,
DebtCeiling: int64(math.Trunc((parm.DebtCeiling+0.0000001)*1e4)) * 1e4,
LiquidationRatio: parm.LiquidationRatio,
StabilityFeeRatio: parm.StabilityFeeRatio,
Period: parm.Period,
CollTotalBalance: parm.CollTotalBalance,
TotalBalance: int64(math.Trunc((parm.TotalBalance+0.0000001)*1e4)) * 1e4,
}
manage := &CollateralizeAction{
......
......@@ -25,14 +25,14 @@ 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"`
StabilityFeeRatio float32 `protobuf:"fixed32,5,opt,name=stabilityFeeRatio,proto3" json:"stabilityFeeRatio,omitempty"`
LiquidationRatio float64 `protobuf:"fixed64,4,opt,name=liquidationRatio,proto3" json:"liquidationRatio,omitempty"`
StabilityFeeRatio float64 `protobuf:"fixed64,5,opt,name=stabilityFeeRatio,proto3" json:"stabilityFeeRatio,omitempty"`
CreateAddr string `protobuf:"bytes,6,opt,name=createAddr,proto3" json:"createAddr,omitempty"`
Balance int64 `protobuf:"varint,7,opt,name=balance,proto3" json:"balance,omitempty"`
BorrowRecords []*BorrowRecord `protobuf:"bytes,8,rep,name=borrowRecords,proto3" json:"borrowRecords,omitempty"`
InvalidRecords []*BorrowRecord `protobuf:"bytes,9,rep,name=InvalidRecords,proto3" json:"InvalidRecords,omitempty"`
Status int32 `protobuf:"varint,10,opt,name=status,proto3" json:"status,omitempty"`
LatestLiquidationPrice float32 `protobuf:"fixed32,11,opt,name=latestLiquidationPrice,proto3" json:"latestLiquidationPrice,omitempty"`
LatestLiquidationPrice float64 `protobuf:"fixed64,11,opt,name=latestLiquidationPrice,proto3" json:"latestLiquidationPrice,omitempty"`
Period int64 `protobuf:"varint,12,opt,name=period,proto3" json:"period,omitempty"`
LatestExpireTime int64 `protobuf:"varint,13,opt,name=latestExpireTime,proto3" json:"latestExpireTime,omitempty"`
Index int64 `protobuf:"varint,14,opt,name=index,proto3" json:"index,omitempty"`
......@@ -89,14 +89,14 @@ func (m *Collateralize) GetDebtCeiling() int64 {
return 0
}
func (m *Collateralize) GetLiquidationRatio() float32 {
func (m *Collateralize) GetLiquidationRatio() float64 {
if m != nil {
return m.LiquidationRatio
}
return 0
}
func (m *Collateralize) GetStabilityFeeRatio() float32 {
func (m *Collateralize) GetStabilityFeeRatio() float64 {
if m != nil {
return m.StabilityFeeRatio
}
......@@ -138,7 +138,7 @@ func (m *Collateralize) GetStatus() int32 {
return 0
}
func (m *Collateralize) GetLatestLiquidationPrice() float32 {
func (m *Collateralize) GetLatestLiquidationPrice() float64 {
if m != nil {
return m.LatestLiquidationPrice
}
......@@ -185,9 +185,9 @@ 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"`
CollateralPrice float64 `protobuf:"fixed64,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"`
LiquidationPrice float64 `protobuf:"fixed64,6,opt,name=liquidationPrice,proto3" json:"liquidationPrice,omitempty"`
Status int32 `protobuf:"varint,7,opt,name=status,proto3" json:"status,omitempty"`
LiquidateTime int64 `protobuf:"varint,8,opt,name=liquidateTime,proto3" json:"liquidateTime,omitempty"`
ExpireTime int64 `protobuf:"varint,9,opt,name=expireTime,proto3" json:"expireTime,omitempty"`
......@@ -247,7 +247,7 @@ func (m *BorrowRecord) GetCollateralValue() int64 {
return 0
}
func (m *BorrowRecord) GetCollateralPrice() float32 {
func (m *BorrowRecord) GetCollateralPrice() float64 {
if m != nil {
return m.CollateralPrice
}
......@@ -261,7 +261,7 @@ func (m *BorrowRecord) GetDebtValue() int64 {
return 0
}
func (m *BorrowRecord) GetLiquidationPrice() float32 {
func (m *BorrowRecord) GetLiquidationPrice() float64 {
if m != nil {
return m.LiquidationPrice
}
......@@ -327,9 +327,9 @@ func (m *BorrowRecord) GetPreIndex() int64 {
// 资产价格记录
type AssetPriceRecord struct {
RecordTime int64 `protobuf:"varint,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"`
BtyPrice float64 `protobuf:"fixed64,2,opt,name=btyPrice,proto3" json:"btyPrice,omitempty"`
BtcPrice float64 `protobuf:"fixed64,3,opt,name=btcPrice,proto3" json:"btcPrice,omitempty"`
EthPrice float64 `protobuf:"fixed64,4,opt,name=ethPrice,proto3" json:"ethPrice,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
......@@ -367,21 +367,21 @@ func (m *AssetPriceRecord) GetRecordTime() int64 {
return 0
}
func (m *AssetPriceRecord) GetBtyPrice() float32 {
func (m *AssetPriceRecord) GetBtyPrice() float64 {
if m != nil {
return m.BtyPrice
}
return 0
}
func (m *AssetPriceRecord) GetBtcPrice() float32 {
func (m *AssetPriceRecord) GetBtcPrice() float64 {
if m != nil {
return m.BtcPrice
}
return 0
}
func (m *AssetPriceRecord) GetEthPrice() float32 {
func (m *AssetPriceRecord) GetEthPrice() float64 {
if m != nil {
return m.EthPrice
}
......@@ -554,10 +554,10 @@ func (*CollateralizeAction) XXX_OneofWrappers() []interface{} {
type CollateralizeManage 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"`
StabilityFeeRatio float32 `protobuf:"fixed32,3,opt,name=stabilityFeeRatio,proto3" json:"stabilityFeeRatio,omitempty"`
LiquidationRatio float64 `protobuf:"fixed64,2,opt,name=liquidationRatio,proto3" json:"liquidationRatio,omitempty"`
StabilityFeeRatio float64 `protobuf:"fixed64,3,opt,name=stabilityFeeRatio,proto3" json:"stabilityFeeRatio,omitempty"`
Period int64 `protobuf:"varint,4,opt,name=period,proto3" json:"period,omitempty"`
CollTotalBalance int64 `protobuf:"varint,5,opt,name=collTotalBalance,proto3" json:"collTotalBalance,omitempty"`
TotalBalance int64 `protobuf:"varint,5,opt,name=totalBalance,proto3" json:"totalBalance,omitempty"`
CurrentTime int64 `protobuf:"varint,6,opt,name=currentTime,proto3" json:"currentTime,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
......@@ -596,14 +596,14 @@ func (m *CollateralizeManage) GetDebtCeiling() int64 {
return 0
}
func (m *CollateralizeManage) GetLiquidationRatio() float32 {
func (m *CollateralizeManage) GetLiquidationRatio() float64 {
if m != nil {
return m.LiquidationRatio
}
return 0
}
func (m *CollateralizeManage) GetStabilityFeeRatio() float32 {
func (m *CollateralizeManage) GetStabilityFeeRatio() float64 {
if m != nil {
return m.StabilityFeeRatio
}
......@@ -617,9 +617,9 @@ func (m *CollateralizeManage) GetPeriod() int64 {
return 0
}
func (m *CollateralizeManage) GetCollTotalBalance() int64 {
func (m *CollateralizeManage) GetTotalBalance() int64 {
if m != nil {
return m.CollTotalBalance
return m.TotalBalance
}
return 0
}
......@@ -865,7 +865,7 @@ func (m *CollateralizeAppend) GetCollateralValue() int64 {
// 喂价
type CollateralizeFeed struct {
CollType int32 `protobuf:"varint,1,opt,name=collType,proto3" json:"collType,omitempty"`
Price []float32 `protobuf:"fixed32,2,rep,packed,name=price,proto3" json:"price,omitempty"`
Price []float64 `protobuf:"fixed64,2,rep,packed,name=price,proto3" json:"price,omitempty"`
Volume []int64 `protobuf:"varint,3,rep,packed,name=volume,proto3" json:"volume,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
......@@ -904,7 +904,7 @@ func (m *CollateralizeFeed) GetCollType() int32 {
return 0
}
func (m *CollateralizeFeed) GetPrice() []float32 {
func (m *CollateralizeFeed) GetPrice() []float64 {
if m != nil {
return m.Price
}
......@@ -1219,8 +1219,8 @@ type RepCollateralizeCurrentInfo 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"`
StabilityFeeRatio float32 `protobuf:"fixed32,5,opt,name=stabilityFeeRatio,proto3" json:"stabilityFeeRatio,omitempty"`
LiquidationRatio float64 `protobuf:"fixed64,4,opt,name=liquidationRatio,proto3" json:"liquidationRatio,omitempty"`
StabilityFeeRatio float64 `protobuf:"fixed64,5,opt,name=stabilityFeeRatio,proto3" json:"stabilityFeeRatio,omitempty"`
CreateAddr string `protobuf:"bytes,6,opt,name=createAddr,proto3" json:"createAddr,omitempty"`
Balance int64 `protobuf:"varint,7,opt,name=balance,proto3" json:"balance,omitempty"`
Period int64 `protobuf:"varint,8,opt,name=period,proto3" json:"period,omitempty"`
......@@ -1278,14 +1278,14 @@ func (m *RepCollateralizeCurrentInfo) GetDebtCeiling() int64 {
return 0
}
func (m *RepCollateralizeCurrentInfo) GetLiquidationRatio() float32 {
func (m *RepCollateralizeCurrentInfo) GetLiquidationRatio() float64 {
if m != nil {
return m.LiquidationRatio
}
return 0
}
func (m *RepCollateralizeCurrentInfo) GetStabilityFeeRatio() float32 {
func (m *RepCollateralizeCurrentInfo) GetStabilityFeeRatio() float64 {
if m != nil {
return m.StabilityFeeRatio
}
......@@ -1809,11 +1809,11 @@ func (m *RepCollateralizeRecord) GetRecord() *BorrowRecord {
// 返回放贷配置
type RepCollateralizeConfig 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"`
StabilityFeeRatio float32 `protobuf:"fixed32,3,opt,name=stabilityFeeRatio,proto3" json:"stabilityFeeRatio,omitempty"`
LiquidationRatio float64 `protobuf:"fixed64,2,opt,name=liquidationRatio,proto3" json:"liquidationRatio,omitempty"`
StabilityFeeRatio float64 `protobuf:"fixed64,3,opt,name=stabilityFeeRatio,proto3" json:"stabilityFeeRatio,omitempty"`
Period int64 `protobuf:"varint,4,opt,name=period,proto3" json:"period,omitempty"`
CollTotalBalance int64 `protobuf:"varint,5,opt,name=collTotalBalance,proto3" json:"collTotalBalance,omitempty"`
CollBalance int64 `protobuf:"varint,6,opt,name=collBalance,proto3" json:"collBalance,omitempty"`
TotalBalance int64 `protobuf:"varint,5,opt,name=totalBalance,proto3" json:"totalBalance,omitempty"`
Balance int64 `protobuf:"varint,6,opt,name=balance,proto3" json:"balance,omitempty"`
CurrentTime int64 `protobuf:"varint,7,opt,name=currentTime,proto3" json:"currentTime,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
......@@ -1852,14 +1852,14 @@ func (m *RepCollateralizeConfig) GetDebtCeiling() int64 {
return 0
}
func (m *RepCollateralizeConfig) GetLiquidationRatio() float32 {
func (m *RepCollateralizeConfig) GetLiquidationRatio() float64 {
if m != nil {
return m.LiquidationRatio
}
return 0
}
func (m *RepCollateralizeConfig) GetStabilityFeeRatio() float32 {
func (m *RepCollateralizeConfig) GetStabilityFeeRatio() float64 {
if m != nil {
return m.StabilityFeeRatio
}
......@@ -1873,16 +1873,16 @@ func (m *RepCollateralizeConfig) GetPeriod() int64 {
return 0
}
func (m *RepCollateralizeConfig) GetCollTotalBalance() int64 {
func (m *RepCollateralizeConfig) GetTotalBalance() int64 {
if m != nil {
return m.CollTotalBalance
return m.TotalBalance
}
return 0
}
func (m *RepCollateralizeConfig) GetCollBalance() int64 {
func (m *RepCollateralizeConfig) GetBalance() int64 {
if m != nil {
return m.CollBalance
return m.Balance
}
return 0
}
......@@ -1896,7 +1896,7 @@ func (m *RepCollateralizeConfig) GetCurrentTime() int64 {
// 返回最新抵押物价格
type RepCollateralizePrice struct {
Price float32 `protobuf:"fixed32,1,opt,name=price,proto3" json:"price,omitempty"`
Price float64 `protobuf:"fixed64,1,opt,name=price,proto3" json:"price,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
......@@ -1927,7 +1927,7 @@ func (m *RepCollateralizePrice) XXX_DiscardUnknown() {
var xxx_messageInfo_RepCollateralizePrice proto.InternalMessageInfo
func (m *RepCollateralizePrice) GetPrice() float32 {
func (m *RepCollateralizePrice) GetPrice() float64 {
if m != nil {
return m.Price
}
......@@ -1969,85 +1969,85 @@ func init() {
func init() { proto.RegisterFile("collateralize.proto", fileDescriptor_a988fb4a61381972) }
var fileDescriptor_a988fb4a61381972 = []byte{
// 1270 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xdc, 0x58, 0x4d, 0x6f, 0xdc, 0x44,
0x18, 0xae, 0xed, 0xfd, 0xc8, 0xbe, 0x9b, 0xa4, 0xe9, 0x24, 0x0d, 0x26, 0x44, 0xd1, 0x6a, 0x84,
0xc4, 0x0a, 0x68, 0x24, 0xd2, 0x0a, 0x51, 0xb8, 0x90, 0xa4, 0xad, 0xb2, 0x52, 0x91, 0x2a, 0x53,
0x10, 0x2a, 0x02, 0xc9, 0xbb, 0x9e, 0x04, 0x4b, 0x8e, 0xed, 0xd8, 0xb3, 0x21, 0xcb, 0x9d, 0x1e,
0xf8, 0x0d, 0x70, 0xe4, 0xca, 0x6f, 0xe2, 0x3f, 0x70, 0xe0, 0x8a, 0xe6, 0xc3, 0xf6, 0xcc, 0xd8,
0x8e, 0x76, 0x81, 0x53, 0x2f, 0xd1, 0xce, 0x3b, 0xcf, 0xcc, 0xbc, 0x1f, 0xcf, 0xfb, 0xe1, 0xc0,
0xf6, 0x2c, 0x89, 0x22, 0x9f, 0x92, 0xcc, 0x8f, 0xc2, 0x9f, 0xc8, 0x61, 0x9a, 0x25, 0x34, 0x41,
0x5d, 0xba, 0x48, 0x49, 0x8e, 0xff, 0xea, 0x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
0x79, 0xe5, 0x91, 0x17, 0x59, 0x38, 0x23, 0xee, 0x90, 0x1b, 0xdf, 0xb2, 0xcb, 0xee, 0x4b, 0x49,
0x16, 0x26, 0x81, 0xbb, 0xce, 0x0d, 0x94, 0x2b, 0xee, 0x73, 0x7e, 0xe2, 0xe9, 0x4d, 0x1a, 0x66,
0xe4, 0x65, 0x78, 0x49, 0xdc, 0x0d, 0x8e, 0xa8, 0xc9, 0xd1, 0x0e, 0x74, 0xc3, 0x38, 0x20, 0x37,
0xee, 0x26, 0x07, 0x88, 0x05, 0xda, 0x83, 0xb5, 0x34, 0x23, 0x13, 0xbe, 0x71, 0x97, 0x6f, 0x94,
0x6b, 0x16, 0x73, 0x46, 0x95, 0x82, 0x16, 0x5b, 0x22, 0xe6, 0x8a, 0x08, 0xff, 0xe9, 0xc0, 0xba,
0xea, 0x08, 0x76, 0xc4, 0x9f, 0xcd, 0x92, 0x79, 0x4c, 0x79, 0xac, 0x04, 0xe1, 0x54, 0x11, 0xda,
0x87, 0x41, 0x4e, 0xfd, 0x8c, 0x72, 0x5d, 0x05, 0xd3, 0x2a, 0x81, 0x4e, 0xda, 0xaf, 0xfd, 0x68,
0x4e, 0x24, 0xd5, 0x4c, 0xb1, 0x8e, 0x14, 0x3e, 0x14, 0x6c, 0x33, 0xc5, 0xec, 0x45, 0xc6, 0x53,
0x71, 0x5b, 0x57, 0xbc, 0x58, 0x0a, 0x0c, 0xda, 0x8a, 0x8b, 0x7a, 0x35, 0xda, 0x96, 0x61, 0x90,
0x61, 0xed, 0x6b, 0x61, 0x7d, 0x17, 0x36, 0x0a, 0xac, 0x88, 0xc1, 0x1a, 0x7f, 0x45, 0x17, 0x32,
0x1a, 0x93, 0x2a, 0x4c, 0x03, 0x0e, 0x51, 0x24, 0x4c, 0xcf, 0x34, 0x23, 0x5f, 0xaa, 0xbc, 0xa9,
0x04, 0x2c, 0x50, 0x19, 0xf7, 0xf1, 0x24, 0xe0, 0x64, 0x19, 0x78, 0xe5, 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0x27, 0x63, 0xaa, 0xed,
0xd7, 0xa7, 0xda, 0x07, 0xac, 0x08, 0xe9, 0xde, 0x11, 0x1f, 0x6b, 0xe5, 0x48, 0x64, 0x71, 0x13,
0xc4, 0x62, 0xda, 0xe3, 0xff, 0x96, 0x7a, 0xf8, 0x4f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x82, 0xe9,
0x7d, 0xb9, 0xad, 0x12, 0x00, 0x00,
// 1266 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xdc, 0x58, 0xdd, 0x6e, 0xdc, 0x44,
0x14, 0xae, 0xed, 0xf5, 0x6e, 0xf6, 0x6c, 0x92, 0xa6, 0x93, 0x34, 0x98, 0x10, 0x45, 0xab, 0x11,
0x12, 0x2b, 0xa0, 0x91, 0x48, 0x2b, 0x44, 0xe1, 0x86, 0x24, 0x6d, 0x95, 0x95, 0x8a, 0x54, 0x99,
0x82, 0x50, 0x11, 0x48, 0x5e, 0x7b, 0x12, 0x2c, 0x39, 0xb6, 0x63, 0xcf, 0x86, 0x2c, 0xf7, 0xf4,
0x02, 0xf1, 0x0a, 0x5c, 0x72, 0xcb, 0x33, 0xf1, 0x06, 0x5c, 0xf0, 0x02, 0x68, 0x7e, 0xfc, 0x33,
0x63, 0x3b, 0xda, 0x05, 0x6e, 0xe0, 0x26, 0xda, 0x39, 0xf3, 0xcd, 0xcc, 0x37, 0xe7, 0x7c, 0x73,
0xce, 0x71, 0x60, 0xdb, 0x4f, 0xa2, 0xc8, 0xa3, 0x24, 0xf3, 0xa2, 0xf0, 0x07, 0x72, 0x98, 0x66,
0x09, 0x4d, 0x90, 0x4d, 0x17, 0x29, 0xc9, 0xf1, 0x9f, 0x3d, 0xd8, 0x38, 0xad, 0x4f, 0xa3, 0x09,
0xdc, 0x55, 0xf0, 0xd3, 0xc0, 0x31, 0xc6, 0xc6, 0x64, 0xe8, 0xea, 0x66, 0x84, 0x61,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98, 0xf5,
0xf9, 0xbf, 0x9f, 0x1e, 0xfe, 0x15, 0x00, 0x00, 0xff, 0xff, 0x44, 0xb2, 0x25, 0xe1, 0x95, 0x12,
0x00, 0x00,
}
......@@ -9,7 +9,6 @@ import "errors"
// Errors for lottery
var (
ErrRiskParam = errors.New("ErrRiskParam")
ErrCollateralizeRepeatHash = errors.New("ErrCollateralizeRepeatHash")
ErrCollateralizeStatus = errors.New("ErrCollateralizeStatus")
ErrCollateralizeExceedDebtCeiling = errors.New("ErrCollateralizeExceedDebtCeiling")
ErrPriceInvalid = errors.New("ErrPriceInvalid")
......
......@@ -6,14 +6,14 @@ package types
// CollateralizeCreateTx for construction
type CollateralizeCreateTx struct {
TotalBalance int64 `json:"totalBalance"`
TotalBalance float64 `json:"totalBalance"`
Fee int64 `json:"fee"`
}
// CollateralizeBorrowTx for construction
type CollateralizeBorrowTx struct {
CollateralizeID string `json:"collateralizeId"`
Value int64 `json:"value"`
Value float64 `json:"value"`
Fee int64 `json:"fee"`
}
......@@ -28,13 +28,13 @@ type CollateralizeRepayTx struct {
type CollateralizeAppendTx struct {
CollateralizeID string `json:"collateralizeId"`
RecordID string `json:"recordID"`
Value int64 `json:"value"`
Value float64 `json:"value"`
Fee int64 `json:"fee"`
}
// CollateralizeFeedTx for construction
type CollateralizeFeedTx struct {
Price []float32 `json:"price"`
Price []float64 `json:"price"`
Volume []int64 `json:"volume"`
Fee int64 `json:"fee"`
}
......@@ -42,16 +42,16 @@ type CollateralizeFeedTx struct {
// CollateralizeRetrieveTx for construction
type CollateralizeRetrieveTx struct {
CollateralizeID string `json:"collateralizeId"`
Balance int64 `json:"Balance"`
Balance float64 `json:"Balance"`
Fee int64 `json:"fee"`
}
// CollateralizeManageTx for construction
type CollateralizeManageTx struct {
DebtCeiling int64 `json:"debtCeiling"`
LiquidationRatio float32 `json:"liquidationRatio"`
StabilityFeeRatio float32 `json:"stabilityFeeRatio"`
DebtCeiling float64 `json:"debtCeiling"`
LiquidationRatio float64 `json:"liquidationRatio"`
StabilityFeeRatio float64 `json:"stabilityFeeRatio"`
Period int64 `json:"period"`
CollTotalBalance int64 `json:"collTotalBalance"`
TotalBalance float64 `json:"totalBalance"`
Fee int64 `json:"fee"`
}
......@@ -43,11 +43,11 @@ func IssuanceCreateRawTxCmd() *cobra.Command {
}
func addIssuanceCreateFlags(cmd *cobra.Command) {
cmd.Flags().Uint64P("balance", "b", 0, "balance")
cmd.Flags().Float64P("balance", "b", 0, "balance")
cmd.MarkFlagRequired("balance")
cmd.Flags().Uint64P("debtCeiling", "d", 0, "debtCeiling")
cmd.Flags().Float64P("debtCeiling", "d", 0, "debtCeiling")
cmd.Flags().Float32P("liquidationRatio", "l", 0, "liquidationRatio")
cmd.Flags().Uint64P("period", "p", 0, "period")
cmd.Flags().Float32P("period", "p", 0, "period")
}
func IssuanceCreate(cmd *cobra.Command, args []string) {
......@@ -58,15 +58,15 @@ func IssuanceCreate(cmd *cobra.Command, args []string) {
}
rpcLaddr, _ := cmd.Flags().GetString("rpc_laddr")
balance, _ := cmd.Flags().GetUint64("balance")
debtCeiling, _ := cmd.Flags().GetUint64("debtCeiling")
balance, _ := cmd.Flags().GetFloat64("balance")
debtCeiling, _ := cmd.Flags().GetFloat64("debtCeiling")
liquidationRatio, _ := cmd.Flags().GetFloat32("liquidationRatio")
period, _ := cmd.Flags().GetUint64("period")
params := &rpctypes.CreateTxIn{
Execer: cfg.ExecName(pkt.IssuanceX),
ActionName: "IssuanceCreate",
Payload: []byte(fmt.Sprintf("{\"totalBalance\":%d, \"debtCeiling\":%d, \"liquidationRatio\":%f, \"period\":%d}",
Payload: []byte(fmt.Sprintf("{\"totalBalance\":%f, \"debtCeiling\":%f, \"liquidationRatio\":%f, \"period\":%d}",
balance, debtCeiling, liquidationRatio, period)),
}
......@@ -89,7 +89,7 @@ func IssuanceDebtRawTxCmd() *cobra.Command {
func addIssuanceDebtFlags(cmd *cobra.Command) {
cmd.Flags().StringP("issuanceID", "g", "", "issuance ID")
cmd.MarkFlagRequired("issuanceID")
cmd.Flags().Uint64P("value", "v", 0, "value")
cmd.Flags().Float64P("value", "v", 0, "value")
cmd.MarkFlagRequired("value")
}
......@@ -102,12 +102,12 @@ func IssuanceDebt(cmd *cobra.Command, args []string) {
rpcLaddr, _ := cmd.Flags().GetString("rpc_laddr")
issuanceID, _ := cmd.Flags().GetString("issuanceID")
value, _ := cmd.Flags().GetUint64("value")
value, _ := cmd.Flags().GetFloat64("value")
params := &rpctypes.CreateTxIn{
Execer: cfg.ExecName(pkt.IssuanceX),
ActionName: "IssuanceDebt",
Payload: []byte(fmt.Sprintf("{\"issuanceID\":\"%s\",\"value\":%d}", issuanceID, value)),
Payload: []byte(fmt.Sprintf("{\"issuanceID\":\"%s\",\"value\":%f}", issuanceID, value)),
}
var res string
......
......@@ -81,4 +81,9 @@ func (c *Issuance) ExecDelLocal_Feed(payload *pty.IssuanceFeed, tx *types.Transa
// ExecDelLocal_Close Action
func (c *Issuance) ExecDelLocal_Close(payload *pty.IssuanceClose, tx *types.Transaction, receiptData *types.ReceiptData, index int) (*types.LocalDBSet, error) {
return c.execDelLocal(tx, receiptData)
}
// ExecDelLocal_Manage Action
func (c *Issuance) ExecDelLocal_Manage(payload *pty.IssuanceManage, tx *types.Transaction, receiptData *types.ReceiptData, index int) (*types.LocalDBSet, error) {
return c.execDelLocal(tx, receiptData)
}
\ No newline at end of file
......@@ -83,3 +83,8 @@ func (c *Issuance) ExecLocal_Feed(payload *pty.IssuanceFeed, tx *types.Transacti
func (c *Issuance) ExecLocal_Close(payload *pty.IssuanceClose, tx *types.Transaction, receiptData *types.ReceiptData, index int) (*types.LocalDBSet, error) {
return c.execLocal(tx, receiptData)
}
// ExecLocal_Manage Action
func (c *Issuance) ExecLocal_Manage(payload *pty.IssuanceManage, tx *types.Transaction, receiptData *types.ReceiptData, index int) (*types.LocalDBSet, error) {
return c.execLocal(tx, receiptData)
}
......@@ -144,7 +144,7 @@ func (c *Issuance) deleteIssuanceRecordStatus(status int32, index int64) (kvs []
return kvs
}
func (c *Issuance) addIssuancePriceRecord(recordTime int64, price float32) (kvs []*types.KeyValue) {
func (c *Issuance) addIssuancePriceRecord(recordTime int64, price float64) (kvs []*types.KeyValue) {
key := calcIssuancePriceKey(string(recordTime))
record := &pty.IssuanceAssetPriceRecord{
......
......@@ -13,6 +13,7 @@ import (
"github.com/33cn/chain33/types"
pty "github.com/33cn/plugin/plugin/dapp/issuance/types"
tokenE "github.com/33cn/plugin/plugin/dapp/token/executor"
"math"
)
// List control
......@@ -25,7 +26,7 @@ const (
const (
Coin = types.Coin // 1e8
DefaultDebtCeiling = 100000 // 默认借贷限额
DefaultDebtCeiling = 100000 * Coin // 默认借贷限额
DefaultLiquidationRatio = 0.25 // 默认质押比
DefaultPeriod = 3600 * 24 * 365 // 默认合约限期
PriceWarningRate = 1.3 // 价格提前预警率
......@@ -289,8 +290,8 @@ func (action *Action) GetIndex() int64 {
return action.height*types.MaxTxsPerBlock + int64(action.index)
}
func getLatestLiquidationPrice(issu *pty.Issuance) float32 {
var latest float32
func getLatestLiquidationPrice(issu *pty.Issuance) float64 {
var latest float64
for _, collRecord := range issu.DebtRecords {
if collRecord.LiquidationPrice > latest {
latest = collRecord.LiquidationPrice
......@@ -385,7 +386,7 @@ func (action *Action) IssuanceCreate(create *pty.IssuanceCreate) (*types.Receipt
}
// 检查ccny余额
if !action.CheckExecTokenAccount(action.fromaddr, create.TotalBalance*Coin, false) {
if !action.CheckExecTokenAccount(action.fromaddr, create.TotalBalance, false) {
return nil, types.ErrInsufficientBalance
}
......@@ -398,7 +399,7 @@ func (action *Action) IssuanceCreate(create *pty.IssuanceCreate) (*types.Receipt
}
// 冻结ccny
receipt, err = action.tokenAccount.ExecFrozen(action.fromaddr, action.execaddr, create.TotalBalance*Coin)
receipt, err = action.tokenAccount.ExecFrozen(action.fromaddr, action.execaddr, create.TotalBalance)
if err != nil {
clog.Error("IssuanceCreate.Frozen", "addr", action.fromaddr, "execaddr", action.execaddr, "amount", create.TotalBalance)
return nil, err
......@@ -445,20 +446,19 @@ func (action *Action) IssuanceCreate(create *pty.IssuanceCreate) (*types.Receipt
}
// 根据最近抵押物价格计算需要冻结的BTY数量
func getBtyNumToFrozen(value int64, price float32, ratio float32) (int64,error) {
func getBtyNumToFrozen(value int64, price float64, ratio float64) (int64,error) {
if price == 0 {
clog.Error("Bty price should greate to 0")
return 0, pty.ErrPriceInvalid
}
btyValue := float32(value)/ratio
btyNum := int64(btyValue/price) + 1
return btyNum, nil
valueReal := float64(value)/1e8
btyValue := valueReal/(price * ratio)
return int64(math.Trunc((btyValue+0.0000001)*1e4)) * 1e4, nil
}
// 获取最近抵押物价格
func getLatestPrice(db dbm.KV) (float32, error) {
func getLatestPrice(db dbm.KV) (float64, error) {
data, err := db.Get(PriceKey())
if err != nil {
clog.Error("getLatestPrice", "get", err)
......@@ -558,13 +558,13 @@ func (action *Action) IssuanceDebt(debt *pty.IssuanceDebt) (*types.Receipt, erro
}
// 检查抵押物账户余额
if !action.CheckExecAccountBalance(action.fromaddr, btyFrozen*Coin, 0) {
if !action.CheckExecAccountBalance(action.fromaddr, btyFrozen, 0) {
clog.Error("IssuanceDebt.CheckExecAccountBalance", "CollID", issu.IssuanceId, "addr", action.fromaddr, "execaddr", action.execaddr, "btyFrozen", btyFrozen, "err", types.ErrNoBalance)
return nil, types.ErrNoBalance
}
// 抵押物转账
receipt, err := action.coinsAccount.ExecTransfer(action.fromaddr, issu.IssuerAddr, action.execaddr, btyFrozen*Coin)
receipt, err := action.coinsAccount.ExecTransfer(action.fromaddr, issu.IssuerAddr, action.execaddr, btyFrozen)
if err != nil {
clog.Error("IssuanceDebt.ExecTransfer", "addr", action.fromaddr, "execaddr", action.execaddr, "amount", btyFrozen)
return nil, err
......@@ -573,7 +573,7 @@ func (action *Action) IssuanceDebt(debt *pty.IssuanceDebt) (*types.Receipt, erro
kv = append(kv, receipt.KV...)
// 抵押物冻结
receipt, err = action.coinsAccount.ExecFrozen(issu.IssuerAddr, action.execaddr, btyFrozen*Coin)
receipt, err = action.coinsAccount.ExecFrozen(issu.IssuerAddr, action.execaddr, btyFrozen)
if err != nil {
clog.Error("IssuanceDebt.Frozen", "addr", issu.IssuerAddr, "execaddr", action.execaddr, "amount", btyFrozen)
return nil, err
......@@ -582,7 +582,7 @@ func (action *Action) IssuanceDebt(debt *pty.IssuanceDebt) (*types.Receipt, erro
kv = append(kv, receipt.KV...)
// 借出ccny
receipt, err = action.tokenAccount.ExecTransferFrozen(issu.IssuerAddr, action.fromaddr, action.execaddr, debt.Value*Coin)
receipt, err = action.tokenAccount.ExecTransferFrozen(issu.IssuerAddr, action.fromaddr, action.execaddr, debt.Value)
if err != nil {
clog.Error("IssuanceDebt.ExecTokenTransfer", "addr", action.fromaddr, "execaddr", action.execaddr, "amount", debt.Value)
return nil, err
......@@ -663,13 +663,13 @@ func (action *Action) IssuanceRepay(repay *pty.IssuanceRepay) (*types.Receipt, e
}
// 检查
if !action.CheckExecTokenAccount(action.fromaddr, debtRecord.DebtValue*Coin, false) {
if !action.CheckExecTokenAccount(action.fromaddr, debtRecord.DebtValue, false) {
clog.Error("IssuanceRepay", "CollID", issu.IssuanceId, "addr", action.fromaddr, "execaddr", action.execaddr, "err", types.ErrInsufficientBalance)
return nil, types.ErrNoBalance
}
// ccny转移
receipt, err = action.tokenAccount.ExecTransfer(action.fromaddr, issu.IssuerAddr, action.execaddr, debtRecord.DebtValue*Coin)
receipt, err = action.tokenAccount.ExecTransfer(action.fromaddr, issu.IssuerAddr, action.execaddr, debtRecord.DebtValue)
if err != nil {
clog.Error("IssuanceRepay.ExecTokenTransfer", "addr", action.fromaddr, "execaddr", action.execaddr, "amount", debtRecord.DebtValue)
return nil, err
......@@ -678,7 +678,7 @@ func (action *Action) IssuanceRepay(repay *pty.IssuanceRepay) (*types.Receipt, e
kv = append(kv, receipt.KV...)
// 冻结ccny
receipt, err = action.tokenAccount.ExecFrozen(issu.IssuerAddr, action.execaddr, debtRecord.DebtValue*Coin)
receipt, err = action.tokenAccount.ExecFrozen(issu.IssuerAddr, action.execaddr, debtRecord.DebtValue)
if err != nil {
clog.Error("IssuanceCreate.Frozen", "addr", action.fromaddr, "execaddr", action.execaddr, "amount", debtRecord.DebtValue)
return nil, err
......@@ -687,7 +687,7 @@ func (action *Action) IssuanceRepay(repay *pty.IssuanceRepay) (*types.Receipt, e
kv = append(kv, receipt.KV...)
// 抵押物归还
receipt, err = action.coinsAccount.ExecTransferFrozen(issu.IssuerAddr, action.fromaddr, action.execaddr, debtRecord.CollateralValue*Coin)
receipt, err = action.coinsAccount.ExecTransferFrozen(issu.IssuerAddr, action.fromaddr, action.execaddr, debtRecord.CollateralValue)
if err != nil {
clog.Error("IssuanceRepay.ExecTransferFrozen", "addr", issu.IssuerAddr, "execaddr", action.execaddr, "amount", debtRecord.CollateralValue)
return nil, err
......@@ -720,7 +720,7 @@ func (action *Action) IssuanceRepay(repay *pty.IssuanceRepay) (*types.Receipt, e
}
// 系统清算
func (action *Action) systemLiquidation(issu *pty.Issuance, price float32) (*types.Receipt, error) {
func (action *Action) systemLiquidation(issu *pty.Issuance, price float64) (*types.Receipt, error) {
var logs []*types.ReceiptLog
var kv []*types.KeyValue
......@@ -743,7 +743,7 @@ func (action *Action) systemLiquidation(issu *pty.Issuance, price float32) (*typ
}
// 抵押物转移
receipt, err := action.coinsAccount.ExecTransferFrozen(issu.IssuerAddr, getGuarantorAddr, action.execaddr, debtRecord.CollateralValue*Coin)
receipt, err := action.coinsAccount.ExecTransferFrozen(issu.IssuerAddr, getGuarantorAddr, action.execaddr, debtRecord.CollateralValue)
if err != nil {
clog.Error("systemLiquidation", "addr", action.fromaddr, "execaddr", action.execaddr, "amount", debtRecord.CollateralValue, "err", err)
continue
......@@ -801,7 +801,7 @@ func (action *Action) expireLiquidation(issu *pty.Issuance) (*types.Receipt, err
}
// 抵押物转移
receipt, err := action.coinsAccount.ExecTransferFrozen(issu.IssuerAddr, getGuarantorAddr, action.execaddr, debtRecord.CollateralValue*Coin)
receipt, err := action.coinsAccount.ExecTransferFrozen(issu.IssuerAddr, getGuarantorAddr, action.execaddr, debtRecord.CollateralValue)
if err != nil {
clog.Error("systemLiquidation", "addr", action.fromaddr, "execaddr", action.execaddr, "amount", debtRecord.CollateralValue, "err", err)
continue
......@@ -840,8 +840,8 @@ func (action *Action) expireLiquidation(issu *pty.Issuance) (*types.Receipt, err
}
// 价格计算策略
func pricePolicy(feed *pty.IssuanceFeed) float32 {
var totalPrice float32
func pricePolicy(feed *pty.IssuanceFeed) float64 {
var totalPrice float64
var totalVolume int64
for _, volume := range feed.Volume {
totalVolume += volume
......@@ -852,7 +852,7 @@ func pricePolicy(feed *pty.IssuanceFeed) float32 {
return 0
}
for i, price := range feed.Price {
totalPrice += price * float32(float64(feed.Volume[i])/float64(totalVolume))
totalPrice += price * (float64(feed.Volume[i])/float64(totalVolume))
}
return totalPrice
......@@ -955,9 +955,9 @@ func (action *Action) IssuanceClose(close *pty.IssuanceClose) (*types.Receipt, e
}
// 解冻ccny
receipt, err = action.tokenAccount.ExecActive(action.fromaddr, action.execaddr, issuance.Balance*Coin)
receipt, err = action.tokenAccount.ExecActive(action.fromaddr, action.execaddr, issuance.Balance)
if err != nil {
clog.Error("IssuanceClose.ExecActive", "addr", action.fromaddr, "execaddr", action.execaddr, "amount", issuance.TotalBalance)
clog.Error("IssuanceClose.ExecActive", "addr", action.fromaddr, "execaddr", action.execaddr, "amount", issuance.Balance, "err", err)
return nil, err
}
logs = append(logs, receipt.Logs...)
......
......@@ -7,13 +7,13 @@ message Issuance {
string issuanceId = 1; //发行ID,一期发行对应一个ID
int64 totalBalance = 2; //当期发行的总金额(ccny)
int64 debtCeiling = 3; //单用户可借出的限额(ccny)
float liquidationRatio = 4; //清算比例
double liquidationRatio = 4; //清算比例
int64 collateralValue = 5; //抵押物总数量(bty)
int64 debtValue = 6; //产生的ccny数量
repeated DebtRecord debtRecords = 7; //大户抵押记录
repeated DebtRecord invalidRecords = 8; //大户抵押记录
int32 status = 9; //当期发行的状态,是否关闭
float latestLiquidationPrice = 10;//最高清算价格
double latestLiquidationPrice = 10;//最高清算价格
int64 period = 11;//发行最大期限
int64 latestExpireTime = 12;//最近超期时间
int64 createTime = 13;//创建时间
......@@ -28,9 +28,9 @@ message DebtRecord {
string accountAddr = 1; //抵押人地址
int64 startTime = 2; //抵押时间
int64 collateralValue = 3; //抵押物价值(bty)
float collateralPrice = 4; //抵押物价格
double collateralPrice = 4; //抵押物价格
int64 debtValue = 5; //债务价值(ccny)
float liquidationPrice = 6; //抵押物清算价格
double liquidationPrice = 6; //抵押物清算价格
int32 status = 7; //抵押状态,是否被清算
int64 liquidateTime = 8; //清算时间
int64 expireTime = 9; //超时清算时间
......@@ -44,7 +44,7 @@ message DebtRecord {
// 资产价格记录
message IssuanceAssetPriceRecord {
int64 recordTime = 1; //价格记录时间
float btyPrice = 2; //bty价格
double btyPrice = 2; //bty价格
}
// action
......@@ -68,7 +68,7 @@ message IssuanceManage {
message IssuanceCreate {
int64 totalBalance = 1; //发行总金额
int64 debtCeiling = 2; //单用户可借出的限额(ccny)
float liquidationRatio = 3; //清算比例
double liquidationRatio = 3; //清算比例
int64 period = 4; //发行最大期限
}
......@@ -86,9 +86,9 @@ message IssuanceRepay {
// 喂价
message IssuanceFeed {
int32 collType = 1; //抵押物价格类型(1,bty,2,btc,3,eth...)
repeated float price = 2; //喂价
repeated int64 volume = 3; //成交量
int32 collType = 1; //抵押物价格类型(1,bty,2,btc,3,eth...)
repeated double price = 2; //喂价
repeated int64 volume = 3; //成交量
}
// 借贷关闭
......@@ -106,7 +106,7 @@ message ReceiptIssuance {
int64 index = 6;
int64 preIndex = 7;
int64 recordTime = 8; //价格记录时间
float btyPrice = 9; //bty价格
double btyPrice = 9; //bty价格
}
// exec_local 抵押记录信息
......@@ -132,7 +132,7 @@ message RepIssuanceCurrentInfo {
int32 status = 1; //当期发行的状态,是否关闭
int64 totalBalance = 2; //当期发行总金额(ccny)
int64 debtCeiling = 3; //单用户可借出的限额(ccny)
float liquidationRatio = 4; //清算比例
double liquidationRatio = 4; //清算比例
int64 balance = 5; //剩余可借贷金额(ccny)
int64 collateralValue = 6; //抵押物总数量(bty)
int64 debtValue = 7; //产生的ccny数量
......@@ -195,5 +195,5 @@ message RepIssuanceDebtInfo {
// 返回最新抵押物价格
message RepIssuancePrice {
float price = 1; //当前抵押物最新价格
double price = 1; //当前抵押物最新价格
}
\ No newline at end of file
......@@ -6,6 +6,7 @@ package types
import (
"encoding/json"
"math"
"reflect"
"github.com/33cn/chain33/common/address"
......@@ -143,8 +144,8 @@ func CreateRawIssuanceCreateTx(cfg *types.Chain33Config, parm *IssuanceCreateTx)
}
v := &IssuanceCreate{
TotalBalance: parm.TotalBalance,
DebtCeiling: parm.DebtCeiling,
TotalBalance: int64(math.Trunc((parm.TotalBalance+0.0000001)*1e4)) * 1e4,
DebtCeiling: int64(math.Trunc((parm.DebtCeiling+0.0000001)*1e4)) * 1e4,
LiquidationRatio: parm.LiquidationRatio,
Period: parm.Period,
}
......@@ -175,7 +176,7 @@ func CreateRawIssuanceDebtTx(cfg *types.Chain33Config, parm *IssuanceDebtTx) (*t
v := &IssuanceDebt{
IssuanceId: parm.IssuanceID,
Value: parm.Value,
Value: int64(math.Trunc((parm.Value+0.0000001)*1e4)) * 1e4,
}
debt := &IssuanceAction{
Ty: IssuanceActionDebt,
......
......@@ -25,13 +25,13 @@ type Issuance struct {
IssuanceId string `protobuf:"bytes,1,opt,name=issuanceId,proto3" json:"issuanceId,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"`
LiquidationRatio float64 `protobuf:"fixed64,4,opt,name=liquidationRatio,proto3" json:"liquidationRatio,omitempty"`
CollateralValue int64 `protobuf:"varint,5,opt,name=collateralValue,proto3" json:"collateralValue,omitempty"`
DebtValue int64 `protobuf:"varint,6,opt,name=debtValue,proto3" json:"debtValue,omitempty"`
DebtRecords []*DebtRecord `protobuf:"bytes,7,rep,name=debtRecords,proto3" json:"debtRecords,omitempty"`
InvalidRecords []*DebtRecord `protobuf:"bytes,8,rep,name=invalidRecords,proto3" json:"invalidRecords,omitempty"`
Status int32 `protobuf:"varint,9,opt,name=status,proto3" json:"status,omitempty"`
LatestLiquidationPrice float32 `protobuf:"fixed32,10,opt,name=latestLiquidationPrice,proto3" json:"latestLiquidationPrice,omitempty"`
LatestLiquidationPrice float64 `protobuf:"fixed64,10,opt,name=latestLiquidationPrice,proto3" json:"latestLiquidationPrice,omitempty"`
Period int64 `protobuf:"varint,11,opt,name=period,proto3" json:"period,omitempty"`
LatestExpireTime int64 `protobuf:"varint,12,opt,name=latestExpireTime,proto3" json:"latestExpireTime,omitempty"`
CreateTime int64 `protobuf:"varint,13,opt,name=createTime,proto3" json:"createTime,omitempty"`
......@@ -90,7 +90,7 @@ func (m *Issuance) GetDebtCeiling() int64 {
return 0
}
func (m *Issuance) GetLiquidationRatio() float32 {
func (m *Issuance) GetLiquidationRatio() float64 {
if m != nil {
return m.LiquidationRatio
}
......@@ -132,7 +132,7 @@ func (m *Issuance) GetStatus() int32 {
return 0
}
func (m *Issuance) GetLatestLiquidationPrice() float32 {
func (m *Issuance) GetLatestLiquidationPrice() float64 {
if m != nil {
return m.LatestLiquidationPrice
}
......@@ -193,9 +193,9 @@ type DebtRecord 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"`
CollateralPrice float64 `protobuf:"fixed64,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"`
LiquidationPrice float64 `protobuf:"fixed64,6,opt,name=liquidationPrice,proto3" json:"liquidationPrice,omitempty"`
Status int32 `protobuf:"varint,7,opt,name=status,proto3" json:"status,omitempty"`
LiquidateTime int64 `protobuf:"varint,8,opt,name=liquidateTime,proto3" json:"liquidateTime,omitempty"`
ExpireTime int64 `protobuf:"varint,9,opt,name=expireTime,proto3" json:"expireTime,omitempty"`
......@@ -255,7 +255,7 @@ func (m *DebtRecord) GetCollateralValue() int64 {
return 0
}
func (m *DebtRecord) GetCollateralPrice() float32 {
func (m *DebtRecord) GetCollateralPrice() float64 {
if m != nil {
return m.CollateralPrice
}
......@@ -269,7 +269,7 @@ func (m *DebtRecord) GetDebtValue() int64 {
return 0
}
func (m *DebtRecord) GetLiquidationPrice() float32 {
func (m *DebtRecord) GetLiquidationPrice() float64 {
if m != nil {
return m.LiquidationPrice
}
......@@ -335,7 +335,7 @@ func (m *DebtRecord) GetPreIndex() int64 {
// 资产价格记录
type IssuanceAssetPriceRecord struct {
RecordTime int64 `protobuf:"varint,1,opt,name=recordTime,proto3" json:"recordTime,omitempty"`
BtyPrice float32 `protobuf:"fixed32,2,opt,name=btyPrice,proto3" json:"btyPrice,omitempty"`
BtyPrice float64 `protobuf:"fixed64,2,opt,name=btyPrice,proto3" json:"btyPrice,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
......@@ -373,7 +373,7 @@ func (m *IssuanceAssetPriceRecord) GetRecordTime() int64 {
return 0
}
func (m *IssuanceAssetPriceRecord) GetBtyPrice() float32 {
func (m *IssuanceAssetPriceRecord) GetBtyPrice() float64 {
if m != nil {
return m.BtyPrice
}
......@@ -572,7 +572,7 @@ func (m *IssuanceManage) GetSuperAddrs() []string {
type IssuanceCreate struct {
TotalBalance int64 `protobuf:"varint,1,opt,name=totalBalance,proto3" json:"totalBalance,omitempty"`
DebtCeiling int64 `protobuf:"varint,2,opt,name=debtCeiling,proto3" json:"debtCeiling,omitempty"`
LiquidationRatio float32 `protobuf:"fixed32,3,opt,name=liquidationRatio,proto3" json:"liquidationRatio,omitempty"`
LiquidationRatio float64 `protobuf:"fixed64,3,opt,name=liquidationRatio,proto3" json:"liquidationRatio,omitempty"`
Period int64 `protobuf:"varint,4,opt,name=period,proto3" json:"period,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
......@@ -618,7 +618,7 @@ func (m *IssuanceCreate) GetDebtCeiling() int64 {
return 0
}
func (m *IssuanceCreate) GetLiquidationRatio() float32 {
func (m *IssuanceCreate) GetLiquidationRatio() float64 {
if m != nil {
return m.LiquidationRatio
}
......@@ -731,7 +731,7 @@ func (m *IssuanceRepay) GetDebtId() string {
// 喂价
type IssuanceFeed struct {
CollType int32 `protobuf:"varint,1,opt,name=collType,proto3" json:"collType,omitempty"`
Price []float32 `protobuf:"fixed32,2,rep,packed,name=price,proto3" json:"price,omitempty"`
Price []float64 `protobuf:"fixed64,2,rep,packed,name=price,proto3" json:"price,omitempty"`
Volume []int64 `protobuf:"varint,3,rep,packed,name=volume,proto3" json:"volume,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
......@@ -770,7 +770,7 @@ func (m *IssuanceFeed) GetCollType() int32 {
return 0
}
func (m *IssuanceFeed) GetPrice() []float32 {
func (m *IssuanceFeed) GetPrice() []float64 {
if m != nil {
return m.Price
}
......@@ -834,7 +834,7 @@ type ReceiptIssuance struct {
Index int64 `protobuf:"varint,6,opt,name=index,proto3" json:"index,omitempty"`
PreIndex int64 `protobuf:"varint,7,opt,name=preIndex,proto3" json:"preIndex,omitempty"`
RecordTime int64 `protobuf:"varint,8,opt,name=recordTime,proto3" json:"recordTime,omitempty"`
BtyPrice float32 `protobuf:"fixed32,9,opt,name=btyPrice,proto3" json:"btyPrice,omitempty"`
BtyPrice float64 `protobuf:"fixed64,9,opt,name=btyPrice,proto3" json:"btyPrice,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
......@@ -921,7 +921,7 @@ func (m *ReceiptIssuance) GetRecordTime() int64 {
return 0
}
func (m *ReceiptIssuance) GetBtyPrice() float32 {
func (m *ReceiptIssuance) GetBtyPrice() float64 {
if m != nil {
return m.BtyPrice
}
......@@ -1077,7 +1077,7 @@ type RepIssuanceCurrentInfo 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"`
LiquidationRatio float64 `protobuf:"fixed64,4,opt,name=liquidationRatio,proto3" json:"liquidationRatio,omitempty"`
Balance int64 `protobuf:"varint,5,opt,name=balance,proto3" json:"balance,omitempty"`
CollateralValue int64 `protobuf:"varint,6,opt,name=collateralValue,proto3" json:"collateralValue,omitempty"`
DebtValue int64 `protobuf:"varint,7,opt,name=debtValue,proto3" json:"debtValue,omitempty"`
......@@ -1135,7 +1135,7 @@ func (m *RepIssuanceCurrentInfo) GetDebtCeiling() int64 {
return 0
}
func (m *RepIssuanceCurrentInfo) GetLiquidationRatio() float32 {
func (m *RepIssuanceCurrentInfo) GetLiquidationRatio() float64 {
if m != nil {
return m.LiquidationRatio
}
......@@ -1602,7 +1602,7 @@ func (m *RepIssuanceDebtInfo) GetRecord() *DebtRecord {
// 返回最新抵押物价格
type RepIssuancePrice struct {
Price float32 `protobuf:"fixed32,1,opt,name=price,proto3" json:"price,omitempty"`
Price float64 `protobuf:"fixed64,1,opt,name=price,proto3" json:"price,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
......@@ -1633,7 +1633,7 @@ func (m *RepIssuancePrice) XXX_DiscardUnknown() {
var xxx_messageInfo_RepIssuancePrice proto.InternalMessageInfo
func (m *RepIssuancePrice) GetPrice() float32 {
func (m *RepIssuancePrice) GetPrice() float64 {
if m != nil {
return m.Price
}
......@@ -1683,7 +1683,7 @@ var fileDescriptor_7110f4228953d675 = []byte{
0x2c, 0xcc, 0x85, 0x7d, 0x91, 0x08, 0x3f, 0x9e, 0xfb, 0x31, 0x5a, 0x1c, 0x73, 0x6a, 0xcc, 0x2c,
0xaf, 0x66, 0x63, 0x53, 0x18, 0x87, 0xfc, 0x56, 0x5c, 0xf1, 0x28, 0x8e, 0x96, 0x6f, 0x1d, 0x8b,
0x5c, 0xaa, 0x26, 0xf6, 0x09, 0x1c, 0xc5, 0xd1, 0xbb, 0x55, 0x14, 0xfa, 0x22, 0x4a, 0x96, 0x1e,
0xfe, 0x75, 0x7a, 0x53, 0x63, 0x66, 0x7a, 0x2d, 0x3b, 0x9b, 0xc1, 0x61, 0x90, 0xc4, 0xb1, 0x2f,
0xfe, 0x75, 0x7a, 0x53, 0x63, 0x66, 0x78, 0x2d, 0x3b, 0x9b, 0xc1, 0x61, 0x90, 0xc4, 0xb1, 0x2f,
0x78, 0xe6, 0xc7, 0x6f, 0xfc, 0x78, 0xc5, 0x1d, 0x9b, 0x22, 0x36, 0xcd, 0xec, 0x43, 0x18, 0x61,
0x12, 0xe9, 0xd3, 0x27, 0x1f, 0x6d, 0x60, 0x17, 0xb2, 0x2a, 0x8f, 0x07, 0x49, 0x16, 0xe6, 0xce,
0x60, 0x6a, 0xcd, 0xc6, 0xe7, 0x4f, 0x4e, 0xa9, 0x07, 0xa7, 0xd7, 0xe5, 0x8e, 0x57, 0xf5, 0x62,
......@@ -1718,7 +1718,7 @@ var fileDescriptor_7110f4228953d675 = []byte{
0xad, 0x0d, 0x8a, 0xaf, 0x95, 0xae, 0x57, 0x55, 0x3a, 0xf7, 0x1a, 0xf6, 0xab, 0xb8, 0x6d, 0x7d,
0xab, 0x8e, 0x55, 0x1f, 0x54, 0x3d, 0xaa, 0x29, 0xdf, 0xc3, 0x41, 0x0d, 0xd1, 0xad, 0x61, 0xf4,
0xfd, 0x31, 0xab, 0xf7, 0xc7, 0xfd, 0x45, 0x97, 0x83, 0x68, 0x23, 0x93, 0x51, 0x40, 0x5e, 0xaf,
0x53, 0xd9, 0x24, 0xdb, 0x2b, 0xd7, 0x58, 0x4a, 0xaa, 0x28, 0x6e, 0xcd, 0x4c, 0x4f, 0x2e, 0x30,
0x53, 0xd9, 0x24, 0xdb, 0x2b, 0xd7, 0x58, 0x4a, 0xaa, 0x28, 0x6e, 0xcd, 0x0c, 0x4f, 0x2e, 0x30,
0xf2, 0x43, 0x12, 0xaf, 0xee, 0x51, 0xaa, 0x2c, 0x3c, 0xa8, 0x5c, 0xb9, 0x67, 0xba, 0x44, 0xe2,
0xc6, 0xb6, 0x12, 0xdd, 0xdf, 0x4d, 0x38, 0xf4, 0x78, 0xc0, 0xa3, 0x54, 0xec, 0xfc, 0x92, 0x37,
0x04, 0xd7, 0x6c, 0x0b, 0xae, 0x3e, 0xb8, 0xd5, 0x14, 0x0e, 0x25, 0x66, 0xbd, 0x9a, 0x98, 0xd5,
......@@ -1741,5 +1741,5 @@ var fileDescriptor_7110f4228953d675 = []byte{
0xde, 0xd2, 0x57, 0x35, 0x54, 0xd0, 0x63, 0x97, 0x9b, 0xba, 0xf1, 0x25, 0xf9, 0x06, 0xc3, 0xa5,
0xad, 0x70, 0x2f, 0xa1, 0x2f, 0x13, 0xaa, 0x59, 0xa7, 0xa3, 0x22, 0xe5, 0xe0, 0xce, 0x90, 0xac,
0x65, 0x04, 0x39, 0x73, 0x96, 0x6f, 0x8e, 0x41, 0x77, 0x52, 0x2e, 0x6e, 0xfb, 0xf4, 0xbf, 0xdf,
0xc5, 0xbf, 0x01, 0x00, 0x00, 0xff, 0xff, 0x9c, 0x86, 0x5d, 0xb7, 0x0d, 0x0e, 0x00, 0x00,
0xc5, 0xbf, 0x01, 0x00, 0x00, 0xff, 0xff, 0xa1, 0x37, 0xc2, 0xe4, 0x0d, 0x0e, 0x00, 0x00,
}
......@@ -6,17 +6,17 @@ package types
// IssuanceCreateTx for construction
type IssuanceCreateTx struct {
DebtCeiling int64 `json:"debtCeiling"`
LiquidationRatio float32 `json:"liquidationRatio"`
DebtCeiling float64 `json:"debtCeiling"`
LiquidationRatio float64 `json:"liquidationRatio"`
Period int64 `json:"period"`
TotalBalance int64 `json:"totalBalance"`
TotalBalance float64 `json:"totalBalance"`
Fee int64 `json:"fee"`
}
// IssuanceDebtTx for construction
type IssuanceDebtTx struct {
IssuanceID string `json:"issuanceId"`
Value int64 `json:"value"`
Value float64 `json:"value"`
Fee int64 `json:"fee"`
}
......@@ -29,7 +29,7 @@ type IssuanceRepayTx struct {
// IssuanceFeedTx for construction
type IssuanceFeedTx struct {
Price []float32 `json:"price"`
Price []float64 `json:"price"`
Volume []int64 `json:"volume"`
Fee int64 `json:"fee"`
}
......
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