docs/content/standards/deepbook-margin/contract-information/supply-referral.mdx
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.
SupplyReferral object for a specific margin poolThe referral system uses a shares-based tracking mechanism. When a supplier deposits with your referral:
Following are the functions for managing supply referrals.
<details> <summary>Mint a `SupplyReferral`</summary>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.
<ImportContent source="packages/deepbook_margin/sources/margin_pool.move" mode="code" org="MystenLabs" repo="deepbookv3" fun="mint_supply_referral" />
</details> <details> <summary>Supply with referral</summary>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.
<ImportContent source="packages/deepbook_margin/sources/margin_pool.move" mode="code" org="MystenLabs" repo="deepbookv3" fun="supply" />
</details> <details> <summary>Withdraw referral fees</summary>Withdraw accumulated referral fees. Only the owner of the SupplyReferral object can claim its fees.
<ImportContent source="packages/deepbook_margin/sources/margin_pool.move" mode="code" org="MystenLabs" repo="deepbookv3" fun="withdraw_referral_fees" />
</details> <details> <summary>Query referral tracker</summary>Query the current shares and unclaimed fees for a referral.
<ImportContent source="packages/deepbook_margin/sources/margin_pool/protocol_fees.move" mode="code" org="MystenLabs" repo="deepbookv3" fun="referral_tracker" />
</details>Emitted when a new supply referral is created.
<ImportContent source="packages/deepbook_margin/sources/margin_pool.move" mode="code" org="MystenLabs" repo="deepbookv3" struct="SupplyReferralMinted" />
</details> <details> <summary>`ReferralFeesClaimed`</summary>Emitted when referral fees are claimed by the referral owner.
<ImportContent source="packages/deepbook_margin/sources/margin_pool/protocol_fees.move" mode="code" org="MystenLabs" repo="deepbookv3" struct="ReferralFeesClaimedEvent" />
</details>The referral spread parameter (typically 20%) determines what portion of protocol fees goes to referrers. For example:
The referral spread is configured per margin pool and can be viewed in the Contract Information.