| 532 | } |
| 533 | |
| 534 | Value gendexoperatorordertx(const Array& params, bool fHelp) { |
| 535 | if (fHelp || params.size() < 10 || params.size() > 13) { |
| 536 | throw runtime_error( |
| 537 | "gendexoperatorordertx \"sender\" \"order_type\" \"order_side\" \"symbol:coins:unit\" \"symbol:assets:unit\"" |
| 538 | " price dex_id \"open_mode\" taker_fee_ratio maker_fee_ratio \"[symbol:fee:unit]\"" |
| 539 | " \"[symbol:operator_tx_fee:unit]\" \"[memo]\"\n" |
| 540 | "\ngenerator an operator dex order tx, support operator config, and must be signed by operator before sumiting.\n" |
| 541 | "\nArguments:\n" |
| 542 | "1.\"sender\": (string required) the tx sender's address\n" |
| 543 | "2.\"order_type\": (string required) order type, must be in (LIMIT_PRICE, MARKET_PRICE)\n" |
| 544 | "3.\"order_side\": (string required) order side, must be in (BUY, SELL)\n" |
| 545 | "4.\"symbol:coins:unit\": (string:numeric:string, required) the coins(money) of order, coins=0 if not market buy order, \n" |
| 546 | "default symbol is WUSD, default unit is sawi.\n" |
| 547 | "5.\"symbol:assets:unit\",(string:numeric:string, required) the assets of order, assets=0 if market buy order" |
| 548 | "default symbol is WICC, default unit is sawi.\n" |
| 549 | "6.\"price\": (numeric, required) expected price of order, boost 100000000\n" |
| 550 | "7.\"dex_id\": (numeric, required) Decentralized Exchange(DEX) ID\n" |
| 551 | "8.\"open_mode\": (string, required) indicate the order is PUBLIC or PRIVATE\n" |
| 552 | "9.\"taker_fee_ratio\": (numeric, required) taker fee ratio config by operator, boost 100000000\n" |
| 553 | "10.\"maker_fee_ratio\": (numeric, required) maker fee ratio config by operator, boost 100000000\n" |
| 554 | "11.\"symbol:fee:unit\":(string:numeric:string, optional) fee pay by tx user to miner, default is WICC:10000:sawi\n" |
| 555 | "12.\"symbol:operator_tx_fee:unit\":(string:numeric:string, optional) tx fee pay by operator to miner," |
| 556 | "symbol must equal to fee, default is WICC:0:sawi\n" |
| 557 | "13.\"memo\": (string, optional) memo\n" |
| 558 | "\nResult:\n" |
| 559 | "\"txid\" (string) The transaction id.\n" |
| 560 | "\nExamples:\n" |
| 561 | + HelpExampleCli("gendexoperatorordertx", "\"10-3\" \"LIMIT_PRICE\" \"BUY\" \"WUSD:0\" \"WICC:2000000000:sawi\"" |
| 562 | " 100000000 0 \"PUBLIC\" 80000 40000\n") |
| 563 | + "\nAs json rpc call\n" |
| 564 | + HelpExampleRpc("gendexoperatorordertx", "\"10-3\", \"LIMIT_PRICE\", \"BUY\", \"WUSD:0\", \"WICC:2000000000:sawi\"," |
| 565 | " 100000000, 0, \"PUBLIC\", 80000, 40000\n") |
| 566 | ); |
| 567 | } |
| 568 | |
| 569 | EnsureWalletIsUnlocked(); |
| 570 | int32_t validHeight = chainActive.Height(); |
| 571 | FeatureForkVersionEnum version = GetFeatureForkVersion(validHeight); |
| 572 | const TxType txType = DEX_OPERATOR_ORDER_TX; |
| 573 | |
| 574 | if (version < MAJOR_VER_R3) { |
| 575 | throw JSONRPCError(RPC_INVALID_PARAMS, strprintf("unsupport to call %s() before R3 fork height=%d", |
| 576 | __func__, SysCfg().GetVer3ForkHeight())); |
| 577 | } |
| 578 | |
| 579 | const CUserID &userId = RPC_PARAM::GetUserId(params[0], true); |
| 580 | OrderType orderType = RPC_PARAM::GetOrderType(params[1]); |
| 581 | OrderSide orderSide = RPC_PARAM::GetOrderSide(params[2]); |
| 582 | const ComboMoney &coins = RPC_PARAM::GetComboMoney(params[3]); |
| 583 | const ComboMoney &assets = RPC_PARAM::GetComboMoney(params[4], SYMB::WICC); |
| 584 | uint64_t price = RPC_PARAM::GetPrice(params[5]); |
| 585 | DexID dexId = RPC_PARAM::GetDexId(params[6]); |
| 586 | OpenMode openMode = RPC_PARAM::GetOrderOpenMode(params[7]); |
| 587 | uint64_t takerFeeRatio = RPC_PARAM::GetOperatorFeeRatio(params[8]); |
| 588 | uint64_t makerFeeRatio = RPC_PARAM::GetOperatorFeeRatio(params[9]); |
| 589 | auto [txFee, minTxFeeAmount] = RPC_PARAM::ParseTxFee(params, 10, txType); |
| 590 | ComboMoney operatorTxFee = RPC_PARAM::GetOperatorTxFee(params, 11); |
| 591 | string memo = RPC_PARAM::GetMemo(params, 12); |
nothing calls this directly
no test coverage detected