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

first version of fast-withdrawal feature is ready #24

Open
wants to merge 5 commits into
base: pa
Choose a base branch
from

Conversation

pavelvm5
Copy link

Fast-withdrawal feature - first version (without liquidity accounting).
Added some new tests, changed old ones, which don't suit current implementation.

@pavelvm5 pavelvm5 requested a review from sakulstra July 15, 2024 09:03
/// @notice The maximum fee in BIPS that will be taken when the cooldown period is reduced by maxReductionTime
uint216 maxFee;
/// @notice The address of treasury
address treasury;
Copy link
Contributor

Choose a reason for hiding this comment

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

in most other contracts we handle the treasury as immutable as there's no good reason for it to ever change

Copy link
Author

Choose a reason for hiding this comment

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

I added a setter here because the possibility of distributing these rewards to users as additional APY was previously discussed.

So I decided to leave some flexibility here.

src/contracts/IStakeToken.sol Outdated Show resolved Hide resolved
src/contracts/IStakeToken.sol Outdated Show resolved Hide resolved
src/contracts/StakeToken.sol Outdated Show resolved Hide resolved
@@ -169,16 +184,23 @@ contract StakeToken is ERC20PermitUpgradeable, IStakeToken, Rescuable {

/// @inheritdoc IStakeToken
function cooldownOnBehalfOf(address from) external onlyOwner {
// @audit-info same modif here
Copy link
Contributor

Choose a reason for hiding this comment

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

don't understand that comment, can you elaborate?

Copy link
Author

Choose a reason for hiding this comment

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

The comment refers to the same division of roles as stated below.

It is not clear why the owner is able to move my funds.

/// @inheritdoc IStakeToken
function redeem(address to, uint256 amount) external {
_redeem(msg.sender, to, amount.toUint104());
}

/// @inheritdoc IStakeToken
function redeemOnBehalf(address from, address to, uint256 amount) external onlyOwner {
// @audit-info why we have onlyOwner here, it looks like rug, we should set different role here
Copy link
Contributor

Choose a reason for hiding this comment

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

in aave contracts owner is always governance short exec, imo doesn't make sense to change the naming now

Copy link
Author

Choose a reason for hiding this comment

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

I think it’s a good pattern to have 2 different roles that will be responsible for helping/calling their methods.

Being an auditor or any third party not familiar with the specifics of implementation in AAVE, I will have questions about why the owner (regardless of whether it is a DAO or some kind of contract or address) can withdraw my money specifically to any address.

@@ -232,22 +254,115 @@ contract StakeToken is ERC20PermitUpgradeable, IStakeToken, Rescuable {
_setCooldownSeconds(cooldownSeconds);
}

// TODO: @pavelvm5 wouldn't sort functions here cause it can cause conflicts, but standard is external - first, public .., internal, makes easier to understand everything
Copy link
Contributor

Choose a reason for hiding this comment

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

i personally agree, but would say it's to opinionated - better to follow the standard.

Copy link
Author

Choose a reason for hiding this comment

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

It's absolutely unreadable to have such scattered functions. It’s just difficult for me to understand what entry points the contract has and what methods are available inside.

I don’t consider this opinioned, at least because out of 40 projects I have never seen anyone write this way. This is at least some informations about a bad style guide and unreadable code.

src/contracts/StakeToken.sol Show resolved Hide resolved
src/contracts/IStakeToken.sol Outdated Show resolved Hide resolved
src/contracts/StakeToken.sol Outdated Show resolved Hide resolved
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.

2 participants