Augur Turbo - Contract API
Augur Turbo has a relatively simple contract design, consisting of three major components.
- Market Factories
- AMM Factories
- FeePot
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.
Actors
There are four main Actors in the system.
- Liquidity Providers (LPs)
- Traders
- Chainlink Nodes
- UIs / Data Clients
Each API is associated with one or more of these actors.
Index
Actor | Action | Contract | Method | Approvals | Notes |
---|---|---|---|---|---|
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 |