Inspiration
Dollar-cost-averaging (DCA) is a popular and widely known investment strategy. For crypto, we backtested a strategy to compare investing on a single day vs. DCA'ing over 5-10 days and were surprised by the results. DCA'ing daily led to a higher target asset purchase the majority of the time. Check out the strategy back testing here: DCA Backtesting App
What it does
Coalesce relies on two contracts:
- DollarCostAverageDeployer Code
The main contract that launches new vaults
- DollarVostAverageVault Code A contract that manages the DCA activity for a single wallet
Live Contract Addresses (Polygon): DollarCostAverageDeployer https://polygonscan.com/address/0xb83b39e6718f624b3d68785cf3305a4f514f5e06 DollarCostAverageVault (DAI->ETH) example https://polygonscan.com/address/0x62e0ba89079d1203e9db8d5bdf9abbc6c9d855c6
Chainlink Keeper Here
How we built it
Using hardhat/solidity/react-native/chainlink keepers/polygon/alchemy
The DollarCostAverageVaultDeployer has a performUpkeep method that gets called by the Chainlink Keeper. When that method gets called the DCADeployer will initiate the DCA processing for ALL active vaults depending on each vault's isReady function (we use block.timestamp to determine frequency)
I also built out a full test suite for the deployer which felt great Test File
Challenges we ran into
Scope! It was really difficult to scope the idea down. At first, I wanted to incorporate price feeds to allow for weighting the DCA (ie. buy less on the way up, buy more on the way down), and chaining together vaults. However, I had to scale it back in order to get something working.
On the Front end, I'm not much of a front-end dev, so it took me a while to get scaffold-eth working in a way that I could add in some basic approvals for depositing the underlying tokens. I set up a separate repo for my scaffold-eth fork here
Launching on polygon was also a bit different and doing all of the bridging etc. added to dev time.
Accomplishments that we're proud of
Just getting something done! Launching it on an L2. Honestly, this was just an awesome challenge to deploy a full set of contracts. Synchronizing everything using deploy scripts was something I was really happy about.
What we learned
How to synchronize deployments on multiple chains (I only tested on forked eth mainnet, but still meant managing those deployments) How to use chainlink in a way similar to sidekiq in the ruby on rails community (this was neat) The best thing about this project was the chainlink starter repo.....I picked up so much from this!!!!! So thankful I've got it for building projects going forward.
What's next for Coalesce
Features: Weighted Dollar Cost Averaging using chainlink price feeds Something similar to yearn vaults where people can launch vaults that others can use to get exposure to a BUNCH of different tokens
New hackathons: I'd like to get some other team members and do EthDenver to add in some of these features, but definitely interested in getting some ideas from the community on what people would like to see.
Built With
- alchemyapi
- chainlink
- ethers
- hardhat
- keeper
- polygon
- r
- react
- solidity
Log in or sign up for Devpost to join the conversation.