otomato-sdk 1.5.28 → 1.5.30

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.
@@ -961,7 +961,7 @@ export const ACTIONS = {
961
961
  "CORE": {
962
962
  "DELAY": {
963
963
  "description": "Set of functions to delay the executions of the following blocks.",
964
- "image": "https://otomato-sdk-images.s3.eu-west-1.amazonaws.com/discord.png",
964
+ "image": "https://otomato-sdk-images.s3.eu-west-1.amazonaws.com/delay.png",
965
965
  "WAIT_FOR": {
966
966
  "name": "Wait for",
967
967
  "type": 2,
@@ -991,7 +991,7 @@ export const ACTIONS = {
991
991
  }
992
992
  ],
993
993
  "blockId": 100010,
994
- "image": "https://otomato-sdk-images.s3.eu-west-1.amazonaws.com/discord.png"
994
+ "image": "https://otomato-sdk-images.s3.eu-west-1.amazonaws.com/delay.png"
995
995
  },
996
996
  "WAIT_UNTIL": {
997
997
  "name": "Wait until",
@@ -1022,7 +1022,7 @@ export const ACTIONS = {
1022
1022
  }
1023
1023
  ],
1024
1024
  "blockId": 100011,
1025
- "image": "https://otomato-sdk-images.s3.eu-west-1.amazonaws.com/discord.png"
1025
+ "image": "https://otomato-sdk-images.s3.eu-west-1.amazonaws.com/delay.png"
1026
1026
  }
1027
1027
  }
1028
1028
  },
@@ -1264,6 +1264,7 @@ export const ACTIONS = {
1264
1264
  "type": "erc20",
1265
1265
  "description": "The token to deposit",
1266
1266
  "mandatory": true,
1267
+ "enum": "\n (env) => {\n if (!env.parameters.chainId)\n throw new Error('You need to provide the chainId first');\n \n const availableTokens = {\n \"34443\": [\n \"0xf0F161fDA2712DB8b566946122a5af183995e2eD\",\n \"0xd988097fb8612cc24eeC14542bC03424c656005f\",\n \"0x2416092f143378750bb29b79eD961ab195CcEea5\",\n \"0x4200000000000000000000000000000000000006\",\n \"0xcDd475325D6F564d27247D1DddBb0DAc6fA0a5CF\",\n \"0x80137510979822322193FC997d400D5A6C747bf7\",\n \"0xe7903B1F75C534Dd8159b313d92cDCfbC62cB3Cd\",\n \"0x04C0599Ae5A44757c0af6F9eC3b93da8976c150A\",\n \"0x59889b7021243dB5B1e065385F918316cD90D46c\"\n ]\n};\n const chainId = env.parameters.chainId;\n return availableTokens[chainId] || [];\n }",
1267
1268
  "category": 0
1268
1269
  },
1269
1270
  {
@@ -1301,7 +1302,7 @@ export const ACTIONS = {
1301
1302
  "requiredApprovals": [
1302
1303
  {
1303
1304
  "address": "{{parameters.tokenToDeposit}}",
1304
- "amount": "{{parameters.abiParams.amount}}",
1305
+ "amount": "{{parameters.abi.parameters.amount}}",
1305
1306
  "to": "{{before.contractAddress}}"
1306
1307
  }
1307
1308
  ],
@@ -1341,6 +1342,7 @@ export const ACTIONS = {
1341
1342
  "type": "erc20",
1342
1343
  "description": "The token to withdraw",
1343
1344
  "mandatory": true,
1345
+ "enum": "\n (env) => {\n if (!env.parameters.chainId)\n throw new Error('You need to provide the chainId first');\n \n const availableTokens = {\n \"34443\": [\n \"0xf0F161fDA2712DB8b566946122a5af183995e2eD\",\n \"0xd988097fb8612cc24eeC14542bC03424c656005f\",\n \"0x2416092f143378750bb29b79eD961ab195CcEea5\",\n \"0x4200000000000000000000000000000000000006\",\n \"0xcDd475325D6F564d27247D1DddBb0DAc6fA0a5CF\",\n \"0x80137510979822322193FC997d400D5A6C747bf7\",\n \"0xe7903B1F75C534Dd8159b313d92cDCfbC62cB3Cd\",\n \"0x04C0599Ae5A44757c0af6F9eC3b93da8976c150A\",\n \"0x59889b7021243dB5B1e065385F918316cD90D46c\"\n ]\n};\n const chainId = env.parameters.chainId;\n return availableTokens[chainId] || [];\n }",
1344
1346
  "category": 0
1345
1347
  },
1346
1348
  {
@@ -1411,6 +1413,7 @@ export const ACTIONS = {
1411
1413
  "type": "erc20",
1412
1414
  "description": "The token to borrow",
1413
1415
  "mandatory": true,
1416
+ "enum": "\n (env) => {\n if (!env.parameters.chainId)\n throw new Error('You need to provide the chainId first');\n \n const availableTokens = {\n \"34443\": [\n \"0xf0F161fDA2712DB8b566946122a5af183995e2eD\",\n \"0xd988097fb8612cc24eeC14542bC03424c656005f\",\n \"0x2416092f143378750bb29b79eD961ab195CcEea5\",\n \"0x4200000000000000000000000000000000000006\",\n \"0xcDd475325D6F564d27247D1DddBb0DAc6fA0a5CF\",\n \"0x80137510979822322193FC997d400D5A6C747bf7\",\n \"0xe7903B1F75C534Dd8159b313d92cDCfbC62cB3Cd\",\n \"0x04C0599Ae5A44757c0af6F9eC3b93da8976c150A\",\n \"0x59889b7021243dB5B1e065385F918316cD90D46c\"\n ]\n};\n const chainId = env.parameters.chainId;\n return availableTokens[chainId] || [];\n }",
1414
1417
  "category": 0
1415
1418
  },
1416
1419
  {
@@ -1481,6 +1484,7 @@ export const ACTIONS = {
1481
1484
  "type": "erc20",
1482
1485
  "description": "The token to repay",
1483
1486
  "mandatory": true,
1487
+ "enum": "\n (env) => {\n if (!env.parameters.chainId)\n throw new Error('You need to provide the chainId first');\n \n const availableTokens = {\n \"34443\": [\n \"0xf0F161fDA2712DB8b566946122a5af183995e2eD\",\n \"0xd988097fb8612cc24eeC14542bC03424c656005f\",\n \"0x2416092f143378750bb29b79eD961ab195CcEea5\",\n \"0x4200000000000000000000000000000000000006\",\n \"0xcDd475325D6F564d27247D1DddBb0DAc6fA0a5CF\",\n \"0x80137510979822322193FC997d400D5A6C747bf7\",\n \"0xe7903B1F75C534Dd8159b313d92cDCfbC62cB3Cd\",\n \"0x04C0599Ae5A44757c0af6F9eC3b93da8976c150A\",\n \"0x59889b7021243dB5B1e065385F918316cD90D46c\"\n ]\n};\n const chainId = env.parameters.chainId;\n return availableTokens[chainId] || [];\n }",
1484
1488
  "category": 0
1485
1489
  },
1486
1490
  {
@@ -1518,7 +1522,7 @@ export const ACTIONS = {
1518
1522
  "requiredApprovals": [
1519
1523
  {
1520
1524
  "address": "{{parameters.tokenToRepay}}",
1521
- "amount": "{{parameters.abiParams.amount}}",
1525
+ "amount": "{{parameters.abi.parameters.amount}}",
1522
1526
  "to": "{{before.contractAddress}}"
1523
1527
  }
1524
1528
  ],
@@ -1556,7 +1560,7 @@ export const ACTIONS = {
1556
1560
  "requiredApprovals": [
1557
1561
  {
1558
1562
  "address": "{{parameters.tokenIn}}",
1559
- "amount": "{{parameters.value}}",
1563
+ "amount": "{{parameters.amount}}",
1560
1564
  "to": "0x7E15EB462cdc67Cf92Af1f7102465a8F8c784874"
1561
1565
  }
1562
1566
  ],
@@ -42,7 +42,7 @@ const createSUsdeYieldBuy = () => __awaiter(void 0, void 0, void 0, function* ()
42
42
  trigger.setCondition('gt');
43
43
  trigger.setComparisonValue(20);
44
44
  trigger.setPosition(400, 120);
45
- const odosAction = new Action(ACTIONS.NOTIFICATIONS.TELEGRAM.SEND_MESSAGE);
45
+ const odosAction = new Action(ACTIONS.SWAP.ODOS.SWAP);
46
46
  const chain = CHAINS.ETHEREUM;
47
47
  odosAction.setChainId(chain);
48
48
  odosAction.setParams("tokenIn", getTokenFromSymbol(chain, 'USDC').contractAddress);
@@ -57,7 +57,7 @@ const createSusdeYieldShortEna = () => __awaiter(void 0, void 0, void 0, functio
57
57
  trigger.setCondition('lt');
58
58
  trigger.setComparisonValue(0);
59
59
  trigger.setPosition(400, 120);
60
- const odosAction = new Action(ACTIONS.NOTIFICATIONS.TELEGRAM.SEND_MESSAGE);
60
+ const odosAction = new Action(ACTIONS.SWAP.ODOS.SWAP);
61
61
  const chain = CHAINS.ETHEREUM;
62
62
  odosAction.setChainId(chain);
63
63
  odosAction.setParams("tokenIn", getTokenFromSymbol(chain, 'USDC').contractAddress);
@@ -7,7 +7,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
7
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
8
8
  });
9
9
  };
10
- import { validateType } from '../utils/typeValidator.js';
10
+ import { validateType, isANumber } from '../utils/typeValidator.js';
11
11
  import { apiServices } from '../services/ApiService.js';
12
12
  let nodeCounter = 0;
13
13
  const generatedRefs = new Set();
@@ -72,6 +72,12 @@ export class Node {
72
72
  setParameter(key, value) {
73
73
  if (key in this.parameters) {
74
74
  const param = this.parameters[key];
75
+ try {
76
+ // if the user pass '100000n' for a number, we transform it to Bigints
77
+ if (isANumber(param.type) && (value === null || value === void 0 ? void 0 : value.endsWith('n')))
78
+ value = BigInt(value.substring(0, value.length - 1));
79
+ }
80
+ catch (e) { }
75
81
  if (validateType(param.type, value)) {
76
82
  this.parameters[key].value = value;
77
83
  }
@@ -1,4 +1,25 @@
1
1
  import { ethers } from 'ethers';
2
+ export function isANumber(type) {
3
+ switch (type) {
4
+ case 'integer':
5
+ return true;
6
+ case 'int8':
7
+ case 'int16':
8
+ case 'int32':
9
+ case 'int64':
10
+ case 'int128':
11
+ case 'int256':
12
+ return true;
13
+ case 'uint8':
14
+ case 'uint16':
15
+ case 'uint32':
16
+ case 'uint64':
17
+ case 'uint128':
18
+ case 'uint256':
19
+ return true;
20
+ default: return false;
21
+ }
22
+ }
2
23
  export function validateType(expectedType, value) {
3
24
  switch (expectedType) {
4
25
  case 'bool':
@@ -1,3 +1,4 @@
1
+ export declare function isANumber(type: string): boolean;
1
2
  export declare function validateType(expectedType: string, value: any): boolean;
2
3
  export declare function typeIsNumber(type: string): boolean;
3
4
  export declare function isAddress(value: string): boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "otomato-sdk",
3
- "version": "1.5.28",
3
+ "version": "1.5.30",
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",