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

BqETH subscription (no encryptor fees yet) #272

Merged
merged 8 commits into from
Jun 25, 2024

Conversation

vzotova
Copy link
Member

@vzotova vzotova commented May 28, 2024

Type of PR:

  • Bugfix
  • Feature
  • Documentation
  • Other

Required reviews:

  • 1
  • 2
  • 3

What this does:

High-level idea of the changes introduced in this PR.
List relevant API changes (if any), as well as related PRs and issues.

Issues fixed/closed:
Refs nucypher/tdec#169
Refs #262

Why it's needed:

Explain how this PR fits in the greater context of the NuCypher Network.
E.g., if this PR address a nucypher/productdev issue, let reviewers know!

Notes for reviewers:
Based on #271

@vzotova vzotova self-assigned this May 28, 2024
@vzotova vzotova changed the title [WIP] BqETH subscription BqETH subscription Jun 5, 2024
@vzotova vzotova marked this pull request as ready for review June 5, 2024 22:20
Copy link
Member

@derekpierre derekpierre left a comment

Choose a reason for hiding this comment

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

Looks great - just some suggestions/comments.

contracts/contracts/coordination/BqETHSubscription.sol Outdated Show resolved Hide resolved
contracts/contracts/coordination/BqETHSubscription.sol Outdated Show resolved Hide resolved
contracts/contracts/coordination/BqETHSubscription.sol Outdated Show resolved Hide resolved
contracts/contracts/coordination/BqETHSubscription.sol Outdated Show resolved Hide resolved
contracts/contracts/coordination/BqETHSubscription.sol Outdated Show resolved Hide resolved
contracts/contracts/coordination/BqETHSubscription.sol Outdated Show resolved Hide resolved
@vzotova vzotova force-pushed the subscription-3 branch 2 times, most recently from a2b139e to 37033a8 Compare June 7, 2024 19:17
Copy link
Member

@arjunhassard arjunhassard left a comment

Choose a reason for hiding this comment

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

Base fee logic looks good to me!

* @notice Pays for a subscription
*/
function payForSubscription() external {
// require(endOfSubscription == 0, "Subscription already payed");
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// require(endOfSubscription == 0, "Subscription already payed");
// require(endOfSubscription == 0, "Subscription already paid");

uint32 public constant INACTIVE_RITUAL_ID = type(uint32).max;

// TODO: DAO Treasury
// TODO: Should it be updatable?
Copy link
Member

Choose a reason for hiding this comment

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

We're still in an experimentation phase for fee models, even within the context of a single adopter. So we need a way in the near-term, without involving the DAO Treasury, to make structural changes to individual subscription contracts, the grace periods, and corresponding powers granted to / removed from cohort admins

Copy link
Member Author

Choose a reason for hiding this comment

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

in that case contract could be upgradable and belong not to dao but some multisig
other similar options is create setters/getters for all parameters that can be changed by multisig

Copy link
Member

Choose a reason for hiding this comment

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

For reference, #264 proposed that these contracts are upgradeable initially. Once the adopter and us are confortable, we can always bork upgradeability by transferring privileges to the zero address. I see that you added upgradeability in #277, so just commenting for completeness.

@@ -39,9 +39,9 @@ contract ManagedAllowList is GlobalAllowList {
*/
constructor(
Coordinator _coordinator,
IFeeModel _feeModel,
UpfrontSubscriptionWithEncryptorsCap _subscription
Copy link
Member

Choose a reason for hiding this comment

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

Is IFeeModel.sol where the logic for encryptor annual credits will live, or will it be on a per-adopter basis for now?

Copy link
Member Author

Choose a reason for hiding this comment

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

both statements are correct, IFeeModel implementation can have credits and such contracts will be on a per-adopter basis for now

Copy link
Member

@derekpierre derekpierre left a comment

Choose a reason for hiding this comment

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

🎸

@vzotova vzotova changed the title BqETH subscription BqETH subscription (no encryptor fees yet) Jun 11, 2024
@cygnusv cygnusv changed the base branch from epic-subscription to main June 19, 2024 10:02
@cygnusv cygnusv changed the base branch from main to epic-subscription June 19, 2024 10:03
Copy link
Member

@cygnusv cygnusv left a comment

Choose a reason for hiding this comment

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

First pass


function extendRitual(uint32 ritualId, uint32 duration) external {
Ritual storage ritual = rituals[ritualId];
require(msg.sender == ritual.initiator, "Only initiator can extend ritual");
Copy link
Member

Choose a reason for hiding this comment

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

For the moment this is fine, but in the future we may want to relax this restriction (cc @arjunhassard ). See the last discussion in #93

Copy link
Member

Choose a reason for hiding this comment

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

Didn't we tell BqETH that anyone can extend the ritual?

uint32 duration
) external override {
processPayment(initiator, ritualId, numberOfProviders, duration);
}
Copy link
Member

Choose a reason for hiding this comment

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

If the code is the same than processRitualPayment(), do you think we need a separate function?

Copy link
Member Author

Choose a reason for hiding this comment

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

yes, FlatRateFeeModel is just one fee model, for subscription is different

@@ -9,17 +9,35 @@ import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
* @notice IFeeModel
*/
interface IFeeModel {
function currency() external view returns (IERC20);
Copy link
Member

Choose a reason for hiding this comment

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

Why removing the currency() interface here? Maybe it's because we're moving towards a credits system? In any case, functions to calculate cost are still defined with a reference currency token, so I'd keep this.

Copy link
Member Author

Choose a reason for hiding this comment

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

because FeeModel is more flexible, just imagine fee model without payment

uint32 public constant INACTIVE_RITUAL_ID = type(uint32).max;

// TODO: DAO Treasury
// TODO: Should it be updatable?
Copy link
Member

Choose a reason for hiding this comment

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

For reference, #264 proposed that these contracts are upgradeable initially. Once the adopter and us are confortable, we can always bork upgradeability by transferring privileges to the zero address. I see that you added upgradeability in #277, so just commenting for completeness.


// TODO: DAO Treasury
// TODO: Should it be updatable?
address public immutable beneficiary;
Copy link
Member

Choose a reason for hiding this comment

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

I'd rename this to treasury. Beneficiary is a loaded term from the staking contract.

Copy link
Member Author

Choose a reason for hiding this comment

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

In one of the next PR I've changed it to Ownable contract to be able to transfer this role, and I'll rename rest to treasury in that PR 👍

@cygnusv cygnusv merged commit 449290b into nucypher:epic-subscription Jun 25, 2024
2 checks passed
@derekpierre derekpierre mentioned this pull request Aug 12, 2024
23 tasks
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.

4 participants