Inspiration
Crypto price volatility, emotional decision-making, and human factors negatively impact long-term investments and your crypto-portfolio, but we have great solution:
Dollar-Cost Averaging (DCA) is an investment strategy that involves regularly investing a fixed amount of money into a particular asset, regardless of the asset's price at the time. The basic idea behind DCA is to reduce the impact of market volatility on your overall investment, reduces emotional decision-making, and it is well-known strategy for long-term investors.
FlexDCA, our platform, streamlines the automation of DCA strategy, allowing users to effortlessly exchange stablecoins for any supported cryptocurrency while customizing their unique investment strategy.
What it does
With a user-friendly interface and smart-contracts, we provide a contemporary solution for crypto-investment, emphasizing automation, scalability, and flexibility within a decentralized framework, supported by Chainlink services to introduce innovative financial tools.
In the FlexDCA process, users login using Metamask, choosing one or more strategies. Each strategy involves two tokens: a stablecoin (user deposit) and a crypto token (target of the DCA strategy). Users deposit their stablecoin, decide how to split the tokens for individual investments, and set the time interval between this investments.
Chainlink Automation with custom logic, monitors all positions through multiple upkeeps and executes swaps based on user settings. Combining multiple swaps into a single strategy not only improves efficiency and reduces gas costs but also enables the support of a large number of users.
These swaps occur on Uniswap or Balancer, using Chainlink Data Feeds to check result amount and prevent slippage and negative price impact. If the received amount is less than expected, the swap transaction will be reverted.
Each strategy in FlexDCA can be individually customized, allowing users to define unique settings, add additional stablecoins, claim received crypto, bridge unused stablecoins across multiple chains and strategies, and exit from the strategy to get all tokens and cancel swaps.
The bridge feature enables seamless asset shifting between blockchains, empowering users to diversify their DCA strategy across multiple chains and strategies effortlessly. This function use Chainlink CCIP for cross-chain communication. Although the current version uses regular messages to showcase its functionality, the plan is to transition to token transfers once Chainlink supports the transfer of stablecoins (currently we limited by token availability).
How we built it
I started by analyzing and planning the project, using Scaffold-ETH for the basic structure and focusing on smart contract development. Once the strategy logic was complete and tested, I integrated Chainlink Automation for executing swaps. Using a read function checkUpkeep() for user preparation and transfer this data to the execution function - for swaps and update smart contract storage in performUpkeep(). Then, Chainlink Data Feed was added to monitor returned token amounts, ensuring accurate execution by reverting transactions if the received amount was lower than expected.
After implementing first smart-contract, I added a frontend interface and tackled issues with Scaffold for multiple chains. The core pages - homepage, strategies, and detailed strategy pages with pop-ups for key actions were then created: join strategy, deposit more tokens, claim investment crypto and exit from strategy.
Next I start work with bridge functionality, utilizing CCIP token transfer, commenced with development and testing. However, encountering limitations in transferring stablecoins, I adapted the code to send regular CCIP messages, updating smart contract data to illustrate future functionality once Chainlink supports a broader range of tokens.
Expanding features, I introduced a statistics page highlighting project stats and user interest in each strategy. Lastly, I added fDCA, an ERC20 token for DAO and platform rewards, where users receive tokens in 1:1 ratio to their swapped USD amount, paving the way for participation in DAO, raffles, and other FlexDCA bonuses.
Challenges we ran into
- How to create independent strategies for each blockchain and building the basic logic.
- Figuring out efficient token swaps using Uniswap and Balancer.
- How to use Chainlink Automation and handle a large number of users (multiple upkeeps).
- Ensuring control over swap results, with the help of Chainlink Data Feed.
- How to optimise processes for batch swaps in a single strategy, rather than individual swaps.
- Navigating token bridging challenges with Chainlink CCIP, adapting later to messages due to limited stablecoin support.
- Providing flexibility for future updates, such as adding new strategies, updating Balancer pools, and bridging tokens for each strategy on different blockchains.
- Balancing flexibility with a straightforward and user-friendly interface.
Accomplishments that we're proud of
- Great investment automation tool with simple settings for end-users.
- Flexible solution that allow to extend and modify strategies.
- Multichain support and bridge.
- fDCA token implementation with rewards for users that use FlexDCA.
What we learned
- How to use Chainlink services for automation, checking prices and CCIP for messages and tokens bridge.
- How to swap tokens using balancer and uniswap.
- How to build bridge that control messages delivery (not implemented in interface but done in smart-contract). This feature allow to see all messages/token transfers history.
- How to fix scaffold-eth to work with multiple chains.
What's next for FlexDCA - automated investments
- Support more strategies (tokens).
- Update bridge to transfer real tokens.
- Integrate landing protocol for collateral to earn additional income for stablecoins that waiting swap execution.
- Testing and lauch on mainnet.
- Marketing.
Built With
- chainlink
- hardhat
- next.js
- openzeppelin
- solidity




Log in or sign up for Devpost to join the conversation.