Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unreliable Senior Tranche yield #7

Open
kitty-the-kat opened this issue Jan 11, 2023 · 2 comments
Open

Unreliable Senior Tranche yield #7

kitty-the-kat opened this issue Jan 11, 2023 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@kitty-the-kat
Copy link
Contributor

The Senior Tranche is designed to earn a fixed amount of yield. This yield is not always accounted for in the PnL calculations.

Technical Details

PnLFixedRate.sol does not account for seniorProfit in two cases:

  1. In distributeLoss() when the loss is greater than or equal to the value of the Junior Tranche and could cause losses for the Senior Tranche
  2. In distributeProfit() when the utilisation ratio is greater than utilisationThreshold

Impact

Medium. The PnLFixedRate.sol calculations do not account for seniorProfit in less common edge cases.

Recommendation

The amount seniorProfit should likely be summed into loss[1] or profit[1] respectively. Otherwise, when distributeAssets() is called and fixedRate.lastDistribution is updated without the seniorProfit getting added to either tranche, users who deposited into the Senior Tranche will lose out on the yield they should have received since the previous distribution.

@kitty-the-kat kitty-the-kat added the bug Something isn't working label Jan 11, 2023
@kitty-the-kat kitty-the-kat self-assigned this Jan 11, 2023
@kitty-the-kat
Copy link
Contributor Author

disputed: If I understand correctly then the issue is that senior tranche doesnt get any APY under the two listed circumstances above - if this is the case than that is intendent behaviour. The protection is only up to whatever the junior tranche offers, anything beyond that will result in losses for the senior tranche. The loss of APY when falling below the utilizationThreshold is intended to act as a protection to the junior tranche, and encourage senior tranche holders to pull out (as they now get 0% APY), so also intended. If theres anything Im missing, please let me know!

@engn33r
Copy link

engn33r commented Jan 19, 2023

I can see the points from the comments by @kitty-the-kat, this might be intended behaviour. I will elaborate further to make sure the suggestions are clear. If the explanations below were already understood, I will remove this issue because it may be a non-issue.

The suggestion for distributeLoss() is to make this modification

- loss[1] = _amount - _trancheBalances[0];
+ loss[1] = _amount - _trancheBalances[0] + seniorProfit;

The reason this change may make sense is because the return values of distributeLoss() and distributeProfit() is how the tranche balances are updated. The senior tranche should always receive the fixed rate yield calculated by _calc_rate(). What makes this particular case interesting is that seniorProfit is used in the if statement, so not including it in the following math means the value is considered for the branching logic but then ignore in one of the branches.

The suggestion for distributeProfit() is pointing out that currently when the utilisationThreshold is exceeded, the senior tranche receives no profit. Would it make more sense to pay the senior tranche the profit it is due if the utilization were at the maximum? Perhaps the senior tranche cannot receive the profit when the utilization is greater than the maximum utilisationThreshold, but why not cap the profits to the equivalent profits at 100% of utilisationThreshold? The suggested edit would go into this else statement.
https://github.com/groLabs/GSquared-foundry/blob/f1831bdb353d4a0b3a8937087e1663f73b75e905/src/pnl/PnLFixedRate.sol#L159-L161

With that said, I can understand why the design might choose a zero senior tranche yield when over the utilisationThreshold provides a useful incentive to withdraw. But this should be documented because it breaks the "fixed yield" assumption for the senior tranche and may be considered unexpected behaviour by users.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

When branches are created from issues, their pull requests are automatically linked.

2 participants