Automate
For more in depth control over the Ditto execution layer and comprehensive integration into solidity smart contracts we offer the "Automate" - solidity developer playground to master the automations!
Last updated
For more in depth control over the Ditto execution layer and comprehensive integration into solidity smart contracts we offer the "Automate" - solidity developer playground to master the automations!
Last updated
Ditto Automate provides a connection bridge to the The Ditto Entry Point (DEP). DEP is a contract designed to facilitate the routing of workflows and validating the desired intents based on the smart contract policies. The created and registered workflows are then monitored by the Ditto execution layer, a collection of operators that strive to execute the registered workflows as soon as feasible. As a developer, you can take advantage of our automation framework to create DEP-compatible automations.
As Ditto Execution Layer is undergoing huge migration to Meta Automations the documentation will undergo big changes. Please contact us if you desire to integrate the execution layer into your dApp.
Solidity developers can clone the example automation repository. After cloning, run forge install
to install the Ditto automation library.
In the src
folder, you will find two contracts:
Mock
: This contract stores a value that can be incremented on every even block.
AutomateCounter
: This contract inherits from DittoAutomate
and enables easy, permissionless execution.
In the test
folder, you will see an example of a full integration test in a forked environment on Polygon.
To run the integration test, use the following command to set up rpc url:
And start the tests:
The DittoAutomateIOFramework V1 is a comprehensive automation solution for smart contracts. Below is an overview of its components:
Automate.sol: The parent contract to inherit from, providing core automation functionality.
DEP (Ditto Entry Point): The central contract managing workflow execution and integration.
Custom Contracts: Contracts that inherit from Automate.sol to implement specific automation logic.
CheckerBase: The base contract for implementing custom checkers, including:
Time Checker
HF (Health Factor) Checker
V1 Showcase: AutomateOracleMock: A demonstration of Automate.sol combined with TimeChecker.
AutomateBaseTest V1: Allows for seamless, close-to-production fork tests of any inherited contracts.
DEP : The Ditto contract enables the execution of real-time automations based on user requests.
Automation : A contract tailored to your personal needs that executes actions on the blockchain using DEP control.
Checker : An additional verification contract that your automation references to ensure that the necessary conditions have been met.
Automation consists of checkers and action. Checkers allow or revert the workflow executions signaling to execution network that the conditions are not met. To perform a check, it must be initialized beforehand. Checkers are optional, so you can create automations without checks.
A contract that can be inherited to create your own automations. Automate.sol interacts with DittoEntryPoint by creating automation on DittoEntryPoint. Then the executors give the DittoEntryPoint command to execute one or another automation on Automate.sol.
The AutomateOracleMock.sol contract shows you how to properly inherit Automate.sol in order to create your own automation that will perform the tasks you need.
The module of the EIP-7579 standard. The contract works as a layer between DittoEntryPoint and account abstraction of the EIP-4337 standard. Automate7579.sol offers a unified option for creating and executing automations on account abstraction.
An example of how you can inherit an Automate.sol contract.
The contract will rewrite the test data through the function updateTimestamp. This function can only be called by the contract itself. This is indicated by the onlyItself modifier.
The main function in the contract creates automation with 60 seconds interval time checker, that will trigger the function on automated contract.
A simplified version of AutomateOracleMock.sol that does not include checkers.
The module makes swaps for account abstraction with built-in protection against MEV attacks. Before using the module, it must be installed on account abstraction according to the EIP-7579 standard.
With this module, account abstraction can easily interact with the Aave protocol. The module has a function that can make an emergency repayment of the debt, for this you need to specify only the supplyToken and borrowToken.
There are contracts in the repository that are not recommended to be changed:
src/base
src/conncet
They should be considered as basic for creating automation.
The src/modules/checkers folder contains examples of checkers that you can use as-is or modify to suit your needs. Additionally, you have the option to create your own checkers tailored specifically to your automation requirements.
The src/modules directory will include functionality for working with DeFi logic and is open to further enhancements.
You can create new types of automation by studying AutomateOracleMock.sol as an example.
In the tests, we have prepared AutomateBaseTest, which allows for integration testing with DEP on forks:
testing of checkers;
testing the payPrefund function;
testing the runWorkflow function;
AutomateBaseTest identifies valid executors and simulates their execution on your contracts.