Open aantia opened 3 years ago
Sorry, I had a mental glitch and closed this incorrectly.
Updated information: The error occurs in utils/formatters/farm.js, on line 8. The problem is in the expression 'totalShares.toNumber() === 0'; this only works if totalShares (which is a BN) is small enough to represent in 53 bits.
Replace the line with this and it'll work (it's a bit ugly, though):
const userLP = totalShares.length < 2 ? (totalShares.toNumber() === 0 ? 0 : userShares.mul(totalLP).div(totalShares)) : userShares.mul(totalLP).div(totalShares);
Thanks! This solution helped me too.
@aantia maybe you can make pr on this issue.
fixed in 1.2.30
Thank you!
I just updated the sdk to 1.2.23, and I'm now seeing an error when I call FranciumSDK.getUserFarmPosition(Web3.PublicKey). The error is
UnhandledPromiseRejectionWarning: Error: Number can only safely store up to 53 bits
. which I've seen when trying to convert overly-large BNs to Numbers, but it's being thrown before I actually touch any of the data. Here's the full trace: