-
Notifications
You must be signed in to change notification settings - Fork 89
Instruction moveLockedLp doesn't exists? #213
Copy link
Copy link
Open
Description
Hello!
I was trying to use moveLockedLp instruction and fixed #212 locally, copying over function from ts sdk.
But the transaction actually failed with AnchorError occurred. Error Code: InstructionFallbackNotFound. which basically means that there is no such instruction in the program.
Here is the code to prepare instruction:
// Have to copy this function from the dynamic-amm-sdk, as the original function is private and has error
private async _moveLockedLP(
owner: PublicKey,
newOwner: PublicKey,
maxAmount: BN,
payer?: PublicKey,
) {
// revert if not initialized
if (!this.client) {
throw new Error('DammV1 not initialized')
}
payer = payer ?? owner
const [ownerLockEscrowPK] = deriveLockEscrowPda(this.poolId, owner, DammV1.PROGRAM_ID)
const [newOwnerLockEscrowPK] = deriveLockEscrowPda(this.poolId, newOwner, DammV1.PROGRAM_ID)
const poolState = await this.getPoolState()
const vaultA = this.client.vaultA
const vaultB = this.client.vaultB
const preInstructions: TransactionInstruction[] = []
const { ammProgram } = createProgram(this.connection, DammV1.PROGRAM_ID.toBase58())
const newOwnerLockEscrow =
await ammProgram.account.lockEscrow.fetchNullable(newOwnerLockEscrowPK)
if (!newOwnerLockEscrow) {
const createLockEscrowIx = await ammProgram.methods
.createLockEscrow()
.accounts({
pool: this.poolId,
lockEscrow: newOwnerLockEscrowPK,
owner: newOwner,
lpMint: poolState.lpMint,
payer,
systemProgram: SystemProgram.programId,
})
.instruction()
preInstructions.push(createLockEscrowIx)
}
// FIXME Original function has error: TokenOwnerOffCurveError, and ownerLockEscrowPK is not on curve 100%
const fromEscrowVault = getAssociatedTokenAddressSync(poolState.lpMint, ownerLockEscrowPK, true)
const [toEscrowVault, createToEscrowVaultIx] = await getOrCreateATAInstruction(
poolState.lpMint,
newOwnerLockEscrowPK,
this.connection,
payer,
)
createToEscrowVaultIx && preInstructions.push(createToEscrowVaultIx)
const tx = await ammProgram.methods
.moveLockedLp(maxAmount)
.accounts({
pool: this.poolId,
lpMint: poolState.lpMint,
fromLockEscrow: ownerLockEscrowPK,
toLockEscrow: newOwnerLockEscrowPK,
owner,
fromEscrowVault,
toEscrowVault,
tokenProgram: TOKEN_PROGRAM_ID,
aVault: poolState.aVault,
bVault: poolState.bVault,
aVaultLp: poolState.aVaultLp,
bVaultLp: poolState.bVaultLp,
aVaultLpMint: vaultA.vaultState.lpMint,
bVaultLpMint: vaultB.vaultState.lpMint,
})
.preInstructions(preInstructions)
.transaction()
return tx.instructions
}And the onchain tx logs (local validator with copied program):
[
"Program ComputeBudget111111111111111111111111111111 invoke [1]",
"Program ComputeBudget111111111111111111111111111111 success",
"Program Eo7WjKq67rjJQSZxS6z3YkapzY3eMj6Xy8X5EQVn5UaB invoke [1]",
"Program log: Instruction: ClaimFee",
"Program Eo7WjKq67rjJQSZxS6z3YkapzY3eMj6Xy8X5EQVn5UaB consumed 40163 of 1002850 compute units",
"Program Eo7WjKq67rjJQSZxS6z3YkapzY3eMj6Xy8X5EQVn5UaB success",
"Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA invoke [1]",
"Program log: Instruction: CloseAccount",
"Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA consumed 2915 of 962687 compute units",
"Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA success",
"Program Eo7WjKq67rjJQSZxS6z3YkapzY3eMj6Xy8X5EQVn5UaB invoke [1]",
"Program log: Instruction: CreateLockEscrow",
"Program 11111111111111111111111111111111 invoke [2]",
"Program 11111111111111111111111111111111 success",
"Program data: Sl5qjTERYm2bnFKG5Z3vSUUo17vgQEgzFVmUCMux2ezFIyxX81a7Uo/FzRvCWCNZH0DSfPNd+E7xIC+m8EsEwarDQTcR3Tty",
"Program Eo7WjKq67rjJQSZxS6z3YkapzY3eMj6Xy8X5EQVn5UaB consumed 19056 of 959772 compute units",
"Program Eo7WjKq67rjJQSZxS6z3YkapzY3eMj6Xy8X5EQVn5UaB success",
"Program ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL invoke [1]",
"Program log: Create",
"Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA invoke [2]",
"Program log: Instruction: GetAccountDataSize",
"Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA consumed 1595 of 933774 compute units",
"Program return: TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA pQAAAAAAAAA=",
"Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA success",
"Program 11111111111111111111111111111111 invoke [2]",
"Program 11111111111111111111111111111111 success",
"Program log: Initialize the associated token account",
"Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA invoke [2]",
"Program log: Instruction: InitializeImmutableOwner",
"Program log: Please upgrade to SPL Token 2022 for immutable owner support",
"Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA consumed 1405 of 927161 compute units",
"Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA success",
"Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA invoke [2]",
"Program log: Instruction: InitializeAccount3",
"Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA consumed 4214 of 923279 compute units",
"Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA success",
"Program ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL consumed 21955 of 940716 compute units",
"Program ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL success",
"Program Eo7WjKq67rjJQSZxS6z3YkapzY3eMj6Xy8X5EQVn5UaB invoke [1]",
"Program log: AnchorError occurred. Error Code: InstructionFallbackNotFound. Error Number: 101. Error Message: Fallback functions are not supported.",
"Program Eo7WjKq67rjJQSZxS6z3YkapzY3eMj6Xy8X5EQVn5UaB consumed 4387 of 918761 compute units",
"Program Eo7WjKq67rjJQSZxS6z3YkapzY3eMj6Xy8X5EQVn5UaB failed: custom program error: 0x65"
]
Can you check this issue please?
Cheers.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels