Margin Manager SDK
Managing margin accounts is essential for leveraged trading on DeepBook. The Margin Manager SDK provides functions for creating margin managers, depositing collateral, borrowing assets, and managing risk.
Margin Manager functions
The DeepBook Margin SDK provides the following functions for managing margin accounts.
newMarginManager
Use newMarginManager to create and share a new margin manager in one transaction. The call returns a function that takes a Transaction object.
Parameters
poolKey: String that identifies the DeepBook pool.
packages/deepbook-v3/src/transactions/marginManager.ts. You probably need to run `pnpm prebuild` and restart the site.newMarginManagerWithInitializer
Use newMarginManagerWithInitializer to create a margin manager and return it with an initializer. You must call shareMarginManager afterward to share it. The call returns an object with manager and initializer.
Parameters
poolKey: String that identifies the DeepBook pool.
packages/deepbook-v3/src/transactions/marginManager.ts. You probably need to run `pnpm prebuild` and restart the site.shareMarginManager
Use shareMarginManager to share a margin manager created with newMarginManagerWithInitializer. The call returns a function that takes a Transaction object.
Parameters
poolKey: String that identifies the DeepBook pool.manager:TransactionArgumentrepresenting the margin manager.initializer:TransactionArgumentrepresenting the initializer.
packages/deepbook-v3/src/transactions/marginManager.ts. You probably need to run `pnpm prebuild` and restart the site.depositBase, depositQuote, depositDeep
Use these functions to deposit assets into a margin manager. The call returns a function that takes a Transaction object.
Parameters
managerKey: String that identifies the margin manager.amount: Number representing the amount to deposit.
packages/deepbook-v3/src/transactions/marginManager.ts. You probably need to run `pnpm prebuild` and restart the site.