Skip to main content
async def cancelOpenOrder(marketId: int, openOrderId: int):
    contract = retrieveContract()
    w3 = retrieveWeb3Instance()

    orders = await retrieveOrders()
    for i, order in enumerate(orders, 0):
        if order.order_id == openOrderId:
            retVal = order

    transaction = contract.functions.cancelOrder(
        marketId, openOrderId, False
    ).build_transaction(
        {
            "from": Web3.to_checksum_address(os.getenv("ACCOUNT")),
            "nonce": w3.eth.get_transaction_count(
                Web3.to_checksum_address(os.getenv("ACCOUNT"))
            ),
            "gas": GAS_VALUE,
            "gasPrice": math.ceil(w3.eth.gas_price + (w3.eth.gas_price * 0.25)),
        }
    )
    await submitTransactionWithOracle(w3, transaction, marketId)
    print(retVal)
    return retVal