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
9 changes: 7 additions & 2 deletions claim.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ if [[ "$variant" == "$temp" ]]; then
exit 1
fi

# ensure there are no other transactions from the staker in 5 block before the forge script is executed
# because we will compare the stakers balance after the forge script and before the forge script and
# the latter is queried from 5 blocks before the first block number we get after the script execution
echo "Waiting 10 seconds..."
sleep 10

forge script script/Claim.s.sol --broadcast --legacy --sig "run(address payable)" $1 --private-key $2 -vvvv

block=$(cast rpc eth_blockNumber)
Expand All @@ -35,12 +41,11 @@ if [[ "$tmp" != "" ]]; then
d2=${tmp[1]}
#d1=$(echo $tmp | sed -n -e 1p | sed 's/\[[^]]*\]//g')
#d2=$(echo $tmp | sed -n -e 2p | sed 's/\[[^]]*\]//g')

fi

echo $(date +"%T,%3N") $block_num

block_num=$((block_num-1))
block_num=$((block_num - 5))
block=$(echo $block_num | cast to-hex --base-in 10)

echo rewardsBeforeClaiming = $(cast call $1 "getRewards()(uint256)" --block $block_num | sed 's/\[[^]]*\]//g')
Expand Down
2 changes: 1 addition & 1 deletion src/BaseDelegation.sol
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,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, 2);
uint64 internal immutable VERSION = encodeVersion(1, 1, 3);

/**
* @dev Return the contracts' version.
Expand Down
4 changes: 2 additions & 2 deletions src/NonLiquidDelegation.sol
Original file line number Diff line number Diff line change
Expand Up @@ -445,9 +445,9 @@ contract NonLiquidDelegation is IDelegation, BaseDelegation {
function getAdditionalSteps() public view returns(uint64) {
NonLiquidDelegationStorage storage $ = _getNonLiquidDelegationStorage();
uint256 first = $.lastStakingIndex[_msgSender()];
if (first == 0)
if (first == 0 && $.stakingIndices[_msgSender()].length > 0)
first = $.stakingIndices[_msgSender()][0];
return uint64($.stakings.length - first - 1);
return $.stakings.length > first ? uint64($.stakings.length - first - 1) : 0;
}

/**
Expand Down
8 changes: 7 additions & 1 deletion stake.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ if [[ "$variant" == "$temp" ]]; then
exit 1
fi

# ensure there are no other transactions from the staker in 5 block before the forge script is executed
# because we will compare the stakers balance after the forge script and before the forge script and
# the latter is queried from 5 blocks before the first block number we get after the script execution
echo "Waiting 10 seconds..."
sleep 10

forge script script/Stake.s.sol --broadcast --legacy --sig "run(address payable, uint256)" $1 $3 --private-key $2

block=$(cast rpc eth_blockNumber)
Expand All @@ -39,7 +45,7 @@ fi

echo $(date +"%T,%3N") $block_num

block_num=$((block_num-1))
block_num=$((block_num - 5))
block=$(echo $block_num | cast to-hex --base-in 10)

rewardsBeforeStaking=$(cast call $1 "getRewards()(uint256)" --block $block_num | sed 's/\[[^]]*\]//g')
Expand Down
8 changes: 7 additions & 1 deletion stakeRewards.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ if [ "$variant" == "LiquidStaking" ] && [ "$staker" != "$owner" ]; then
exit 1
fi

# ensure there are no other transactions from the staker in 5 block before the forge script is executed
# because we will compare the stakers balance after the forge script and before the forge script and
# the latter is queried from 5 blocks before the first block number we get after the script execution
echo "Waiting 10 seconds..."
sleep 10

forge script script/StakeRewards.s.sol --broadcast --legacy --sig "run(address payable)" $1 --private-key $2

block=$(cast rpc eth_blockNumber)
Expand All @@ -47,7 +53,7 @@ fi

echo $(date +"%T,%3N") $block_num

block_num=$((block_num-1))
block_num=$((block_num - 5))
block=$(echo $block_num | cast to-hex --base-in 10)

stake=$(cast call $1 "getStake()(uint256)" --block $block_num | sed 's/\[[^]]*\]//g')
Expand Down
3 changes: 3 additions & 0 deletions unstake.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ fi

echo $(date +"%T,%3N") $block_num

# if block_num retrieved after the forge script was higher that the block in which the transaction submitted by
# the script was included, decrementing block_num by only 1 will lead to fetching all values below from the state
# after the script execution
block_num=$((block_num-1))
block=$(echo $block_num | cast to-hex --base-in 10)

Expand Down
8 changes: 7 additions & 1 deletion withdrawRewards.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ if [[ "$variant" != "NonLiquidStaking" ]]; then
exit 1
fi

# ensure there are no other transactions from the staker in 5 block before the forge script is executed
# because we will compare the stakers balance after the forge script and before the forge script and
# the latter is queried from 5 blocks before the first block number we get after the script execution
echo "Waiting 10 seconds..."
sleep 10

forge script script/WithdrawRewards.s.sol --broadcast --legacy --sig "run(address payable, string, string)" $1 $amount $steps --private-key $2

block=$(cast rpc eth_blockNumber)
Expand Down Expand Up @@ -66,7 +72,7 @@ staker_rewards_after_withdrawal=$(cast to-unit $x ether)

echo $(date +"%T,%3N") $block_num

block_num=$((block_num-1))
block_num=$((block_num - 5))
block=$(echo $block_num | cast to-hex --base-in 10)

rewardsBeforeWithdrawal=$(cast call $1 "getRewards()(uint256)" --block $block_num | sed 's/\[[^]]*\]//g')
Expand Down