Adding subscriptions to Lens using Superfluid #101
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Table of Contents
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:
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 followingmoduleData
tocreateProfile()
orsetFollowModule()
:The REQUIRED
recipient
variable is the addressSUBSCRIBER
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 incurrency
theSUBSCRIBER
MUST pay to follow. It can be 0.The REQUIRED
flowRate
variable is the rate per second ofcurrency
at which theSUBSCRIBER
MUST stream money to therecipient
. It MUST NOT be 0.Subscribing
To subscribe to
OWNER
,SUBSCRIBER
needs to:Superfluid Constant Flow Agreement
(js example) usingcurrency
andflowRate
torecipient
.fee
amount ofcurrency
iffee
> 0.OWNER
’s Profile. It will call this module’sprocessFollow()
that checks ifSUBSCRIBER
is not already following/subscribed, charges the fee and checks if there is a valid CFA fromSUBSCRIBER
toOWNER
.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:
SUBSCRIBER
’s Profile MUST be followingOWNER
’s ProfileSUBSCRIBER
torecipient
usingcurrency
flowRate
SUBSCRIBER
followed (see 5 to understand why)Unsubscribing
To unsubscribe to
OWNER
,SUBSCRIBER
MUST delete their CFA torecipient
. 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 callingfollow()
and Lens doesn’t have aunfollow()
anyway 😜. It also means a maliciousSUBSCRIBER
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 onisFollowing()
.I hope i was clear enough 😫 but let me know if you have some questions!