Commit f265dde9 authored by linj's avatar linj Committed by vipwzw

price: buy limit exec

parent 446024a6
......@@ -187,6 +187,8 @@ func (buydb *buyDB) getBuyLogs(tradeType int32, txhash string) *types.ReceiptLog
TxHash: txhash,
Height: buydb.Height,
AssetExec: buydb.AssetExec,
PriceExec: buydb.PriceExec,
PriceSymbol: buydb.PriceSymbol,
}
if pty.TyLogTradeBuyLimit == tradeType {
receiptTrade := &pty.ReceiptTradeBuyLimit{Base: base}
......@@ -475,10 +477,20 @@ func (action *tradeAction) tradeBuyLimit(buy *pty.TradeForBuyLimit) (*types.Rece
if !checkAsset(action.height, buy.AssetExec, buy.TokenSymbol) {
return nil, types.ErrInvalidParam
}
if !checkPrice(action.height, buy.PriceExec, buy.PriceExec) {
return nil, types.ErrInvalidParam
}
if !notSameAsset(action.height, buy.AssetExec, buy.TokenSymbol, buy.PriceExec, buy.PriceExec) {
return nil, pty.ErrAssetAndPriceSame
}
priceAcc, err := createPriceDB(action.height, action.db, buy.PriceExec, buy.PriceSymbol)
if err != nil {
return nil, err
}
// check enough bty
amount := buy.PricePerBoardlot * buy.TotalBoardlot
receipt, err := action.coinsAccount.ExecFrozen(action.fromaddr, action.execaddr, amount)
receipt, err := priceAcc.ExecFrozen(action.fromaddr, action.execaddr, amount)
if err != nil {
tradelog.Error("trade tradeBuyLimit ", "addr", action.fromaddr, "execaddr", action.execaddr, "amount", amount)
return nil, err
......@@ -498,6 +510,8 @@ func (action *tradeAction) tradeBuyLimit(buy *pty.TradeForBuyLimit) (*types.Rece
Status: pty.TradeOrderStatusOnBuy,
Height: action.height,
AssetExec: buy.AssetExec,
PriceExec: buy.PriceExec,
PriceSymbol: buy.PriceSymbol,
}
tokendb := newBuyDB(buyOrder)
......
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