Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/BaseDelegation.sol
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ abstract contract BaseDelegation is IDelegation, PausableUpgradeable, Ownable2St
// ************************************************************************

/// @dev The current version of all upgradeable contracts in the repository.
uint64 internal immutable VERSION = encodeVersion(1, 1, 0);
uint64 internal immutable VERSION = encodeVersion(1, 1, 1);

/**
* @dev Return the contracts' version.
Expand Down
11 changes: 7 additions & 4 deletions src/NonLiquidDelegation.sol
Original file line number Diff line number Diff line change
Expand Up @@ -365,16 +365,19 @@ contract NonLiquidDelegation is IDelegation, BaseDelegation {
* caller's stake if the `value` to be unstaked is greater than the current stake.
*/
function _appendToHistory(int256 value, address staker) internal {
if (value >= 0)
require(uint256(value) >= MIN_DELEGATION, AmountTooLow(uint256(value)));
else
require(uint256(-value) >= MIN_DELEGATION, AmountTooLow(uint256(-value)));
NonLiquidDelegationStorage storage $ = _getNonLiquidDelegationStorage();
int256 amount = value;
if ($.stakingIndices[staker].length > 0)
amount += int256($.stakings[
$.stakingIndices[staker][$.stakingIndices[staker].length - 1]
].amount);
if (value >= 0)
require(uint256(value) >= MIN_DELEGATION, AmountTooLow(uint256(value)));
else
require(
uint256(-value) >= MIN_DELEGATION || amount == 0,
AmountTooLow(uint256(-value))
);
if (value < 0)
require(
amount >= 0,
Expand Down
4 changes: 2 additions & 2 deletions test/NonLiquidDelegation.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2304,8 +2304,8 @@ contract NonLiquidDelegationTest is BaseDelegationTest {
continue;
Console.log("block %s avg rewards %s", block.number, rewards / blocks);
uint256 amount =
operation % 2 == 0 && stakedZil[user] > 2 * delegation.MIN_DELEGATION() ?
vm.randomUint(delegation.MIN_DELEGATION(), stakedZil[user] / 2):
operation % 2 == 0 && stakedZil[user] >= delegation.MIN_DELEGATION() ?
vm.randomUint(delegation.MIN_DELEGATION(), stakedZil[user]):
stakedZil[user];
uint256 pendingBefore = delegation.totalPendingWithdrawals();
uint256 totalStakeValue = delegation.getDelegatedTotal();
Expand Down