🤖Sports AMM Smart Contract
Last updated
Last updated
Now that we've learned how Game Market Contracts and Outcome Tokens are created, you may be wondering how these individual market contracts get seeded with collateral to exchange for winning Outcome Tokens once a market is resolved. This is where the next key contract for Overtime's architecture, the Sports AMM Smart Contract, comes into play.
The Sports AMM Smart Contract is whitelisted to automatically mint Outcome Tokens for individual sports markets by depositing USD collateral from the liquidity pool to individual Game Market Smart Contracts. This collateral acts as on-demand liquidity for traders minting Outcome Tokens during the positioning phase, with odds data provided by Chainlink to update prices in near real-time.
There are two methods that need to get called before the Sports AMM can minted Outcome Tokens. These include the "BuyFromAmmQuote" method and the "BuyFromAMM" method.
When a user wants to acquire a position for a certain game using the SportsAMM, the first step is retrieval of pricing data for that position. This data is seeded to the contract from the Chainlink Odds Data request and it determines the price that the SportsAMM will sell the ERC20 Outcome Tokens for on-demand. When the Odds Data request sends the odds data to the AMM contract, the ERC20 Outcome Tokens can be acquired from the SportsAMM with the "BuyFromAmmQuote" read method called by the user. This method requires the following inputs to return a relevant quote:
Market (address): The address of the Game Market Smart Contract that the position is from
Position (uint8): A single digit input in the uint8 format that signals what is the exact position for the game in question
Amount (uint256): The amount of Outcome Tokens requested for that position which is needed to calculate the Skew Impact/Discount for the quote
Traders are able to purchase of Outcome Tokens using their wallet to execute the Sports AMM Smart Contract's "BuyFromAMM" method. The inputs required are as follows:
Market (address): Address of the Game Market Smart Contract that the position is from
Position (uint8): A single digit input in the uint8 format that signals what is the exact position for the game in question
Amount (uint256): The amount of Outcome Tokens requested for that position which is needed to calculate the Skew Impact/Discount for the quote
ExpectedPayout (uint256): The amount of collateral that can be claimed for a winning position
AdditionalSlippage (uint256): The amount of slippage to include in the transaction as a risk management measure
After the "BuyFromAMM" method is executed by the SportsAMM, the contract executes the following series of actions atomically in a single transaction:
Take the buy-in amount of USD from the user
Take the amount of USD required to collateralize a user's requested ERC-20 Outcome Tokens from the Liquidity Pool contract
Use the USD taken from the Liquidity Pool to mint an equal amount of every type of ERC-20 Outcome Token that matches the amount requested by the user
Sends the minted ERC-20 Outcome Tokens for the specific position/outcome (stored in the position input) and amount (stored in the amount input) to the user
Sends a certain percentage of USD from the user's buy-in amount to the SafeBox contract, determined by the "SafeBoxImpact" parameter
Sends the remaining amount of USD from the user's buy-in amount to the Liquidity Pool contract
The Sports AMM has certain mechanics implemented that act as risk management tools. These mechanics keep the SportsAMM from offering positions that could expose it to an unacceptable amount of downside risk.
These are:
Cap Per Market: A threshold of how much risk the Sports AMM allows itself to take per Game Market, denominated in USD. The "DefaultCapPerGame" read method shows the global default for any new game market, while the "CapPerSport" method shows the specific risk cap set for an individual sport/league. "CapPerMarket" shows a specific cap set for an individual market.
Skew Impact / Discount: A per-market premium or discount on top of the default pricing provided by Chainlink Odds data, based on the amount of current risk taken on by the Sports AMM.
Max/Min Supported Odds: Determines the maximum and minimum price of any position that the SportsAMM can provide liquidity for. If the Chainlink Odds data provides odds that are beyond this threshold for a certain game, that game will not have on-demand liquidity from the SportsAMM until they are potentially updated to fall within the required price range.