#41890 [SC-Insight] MoneyBrinter vault does not consider Farm's staking cap
Previous#41885 [SC-Insight] Bypass token whitelistNext#41886 [SC-Low] Full or Large WBERA reward collects can be blocked by small amounts
Was this helpful?
Was this helpful?
Was this helpful?
function _stakeLocked(
address staker_address,
address source_address,
uint256 liquidity,
uint256 secs,
uint256 start_timestamp
) internal updateRewardAndBalance(staker_address, true) {
require(!stakingPaused, "Staking paused");
require(liquidity > 0, "Must stake more than zero");
@> staking cap here >> require(_total_liquidity_locked.add(liquidity) <= stakingTokenCap, "Farm cap exceeded");
require(greylist[staker_address] == false, "Address has been greylisted");
require(secs >= lock_time_min, "Minimum stake time not met");
require(secs <= lock_time_for_max_multiplier,"Trying to lock for too long");
uint256 lock_multiplier = lockMultiplier(secs);
bytes32 kek_id = keccak256(abi.encodePacked(staker_address, start_timestamp, liquidity, _locked_liquidity[staker_address]));
lockedStakes[staker_address].push(LockedStake(
kek_id,
start_timestamp,
liquidity,
start_timestamp.add(secs),
lock_multiplier
));
// Pull the tokens from the source_address
TransferHelper.safeTransferFrom(address(stakingToken), source_address, address(this), liquidity);
// Update liquidities
_total_liquidity_locked = _total_liquidity_locked.add(liquidity);
_locked_liquidity[staker_address] = _locked_liquidity[staker_address].add(liquidity);
// Need to call to update the combined weights
_updateRewardAndBalance(staker_address, false);
// Needed for edge case if the staker only claims once, and after the lock expired
if (lastRewardClaimTime[staker_address] == 0) lastRewardClaimTime[staker_address] = block.timestamp;
emit StakeLocked(staker_address, liquidity, secs, kek_id, source_address);
} function test_Valid_Deposit_Into_Beradrome() public {
uint256 maxYeet = 80 * token;
uint256 maxWBera = 1 * token;
fundYeet(alice, maxYeet);
fundWbera(alice, maxWBera);
(, bytes memory ret) = kodiakFarm.staticcall(abi.encodeWithSignature("owner()"));
address owner = abi.decode(ret, (address));
vm.prank(owner);
kodiakFarm.call(abi.encodeWithSignature("setStakingTokenCap(uint256)", 1 ether));
(uint256 yeetUsed, uint256 wBeraUsed, uint256 islandsMinted) =
depositIntoYeetIsland(alice, maxYeet, maxWBera);
vm.startPrank(alice);
IERC20(yeetIsland).approve(moneyBrinter, islandsMinted);
uint max = IERC4626(moneyBrinter).maxDeposit(alice);
console.log('max deposit: %s', max);
vm.expectRevert('Farm cap exceeded');
uint256 sharesMinted = IERC4626(moneyBrinter).deposit(islandsMinted, alice);
}Ran 1 test for test/vault/Vault_IntegrationTest_ZeroFee.t.sol:Vault_IntegrationTest_ZeroFee
[PASS] test_Valid_Deposit_Into_Beradrome() (gas: 1110991)
Logs:
max deposit: 115792089237316195423570985008687907853269984665640564039457584007913129639935