Joystream / joystream

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

Runtime revenue share bug #5126

Closed WRadoslaw closed 7 months ago

WRadoslaw commented 7 months ago

There is a possibility of withdrawing more funds from the module treasury account when the revenue share and AMM market is active. To simplify the way how it will happen I will use an example:

Let's assume Alice created a token (with 10k initial allocation) and started a market where Bob bought 1k tokens.

  1. Alice opens revenue share and stakes her tokens (10k). Her part in the total supply is 10k/11k = 0.91
  2. Before Bob managed to stake his tokens, a new actor - Charlie bought 1k tokens on amm.
  3. Next Bob stakes his tokens. His total supply part is 1k/12k = 0.08(3).
  4. The last holder - Charlie now decided to claim his share as well. His part in supply is the same as Bobs' - 0.08(3)

The fourth point is where the logic breaks. After the 3rd point total allocation that was claimed is 0.91 + 0.08(3) = 0.993, and now Bob during his action will try to claim his part which will exceed the total allocation by 7,6% - 0.993 + 0.083 = 1.076.

kdembler commented 7 months ago

Fixed by #5127