Joystream / joystream

Joystream Monorepo
http://www.joystream.org
GNU General Public License v3.0
1.42k stars 115 forks source link

CRT: Revenue splits and AMM may be active at the same time, causing unexpected states #4783

Closed Lezek123 closed 7 months ago

Lezek123 commented 1 year ago

As I understand in the current runtime implementation of CRT:

This means that it's possible to claim over 100% of holders' share of a revenue split, ie.:

  1. Member A has 100 CRT which is 100% of the current total supply
  2. Member A stakes all the tokens on the current revenue split, claiming 100% of holders' share (revenue_split.allocation)
  3. Member B buys 100 CRT on AMM and stakes them on the same split
  4. Member B claims 50% of revenue_split.allocation JOY, even though 100% of token.revenue_split.allocation has already been claimed
  5. Members A and B together have claimed 150% of token.revenue_split.allocation (the amount they can claim is only limited by the balance of CRT module account)
bedeho commented 1 year ago

Hmm, if this turns out to be correct, what is best fix? blocking AMM perhaps? seems most orderly anyway. please verify @ignazio-bovo , if this turns out to be accurate, we need to have @KubaMikolajczyk review designs and tweak.

ignazio-bovo commented 1 year ago

I have written a test here: https://github.com/ignazio-bovo/joystream/commit/4c792880b0f0396cea450b8211a56907a6f6ca13 and in this scenario the split participation will throw an error saying that the treasury balance is too low.

bedeho commented 1 year ago

and in this scenario the split participation will throw an error saying that the treasury balance is too low.

Ok, thank you for getting on top of this so soon, but should we keep this behaviour? seems more orderly to actually block AMM during splits?

ignazio-bovo commented 1 year ago

I agree that is why I have opened a PR with the fix already. See #4784

kdembler commented 7 months ago

Wow we still shipped this bug 🤦 Fixed in #5127