System Design and Overview
Last updated
Last updated
The Tribe3 trading platform is powered by a hybrid system, which combines liquidity of AMM and an 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 the price impact of each trade.
The Tribe3 technical stack is composed of an on-chain clearing house and an off-chain matching engine. The on-chain clearing house hosts the trading venue where core trading components and logic are controlled by the smart contracts. Meanwhile the off-chain matching engine houses a central-limit order book and matches orders with the best price available across AMM/order book in a gasless and low-latency manner. Built orders are eventually submitted on-chain for settlement. Harnessing the power of Tribe3's unique technical construct, traders and market makers are offered with a secured and highly-performant venue to execute trades.
User deposits funds into Tribe3
User creates an market/limit order and specifies parameters including collateral amount and leverage
System builds order by routing the order through AMM and order book at the best possible price (if a limit order is not immediately executable, it will be inserted into the order book until matched by another order)
System sends collateral (e.g. WETH) to the vault
System executes the trade by updating AMM, matching orders
System updates user's positions
The simplified example below illustrates the case where Satoshi wants to open up a long position with 15 WETH at 2x leverage (i.e. 30 WETH notional) for BAYC via market order. Assuming the system's current state is:
AMM at price of 10 WETH
Order book has the following sell orders:
11 ETH with depth of 10 WETH
12 ETH with depth of 10 WETH
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 WETH of Satoshi's order is filled which takes the AMM price from 10 WETH to 11 WETH
10 WETH of Satoshi's remaining order will be filled directly against the order book at 11 WETH
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 11 WETH has been matched - further suppose 5 WETH of Satoshi's order is filled against the AMM, taking the price from 11 WETH to 12 WETH
Remaining 5 WETH of Satoshi's order will then be filled against the order book at 12 WETH
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, liquidity depth of the AMM and the order book.
Tribe3 has implemented the following measures to protect the stability of the system:
Price fluctuation is capped at 6% per block (where the length of each block is defined as 15 seconds). In the case where price has already increased/decrease more than 6% within a block, users won’t be allowed to execute any trades that widen the price gap until the next block
*Tribe3 team will continuously implement updates and new features to improve the protocol's stability