# Manipulation2

## Manipulation strategies overview

Traders or counterparties who use this oracle want the most profitable price for themselves. For example, if a trader opens a long position and the price moves higher within 5 seconds, they would want the oracle to not update so they get the initial price instead of the worse one. In the current design, there is no way for a trader to prevent a report from being disputed.

In a different example, the trader opens a long position and the price moves lower before the oracle is settled. In the case that the price moves outside the reporter's fee boundary downwards, disputers will compete to dispute the previous report. Because there is the same chance of the price moving outside the reporter's fee boundary upwards, there is no net benefit to the trader.

Imagine we are back to a trader opening a long position. Assume the trader has a large notional exposure on their trade that is settled by this oracle. Assume the first report was an accurate price. It is possible for the trader to immediately dispute the first report and report a price that is at or just beyond the lower fee boundary. The price is still around the last reported price at this time, meaning the current price is effectively the upper fee boundary of the dispute. And since the chance of the price going epsilon above its initial value at any point in the next five seconds is very high, there is a very high chance the trader's dispute itself is disputed, and all the trader did was burn money in swaps twice trying to manipulate the oracle. For the trader's counterparty, they could do the same thing except in their dispute they report the higher fee boundary, and the outcome is the same.

What if the trader decides to wait until the price has moved down but is still well above the lower fee boundary? They dispute the price, lose some small amount in the swap and attest to a price at or just outside the lower fee boundary. Now, their upper fee boundary is above the current price, so there isn't a near 100% chance of them getting disputed anymore. Given that the fee boundary is determined using +/- F, and F is equal to 1 standard deviation of 5 second returns, we can say (assuming normality) that the lowest chance of them getting disputed lies when current price is 0.5F away from initial report price. This is a dispute probability of around 75% (complement of double no touch with barriers +/-0.5 and -/+1.5 st dev). If they don't get disputed, they win a 2bps edge (assuming F = 0.04%). This is 0.5bp in EV (25% \* 2) over their counterparties, assuming the price even gets to 0.5F during the 5 seconds. The problem is that there is the exact same incentive for the counterparty to dispute 0.5F in the other direction, which means if both traders and counterparties are doing this, the effect should net out to zero.

For example, immediately after the trader's dispute, the trader's counterparty could dispute and place the price 0.5F above the true price. They would go back and forth, with the latest swapper net losing because they are paying each other effective 4bps in swap fees on increasingly larger swaps. The game would end once the money at stake reaches around the notional size of the order, because it would cost too much money to keep delaying oracle settlement.

It doesn't seem great to have traders and counterparties playing this game. Despite the effect netting out to zero, there seems to be an incentive for the traders and counterparties to play a pyrrhic game of chicken. The trader disputes low, the counterparty re-disputes high, the trader re-re-disputes low, etc. It only ends if the price never gets to 0.5F in either direction, which is a small % of the time.

### Passive trader or counterparty dispute game

In the case of a passive counterparty that lets the trader manipulate the oracle in their benefit, it is important to know how much this actually costs the counterparty. Assume the trader is opening a long. Let's assume for now the initial reporter is honest. The trader sees this honest report and is trying to get themselves a better execution price for their trade. In this scenario, where F = st dev, the optimal place to get a manipulated report in is -0.5F below the "true" price at 0F given the trader is long.\
\
But first, we need to know, what is the chance the price actually gets to -0.5F so the trader can play this game? Starting from a neutral report at 0F, the report has 2 possible outcomes: not be disputed (outcome A) or be disputed higher or lower (outcome B). Let's set A to 0% for now. Now we have a lower barrier at -0.5F and an upper barrier at +1.0F. We know from statistical barrier math that ⅔ of the time -0.5F is hit first. Said another way, the trader has a 67% chance of being able to play the game, starting from a neutral report.\
\
So now let's assume the trader waits until the price gets to -0.5F and reports a further -0.5F from there. Now the fee boundaries are at -1.5F and +0.5F with respect to the true price at 0F. If the manipulator's report isn't disputed, the trader gains 2bps (assuming F = 0.04%) on their external notional exposure. In either case, dispute higher or dispute lower, the game is reset by a neutral disputer and neither trader nor counterparty gains or loses anything as the external trade is not actually open yet.\
\
So we have 2 scenarios: no dispute (A) and dispute higher/lower (B). In case A, the trader earns 2bps on their notional, relative to the initial true price. In case B, the trader earns nothing but gets the same 67% chance at playing the game again. The probability of no dispute is 25% following the same math earlier in this page.

EV(A) = 0.67\*0.25\*2\
EV(B) = 0.67\*0.75 \* (EV(A)+EV(B))

Solving for EV(A+B) results in the trader gaining \~0.67 of a basis point from this strategy on their notional.

We can generalize to get a better understanding of the situation. Using fractions of the swap fee report placement R (i.e. R = |-0.5F| ) for optimal report manipulation placement, P(A) for no dispute probability and P(G) for the chance we get to play the game again, but this time breaking the disputes into dispute down P(C) and dispute up P(B) because in the case of dispute down, the active trader is incentivized to try to submit another -0.5F report. Let's say they do it perfectly.

EV(A) = P(G)\*P(A)\*R\
EV(B) = P(G)\*P(B) \* (EV(A)+EV(B)+EV(C) )\
EV(C) = P(G) \* (P(C)\*P(A)\*R  +  P(C)\*(1-P(A))\*(EV(B)+EV(C) ) )

Solving for EV(A+B + C) is kind of complicated but we get the below:\
\
$$Loss = \frac{ R \* P(G) \* P(A) *(1 + P(C)) } { 1 - P(G)*(1 - P(A) - P(C)\*P(A)) }$$\
\
Notice the denominator may be able to blow up at 0, but we will ignore that for a second and assume it can't. Recall we set P(G) to 67%, which is actually a theoretical maximum assuming the neutral report has a no dispute chance of 0%. This means if we plug in ⅔ for P(G) and ¼ for P(C), we get a theoretical upper bound for arbitrage loss of R \* 5 \* P(A) / (2+5\*P(A)), or with P(A)=1, Loss <= 5R/7.\
\
In this case we set P(A) as 25% (probability of no dispute) which implies an arbitrage loss upper bound of \<R/2.6. Notably, the worse the distribution is for disputers (i.e. the lower the P(A)), the better things are for passive[ ](#user-content-fn-1)[^1]traders or counterparties from an arbitrage loss perspective. \
\
Neither P(G) nor P(C) are actually ⅔ and ¼ respectively. This assumes the no-dispute probability inside of that particular game state is 0, when it is actually more like 12% and 27% respectively. So the arbitrage loss is even lower. Assuming P(A) = 25%, we get the arbitrage loss bounded to \<R/3.2\
\
A mitigating factor here is, during the dispute down scenario, the active trader is not guaranteed to get a report in at -0.5F. They may try to go early at -0.4F to avoid being frontran by some other honest disputer. But D is not -0.4F, which reduces arbitrage profit with an exponential falloff penalty. So we should think it's likely \<R/3.2 is more like \<R/4.\
&#x20;\
A consequence of our complicated Loss(R,P(A),P(G),P(C)) formula above is at the extremes, arbitrage loss is capped to R. And because R<=F, arbitrage loss is capped at F.\
\
Case of P(C) = 0:\
P(A)=1, P(G)=1 ⇒ R/1 = R\
P(A)=1, P(G)=0 ⇒ 0/1 = 0\
P(A)=0, P(G)=1 ⇒ 0/0 = R\
P(A)=0, P(G)=0 ⇒ 0/1 = 0\
\
Case of P(C) = 1:\
P(A)=1, P(G)=1 ⇒ 2R/2 = R\
P(A)=1, P(G)=0 ⇒ 0/1 = 0\
P(A)=0, P(G)=1 ⇒ 0/0 = R\
P(A)=0, P(G)=0 ⇒ 0/1 = 0\
\
In the two cases where we have 0 in both numerator and denominator, the limit approaches R as P(A) approaches 0. P(C) and P(A) cannot both be 1 but in any case still return the cap R of loss. You can only lose the full R when P(A) and P(G) are 1 but P(C) is 0.\
\
But, it appears there could be situations where the denominator can get close to zero, unbounding the arbitrage profit. Specifically, from our formula's denominator we can say if 1 - \* P(G) \* (1-P(A) - P(C)\*P(A)) = 0, our arbitrage loss is infinite. If we get close to 0, it's way too high. \
\
So, solving the equals zero equation, we can say if P(G) \~= 1 / ( 1 - P(A)\[1+P(C)] ), our arbitrage profit is too high. Whenever P(A)>0, 1-P(A)\[1+P(C)] is <1. The reciprocal is then >1, meaning this implies P(G) >1, which is impossible. So the only possible way for this to diverge is either the case of P(A) = 0 or the case of P(A) = 1 & P(C) = 0. In both those cases, the numerator of the complex Loss function is 0, so the whole arbitrage loss tends to either 0 or R and doesn't diverge. What about, the denominator isn't zero but it's quite low so the arbitrage loss blows out but not to infinity? As denominator gets small inside of a feasible probability set, the numerator shrinks at least as quickly, leaving us with numerator < denominator \* R. There is no parameter choice of P(A), P(G) and P(C) within \[0,1] that leaves the arbitrage loss unbounded.\
\
In fact, since P(G) (chance you get to play) and P(A) (chance the manipulated price survives) are not independent and counteract each other in practice, it's likely the arbitrage loss is typically capped to much less than R. Even if these probabilities are at different points in the game state, they are sequential and should have basically the same underlying distribution governing them.\
\
Finally, we can cap the manipulator’s edge just from barrier math. Since we know P(G) <= ⅔ plugging this our Loss function yields:\
\
Arbitrage loss <= 2R/3 <= 2F/3\
\
So almost no matter what, regardless of how P(A) and P(C) are configured, an active trader can't extract more than ⅔ F on their notional out of passive counterparties via disputes. In practice it is much lower because environments with high P(A) are not typically hospitable to high P(G).

### Initial Reports

Initial reports are a one round version of the above game, except P(G) is 1 since they can choose whatever price they want, assuming they are the first to report. If not disputed, initial reporter makes the optimal report manipulation placement R on their external notional. If disputed, the price is neutral. Here, P(A) is the chance the initial report isn't disputed. So the total arbitrage loss is just this line and doesn't need recursion:[<br>](#user-content-fn-1)[^1]\
EV(A) = P(A)\*R\
\
So given R <= F,  initial report arbitrage loss caps at F (the swap fee). You would need unnaturally stable price action and even then you can only extract almost the swap fee. In practice, when F is set to stdev of the settlement window, P(A) here (DNT with barriers +0.5/-1.5) is around 0.27 and possibly lower for financial returns. With R = 0.5F, we are looking at something like \~F/8 for max expected arbitrage loss attributable to initial report.\
\
The active trader would be willing to outbid any other initial reporter for the spot, so it is highly likely they are the initial reporter.

### How high is F?

In the previous examples, we set F to be 0.04%. We talked about it as the standard deviation but really it is supposed to be a dispersion measure since we don't know the distribution. F at 0.04% is often the standard deviation at 1 minute timeframes, not 5 seconds as we were using it before. Scaling down to 5 seconds ( 0.04%/sqrt(12) ) is an F of 1.15 basis points. And with P(A) of 25% and P(G) of 67%, we see the arbitrage loss as less than \~0.4 basis points. Further reductions to arbitrage loss can be had with reductions in settlement time (like reducing from 5 seconds to 3) though it is a worse than linear decrease in arbitrage. Also, we can use a fraction of the dispersion measure for the fee boundary instead of fully F. If we use some fraction of F for the fee boundary, this also reduces P(A) which has a knock-on effect on the arbitrage loss. So it is a better than linear benefit to arbitrage loss when we reduce the fee boundary to below F.

### Conclusion

Manipulation techniques may produce arbitrage loss for passive traders or counterparties but can be made manageably low. Maybe the fee boundary should be set at something below F, like 85% of F, but this comes at a liveness tradeoff.

[^1]:
