Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion ts-client/src/examples/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,9 @@ export async function lockLiquidityToFeeVault(

const poolLpAta = getAssociatedTokenAddressSync(
pool.poolState.lpMint,
keypair.publicKey
keypair.publicKey,
// Only needed if dealing with off-curve addresses, like a Squad.
true
);

const lpAmount = await connection
Expand Down
8 changes: 6 additions & 2 deletions ts-client/src/stake-for-fee/helpers/tx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,16 @@ export const computeUnitIx = (units?: number) => {
};

export const unwrapSOLInstruction = async (owner: PublicKey) => {
const wSolATAAccount = getAssociatedTokenAddressSync(NATIVE_MINT, owner);
const wSolATAAccount = getAssociatedTokenAddressSync(
NATIVE_MINT,
owner,
true
);
if (wSolATAAccount) {
const closedWrappedSolInstruction = createCloseAccountInstruction(
wSolATAAccount,
owner,
owner,
owner
);
return closedWrappedSolInstruction;
}
Expand Down
82 changes: 40 additions & 42 deletions ts-client/src/stake-for-fee/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,8 @@ export class StakeForFee {
connection,
poolState.lpMint,
lockEscrowPK,
payer
payer,
true
);

createEscrowAtaIx && preInstructions.push(createEscrowAtaIx);
Expand Down Expand Up @@ -881,15 +882,14 @@ export class StakeForFee {
.remainingAccounts(remainingAccounts)
.transaction();

const [{ blockhash, lastValidBlockHeight }, setCUIx] =
await Promise.all([
this.connection.getLatestBlockhash(),
getEstimatedComputeUnitIxWithBuffer(
this.stakeForFeeProgram.provider.connection,
transaction.instructions,
owner,
)
]);
const [{ blockhash, lastValidBlockHeight }, setCUIx] = await Promise.all([
this.connection.getLatestBlockhash(),
getEstimatedComputeUnitIxWithBuffer(
this.stakeForFeeProgram.provider.connection,
transaction.instructions,
owner
),
]);
transaction.instructions.unshift(setCUIx);

return new Transaction({
Expand Down Expand Up @@ -979,22 +979,21 @@ export class StakeForFee {
.remainingAccounts(remainingAccounts)
.transaction();

const [{ blockhash, lastValidBlockHeight }, setCUIx] =
await Promise.all([
this.connection.getLatestBlockhash(),
getEstimatedComputeUnitIxWithBuffer(
this.stakeForFeeProgram.provider.connection,
transaction.instructions,
owner,
)
]);
const [{ blockhash, lastValidBlockHeight }, setCUIx] = await Promise.all([
this.connection.getLatestBlockhash(),
getEstimatedComputeUnitIxWithBuffer(
this.stakeForFeeProgram.provider.connection,
transaction.instructions,
owner
),
]);
transaction.instructions.unshift(setCUIx);

return new Transaction({
blockhash,
lastValidBlockHeight,
feePayer: owner,
}).add(transaction);
blockhash,
lastValidBlockHeight,
feePayer: owner,
}).add(transaction);
}

/**
Expand Down Expand Up @@ -1031,7 +1030,8 @@ export class StakeForFee {

const userStakeTokenKey = getAssociatedTokenAddressSync(
this.accountStates.feeVault.stakeMint,
owner
owner,
true
);

const remainingAccounts: Array<AccountMeta> = [];
Expand Down Expand Up @@ -1082,15 +1082,14 @@ export class StakeForFee {
.remainingAccounts(remainingAccounts)
.transaction();

const [{ blockhash, lastValidBlockHeight }, setCUIx] =
await Promise.all([
this.connection.getLatestBlockhash(),
getEstimatedComputeUnitIxWithBuffer(
this.stakeForFeeProgram.provider.connection,
transaction.instructions,
owner,
)
]);
const [{ blockhash, lastValidBlockHeight }, setCUIx] = await Promise.all([
this.connection.getLatestBlockhash(),
getEstimatedComputeUnitIxWithBuffer(
this.stakeForFeeProgram.provider.connection,
transaction.instructions,
owner
),
]);
transaction.instructions.unshift(setCUIx);

return new Transaction({
Expand Down Expand Up @@ -1169,15 +1168,14 @@ export class StakeForFee {
.preInstructions(preInstructions)
.transaction();

const [{ blockhash, lastValidBlockHeight }, setCUIx] =
await Promise.all([
this.connection.getLatestBlockhash(),
getEstimatedComputeUnitIxWithBuffer(
this.stakeForFeeProgram.provider.connection,
transaction.instructions,
owner,
)
]);
const [{ blockhash, lastValidBlockHeight }, setCUIx] = await Promise.all([
this.connection.getLatestBlockhash(),
getEstimatedComputeUnitIxWithBuffer(
this.stakeForFeeProgram.provider.connection,
transaction.instructions,
owner
),
]);
transaction.instructions.unshift(setCUIx);

return new Transaction({
Expand Down