Skip to main content

Supply Referral

The supply referral system allows users to earn a portion of the protocol fees generated by liquidity suppliers they refer. When a supplier deposits assets using your referral ID, you earn fees proportional to interest paid over time.

How it works

  1. Create a referral: Mint a SupplyReferral object for a specific margin pool
  2. Referral ID: Suppliers include your referral ID when supplying liquidity
  3. Earn fees: As referred suppliers earn interest, a portion of protocol fees accrues to your referral
  4. Claim fees: Withdraw accumulated referral fees at any time

The referral system uses a shares-based tracking mechanism. When a supplier deposits with your referral:

  • Your referral's shares increase proportionally to the supplier's position
  • As interest accrues and protocol fees are collected, your claimable fees grow
  • When a supplier withdraws, your referral's shares decrease accordingly

API

Following are the functions for managing supply referrals.

Click to open
Mint a SupplyReferral

Create a new supply referral for earning fees from referred suppliers. The returned SupplyReferral object is transferable and can be used to claim accumulated fees.

Click to open
Supply with referral

Supply assets to a margin pool with an optional referral ID. When a referral ID is provided, the referrer earns a portion of protocol fees from the supplier's position.

Click to open
Withdraw referral fees

Withdraw accumulated referral fees. Only the owner of the SupplyReferral object can claim its fees.

Click to open
Query referral tracker

Query the current shares and unclaimed fees for a referral.

Events

Click to open
SupplyReferralMinted

Emitted when a new supply referral is created.

Click to open
ReferralFeesClaimed

Emitted when referral fees are claimed by the referral owner.

Fee distribution

The referral spread parameter (typically 20%) determines what portion of protocol fees goes to referrers. For example:

  • Without referral: 100% of protocol fees go to the protocol
  • With referral: 80% to protocol, 20% to referrer (at 20% referral spread)

The referral spread is configured per margin pool and can be viewed in the Contract Information.

Margin Pool

Learn about margin pools and supplying liquidity.

DeepBook Margin package

The DeepBook Margin package on GitHub.