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

# Lend Referral Reference

> Program addresses, accounts, wrapper fields, limits, instructions, errors and events for Lend Referral.

Lookup tables for the Lend Referral program. For how the program behaves, see the [Lend Referral Overview](https://developers.jup.ag/docs/lend/referral.md) and [Fees and Yield](https://developers.jup.ag/docs/lend/referral/fees.md). Instruction, field and parameter names follow `@jup-ag/lend-referral-sdk`.

## Program addresses

| Program | Address | SDK constant |
| - | - | - |
| Lend Referral | `LrefWFcNXGnLxnQUdKmuJ1U3fUrFBdNkm6xCfVfWwQW` | `LENDING_REFERRAL_PROGRAM_ADDRESS` |
| Jupiter Lend (Earn) | `jup3YeL8QhtSx1e253b2FDvsMNC87fDrgQZivbrndc9` | `LENDING_PROGRAM_ADDRESS` |
| Jupiter Lend (Liquidity) | `jupeiUmn818Jg1ekPURTpr4mFo29p46vygyykFJ3wZC` | `LIQUIDITY_PROGRAM_ADDRESS` |
| Metaplex Token Metadata | `metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s` | `TOKEN_METADATA_PROGRAM_ADDRESS` |

## Accounts

| Account | Derivation | SDK helper |
| - | - | - |
| Protocol config | PDA `["protocol_config"]` of the Lend Referral program | `findProtocolConfigPda()` |
| Wrapper config | PDA `["wrapper_config", xTokenMint]` of the Lend Referral program | `findWrapperConfigPda({ xTokenMint })` |
| Vault | Associated token account of the wrapper config for the jlToken mint | `ctx.wrapper.data.vault` |
| Underlying transit account | Associated token account of the wrapper config for the underlying mint. Empty between instructions. | `ctx.wrapper.data.wrapperUnderlyingAta` |
| Lending account | PDA `["lending", underlyingMint, jlTokenMint]` of Jupiter Lend (Earn) | `findLendingAddress({ underlyingMint, jlTokenMint })` |
| xToken metadata | Metaplex PDA `["metadata", TOKEN_METADATA_PROGRAM_ADDRESS, xTokenMint]` | `findXTokenMetadataAddress(xTokenMint)` |

`findProtocolConfigPda` and `findWrapperConfigPda` resolve to `[address, bump]`. The other helpers resolve to an address.

## Wrapper fields

`WrapperConfig`, read through `resolveWrapper` as `ctx.wrapper.data`:

| Field | Type and unit | Meaning |
| - | - | - |
| `authority` | `Address` | Wrapper authority |
| `jlTokenMint` | `Address` | jlToken mint of the market. Fixed at creation. |
| `lending` | `Address` | Lending account of the market. Fixed at creation. |
| `xTokenMint` | `Address` | xToken mint. Fixed at creation. |
| `vault` | `Address` | jlToken vault. Fixed at creation. |
| `wrapperUnderlyingAta` | `Address` | Underlying transit account. Fixed at creation. |
| `partnerFeeRecipient` | `Address` | jlToken token account that receives partner fees |
| `claimAuthority` | `Option<Address>` | Claim authority. `None`: anyone can trigger a partner claim. |
| `partnerFeeBps` | `number`, bps of user yield | Partner fee |
| `protocolFeeShareBps` | `number`, bps of the partner fee | Protocol share applied to the yield pending since the last accrue |
| `protocolFeeShareOverride` | `Option<number>`, bps of the partner fee | Share Jupiter set for this wrapper. `None`: the wrapper follows the global share. |
| `totalUserJLTokenBalance` | `bigint`, jlToken atoms × 10^6 | Users' balance |
| `accruedProtocolFeeJLTokens` | `bigint`, jlToken atoms × 10^6 | Jupiter's balance |
| `lastJLTokenPrice` | `bigint`, underlying per jlToken × 10^12 | Exchange price at the last accrue (the fee checkpoint) |
| `totalXShares` | `bigint`, xToken atoms | Circulating xTokens plus the locked seed shares |
| `lockedXShares` | `bigint`, xToken atoms | Seed shares. Never minted. Fixed at creation. |
| `bump` | `number` | PDA bump |

The partner's balance is not stored. It is the vault balance less the users' and Jupiter's balances. The stored balances exclude the fee since the last accrue: project them with `simulateAccrue` before you compute a value.

`claimAuthority` and `protocolFeeShareOverride` are Kit `Option`s. Read them with `unwrapOption` or `isSome` from `@solana/kit`.

`ProtocolConfig`, read as `ctx.protocol.data` or with `fetchProtocol`:

| Field | Type | Meaning |
| - | - | - |
| `authority` | `Address` | Protocol authority (Jupiter) |
| `protocolFeeShareBps` | `number`, bps of the partner fee | Global protocol share |
| `paused` | `boolean` | `true` while the protocol is paused |
| `bump` | `number` | PDA bump |

## Limits

| Limit | Value | SDK constant |
| - | - | - |
| Partner fee | 0 to 1000 bps (10% of user yield) | `MAX_YIELD_FEE_BPS` |
| Protocol share | 0 to 2500 bps (25% of the partner fee). Currently 2500. | `MAX_PROTOCOL_FEE_SHARE_BPS` |
| Smallest underlying amount on the underlying path | 10 underlying atoms | `MIN_UNDERLYING_AMOUNT` |
| Seed | More than 1,000,000 jlToken atoms, and at most 10 whole jlTokens | `MIN_SEED_JL_AMOUNT`, `MAX_SEED_WHOLE_JL_TOKENS` |
| xToken name | 32 bytes | |
| xToken symbol | 10 bytes | |
| xToken metadata URI | 200 bytes | |
| Claim everything | Claim amount `2^64 − 1`. The SDK sends it for `amount: "all"`. | `U64_MAX` |
| Suggested slippage | 50 bps. The SDK never applies it unless you pass it. | `DEFAULT_SLIPPAGE_BPS` |
| Fee basis | 10,000 bps = 100% | `FEE_PRECISION` |

## Instructions

This section lists the instructions that users, partners and anyone can call. Jupiter-only instructions are not listed. Instruction and argument names are the SDK's: `get<Name>Instruction` builds each instruction, for example `getDepositJLTokenInstruction`.

### User instructions

Every user instruction accrues first and is blocked while the protocol is paused. Amounts are raw token atoms. Rounding always favours the pool.

| Instruction | Arguments | Returns | SDK action |
| - | - | - | - |
| `depositJLToken` | `jlAmount` | xTokens minted | `depositJLToken` |
| `depositJLTokenWithMinXOut` | `jlAmount`, `minXOut` | xTokens minted | `depositJLToken` |
| `redeemToJLToken` | `xShares` | jlTokens paid | `redeemToJLToken` |
| `redeemToJLTokenWithMinOut` | `xShares`, `minJLOut` | jlTokens paid | `redeemToJLToken` |
| `depositUnderlying` | `underlyingAmount` | xTokens minted | `depositUnderlying` |
| `depositUnderlyingWithMinXOut` | `underlyingAmount`, `minXOut` | xTokens minted | `depositUnderlying` |
| `mintUnderlying` | `xToMint`, `maxUnderlyingIn` | Underlying charged | `mintUnderlying` |
| `redeemToUnderlying` | `xShares` | Underlying paid | `redeemToUnderlying` |
| `redeemToUnderlyingWithMinOut` | `xShares`, `minUnderlyingOut` | Underlying paid | `redeemToUnderlying` |
| `withdrawToUnderlying` | `underlyingOut`, `maxXIn` | xTokens burned | `withdrawToUnderlying` |

The signer is the user. The SDK action sends the `...WithMin...` variant when you pass a bound, and the plain instruction for `bound: "unbounded"`. `mintUnderlying` and `withdrawToUnderlying` always carry a maximum-input bound.

### Partner and permissionless instructions

| Instruction | Signer | Arguments | Accrues first | Blocked while paused | SDK function |
| - | - | - | - | - | - |
| `accrue` | None. Only the transaction fee payer signs. | none | Yes | Yes | `accrue` |
| `claimPartnerFees` | Anyone when no claim authority is set. Otherwise the claim authority, the wrapper authority, or the owner of the fee recipient account. | `amount` (`2^64 − 1` claims everything) | Yes | Yes | `claimPartnerFees` |
| `updatePartnerFee` | Wrapper authority | `newFeeBps` (at most 1000) | Yes | Yes | `updatePartnerFee` |
| `updatePartnerFeeRecipient` | Wrapper authority | None. The new recipient is the `newRecipient` account. | No | No | `updatePartnerFeeRecipient` |
| `updateClaimAuthority` | Wrapper authority | `newClaimAuthority` (`Option<Address>`) | No | No | `getUpdateClaimAuthorityInstruction` |
| `transferWrapperAuthority` | Wrapper authority | `newAuthority` | No | No | `getTransferWrapperAuthorityInstruction` |
| `updateXTokenMetadata` | Wrapper authority | `name`, `symbol`, `uri` | No | No | `getUpdateXTokenMetadataInstructionAsync` |

`claimPartnerFees` always pays the stored `partnerFeeRecipient`. `updatePartnerFeeRecipient` accepts only an existing jlToken token account under the market's token program, and not the vault.

## Errors

Lend Referral program errors use codes 7000 to 7018. An error raised inside Jupiter Lend or Liquidity during a cross-program call keeps its own code, in the 6000 range. To decode a failed send or simulation, use `decodeProgramError` from the SDK.

| Code | Name | Cause |
| - | - | - |
| 7000 | `OnlyAuthority` | The signer is not the required authority. |
| 7001 | `WrapperYieldFeeExceedsMax` | The partner fee is above 1000 bps. |
| 7002 | `ProtocolFeeShareExceedsMax` | The protocol share is above 2500 bps. Raised by Jupiter's instructions only. |
| 7003 | `WrapperSlippageExceeded` | The output is below the minimum, or the input is above the maximum. |
| 7004 | `WrapperInvalidFeeRecipient` | The recipient account differs from the stored one, or is the vault. |
| 7005 | `WrapperJLTokenMintMismatch` | An account does not belong to this wrapper or market. |
| 7006 | `WrapperZeroShares` | The operation would mint or burn 0 xTokens. |
| 7007 | `WrapperZeroAssets` | The operation would pay out 0 jlTokens or 0 underlying. |
| 7008 | `WrapperCpiToLendingFailed` | Jupiter Lend returned fewer jlTokens than required, or burned more than computed. |
| 7009 | `WrapperInsufficientPartnerBalance` | The claim amount is more than the partner's balance. |
| 7010 | `WrapperInsufficientProtocolBalance` | The claim amount is more than Jupiter's balance. Raised by Jupiter's claim only. |
| 7011 | `WrapperVaultBalanceUnderrun` | The vault holds less than the wrapper's tracked balances. This should not occur. |
| 7012 | `InvalidLendingProgram` | The Jupiter Lend program account is wrong. |
| 7013 | `InvalidClaimAuthority` | The signer may not trigger partner claims on this wrapper. |
| 7014 | `WrapperInitialDepositTooSmall` | The seed is not above 1,000,000 jlToken atoms. Raised at wrapper creation only. |
| 7015 | `WrapperExactWithdrawStrandsShares` | `withdrawToUnderlying` would burn every circulating xToken and leave one jlToken or more behind. Use `redeemToUnderlying` for a full exit. |
| 7016 | `ProtocolPaused` | The protocol is paused. |
| 7017 | `WrapperUnderlyingAmountTooSmall` | The underlying amount is below 10 atoms. Move dust with `redeemToJLToken`. |
| 7018 | `WrapperSeedTooLarge` | The seed is above 10 whole jlTokens. Raised at wrapper creation only. |

## Events

The program emits these events for users, fees and wrapper settings. Field names follow the SDK's decoders. Amounts are raw token atoms, except in `LogAccrue`.

| Event | Emitted by | Fields |
| - | - | - |
| `LogDepositJLToken` | `depositJLToken` | `wrapperConfig`, `user`, `jlTokenAmount`, `xTokenMinted` |
| `LogRedeemToJLToken` | `redeemToJLToken` | `wrapperConfig`, `user`, `xTokenBurned`, `jlTokenAmount` |
| `LogDepositUnderlying` | `depositUnderlying`, `mintUnderlying` | `wrapperConfig`, `user`, `underlyingAmount`, `jlSharesReceived`, `xTokenMinted` |
| `LogRedeemToUnderlying` | `redeemToUnderlying` | `wrapperConfig`, `user`, `xTokenBurned`, `jlSharesRedeemed`, `underlyingReceived` |
| `LogWithdrawToUnderlying` | `withdrawToUnderlying` | `wrapperConfig`, `user`, `xTokenBurned`, `jlSharesRedeemed`, `underlyingReceived` |
| `LogAccrue` | An accrue at which the Lend exchange price has risen since the last checkpoint | `wrapperConfig`, `oldPrice`, `newPrice`, `totalDeltaScaled`, `protocolDeltaScaled`, `partnerDeltaScaled` |
| `LogClaimPartnerFees` | `claimPartnerFees` | `wrapperConfig`, `partnerFeeRecipient`, `jlTokenAmount` |
| `LogUpdateWrapperProtocolFeeShare` | An accrue at which the wrapper adopts a new protocol share | `wrapperConfig`, `oldBps`, `newBps` |
| `LogInitWrapper` | Wrapper creation | `wrapperConfig`, `xTokenMint`, `jlTokenMint`, `lending`, `authority`, `partnerFeeBps`, `partnerFeeRecipient`, `seedJLAmount` |
| `LogUpdatePartnerYieldFee` | `updatePartnerFee` | `wrapperConfig`, `oldBps`, `newBps` |
| `LogUpdatePartnerFeeRecipient` | `updatePartnerFeeRecipient` | `wrapperConfig`, `oldRecipient`, `newRecipient` |
| `LogUpdateClaimAuthority` | `updateClaimAuthority` | `wrapperConfig`, `oldClaimAuthority`, `newClaimAuthority` |
| `LogTransferWrapperAuthority` | `transferWrapperAuthority` | `wrapperConfig`, `oldAuthority`, `newAuthority` |
| `LogUpdateXTokenMetadata` | `updateXTokenMetadata` | `wrapperConfig`, `xTokenMint`, `name`, `symbol`, `uri` |

In `LogAccrue`, `oldPrice` and `newPrice` are underlying per jlToken × 10^12, and the three deltas are jlToken atoms × 10^6. `jlSharesReceived` and `jlSharesRedeemed` are jlToken atoms.

The SDK has a decoder for each event, such as `getLogAccrueEventDecoder`. Neither Kit nor the SDK extracts events from transaction logs: parse the `Program data:` log lines yourself, then decode the bytes with the event's decoder.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.