> ## Documentation Index
> Fetch the complete documentation index at: https://docs.exponent.finance/llms.txt
> Use this file to discover all available pages before exploring further.

# Market Accrue Emission

> Low-level instruction to accrue farm emissions for an LP position

# 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.

<Info>This instruction must be called before collecting emissions to ensure all pending rewards are calculated.</Info>

## Usage

```typescript theme={null}
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

| Name                 | Type        | Signer | Writable | Description                   |
| -------------------- | ----------- | ------ | -------- | ----------------------------- |
| `owner`              | `PublicKey` | Yes    | Yes      | LP position owner             |
| `market`             | `PublicKey` | No     | Yes      | The CLMM market account       |
| `ticks`              | `PublicKey` | No     | Yes      | The market tick array account |
| `lpPosition`         | `PublicKey` | No     | Yes      | LP position account           |
| `addressLookupTable` | `PublicKey` | No     | No       | Market address lookup table   |
| `syProgram`          | `PublicKey` | No     | No       | SY program                    |
| `systemProgram`      | `PublicKey` | No     | No       | System program                |
| `eventAuthority`     | `PublicKey` | No     | No       | Event authority PDA           |
| `program`            | `PublicKey` | No     | No       | CLMM 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:

```typescript theme={null}
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.
