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

Adding subscriptions to Lens using Superfluid #101

Closed
wants to merge 3 commits into from

Conversation

The-Wary-One
Copy link

Table of Contents

  1. Simple Summary
  2. Abstract
  3. Motivation
  4. Specification
    1. Initializing the module
    2. Subscribing
    3. Verifying the subscription
    4. Unsubscribing
    5. Transferring Ownership
  5. Rationale

I did the LFGrow Hackaton with the goal to propose my project to the Lens Protocol afterward. So here it is 😀.

Simple Summary

Adding Subscriptions to Lens using Superfluid.

Abstract

The new SuperfluidCFAFollowModule is a follow module where its Lens Profile can specify the amount of their chosen currency per second and a optional fee their wannabe followers need to pay to follow. It means they first need to open a Superfluid constant flow agreement using the right flow rate and token to the Lens Profile recipient address before following the profile.

Motivation

Having a subscription-like feature in Lens by only allowing profiles to follow if they stream money to a profile owner, can open a lot of new use cases:

  • decentralizing crowdfunding plateforms a la Patreon (Patreeon?! 😜)
  • creating offchain token gated communities to subscribers a la discord’s private channels
  • decentralizing content plateforms a la Spotify where only subscribers can reference or collect content

Specification

In this section i will first specify how a Lens Profile owner can initialize the SuperfluidCFAFollowModule, then how a user can follow them. I will call this 2 Lens users OWNER and SUBSCRIBER.

Initializing the module

To initialize this follow module, OWNER MUST pass the encoded following moduleData to createProfile() or setFollowModule():

abi.encode(
    ['address', 'address', 'uint256', 'uint96'],
    [recipient, currency, fee, flowRate]
)

The REQUIRED recipient variable is the address SUBSCRIBER MUST stream money to. It MUST NOT be 0.
The REQUIRED currency variable MUST be a whitelisted Superfluid SuperToken address.
The fee variable is the OPTIONAL fee amount in currency the SUBSCRIBER MUST pay to follow. It can be 0.
The REQUIRED flowRate variable is the rate per second of currency at which the SUBSCRIBER MUST stream money to the recipient. It MUST NOT be 0.

Subscribing

To subscribe to OWNER, SUBSCRIBER needs to:

  1. create a Superfluid Constant Flow Agreement (js example) using currency and flowRate to recipient.
  2. allow SuperfluidCFAFollowModule to spend fee amount of currency if fee > 0.
  3. follow OWNER’s Profile. It will call this module’s processFollow() that checks if SUBSCRIBER is not already following/subscribed, charges the fee and checks if there is a valid CFA from SUBSCRIBER to OWNER.

Verifying the subscription

Because a Superfluid CFA creator has full control over their flows, to know if a follow/subscription is valid it is important to call isFollowing() on SuperfluidCFAFollowModule and not rely solely on a Lens follow NFT.
A valid subscription MUST follow the following rules:

  1. SUBSCRIBER’s Profile MUST be following OWNER’s Profile
  2. a Superfluid CFA MUST exists from SUBSCRIBER to recipient using currency
  3. the CFA flowRate MUST be equal to flowRate
  4. the CFA MUST NOT have been updated since the SUBSCRIBER followed (see 5 to understand why)

Unsubscribing

To unsubscribe to OWNER, SUBSCRIBER MUST delete their CFA to recipient. They will keep their follower NFT (see 5 to understand why) but they won’t be a valid follower/subscriber anymore.
To resubscribe SUBSCRIBER needs to first burn their follow NFT.

Transferring Ownership

TBD

Rationale

This current design to add subscriptions to Lens is heavily influenced by understanding of Superfluid’s protocol design.
The main gist is that a Superfluid CFA creator has full control over it without delegation, they must manage their CFA themselves. It means Lens cannot create a CFA for a SUBSCRIBER when calling follow() and Lens doesn’t have a unfollow() anyway 😜. It also means a malicious SUBSCRIBER could update their flowRate or delete their CFA entirely after successfully following! That’s why it is important for the other modules and apps to rely on isFollowing().

I hope i was clear enough 😫 but let me know if you have some questions!

@The-Wary-One The-Wary-One changed the title 🎉 superfluid cfa follow module created Adding subscriptions to Lens using Superfluid Apr 12, 2022
@tomonari-t
Copy link

+1

@LucasBonafe
Copy link

Is it possible to segregate posts between followers and subscribers?

@The-Wary-One
Copy link
Author

Is it possible to segregate posts between followers and subscribers?
In this implementation you can only have subscribers. It is pretty limited as i created it for a hackaton.

I am closing this PR because both the Lens protocol and Superfluid changed a lot since a year ago.

donosonaumczuk added a commit that referenced this pull request Jul 17, 2023
This pull request was closed.
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