This section contains example of composing Jupiter's DCA program in your program via CPI.
Our aim is to simplify the process for our partners to integrate Jupiter's DCA for customized incentive programs.
The use cases are limitless. Feel free to use the following example as an inspiration to introduce your own functionalities.
Our example code allows you to have your own customized frontend + program that incentivizes users to DCA into your token in order to receive additional airdrops from you.
Open Sourced Code
- anchor program + scripts - https://github.com/jup-ag/dca-cpi-example
- frontend - https://github.com/TeamRaccoons/locked-dca (see example)
The open-sourced example allows you to airdrop additional tokens to users who DCA into your token.
Setting up (Program)
- Fork and clone https://github.com/jup-ag/dca-cpi-example
- Adjust the parameters
- Generate a new program ID and modify the program code
- Deploy the program to Solana
Setting up (Airdrop Script)
- Replace with your deployed program ID here
- Set env var
ADMIN_PRIVATE_KEY- this is the account you will use to execute airdrops (it should contain sufficient tokens to airdrop + SOL to perform transactions)
- Run the airdrop script
cd app && npm i && npm run airdropcode
Setting up (Frontend)
- Fork and clone https://github.com/TeamRaccoons/locked-dca
- Replace the program ID here
- Craft new plans for the campaigns - Plans are hardcoded on the Frontend, and enforce on the contract level.
export const SECONDS_IN_MINUTE = 60; // 1 minute
export const SECONDS_IN_DAY = 86400; // 1 day
export const LOCKING_PLAN: ILockingPlan = [
name: `5 minutes`,
cycleSecondsApart: SECONDS_IN_MINUTE, // executed per minute
name: `60 days`,
numberOfTrade: 60, // executed daily
name: `90 days`,
numberOfTrade: 90, // executed daily
Here's how it works
A user creates a DCA via your frontend and program. This creates an escrow account that integrates with Jupiter's DCA program.
Once the DCA is completed (all orders are executed), the user will then be able to claim the tokens that they bought. Once they claim, the airdrop script will also airdrop additional tokens from your admin account to them.
- User create a DCA order via your deployed UI.
- DCA completes within the preset duration.
- User will be able to navigate to the site and close their escrow and receive the output token from the executed DCA orders.
- Once the order and escrow has been closed, partners and integrators will automatically airdrop rewards or incentives directly into user's wallet (With the provided script running in a infinite loop in the background)