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

268 potencial fixes contracts from review #81

Merged
merged 13 commits into from
Nov 21, 2024

Conversation

SamBorisov
Copy link
Contributor

@SamBorisov SamBorisov commented Nov 14, 2024

Update ValData:

  • return if array empty
  • emit event with the data

Add extra checks:

  • add asserts in PriceUpdate, so we do not catch any calculation error if priceOracle has a problem
  • check if validator is already banned, before ban
  • check if validator is active before deactivation
  • check the price input to be no more than uint224 max

Penalty now changeable:

  • The penalty for the left weeks us no changeable by governance between 0.1% to 1.5% (range is made to avoid human error and calculation break)

Base APR constant:

  • make APR a constant so we do not hit problems with calculation if someone change it to too big amount
  • also all unclaimed rewards will be changed if APR is changed witch could lead to unfair rewards

Update vestingManager:

  • add __gap
  • make liquid token immutable to avoid external calls

@coveralls
Copy link

coveralls commented Nov 14, 2024

Pull Request Test Coverage Report for Build 11955075956

Details

  • 28 of 28 (100.0%) changed or added relevant lines in 11 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.08%) to 88.95%

Totals Coverage Status
Change from base Build 11949877426: 0.08%
Covered Lines: 1254
Relevant Lines: 1334

💛 - Coveralls

@SamBorisov SamBorisov requested a review from R-Santev November 15, 2024 11:00
* @dev Only callable by the admin
* @dev the rate should be between 10 and 150 (0.1% and 1.5%)
*/
function setPenaltyDecreasePerWeek(uint256 newRate) external;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this function declared here, when the variable is part of the vesting contract

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added internal function in vesting so we can easily call later

@@ -20,6 +20,7 @@ contract PriceOracle is IPriceOracle, System, Initializable, HydraChainConnector
mapping(uint256 => uint256) public pricePerDay;
mapping(uint256 => List) public priceVotesForDay;

uint256 constant MAX_UINT224 = type(uint224).max;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add visibility modifier

@@ -37,8 +39,7 @@ contract VestingManager is IVestingManager, Initializable, OwnableUpgradeable {
*/
function openVestedDelegatePosition(address staker, uint256 durationWeeks) external payable onlyOwner {
HYDRA_DELEGATION.delegateWithVesting{value: msg.value}(staker, durationWeeks);
address liquidToken = HYDRA_DELEGATION.liquidToken();
_sendLiquidTokens(msg.sender, IERC20(liquidToken).balanceOf(address(this)));
_sendLiquidTokens(msg.sender, IERC20(LIQUIDITY_TOKEN).balanceOf(address(this)));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is already IERC20. No need to cast

const { hydraChain } = await loadFixture(this.fixtures.initializedHydraChainStateFixture);

const validatorsData = [{ validator: this.signers.validators[1].address, votingPower: 12 }];
await expect(hydraChain.connect(this.signers.system).syncValidatorsData(validatorsData)).to.emit(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ensure proper data is emited

@SamBorisov SamBorisov requested a review from R-Santev November 20, 2024 11:51
struct StakingRewardsHistory {
uint256 totalReward;
uint256 epoch;
uint256 timestamp;
}

interface IVestedStaking {
interface IVestedStaking is IVesting {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why this is not IStaking as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well since Vesting is used only in VestedStaking/Delegation and before it was part of this contract, I thought it would be better to be in this interface (IVestedStaking), which is also included in the IStaking, so we should have all the functions.

/**
* @inheritdoc IVesting
*/
function setPenaltyDecreasePerWeek(uint256 newRate) external onlyRole(DEFAULT_ADMIN_ROLE) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's create a reusable modifier to wrap onlyRole(DEFAULT_ADMIN_ROLE) - ```onlyGovernance()```` so we can use it everywhere for better readability

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, wouldn't that be better to be in the ticket (governance consistency) so I can modify it in every contract?

@SamBorisov SamBorisov force-pushed the 268-potencial-fixes-contracts-from-review branch from 6348492 to 2d9f77c Compare November 21, 2024 10:25
@SamBorisov SamBorisov requested a review from R-Santev November 21, 2024 10:31
@SamBorisov SamBorisov merged commit af3edce into main Nov 21, 2024
7 checks passed
@SamBorisov SamBorisov deleted the 268-potencial-fixes-contracts-from-review branch November 21, 2024 15:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants