untitled(37)-1716863690.png
2024-05-28

How Autonomous DCA Agent Implements AO Cron Triggers

Author : Autonomous Degen


@aoTheComputer uniquely supports automation through native crons, distinguishing itself from legacy blockchains in the realm of smart contract functionality and dApp development.

Let's explore how @autonomous_af's DCA Agent implements AO cron triggers. ↓

  1. First! What are Cron Jobs or Triggers?

Cron is a tool on computers that automatically runs tasks, like sending an email or cleaning up files, at specific times.

Cron triggers are scheduling mechanisms used to automatically execute scripts or commands at specified times or intervals.

https://pbs.twimg.com/media/GNkvQ0kW0AAZTWs?format=png&name=small

  1. Legacy Blockchain dApp Design

In traditional smart contract environments (like Ethereum, Solana, Polygon, etc.), contracts 'wake up' to perform compute at the request of a user transaction.

Programs are not 'live' unless a user interacts with them and cannot perform reoccurring cron jobs or triggers without the use of offchain programming solutions.

  1. AO Process Design and Cron Jobs

@aoTheComputer processes can load and execute data of any size directly into their memory and write back to the network.

This allows contracts to have scheduled 'cron' interactions that automatically wake them up and execute compute at set intervals (cron triggers).

  1. DCA Agent and Cron Jobs

In AO, developers can set up cron jobs that operate entirely onchain. This is crucial for the development of autonomous agents.

Let's now explore how @autonomous_af's DCA Agent integrates cron triggers as part of its functionality.

  1. Direct Cron Triggers: Regular Execution of One Action

DCA agent uses a pattern known as Direct Trigger where the process requires only one action that needs regular execution.

With direct triggers, the process is tagged at the time of creation to receive cron ticks. The frequency of these ticks is determined by a single parameter, and for this agent, we've chosen one tick per a minute...

The process starts receiving cron ticks once per minute. If it has a prompt that matches, (a swap based on an event) these ticks will execute said prompt.

https://pbs.twimg.com/media/GNkwAqMWsAA5QDP?format=png&name=medium

  1. Indirect Cron Triggers: Regular Execution of Multiple Actions

The DCA agent uses indirect triggers when multiple types of actions need regular execution.

This approach uses separate processes that function as trigger-notifiers. These are simple cron-powered agents that remind the main process to perform its tasks.

Example: Cron Triggers Manage Reattempts at Failed Message Deliveries

  1. Swap Notifier: Executes DCA buys at regular intervals.

  2. Retry Notifier: Monitors its own state at these intervals to handle any requests it made that did not receive responses within a predetermined timeout.

  1. Advantages of Indirect Trigger Patterns

Typically, cron tick intervals are set as a process and cannot be changed. However, indirect triggers can update cron tick intervals.

By simply spawning a new trigger-notifier with a different interval, it becomes trivial to adjust the timing of the tasks as needed.

  1. Breakdown of AO Cron Process for DCA Agent

• Facilitates user-triggered and automated DCA buys. • Isolates actions on assets through a state machine. • Tracks fund balances in both tokens. • Updates the AO Process (backend) about completed actions.

https://pbs.twimg.com/media/GNkwoFyXEAAEOWS?format=png&name=medium

If you've enjoyed this thread, make sure to like, retweet, and follow us @autonomous_af For technical details regarding the DCA agent please review the full-length article:

https://twitter.com/autonomous_af/status/1788608899974635555


🏆 Spot typos, grammatical errors, or inaccuracies in this article? Report and Earn !

🔗 More about PermaDAO :Website | Twitter | Telegram | Discord | MediumYoutube

In AO
Tagged with In AO

Sign up for newsletter

Sign up here to get the latest news and updates delivered directly to your inbox.