# Oracle life cycle

We will go through a simplified example of how the oracle works from start to end. The oracle life cycle begins with a price request.\
\
Let's say an application wants the price of WETH against USDC. In the price request, they specify\
\
1\.  token1: WETH\
2\. token2: USDC\
3\. token1Amount: 0.1 WETH\
4\. settlementTime: 10 seconds\
5\. multiplier: 1.5x\
6\. reward: 0.001 eth\
\
The oracle contract balance is now 0.001 eth.\
\
This price request gets on-chain and anybody can report a price. Let's say the price of ETH is $3000. The next step is a reporter submits an initial report, winning the race against everybody else to claim the 0.001 eth.

Because an application was using the oracle to get a price, there must be two people who are in opposite positions. Meaning, if the price is reported higher, one person benefits and the other loses, and vice versa. Assume one of the people is completely passive, but assume the other is active, and would benefit were the oracle to settle reporting WETH as not as valuable. So assume the initial reporter is the manipulator in this party, because they are able to outbid everybody else in the block.\
\
In the initial report, they specify: \
\
token1Amount: 0.1 WETH\
token2Amount: 150 USDC\
\
The oracle contract balances are now 0.001 eth, 0.1 WETH, and 150 USDC. \
\
These report balances imply an eth price of $1500 when the real price is $3000.\
\
After settlementTime of 10 seconds assuming nobody disputes this report, the report may be settled and become usable for the application, at a horrible price. But, it is profitable to come along and dispute this, so we assume a disputer comes along before 10 seconds is up.\
\
In the dispute, they specify:\
\
token1AmountNew: 0.15 WETH\
token2AmountNew: 450 USDC\
tokenToSwap: USDC\
\
They decide to swap against the initial reporter's 150 USDC, meaning they choose USDC as the token to swap in their dispute. The amounts are 50% larger than the initial report by contract rule using the 1.5x multiplier from the price request. The token flows are as follows:\
\
The oracle contract takes 150 USDC from the disputer, then adds this to the initial reporter's original 150 USDC and sends it all to the initial reporter, for a total of 300 USDC sent to the initial reporter.

Next, the oracle contract takes 450 USDC and 0.05 WETH from the disputer and adds it to the report.\
\
The contract balances are now 0.001 eth, 0.15 WETH and 450 USDC and the settlementTime timer resets to another 10 seconds.\
\
Assume the manipulator relents and the settlementTime of 10 seconds passes, anyone can come along and settle the reported price. The oracle price is $3000 (implied by 0.15 WETH and 450 USDC) while the real price is $3000.\
\
In the settlement, they only specify which report they are settling. The token flows in the settle are as follows:\
\
Initial reporter (the manipulator) receives 0.001 eth from the initial reporter reward. This must be netted against the gas cost of outbidding everyone else to be the first initial reporter.\
\
Disputer receives 450 USDC and 0.15 WETH back.\
\
The contract balances are now 0 across all eth and tokens. If we net the flows across the entire oracle life cycle of price request, initial report, dispute and settlement, we see the following:\
\
Initial reporter: \
&#x20;   USDC: +150\
&#x20;   WETH: -0.1\
\
Disputer:\
&#x20;   USDC: -150\
&#x20;   WETH: +0.1\
\
Assume the gas fees and initial reporter reward net to near zero. The true price of ETH is $3000, so the manipulator loses $150, the disputer makes $150, and the oracle price settles fairly for the application to use. If the manipulator decided to keep trying to manipulate the price by disputing the honest disputer's report, they would lose an exponentially increasing amount of money that scales with the error in reported price.\
\
The oracle in production has more parameters to tweak, like fees, escalation halt, dispute delay, time mode (block numbers versus block time) and many more, but the simplified version is accurate with respect to how the incentives work.<br>
