Skip to main content

Margin Pool

The MarginPool is a shared object that manages liquidity for a specific asset, enabling lenders to supply assets and margin traders to borrow them. Each margin pool tracks supply and borrow positions, accrues interest over time, and enforces risk parameters to maintain system health.

Margin pools use a shares-based accounting system where suppliers receive shares representing their proportion of the total supply. Interest accrues continuously, increasing the value of these shares over time. Borrowers can only borrow from pools that have enabled their specific DeepBook trading pool.

API

Following are the different public functions that the MarginPool exposes.

Create a margin pool

Creates and registers a new margin pool for a specific asset. Only one margin pool can exist per asset type.

Enable or disable DeepBook pools

Control which DeepBook pools can borrow from this margin pool. Only margin managers associated with enabled pools can take loans.

Update pool parameters

Update interest rate parameters and margin pool configuration settings.

Mint a SupplierCap

Create a new SupplierCap that can be used to supply and withdraw from margin pools. One SupplierCap can be used across multiple margin pools.

Supply liquidity

Supply assets to the margin pool to earn interest. Returns the total supply shares owned by the supplier after this operation.

Withdraw liquidity

Withdraw supplied assets from the margin pool. You can specify an exact amount or withdraw all available shares.

Referral system

Create supply referrals and withdraw referral fees. Referrals earn a portion of the interest generated by assets supplied through their referral link.

Withdraw fees

Withdraw accumulated maintainer and protocol fees from the margin pool.

Read endpoints

DeepBook Margin package

The DeepBook Margin package on GitHub.