System Design and Overview
Hybrid AMM and Order Book Design
The Tribe3 trading platform is powered by a hybrid system, which combines liquidity of AMM and order book. All orders are traded against the AMM and/or the order book, depending on which liquidity source offers the best available execution price. The hybrid approach combines the advantages of AMM and order book, allowing the system to achieve seamless and efficient trading experience while minimizing price impact of each trade.
Mechanism Overview and Flow
A user's trade interacts with the following components:
A non-custodial deposit account that enables flexible execution of orders
An AMM that is powered by the the constant product formula x*y=k
An order book, where limit orders are stored, that acts as a more scalable source of liquidity which reduces price impact of each trade
User deposits fund into Tribe3
User uses fund in deposit account to open a position by specifying the collateral amount and the leverage to be applied
System builds order by routing the order through AMM and order book at the best possible price
System sends collateral (e.g. ETH, USDC) to the vault
System executes the trade by updating AMM, matching orders
System updates user's positions
Quick Example
The simplified example below illustrates the case where Satoshi wants to open up a long position with 15 ETH at 2x leverage (i.e. 30 ETH notional) for BAYC via market order. Assuming the system's current state is:
AMM at price of 30 ETH
Order book has the following sell orders:
31 ETH with depth of 10 ETH
32 ETH with depth of 10 ETH
Satoshi's order is then filled following the logic below:
Since AMM has a better execution price, Satoshi's order is first filled against the AMM - suppose 10 ETH of Satoshi's order is filled which takes the AMM price from 30 ETH to 31 ETH
10 ETH of Satoshi's remaining order will be filled directly against the order book at 31 ETH
AMM liquidity will then be tapped given AMM price has the best execution price after all the liquidity in the order book at price of 31 ETH has been matched - further suppose 5 ETH of Satoshi's order is filled against the AMM, taking the price from 31 ETH to 32 ETH
Remaining 5 ETH of Satoshi's order will then be filled against the order book at 32 ETH
Price Impact
Price moves whenever a trade is made. The percentage moved caused by each trade is called price impact, which is determined by the size of the trade, size of k of AMM and the liquidity depth of the order book.
System Stability
Tribe3 has implemented the following measures to protect the stability of the system:
Price fluctuation per block is capped at 3%. In the case where price has already increased/decrease more than 3% within a block, users won’t be allowed to execute any trades until the next block
*During testnet, Tribe3 team will continuously implement updates and new features to improve the protocol's stability
Last updated