@@ -58,6 +58,8 @@ contract GenericDistributionHelper is
5858
5959 address public reserveToken;
6060
61+ uint256 private _status; //for reentrancy guard
62+
6163 event Distribution (
6264 uint256 distributed ,
6365 uint256 startingBalance ,
@@ -76,6 +78,18 @@ contract GenericDistributionHelper is
7678
7779 receive () external payable {}
7880
81+ modifier nonReentrant () {
82+ // On the first call to nonReentrant, _status will be _NOT_ENTERED
83+ require (_status != 1 , "ReentrancyGuard: reentrant call " );
84+
85+ // Any calls to nonReentrant after this point will fail
86+ _status = 1 ;
87+ _;
88+ // By storing the original value once again, a refund is triggered (see
89+ // https://eips.ethereum.org/EIPS/eip-2200)
90+ _status = 0 ;
91+ }
92+
7993 function initialize (
8094 INameService _ns ,
8195 IStaticOracle _oracle ,
@@ -129,7 +143,7 @@ contract GenericDistributionHelper is
129143 * @notice this is usually called by reserve, but can be called by anyone anytime to trigger distribution
130144 * @param _amount how much was sent, informational only
131145 */
132- function onDistribution (uint256 _amount ) external virtual {
146+ function onDistribution (uint256 _amount ) external virtual nonReentrant {
133147 //we consider the actual balance and not _amount
134148 uint256 toDistribute = nativeToken ().balanceOf (address (this ));
135149 if (toDistribute == 0 ) return ;
@@ -300,7 +314,7 @@ contract GenericDistributionHelper is
300314 }
301315 for (uint i = 1 ; i < gdPools.length ; i++ ) {
302316 uint24 fee = IUniswapV3Pool (gdPools[i]).fee ();
303- gdFee = gasFee < fee ? gasFee : fee;
317+ gdFee = gdFee < fee ? gdFee : fee;
304318 }
305319 ERC20 (nativeToken ()).approve (address (ROUTER), amountToSell);
306320 uint256 amountOutMinimum = (minReceived * (100 - feeSettings.maxSlippage)) /
0 commit comments