Code Monkey home page Code Monkey logo

dca's Introduction

Presentation of the DCA Smart Contract

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.

Functionality of the Main Functions

  1. createOrder Function

    • Arguments: Takes the order values and the ExactInputParams 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.
  2. executeOrder Function

    • Arguments: Takes the order ID, Gelato fees, and two ExactInputParams 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).
  3. editOrder, stopOrder, restartOrder Functions

    • Role: Allow interaction with the existing order. The function names are self-explanatory.

External Integrations for the DCA Functionality

  • 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 for executeOrder.
    • Self-Payment: Gelato uses a selfpay mechanism, for which 0.1 FTM is swapped to pay Gelato's fees, managed within executeOrder.
  • Algebra

    • Role: Algebra Swap Router is used to perform the swaps, which is why functions leading to a swap use a ExactInputParams structure.

In summary, our DCA smart contract allows for automated and regular investments through the integration of Gelato for task management and Algebra for swap execution. The main functions handle the creation, execution, and modification of orders, providing a simple and effective investment solution.

dca's People

Contributors

sifexpro avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.