protocol-v2 icon indicating copy to clipboard operation
protocol-v2 copied to clipboard

Can not modify via user order id

Open sakib1361 opened this issue 9 months ago • 1 comments

When using user order id, I can place order but cannot modify that order via user order id.


async def main():
    logger.info("Starting...")
    dotenv.load_dotenv()
    rpc_url = os.getenv("RPC_TRITON")
    private_key = os.getenv("PRIVATE_KEY")
    if not rpc_url or not private_key:
        raise Exception("Missing env vars")
    kp = load_keypair(private_key)

    drift_client = DriftClient(
        connection=AsyncClient(rpc_url),
        wallet=Wallet(kp),
        env="devnet"
    )
    
    await drift_client.subscribe()
    await drift_client.cancel_orders()
    order_params = OrderParams(
            order_type=OrderType.Limit(),
            base_asset_amount=drift_client.convert_to_perp_precision(0.01),
            market_index=0,
            user_order_id=21,
            market_type=MarketType.Perp,
            direction=PositionDirection.Long(),
            price=drift_client.convert_to_price_precision(125),
            post_only=PostOnlyParams.TryPostOnly(),
        )
    
    await drift_client.place_perp_order(order_params)
    order_mod = ModifyOrderParams(price=drift_client.convert_to_price_precision(124))
    await drift_client.modify_order_by_user_id(21, order_mod)

The order place response {"name":"placePerpOrder","accounts":[{"name":"state","isMut":false,"isSigner":false},{"name":"user","isMut":true,"isSigner":false},{"name":"authority","isMut":false,"isSigner":true}],"args":[{"name":"params","type":{"defined":"OrderParams"}}]} 45a15dca787e4cb90101001580969800000000004059730700000000000000020000000000000000 And was ok.

However, when modifying, it failed. The response is recieved as { message: "Transaction simulation failed: Error processing Instruction 2: custom program error: 0x17b7", data: RpcSimulateTransactionResult(RpcSimulateTransactionResult { err: Some(InstructionError(2, Custom(6071))), logs: Some([ "Program ComputeBudget111111111111111111111111111111 invoke [1]", "Program ComputeBudget111111111111111111111111111111 success", "Program ComputeBudget111111111111111111111111111111 invoke [1]", "Program ComputeBudget111111111111111111111111111111 success", "Program dRiftyHA39MWEi3m9aunc5MzRF1JYuBsbn6VPcn33UH invoke [1]", "Program log: Instruction: ModifyOrderByUserId", "Program log: 4DRDR8LtbQHSjdJnAAAAAAEAAAABAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAbiqjxg72gl7oxM1f2LHSMXAR4BnerlEOssXBpua5XagAVEAAAABAAGAlpgAAAAAAAEAAAAAAAAAAAEAAAAAAAAAAGByZwcAAAAA", "Program log: user_order_id is already in use 21", "Program log: AnchorError occurred. Error Code: UserOrderIdAlreadyInUse. Error Number: 6071. Error Message: User Order Id Already In Use.", "Program dRiftyHA39MWEi3m9aunc5MzRF1JYuBsbn6VPcn33UH consumed 18279 of 599700 compute units", "Program dRiftyHA39MWEi3m9aunc5MzRF1JYuBsbn6VPcn33UH failed: custom program error: 0x17b7" ]), accounts: None, units_consumed: Some(18579), return_data: None, inner_instructions: None }) }

I have also tested with our own implementation of c#. The output remains same.

sakib1361 avatar Mar 13 '25 07:03 sakib1361

was this on devnet or mainnet?

crispheaney avatar Apr 02 '25 18:04 crispheaney

Devnet.

sakib1361 avatar May 15 '25 07:05 sakib1361