Augur Turbo has a relatively simple contract design, consisting of three major components.
- Market Factories
- AMM Factories
In the current system there is very little trust of any of these contracts.
A market factory is a contract interface that Chainlink nodes can use to put market data on chain and update it upon resolution. For each of these markets, a user will interact with an AMMFactory to create an AMM associated with that market. In the current implementation this AMM is a simple Balancer v1 pool.
The FeePot is a contract which will be used in the future to handle REPv2 staking for claiming a portion of fees generated by trading in the system.
There are four main Actors in the system.
- Liquidity Providers (LPs)
- Chainlink Nodes
- UIs / Data Clients
Each API is associated with one or more of these actors.
|LP||add initial liquidity||AMMFactory||createPool||collateral|
|LP||add subsequent liquidity||AMMFactory||addLiquidity||collateral|
|LP||remove liquidity||AMMFactory||removeLiquidity||lp token||each market has its own lp token|
|LP, trader||trade winning shares for collateral||SportsLinkMarketFactory||claimWinnings, claimManyWinnings|
|trader||trade collateral for shares||AMMFactory||buy||collateral|
|trader||trade shares for collateral||AMMFactory||sellForCollateral||share tokens trust AMMFactory so no approval needed|
|link node||create market||SportsLinkMarketFactory||createMarket||link node only. use encodeCreation to build the argument. creates 3 markets off of the event|
|link node||resolve market||SportsLinkMarketFactory||trustedResolveMarkets||link node only. use encodeResolutin to build the argument. resolves all 3 markets for the event|
|link node||claim settlement fees||SportsLinkMarketFactory||claimSettlementFees||link node only|
|UI||get share prices||AMMFactory||tokenRatios||one of each share equals one collateral, adjusted by shareFactor|
|UI||get pool liquidity||AMMFactory||getPoolBalances and getPoolWeights||one of each share equals one collateral, adjusted by shareFactor|
|UI||get trading fee||AMMFactory||getSwapFee|
|UI||get someone's token balance||AMMFactory||getPoolTokenBalance||works well with multicall|
|UI||get pool associated with market||AMMFactory||getPool|
|UI||get basic market info||SportsLinkMarketFactory||getMarket|
|UI||get market info for SportsLink||SportsLinkMarketFactory||getMarketDetails|
|UI||get quantity of markets||SportsLinkMarketFactory||marketCount||market ids increment from 1 so this implies the list of all markets|
|AMMFactory||turn collateral into n of each share||SportsLinkMarketFactory||mintShares||collateral||AMMFactory uses this for more liquidity-efficient buys|
|AMMFactory||turn n of each share into collateral||SportsLinkMarketFactory||burnShares||AMMFactory uses this for more liquidity-efficient sells|
|link node||check if market is resolved||SportsLinkMarketFactory||isMarketResolved|
|link node||list all unresolved markets||SportsLinkMarketFactory||listUnresolvedMarkets||unusable on-chain due to O(n) gas cost|
|nobody||get conversion rate from shares to collateral||SportsLinkMarketFactory||calcCost||does the shareFactor adjustment for shares and collateral. dies if there's a remainder|
|nobody||get conversion rate from collateral to shares||SportsLinkMarketFactory||calcShares||reverse of calcCost|
|link node||get markets associated with event||SportsLinkMarketFactory||getEventMarkets||list of 3 market IDS. zero means the market wasn't created|
|link node||check if event was already registered||SportsLinkMarketFactory||isEventRegistered||return true only if all markets were created - often the first (head2head) is created alone|
|link node||pack market creation args into a bytes32||SportsLinkMarketFactory||encodeCreation||use with createMarket|
|nobody||unpack market creation args from bytes32||SportsLinkMarketFactory||decodeCreation||used internally|
|link node||pack market resolution args into a bytes32||SportsLinkMarketFactory||encodeResolution||use with trustedResolveMarkets|
|nobody||unpack market resolution args from a bytes32||SportsLinkMarketFactory||decodeResolution||used internally|