Our smart contract implements a Dollar Cost Averaging (DCA) strategy. This strategy allows regular investments of an amount in tokenIn, which will be converted to tokenOut at defined intervals (e.g., daily or weekly). This enables a passive and automatic investment approach.
-
createOrder
Function- Arguments: Takes the order values and the
paraswapArgs
structure as input. - Role: Creates the user's order, executes the order for the first time, and sets up an automated task with Gelato for future executions.
- Arguments: Takes the order values and the
-
executeOrder
Function- Arguments: Takes the order ID, Gelato fees, and two
paraswapArgs
structures (one for the order swap and one for the equivalent of 0.1 FTM swap for Gelato fees). - Role: Executes the order swap according to the ID (and pays Gelato fees).
- Arguments: Takes the order ID, Gelato fees, and two
-
editOrder
,stopOrder
,restartOrder
Functions- Role: Allow interaction with the existing order. The function names are self-explanatory.
-
Gelato
- Role: Gelato is used to execute tasks that call the
executeOrder
function of the smart contract at regular intervals (according to the period defined in the order). - Functionality: A TypeScript script, hosted on IPFS, retrieves the values from ParaSwap based on the parameters (tokenIn, tokenOut, amount, etc.). These values are then placed into the
paraswapArgs
structure, necessary forexecuteOrder
. - Self-Payment: Gelato uses a selfpay mechanism, for which 0.1 FTM is swapped to pay Gelato's fees, managed within
executeOrder
.
- Role: Gelato is used to execute tasks that call the
-
ParaSwap
- Role: ParaSwap is used to perform the swaps. It supports different types of swaps (SimpleSwap, MultiSwap, MegaSwap), which is why functions leading to a swap use a
paraswapArgs
structure.
- Role: ParaSwap is used to perform the swaps. It supports different types of swaps (SimpleSwap, MultiSwap, MegaSwap), which is why functions leading to a swap use a
In summary, our DCA smart contract allows for automated and regular investments through the integration of Gelato for task management and ParaSwap for swap execution. The main functions handle the creation, execution, and modification of orders, providing a simple and effective investment solution.