I'm trying to make an order request on Serum DEX V3:
tx.add(market.makeNewOrderV3Instruction( {
owner,
payer,
side: 'buy',
price,
size,
orderType: 'ioc',
selfTradeBehavior: 'decrementTake'
}));
and then later:
await web3.sendAndConfirmTransaction(con, tx, txSigners);
But i face the following error:
Transaction simulation failed: Error processing Instruction 0: custom program error: 0x1000757
Program 9xQeWvG816bUx9EPjHmaT23yvVM2ZWbrrpZb9PusVFin invoke [1]
Program 9xQeWvG816bUx9EPjHmaT23yvVM2ZWbrrpZb9PusVFin consumed 4018 of 200000 compute units
Program 9xQeWvG816bUx9EPjHmaT23yvVM2ZWbrrpZb9PusVFin failed: custom program error: 0x1000757
(node:12224) UnhandledPromiseRejectionWarning: Error: failed to send transaction: Transaction simulation failed: Error processing Instruction 0: custom program error: 0x1000757
I double checked all input accounts and params which are required by serum SDK to make a new order instruction, but I could not solve the issue.
Just in case anyone stumbles on this question, lemme explain how to read these sorts of error messages in general, i.e. teach you how to fish.
Serum DEX has three classes of custom program errors it returns:
0x22
0x3E8
- good luck!For "business errors", you can decipher them by converting the hexadecimal number to decimal and then looking up the corresponding error, starting from the top in the source code.
The assertion errors occur when an assert condition in the code is tripped. The returned error code is deciphered differently. The first 8 bit is the ID of the file where the assertion is and the last 16 bit is the line number of where the assertion is.
Let's take
0x1000757
from the question. Splitting it into the two portions and converting each to decimal gives us: File #1, line number 1879. The file ID lookup can be found here.One problem you will face with Serum errors is that it is all very dependent on the source code. We have no way to know which version/commit of the code is currently deployed to the mainnet. In most cases, I roughly guess the appropriate commit, view the relevant file at the time of that commit and look in the range of the line number to see if there are any asserts. This normally gives me a hint about what is wrong with my instructions.