Skip to main content

createMarketAccrueEmissionInstruction

Builds a raw instruction to accrue farm emissions for a liquidity provider position. This updates the internal accounting for all active farm emissions that the position is entitled to, based on the LP’s share of liquidity and time elapsed since the last accrual.
This instruction must be called before collecting emissions to ensure all pending rewards are calculated.

Usage

import { createMarketAccrueEmissionInstruction } from "@exponent-labs/exponent-sdk/client/clmm";
import { PublicKey, SystemProgram } from "@solana/web3.js";

// Example: Accrue all pending emissions for an LP position
const ix = createMarketAccrueEmissionInstruction({
  owner: lpOwner.publicKey,
  market: marketAddress,
  ticks: ticksAccount,
  lpPosition: lpPositionAccount,
  addressLookupTable: lookupTableAddress,
  syProgram: syProgramId,
  systemProgram: SystemProgram.programId,
  eventAuthority: eventAuthorityPda,
  program: clmmProgramId,
});

Accounts

NameTypeSignerWritableDescription
ownerPublicKeyYesYesLP position owner
marketPublicKeyNoYesThe CLMM market account
ticksPublicKeyNoYesThe market tick array account
lpPositionPublicKeyNoYesLP position account
addressLookupTablePublicKeyNoNoMarket address lookup table
syProgramPublicKeyNoNoSY program
systemProgramPublicKeyNoNoSystem program
eventAuthorityPublicKeyNoNoEvent authority PDA
programPublicKeyNoNoCLMM program ID

Args

This instruction takes no arguments.

Behavior

The instruction:
  1. Fetches the current state of all active farm emissions in the market
  2. Calculates time-weighted emissions accrued since last update
  3. Updates the LP position’s internal trackers for each emission token
  4. Stages the accrued tokens for collection
The accrued amounts depend on:
  • LP position’s share of liquidity in the active tick range
  • Time elapsed since last accrual
  • Emission rates for each active farm
  • Current tick position relative to LP position bounds

Returns

Returns a MarketAccrueEmissionEvent containing:
type MarketAccrueEmissionEvent = {
  ownerAddress: PublicKey;
  marketAddress: PublicKey;
  lpPosition: PublicKey;
  lpBalance: bigint;
  lowerTick: number;
  upperTick: number;
  tokensOwedSy: bigint;
  tokensOwedPt: bigint;
  farms: PersonalYieldTrackers; // Updated emission trackers
  shareTrackers: PrincipalShareTrackers;
  feeInsideLastPt: bigint; // u128
  feeInsideLastSy: bigint; // u128
};
TransactionInstruction — a transaction instruction ready to be added to a transaction.