Skip to content

Commit

Permalink
fix BoringHelperV1 after masterchef end of supply issue
Browse files Browse the repository at this point in the history
  • Loading branch information
Mathieu-Be committed Nov 6, 2023
1 parent bdcdb6e commit 95bba46
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 1 deletion.
14 changes: 13 additions & 1 deletion contracts/boringcrypto/BoringHelperV1.sol
Original file line number Diff line number Diff line change
Expand Up @@ -858,7 +858,7 @@ contract BoringHelperV1 is Ownable {
for (uint256 i = 0; i < pids.length; i++) {
(uint256 amount, ) = chef.userInfo(pids[i], who);
pools[i].balance = amount;
(uint256 pendingJoe, , , ) = chef.pendingTokens(pids[i], who);
uint256 pendingJoe = _pendingTokens(pids[i], who);
pools[i].pending = pendingJoe;

(address lpToken, , , ) = chef.poolInfo(pids[i]);
Expand All @@ -878,4 +878,16 @@ contract BoringHelperV1 is Ownable {
}
return pools;
}


/// @notice Returns the user's pendingTokens for a specific pool of the MasterChef contract
/// @param pid The pool id
/// @param who The user's address
function _pendingTokens(uint256 pid, address who) internal view returns (uint256) {
try chef.pendingTokens(pid, who) returns (uint256 pendingJoe, address, string memory, uint256) {
return pendingJoe;
} catch {
return 0;
}
}
}
34 changes: 34 additions & 0 deletions test/foundry/BoringHelperV1.t.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// SPDX-License-Identifier: MIT
pragma experimental ABIEncoderV2;
pragma solidity 0.6.12;

import "forge-std/Test.sol";

import "contracts/boringcrypto/BoringHelperV1.sol";

contract testBoringHelperV1 is Test {
BoringHelperV1 constant boringHelper = BoringHelperV1(0x1dd4D86180EEe39ac4fB35ECa67CACF608Ab5741);

function setUp() public {
vm.createSelectFork(vm.rpcUrl("avalanche"), 37292546);
}

function test_PollPools() public {
uint256[] memory pids = new uint256[](1);

vm.expectRevert("SafeMath: division by zero");
boringHelper.pollPools(address(this), pids);

BoringHelperV1 newBoringHelper = new BoringHelperV1(
boringHelper.chef(),
boringHelper.maker(),
boringHelper.joe(),
boringHelper.WAVAX(),
boringHelper.joeFactory(),
boringHelper.pangolinFactory(),
boringHelper.bar()
);

newBoringHelper.pollPools(address(this), pids);
}
}

0 comments on commit 95bba46

Please sign in to comment.