XY Finance
Search…
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%10\%
of asset into Swapper to supply liquidity needed by X swap; another pool on BSC puts
20%20\%
of asset into Swapper; the other puts
20%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,
LL
, 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
LL
based on given parameters.
Let's have an example. First we need some assumptions such as:
Parameter
Description
Ethereum
BSC
Polygon
TVLTVL
TVL of Y Pool
$5,000,000
$5,000,000
$5,000,000
RR
Ratio of swapping out
80%
80%
80%
APYAPY
Supply APY of USDT on lending platform
10.5%
5%
2%
CC
Withdraw cost from lending platform
$20
$5
$1
SS
Safe reserve ratio
10%
10%
10%
And
DD
, 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
LL
of
TVLTVL
to supply USDT on lending platform:
Earning=TVLLAPY365Earning = 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(D[R(1R)]TVL(1L), 0)Times\ of \ Rebalance = max(\frac{D \cdot [R - (1 - R)]}{TVL \cdot(1-L)},\ 0)
Cost=max(Times of RebalanceC,0)Cost = max(Times\ of\ Rebalance \cdot C, 0)
By
RR
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
RR
to
80%80\%
to represent the worst scenario on each chain.
And net profit per day:
Net Profit=TVLLAPY365max(D[R(1R)]TVL(1L)C,0)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
LL
that leads to maximum
Net ProfitNet\ Profit
by differentiating
LL
.
Pulling in all the numbers from table above, do the math and we have:
Ethereum
BSC
Polygon
Parameter
Ethereum
BSC
Polygon
LL
88%
92%
94%
min(L, 1S)min(L,\ 1 - S)
88%
90%
90%
Bonus APYBonus\ APY
7.79%
4.05%
1.70%
LL
should never be greater than
1S1-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
RR
to be greater than
50%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,0000.1%=10,00010,000,000 \cdot 0.1\% = 10,000
APYfee=10,0003655,000,0003=24.3%APY_{fee} =\frac{10,000 \cdot 365}{5,000,000 \cdot 3} = 24.3\%
YOGA then brings at least
7.79%+4.05%+1.70%24.3%=55.7\frac{7.79\%+4.05\%+1.70\%}{24.3\%}=55.7
% boost of APY compared to merely collecting fee for liquidity providers.
Copy link