Skip to content

Latest commit

 

History

History
38 lines (22 loc) · 3.11 KB

TIP-202.md

File metadata and controls

38 lines (22 loc) · 3.11 KB
id Title Status Author Description Discussions to Created
TIP-202 Speed Markets contract changes and optimization Draft padzank (@padzank) Optimize market creation logic and introduce a new creator contract https://discord.gg/thales 2024-05-17

Simple Summary

Optimize market creation logic and introduce a new market creator contract for Speed Markets product

Abstract

This TIP proposes to optimize Speed Markets architecture by introducing strike price slippage mechanism that further enhances product security against toxic flow and strike price manipulation.

This is implemented by deploying a new SpeedMarketsAMMCreator contract which becomes the sole whitelisted contract for creating new markets based on user sent parameters. Parameters that users sends are now Strike Price and Slippage, where Strike Price is snapshotted as current price from UI and Slippage is used to determined how much deviation to their chosen strike price is the user willing to tolerate if the live price changes until the request reaches the chain.

Motivation

First implementation of Speed Markets allowed anyone to create markets by directly interacting with SpeedMarketsAMM contract. This versions design entailed that the contract will accept Pyth current strike price at time of latest UI update as long as its not older than 20 seconds. This condition was implemented due to time difference between locking in the price on the UI and locking in the price on the live Pyth price feed on the contract.

Even though this design was succesful in providing fast onchain trading environment around current price, the 20 seconds delay also made possible for malicious automated entities to try and gain an unfair edge against the AMM by frontrunning the price during those 20 seconds.

These changes succesfully mitigate that issue by replacing the buffer delay mechanism with a customizable Slippage mechanism. The slippage will effectively tell the market creator contract to create a market only if the user-sent strike price is not deviated from the live contract price by more than the chosen percentage amount.

Specification

This TIP entails the Thales Protocol DAO to make the following changes to the Speed Markets contracts:

  • Deploy a new SpeedmarketsAMMCreator contract which uses the SpeedMarketsAMM contract to create all pending speed markets
  • Whitelist SpeedMarketsAMMCreator contract as a sole address enabled to use SpeedMarketsAMM contract
  • Remove the createNewMarketWithDifferentCollateral method from SpeedMarketsAMM contracts and unify the default and non-default collateral market creations under the same call, for optimization purposes
  • Remove priceUpdateData and add pythPrice and collateral functions from createNewMarket method

Implementation

SpeedMarketsAMMCreator.sol

Copyright

Copyright and related rights waived via CC0.