FLEX General Architecture
Last updated
Last updated
Flex achieves load balancing and speed of execution by distributing the logic among many atomic smart contracts, while simultaneously transferring search and decision logic to user computers. All Order Book contracts addresses are deterministically calculated: the Trading Pair and its Price order contracts.
Flex trades exclusively in Flex TIP3 tokens. External TIP3 tokens or any other type of tokens, including native EVERs are introduced to Flex via a Flex TIP3 wrapper for the token.
For instance, XTIP3-YTIP3 will resolve a Root of XTIP3-YTIP3 trading pair. XTIP3 is the base currency (major token) and YTIP3 is the quote currency (minor token). Users then can calculate an address of a particular Price Contract by entering a Price. “Code Hash=$XTIP3-YTIP3 Data=1.2” will calculate an address of a contract that currently trades an XTIP3-YTIP3 pair at 1.2 YTIP3 per 1 XTIP3 token.
After performing the calculation of addresses, the user performs a read operation: querying the blockchain database with SDK over GraphQL. Since each user only calculates pairs and prices they need, the operation takes microseconds and one query is almost instantaneous.
Trading step value for a pair will be provided in the pair's Root Contract data. Users can now calculate a whole order book of this pair by entering all price steps around the target price or ask the database for all addresses of that Price contract code hash. After calculating all price step contract addresses, a user may try to retrieve all these contracts. If the contract does not exist, it means there are no orders of that price.