마진 매니저
MarginManager는 BalanceManager를 감싸며 deposit, withdraw, trade, 그리고 leveraged position을 관리하는 데 필요한 capability를 제공하는 shared object이다. 이는 사용자가 margin pool에서 asset을 차입하여 trading position을 확대할 수 있게 하면서, collateralization을 통해 risk를 관리하도록 한다.
각 MarginManager는 특정 DeepBook pool과 연관되며, 해당 pool에서 trading을 허용하는 margin pool로부터 차입할 수 있다. margin manager는 차입 position을 추적하고 시스템 건전성을 유지하기 위해 risk ratio limit을 강제한다.
API
다음은 MarginManager가 노출하는 서로 다른 public 함수이다.
Create a MarginManager
new() 함수는 하나의 transaction에서 MarginManager를 생성하고 공유한다. 지정된 pool에 대해 margin trading이 활성화되어 있는지 검증한다.
packages/deepbook_margin/sources/margin_manager.move. You probably need to run `pnpm prebuild` and restart the site.Create a MarginManager with initializer
new_with_initializer() 함수는 MarginManager를 생성하고 initializer hot potato와 함께 반환한다. initializer는 share() 함수를 사용해 생성 후 margin manager가 올바르게 공유되도록 보장한다.
packages/deepbook_margin/sources/margin_manager.move. You probably need to run `pnpm prebuild` and restart the site.Set or unset referral
MarginManager의 소유자는 trading fee 혜택을 위해 pool별 referral을 설정하거나 해제할 수 있다. referral은 margin manager와 연관된 pool에 대해 mint된 DeepBookPoolReferral이어야 한다. 각 margin manager는 서로 다른 pool에 대해 서로 다른 referral을 가질 수 있다.
packages/deepbook_margin/sources/margin_manager.move. You probably need to run `pnpm prebuild` and restart the site.Deposit funds
소유자만 MarginManager에 fund를 deposit할 수 있다. deposit하는 asset은 base asset, quote asset, 또는 DEEP token이어야 한다.
packages/deepbook_margin/sources/margin_manager.move. You probably need to run `pnpm prebuild` and restart the site.Withdraw funds
소유자만 MarginManager에서 fund를 인출할 수 있다. manager에 활성 loan이 있을 때 인출은 risk ratio limit의 적용을 받는다.
packages/deepbook_margin/sources/margin_manager.move. You probably need to run `pnpm prebuild` and restart the site.Borrow assets
position 크기를 늘리기 위해 margin pool에서 base asset 또는 quote asset을 차입한다. 차입에는 risk ratio limit이 적용되며 margin pool은 manager의 DeepBook pool에서 trading을 허용해야 한다.
packages/deepbook_margin/sources/margin_manager.move. You probably need to run `pnpm prebuild` and restart the site.Repay loans
debt를 줄이기 위해 차입한 asset을 상환한다. 정확한 amount를 지정하거나, 총 debt까지 사용 가능한 balance 전체를 상환할 수 있다.
packages/deepbook_margin/sources/margin_manager.move. You probably need to run `pnpm prebuild` and restart the site.Liquidate position
담보가 부족한 margin manager를 liquidation한다. liquidator는 상환을 제공하고 담보 asset과 liquidation reward를 받는다. margin pool은 position 상태에 따라 보상을 받거나 bad debt가 발생할 수 있다.
packages/deepbook_margin/sources/margin_manager.move. You probably need to run `pnpm prebuild` and restart the site.Calculate risk ratio
margin manager의 risk ratio를 반환하며, 이는 asset 대비 debt의 비율을 나타낸다. ratio가 높을수록 더 건강한 position을 의미한다.
packages/deepbook_margin/sources/margin_manager.move. You probably need to run `pnpm prebuild` and restart the site.Read endpoints
packages/deepbook_margin/sources/margin_manager.move. You probably need to run `pnpm prebuild` and restart the site.Events
MarginManagerCreatedEvent
새 margin manager가 생성될 때 발생한다.
packages/deepbook_margin/sources/margin_manager.move. You probably need to run `pnpm prebuild` and restart the site.DepositCollateralEvent
담보가 margin manager에 deposit될 때 발생한다.
packages/deepbook_margin/sources/margin_manager.move. You probably need to run `pnpm prebuild` and restart the site.WithdrawCollateralEvent
담보가 margin manager에서 인출될 때 발생한다.
packages/deepbook_margin/sources/margin_manager.move. You probably need to run `pnpm prebuild` and restart the site.LoanBorrowedEvent
asset이 margin pool에서 차입될 때 발생한다.
packages/deepbook_margin/sources/margin_manager.move. You probably need to run `pnpm prebuild` and restart the site.LoanRepaidEvent
차입한 asset이 상환될 때 발생한다.
packages/deepbook_margin/sources/margin_manager.move. You probably need to run `pnpm prebuild` and restart the site.LiquidationEvent
margin manager가 liquidation될 때 발생한다.
packages/deepbook_margin/sources/margin_manager.move. You probably need to run `pnpm prebuild` and restart the site.