Hello everyone Welcome to the very first attempt at RFC.
After reading @with-heart 's post - RFC Implement Champion-led, RFC-drive decision-making process - I was inspired to get my idea out in the world using the above mentioned approach.
(If you haven’t read it yet, I 100% recommend it!)
Before, I had to go in multiple Discord servers, post my idea & wait for days to receive a “meh” response & critique from other developers. With RFC, we’re onto something different. Champions, will have a specific place to share their ideas with a well constructed structure - the what, why and how - and receive a well thought-out response.
So here goes my attempt at creating the very first RFC - subject to improvement.
What are we doing?
I came up with the idea back in October at ETHGlobal Hackathon. I was trying to create income management tool for users receiving their crypto via streams.
Project Name: Decentralized Dollar-Cost-Averaging Dapp (DCA Dapp)
One sentence explanation: DCA Dapp allows users to Dollar-Cost-Average from one crypto to another using smart contracts.
Detailed explanation: DCA Dapp will utilize smart contracts to allow users to exchange one crypto asset for another, over time. Smart contracts will allow the Dapp to cut out any 3rd party service providers, like Kepeers, thus making the Dapp completely decentralized.
Example: Steve has $100 in USDC. He wishes to buy ETH, but ETH’s price is falling and he doesn’t want to go all in @ a certain price. Steve is smart. Steve deposits his $100 USDC into DCA-Dapp, which will exchange Steve’s USDC for ETH over a period of 10 days (for example). Specifically - DCA Dapp will purchase $10 of ETH a day over 10 days, taking the price fluctuations into account.
After the operation, Steve has successfully Dollar-Cost-Averaged into ETH position with his USDC, meaning he now has more ETH than he’d have with simply buying ETH 10 days prior at fixed price.
NOTE: In the above example, we presume that the price of ETH fell each day, leaving Steve with more ETH at the end of the 10 day period.
Why are we doing it?
We’ve protocols like Uniswap - where users can exchange one asset for another @ a fixed price (slippage taken into account). Limit orders were also created by Sushiswap - providing traders with more tools to play around with and to compete with centralized exchanges.
We haven’t really seen any Dollar-Cost-Averaging Dapp where you could park your asset in exchange for another, over time. Today’s DCA is heavy-work. You’ve to execute multiple trades yourself & each time pay the gas fees. With DCA Dapp, you only have to pay gas for depositing/withdrawing your asset(s). After that, you DCA into any asset you wish - gas-free.
You pay the gas fees only, when you:
- Approve (one time, per asset)
- Deposit
- Withdraw
Rest of the heavy-duty work - Dollar-Cost-Averaging - is gas-free & automated.
Advantages:
- Decentralized DCA mechanism
- Relatively cheap (gas fees wise)
- No 3rd parties required
- DCA-ing is gas-free
- DCA-ing is automated
- Completely customizable (timeframe, amount)
How are we doing it?
Like I mentioned in the beginning, I came up with the idea during ETHGlobal Hackathon. I was trying to develop an income management tool for Superfluid’s users (different from DCA Dapp.)
Tech
What’s Superfluid?
Superfluid is a smart contract framework on L1 Ethereum, enabling you to move assets on-chain following predefined rules called agreements. With a single on-chain transaction, the money will flow from your wallet to the receiver in real time! No further transactions required- it works like magic
Super Tokens
Super Tokens are upgraded ERC20 tokens. They’ve super powers that enable them to go from one wallet to another in real-time without performing a TX, unlike regular ERC20 tokens.
Super Apps
Super App is a contract in which we can write our own logic to handle incoming super tokens. What are we going to do with them? Send them to another user? Trade them? Or… DCA?
Architecture
Users will have to upgrade their ERC20 tokens to “Super Tokens” - allowing it to transfer from one wallet to another without any transactions.
After the user has their upgraded ERC20 token, he/she can deposit the asset into DCA Dapp (Super App), which will take two parameters:
- Amount of ERC20
- Timeframe for ERC20
Say Steve wishes to purchase $100 worth of ETH with USDC over 10 days - DCA Dapp will purchase $10 worth ETH a day.
Stephanie wishes to sell $100 worth of ETH (at that time) for USDC over 10 days - DCA Dapp will sell $10 worth ETH a day.
NOTE: In the above example, we presume that the price of ETH over 10 day period is constant.
Pools
Pools are another option for DCA Dapp, although I haven’t given enough thought to it.
Essentially, users would be providing liquidity (one asset, or both assets), earning fees in the process. This resembles Uniswap V3, although major difference between DCA Dapp’s pool model & Uni V3 is that DCA Dapp is constantly exchanging one token for another on its own, taking the price into account at each exchange. Whilst Uni V3 is dependent on users interacting with it, causing price/pool changes.
Challenges
Price changes
Above example is a simple one. Two parties, each want to exchange same amount of asset (in USD value) within the same timeframe.
Challenge that I see is what should the logic be to handle multiple users, for multiple currencies, with different amounts & timeframe, whilst keeping track of price fluctuations between all these different assets.
Even the above mentioned example poses few questions - what if price of ETH is not constant and changes by 1% daily? Let’s imagine this is the case:
- Steve has $100 in USDC.
- Stephanie has 1 ETH, which is $100.
- Price of ETH decreases by $1 each day
Logging the days:
- $10 for 0.1 ETH
- $10 for 0.101 ETH
- $10 for 0.102 ETH
- $10 for 0.103 ETH
- $10 for 0.104 ETH
- $10 for 0.105 ETH
etc.
All-in-all Steve accumulated more by utilizing DCA Dapp, than he would’ve otherwise. Whilst Stephanie sold her ETH for less.
Multiple parties
As mentioned above, having multiple parties with different parameters is a challenge. How can DCA Dapp keep track of them is still unbeknownst to be.
Usage
Why should Stephanie sell her ETH? In above mentioned example, she sold her 1 ETH for $78.37, when she could’ve just sold it in one transaction @ $100 or $99. That’d leave her with a lot more USDC than selling ETH whilst price is depreciating.
Pooling
Why would someone provide liquidity, knowing they’ll DCA into another asset and potentially lose money? We call this - Impermanent Loss.