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.

Click to open
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.

Click to open
Supply liquidity

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

Click to open
Withdraw liquidity

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

Click to open
Read endpoints

Events

Click to open
MarginPoolCreated

Emitted when a new margin pool is created.

Click to open
DeepbookPoolUpdated

Emitted when a DeepBook pool is enabled or disabled for lending.

Click to open
InterestParamsUpdated

Emitted when interest rate parameters are updated.

Click to open
MarginPoolConfigUpdated

Emitted when margin pool configuration is updated.

Click to open
SupplierCapMinted

Emitted when a new supplier cap is minted.

Click to open
AssetSupplied

Emitted when assets are supplied to a margin pool.

Click to open
AssetWithdrawn

Emitted when assets are withdrawn from a margin pool.

Click to open
MaintainerFeesWithdrawn

Emitted when maintainer fees are withdrawn.

Click to open
ProtocolFeesWithdrawn

Emitted when protocol fees are withdrawn.

Click to open
ProtocolFeesIncreased

Emitted when protocol fees are accrued from interest payments.

Interest Rates

Learn how interest rates are calculated for margin pool borrowing.

Supply Referral

Learn how to earn referral fees by referring liquidity suppliers.

DeepBook Margin package

The DeepBook Margin package on GitHub.