Skip to content
This repository has been archived by the owner on Oct 6, 2023. It is now read-only.

Refactor Fees #63

Merged
merged 10 commits into from
May 31, 2023
Merged

Refactor Fees #63

merged 10 commits into from
May 31, 2023

Conversation

stevieraykatz
Copy link
Contributor

Ticket(s):
We currently store and track fees in three different places using three different mechanisms. This PR will unify the way we track and store fees.

Explanation of the solution

We can implement an ENUM in the LocalRegistrar that acts as a key set for all Fees. In the storage of the LocalRegistrar, we can employ a new mapping which stores the fee rate per enumerated Fee.

Some limitations with the way that I have it written now:

  • All of the fee names must be enumerated at the LocalRegistrar level; even ones that won't be used on a cross chain implementation
  • This currently doesn't employ the same theoretical flexibility that our existing EndowmentFee struct provides:
    struct EndowmentFee {
        address payoutAddress;
        uint256 feePercentage;
        bool active;
    }

However, looking through our code, it doesn't look like we take advantage of the struct's feature set anywhere so maybe we don't need that granular level of control?

  • Using what I currently have sketched, we won't have a way of tracking fees on a per endowment basis. It seems like we're protecting for the concept of "fees by endowment by situation" with our current structure/config, but are we really going to change the fees for individuals? I think that we can add protections here wherein the Enum covers all our basis assuming we don't need control on an individual basis.

Instructions on making this work

  • run yarn or yarn install to install npm dependencies
  • run yarn test to verify all tests still pass

@stevieraykatz stevieraykatz changed the base branch from master to merge-registrars May 23, 2023 23:22
@SovereignAndrey
Copy link
Contributor

SovereignAndrey commented May 24, 2023

@stevieraykatz

This currently doesn't employ the same theoretical flexibility that our existing EndowmentFee struct provides

I think it's OK that the Registrar Fees setup doesn't have the same flexibility. At the end of the day:

  • AP Protocol-level Fees will flow to a singular address (ex. Collector contract, AP Team MultiSig, or some random wallet) that we set and manage at the Registrar level
  • Endowment-level fees will need the flexibility to go to separate payout addresses

While we're thinking about Fees and refactoring, wdyt about removing EndowmentFee.active field and use EndowmentFee.percentage as 0 for anything that wasn't active? If yes, I'll work in those changes in the cosmos branch as part of the final prep to go into merge-registrars after this branch is merged in first.

UPDATES: Made the changes to EndowmentFee in merge-registrars.

  • No more more active field,
  • renamed feePercentage > percentage
  • added check that new percentages passed are less than 100% when updating EndowmentFees
    struct EndowmentFee {
        address payoutAddress;
        uint256 percentage;
    }

@stevieraykatz
Copy link
Contributor Author

I like the idea of removing the active param and using 0 as a default/off switch.

I think we can actually extend this one step further and use the same EndowmentFee struct in the Registrar's mapping:

mapping(Fees => EndowmentFee) FeeRateByFees;

I'm also a fan of renaming some things for clarity. Perhaps:

struct EndowmentFee -> struct FeeSetting
EndowmentFee.percentage -> FeeSetting.feeRate
enum Fees -> enum FeeTypes
mapping FeeRateByFees -> mapping FeeSettingsByFeeType

@stevieraykatz stevieraykatz changed the title Refactor fees {WIP} WIP: Refactor fees May 24, 2023
@SovereignAndrey
Copy link
Contributor

SovereignAndrey commented May 24, 2023

@stevieraykatz I agree with all your suggested changes! That'll unify everything nicely and clarifies what things are and how they can be used. 💯

Those suggestions have been captured in 921f83b.

@SovereignAndrey SovereignAndrey added enhancement New feature or request and removed WIP labels May 25, 2023
@SovereignAndrey SovereignAndrey changed the title WIP: Refactor fees Refactor Fees May 25, 2023
@SovereignAndrey SovereignAndrey deleted the branch master May 25, 2023 23:44
@SovereignAndrey SovereignAndrey changed the base branch from merge-registrars to master May 25, 2023 23:48
@stevieraykatz
Copy link
Contributor Author

@SovereignAndrey should be ready for review and merge

@SovereignAndrey SovereignAndrey merged commit 3e184a9 into master May 31, 2023
@SovereignAndrey SovereignAndrey deleted the refactor-fees branch May 31, 2023 04:02
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
No open projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants