otomato-sdk 2.0.0 → 2.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,65 +1,272 @@
1
-
2
1
  # Otomato SDK
3
2
 
4
- The Otomato SDK provides a set of tools to create and manage automations, triggers, and actions in your applications. It is designed to work in both frontend and backend environments using TypeScript.
3
+ The Otomato SDK empowers users to automate any crypto related behavior. With its suite of intuitive automation tools, Otomato allows users to seamlessly respond to market dynamics while abstracting all the complexity.
5
4
 
6
- ## Installation
5
+ ## Table of Contents
6
+
7
+ - [Features](#features)
8
+ - [Installation](#installation)
9
+ - [Getting Started](#getting-started)
10
+ - [Authentication](#authentication)
11
+ - [Creating a Workflow](#creating-a-workflow)
12
+ - [Running a Workflow](#running-a-workflow)
13
+ - [Core Concepts](#core-concepts)
14
+ - [Workflow](#workflow)
15
+ - [Node](#node)
16
+ - [Trigger](#trigger)
17
+ - [Action](#action)
18
+ - [Edge](#edge)
19
+ - [Examples](#examples)
20
+ - [Swap and Deposit Workflow](#swap-and-deposit-workflow)
21
+ - [ETH Price Monitoring with Split Conditions](#eth-price-monitoring-with-split-conditions)
22
+ - [API Reference](#api-reference)
23
+ - [Contributing](#contributing)
24
+ - [License](#license)
25
+
26
+ ## Features
7
27
 
8
- To install the Otomato SDK, run:
28
+ - **Automate Web3 Actions**: Create automated workflows to interact with smart contracts, perform token swaps, send notifications, and more.
29
+ - **Smart Account Integration**: Utilize Smart Accounts (ERC-4337) for secure and efficient automation.
30
+ - **Building Block System**: Combine triggers and actions to build complex strategies without writing low-level code.
31
+ - **Session Key Permissions**: Maintain control over your assets with explicit action authorizations.
32
+ - **Extensible Architecture**: Easily add new triggers, actions, and services.
33
+
34
+ ## Installation
9
35
 
10
36
  ```bash
11
37
  npm install otomato-sdk
38
+
39
+ ## Getting Started
40
+
41
+ ### Authentication
42
+
43
+ Before interacting with the Otomato SDK, you need to authenticate your account.
44
+
45
+ ```js
46
+ import { apiServices, CHAINS } from 'otomato-sdk';
47
+
48
+ async function authenticate() {
49
+ const address = 'YOUR_WALLET_ADDRESS';
50
+ const chainId = CHAINS.ETHEREUM;
51
+ const accessCode = 'YOUR_ACCESS_CODE';
52
+
53
+ const loginPayload = await apiServices.generateLoginPayload(address, chainId, accessCode);
54
+ const signature = 'SIGNATURE_OF_LOGIN_PAYLOAD';
55
+ const { token } = await apiServices.getToken(loginPayload, signature);
56
+
57
+ apiServices.setAuth(token);
58
+ }
12
59
  ```
13
60
 
14
- ## Usage
61
+ ### Creating a workflow
62
+
63
+ A Workflow is a collection of Nodes (Triggers and Actions) connected by Edges.
15
64
 
16
- ### Create an Automation
65
+ ```js
66
+ import { Workflow, Trigger, Action, Edge, TRIGGERS, ACTIONS, CHAINS } from 'otomato-sdk';
17
67
 
18
- ### Create a Trigger
68
+ // Initialize Trigger and Action nodes
69
+ const priceTrigger = new Trigger(TRIGGERS.TOKENS.ON_CHAIN_PRICE_MOVEMENT.PRICE_MOVEMENT_AGAINST_CURRENCY);
70
+ priceTrigger.setChainId(CHAINS.MODE);
71
+ priceTrigger.setComparisonValue(3000);
72
+ priceTrigger.setCondition('lte');
73
+ priceTrigger.setParams('currency', 'USD');
74
+ priceTrigger.setContractAddress('TOKEN_CONTRACT_ADDRESS');
75
+ priceTrigger.setPosition(0, 0);
19
76
 
20
- #### Example
77
+ const swapAction = new Action(ACTIONS.SWAP.ODOS.SWAP);
78
+ swapAction.setChainId(CHAINS.MODE);
79
+ swapAction.setParams('amount', 'AMOUNT_IN_WEI');
80
+ swapAction.setParams('tokenIn', 'TOKEN_IN_CONTRACT_ADDRESS');
81
+ swapAction.setParams('tokenOut', 'TOKEN_OUT_CONTRACT_ADDRESS');
82
+ swapAction.setPosition(0, 100);
21
83
 
22
- Here's how to create a trigger using the Otomato SDK:
84
+ // Create Edges to connect Nodes
85
+ const edge = new Edge({ source: priceTrigger, target: swapAction });
23
86
 
24
- ```typescript
25
- import { Trigger, TRIGGERS, CHAINS, getTokenFromSymbol } from 'otomato-sdk';
87
+ // Create Workflow
88
+ const workflow = new Workflow('Swap on Price Trigger', [priceTrigger, swapAction], [edge]);
89
+ ```
90
+
91
+ ### Running a Workflow
26
92
 
27
- const transferTrigger = new Trigger(TRIGGERS.TOKENS.TRANSFER.TRANSFER);
28
- transferTrigger.setChainId(CHAINS.ETHEREUM);
29
- transferTrigger.setParams("value", 1000);
30
- transferTrigger.setParams("to", "0xe1432599B51d9BE1b5A27E2A2FB8e5dF684749C6");
31
- transferTrigger.setContractAddress(getTokenFromSymbol(CHAINS.ETHEREUM, 'USDC').contractAddress);
93
+ ```js
94
+ // Publish the Workflow
95
+ const creationResult = await workflow.create();
32
96
 
33
- console.log(transferTrigger.toJSON());
97
+ if (creationResult.success) {
98
+ // Run the Workflow
99
+ const runResult = await workflow.run();
100
+ if (runResult.success) {
101
+ console.log('Workflow is running');
102
+ } else {
103
+ console.error('Error running workflow:', runResult.error);
104
+ }
105
+ } else {
106
+ console.error('Error creating workflow:', creationResult.error);
107
+ }
34
108
  ```
35
109
 
36
- ## Contributing
110
+ ## Core concepts
111
+
112
+ ### Workflow
113
+
114
+ A Workflow is a container for nodes (triggers and actions) and the edges that connect them.
115
+
116
+ **Properties**:
117
+ • `id`: Unique identifier.
118
+ • `name`: Name of the workflow.
119
+ • `nodes`: Array of Node instances.
120
+ • `edges`: Array of Edge instances.
121
+ • `state`: Current state (inactive, active, failed, completed, waiting).
122
+
123
+ ### node
124
+
125
+ Node is an abstract class representing either a Trigger or an Action.
126
+
127
+ **Properties**:
128
+ • `id`: Unique identifier.
129
+ • `blockId`: Identifier for the block type.
130
+ • `parameters`: Key-value pairs for node configuration.
131
+ • `position`: Coordinates for UI placement.
132
+
133
+ ### Trigger
134
+
135
+ A Trigger initiates the workflow based on certain conditions.
136
+
137
+ **Methods**:
138
+ • `setCondition(value)`: Sets the logical condition (lt, gt, etc.). This works only for polling based triggers.
139
+ • `setComparisonValue(value)`: Sets the value to compare against. This works only for polling based triggers.
140
+
141
+ ### Action
142
+
143
+ An Action performs operations like swapping tokens, sending notifications, etc.
144
+
145
+ **Methods**:
146
+ • `setParams(key, value)`: Sets parameters specific to the action.
147
+
148
+ ### Edges
149
+
150
+ An Edge connects two nodes, defining the workflow’s execution path.
151
+
152
+ **Properties**:
153
+ • `source`: Source Node.
154
+ • `target`: Target Node.
155
+ • `label`: Optional label for the edge.
156
+ • `value`: Optional value for conditional edges.
157
+
158
+
159
+ ## Examples
160
+
161
+ ### Swap and Deposit Workflow
162
+
163
+ This example demonstrates how to create a workflow that swaps tokens and then deposits them into a lending platform.
164
+
165
+ ```js
166
+ import { Workflow, Trigger, Action, Edge, TRIGGERS, ACTIONS, CHAINS, getTokenFromSymbol } from 'otomato-sdk';
167
+
168
+ // Initialize Trigger
169
+ const priceTrigger = new Trigger(TRIGGERS.TOKENS.ON_CHAIN_PRICE_MOVEMENT.PRICE_MOVEMENT_AGAINST_CURRENCY);
170
+ priceTrigger.setChainId(CHAINS.MODE);
171
+ priceTrigger.setComparisonValue(3000);
172
+ priceTrigger.setCondition('lte');
173
+ priceTrigger.setParams('currency', 'USD');
174
+ priceTrigger.setContractAddress(getTokenFromSymbol(CHAINS.MODE, 'WETH').contractAddress);
175
+ priceTrigger.setPosition(0, 0);
176
+
177
+ // Initialize Actions
178
+ const swapAction = new Action(ACTIONS.SWAP.ODOS.SWAP);
179
+ swapAction.setChainId(CHAINS.MODE);
180
+ swapAction.setParams('amount', '1000000'); // Amount in token units
181
+ swapAction.setParams('tokenIn', getTokenFromSymbol(CHAINS.MODE, 'USDT').contractAddress);
182
+ swapAction.setParams('tokenOut', getTokenFromSymbol(CHAINS.MODE, 'WETH').contractAddress);
183
+ swapAction.setPosition(0, 100);
184
+
185
+ const depositAction = new Action(ACTIONS.LENDING.IONIC.DEPOSIT);
186
+ depositAction.setChainId(CHAINS.MODE);
187
+ depositAction.setParams('tokenToDeposit', getTokenFromSymbol(CHAINS.MODE, 'WETH').contractAddress);
188
+ depositAction.setParams('amount', swapAction.getOutputVariableName('amountOut'));
189
+ depositAction.setPosition(0, 200);
190
+
191
+ // Create Edges
192
+ const edge1 = new Edge({ source: priceTrigger, target: swapAction });
193
+ const edge2 = new Edge({ source: swapAction, target: depositAction });
194
+
195
+ // Create Workflow
196
+ const workflow = new Workflow('Swap and Deposit', [priceTrigger, swapAction, depositAction], [edge1, edge2]);
197
+ ```
198
+
199
+ ### ETH Price Monitoring with Split Conditions
200
+
201
+ An advanced workflow using conditional branching based on ETH price.
202
+
203
+ ```js
204
+ import { Workflow, Trigger, Action, Edge, TRIGGERS, ACTIONS, CHAINS, LOGIC_OPERATORS, ConditionGroup } from 'otomato-sdk';
205
+
206
+ // Initialize Trigger
207
+ const ethPriceTrigger = new Trigger(TRIGGERS.TOKENS.ON_CHAIN_PRICE_MOVEMENT.PRICE_MOVEMENT_AGAINST_CURRENCY);
208
+ ethPriceTrigger.setChainId(CHAINS.MODE);
209
+ ethPriceTrigger.setComparisonValue(3000);
210
+ ethPriceTrigger.setCondition('lt');
211
+ ethPriceTrigger.setParams('currency', 'USD');
212
+ ethPriceTrigger.setContractAddress('ETH_CONTRACT_ADDRESS');
213
+ ethPriceTrigger.setPosition(0, 0);
214
+
215
+ // Split Action
216
+ const splitAction = new Action(ACTIONS.CORE.SPLIT.SPLIT);
217
+
218
+ // Conditional Branches
219
+ const conditionTrue = new Action(ACTIONS.CORE.CONDITION.IF);
220
+ conditionTrue.setParams('logic', LOGIC_OPERATORS.OR);
221
+ const conditionGroup = new ConditionGroup(LOGIC_OPERATORS.AND);
222
+ conditionGroup.addConditionCheck(ethPriceTrigger.getOutputVariableName('price'), 'lt', 3000);
223
+ conditionTrue.setParams('groups', [conditionGroup]);
224
+
225
+ const slackAction = new Action(ACTIONS.NOTIFICATIONS.SLACK.SEND_MESSAGE);
226
+ slackAction.setParams('webhook', 'YOUR_SLACK_WEBHOOK');
227
+ slackAction.setParams('message', 'ETH price is below $3000!');
228
+
229
+ // Create Edges
230
+ const edge1 = new Edge({ source: ethPriceTrigger, target: splitAction });
231
+ const edge2 = new Edge({ source: splitAction, target: conditionTrue });
232
+ const edge3 = new Edge({ source: conditionTrue, target: slackAction, label: 'true', value: 'true' });
233
+
234
+ // Create Workflow
235
+ const workflow = new Workflow('ETH Price Monitoring', [ethPriceTrigger, splitAction, conditionTrue, slackAction], [edge1, edge2, edge3]);
236
+ ```
237
+
238
+ ## API Reference
239
+
240
+ ### Workflow Class
241
+
242
+ - **Methods**:
243
+ - `create()`: Publishes the workflow to the Otomato platform.
244
+ - `run()`: Executes the workflow.
245
+ - `update()`: Updates the workflow.
246
+ - `delete()`: Deletes the workflow.
247
+ - `load(workflowId)`: Loads a workflow by ID.
37
248
 
38
- We welcome contributions to the Otomato SDK. Please make sure you have Node.js v20 installed.
249
+ ### Trigger Class
39
250
 
40
- ### Development Setup
251
+ - **Methods**:
252
+ - `setCondition(value)`: Sets the trigger condition.
253
+ - `setComparisonValue(value)`: Sets the comparison value.
254
+ - `setChainId(value)`: Sets the blockchain network.
255
+ - `setContractAddress(value)`: Sets the contract address.
41
256
 
42
- 1. Clone the repository:
43
- ```bash
44
- git clone https://github.com/otomatorg/otomato-sdk.git
45
- cd otomato-sdk
46
- ```
257
+ ### Action Class
47
258
 
48
- 2. Install dependencies:
49
- ```bash
50
- npm install
51
- ```
259
+ - **Methods**:
260
+ - `setParams(key, value)`: Sets action parameters.
261
+ - `setChainId(value)`: Sets the blockchain network.
262
+ - `setContractAddress(value)`: Sets the contract address.
52
263
 
53
- 3. Build the project:
54
- ```bash
55
- npm run build
56
- ```
264
+ ### Edge Class
57
265
 
58
- 4. Run an example:
59
- ```bash
60
- node dist/examples/create-trigger.js
61
- ```
266
+ - **Methods**:
267
+ - `toJSON()`: Serializes the edge.
268
+ - `delete()`: Deletes the edge.
62
269
 
63
270
  ## License
64
271
 
65
- This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
272
+ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
@@ -1460,7 +1460,44 @@ export const ACTIONS = {
1460
1460
  "CONDITION": {
1461
1461
  "description": "Checks for a condition before proceeding",
1462
1462
  "image": "https://otomato-sdk-images.s3.eu-west-1.amazonaws.com/if.png",
1463
+ "IF": {
1464
+ "name": "Condition",
1465
+ "type": 5,
1466
+ "description": "Checks for a condition before proceeding",
1467
+ "parameters": [
1468
+ {
1469
+ "key": "logic",
1470
+ "type": "and_or",
1471
+ "description": "",
1472
+ "mandatory": true,
1473
+ "category": 0
1474
+ },
1475
+ {
1476
+ "key": "groups",
1477
+ "type": "condition_groups",
1478
+ "description": "",
1479
+ "mandatory": true,
1480
+ "category": 0
1481
+ },
1482
+ ],
1483
+ "examples": [],
1484
+ "blockId": 100016,
1485
+ "image": "https://otomato-sdk-images.s3.eu-west-1.amazonaws.com/if.png"
1486
+ }
1463
1487
  },
1488
+ "SPLIT": {
1489
+ "description": "Split a branch in multiple ones",
1490
+ "image": "https://otomato-sdk-images.s3.eu-west-1.amazonaws.com/split.png",
1491
+ "SPLIT": {
1492
+ "name": "Split",
1493
+ "type": 4,
1494
+ "description": "Split a branch in multiples ones",
1495
+ "parameters": [],
1496
+ "examples": [],
1497
+ "blockId": 100015,
1498
+ "image": "https://otomato-sdk-images.s3.eu-west-1.amazonaws.com/split.png"
1499
+ }
1500
+ }
1464
1501
  },
1465
1502
  "NOTIFICATIONS": {
1466
1503
  "EMAIL": {
@@ -1591,14 +1628,16 @@ export const ACTIONS = {
1591
1628
  "content": "{{message}}"
1592
1629
  }
1593
1630
  },
1594
- "examples": [],
1631
+ "examples": [
1632
+ {}
1633
+ ],
1595
1634
  "blockId": 100003,
1596
1635
  "image": "https://otomato-sdk-images.s3.eu-west-1.amazonaws.com/discord.png"
1597
1636
  }
1598
1637
  },
1599
1638
  "TELEGRAM": {
1600
1639
  "description": "Telegram is a cloud-based mobile and desktop messaging app with a focus on security and speed.",
1601
- "image": "https://otomato-sdk-images.s3.eu-west-1.amazonaws.com/telegram.jpeg",
1640
+ "image": "https://otomato-sdk-images.s3.eu-west-1.amazonaws.com/telegram.jpeg"
1602
1641
  }
1603
1642
  },
1604
1643
  "TOKENS": {
@@ -2103,6 +2142,153 @@ export const ACTIONS = {
2103
2142
  34443
2104
2143
  ],
2105
2144
  "image": "https://otomato-sdk-images.s3.eu-west-1.amazonaws.com/renzo.jpg"
2145
+ },
2146
+ "AAVE": {
2147
+ "description": "Decentralized lending protocol",
2148
+ "chains": [
2149
+ 8453,
2150
+ 534352
2151
+ ],
2152
+ "image": "https://otomato-sdk-images.s3.eu-west-1.amazonaws.com/aave.jpg",
2153
+ "SUPPLY": {
2154
+ "name": "Supply Asset to Aave",
2155
+ "description": "Supply an asset to AAVE",
2156
+ "type": 1,
2157
+ "method": "function supply(address asset, uint256 amount, address onBehalfOf, uint16 referralCode)",
2158
+ "contractAddress": "0xA238Dd80C259a72e81d7e4664a9801593F98d1c5",
2159
+ "parameters": [
2160
+ {
2161
+ "key": "chainId",
2162
+ "type": "chainId",
2163
+ "description": "Chain ID of the network",
2164
+ "mandatory": true,
2165
+ "category": 0
2166
+ },
2167
+ {
2168
+ "key": "asset",
2169
+ "type": "erc20",
2170
+ "description": "The token to supply",
2171
+ "mandatory": true,
2172
+ "enum": "\n (env) => {\n if (!env.parameters.chainId)\n throw new Error('You need to provide the chainId first');\n\n return availableLendingTokens[env.parameters.chainId];\n }",
2173
+ "category": 0
2174
+ },
2175
+ {
2176
+ "key": "amount",
2177
+ "type": "uint256",
2178
+ "description": "The amount of the asset to supply",
2179
+ "mandatory": true,
2180
+ "category": 0,
2181
+ "erc20FormattedAmount": {
2182
+ "contractAddress": "{{parameters.asset}}",
2183
+ "chain": "{{parameters.chainId}}"
2184
+ }
2185
+ },
2186
+ {
2187
+ "key": "onBehalfOf",
2188
+ "type": "address",
2189
+ "description": "The address to receive aTokens",
2190
+ "mandatory": true,
2191
+ "hideInUI": true,
2192
+ "category": 1,
2193
+ "value": "{{user.smartAccountAddress}}"
2194
+ },
2195
+ {
2196
+ "key": "referralCode",
2197
+ "type": "uint16",
2198
+ "description": "Referral code (use 0, as inactive)",
2199
+ "mandatory": true,
2200
+ "hideInUI": true,
2201
+ "category": 1,
2202
+ "value": 0
2203
+ },
2204
+ ],
2205
+ "requiredApprovals": [
2206
+ {
2207
+ "address": "{{parameters.asset}}",
2208
+ "amount": "{{parameters.amount}}",
2209
+ "to": "0xA238Dd80C259a72e81d7e4664a9801593F98d1c5"
2210
+ }
2211
+ ],
2212
+ "output": {
2213
+ "transactionHash": "string"
2214
+ },
2215
+ "permissions": {
2216
+ "approvedTargets": [
2217
+ "{{parameters.asset}}",
2218
+ "0xA238Dd80C259a72e81d7e4664a9801593F98d1c5"
2219
+ ],
2220
+ "label": [
2221
+ "Supply {{tokenSymbol({{parameters.chainId}}, {{parameters.asset}})}} on Aave"
2222
+ ],
2223
+ "labelNotAuthorized": [
2224
+ "Transfer {{tokenSymbol({{parameters.chainId}}, {{parameters.asset}})}}"
2225
+ ]
2226
+ },
2227
+ "blockId": 100020,
2228
+ "image": "https://otomato-sdk-images.s3.eu-west-1.amazonaws.com/aave.jpg"
2229
+ },
2230
+ "WITHDRAW": {
2231
+ "name": "Withdraw Asset from Aave",
2232
+ "description": "Withdraw a supplied asset from the Aave pool.",
2233
+ "type": 1,
2234
+ "method": "function withdraw(address asset, uint256 amount, address to) returns (uint256)",
2235
+ "contractAddress": "0xA238Dd80C259a72e81d7e4664a9801593F98d1c5",
2236
+ "parameters": [
2237
+ {
2238
+ "key": "chainId",
2239
+ "type": "chainId",
2240
+ "description": "Chain ID of the network",
2241
+ "mandatory": true,
2242
+ "category": 0
2243
+ },
2244
+ {
2245
+ "key": "asset",
2246
+ "type": "erc20",
2247
+ "description": "The address of the asset to withdraw",
2248
+ "mandatory": true,
2249
+ "enum": "\n (env) => {\n if (!env.parameters.chainId)\n throw new Error('You need to provide the chainId first');\n\n return availableLendingTokens[env.parameters.chainId];\n }",
2250
+ "category": 0
2251
+ },
2252
+ {
2253
+ "key": "amount",
2254
+ "type": "uint256",
2255
+ "description": "The amount of the asset to withdraw. Use type(uint).max for full balance.",
2256
+ "mandatory": true,
2257
+ "category": 0,
2258
+ "erc20FormattedAmount": {
2259
+ "contractAddress": "{{parameters.asset}}",
2260
+ "chain": "{{parameters.chainId}}"
2261
+ },
2262
+ "default": "type(uint256).max"
2263
+ },
2264
+ {
2265
+ "key": "to",
2266
+ "type": "address",
2267
+ "description": "The address to receive the withdrawn asset",
2268
+ "mandatory": true,
2269
+ "category": 0,
2270
+ "hideInUI": true,
2271
+ "default": "{{user.smartAccountAddress}}"
2272
+ },
2273
+ ],
2274
+ "output": {
2275
+ "transactionHash": "string",
2276
+ "amountWithdrawn": "uint256"
2277
+ },
2278
+ "permissions": {
2279
+ "approvedTargets": [
2280
+ "0xA238Dd80C259a72e81d7e4664a9801593F98d1c5"
2281
+ ],
2282
+ "label": [
2283
+ "Withdraw {{tokenSymbol({{parameters.chainId}}, {{parameters.asset}})}} from Aave"
2284
+ ],
2285
+ "labelNotAuthorized": [
2286
+ "Transfer {{tokenSymbol({{parameters.chainId}}, {{parameters.asset}})}}"
2287
+ ]
2288
+ },
2289
+ "blockId": 100021,
2290
+ "image": "https://otomato-sdk-images.s3.eu-west-1.amazonaws.com/aave.jpg"
2291
+ }
2106
2292
  }
2107
2293
  },
2108
2294
  "SWAP": {
@@ -38,7 +38,7 @@ const createETHFearAndGreedBuy = () => __awaiter(void 0, void 0, void 0, functio
38
38
  const chain = CHAINS.MODE;
39
39
  odosAction.setChainId(chain);
40
40
  odosAction.setParams("tokenIn", getTokenFromSymbol(chain, 'USDC').contractAddress);
41
- odosAction.setParams("tokenOut", getTokenFromSymbol(chain, 'sUSDE').contractAddress);
41
+ odosAction.setParams("tokenOut", getTokenFromSymbol(chain, 'WETH').contractAddress);
42
42
  odosAction.setParams("amount", yield convertToTokenUnitsFromSymbol(100, chain, 'USDC'));
43
43
  odosAction.setPosition(400, 240);
44
44
  const edge = new Edge({ source: trigger, target: odosAction });
@@ -61,7 +61,7 @@ const createETHFearAndGreedCapitalEfficientBuy = () => __awaiter(void 0, void 0,
61
61
  odosAction.setChainId(chain);
62
62
  odosAction.setParams("tokenIn", getTokenFromSymbol(chain, tokenIn).contractAddress);
63
63
  odosAction.setParams("tokenOut", getTokenFromSymbol(chain, tokenOut).contractAddress);
64
- odosAction.setParams("amount", /*ionicWithdraw.getParameterVariableName('amount')*/ yield convertToTokenUnitsFromSymbol(1, chain, tokenIn));
64
+ odosAction.setParams("amount", ionicWithdraw.getParameterVariableName('amount'));
65
65
  odosAction.setPosition(400, 360);
66
66
  const ionicDeposit = new Action(ACTIONS.LENDING.IONIC.DEPOSIT);
67
67
  ionicDeposit.setChainId(chain);
@@ -2,4 +2,5 @@ export const CHAINS = {
2
2
  ALL: 0,
3
3
  ETHEREUM: 1,
4
4
  MODE: 34443,
5
+ BASE: 8453
5
6
  };
@@ -208,6 +208,15 @@ export const TOKENS = {
208
208
  decimals: 18,
209
209
  image: null
210
210
  },
211
+ ],
212
+ 8453: [
213
+ {
214
+ contractAddress: "0x833589fcd6edb6e08f4c7c32d4f71b54bda02913",
215
+ name: "USDC",
216
+ symbol: "USDC",
217
+ decimals: 6,
218
+ image: "https://static.debank.com/image/coin/logo_url/usdc/e87790bfe0b3f2ea855dc29069b38818.png"
219
+ }
211
220
  ]
212
221
  };
213
222
  export const NFTS = {
@@ -1,4 +1,4 @@
1
- export const SDK_VERSION = '1.5.82';
1
+ export const SDK_VERSION = '2.0.2';
2
2
  export function compareVersions(v1, v2) {
3
3
  // Split the version strings into parts
4
4
  const v1Parts = v1.split('.').map(Number);
@@ -0,0 +1,17 @@
1
+ export class Note {
2
+ constructor(text, position) {
3
+ this.id = Date.now().toString(); // Assign the current timestamp as the ID
4
+ this.text = text;
5
+ this.position = position;
6
+ }
7
+ setPosition(x, y) {
8
+ this.position = { x, y };
9
+ }
10
+ toJSON() {
11
+ return {
12
+ id: this.id,
13
+ text: this.text,
14
+ position: this.position,
15
+ };
16
+ }
17
+ }
@@ -16,6 +16,7 @@ export class Workflow {
16
16
  this.dateCreated = null;
17
17
  this.dateModified = null;
18
18
  this.executionId = null;
19
+ this.notes = [];
19
20
  this.name = name;
20
21
  this.nodes = nodes;
21
22
  this.edges = edges;
@@ -49,6 +50,35 @@ export class Workflow {
49
50
  getState() {
50
51
  return this.state;
51
52
  }
53
+ // Add a new note to the workflow
54
+ addNote(note) {
55
+ this.notes.push(note);
56
+ }
57
+ // Update an existing note by ID
58
+ updateNote(noteId, newText, newPosition) {
59
+ const note = this.notes.find(n => n.id === noteId);
60
+ if (note) {
61
+ note.text = newText;
62
+ note.position = newPosition;
63
+ }
64
+ else {
65
+ throw new Error(`Note with id ${noteId} not found`);
66
+ }
67
+ }
68
+ // Delete a note by ID
69
+ deleteNote(noteId) {
70
+ const index = this.notes.findIndex(n => n.id === noteId);
71
+ if (index !== -1) {
72
+ this.notes.splice(index, 1);
73
+ }
74
+ else {
75
+ throw new Error(`Note with id ${noteId} not found`);
76
+ }
77
+ }
78
+ // Retrieve notes as JSON to include them in the toJSON method
79
+ getNotes() {
80
+ return this.notes.map(note => note.toJSON());
81
+ }
52
82
  toJSON() {
53
83
  return {
54
84
  id: this.id,
@@ -59,6 +89,7 @@ export class Workflow {
59
89
  executionId: this.executionId,
60
90
  nodes: this.nodes.map(node => node.toJSON()),
61
91
  edges: this.edges.map(edge => edge.toJSON()),
92
+ notes: this.getNotes(), // Include notes
62
93
  };
63
94
  }
64
95
  create() {
@@ -600,6 +600,28 @@ export declare const ACTIONS: {
600
600
  CONDITION: {
601
601
  description: string;
602
602
  image: string;
603
+ IF: {
604
+ name: string;
605
+ type: number;
606
+ description: string;
607
+ parameters: Parameter[];
608
+ examples: never[];
609
+ blockId: number;
610
+ image: string;
611
+ };
612
+ };
613
+ SPLIT: {
614
+ description: string;
615
+ image: string;
616
+ SPLIT: {
617
+ name: string;
618
+ type: number;
619
+ description: string;
620
+ parameters: Parameter[];
621
+ examples: never[];
622
+ blockId: number;
623
+ image: string;
624
+ };
603
625
  };
604
626
  };
605
627
  NOTIFICATIONS: {
@@ -665,7 +687,7 @@ export declare const ACTIONS: {
665
687
  content: string;
666
688
  };
667
689
  };
668
- examples: never[];
690
+ examples: {}[];
669
691
  blockId: number;
670
692
  image: string;
671
693
  };
@@ -910,6 +932,53 @@ export declare const ACTIONS: {
910
932
  chains: number[];
911
933
  image: string;
912
934
  };
935
+ AAVE: {
936
+ description: string;
937
+ chains: number[];
938
+ image: string;
939
+ SUPPLY: {
940
+ name: string;
941
+ description: string;
942
+ type: number;
943
+ method: string;
944
+ contractAddress: string;
945
+ parameters: Parameter[];
946
+ requiredApprovals: {
947
+ address: string;
948
+ amount: string;
949
+ to: string;
950
+ }[];
951
+ output: {
952
+ transactionHash: string;
953
+ };
954
+ permissions: {
955
+ approvedTargets: string[];
956
+ label: string[];
957
+ labelNotAuthorized: string[];
958
+ };
959
+ blockId: number;
960
+ image: string;
961
+ };
962
+ WITHDRAW: {
963
+ name: string;
964
+ description: string;
965
+ type: number;
966
+ method: string;
967
+ contractAddress: string;
968
+ parameters: Parameter[];
969
+ output: {
970
+ transactionHash: string;
971
+ amountWithdrawn: string;
972
+ };
973
+ permissions: {
974
+ approvedTargets: string[];
975
+ label: string[];
976
+ labelNotAuthorized: string[];
977
+ };
978
+ blockId: number;
979
+ image: string;
980
+ };
981
+ };
913
982
  };
914
983
  SWAP: {
915
984
  ODOS: {
@@ -2,4 +2,5 @@ export declare const CHAINS: {
2
2
  ALL: number;
3
3
  ETHEREUM: number;
4
4
  MODE: number;
5
+ BASE: number;
5
6
  };
@@ -1,2 +1,2 @@
1
- export declare const SDK_VERSION = "1.5.82";
1
+ export declare const SDK_VERSION = "2.0.2";
2
2
  export declare function compareVersions(v1: string, v2: string): number;
@@ -0,0 +1,13 @@
1
+ import { Position } from "./Node";
2
+ export declare class Note {
3
+ id: string;
4
+ text: string;
5
+ position: Position;
6
+ constructor(text: string, position: Position);
7
+ setPosition(x: number, y: number): void;
8
+ toJSON(): {
9
+ id: string;
10
+ text: string;
11
+ position: Position;
12
+ };
13
+ }
@@ -1,6 +1,7 @@
1
- import { Node } from './Node.js';
1
+ import { Node, Position } from './Node.js';
2
2
  import { Edge } from './Edge.js';
3
3
  import { SessionKeyPermission } from './SessionKeyPermission.js';
4
+ import { Note } from './Note.js';
4
5
  export type WorkflowState = 'inactive' | 'active' | 'failed' | 'completed' | 'waiting';
5
6
  export declare class Workflow {
6
7
  id: string | null;
@@ -11,6 +12,7 @@ export declare class Workflow {
11
12
  dateCreated: string | null;
12
13
  dateModified: string | null;
13
14
  executionId: string | null;
15
+ notes: Note[];
14
16
  constructor(name?: string, nodes?: Node[], edges?: Edge[]);
15
17
  setName(name: string): void;
16
18
  addNode(node: Node): void;
@@ -19,6 +21,14 @@ export declare class Workflow {
19
21
  updateEdge(edgeId: string, newEdge: Edge): void;
20
22
  addEdges(edges: Edge[]): void;
21
23
  getState(): WorkflowState;
24
+ addNote(note: Note): void;
25
+ updateNote(noteId: string, newText: string, newPosition: Position): void;
26
+ deleteNote(noteId: string): void;
27
+ getNotes(): {
28
+ id: string | null;
29
+ text: string;
30
+ position: Position;
31
+ }[];
22
32
  toJSON(): {
23
33
  id: string | null;
24
34
  name: string;
@@ -32,6 +42,11 @@ export declare class Workflow {
32
42
  edges: {
33
43
  [key: string]: any;
34
44
  }[];
45
+ notes: {
46
+ id: string | null;
47
+ text: string;
48
+ position: Position;
49
+ }[];
35
50
  };
36
51
  create(): Promise<{
37
52
  success: boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "otomato-sdk",
3
- "version": "2.0.0",
3
+ "version": "2.0.2",
4
4
  "description": "An SDK for building and managing automations on Otomato",
5
5
  "main": "dist/src/index.js",
6
6
  "types": "dist/types/src/index.d.ts",