Fujicracy / fuji-v1

0 stars 0 forks source link

[Bug] Climbing Speed not reacting to my position #371

Closed iafhurtado closed 2 years ago

iafhurtado commented 2 years ago

Image

Even though I have a small position open in Fantom, I don't seem to have any climbing speed at all.

brozorec commented 2 years ago

@DaigaroCota Ivan is testing with 0xAdC24d7b630759A3AF7f52716d91299c999a2213 on the old contract https://ftmscan.com/address/0xa4e25a3d190afa0e54609b160391e63b678d0315 where the decimal points are still 5. Can you confirm that this is the reason for this bug plz?

This is how his userdata looks like: Screenshot from 2022-05-31 11-49-55

0xdcota commented 2 years ago

I checked the numbers returned by the contract and all seems to be correct (confirming this by looking both at the the old contract and the latest).

I also checked the code on the front-end hook and the logic seems to format the meter points climbing speed according to the game point decimals.

Now, my believe is that the issue is here: https://github.com/Fujicracy/fuji/blob/e24cfb2f6399cd07d096225918648dec1ac5e484/packages/react-app/src/hooks/NftGame.js#L176

Dummy, question, @doliG, should the rateOfAccrual be converted to Number type?

Seems like this is returning zero

  const climbingSpeedPerDay = rateOfAccrual
    ? Number(formatUnits(rateOfAccrual, NFT_GAME_POINTS_DECIMALS)) * 60 * 60 * 24
    : 0;
doliG commented 2 years ago

@DaigaroCota in that case, it simply means that Number(formatUnits(rateOfAccrual, NFT_GAME_POINTS_DECIMALS)) 60 60 * 24 is evaluated to false, meaning it can be a NaN or 0.

0xdcota commented 2 years ago

@doliG and myself did a peer review of the code that returns the Day and week climbing speeds. There is no change required. Both contracts and front-end are returning correct values accordingly. Issue reported is only due to connecting Front-end, that is reading values as 9 decimals, while obsolete contract returns values with 5 decimal places. This would not be a problem for production.