CoinRoster / slotmachine

fruitgame
0 stars 0 forks source link

Current Investment Value Incorrect #50

Closed Patrick-Bay closed 6 years ago

Patrick-Bay commented 6 years ago

The current value of an investment on Admin page appears to be incorrect after approximately 1 day of activity (possibly earlier). Note that the value of an investment can never exceed the amount of money deposited into the system but currently it does (investment balance = 2.2 TBTC and deposits are only abbout 1.1 TBTC).

This may involve both game play calculations and dividend calculations.

RiskingTime commented 6 years ago

@Patrick-Bay can you focus on this issue now?

Patrick-Bay commented 6 years ago

I believe I may have tackled this issue with previous updates but either way we should clear the database as it will most likely have erroneous values in it (actually I'm quite sure it does). Am I okay to do this -- following the instructions of course?

After this I will do additional local testing using a database copy (of any newly added values) and if any work needs to be done I don't expect it to take more than 1 hour.

RiskingTime commented 6 years ago

ok, please reset the database and we'll test it then

J

Patrick-Bay commented 6 years ago

Okay, I've reset the database and generated a new account for testing (mumibdTqAm9umFJRFQkbZGQ7FVM8T5Nbtd), and sent 0.275 BTC to it. So far everything looks good!

Cheers, Patrick

On Wed, May 16, 2018 at 3:21 PM, RiskingTime notifications@github.com wrote:

ok, please reset the database and we'll test it then

J

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/CoinRoster/slotmachine/issues/50#issuecomment-389635717, or mute the thread https://github.com/notifications/unsubscribe-auth/AHrbz6ozl2czYAyNIHW2qODlkiQmlZyiks5tzHwpgaJpZM4T6A3s .

RiskingTime commented 6 years ago

see the screenshot attached, the value that I'm referring to that is incorrect is current investment balance of the bankroll on the stats page

current investment balance

Patrick-Bay commented 6 years ago

During this cycle the EOD gains were 0.014365 with a 1.1 base investment value which strongly suggests that the book value is being doubled (possibly due to the value of the investments.btc_balance_snapshot value in the database).

The database also clearly indicates that this is part of the dividend payment process so it'll most likely appear in the external timer_payDividends function.

I don't expect this fix to take more than an hour or so as there don't appear to be any external dependencies and I can recreate the conditions exactly as they were on the server just prior to this.

Unfortunately, at this time the database already has erroneous values in it. After the fix we could simply continue with the wrong value (just subtract 1.1 from it), update the database manually, or perform a full reset again. Something to consider while I implement this fix.

RiskingTime commented 6 years ago

Ok great please proceed

Patrick-Bay commented 6 years ago

It looks like the problem was as described -- the legacy balance snapshot value was being used to perform calculations (this is now included with the total balance), so that the base investment value would be doubled up on the first day (difference between previous day and current would be the full balance), and incrementally increased whenever the base investment value changed (difference between previous day's base and current base).

The fix for this has been committed (https://github.com/CoinRoster/slotmachine/commit/d287225f681b0c5a10c1ba5ef86624b2549f2370), and is available for testing on the development server now.

RiskingTime commented 6 years ago

do we need to reset the database in order to test whether this is fixed?