project screenshot 1
project screenshot 2
project screenshot 3

Sublimate Finance

Make every second count! Whether you're an artist, open-source dev, content creator or organization, Sublimate lets you accept continuous financial support from anyone—paid automatically over time in ERC20 tokens per block—so you can focus on creating and building amazing things.

Sublimate Finance

Created At

MarketMake

Project Description

Sublimate is a DeFi smart contract app that lets artists, open-source developers, and content creators accept continuous financial support from anyone in the form of streamable tokens.

For supporters: • Reward your favorite artists, builders, and content creators on a continual basis, at your own pace. • Mint streamable tokens (strETH, strDAI, etc.) by depositing ETH, DAI or any ERC-20 token. • Start a "streamable subscription" to a recipient by choosing a token, a duration, and a rate or maximum amount. Funds will be streamed out of your balance and into the recipient's every time a block is added to the blockchain. You can cancel a subscription at any time. • You pay gas fees only when starting/canceling subscriptions, and converting between streamable and non-streamable tokens. There are no recurring fees during the subscription itself.

For creators: • Connect your wallet address to build a personalized "creator page" ready to receive streamable tokens. You'll get a custom sublimate.finance link to share to your fans and followers (optionally personalizable by connecting an ENS name, e.g. sublimate.finance/creator/vitalik.eth). • Track your balance, number of supporters, and other analytics using our built in dashboard powered by The Graph. • Use our embeddable subscribe widget so anyone can support you from your newsletter, blog or website. • Pay it forward – showcase other creators you're supporting!

How it's Made

Smart contract protocol: Streamable Tokens

• The StreamableERC20 contract is a modified ERC-20 implementation overriding the balanceOf() and transfer() methods.

• A subscription is defined as a rate expressed in tokens per block and a maximum amount of tokens to send. The incoming and outgoing subscriptions for each address are stored as a struct within a double mapping indexed by the "from" and "to" addresses.

• The balance of streamable tokens can be dynamically computed at any time, using the following formula: balance = lastUpdatedBalance + (incomingRate - outgoingRate) * (block - lastUpdatedBlock). Subscriptions can be canceled at any time by the sender.

• We implemented wrapping contracts for ETH and existing ERC20 tokens. This means creating a streamable version of any currency (for instance, DAI) is as easy as deploying StreamableWrappedERC20 with the corresponding underlying token address in the constructor.

• Our current implementation is quite limited; all subscriptions must be funded up-front and last a finite duration to prevent any malfunction of the contract's logic. For future implementations, we're planning to support unfunded and endless subscriptions (e.g. subscribe for 1 year without holding the full amount up front, or even forever), as well as multiple subscriptions to the same address.

• We're working on updating the protocol to allow streamable versions of Aave's interest bearing tokens, so creators and subscribers can earn extra interest while supporting each other.

• We're exploring the use of a new Chainlink feed that will track the average block time of the past day/month/year, so that instead of taking a rate of tokens per block, our smart contract can take a time interval as input and accurately estimate how many blocks a subscription should last.

Smart contracts: StreamableWrappedETH and StreamableDAI

• We used Solidity and the Hardhat development environment to develop the smart contracts, and the Chai library for tests.

• StreamableWrappedETH and StreamableDAI are deployed to the Kovan testnet

• Our contracts are ready to deploy to Matic so our users can support their favorite creators without the friction of exorbitant gas fees.

The Graph: Sublimate subgraph

• Our subgraph calculates block-by-block analytics for users of streamable tokens, including subscriber counts, account balances and net incoming and outgoing rates across all subscriptions.

• Entities include User, StreamableToken, and StreamableSubscription.

• We used event handlers to index the state of all subscriptions, and a block handler to index the balance/amount transferred at every block for all accounts and subscriptions.

• The subgraph is deployed to The Graph's hosted service, indexing on Kovan: https://thegraph.com/explorer/subgraph/sublimate-finance/sublimate

• We started integrating Chainlink's price oracles in the subgraph indexer to accurately calculate the total fiat value of a subscription, since each bit of token streamed within a subscription can have a different price.

Front-end: Svelte Single-Page Application

• We used TypeScript and the Svelte/Sapper web framework to build our dapp as a dynamic single page application. It can be installed as a progressive web app or even deployed to IPFS for censorship resistance.

• The front-end uses ethers.js to make smart contract calls and urql to make GraphQL requests to our subgraph on The Graph.

Back-end: Profile Editing

• Our back-end lets creators associate custom profile information with their Ethereum address to display on their http://sublimate.finance creator page, including an avatar image, cover image, short description and social network links.

• We opted for an off-chain solution using a cloud database and lambda function, deployed to AWS. Editing your profile is as simple as signing the new profile contents with your address through your wallet and making a POST request to the lambda function. (On-chain profile editing would require a transaction at each modification since it changes the state of the EVM.)

Sponsor technologies integrated: ENS, The Graph, AAVE, Matic, Chainlink

background image mobile

Join the mailing list

Get the latest news and updates