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.
packages/deepbook_margin/sources/margin_pool.move. You probably need to run `pnpm prebuild` and restart the site.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.
packages/deepbook_margin/sources/margin_pool.move. You probably need to run `pnpm prebuild` and restart the site.Update pool parameters
Update interest rate parameters and margin pool configuration settings.
packages/deepbook_margin/sources/margin_pool.move. You probably need to run `pnpm prebuild` and restart the site.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.
packages/deepbook_margin/sources/margin_pool.move. You probably need to run `pnpm prebuild` and restart the site.Supply liquidity
Supply assets to the margin pool to earn interest. Returns the total supply shares owned by the supplier after this operation.
packages/deepbook_margin/sources/margin_pool.move. You probably need to run `pnpm prebuild` and restart the site.Withdraw liquidity
Withdraw supplied assets from the margin pool. You can specify an exact amount or withdraw all available shares.
packages/deepbook_margin/sources/margin_pool.move. You probably need to run `pnpm prebuild` and restart the site.Referral system
Create supply referrals and withdraw referral fees. Referrals earn a portion of the interest generated by assets supplied through their referral link.
packages/deepbook_margin/sources/margin_pool.move. You probably need to run `pnpm prebuild` and restart the site.Withdraw fees
Withdraw accumulated maintainer and protocol fees from the margin pool.
packages/deepbook_margin/sources/margin_pool.move. You probably need to run `pnpm prebuild` and restart the site.Read endpoints
packages/deepbook_margin/sources/margin_pool.move. You probably need to run `pnpm prebuild` and restart the site.Related links
The DeepBook Margin package on GitHub.