marginfi Liquid Incentive Program Documentation
The Liquidity Incentive Program is a fully open-sourced proxy program for marginfi-v2. It allows anyone to create campaigns and incentivize other users to deposit into and lock their funds in marginfi-v2 by offering guaranteed yields.
The official LIP program address on Solana mainnet-beta is LipsxuAkFkwa4RKNzn51wAsW7Dedzt1RNHMkTkDEZUW.
Features
Permissionless campaign creation
Anyone can create a new incentive campaign without needing special permissions or approvals. This allows for a decentralized and open system where anyone can contribute to boosting liquidity in the protocol.
Arbitrary asset support
The program supports incentivizing deposits for any asset listed on the marginfi-v2 protocol. This flexibility enables campaigns to target specific assets or a range of assets based on the organizer's goals.
Configurable lock-up periods
When creating a campaign, the organizer can specify the duration for which deposited assets must remain locked in the protocol to qualify for the incentives. This allows tailoring campaigns to suit different liquidity needs and user preferences.
How It Works
liquidity-incentive-program
primarily works off of the Campaign
concept.
Think of a Campaign
as a marketing campaign:
- Each campaign has a creator, who becomes the
admin
of that campaign. - The creator selects:
- the type of asset to incentivize deposits for (e.g. $SOL)
- the lockup period that depositors' funds will be locked up for
- the maximum amount of user deposits allowed
- The maximum rewards to be paid out to users (together with the maximum amount of deposits allowed, this calculates the guaranteed fixed yield).
LIP works off of the concept of a minimum guaranteed yield, but depositors may earn higher yield if marginfi's native lender yield for the related asset exceeds the yield guaranteed by the Campaign. This is a win-win for depositors.
- As a proof of reward reserves, campaign creators lock up maximum rewards to be paid out upon campaign creation, making it easy for campaign depositors to know the source of yield.
- In product UIs, each
Campaign
typically highlights a fixedAPY
, but there is no compounding involved in the guaranteed yield. SinceAPY
accounts for compounding effects even if there are none, measuring yield inAPY
gives depositors the correct impression that they should expect the yield they see. In the smart contract, yield is specified via themax_rewards
parameter of eachCampaign
. - When users deposit funds into an LIP
Campaign
, funds are stored directly inmarginfi
. Funds earnmarginfi
lender yield. When lockups expire, depositors are paidmax(guarenteed yield, earned lender yield)
for the assets they deposited. As earned lender yield grows above0%
, it subsidizes the expense that campaign creators pay out of the rewards they've escrowed. This is a win-win for campaign creators.
Instructions
create_campaign
- Definition: This instruction allows a user to create a new campaign to incentivize deposits into the marginfi-v2 protocol for a specific asset. The campaign creator must provide the necessary parameters and lock up the maximum rewards upfront.
- Parameters:
ctx: Context<CreateCampaign>
: A context struct containing various accounts required for the operationcampaign
: The newly created Campaign accountcampaign_reward_vault
: The token account to hold the locked rewards for the campaigncampaign_reward_vault_authority
: The authority account for the campaign reward vaultasset_mint
: The mint account for the asset being incentivizedmarginfi_bank
: The Bank account for the target asset in the marginfi-v2 protocoladmin
: The signer account, representing the campaign creatorfunding_account
: The token account from which the locked rewards will be transferredrent
: The Rent sysvartoken_program
: The SPL Token program accountsystem_program
: The System program account
lockup_period: u64
: The duration for which deposited funds will be locked upmax_deposits: u64
: The maximum amount of deposits allowed for the campaignmax_rewards: u64
: The maximum amount of rewards to be paid out to depositors
create_deposit
- Definition: Creates a new deposit in an active liquidity incentive campaign (LIP).
- Parameters:
ctx: Context<CreateDeposit>
: A context struct containing the relevant accounts for the new depositcampaign
: The mutable Campaign accountsigner
: The mutable signer account (user)deposit
: The newly initialized Deposit accountmfi_pda_signer
: A derived Program-Derived Address (PDA) used as the authority for the MarginFi accountfunding_account
: The user's token account to transfer the deposit amount fromtemp_token_account
: A temporary token account to hold the deposit amount during the transactionasset_mint
: The mint account for the asset being depositedmarginfi_group
: The MarginFi group account associated with the depositmarginfi_bank
: The MarginFi bank account for the deposited assetmarginfi_account
: The newly initialized MarginFi account for the depositmarginfi_bank_vault
: The MarginFi bank's liquidity vault account where the deposited tokens are storedmarginfi_program
: The MarginFi program accounttoken_program
: The SPL Token program accountrent
: The Rent sysvar accountsystem_program
: The System program account
amount: u64
: The amount of tokens to be deposited
end_deposit
- Definition: After a lockup period has ended, closes a deposit and returns the initial deposit + earned rewards from a liquidity incentive campaign back to the liquidity depositor.
- Parameters:
ctx: Context<EndDeposit>
: A context struct containing the relevant accounts for ending the depositcampaign
: The Campaign account associated with the depositcampaign_reward_vault
: The token account holding the locked rewards for the campaigncampaign_reward_vault_authority
: The authority account for the campaign reward vaultsigner
: The signer account (user) who made the depositdeposit
: The Deposit account to be closedmfi_pda_signer
: The PDA used as the authority for the MarginFi accounttemp_token_account
: A temporary token account used for token transferstemp_token_account_authority
: The authority account for the temporary token accountdestination_account
: The user's token account to receive the deposit and rewardsasset_mint
: The mint account for the deposited assetmarginfi_account
: The MarginFi account associated with the depositmarginfi_group
: The MarginFi group account associated with the depositmarginfi_bank
: The MarginFi bank account for the deposited assetmarginfi_bank_vault
: The MarginFi bank's liquidity vault accountmarginfi_bank_vault_authority
: The authority account for the MarginFi bank's liquidity vaultmarginfi_program
: The MarginFi program accounttoken_program
: The SPL Token program accountsystem_program
: The System program account
Errors
- Name
CampaignNotActive
- Type
- 300
- Description
The liquidity incentive campaign is not currently active. This error occurs when attempting to interact with a campaign that is not in an active state.
- Name
DepositAmountTooLarge
- Type
- 301
- Description
The specified deposit amount exceeds the remaining capacity of the campaign. This error is raised when the user tries to deposit an amount that is larger than the remaining deposit capacity allowed for the campaign.
- Name
DepositNotMature
- Type
- 302
- Description
The deposit has not reached its maturity date yet. This error indicates that the lockup period for the deposit has not been fulfilled, and the deposit cannot be withdrawn or claimed until the maturity date.
Constants
- Name
CAMPAIGN_SEED
- Type
- &str
- Description
Seed used to derive the campaign address.
- Name
CAMPAIGN_AUTH_SEED
- Type
- &str
- Description
Seed used to derive the authority for the campaign.
- Name
DEPOSIT_MFI_AUTH_SIGNER_SEED
- Type
- &str
- Description
Seed used to derive the authority for the deposit MFI signer.
- Name
TEMP_TOKEN_ACCOUNT_AUTH_SEED
- Type
- &str
- Description
Seed used to derive the authority for the ephemeral token account.
- Name
MARGINFI_ACCOUNT_SEED
- Type
- &str
- Description
Seed used to derive the address of the marginfi account.