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

Feature/fee manager #136

Closed
wants to merge 7 commits into from
Closed

Feature/fee manager #136

wants to merge 7 commits into from

Conversation

psparacino
Copy link
Collaborator

Testing FeeManager Implementation

@psparacino psparacino changed the base branch from main to develop September 27, 2023 18:35
Copy link
Member

@plor plor left a comment

Choose a reason for hiding this comment

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

Some of my comments are mostly based on my different conception of how this would be implemented. I'm worried mostly about governance and upgradability. Primarily I want to be able to upgrade the fee setup without redeploying new implementations of the escrow. This might be difficult without changing the factory, so we should think of a middle ground perhaps. Thoughts?

import "@openzeppelin/contracts/access/Ownable.sol";

contract FeeManager is Ownable {
uint256 public version = 1;
Copy link
Member

Choose a reason for hiding this comment

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

How does this versioning work? Is it used for anything?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Not yet, a stable versioning set-up is at the top of the current to-do list before this is merged

uint256 endDate;
}

uint256 public feePercentage = 0;
Copy link
Member

Choose a reason for hiding this comment

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

I think the fee should be in basis points. This wouldn't allow for something like 0.75%

Comment on lines +28 to +32
function setExemption(
ExemptionType exemptionType,
uint256 endDate,
address _address
) external onlyOwner {
Copy link
Member

Choose a reason for hiding this comment

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

Will this be set to the protocol DAO? Just wondering how the governance is set to work.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yes, that's the current plan

Comment on lines +532 to +540
function _calculateFee(uint256 _amount)
internal
view
returns (uint256 fee, uint256 adjustedAmount)
{
fee = (_amount * feePercentage) / 100;
adjustedAmount = _amount - fee;
return (fee, adjustedAmount);
}
Copy link
Member

Choose a reason for hiding this comment

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

I feel like this should be part of the FeeManager rather than in the escrow implementation.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes that makes sense, especially if there are more complicated fee structures down the road that are reused among different types

Copy link
Member

Choose a reason for hiding this comment

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

The issue here is that we don't want to change the fee on an existing invoice, so we'll have to make things immutable.

Comment on lines +128 to +130
FeeManager feeManager = FeeManager(
0x8787678DB688eaD8D53F8F96f33Ceeb0FD821d5a
);
Copy link
Member

Choose a reason for hiding this comment

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

This feels odd to me, hardcoding addresses in source seems like an anti-pattern.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Passing in the FeeManager address seemed like a large vulnerability. Hardcoding it takes that away; if the FeeManager is updated then we update the escrow type on the factory to use the FeeManager. The only way we could securely pass I saw would have been to have a setter on the factory.

Copy link
Member

Choose a reason for hiding this comment

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

Can we maybe add a layer of indirection here? If we're hardcoding an address it should be to something that will never change. That way we can register a new FeeManager there and allow the invoice to look up the current version to set as it's FeeManager. I guess this looks something like a FeeManagerRegistry or FeeManagerFactory.

@wtfsayo
Copy link
Member

wtfsayo commented Oct 18, 2024

closing for being old!

@wtfsayo wtfsayo closed this Oct 18, 2024
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