주문
사용자는 지정가 주문 또는 시장가 주문을 생성하고, 주문을 수정하고, 주문을 취소할 수 있다. BalanceManager는 주문을 처리하기 위해 필요한 자금을 보유해야 한다. DeepBookV3는 네 가지 주문 옵션과 세 가지 자체 매칭 옵션을 제공한다. pay_with_deep 플래그를 true로 설정하면 거래 수수료는 DEEP 토큰으로 지불된다. pay_with_deep 플래그를 false로 설정하면 거래 수수료는 입력 토큰으로 지불된다.
사용자는 기존 주문을 수정하여 크기를 줄이거나 만료 시간을 낮추거나 둘 다 할 수 있다. 사용자는 주문을 수정하여 크기를 늘리거나 만료 시간을 늘릴 수 없다. 그렇게 하려면 원래 주문을 취소하고 새 주문을 배치해야 한다.
사용자는 단일 주문을 취소하거나 모든 주문을 취소할 수 있다.
API
Pool이 노출하는 주문 관련 엔드포인트는 다음과 같다.
Order options
다음 상수는 주문에 사용할 수 있는 옵션을 정의한다.
packages/deepbook/sources/helper/constants.move. You probably need to run `pnpm prebuild` and restart the site.Self-matching options
다음 상수는 자체 매칭 주문에 사용할 수 있는 옵션을 정의한다.
packages/deepbook/sources/helper/constants.move. You probably need to run `pnpm prebuild` and restart the site.OrderInfo struct
지정가 주문 또는 시장가 주문을 배치하면 OrderInfo object가 생성되어 반환된다. DeepBookV3는 주문이 완료되거나 book에 배치된 후 이 object를 자동으로 drop한다. OrderInfo는 모든 주문 정보를 나타내므로 요청의 실행 세부 정보를 검사하기 위해 OrderInfo를 사용한다. DeepBookV3는 어떤 error도 catch하지 않으므로 어떤 종류의 failure라도 발생하면 전체 transaction이 실패한다.
packages/deepbook/sources/book/order_info.move. You probably need to run `pnpm prebuild` and restart the site.OrderDeepPrice struct
OrderDeepPrice struct는 주문이 배치된 시점의 DEEP 변환율을 나타낸다.
packages/deepbook/sources/vault/deep_price.move. You probably need to run `pnpm prebuild` and restart the site.Fill struct
Fill struct는 두 주문 간 매칭 결과를 나타낸다. 이 struct를 사용하여 state를 업데이트한다.
packages/deepbook/sources/book/fill.move. You probably need to run `pnpm prebuild` and restart the site.Place limit order
지정가 주문을 배치한다. 수량은 베이스 자산 기준이다. 현재 버전에서는 pay_with_deep가 true여야 하므로 수수료는 DEEP 토큰으로 지불된다.
주문을 배치하기 전에 TradeProof를 생성하는 BalanceManager 호출을 결합해야 한다.
packages/deepbook/sources/pool.move. You probably need to run `pnpm prebuild` and restart the site.Place market order
시장가 주문을 배치한다. 수량은 베이스 자산 기준이다. bids에는 MAX_PRICE 가격으로, asks에는 MIN_PRICE 가격으로 place_limit_order를 호출한다. DeepBookV3는 채워지지 않은 수량이 있으면 그 수량에 대해 주문을 취소한다.
packages/deepbook/sources/pool.move. You probably need to run `pnpm prebuild` and restart the site.Modify order
order_id와 new_quantity가 주어지면 주문을 수정한다. 새 수량은 원래 수량보다 작고 체결된 수량보다 커야 한다. 주문은 아직 만료되지 않았어야 한다.
modify_order 함수는 아무것도 반환하지 않는다. transaction이 성공하면 수정이 성공한 것으로 간주한다.
packages/deepbook/sources/pool.move. You probably need to run `pnpm prebuild` and restart the site.Cancel order
주문을 취소한다. 주문은 balance_manager가 소유해야 한다. 주문은 book과 balance_manager open orders에서 제거된다. balance_manager balance는 주문의 남은 수량으로 업데이트된다.
modify와 유사하게 cancel_order는 아무것도 반환하지 않는다. DeepBookV3는 OrderCanceled event를 emit한다.
packages/deepbook/sources/pool.move. You probably need to run `pnpm prebuild` and restart the site.Cancel multiple orders
vector 안의 여러 주문을 취소한다. 주문은 balance_manager가 소유해야 한다. 주문은 book과 balance_manager open orders에서 제거된다. 어떤 주문이라도 취소에 실패하면 어떤 주문도 취소되지 않는다(atomic operation).
packages/deepbook/sources/pool.move. You probably need to run `pnpm prebuild` and restart the site.Cancel all orders
pool에서 balance manager가 배치한 모든 open orders를 취소한다. 이는 balance manager와 연관된 모든 주문을 취소하는 편의 함수이다.
packages/deepbook/sources/pool.move. You probably need to run `pnpm prebuild` and restart the site.Withdraw settled amounts
정산된 금액을 balance_manager로 withdraw한다. 모든 주문은 정산된 금액을 자동으로 withdraw한다. 이는 pool에서 정산된 모든 자금을 withdraw하기 위해 명시적으로 호출할 수 있다.
packages/deepbook/sources/pool.move. You probably need to run `pnpm prebuild` and restart the site.Withdraw settled amounts permissionless
TradeProof를 요구하지 않고 정산된 금액을 balance_manager로 withdraw한다. 이는 누구나 호출하여 balance manager의 자금을 정산할 수 있는 permissionless 버전이다.
packages/deepbook/sources/pool.move. You probably need to run `pnpm prebuild` and restart the site.Events
OrderFilled
maker order가 채워질 때 emit된다.
packages/deepbook/sources/book/order_info.move. You probably need to run `pnpm prebuild` and restart the site.OrderCanceled
maker order가 취소될 때 emit된다.
packages/deepbook/sources/book/order.move. You probably need to run `pnpm prebuild` and restart the site.OrderModified
maker order가 수정될 때 emit된다.
packages/deepbook/sources/book/order.move. You probably need to run `pnpm prebuild` and restart the site.OrderPlaced
maker order가 order book에 배치될 때 emit된다.
packages/deepbook/sources/book/order_info.move. You probably need to run `pnpm prebuild` and restart the site.