-
Notifications
You must be signed in to change notification settings - Fork 18
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
👷 KSX - Remove escrow on inflationary rewards and remove staking cooldown #252
base: main
Are you sure you want to change the base?
Changes from 1 commit
62462f1
6006911
1052a6d
5142e90
1735867
43300af
371f847
b4b69a7
d33ee53
9dee0eb
fb03e81
6336698
7ff1a0a
15eea33
9cb9509
427134b
827e85c
e4d6166
48a2b16
0d173e7
0f1db85
c9e48f6
bf210e9
c6d26b6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -241,11 +241,7 @@ contract StakingRewardsV2 is | |
} | ||
|
||
/// @inheritdoc IStakingRewardsV2 | ||
function unstake(uint256 _amount) | ||
public | ||
whenNotPaused | ||
updateReward(msg.sender) | ||
{ | ||
function unstake(uint256 _amount) public whenNotPaused updateReward(msg.sender) { | ||
if (_amount == 0) revert AmountZero(); | ||
uint256 nonEscrowedBalance = nonEscrowedBalanceOf(msg.sender); | ||
if (_amount > nonEscrowedBalance) revert InsufficientBalance(nonEscrowedBalance); | ||
|
@@ -293,10 +289,7 @@ contract StakingRewardsV2 is | |
} | ||
|
||
/// @inheritdoc IStakingRewardsV2 | ||
function unstakeEscrowAdmin(address _account, uint256 _amount) | ||
external | ||
onlyRewardEscrow | ||
{ | ||
function unstakeEscrowAdmin(address _account, uint256 _amount) external onlyRewardEscrow { | ||
_unstakeEscrow(_account, _amount); | ||
} | ||
|
||
|
@@ -345,61 +338,43 @@ contract StakingRewardsV2 is | |
whenNotPaused | ||
updateReward(_account) | ||
{ | ||
uint256 reward = rewards[_account]; | ||
if (reward > 0) { | ||
// update state (first) | ||
rewards[_account] = 0; | ||
|
||
// emit reward claimed event and index account | ||
emit RewardPaid(_account, reward); | ||
|
||
// transfer token from this contract to the account | ||
// as newly issued rewards from inflation are now issued as non-escrowed | ||
kwenta.transfer(_to, reward); | ||
} | ||
|
||
uint256 rewardUSDC = rewardsUSDC[_account] / PRECISION; | ||
if (rewardUSDC > 0) { | ||
// update state (first) | ||
rewardsUSDC[_account] = 0; | ||
|
||
// emit reward claimed event and index account | ||
emit RewardPaidUSDC(_account, rewardUSDC); | ||
|
||
// transfer token from this contract to the account | ||
// as newly issued rewards from inflation are now issued as non-escrowed | ||
usdc.transfer(_to, rewardUSDC); | ||
} | ||
_processReward(_account, _to, true); | ||
} | ||
|
||
/// @notice Get the reward of the given account for compounding. | ||
/// @dev Retrieves the Kwenta reward without transferring it, as it will be staked immediately after. | ||
function _getRewardCompounding(address _account) | ||
/// @notice Process KWENTA and USDC rewards | ||
/// @dev transferKwenta is set to false when compounding KWENTA rewards | ||
/// @param _account The address of the account to process rewards for | ||
/// @param _to The address to transfer rewards to | ||
/// @param transferKwenta Boolean flag to determine if Kwenta should be transferred | ||
/// @return kwentaReward The amount of Kwenta reward processed | ||
function _processReward(address _account, address _to, bool transferKwenta) | ||
internal | ||
whenNotPaused | ||
updateReward(_account) | ||
returns (uint256 reward) | ||
returns (uint256 kwentaReward) | ||
{ | ||
reward = rewards[_account]; | ||
if (reward > 0) { | ||
// Process Kwenta reward | ||
kwentaReward = rewards[_account]; | ||
if (kwentaReward > 0) { | ||
// update state (first) | ||
rewards[_account] = 0; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if transferKwenta is set to false meaning they want to compound their rewards then doesnt this line ruin that? their rewards are set to 0 but they dont get transferred their kwenta, so next time this is called again (im assuming after they waited for it to compound in this contract), then their rewards will be 0 or close to 0 and therefore they lost their kwenta entirely? if im understanding this correctly then this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. oh upon further look, kwentaReward is extrapolating this value? and it hopefully gets relogged when calling _stake in _compound? |
||
|
||
// emit reward claimed event and index account | ||
emit RewardPaid(_account, reward); | ||
emit RewardPaid(_account, kwentaReward); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the other event is called RewardPaidUSDC this should be called RewardPaidKwenta to match |
||
|
||
if (transferKwenta) { | ||
kwenta.transfer(_to, kwentaReward); | ||
} | ||
} | ||
|
||
uint256 rewardUSDC = rewardsUSDC[_account] / PRECISION; | ||
if (rewardUSDC > 0) { | ||
// Process USDC reward | ||
uint256 usdcReward = rewardsUSDC[_account] / PRECISION; | ||
if (usdcReward > 0) { | ||
// update state (first) | ||
rewardsUSDC[_account] = 0; | ||
|
||
// emit reward claimed event and index account | ||
emit RewardPaidUSDC(_account, rewardUSDC); | ||
emit RewardPaidUSDC(_account, usdcReward); | ||
|
||
// transfer token from this contract to the account | ||
// as newly issued rewards from inflation are now issued as non-escrowed | ||
usdc.transfer(_account, rewardUSDC); | ||
usdc.transfer(_to, usdcReward); | ||
} | ||
} | ||
|
||
|
@@ -411,7 +386,7 @@ contract StakingRewardsV2 is | |
/// @dev internal helper to compound for a given account | ||
/// @param _account the account to compound for | ||
function _compound(address _account) internal { | ||
uint256 reward = _getRewardCompounding(_account); | ||
uint256 reward = _processReward(_account, _account, false); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. will reward be 0 here? |
||
_stake(_account, reward); | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't seem you're using kwentaReward outside of _processReward, but for consistency sake you should either return both kwenta and USDC reward as a tuple or return neither.