There is no commentSelect some text and then click Comment, or simply add a comment to this page from below to start a discussion.
Mathematical Principle of TWAMM
Definition
Assume that TWAMM requires blocks to execute a large virtual transaction, and that the pool selling sells at a rate of per block, while the pool selling sells at a rate of per block. Thus, the total amount of sold during the whole period is and the total amount of sold is .
Also, we note the initial reserves and for this time period in embeded AMM as and , respectively.
According to the design of TWAMM, large orders are traded with blocks, each block sells to get , or sells to get , while AMM updates the values of and , the whole process transactions in total.
It is worth noting that each block transaction of AMM always follows a constant product market making.
First, after executing the transaction for the block, we assume that the and values of AMM are and , respectively.
Next, the transaction for block is executed, with and feeding and to AMM, respectively. Then,
Since and are very small and the exchange follow a constant product market maker, we can obtain that,
Simplifying,
After getting the values of and , we can further obtain the and values and after the transaction of blocks.
By observation, we find that , which exactly meets the prerequisite requirement of AMM for making a market by following a constant product.
Let , is a constant.
Fractional Linear Recursion
First find the general formula for and obtain the value of , and the same for .
Let , then
The fractional linear recursive expression for is as follows:
Solution
First, if and , then
And,
The calculation yields,
When and , the discussion is the same as above.
If both and , for general fractional linear recursion, we can use the Fixed-Point Iteration method to solve the problem.
According to , replace and solve for . is exactly the two fixed points of the above fractional linear recursive expression.
Further calculations,
Dividing the two expressions above,
According to the geometric progression we get,
Similarly,
Limit Value
The basic principle of TWAMM is to decompose long term large orders into infinitely many infinitely small virtual orders, i.e. can be taken to infinity, so the limit value of can be obtained.
Where,
Similarly,
An important point is that,, , and must larger than 0:
Finally, after a simple verification , the constant product of AMM is still satisfied.
Assume the trading rate of and is uniform according to time,
Let , then,
Where,
If we use and instead of and , that is , the trading rate of and is a function of time.
Let , then,
Let ,
If is constant, i.e.the trading rate of and is synchronized.
Where,
At this point, we have completed a rigorous argument and explanation of the mathematical principles of TWAMM and obtained exactly the same conclusion as in the article [The Time-Weighted Average Market Maker - TWAMM].