Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add RewardsWithdrawn event to withdrawRewards function in TACoApplication #276

Merged
merged 3 commits into from
Aug 28, 2024
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
1 change: 1 addition & 0 deletions contracts/contracts/TACoApplication.sol
Original file line number Diff line number Diff line change
Expand Up @@ -556,6 +556,7 @@ contract TACoApplication is
uint96 value = info.tReward;
require(value > 0, "No reward to withdraw");
info.tReward = 0;
emit RewardsWithdrawn(_stakingProvider, value);
emit RewardPaid(msg.sender, _stakingProvider, beneficiary, value);
token.safeTransfer(beneficiary, value);
}
Expand Down
16 changes: 12 additions & 4 deletions tests/application/test_reward.py
Original file line number Diff line number Diff line change
Expand Up @@ -393,15 +393,19 @@ def test_withdraw(accounts, token, threshold_staking, taco_application, child_ap
assert token.balanceOf(beneficiary) == earned
assert token.balanceOf(taco_application.address) == reward_portion - earned

events = taco_application.RewardPaid.from_receipt(tx)
assert events == [
reward_paid_events = taco_application.RewardPaid.from_receipt(tx)
assert reward_paid_events == [
taco_application.RewardPaid(
stakingProvider=staking_provider,
beneficiary=beneficiary,
reward=earned,
sender=beneficiary,
)
]
rewards_withdrawn_events = taco_application.RewardsWithdrawn.from_receipt(tx)
assert rewards_withdrawn_events == [
taco_application.RewardsWithdrawn(stakingProvider=staking_provider, amount=earned)
]

# Add one more staking provider, push reward again and drop operator
chain.pending_timestamp += min_operator_seconds
Expand Down Expand Up @@ -430,15 +434,19 @@ def test_withdraw(accounts, token, threshold_staking, taco_application, child_ap
assert token.balanceOf(beneficiary) == earned + new_earned
assert token.balanceOf(taco_application.address) == 2 * reward_portion - earned - new_earned

events = taco_application.RewardPaid.from_receipt(tx)
assert events == [
reward_paid_events = taco_application.RewardPaid.from_receipt(tx)
assert reward_paid_events == [
taco_application.RewardPaid(
stakingProvider=staking_provider,
beneficiary=beneficiary,
reward=new_earned,
sender=reward_contract,
)
]
rewards_withdrawn_events = taco_application.RewardsWithdrawn.from_receipt(tx)
assert rewards_withdrawn_events == [
taco_application.RewardsWithdrawn(stakingProvider=staking_provider, amount=new_earned)
]

# Reset reward contract
taco_application.setRewardContract(ZERO_ADDRESS, sender=creator)
Expand Down
Loading