Conversion fee in Uniswap V2

    In Uniswap V2, the default is to charge a 0.3% handling fee, which is calculated based on the ΔX deposited in the resource pool, that is, 0.3%*ΔX Token X is first deducted.
    First define the following commonly used conversion formulas, as shown in Figure (1).

Common conversion formula

Figure (1) Commonly used calculation formulas in Uniswap V2

Figure (2) Proof and inference

When the agreement draw becomes Φ=1/6

    By the Uniswap white paper shows, from among the fee is 0.3%, in proportion to the development team to extract φ as a fee agreement, the remaining proportion returned to the LP. Note that the return is not the Token X and Token Y that actually participated in the transaction, but the LP Token (that is, Uniswap's platform currency UNI), and Uniswap does not return the UNI immediately, but when the LP user removes the liquidity or directly withdraws the UNI UNI will be returned to the LP user only when the time comes.

    Case 1: HelloSwap is an independent Uniswap exchange. It is not connected to other exchanges. The transaction fee ratio of this exchange is 0.3.%, 0.25% is returned to LP, and the remaining 0.05% is given to the development team, that is, the agreement percentage ϕ= 1/6 , there is a resource pool for the LAM-MUT token pair. Assuming that the holder of the resource pool has only one user name named Tom, as shown in Figure (3), that is, the proportion of Tom's possession of the LAM-MUT resource pool is 100%, the ratio of his initial liquidity addition is LAM:MUT = 4000:1000, and he buys MUT by selling 100LAM in 2 times. When Tom removes 100% of the liquidity of LAM-MUT, he will return to Tom’s LP What is the handling fee (number of UNI)?


Figure (3) LP handling fee when Φ=1/6

When the agreement draw becomes Φ=1/2

    Case 2: ByeSwap is an independent Uniswap exchange, which is not connected to other exchanges. The transaction fee ratio of this exchange is 0.3.%, 0.15% is returned to LP, and the remaining 0.15% is given to the development team, that is, the agreement fee ϕ= 1/2 , there is a resource pool for the LAM-MUT token pair. Assuming that the holder of the resource pool has only one user named Jerry, as shown in Figure (4), that is, the proportion of Jerry occupies the LAM-MUT resource pool is 100%, the ratio of his initial liquidity addition is LAM:MUT = 4000:1000, and he buys MUT by selling 100LAM in 2 times. When Jerry removes 100% of the liquidity of LAM-MUT, he will return it to Jerry’s LP What is the handling fee (number of UNI)?



Figure (4) LP handling fee when Φ=1/2

references

1 Uniswap V2 white paper

https://uniswap.org/whitepaper.pdf

2 Uniswap calculation formula

https://github.com/runtimeverification/verified-smart-contracts/blob/uniswap/uniswap/x-y-k.pdf

Guess you like

Origin blog.csdn.net/sanqima/article/details/109667469
v2