BalanceManager
BalanceManager shared object는 서로 다른 asset에 대한 모든 balance를 보관한다. 거래를 수행하려면 BalanceManager와 TradeProof 조합을 pool에 전달한다. TradeProof는 두 가지 방법 중 하나로 생성되며, BalanceManager owner가 직접 생성하거나 어떤 TradeCap owner든 생성한다. owner는 equivocation 위험 없이 TradeProof를 생성할 수 있다. TradeCap owner는 owned object이기 때문에 TradeProof를 생성할 때 equivocation 위험이 있다. 일반적으로 high frequency trading engine은 default owner로서 거래한다.
swap을 제외하면 DeepBookV3와의 모든 상호작용에는 input 중 하나로 BalanceManager가 필요하다. order가 매칭되면 fund가 BalanceManager로 또는 BalanceManager에서 이체된다. 모든 pool에서 단일 BalanceManager를 사용할 수 있다.
API
BalanceManager가 노출하는 다양한 public function은 다음과 같다.
BalanceManager 생성
new() 함수는 BalanceManager를 생성한다. share와 함께 사용하지 않으면 transaction이 실패한다. transaction을 deposit 호출과 결합하여 단일 transaction에서 balance manager를 생성하고 deposit한 다음 share할 수 있다.
packages/deepbook/sources/balance_manager.move. You probably need to run `pnpm prebuild` and restart the site.Create a BalanceManager with custom owner
new_with_custom_owner() 함수는 custom owner로 BalanceManager를 생성한다. share와 함께 사용하지 않으면 transaction이 실패한다. transaction을 deposit 호출과 결합하여 단일 transaction에서 balance manager를 생성하고 deposit한 다음 share할 수 있다.
packages/deepbook/sources/balance_manager.move. You probably need to run `pnpm prebuild` and restart the site.Create a BalanceManager with custom owner and capabilities
new_with_custom_owner_caps<App>() 함수는 custom owner로 BalanceManager를 생성하고 단일 호출로 세 가지 capability(DepositCap, WithdrawCap, TradeCap)를 모두 반환한다. 이 함수는 특정 App type을 통해 DeepBook Registry의 authorization이 필요하다. balance manager를 share와 함께 사용하지 않 으면 transaction이 실패한다. 이 방식은 단일 transaction에서 필요한 모든 capability를 포함한 완전한 balance manager를 설정할 수 있는 편리한 방법이다.
DeepBookV3를 사용하는 Move code는 DepositCap, WithdrawCap, TradeCap을 사용하는 반면, DeepBookV3 SDK는 depositCap, withdrawCap, tradeCap을 사용한다.
packages/deepbook/sources/balance_manager.move. You probably need to run `pnpm prebuild` and restart the site.Mint a TradeCap
BalanceManager owner는 TradeCap을 mint하여 다른 address로 보낼 수 있다. 수신한 address는 이 BalanceManager로 order를 배치할 수 있는 capability를 갖게 된다. 그러나 address owner는 fund를 deposit하거나 withdraw할 수 없다. BalanceManager에 대해 할당할 수 있는 TradeCap, WithdrawCap, DepositCap의 최대 총 개수는 1000이다. 이 제한에 도달하면 하나 이상의 기존 cap을 revoke한 후 새 cap을 mint해야 한다. 또한 revoke_trade_cap을 사용하여 DepositCap과 WithdrawCap을 revoke할 수 있다.
packages/deepbook/sources/balance_manager.move. You probably need to run `pnpm prebuild` and restart the site.Mint a DepositCap or WithdrawCap
BalanceManager owner는 DepositCap 또는 WithdrawCap을 mint하여 다른 address로 보낼 수 있다. 수신한 address는 BalanceManager에 deposit하거나 BalanceManager에서 withdraw할 수 있는 capability를 갖게 된다. 그러나 address owner는 trade를 실행할 수 없다. BalanceManager에 대해 할당할 수 있는 TradeCap, WithdrawCap, DepositCap의 최대 총 개수는 1000이다. 이 제한에 도달하면 하나 이상의 기존 cap을 revoke한 후 새 cap을 mint해야 한다.
packages/deepbook/sources/balance_manager.move. You probably need to run `pnpm prebuild` and restart the site.Generate a TradeProof
balance check 또는 transfer가 필요한 어떤 function을 호출하려면, 사용자는 자신의 BalanceManager와 TradeProof를 제공해야 한다. trade proof는 두 가지 방법으로 생성할 수 있으며, 하나는 owner가 사용하는 방식이고 다른 하나는 TradeCap owner가 사용하는 방식이다.
packages/deepbook/sources/balance_manager.move. You probably need to run `pnpm prebuild` and restart the site.Deposit funds
owner만 이 function을 호출하여 BalanceManager에 fund를 deposit할 수 있다.
packages/deepbook/sources/balance_manager.move. You probably need to run `pnpm prebuild` and restart the site.Withdraw funds
owner만 이 function을 호출하여 BalanceManager에서 fund를 withdraw할 수 있다.
packages/deepbook/sources/balance_manager.move. You probably need to run `pnpm prebuild` and restart the site.Deposit funds using DepositCap
BalanceManager에 대한 DepositCap holder만 이 function을 호출하여 BalanceManager에 fund를 deposit할 수 있다.
packages/deepbook/sources/balance_manager.move. You probably need to run `pnpm prebuild` and restart the site.Withdraw funds using WithdrawCap
BalanceManager에 대한 WithdrawCap holder만 이 function을 호출하여 BalanceManager에서 fund를 withdraw할 수 있다.
packages/deepbook/sources/balance_manager.move. You probably need to run `pnpm prebuild` and restart the site.Set and unset referral
TradeCap owner는 balance manager에 대해 pool-specific referral을 set하거나 unset할 수 있다. referral을 set하면 balance manager가 해당 pool의 DeepBookPoolReferral과 연관될 수 있으며, 이는 referral fee를 추적하고 획득할 수 있다. 각 balance manager는 서로 다른 pool에 대해 서로 다른 referral을 가질 수 있다.
packages/deepbook/sources/balance_manager.move. You probably need to run `pnpm prebuild` and restart the site.Register balance manager
registry에 balance manager를 register한다. 이 작업은 registry에서 owner의 manager 목록에 balance manager를 추가한다.
packages/deepbook/sources/balance_manager.move. You probably need to run `pnpm prebuild` and restart the site.Read endpoints
packages/deepbook/sources/balance_manager.move. You probably need to run `pnpm prebuild` and restart the site.이벤트
BalanceManagerEvent
새 balance manager가 생성될 때 방출된다.
packages/deepbook/sources/balance_manager.move. You probably need to run `pnpm prebuild` and restart the site.BalanceEvent
deposit 또는 withdrawal이 발생할 때 방출된다.
packages/deepbook/sources/balance_manager.move. You probably need to run `pnpm prebuild` and restart the site.