From 95bba465e81c1bdff00bbd01fd80a5847e3e11b4 Mon Sep 17 00:00:00 2001 From: Patate Date: Mon, 6 Nov 2023 21:14:11 +0100 Subject: [PATCH 1/2] fix BoringHelperV1 after masterchef end of supply issue --- contracts/boringcrypto/BoringHelperV1.sol | 14 +++++++++- test/foundry/BoringHelperV1.t.sol | 34 +++++++++++++++++++++++ 2 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 test/foundry/BoringHelperV1.t.sol diff --git a/contracts/boringcrypto/BoringHelperV1.sol b/contracts/boringcrypto/BoringHelperV1.sol index 4c7189e0..11eff44c 100644 --- a/contracts/boringcrypto/BoringHelperV1.sol +++ b/contracts/boringcrypto/BoringHelperV1.sol @@ -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]); @@ -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; + } + } } diff --git a/test/foundry/BoringHelperV1.t.sol b/test/foundry/BoringHelperV1.t.sol new file mode 100644 index 00000000..aad192ea --- /dev/null +++ b/test/foundry/BoringHelperV1.t.sol @@ -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); + } +} From 6234508103f84cffb8a58532150dcb8532b89c74 Mon Sep 17 00:00:00 2001 From: Lint Action Date: Mon, 6 Nov 2023 20:16:43 +0000 Subject: [PATCH 2/2] Fix code style issues with Prettier --- contracts/boringcrypto/BoringHelperV1.sol | 1 - 1 file changed, 1 deletion(-) diff --git a/contracts/boringcrypto/BoringHelperV1.sol b/contracts/boringcrypto/BoringHelperV1.sol index 11eff44c..d36d16b0 100644 --- a/contracts/boringcrypto/BoringHelperV1.sol +++ b/contracts/boringcrypto/BoringHelperV1.sol @@ -879,7 +879,6 @@ 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