Skip to content
This repository has been archived by the owner on Aug 4, 2020. It is now read-only.

Commit

Permalink
Merge pull request #7 from thanhnguyennguyen/cancel-without-order-side
Browse files Browse the repository at this point in the history
Fix #6: cancel order needs baseToken, quoteToken, orderId, hash
  • Loading branch information
thanhnguyennguyen committed Dec 14, 2019
2 parents 075a4e5 + c9f9791 commit f96a2bc
Showing 1 changed file with 1 addition and 10 deletions.
11 changes: 1 addition & 10 deletions bot.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,6 @@ func cancelOrder(rpcClient *rpc.Client, nonce *big.Int, orderId uint64) {
order.OrderID = orderId
baseToken := os.Getenv("BASE_TOKEN")
quoteToken := os.Getenv("QUOTE_TOKEN")
d, _ := strconv.Atoi(os.Getenv("QUOTE_DECIMAL"))
priceDecimal, _ := strconv.Atoi(os.Getenv("PRICE_DECIMAL"))
d = d - priceDecimal
quoteDecimal := new(big.Int).Exp(big.NewInt(10), big.NewInt(int64(d)), big.NewInt(0))
// getOrderById
var res interface{}
err := rpcClient.Call(&res, "tomox_getOrderById", baseToken, quoteToken, orderId)
Expand All @@ -155,13 +151,8 @@ func cancelOrder(rpcClient *rpc.Client, nonce *big.Int, orderId uint64) {
}
originOrder := res.(map[string]interface{})
hash := common.HexToHash(originOrder["hash"].(string))
side := originOrder["side"].(string)
p := originOrder["price"].(float64) / float64(quoteDecimal.Uint64())
price := new(big.Int).SetUint64(uint64(p))
price = price.Mul(price, quoteDecimal)
order.Hash = hash
order.Side = side
fmt.Printf("Cancel order: OrderId: %d . OrderHash: %s . Side: %s . Price: %v", orderId, hash.Hex(), side, price)
fmt.Printf("Cancel order: OrderId: %d . OrderHash: %s .", orderId, hash.Hex())
fmt.Println()
newHash := ComputeHash(order)

Expand Down

0 comments on commit f96a2bc

Please sign in to comment.