Description
initializePositionByOperator derives positionPda with one positionWidth value but invokes the program with another, causing a PDA mismatch and transaction failure.
Details
The initializePositionByOperator function derives positionPda using the provided positionWidth:
|
const [positionPda, _bump] = derivePosition( |
|
this.pubkey, |
|
base, |
|
lowerBinId, |
|
positionWidth, |
|
this.program.programId |
|
); |
However, when calling the program method initializePositionByOperator, it uses DEFAULT_BIN_PER_POSITION instead of the provided positionWidth:
|
const initializePositionByOperatorTx = await this.program.methods |
|
.initializePositionByOperator( |
|
lowerBinId.toNumber(), |
|
DEFAULT_BIN_PER_POSITION.toNumber(), |
|
feeOwner, |
|
lockReleasePoint |
|
) |
As a result, the on-chain program derives a different positionPda, leading to a transaction failure:
{
"transactionMessage": "Transaction simulation failed: Error processing Instruction 0: custom program error: 0x7d6",
"transactionLogs": [
"Program LBUZKhRxPF3XUpBCjp4YzTKgLccjZhTSDM9YuVaPwxo invoke [1]",
"Program log: Instruction: InitializePositionByOperator",
"Program log: AnchorError caused by account: position. Error Code: ConstraintSeeds. Error Number: 2006. Error Message: A seeds constraint was violated.",
"Program log: Left:",
"Program log: 77Vr1EQF9TQZbTrGK9PRFZNz1ULUE1s4c1Bs5XHbcYXB",
"Program log: Right:",
"Program log: GkCgxJfRsH6Xhf84UB6QwDqizYnzkMeuEd8fsWPfPvhY",
"Program LBUZKhRxPF3XUpBCjp4YzTKgLccjZhTSDM9YuVaPwxo consumed 11701 of 200000 compute units",
"Program LBUZKhRxPF3XUpBCjp4YzTKgLccjZhTSDM9YuVaPwxo failed: custom program error: 0x7d6"
]
}
This indicates a mismatch between the client-side PDA derivation and the program’s expectation.
Suggested fix
Replace usage of DEFAULT_BIN_PER_POSITION with the provided positionWidth parameter when invoking the program method.
Description
initializePositionByOperatorderivespositionPdawith onepositionWidthvalue but invokes the program with another, causing a PDA mismatch and transaction failure.Details
The
initializePositionByOperatorfunction derivespositionPdausing the providedpositionWidth:dlmm-sdk/ts-client/src/dlmm/index.ts
Lines 6423 to 6429 in 43e231e
However, when calling the program method
initializePositionByOperator, it usesDEFAULT_BIN_PER_POSITIONinstead of the providedpositionWidth:dlmm-sdk/ts-client/src/dlmm/index.ts
Lines 6445 to 6451 in 43e231e
As a result, the on-chain program derives a different
positionPda, leading to a transaction failure:{ "transactionMessage": "Transaction simulation failed: Error processing Instruction 0: custom program error: 0x7d6", "transactionLogs": [ "Program LBUZKhRxPF3XUpBCjp4YzTKgLccjZhTSDM9YuVaPwxo invoke [1]", "Program log: Instruction: InitializePositionByOperator", "Program log: AnchorError caused by account: position. Error Code: ConstraintSeeds. Error Number: 2006. Error Message: A seeds constraint was violated.", "Program log: Left:", "Program log: 77Vr1EQF9TQZbTrGK9PRFZNz1ULUE1s4c1Bs5XHbcYXB", "Program log: Right:", "Program log: GkCgxJfRsH6Xhf84UB6QwDqizYnzkMeuEd8fsWPfPvhY", "Program LBUZKhRxPF3XUpBCjp4YzTKgLccjZhTSDM9YuVaPwxo consumed 11701 of 200000 compute units", "Program LBUZKhRxPF3XUpBCjp4YzTKgLccjZhTSDM9YuVaPwxo failed: custom program error: 0x7d6" ] }This indicates a mismatch between the client-side PDA derivation and the program’s expectation.
Suggested fix
Replace usage of
DEFAULT_BIN_PER_POSITIONwith the providedpositionWidthparameter when invoking the program method.