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

Override default fee in Airstreams with two mappings #1040

Closed
4 tasks done
PaulRBerg opened this issue Sep 10, 2024 · 9 comments
Closed
4 tasks done

Override default fee in Airstreams with two mappings #1040

PaulRBerg opened this issue Sep 10, 2024 · 9 comments
Assignees
Labels
effort: high Large or difficult task. priority: 1 This is important. It should be dealt with shortly. type: feature New feature or request. work: complicated Sense-analyze-respond. The relationship between cause and effect requires analysis or expertise.

Comments

@PaulRBerg
Copy link
Member

PaulRBerg commented Sep 10, 2024

Due to our plans to introduce Sablier Pro, it would be helpful to implement a mechanism to override the default fee that gets set as immutable in the MerkleLockup campaign.

Spec:

  • Implement feesByUser mapping that maps address types to uint256 types
  • Implement isUserSet mapping that maps address types to bool types
  • Allow the admin to set a special fee for some users
  • Implement a mechanism that looks up the mappings to check if the user has a special fee and if yes, use that as the campaign fee instead of the default fee

Note: the 'user' in this context refers to the campaign creator. You are welcome to find a better name.

Related:

@PaulRBerg PaulRBerg added type: feature New feature or request. effort: high Large or difficult task. priority: 1 This is important. It should be dealt with shortly. work: complicated Sense-analyze-respond. The relationship between cause and effect requires analysis or expertise. labels Sep 10, 2024
@smol-ninja
Copy link
Member

Question: why do we need two sets? Isn't feesByUser enough? I am assuming the goal here is to allow admin to set different fee for some users. That can be achieved by setting fee through feesByUser and use that to store in the campaigns created by them.

Question: will there be only one special fee? By reading "user has a special fee and if yes, use that as the campaign fee instead of the default fee", it seems like there are two fees: default and special. Does that mean custom fee cant be set for each user if required?

@smol-ninja
Copy link
Member

smol-ninja commented Sep 10, 2024

Pending answers to above questions, I will work on the PR that introduces these changes and will merge it into #1038.

@andreivladbrg
Copy link
Member

andreivladbrg commented Sep 10, 2024

Isn't feesByUser enough? I am assuming the goal here is to allow admin to set different fee for some users. That can be achieved by setting fee through feesByUser and use that to store in the campaigns created by them.

The idea behind the second mapping is to allow for a fee of 0 (zero) in cases where the default fee is greater than zero.

We will have a sablierFee, which is the default fee. If some users (future campaign admins) are configured, we will allow them to have special fees (possibly with a discount or even no fee).

Here’s how it should look:

// If not configured, the default is zero. This means we can't tell if it was intentionally set to zero 
// or if it was never configured. That's why we need the second mapping.
mapping(address => uint256) public feesByUser; 
mapping(address => bool) public isUserSet; 
uint256 public defaultSablierFee = 0.0001e18;

function createMerkle(address admin) public {
    uint256 _sablierFee;

    if (isUserSet[admin]) {
        _sablierFee = feesByUser[admin];
    } else {
        _sablierFee = defaultSablierFee;
    }

    new SablierMerkle(admin, _sablierFee);
}

Does that mean custom fee cant be set for each user if required

I’m not sure I fully understand the question, but I’ll put it this way: the idea is to have specific clients who would benefit from the best rates.

Please lmk if everything is clear, and if you have any suggestions for a better version

@PaulRBerg
Copy link
Member Author

why do we need two sets? Isn't feesByUser enough?

No, because the default value of a Solidity mapping is zero, so it is impossible to differentiate between a default value of zero and an actual fee we want to set to zero for a particular user.

will there be only one special fee?

No. Different users may have different special fees. Some users will be granted a zero fee, while others may pay more than the default fee.

This feature is about giving us and users more optionality.

@smol-ninja
Copy link
Member

@andreivladbrg thanks for explaining. Yes its clear to me know. I didn't consider the scenario of zero fee.

@razgraf

This comment was marked as resolved.

@smol-ninja

This comment was marked as resolved.

@PaulRBerg

This comment was marked as resolved.

@razgraf

This comment was marked as resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
effort: high Large or difficult task. priority: 1 This is important. It should be dealt with shortly. type: feature New feature or request. work: complicated Sense-analyze-respond. The relationship between cause and effect requires analysis or expertise.
Projects
None yet
Development

No branches or pull requests

4 participants