# YOGA

Rest easy! It's just short for Yield Optimization Greedy Algorithm

Y Pool does not put all the money into the Swapper. Instead, some of the assets go into other DeFi protocols to earn yield. For example, the pool on Ethereum places

$10\%$

of assets into Swapper (X Swap) to provide liquidity needed for X Swap; another pool on BSC puts $20\%$

of assets into Swapper; the other also puts $20\%$

on Polygon. Meanwhile, the rest of the assets in each pool goes to lending protocols like AAVE.What YOGA does is find the

**best****percentage**,$L$

,*which maximizes the profits earned outside of Y Pool while still being able to afford the liquidity needed for X Swap. For instance, if there's***$100m**altogether in Y Pool, and Y Pool moves a certain ratio of $100m, say**$80m**, to a strategy that earns yield according to the YOGA, which begets the$L$

*based***on the parameters given.**Let's take a look at an example here, but first, we need some assumptions:

Parameter | Description | Ethereum | BSC | Polygon | |

$TVL$ | TVL of Y Pool | $5,000,000 | $5,000,000 | $5,000,000 | |

$R$ | Ratio of swapping out | 80% | 80% | 80% | |

$APY$ | Supply APY of USDT on lending platforms | 10.5% | 5% | 2% | |

$C$ | Withdrawal cost from lending platforms | $20 | $5 | $1 | |

$S$ | Safe reserve ratio | 10% | 10% | 10% | |

And

$D$

, the**D****aily trading volume in total**, in reference to the 24h volume of the AnySwap bridge, is $10,000,000. We can have the earnings (*Earning*as in the formulae below) per day based on YOGA if$L$

of $TVL$

*is moved to supply USDT on a certain lending platform:*$Earning = TVL \cdot L \cdot \frac{APY}{365}$

On the other hand, the cost to withdraw supplied assets in the lending platform back to the pool that supports liquidity would be:

$Times\ of \ Rebalance = max(\frac{D \cdot [R - (1 - R)]}{TVL \cdot(1-L)},\ 0)$

$Cost = max(Times\ of\ Rebalance \cdot C, 0)$

By

$R$

it imagines a scenario where every pool is not able to make ends meet themselves. Under these circumstances, users are more likely to withdraw money from one chain instead of making any more deposits, so XY Protocol would have to continuously return liquidity. Thus, we adjust $R$

**to**$80\%$

to represent the worst scenario on each chain.Net profit per day is displayed in the formula as follows.

$Net\ Profit = TVL \cdot L \cdot \frac{APY}{365} - max(\frac{D \cdot [R - (1 - R)]}{TVL \cdot(1-L)} \cdot C, 0)$

We could find which

$L$

leads to maximum $Net\ Profit$

*by differentiating*$L$

.Consider all the parameters from the table above, do the math and we will have:

Ethereum

BSC

Polygon

Parameter | Ethereum | BSC | Polygon |

$L$ | 88% | 92% | 94% |

$min(L,\ 1 - S)$ | 88% | 90% | 90% |

$Bonus\ APY$ | 7.79% | 4.05% | 1.70% |

$L$

`should never be greater than`

$1-S$

.We may earn more yields and get all the swap fees simultaneously owing to the invention of YOGA, which gives rise to the best way of managing your wealth and utilizing your assets. Notice that what we've just talked about is even the worst case of bonus APY, let alone the enormous full potential that YOGA can achieve!

Since we are purely being conservative in numbers and, in fact, the frequency of withdrawing from lending platforms should be much lower, it is impossible for

$R$

*to be greater than*$50\%$

on all chains at the same time and the volume should be divided into each chain accordingly. Simply put, the bonus APY would be a lot higher than the results we have yielded here.If we charge

**0.1%**of the swap amount as our fee, the APY of collecting the fee would be$10,000,000 \cdot 0.1\% = 10,000$

$APY_{fee} =\frac{10,000 \cdot 365}{5,000,000 \cdot 3} = 24.3\%$

YOGA then provides at least

$\frac{7.79\%+4.05\%+1.70\%}{24.3\%}=55.7$

**%**boost of APY compared to merely collecting fees for liquidity providers.Last modified 5mo ago