# Yellow Paper

## Abstract

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

where

$x$ denotes the amount swapped.

$u$ denotes the utilisation of the token that is currently being swapped.

$U$ denotes the sum of the utilisations of all the tokens that are participating in the protocol.

$s$ denotes the supply of the token that is currently being swapped.

$S$ denotes the sum of the supplies of all the tokens that are participating in the protocol.

$L$ 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.

## Introduction

### 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

Here, the parameters represent different things:

$x$ is the amount swapped.

$u$ is the utilisation of the token that is currently being swapped.

$U$U is the sum of the utilisations of all the tokens that are participating in the protocol.

$s$ is the supply of the token that is currently being swapped.

$S$ is the sum of the supplies of all the tokens that are participating in the protocol.

$L$are 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 $k$ 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 $x$, let us say for example $x = 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 $x_1 = 2$ after which he swaps an amount of $x_2 = 8$ such that $x_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 $L$, 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>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 $u$. The sum of the utilisation of all the tokens that are using the protocol is denoted by $U$. 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 \geq 0$. However, this also implicates that $U \geq 0$, as $U$ is the sum of non-negative terms. However, there is one final constriction on $U$. 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 \leq L$. We could abbreviate all of this by stating that $0 \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 \geq 0$. However, practically, if someone wants to swap LSTs, it also means that there were tokens circulating in the first place. If $s = 0$, then no swap could have happened. That is why we go a step further and always assume that $s > 0$. Again, as $S$ is the sum of the circulating supplies of the LSTs that are using the system, it also holds that $S \geq s$.

#### Fee amount

When a user comes in to swap an amount, this amount is commonly represented by the variable $x$. The amount $x$ is always assumed to be between $0$ and the minimum of $L-U$ and $s$, excluding $0$. Or more formally, it always holds that $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 $0$, as this would be equivalent to no swap having happened at all. The upper bound is bounded by the minimum of $s$, the token supply, and $L-U$, the liabilities minus the total utilisation. The reason why $x$ can never be bigger than $s$ was just discussed. To understand why $x$ can never be bigger than $L - U$, we first have to understand what $L-U$ means in practice. Remember, $L$ denotes the amount of assets made available by the liquidity providers and $U$ denotes the amount of those assets that are being used. This means that $L - U$ represent the amount of assets that are yet available for the swaps. If $x > L -U$, this would mean that the user is swapping more than there is available. Hence, it always holds that $x \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 $\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 $\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 $\kappa<1$ makes the fee grow less and less the more is swapped, it does not make sense to let $\kappa<1$. This motivates us to always assume that $\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 $\alpha \geq 1$. However, if this is not needed, one can just assume that $\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 $10$ 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, U$ and $S$. We thus obtain $\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 $2$. The second time, he swaps an amount of $8$. The first swap, he pays for fees: $\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 $8$ 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 $2$, it results in changes to some parameters. Consequently, the fee paid for the second swap is calculated using a different function: $\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 $u_2, s_2, U_2$, and $S_2$ so we can more easily investigate the issue. Let us examine each one of these in turn:

After swapping an amount of $2$, the LST utilises an amount of $2$ more. This means that $u_2 = u_1 + 2$.

As $U$ is the sum of the utilisation of every token, it holds that $U_2 = U_1 + 2$.

When the user swapped an amount of $2$, an amount of $2$ vanishes from the circulating supply. That is, $s_2 = s_1 - 2$.

As $S$ is the sum of all the circulating supply of the token that are using the protocol, it holds that $S_2 = S_1 - 2$.

We can hence write the second swap as $\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 > 0$. Instead, he decides to try to reduce the fees and splits up the amount $x$ in $x_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

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 ${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 $P$ as ${x_1, x_1 + x_2, \dots, x_1 + x_2 + \dots, x_n}$. We first note that $x_i = p_i - p_{i-1}$. Furthermore,

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 $x$ into the amounts $x_1, x_2, \dots, x_n$, we can also use the numbers $x_1, x_1 + x_2, \dots, x_1 + x_2 + \dots + x_n$. As in the first term, we multiply by $(x_1 - (x_{1-1}))$, and $x_0$ is not defined, we have a problem here. However, based on the earlier formula, it should be noted that $x_1 - x_0 = x_1$ which implies that $x_0 = 0$. Hence, the above number can also be seen as the interval $[0, x]$ being cut into pieces. This brings us to the first definition of the paper:

**Definition 1** (Swap partition). Let $x > 0$ be given. A set $P$ is called a swap partition if it is in the form $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 \implies p_i > p_j$. The set of all possible partitions for a given $x>0$ is denoted by $\mathscr{P}_x$

Because, as we have seen, $u, s, U$ and $S$ 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 $x$ and a possible partition of the swap $P \in \mathscr{P}_x$, we can thus calculate the total amount of fee with the partition function $\Phi$ defined as $\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 $(p_i - p_{i-1})$ term.

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

The reason for providing a different definition when $\kappa = 1$ may not be immediately apparent. However, later in the paper, we will encounter cases where we need to calculate $\tau(0)$. If $U = 0$, we get a $0^0$ term, which is problematic. However, if $U>0$, then we get a $(U+x)^0 =1$ term. Hence, giving a slightly different definition for when $\kappa = 1$ gives the same result but removes the propblems. Now, we can write the partition function very briefly as $\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 $x$, the function should return the greatest lower bound, or infimum, of all the possible $\Phi$ values of the partitions that adhere to $\mathscr{P}_x$.

**Definition 3** (The partitioned fee function). Let $0 < x \leq \min\{s, L-U\}$ be given. The partitioned fee function is defined as $\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:

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

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 $x$ and uses partitions $P, Q \in \mathscr{P}_x$ such that $P \subset Q$, then $\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 $\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]$, and keeps splitting the intervals in half, we get power partitions. They are often denoted as $X^n_x \subset \mathscr{P}_x$, such that

It would be beneficial to investigate whether $\phi(x) = \lim_{n\to\infty} \Phi(X^n_x)$. However, how do we know this? Maybe we can find a partition $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 $\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, \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 $P$ 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 \in \mathscr{P}_x$, when we have a term* *$\tau(p_i) \cdot (p_i - p{i-1})$, the Lagrange mean value theorem states that we can find a $t_i\in [p_{i-1}, p_i]$ such that $\tau(t_i) \cdot (p_i - p_{i-1}) = T(p_i) - T(p_{i-1})$, where $T$ is the antiderivative of $\tau$. Because of the increasing nature of $\tau$, another fact we would have encountered by now, we know that $\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 \to \infty} X^n_x$ will result in $\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 $\tau(t_i) \cdot (p_i - p_{i-1})$ gets squeezed between those two. However, we see that

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 $\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 $\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