Yellow Paper


In the TenderSwap section, the marginal fee function, called the base fee function in the paper, is introduced to calculate the fee. It was then noted that the base fee function presented a problem where splitting the swap into multiple smaller swaps would reduce the total amount of fees paid by a user. This necessitated the formulation of the partitioned fee function.

The partitioned fee function is a reconstruction of the base fee function that represents the lowest possible fee that could be paid by a user, regardless of how the swap is partitioned by the user. The partitioned fee function is found to be

Ο•(x)=Ξ±Β (S+U)(UΞΊ(βˆ’ΞΊΒ u+Uβˆ’u)βˆ’((βˆ’uβˆ’x)ΞΊ+Uβˆ’u)(U+x)ΞΊ)ΞΊΒ (ΞΊ+1)(s+u)LΞΊ\phi(x) = \frac{\alpha Β \left(S+U\right) \left(U^{\kappa} \left(-\kappa Β u+U-u\right)-\left(\left(-u-x\right) \kappa +U-u\right) \left(U+x\right)^{\kappa}\right)}{\kappa Β \left(\kappa +1\right) \left(s+u\right) L^{\kappa}}


  • xx denotes the amount swapped.

  • uu denotes the utilisation of the token that is currently being swapped.

  • UU denotes the sum of the utilisations of all the tokens that are participating in the protocol.

  • ss denotes the supply of the token that is currently being swapped.

  • SS denotes the sum of the supplies of all the tokens that are participating in the protocol.

  • LL denotes the liabilities of the protocol.

  • ΞΊ\kappa, also known as the k-factor in the whitepaper, is a fixed variable that influences the shape of the graph.

  • Ξ±\alpha, also known as the alpha-factor, is a multiplier of the fee. In the absence of a multiplier, Ξ±\alpha may be set to one.

The proof that the mentioned function is indeed the lowest possible fee a user is not trivial. In this page, we describe the problem in more details. We also give an intuition on why the formula is correct. However, the rigorous proofs are longer and more complicated. That is why we have a whole paper dedicated to that, which can be found at the bottom of this page in the Full paper section.


The base fee function and the shortcomings thereof

In the tenderswap section of the whitepaper of Tenderize, it is discussed that when a user wants to use Tenderswap to swap their liquid staking tokens for the underlying tokens, a fee is charged. The system has assets that can be used for this. The amount of assets that the system has if no swaps have happened are called the liabilities. Because the assets used for Tenderswap are limited and using Tenderswap removes from the amount of assets, this operation temporarily makes the system less solvent. To compensate for this, a swap fee is charged. In the whitepaper, a marginal fee function is given. As discussed in the whitepaper, the marginal fee functions takes different properties of the system into account to calculate the amount of fee. In this paper, we refer to the marginal fee function as the base fee function. In the whitepaper, it was motivated that the base fee function had to be

Ο•^(x)=x(u+xu+s)(U+SU+x)(U+xL)ΞΊ\widehat{\phi}(x) = x \left(\frac{u+x}{u+s}\right) \left(\frac{U+S}{U+x}\right) \left(\frac{U+x}{L}\right)^\kappa

Here, the parameters represent different things:

  • xx is the amount swapped.

  • uu is the utilisation of the token that is currently being swapped.

  • UUU is the sum of the utilisations of all the tokens that are participating in the protocol.

  • ss is the supply of the token that is currently being swapped.

  • SS is the sum of the supplies of all the tokens that are participating in the protocol.

  • LLare the liabilities of the protocol.

  • ΞΊ\kappa, also known as the k-factor in the whitepaper, is a fixed variable that influences the shape of the graph. In this paper we use the greek letter ΞΊ\kappa (kappa), as the letter kk will be used often for indexes in sums.

As said earlier, this function has an important shortcoming. If a user comes in and wants to swap an amount of xx, let us say for example x=10x = 10, then he would need to pay a certain amount of fees. However, assume if he would split the amount swapped in two parts such that the two parts sum up his initial swap. For example he first swaps an amount of x1=2x_1 = 2 after which he swaps an amount of x2=8x_2 = 8 such that x1+x2=xx_1 + x_2 = x. It turns out that sum of the amounts of fee he would pay for the two swaps is less than what he would have payed if he were to swap in one go. The full example can be found in the Tenderswap section in the whitepaper. Conceptually, the reason for this problem is that after a swap, the values of the token supply and token utilisation, and hence the total supply and total utilisation, are changed. This paper examines the base fee function and investigates how a user can split and rearrange a swap, and how this affects the total fees paid. We will come up with the partitioned fee function, a formula that represents what the least amount of fee would be payed by a user if he were to split and rearrange the swap, no matter how the splitting and rearrangement are done.

Conventions about the parameters in the system

Before we delve deeper into the problem, we first have to agree on some conventions that are going to be assumed later on in this paper. When calculating fees, several parameters are taken into account. However, these parameters have certain constraints. In this subsection, we discuss what the constraints are and what the motivations are for each of these constraints.

Non active validators

Every validator could potentially have their own LST-token. However, this does not necessarily mean that every validator uses the protocol. We will shortly discuss the total supply and the total utilisation, which are the sums of the supplies and utilisations of the different type of tokens. However, only the validators that use the protocol are taken into account when talking about the total supply and total utilisation.

The liabilities

The liabilities, denoted by LL, is the amount of assets the liquidity providers have made available for the protocol to use in Tenderswap. If no liquidity has ever been provided, then Tenderswap can not be used, as there is no liquidity available for the users that want to swap, which theoretically is equivalent to Tenderswap not even existing. The system only makes sense if liquidity has been provided. This motivates us to make the convention that it always holds that L>0L>0.

The token utilisation and the total utilisation

When a user swaps LSTs for the underlying token, a part of the assets, which was provided by the liquidity providers, becomes temporarily unavailable. It becomes available again when someone buys the unlock NFT or if a relayer eventually processes the unlock when it has reached it's maturity date. However, until then, the assets are unavailable. We then say that an LST is utilising the liquidity in Tenderswap. The amount of assets that are not available, because an LST is utilising them, is called a token's utilisation and is denoted by uu. The sum of the utilisation of all the tokens that are using the protocol is denoted by UU. Because it is not possible for a token to utilise in a negative way, as this would mean that the system is getting more available assets when a swap happens, we always assume that uβ‰₯0u \geq 0. However, this also implicates that Uβ‰₯0U \geq 0, as UU is the sum of non-negative terms. However, there is one final constriction on UU. There can never be more total utilisation than the amount of assets the liquidity providers have made available in the first place, as otherwise a swapper would need to use non-existing assets to complete their swap. This hence means that U≀LU \leq L. We could abbreviate all of this by stating that 0≀u≀U≀L0 \leq u \leq U \leq L.

The token supply and total supply

Every LST has a finite amount circulating. An LST is either using the system or not. If it is not using the system, we disregard it, until it possibly joins the system. As there can not be a negative amount of token circulating, we know for a fact that it always holds that sβ‰₯0s \geq 0. However, practically, if someone wants to swap LSTs, it also means that there were tokens circulating in the first place. If s=0s = 0, then no swap could have happened. That is why we go a step further and always assume that s>0s > 0. Again, as SS is the sum of the circulating supplies of the LSTs that are using the system, it also holds that Sβ‰₯sS \geq s.

Fee amount

When a user comes in to swap an amount, this amount is commonly represented by the variable xx. The amount xx is always assumed to be between 00 and the minimum of Lβˆ’UL-U and ss, excluding 00. Or more formally, it always holds that x∈(0,min⁑{s,Lβˆ’U}]x \in (0, \min\{s, L-U\}]. The motivation behind the lower bound is that practically, it does not make sense to swap an amount of 00, as this would be equivalent to no swap having happened at all. The upper bound is bounded by the minimum of ss, the token supply, and Lβˆ’UL-U, the liabilities minus the total utilisation. The reason why xx can never be bigger than ss was just discussed. To understand why xx can never be bigger than Lβˆ’UL - U, we first have to understand what Lβˆ’UL-U means in practice. Remember, LL denotes the amount of assets made available by the liquidity providers and UU denotes the amount of those assets that are being used. This means that Lβˆ’UL - U represent the amount of assets that are yet available for the swaps. If x>Lβˆ’Ux > L -U, this would mean that the user is swapping more than there is available. Hence, it always holds that x≀Lβˆ’Ux \leq L-U.

Kappa factor

The kappa factor, also known as the k-value or k-factor, is a fixed and predetermined parameter in the system that might vary from LST to LST. The kappa factor changes the shape of the graph in a specific way. If plenty of assets are available, the protocol should not be asking for a lot of fees. However, if the system is starting to get a high utilisation or if there were not a lot of assets made available by the liquidity providers in the first place, we want the fees to become higher. More simply said, the higher the utilisation rate or in other words, the higher UL\frac{U}{L}, the more harsh the fees should become. Conceptually, if the system is solvent, we want the fee function to be behaving like an almost flat function. However, at a certain point, we want the fees to grow rapidly. The kappa factor influences this. A low kappa factor means that the fee starts to grow rapidly early on. However, the rate of growth does not change a lot. In the most extreme case, when ΞΊ=1\kappa = 1, then the function is even linear. A high kappa factor means that the fee function first almost behaves like a flat function. However, at a certain point, the fee grows very rapidly, even more rapidly than if the function were to have a low kappa factor. Because letting ΞΊ<1\kappa<1 makes the fee grow less and less the more is swapped, it does not make sense to let ΞΊ<1\kappa<1. This motivates us to always assume that ΞΊβ‰₯1\kappa\geq1

Alpha factor

The alpha factor will only appear again at the end of this paper. We will eventually see that the partitioned fee function can become significantly less than the base fee function. If we somehow want to make this effect less severe, we can multiply the final fee result by a factor Ξ±β‰₯1\alpha \geq 1. However, if this is not needed, one can just assume that Ξ±=1\alpha = 1. Furthermore, as Ξ±\alpha does not dominate the theorems and can be easily added afterwards, we will not be discussing Ξ±\alpha until the end.

Fee partitioning

We are now going to focus more in-depth on what the problem with the base fee function is and how we can formally address it. First, let us assume someone comes in and wants to swap 1010 tokens. As the parameters will change after the swap, we are going to subscript the parameters that change after the swap, which are u,s,Uu, s, U and SS. We thus obtain Ο•1^(10)=10(u1+10u1+s1)(U1+S1U1+10)(U1+10L)ΞΊ\widehat{\phi_1}(10) = 10 \left(\frac{u_1+10}{u_1 + s_1}\right) \left(\frac{U_1 + S_1}{U_1+10}\right)\left(\frac{U_1+10}{L}\right)^\kappa. However, let us assume that the user wants to pay fewer fees and decides to split the swap into two parts. First, he swaps an amount of 22. The second time, he swaps an amount of 88. The first swap, he pays for fees: Ο•1^(2)=2(u1+2u1+s1)(U1+S1U1+2)(U1+2L)ΞΊ\widehat{\phi_1}(2) = 2 \left(\frac{u_1+2}{u_1 + s_1}\right) \left(\frac{U_1 + S_1}{U_1+2}\right)\left(\frac{U_1+2}{L}\right)^\kappa Now an important fact comes up. When the user wants to swap an amount of 88 afterward, the function is no longer the same. This is also why we subscripted the Ο•^\hat\phi function. When the user swaps an amount of 22, it results in changes to some parameters. Consequently, the fee paid for the second swap is calculated using a different function: Ο•2^(8)=8(u2+8u2+s2)(U2+S2U2+8)(U2+8L)ΞΊ\widehat{\phi_2}(8) = 8 \left(\frac{u_2+8}{u_2 + s_2}\right) \left(\frac{U_2 + S_2}{U_2+8}\right)\left(\frac{U_2+8}{L}\right)^\kappa It would be beneficial to eliminate u2,s2,U2u_2, s_2, U_2, and S2S_2 so we can more easily investigate the issue. Let us examine each one of these in turn:

  1. After swapping an amount of 22, the LST utilises an amount of 22 more. This means that u2=u1+2u_2 = u_1 + 2.

  2. As UU is the sum of the utilisation of every token, it holds that U2=U1+2U_2 = U_1 + 2.

  3. When the user swapped an amount of 22, an amount of 22 vanishes from the circulating supply. That is, s2=s1βˆ’2s_2 = s_1 - 2.

  4. As SS is the sum of all the circulating supply of the token that are using the protocol, it holds that S2=S1βˆ’2S_2 = S_1 - 2.

We can hence write the second swap as Ο•2^(8)=8(u1+2+8u1+2+s1βˆ’2)(U1+2+S1βˆ’2U1+2+8)(U1+2+8L)ΞΊ\widehat{\phi_2}(8) = 8 \left(\frac{u_1 + 2+8}{u_1 \cancel{+2} + s_1 \cancel{- 2}}\right) \left(\frac{U_1 \cancel{+2} + S_1 \cancel{-2}}{U_1+2+8}\right)\left(\frac{U_1+2+8}{L}\right)^\kappa Let us formalize this concept. Let there be a user that first wants to swap an amount of x>0x > 0. Instead, he decides to try to reduce the fees and splits up the amount xx in x1,x2,…,xn>0∍x1+x2+β‹―+xn=xx_1, x_2, \dots, x_n > 0 \backepsilon x_1 + x_2 + \dots + x_n = x. The amount of fee that is paid in the second case can then be written as

Ο•1^(x1)+Ο•2^(x2)Β +β‹―+Ο•n^(xn)=x1(u1+x1u1+s1)(U1+S1U1+x1)(U1+x1L)ΞΊ+x2(u2+x2u2+s2)(U2+S2U2+x2)(U2+x2L)ΞΊ+…+xn(un+xnun+sn)(Un+SnUn+xn)(Un+xnL)ΞΊ=x1(u1+x1u1+s1)(U1+S1U1+x1)(U1+x1L)ΞΊ+x2(u1+x1+x2u1+s1)(U1+S1U1+x1+x2)(U1+x1+x2L)ΞΊ+…+xn(u1+x1+x2+β‹―+xnu1+s1)(U1+S1U1+x1+x2+β‹―+xn)(U1+x1+x2+β‹―+xnL)ΞΊ=βˆ‘i=1nxi(u1+βˆ‘j=1ixju1+s1)(U1+S1U1+βˆ‘j=1ixj)(U1+βˆ‘j=1ixjL)ΞΊ \begin{align*} &\widehat{\phi_1}(x_1) + \widehat{\phi_2}(x_2) Β + \dots + \widehat{\phi_n}(x_n) \\ =&x_1 \left(\frac{u_1+x_1}{u_1 + s_1}\right) \left(\frac{U_1 + S_1}{U_1+x_1}\right)\left(\frac{U_1+x_1}{L}\right)^\kappa \\ +& x_2 \left(\frac{u_2+x_2}{u_2 + s_2}\right) \left(\frac{U_2 + S_2}{U_2+x_2}\right)\left(\frac{U_2+x_2}{L}\right)^\kappa\\ +&\dots\\ +& x_n \left(\frac{u_n+x_n}{u_n + s_n}\right) \left(\frac{U_n + S_n}{U_n+x_n}\right)\left(\frac{U_n+x_n}{L}\right)^\kappa\\ =&x_1 \left(\frac{u_1+x_1}{u_1 + s_1}\right) \left(\frac{U_1 + S_1}{U_1+x_1}\right)\left(\frac{U_1+x_1}{L}\right)^\kappa \\ +& x_2 \left(\frac{u_1 + x_1+x_2}{u_1 + s_1}\right) \left(\frac{U_1 + S_1}{U_1 + x_1+x_2}\right)\left(\frac{U_1+x_1+x_2}{L}\right)^\kappa\\ +&\dots\\ +& x_n \left(\frac{u_1 + x_1 + x_2 + \dots+x_n}{u_1+ s_1}\right) \left(\frac{U_1+ S_1}{U_1 + x_1 + x_2 + \dots+x_n}\right)\left(\frac{U_1+x_1+x_2+\dots+x_n}{L}\right)^\kappa\\ =&\sum_{i=1}^n x_i \left(\frac{u_1 + \sum_{j=1}^i x_j}{u_1+ s_1}\right) \left(\frac{U_1+ S_1}{U_1+ \sum_{j=1}^i x_j}\right)\left(\frac{U_1+\sum_{j=1}^i x_j}{L}\right)^\kappa\\ \end{align*}

This equation could be cumbersome to work with. That is why we instead use a slightly different approach. Conceptually, we were looking at the ordered set x1,x2,…,xn∍x1+x2+β‹―+xn=x{x_1, x_2, \dots, x_n} \backepsilon x_1 + x_2 + \dots + x_n = x and performing the base fee function on every element with the updated parameters. What we will do now is consider the cumulative values. To illustrate, we define PP as x1,x1+x2,…,x1+x2+…,xn{x_1, x_1 + x_2, \dots, x_1 + x_2 + \dots, x_n}. We first note that xi=piβˆ’piβˆ’1x_i = p_i - p_{i-1}. Furthermore,

Ο•1^(x1)+Ο•2^(x2)Β +β‹―+Ο•n^(xn)=βˆ‘i=1nxi(u1+βˆ‘j=1ixju1+s1)(U1+S1U1+βˆ‘j=1ixj)(U1+βˆ‘j=1ixjL)ΞΊ=βˆ‘i=1nxi(u1+piu1+s1)(U1+S1U1+pi)(U1+piL)ΞΊ=βˆ‘i=1n(u1+piu1+s1)(U1+S1U1+pi)(U1+piL)ΞΊβ‹…(piβˆ’piβˆ’1)Β \begin{align*} &\widehat{\phi_1}(x_1) + \widehat{\phi_2}(x_2) Β + \dots + \widehat{\phi_n}(x_n) \\ =&\sum_{i=1}^n x_i \left(\frac{u_1 + \sum_{j=1}^i x_j}{u_1+ s_1}\right) \left(\frac{U_1+ S_1}{U_1+ \sum_{j=1}^i x_j}\right)\left(\frac{U_1+\sum_{j=1}^i x_j}{L}\right)^\kappa\\ =&\sum_{i=1}^n x_i \left(\frac{u_1 + p_i}{u_1+ s_1}\right) \left(\frac{U_1+ S_1}{U_1+ p_i}\right)\left(\frac{U_1+p_i}{L}\right)^\kappa \\ =&\sum_{i=1}^n \left(\frac{u_1 + p_i}{u_1+ s_1}\right) \left(\frac{U_1+ S_1}{U_1+ p_i}\right)\left(\frac{U_1+p_i}{L}\right)^\kappa \cdot (p_i - p_{i-1})Β  \end{align*}

This knowledge will be used shortly in the next subsection.

The partitioned fee function and the temporary fee function

As previously discussed, when a user partitions a swap amount xx into the amounts x1,x2,…,xnx_1, x_2, \dots, x_n, we can also use the numbers x1,x1+x2,…,x1+x2+β‹―+xnx_1, x_1 + x_2, \dots, x_1 + x_2 + \dots + x_n. As in the first term, we multiply by (x1βˆ’(x1βˆ’1))(x_1 - (x_{1-1})), and x0x_0 is not defined, we have a problem here. However, based on the earlier formula, it should be noted that x1βˆ’x0=x1x_1 - x_0 = x_1 which implies that x0=0x_0 = 0. Hence, the above number can also be seen as the interval [0,x][0, x] being cut into pieces. This brings us to the first definition of the paper:

Definition 1 (Swap partition). Let x>0x > 0 be given. A set PP is called a swap partition if it is in the form P={p0,p1,p2,…,pnβˆ’1,pn}={0,p1,p2,…,pnβˆ’1,x}P = \{p_0, p_1, p_2, \dots, p_{n-1}, p_n\} = \{0, p_1, p_2, \dots, p_{n-1}, x\} where i>jβ€…β€ŠβŸΉβ€…β€Špi>pji > j \implies p_i > p_j. The set of all possible partitions for a given x>0x>0 is denoted by Px\mathscr{P}_x

Because, as we have seen, u,s,Uu, s, U and SS do not change using the new approach to calculating the fee when being partitioned, we can leave the subscript away. Given a swap of an amount of xx and a possible partition of the swap P∈PxP \in \mathscr{P}_x, we can thus calculate the total amount of fee with the partition function Ξ¦\Phi defined as Ξ¦(P)=βˆ‘i=1#Pβˆ’1(u+piu+s)(U+SU+pi)(U+piL)ΞΊβ‹…(piβˆ’piβˆ’1)\Phi(P) = \sum_{i=1}^{\#P-1} \left(\frac{u + p_i}{u+ s}\right) \left(\frac{U+ S}{U+ p_i}\right)\left(\frac{U+p_i}{L}\right)^\kappa \cdot (p_i - p_{i-1})

It will turn out that we will encounter this form a lot during this paper. That is why we introduce the temporary fee function Ο„\tau, which represent the terms, except for the (piβˆ’piβˆ’1)(p_i - p_{i-1}) term.

Definition 2 (Temporary fee function). The temporary fee function is defined as

Ο„(x)=Β {(u+xu+s)(U+S)(U+x)ΞΊβˆ’1LΞΊΒ ifΒ ΞΊ>1(u+xu+s)(U+S)1LΞΊΒ ifΒ ΞΊ=1\begin{align*} \tau(x) =Β  \begin{cases} \left(\frac{u + x}{u+ s}\right) (U+S)\frac{(U+x)^{\kappa - 1}}{L^\kappa} &\text{ if } \kappa > 1\\ \left(\frac{u + x}{u+ s}\right) (U+S)\frac{1}{L^\kappa} & \text { if } \kappa = 1 \end{cases} \end{align*}

The reason for providing a different definition when ΞΊ=1\kappa = 1 may not be immediately apparent. However, later in the paper, we will encounter cases where we need to calculate Ο„(0)\tau(0). If U=0U = 0, we get a 000^0 term, which is problematic. However, if U>0U>0, then we get a (U+x)0=1(U+x)^0 =1 term. Hence, giving a slightly different definition for when ΞΊ=1\kappa = 1 gives the same result but removes the propblems. Now, we can write the partition function very briefly as Ξ¦(P)=βˆ‘i=1#Pβˆ’1Ο„(pi)β‹…(piβˆ’piβˆ’1)\Phi(P) = \sum_{i=1}^{\#P-1} \tau(p_i) \cdot (p_i - p_{i-1}) and we are finally able to define what the partitioned fee function must be. Conceptually, our goal is for the formula to return the minimum fee a user would pay for a swap, regardless of how it is split and rearranged. Or in other words, given an amount of xx, the function should return the greatest lower bound, or infimum, of all the possible Ξ¦\Phi values of the partitions that adhere to Px\mathscr{P}_x.

Definition 3 (The partitioned fee function). Let 0<x≀min⁑{s,Lβˆ’U}0 < x \leq \min\{s, L-U\} be given. The partitioned fee function is defined as Ο•(x)=inf⁑{Ξ¦(P)∍P∈Px}\phi(x) = \inf\left\{\Phi(P) \backepsilon P \in \mathscr{P}_x\right\}

This paper is dedicated to finding a concrete formula for Ο•\phi and proving why this formula is, in fact, the greatest lower bound.

Plan of approach

We will discuss our approach to this problem. This subsection provides an overview of the lemmas, propositions, and theorems we will prove in the paper, and how they contribute to deriving a concrete formula for Ο•\phi.

Fee refinements

First, we will be investigating some important properties about the partitioned fee functions. Two important properties will be proven in lemmas:

  1. Fees are always strictly positive, no matter how a fee is partitioned. This concept is proven in the positive fee lemma.

  2. When a user refines the partition he uses to swap, the fees will always become lower. That is, if a user swaps an amount of xx and uses partitions P,Q∈PxP, Q \in \mathscr{P}_x such that PβŠ‚QP \subset Q, then Ξ¦(P)<Ξ¦(Q)\Phi(P) < \Phi(Q).

These properties are important to know. Firstly, because it will be proven that refining a partition will always lower the fee, we know that we can never point to a concrete partition that would give us the value of the partitioned fee function immediately. Or in other words βˆƒΜΈP∈Px∍Φ(P)=Ο•(x)\not \exists P \in \mathscr{P}_x \backepsilon\Phi(P) = \phi(x). This, however, raises the question of whether we can refine a partition indefinitely until we have a fee of zero or even negative. Fortunately, the positive fee lemma tells us that this will never be the case and we will always be left with a strictly positive fee.

Power partitions

This subsection introduces the concept of index shifting and power partitions. Power partitions are a special type of partitions. Conceptually, if one has an interval [0,x][0, x], and keeps splitting the intervals in half, we get power partitions. They are often denoted as XxnβŠ‚PxX^n_x \subset \mathscr{P}_x, such that

Xx0={0,x}Xx1={0,121x,x}Xx2={0,122x,222x,322x,x}…Xxn={0,12nx,22nx,…,2nβˆ’12nx,x} \begin{align*} X^0_x &= \{0, x\}\\ X^1_x &= \left\{0, \frac{1}{2^1} x, x\right\} \\ X^2_x &= \left\{0, \frac{1}{2^2} x,\frac{2}{2^2} x, \frac{3}{2^2} x,x\right\} \\ \dots&\\ X^n_x &= \left\{0, \frac{1}{2^n} x, \frac{2}{2^n} x, \dots, \frac{2^n-1}{2^n} x, x\right\} \end{align*}

It would be beneficial to investigate whether Ο•(x)=lim⁑nβ†’βˆžΞ¦(Xxn)\phi(x) = \lim_{n\to\infty} \Phi(X^n_x). However, how do we know this? Maybe we can find a partition P∈Px∍Φ(P)<lim⁑nβ†’βˆžΞ¦(Xxn)P \in \mathscr{P}_x \backepsilon \Phi(P) < \lim_{n\to\infty} \Phi(X^n_x). Here, one of the most important theorem in the paper, the power partition theorem, states that no matter which partition we have, we can find a power partition that results in a lower fee. Or in other words βˆ€P∈PxβˆƒN∍n>Nβ€…β€ŠβŸΉβ€…β€ŠΞ¦(Xxn)<Ξ¦(P)\forall P \in \mathscr{P}_x \exists N \backepsilon n > N \implies \Phi(X^n_x) < \Phi(P). This theorem is actually far from trivial. The reason is that if one would for example come with a partition P={0,13x,23x,x}P = \{0, \frac{1}{3} x, \frac{2}{3}x, x\}, then now matter how much we refine the power partitions, they will never overlap. Fortunately, before proving this theorem, we prove the lemma that states that shifting elements in the partition is continuous. In a simplified form, it means that although we can never make PP a subset of some power set, we can shift their elements a little bit such that they do become elements of some power set. The lemma than states that although the value of Ξ¦\Phi then changes, it changes in a continuous and thus predictable way, a fact that we will use in the power partition theorem.

Fundamental fee theorems

In the last part of the paper, the results are showcased. Again, we will simplify things quite a bit here, but we will have seen by this point that Ο„\tau is a continuous function and also integrable. This means that for any partition P∈PxP \in \mathscr{P}_x, when we have a term Ο„(pi)β‹…(piβˆ’piβˆ’1)\tau(p_i) \cdot (p_i - p{i-1}), the Lagrange mean value theorem states that we can find a ti∈[piβˆ’1,pi]t_i\in [p_{i-1}, p_i] such that Ο„(ti)β‹…(piβˆ’piβˆ’1)=T(pi)βˆ’T(piβˆ’1)\tau(t_i) \cdot (p_i - p_{i-1}) = T(p_i) - T(p_{i-1}), where TT is the antiderivative of Ο„\tau. Because of the increasing nature of Ο„\tau, another fact we would have encountered by now, we know that Ο„(piβˆ’1)β‹…(piβˆ’piβˆ’1)≀τ(ti)β‹…(piβˆ’piβˆ’1)≀τ(pi)β‹…(piβˆ’piβˆ’1)\tau(p_{i-1}) \cdot (p_{i} - p_{i-1}) \leq \tau(t_i) \cdot (p_i - p_{i-1}) \leq \tau(p_i) \cdot (p_i - p_{i-1}). If we take the power partitions, we will see that conceptually taking the limit X=lim⁑nβ†’βˆžXxnX = \lim_{n \to \infty} X^n_x will result in βˆ‘i=12nΟ„(Xiβˆ’1)β‹…(Xiβˆ’Xiβˆ’1)=βˆ‘i=12nΟ„(Xi)β‹…(Xiβˆ’Xiβˆ’1)\sum_{i=1}^{2^n} \tau(X_{i-1}) \cdot (X_{i}-X_{i-1}) = \sum_{i=1}^{2^n} \tau(X_{i}) \cdot (X_{i}-X_{i-1}). This conceptually means that the middle term Ο„(ti)β‹…(piβˆ’piβˆ’1)\tau(t_i) \cdot (p_i - p_{i-1}) gets squeezed between those two. However, we see that

βˆ‘i=1#Pβˆ’1Ο„(piβˆ’1)β‹…(piβˆ’piβˆ’1)β‰€βˆ‘i=1#Pβˆ’1Ο„(ti)β‹…(piβˆ’piβˆ’1)=βˆ‘i=1nT(pi)βˆ’T(piβˆ’1)=βˆ’T(0)+T(p1)βˆ’T(p1)+β‹―βˆ’T(p#Pβˆ’1)+T(p#Pβˆ’1)+T(x)=T(x)βˆ’T(0)=∫0xΟ„(x)Β dxβ‰€βˆ‘i=1#Pβˆ’1Ο„(pi)β‹…(piβˆ’piβˆ’1)\begin{align*} \sum_{i=1}^{\#P-1} \tau(p_{i-1}) \cdot (p_i - p_{i-1})&\leq\sum_{i=1}^{\#P-1} \tau(t_i) \cdot (p_i - p_{i-1}) \\&= \sum_{i=1}^n T(p_i) - T(p_{i-1})\\ &= -T(0) + T(p_1) - T(p_1) + \dots -T(p_{\#P-1}) + T(p_{\#P-1}) + T(x)\\ &= T(x) - T(0) = \int_0^x\tau(x) \text{ d} x \leq \sum_{i=1}^{\#P-1} \tau(p_i) \cdot (p_i - p_{i-1}) \end{align*}

As the first and last term are equal, and the last term is taken with the limit of the power set, of which the Ξ¦\Phi value is smaller than the Ξ¦\Phi value of any partition, it is equal to the partitioned fee function. That is the sketch of the proof that the partitioned fee function is equal to Ο•(x)=∫0xΟ„(x)Β dx\phi(x) = \int_0^x \tau(x) \text{ d} x

Fee concat theorem and alpha factor

The fee concat theorem states that if we were to partition a swap and use the partitioned fee function, than the sum of the fees would be equal to the fee that would be paid if the swap were to happen in one go. That was the whole purpose of this paper. The proof is quite simple, as it just involves showing that splitting a swap somewhere and performing the partitioned fee function on this new partition gives the same result. More complex refinements can then be achieved by repeatedly applying this operation. Finally, we end the paper with the remark that if the partitioned fee function returns too small values, then we can multiply the result easily with the Ξ±β‰₯1\alpha \geq 1 factor.

Full paper

If one wishes to read the rigorous proofs on the correctness of the partition fee function, they can read the full paper about it, which can be found here:

Last updated