Dollar Cost Averaging is an investing technique that reduces user exposure towards the volatility of assets, by buying along an asset’s “average” curve.

This week was spent diving deep into the well of DCA and figuring out how to integrate it with streaming.
DCA will be implemented by a contract that receives a stream of tokens from the user, and accumulates this stream till the time the swap function is called. The swap function will be called through a cron job or gelato periodically to swap tokens by all users.
The flow of events:
The user gives permission to the contract for the flow of the given tokens.
The user actually starts the flow, while the contract logs the flow and starts calculating the amount of tokens accumulated by the user.
Whenever the swap or manual swap function is called, the contract calculates the amount of fDAIx tokens sent by the user, unwraps to fDAI, swaps those tokens to WETH and finally sends the tokens to the user itself.
Figured out how to achieve a basic DCA MVP using streams and Uniswap on goerli which swaps fDAIx for WETH - including the contract and UI implementation. Currently, the swap of a user’s tokens happens when the user clicks manual swap, but a function to swap all tokens provided by all users has been written, which needs to be called by a cron job periodically.
Planning out further steps that can serve as USP as well as provide users with more freedom on streams:
Allow users to set custom slippage amounts on token swaps
Allowing users to pause the DCA if they want and also manually swap if they like the market conditions
Notifications on streams and every time tokens are swapped (kind of like logs of DCA)

Check out the Demo Video!
This week was very exciting in terms of figuring out the tech behind DCA and streaming, managing permissions and tokens themselves. Learnt a lot about how tokens are swapped using Uniswap, and actually implementing it using a contract.

