BalanceManager
BalanceManager 공유 객체는 서로 다른 자산에 대한 모든 잔액을 보관한다. 거래를 수행하려면 BalanceManager와 TradeProof 조합을 풀에 전달한다. TradeProof는 두 가지 방법 중 하나로 생성되며, BalanceManager 소유자가 직접 생성하거나 어떤 TradeCap 소유자든 생성한다. 소유자는 equivocation 위험 없이 TradeProof를 생성할 수 있다. TradeCap 소유자는 소유 객체이기 때문에 TradeProof를 생성할 때 equivocation 위험이 있다. 일반적으로 high frequency trading engine은 기본 소유자로서 거래한다.
스왑을 제외하면 DeepBookV3와의 모든 상호작용에는 입력 중 하나로 BalanceManager가 필요하다. 주문이 매칭되면 fund가 해당 BalanceManager로 또는 그 객체에서 이체된다. 모든 풀에서 단일 BalanceManager를 사용할 수 있다.
API
BalanceManager가 노출하는 다양한 public 함수는 다음과 같다.
BalanceManager 생성
new() 함수는 BalanceManager를 생성한다. share와 함께 사용하지 않으면 트랜잭션이 실패한다. 트랜잭션을 예치 호출과 결합하여 단일 트랜잭션에서 BalanceManager를 생성하고 예치한 다음 share할 수 있다.
packages/deepbook/sources/balance_manager.move. You probably need to run `pnpm prebuild` and restart the site.Create a BalanceManager with custom 소유자
new_with_custom_owner() 함수는 custom 소유자로 BalanceManager를 생성한다. share와 함께 사용하지 않으면 트랜잭션이 실패한다. 트랜잭션을 예치 호출과 결합하여 단일 트랜잭션에서 BalanceManager를 생성하고 예치한 다음 share할 수 있다.
packages/deepbook/sources/balance_manager.move. You probably need to run `pnpm prebuild` and restart the site.Create a BalanceManager with custom 소유자 and capabilities
new_with_custom_owner_caps<App>() 함수는 custom 소유자로 BalanceManager를 생성하고 단일 호출로 세 가지 capability(DepositCap, WithdrawCap, TradeCap)를 모두 반환한다. 이 함수는 특정 App 타입을 통해 DeepBook Registry의 authorization이 필요하다. BalanceManager를 share와 함께 사용하지 않으면 트랜잭션이 실패한다. 이 방식은 단일 트랜잭션에서 필요한 모든 capability를 포함한 완전한 BalanceManager를 설정할 수 있는 편리한 방법이다.
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 소유자는 TradeCap을 민트하여 다른 주소로 보낼 수 있다. 수신한 주소는 이 BalanceManager로 주문을 배치할 수 있는 capability를 갖게 된다. 그러나 주소 소유자는 fund를 예치하거나 출금할 수 없다. TradeCap에 대해 할당할 수 있는 WithdrawCap, DepositCap, BalanceManager의 최대 총 개수는 1000이다. 이 제한에 도달하면 하나 이상의 기존 cap을 revoke한 후 새 cap을 민트해야 한다. 또한 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 소유자는 DepositCap 또는 WithdrawCap을 민트하여 다른 주소로 보낼 수 있다. 수신한 주소는 BalanceManager에 예치하거나 해당 객체에서 출금할 수 있는 capability를 갖게 된다. 그러나 주소 소유자는 trade를 실행할 수 없다. TradeCap에 대해 할당할 수 있는 WithdrawCap, DepositCap, BalanceManager의 최대 총 개수는 1000이다. 이 제한에 도달하면 하나 이상의 기존 cap을 revoke한 후 새 cap을 민트해야 한다.
packages/deepbook/sources/balance_manager.move. You probably need to run `pnpm prebuild` and restart the site.Generate a TradeProof
잔액 check 또는 전송이 필요한 어떤 함수를 호출하려면, 사용자는 자신의 BalanceManager와 TradeProof를 제공해야 한다. trade proof는 두 가지 방법으로 생성할 수 있으며, 하나는 소유자가 사용하는 방식이고 다른 하나는 TradeCap 소유자가 사용하는 방식이다.
packages/deepbook/sources/balance_manager.move. You probably need to run `pnpm prebuild` and restart the site.Deposit 자금
소유자만 이 함수를 호출하여 BalanceManager에 fund를 예치할 수 있다.
packages/deepbook/sources/balance_manager.move. You probably need to run `pnpm prebuild` and restart the site.Withdraw 자금
소유자만 이 함수를 호출하여 BalanceManager에서 fund를 출금할 수 있다.
packages/deepbook/sources/balance_manager.move. You probably need to run `pnpm prebuild` and restart the site.Deposit 자금 using DepositCap
DepositCap에 대한 BalanceManager holder만 이 함수를 호출하여 BalanceManager에 fund를 예치할 수 있다.
packages/deepbook/sources/balance_manager.move. You probably need to run `pnpm prebuild` and restart the site.Withdraw 자금 using WithdrawCap
WithdrawCap에 대한 BalanceManager holder만 이 함수를 호출하여 BalanceManager에서 fund를 출금할 수 있다.
packages/deepbook/sources/balance_manager.move. You probably need to run `pnpm prebuild` and restart the site.Set and unset referral
TradeCap 소유자는 BalanceManager에 대해 풀-specific referral을 set하거나 unset할 수 있다. referral을 set하면 BalanceManager가 해당 풀의 DeepBookPoolReferral과 연관될 수 있으며, 이는 리퍼럴 수수료를 추적하고 획득할 수 있다. 각 BalanceManager는 서로 다른 풀에 대해 서로 다른 referral을 가질 수 있다.
packages/deepbook/sources/balance_manager.move. You probably need to run `pnpm prebuild` and restart the site.Register BalanceManager
registry에 BalanceManager를 register한다. 이 작업은 registry에서 소유자의 manager 목록에 BalanceManager를 추가한다.
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
새 BalanceManager가 생성될 때 방출된다.
packages/deepbook/sources/balance_manager.move. You probably need to run `pnpm prebuild` and restart the site.BalanceEvent
예치 또는 출금이 발생할 때 방출된다.
packages/deepbook/sources/balance_manager.move. You probably need to run `pnpm prebuild` and restart the site.