XY Finance
Search…
User Guide
Getting Started
DEVELOPER
YOGA
Yield Optimization Greedy Algorithm
Y Pool does not put all the money into the Swapper. Instead, some of the asset goes to other DeFi protocol to earn yield. For example, pool on Ethereum puts
$10\%$
of asset into Swapper to supply liquidity needed by X swap; another pool on BSC puts
$20\%$
of asset into Swapper; the other puts
$20\%$
on Polygon as well. Meanwhile, rest of the asset of each pool goes to lending protocol such as AAVE.
What YOGA does is find the best percentage,
$L$
, that maximizes the profit earned outside of Y pool while still being able to afford the liquidity needed by X Swap. For example, if there's $100m in Y pool in total, Y Pool moves certain ratio of$100m, say $80m, to strategy that earns yield according to the YOGA, which finds out the the $L$ based on given parameters. Let's have an example. First we need some assumptions such as: 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 platform
10.5%
5%
2%
$C$
Withdraw cost from lending platform
$20$5
$1 $S$ Safe reserve ratio 10% 10% 10% And $D$ , daily trading volume in total, by reference of 24H volume of Anyswap Bridge, is$10,000,000. We can have
earning per day by YOGA if moving
$L$
of
$TVL$
to supply USDT on lending platform:
$Earning = TVL \cdot L \cdot \frac{APY}{365}$
cost to withdraw supplied asset in lending platform back to pool supporting liquidity in one day 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 means every pool is not able to make ends meet. In this case, users are more likely to withdraw money from one chain instead of deposit so that XY Protocol would have to continuously put back liquidity. Thus we set
$R$
to
$80\%$
to represent the worst scenario on each chain.
And net profit per day:
$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$
$Net\ Profit$
by differentiating
$L$
.
Pulling in all the numbers from table above, do the math and we 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 yield and get all the swap fee at the same time owing to YOGA, which leads us to the best way of utilizing asset. Note that it is the worst case of Bonus APY! Since we are being conservative in numbers and in fact the frequency of withdrawing from lending platform should be much lower. It is impossible for
$R$
to be greater than
$50\%$
on all chains at the same time and volume should be separated to each chain accordingly. Therefore, the bonus APY would be a lot higher than results above.
If charging 0.1% of swap amount as fee, APY of collecting 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 brings at least
$\frac{7.79\%+4.05\%+1.70\%}{24.3\%}=55.7$
% boost of APY compared to merely collecting fee for liquidity providers.