Giveth / giveth-dapps-v2

This project is the aggregation of GIVeconomy and Giveth.io DApps in a single repo
https://staging.giveth.io
GNU General Public License v3.0
62 stars 33 forks source link

SuperFluid Integration #3089

Closed divine-comedian closed 5 months ago

divine-comedian commented 1 year ago

Integrating the SuperFluid protocol into the giveth dapp to enable recurring donations.

Figma

https://www.figma.com/file/nVoinu0tgJ565enN5R4WDE/GIVeconomy?type=design&node-id=24117%3A10460&mode=design&t=m2i9UV6ZOVZaTmh8-1

Notion Article & Token Details

https://www.notion.so/giveth/SuperFluid-Integration-on-Optimism-7522a4064c224c08888986998e2cf091?pvs=4

Forum post:

https://forum.giveth.io/t/giveth-superfluid-integration-for-recurring-donations-on-optimism/1160

Docs

https://docs.superfluid.finance/superfluid/

Accounting API

https://superfluidhq.notion.site/Using-the-Stream-Accounting-API-3d161745acfe4750acf43c546f84c724e https://accounting.superfluid.dev/v1/swagger

dashboard

https://app.superfluid.finance/

OP Goerli subgraph

https://console.superfluid.finance/subgraph?_network=optimism-goerli

Optimism SuperFluid subgraph

https://console.superfluid.finance/subgraph?_network=optimism-mainnet

Recurring Donation Creation & Claim Diagram

image

divine-comedian commented 1 year ago

Need to consider that a donor or a project would have a positive netflow or even a balanced netflow

this could mean donors could have an infinite recurring donation on the front-end


a user could change their stream balance or net flow rate outside of the giveth UI we need to check the subgraph periodically to update the estimated end date (perhaps 1 day)

go through the list of recurring donations and recalculate them, calculate the expiry dates, if we hit a date less than what we want we notify these people

or have a calculate every time the flow-changes in the front-end so it is saved in the database. recalculate all the open flows - if you make a flow inside of Giveth we will still use the account API to give us the proper amount, we will save the streams people are giving to projects, we need to know the amount by asking the API

check how much the project has received from the donor?


front-end grabs the information it needs from the user at the moment - gets this information from the subgraph as needed

a cronjob happening in the back-end that doesn't happen when user enters their account, it is something every 12 hours the back-end needs to check all the saved streams and go 1 by 1 asking subgraph or API for updates on when the stream ends - asks for net flowrate and stream balance - checks if it will end soon - if so sends notification to user, will be 1 API request per stream, this is really heavy, need to find a way to simplify it


Check if we can get the total amount being donated reccurring to a project - need all tokens on all chains - the USD value sum

cut it if its too heavy. image


need to get usd value of all token balances on all chains image

divine-comedian commented 7 months ago

On BE - double check cronJob and notification center notifs

MoeNick commented 5 months ago

Closed as all issues are done, please add further improvements in post MVP epic