-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e346103
commit 03d23fb
Showing
1 changed file
with
44 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
pragma solidity ^0.8.14; | ||
|
||
import "./MeijiMasterChef.sol"; | ||
|
||
// Functions which would otherwise Clutter Masterchef for multi-actions | ||
contract MeijiMasterChefExtended is MeijiMasterChef { | ||
function multiWithdraw(uint256[] calldata positionIds, uint256[] calldata amounts) external { | ||
// Update summations only once. | ||
_updateRewardSummations(); | ||
|
||
// Ensure array lengths match. | ||
uint256 length = positionIds.length; | ||
if (length != amounts.length) revert MismatchedArrayLengths(); | ||
|
||
for (uint256 i = 0; i < length; ) { | ||
_withdraw(positionIds[i], amounts[i]); | ||
|
||
// Counter realistically cannot overflow. | ||
unchecked { | ||
++i; | ||
} | ||
} | ||
} | ||
|
||
function multiStake(uint256[] calldata positionIds, uint256[] calldata amounts) external { | ||
// Update summations only once. Note that rewards accumulated when there is no one | ||
// staking will be lost. But this is only a small risk of value loss if a reward period | ||
// during no one staking is followed by staking. | ||
_updateRewardSummations(); | ||
|
||
// Ensure array lengths match. | ||
uint256 length = positionIds.length; | ||
if (length != amounts.length) revert MismatchedArrayLengths(); | ||
|
||
for (uint256 i = 0; i < length; ) { | ||
_stake(positionIds[i], amounts[i]); | ||
|
||
// Counter realistically cannot overflow. | ||
unchecked { | ||
++i; | ||
} | ||
} | ||
} | ||
} |