# Liquidity Provision

In a handful of the YOLO Games titles, players play against a **liquidity pool** (or LP).

The liquidity pool is made up of funds contributed by users, who are incentivized to do so due to the LPβs fee. Naturally, this requires a system that favors liquidity providers over time.

To build this system, we consider the LP as just another player to compute risk sizes for optimal growth. We then restrict the funds playable by the player/counterparty to the aforementioned risk sizes.

The best way to do this is using the **Kelly criterion**.

The Kelly criterion is a formula for maximizing the expected growth of funds based on probabilistic outcomes.

To do so, it uses an equation that considers each player, their odds, and their expected value in the specific game.

**A note before we proceed:** using the maximum risk permitted by the Kelly criterion does create a risk of the LP going to zero. Of course, we canβt have that happening β so weβll take a fraction of the Kelly criterion to reduce the threat of a severe drawdown. Granted, this will also limit the growth rate.

## The Kelly Fractionβ

The Kelly fraction gives us the optimal fraction of funds that should be risked per game in order to achieve the maximum expected growth rate.

To find it, we maximize the expected value of the logarithm of wealth, or, equivalently, we maximize the expected geometric growth rate.

Traditionally, players have used this method to calculate their risk threshold for a given game. But, since we're considering the LP to be a player, we can just use it inversely.

### Binary-Outcome Gamesβ

Weβll start with the Kelly fraction for binary-outcome games to create a model for the LPβs growth rate. Ready for some crazy mathematical shit?

Alright, letβs add some variables. **p** is the probability that the LP wins a round. Accordingly, **(1-p)** will be the probability that a round is lost. **b** will be the payout following a successful round.

By winning a round with **k**% of your funds, your total holdings will become **(1+bk)**, where **1** is the original size of your holdings. If you lose a round (with the funds lost being **a**), then the total holdings become **(1-ak)**.

Still following? Hereβs how weβll model growth rate:

$G = (1 + bk)^p (1 - ak)^{1 - p}$Where:

*G*is the growth rate*b*is the payout from a successful round*k*is the percentage of holdings used*p*is the probability of a successful round*a*is the loss from from an unsuccessful round

Remember, the Kelly fraction is the optimal fraction of funds that should be risked to achieve the **maximum expected growth rate**.Another way to reach this value is when the first derivative of the growth rate equates to **0**.

With this in mind, letβs clean up the previous equation for easier derivation. Weβll remove exponents by taking the natural logarithm of both sides (**1**), use the multiplicative properties of logarithms (**2**) and move the exponents to the front of the natural logs (**3**) to obtain the first derivative with respect to **k** for both sides of the equation (**4**).

- $ln(G) = \ln((1 + bk)^p (1 - ak)^{1 - p})$
- $ln(G) = \ln((1 + bk)^p) + \ln((1 - ak)^{1 - p})$
- $ln(G) = p \ln(1 + bk) + (1 - p) \ln(1 - ak)$
- $\frac{d} {dk}ln(G) = \frac{d} {dk} \left(p \ln(1 + bk) + (1 - p) \ln(1 - ak)\right)$

Let's simplify further:

- ${1 + bk} - \frac{(1 - p) * a} {1 - ak}$
- ${1 + bk} = \frac{(1 - p) * a} {1 - ak}$

From here, itβs just basic algebra to rearrange for **k**.

Finally:

$k = \frac{pb - (1 - p)*a}{ab}$ $k = \frac{pb}{ab} - \frac{(1 - p)*a}{ab}$At long last, weβve got our equation for calculating the Kelly fraction for binary-outcome games:

$k = \frac{p}{a} - \frac{(1 - p)}{b}$*k*is the optimal fraction of funds that the counterparty should use*p*is the probability of YOLO Games winning*a*is the payout from a successful round*b*is the loss from an unsuccessful round

Letβs visualize the above by plotting the growth rate versus the Kelly fraction for *a*, *b* and *p* values of **1**, **1** and **0.6**, respectively:

Note how the optimal growth rate is found at a Kelly fraction of 1 (the inflection point).

Based on the above, youβd be forgiven for thinking that all binary-outcome games should simply use the Kelly fraction at the maximum riskable amount from the LPβs counterparty.

There are disadvantages to doing so. The Kelly criterion is too aggressive for many peopleβs risk tolerance.

For example, in a stacked coin flip where the probability of a βHeadsβ outcome is 60%, weβd get a Kelly fraction of 20% β working with the assumption that a win earns the played amount, while the loss loses it:

$\frac{0.6}{1} - \frac{0.4}{1} = 0.2$To play with 20% of funds for a 60% chance of winning is a relatively high-risk endeavor β and, indeed, one that would likely be too risky for the average player to be comfortable with.

For every 24 coin flips, one can expect three βTailsβ in a row β resulting in a drawdown of 50%. This tracks, though: remember, the Kelly criterion aims to maximize growth rate versus minimizing the drawdown.

Since we cannot treat the liquidity poolβs funds as replenishable, full Kelly must be ruled out due to the risks of severe drawdowns like the above. Instead, full Kelly should serve as an *upper bound on what can be reasonably risked*, with 25-50% of that amount being considered reasonable. At launch, we begin with 10% before considering upping it to 25%.

#### Flipperβ

As mentioned earlier, Flipper emulates the mechanics of a coin flip β players select a side (Gold or Silver) and flip the coin. If their chosen side shows, they get 2x their played amount (before fees). If it doesnβt, they lose their played amount.

In this game, the liquidity pool's probability of winning is **50%** (or 0.5).

Letβs define the playerβs played amount as **1**. Should the liquidity pool lose, it should pay the user 1 (meaning that, as above, the user would leave with **2**, or 2x their original entry). However, as the LP takes 1% (half of the total 2% fee) on its losses due to its fee, it actually pays out **0.96** to the player and **0.02** to future incentives β meaning the proportion of funds lost is **0.98**.

In case of a win for the LP, it takes **1** (the playerβs entire played amount).

By inserting these calculated values into the Kelly Fraction for binary outcomes, we get a result of **0.0102040816**. Since our probability and proportions remain constant, this Kelly Fraction was hard-coded into the smart contract.

#### Quantumβ

In Quantum, players aim to hit *over* or *under* a number. They can set their chance of being correct between 0.1-95%. Then, based on their chance, theyβre assigned a multiplier.

Probabilities and proportions of rounds will change based on user inputs. Here, we'll calculate the Kelly Criterion for the maximum and minimum multipliers.

__Maximum multiplier__

When the player selects the minimum chance of winning (0.1% or 0.001), their multiplier is 100/0.1 = a win of **1,000x**.

Again, letβs call **1** the played funds for a given user. On a user win, the liquidity pool must pay **1,000x** this amount β but since there's a 2% fee on the payout, they only receive **980x** their played funds (10x goes towards the LP and 10x goes towards future incentives).

On an LP loss: the LP pays **989**, as they do not pay for the userβs initial funds.

On an LP win: the LP wins 1. The probability of this happening is 1 - 0.001: **0.999**, or **99.9%**.

Inserting these numbers gives us:

`x* = 0.999/989 - 0.001/1 = 0.00001011122`

__Minimum multiplier__

Using the same logic outlined for the maximum multiplier, with a *maximum* chance of winning (95% or 0.95), we get the following equation:

`x* = 0.05/0.04210526316 - 0.95/1 = 0.23749999994`

Because of the dynamic nature of the Kelly Fraction for Quantum, we opted to include an equation within the smart contract.

#### Don't Fall Inβ

In Donβt Fall In, players must jump from tile to tile. Each jump will uncover what lies beneath the tile β either safety, or death. If itβs the latter, game over.

We can find a roundβs multiplier by using the aforementioned probability, in a fashion similar to that of Quantum. Once we know the chance and multiplier, we can calculate the Kelly Fraction.

Letβs look at some examples:

**One lava pool, one tile to reveal**

The probability of a player winning a game with a single lava pool, where they have to reveal a single tile, is:

`(25 - 1) / 25 = 0.96`

This means that the Liquidity Pool has a **0.04** (4%) chance of winning.

The player's multiplier is 1/0.96 = **~1.041666667**

Therefore, if the player wins, the LP must pay out **((1/0.96)*0.99) - 1** or **0.03125**. If they lose, the LP earns **1** (the playerβs played funds).

Letβs plug these into the Kelly Fraction equation for binary outcomes:

`x* = 0.04/0.03125 - 0.96/1`

= **0.32**

**Three lava pools, five tiles to reveal**

`(25 - 3)/25 * (24 - 3)/24 * (23 - 3)/23 * (22 - 3)/22 * (21 - 3)/21`

= **0.4956521739**

This means that the LP has a **0.504** (50.4%) chance of winning.

The player's multiplier is 1/0.4956521739 = **~2.0175438597**

Therefore, if the player wins, the LP must pay out **0.9973684211**. If they lose, the LP earns **1** (the playerβs played funds).

Again, we plug them into the Kelly Fraction equation for binary outcomes:

`x* = 0.5043478261/0.9973684211 - 0.4956521739/1`

= **0.01002638522**

Because of the dynamic nature of the Kelly Fraction for Don't Fall In, we opted to include an equation within the smart contract.

### Multi-Outcome Gamesβ

Letβs follow similar steps to the Kelly Criterion for binary outcome games. Consider **n** possible outcomes, which each happen with probabilities **p _{1}, p_{2}, β¦ p_{n}**, and payouts of

**M**. If our total funds start at

_{1}, M_{2}, β¦ M_{n}**B**and we play with

**kB**, then our expected value of the natural log of our total funds at the next step can be given by:

Factoring out **B** and simplifying produces:

Using the multiplicative properties of logarithms, we can express this as:

$\sum_{i=1}^{n}p_{i}ln(1+k(M_{i}-1))+ln(B)$Recall that the Kelly criterion can be found by taking the derivative and equating it to 0 to find the **k** value that produces the maximum growth rate:

Therefore, the optimal fraction of total funds to be used as a counterparty is **k**, which is calculated by solving the following:

Where:

**n**is the total number of outcomes**p**is the probability of a given outcome**i****M**is the multiplier paid out to the play in given outcome**i****k**is the Kelly fraction

To apply the equation from the LP's perspective, just treat the multipliers as negatives instead of positives.

## Kelly Criterion Risksβ

### Multiple concurrent entries at max Kellyβ

All games are susceptible to entry by multiple players concurrently. LPs are unable to update based on pending game results β so letβs explore the possible problems that may arise should many players enter at max Kelly.

A playerβs max size is determined using the situationβs Kelly fraction. Should they win, the liquidity pool decreases, but the maximum playable size remains constant. This makes it possible for simultaneous rounds to be played above the Kelly fraction, as multiple successive wins lower the LP funds (thereby causing other roundsβ sizes to exceed 1x Kelly).

Continuing down this path, we could risk an entryβs size being so far above Kelly that it results in flat (or even negative) growth rates for the LP. The earlier diagram illustrates this principle for an amount of ~2x Kelly.

In games with small edges (as is the case on YOLO Games), growth rates tend to stagnate or turn negative at ~2x Kelly. However, higher fees can result in negative growth much sooner (e.g., at ~1.5x Kelly). You can see this in action by plotting the chart from the *Binary-Outcome Games* section and incrementally increasing **p**.

Letβs take a look at the difficulty required to hit 2x Kelly in our low-fee situation.

Weβll suppose that the LPβs capital starts at **C**, with a max payout of **M** (in the case of Flipper, this would be 1.98 β we consider the future incentives as a counterparty to the LP in this case , since we are focused on the LPβs risk), and a Kelly fraction of **k**. The max playable amount is **C*k**, while the maximum winnable amount is **C k(M-1)**. Such an event would reduce the initial LP to

**C**.

*k*(M-1)Hereβs the equation for the maximum playable amount:

$MPA=Ck$Where:

**MPA**is the maximum playable amount**C**is the LPβs capital**k**is the Kelly fraction

Hereβs the equation for the maximum winnable amount:

$MWA=MPA*(M-1)=Ck(M-1)$Where:

**MWA**is the maximum winnable amount**M**is the max payout multiplier**MPA**is the maximum playable amount**C**is the LPβs capital**k**is the Kelly fraction

The maximum playable amount does not change over the course of multiple entries within the same round. However, in an ideal world, we would like for the Kelly fraction to re-compute the maximum playable amount after every round. To approach 2x Kelly, the player needs many consecutive wins in a row whilst entering with the maximum enterable amount. We can compute the bankroll after **n** wins using the following:

Where:

**C**is the LPβs capital after_{n}**n**consecutive wins**n**is the number of consecutive wins**M**is the max payout multiplier**C**is the initial LPβs capital**k**is the Kelly fraction

If we substitute the LP after **n** wins equation (above) into the Maximum winnable amount equation , we can calculate the maximum winnable amount after **n** wins:

Where:

**MWA**is the maximum winnable amount after_{n}**n**wins**n**is the number of consecutive wins**M**is the max payout multiplier**C**is the initial LPβs capital**k**is the Kelly fraction

To identify the specific point where we risk >2x Kelly, we need to discover the number of games at which the maximum winnable amount (from no re-computation) is **twice** that of the maximum winnable amount (including re-computation).

Recall that:

- The maximum winnable amount from no re-computation is
**Ck(M - 1)** - The maximum winnable amount from re-computation is
**Ck(M - 1)(1 - (M - 1)*k)**^{n}

**Sk(M - 1)** can be canceled out, leaving us with the resulting equation, which determines the number of consecutive wins that must take place to reach 2x Kelly:

Where:

**M**is the max payout multiplier**k**is the Kelly fraction**n**is the number of consecutive wins to reach 2x Kelly

Rearranging this equation gives us the following:

$(1-(M-1)k)^{n}=0.5$To compute for **n**, we take the log/natural of both sides and rearrange:

So, with a maximum multiplier payout of 5 and a Kelly Fraction of 0.02, we would need **8.31 consecutive wins** to reach 2x Kelly. Of course, this number must be an integer in practice, so we round it up to **9**.

Alright, time to apply the equation to YOLO Games' suite. Since we apply the LP fee after the user has won, we need to replace **M** with **(1-fee)*M** in the aforementioned equation. Remember, weβre looking at this from the LPβs perspective β so we donβt include the portion of the fee that goes towards future incentives.

__Flipper__

Kelly Fraction | 0.0102040816 |

Maximum Payout Multiplier | 2 |

To reach 2x Kelly, we would need to lose `ceil(ln(0.5)/ln((1-((2*0.99) - 1)*0.0102040816)))`

= **69 rounds** in a row. The probability of this happening is 100*0.5^{69} = **~1.6940659e-19%**.

__Quantum (Maximum possible multiplier)__

Kelly Fraction | 0.00001011122 |

Maximum Payout Multiplier | 1000 |

To reach 2x Kelly, we would need to lose `ceil(ln(0.5)/ln((1 - ((1000*0.99) -1)*0.00001011122)))`

= **69 rounds** in a row. The probability of this happening is 100*0.001^{69} = **1e-205%**.

__Quantum (Minimum possible multiplier)__

Kelly Fraction | 0.23749999994 |

Minimum Payout Multiplier | 1.05 |

To reach 2x Kelly, we would need to lose `ceil(ln(0.5)/ln((1 - ((1.05*0.99) - 1)*0.23749999994)))`

= **74 rounds** in a row. This happens with a probability 100*0.95 ^{74} = 2.25%, but the player would have to risk k*n =

**17.575x**the LP size.

__LaserBlast (Maximum possible multiplier)__

Kelly Fraction | 0.000369 |

Maximum Payout Multiplier | 1000.2 |

To reach 2x Kelly, we would need to lose `ceil(ln(0.5)/ln((1 - ((1000.2*0.98) - 1)*0.000369)))`

= **2 rounds** in a row. The probability of this happening is 100*(2*0.00153)^{2} = **2.3409e-4%**.