synthesized liquidation feeds#137
synthesized liquidation feeds#137mesozoic-technology wants to merge 93 commits intooverlay-market:mainfrom
Conversation
C4 collateral
C4 comptroller
C4 mothership
C4 underwater
…le price relative to ETH for OVL in the depth feed, and placing ETH in the correct slot as to cooperate with the decimals of the market liquidity feed which was taken from ETH/USDC where USDC has 6 decimals
…ding from them to trigger primitive version of subgraph
…low or low to go high respectively
|
In order to easily test liquidations as well as develop frontends, a predictable price feed will reap many benefits. If a price feed is predictable, then the chain can be mined to that point and the feed will be on the verge of liquidation, liquidtable, or underwater, and any one of these can be arrived at deterministically to either construct a precise test, or to queue up another position for liquidation to refine the frontend experience. If a price feed increments or decrements by 1% per iteration, say every 10 minutes, then the time to mine for in order to bring about a specific state can be derived by the following formula
Constructing a price feed with this in mind, allows for comprehensive testing and development. |
… the price at the current tick
|
In practice, as derived from python, the percentage change between price periods looks to amount to I wonder how much this is inherently tethered to the fact that uniswap uses a log of Could that be improved in the python or is the python limited to the reality of the uniswap oracle/mock? In any case, it seems this should be sufficient. Given an epoch of 15 seconds, an entry price of 100, a position of 1x long against a feed that decreases by |
|
Actually, this formula for deriving when you mine to will be insufficient given the one hour window in place for a time weighted average price. I must examine the behavior of the spread and account for either the one hour or ten minute window. |
|
In practice, this may not matter much, at least due to the presence of a TWAP. Since the price feed in/decrements monotonically at a steady pace, it appears that the formula above shows true for all permutations - one hour, ten minute, spot, bid, ask. The below was achieved correctly after computing
Still problematic is that the bid is so different than the ask, where the bid is basically the 10 minute TWAP, the ask is the 1 hour TWAP. |
|
I succeeded in creating a function to more or less brute force this calculation using prior knowledge of the price feed incr/decrementation alongside panda's. Since the periods increase or decrease by a tick value of Once the time weighted averages are computed, from the tick values which I hope alleviates concerns of geometric vs arithmetic twaps, I apply the bid adjustment using a min and the negative spread value. At this point, finding the index of the end price and determining the correct starting index should lead to the number of epochs one must mine to in order to receive those prices. |
|
Two improvements,
|
|
The For this price finding function to work then, the entry price would have to be reworked to its attendant spot price. |
|
All of the above is too elaborate. It forgets the first principle of feeds synthesized in this manner which does away with all of the complexity needing rolling averages. Because the price feed increases or decreases at a steady rate, 101 ticks per period, then it is always known what the 10 minute or 1 hour twap will report relative to spot. Therefore all that needs be done is to calculate spot, adjust it accordingly, follow it ahead into the future until it hits the desired liquidation price and tells how many periods must be mined. So long as the synthesized feeds are de/inclining aggressively enough, the bid will always be the 10 minute twap for liquidating longs and the ask will always be the 10 minute twap for liquidating shorts. |
|
|
Strangely enough this version below works. Why adding 26 periods or 390 seconds to the end, after setting the price in the beginning to be in line with the ten minute twap, makes this work, I have no idea. But it does. This yields the period just beyond the end price parameter to this function, which must be a price that is lesser than the start parameter. Further work could obtain a more granular seconds value, right now per period there is a fairly large chunk of the price that is being skipped over. For instance with an ending price targeted at a margin maintenance of 6 percent, this function yields a period with a price that is If it could be improved such that it'd be right on the boundary of the margin maintenance, this could provide a good liquidation test where a position is asserted to not be liquidatable just before the chain is mined a few seconds and it becomes liquidatable. |
This PR is dedicated to creating a deployment of three quanto markets with unique price feeds skewed towards liquidations for longs, shorts, and one back and forth feed.
Goals are