Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sometimes get error's when creating a new order #161

Open
Gsuz opened this issue Sep 10, 2021 · 4 comments
Open

Sometimes get error's when creating a new order #161

Gsuz opened this issue Sep 10, 2021 · 4 comments

Comments

@Gsuz
Copy link

Gsuz commented Sep 10, 2021

Sometimes new order fails with the following:

Transaction simulation failed: Error processing Instruction 0: custom program error: 0x22
Program 9xQeWvG816bUx9EPjHmaT23yvVM2ZWbrrpZb9PusVFin invoke [1]
Program 9xQeWvG816bUx9EPjHmaT23yvVM2ZWbrrpZb9PusVFin consumed 8970 of 200000 compute units
Program 9xQeWvG816bUx9EPjHmaT23yvVM2ZWbrrpZb9PusVFin failed: custom program error: 0x22
/Users/borkur/Desktop/Coding/server-sunny/node_modules/@solana/web3.js/lib/index.cjs.js:4882
throw new SendTransactionError('failed to send transaction: ' + res.error.message, logs);
^

SendTransactionError: failed to send transaction: Transaction simulation failed: Error processing Instruction 0: custom program error: 0x22
at Connection.sendEncodedTransaction (/Users/borkur/Desktop/Coding/server-sunny/node_modules/@solana/web3.js/lib/index.cjs.js:4882:13)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async Connection.sendRawTransaction (/Users/borkur/Desktop/Coding/server-sunny/node_modules/@solana/web3.js/lib/index.cjs.js:4840:20)
at async Connection.sendTransaction (/Users/borkur/Desktop/Coding/server-sunny/node_modules/@solana/web3.js/lib/index.cjs.js:4830:12)
at async Market._sendTransaction (/Users/borkur/Desktop/Coding/server-sunny/node_modules/@project-serum/serum/lib/market.js:504:27)
at async Market.placeOrder (/Users/borkur/Desktop/Coding/server-sunny/node_modules/@project-serum/serum/lib/market.js:249:16)
at async Timeout.startServer [as _onTimeout] (file:///Users/borkur/Desktop/Coding/server-sunny/server-sunny.js:215:5) {
logs: [
'Program 9xQeWvG816bUx9EPjHmaT23yvVM2ZWbrrpZb9PusVFin invoke [1]',
'Program 9xQeWvG816bUx9EPjHmaT23yvVM2ZWbrrpZb9PusVFin consumed 8970 of 200000 compute units',
'Program 9xQeWvG816bUx9EPjHmaT23yvVM2ZWbrrpZb9PusVFin failed: custom program error: 0x22'
]
}

@Gsuz
Copy link
Author

Gsuz commented Sep 10, 2021

My code is from the example:

await market.placeOrder(connection, {
  owner,
  payer: quoteTokenAddress,
  side: "buy", // 'buy' or 'sell'
  price: 0.11,
  size: 2500,
  orderType: "postOnly", // 'limit', 'ioc', 'postOnly'
});

@dahifi
Copy link

dahifi commented Sep 12, 2021

Not sure, but I think the 'simulation failed' errors are related to some kind of backend RPC issue caused by congestion. That's why it's intermittent. The solution is to run your own validator, but I know that's an expensive answer.

@Gsuz
Copy link
Author

Gsuz commented Sep 12, 2021

Can I simply connect to another validator that's less used?

@jimmyntu
Copy link

jimmyntu commented May 13, 2022

I face the similar issue.

 let result_place_order = await market.placeOrder(connection, {
    owner,
    payer,
    side: 'buy', // 'buy' or 'sell'
    price: 10,
    size: 0.1,
    orderType: 'limit', // 'limit', 'ioc', 'postOnly'
  });
  console.log("Place order result: ", result_place_order)

When connection pointing to https://api.mainnet-beta.solana.com/ it always fails.

(node:91704) UnhandledPromiseRejectionWarning: Error: failed to send transaction: Transaction simulation failed: Error processing Instruction 0: custom program error: 0x1000760
    at Connection.sendEncodedTransaction (/Users/jiaming/my_project/crypto-trading/node-try/node_modules/@solana/web3.js/lib/index.cjs.js:6936:13)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at async Connection.sendRawTransaction (/Users/jiaming/my_project/crypto-trading/node-try/node_modules/@solana/web3.js/lib/index.cjs.js:6897:20)
    at async Connection.sendTransaction (/Users/jiaming/my_project/crypto-trading/node-try/node_modules/@solana/web3.js/lib/index.cjs.js:6887:12)
    at async Market._sendTransaction (/Users/jiaming/my_project/crypto-trading/node-try/node_modules/@project-serum/serum/lib/market.js:510:27)
    at async Market.placeOrder (/Users/jiaming/my_project/crypto-trading/node-try/node_modules/@project-serum/serum/lib/market.js:251:16)
    at async run_serum (/Users/jiaming/my_project/crypto-trading/node-try/serum-test.js:47:28)
(node:91704) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:91704) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

When change the connection to https://solana-api.projectserum.com/, the order goes through.

In this case, I cannot connect to my own validator to place order.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants