Skip to main content

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.

  1. Liquidity Providers (LPs)
  2. Traders
  3. Chainlink Nodes
  4. UIs / Data Clients

Each API is associated with one or more of these actors.

Index

ActorActionContractMethodApprovalsNotes
LPadd initial liquidityAMMFactorycreatePoolcollateral 
LPadd subsequent liquidityAMMFactoryaddLiquiditycollateral 
LPremove liquidityAMMFactoryremoveLiquiditylp tokeneach market has its own lp token
LP, tradertrade winning shares for collateralSportsLinkMarketFactoryclaimWinnings, claimManyWinnings  
tradertrade collateral for sharesAMMFactorybuycollateral 
tradertrade shares for collateralAMMFactorysellForCollateral share tokens trust AMMFactory so no approval needed
link nodecreate marketSportsLinkMarketFactorycreateMarket link node only. use encodeCreation to build the argument. creates 3 markets off of the event
link noderesolve marketSportsLinkMarketFactorytrustedResolveMarkets link node only. use encodeResolutin to build the argument. resolves all 3 markets for the event
link nodeclaim settlement feesSportsLinkMarketFactoryclaimSettlementFees link node only
UIget share pricesAMMFactorytokenRatios one of each share equals one collateral, adjusted by shareFactor
UIget pool liquidityAMMFactorygetPoolBalances and getPoolWeights one of each share equals one collateral, adjusted by shareFactor
UIget trading feeAMMFactorygetSwapFee  
UIget someone's token balanceAMMFactorygetPoolTokenBalance works well with multicall
UIget pool associated with marketAMMFactorygetPool  
UIget basic market infoSportsLinkMarketFactorygetMarket  
UIget market info for SportsLinkSportsLinkMarketFactorygetMarketDetails  
UIget quantity of marketsSportsLinkMarketFactorymarketCount market ids increment from 1 so this implies the list of all markets
AMMFactoryturn collateral into n of each shareSportsLinkMarketFactorymintSharescollateralAMMFactory uses this for more liquidity-efficient buys
AMMFactoryturn n of each share into collateralSportsLinkMarketFactoryburnShares AMMFactory uses this for more liquidity-efficient sells
link nodecheck if market is resolvedSportsLinkMarketFactoryisMarketResolved  
link nodelist all unresolved marketsSportsLinkMarketFactorylistUnresolvedMarkets unusable on-chain due to O(n) gas cost
nobodyget conversion rate from shares to collateralSportsLinkMarketFactorycalcCost does the shareFactor adjustment for shares and collateral. dies if there's a remainder
nobodyget conversion rate from collateral to sharesSportsLinkMarketFactorycalcShares reverse of calcCost
link nodeget markets associated with eventSportsLinkMarketFactorygetEventMarkets list of 3 market IDS. zero means the market wasn't created
link nodecheck if event was already registeredSportsLinkMarketFactoryisEventRegistered return true only if all markets were created - often the first (head2head) is created alone
link nodepack market creation args into a bytes32SportsLinkMarketFactoryencodeCreation use with createMarket
nobodyunpack market creation args from bytes32SportsLinkMarketFactorydecodeCreation used internally
link nodepack market resolution args into a bytes32SportsLinkMarketFactoryencodeResolution use with trustedResolveMarkets
nobodyunpack market resolution args from a bytes32SportsLinkMarketFactorydecodeResolution used internally