From c6af76d77baa5409debcd296b4651b3f8828a8e9 Mon Sep 17 00:00:00 2001 From: aalavandhann <6264334+aalavandhan@users.noreply.github.com> Date: Thu, 28 Nov 2024 11:04:16 -0500 Subject: [PATCH] rouning up when going from shares to staked amount --- contracts/TokenGeyser.sol | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/contracts/TokenGeyser.sol b/contracts/TokenGeyser.sol index e8cbb65..ad560c7 100644 --- a/contracts/TokenGeyser.sol +++ b/contracts/TokenGeyser.sol @@ -4,6 +4,7 @@ pragma solidity ^0.8.24; import { OwnableUpgradeable } from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; import { PausableUpgradeable } from "@openzeppelin/contracts-upgradeable/utils/PausableUpgradeable.sol"; import { ReentrancyGuardUpgradeable } from "@openzeppelin/contracts-upgradeable/utils/ReentrancyGuardUpgradeable.sol"; +import { Math } from "@openzeppelin/contracts/utils/math/Math.sol"; import { Clones } from "@openzeppelin/contracts/proxy/Clones.sol"; import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import { SafeMathCompatibility } from "./_utils/SafeMathCompatibility.sol"; @@ -37,6 +38,7 @@ contract TokenGeyser is ReentrancyGuardUpgradeable { using SafeMathCompatibility for uint256; + using Math for uint256; using SafeERC20 for IERC20; //------------------------------------------------------------------------- @@ -360,8 +362,10 @@ contract TokenGeyser is function totalStakedBy(address addr) public view returns (uint256) { return totalStakingShares > 0 - ? totalStaked().mul(userTotals[addr].stakingShares).div( - totalStakingShares + ? totalStaked().mulDiv( + userTotals[addr].stakingShares, + totalStakingShares, + Math.Rounding.Ceil ) : 0; }