otomato-sdk 1.5.36 → 1.5.39

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.
@@ -470,7 +470,7 @@ export const TRIGGERS = {
470
470
  34443
471
471
  ],
472
472
  "image": "https://otomato-sdk-images.s3.eu-west-1.amazonaws.com/ionic.jpg",
473
- "DEPOSIT": {
473
+ "LENDING_RATE": {
474
474
  "name": "Lending rate",
475
475
  "description": "Get the lending rate of any asset on Ionic",
476
476
  "type": 1,
@@ -1028,6 +1028,24 @@ export const TRIGGERS = {
1028
1028
  "image": "https://otomato-sdk-images.s3.eu-west-1.amazonaws.com/blackrock.jpeg"
1029
1029
  }
1030
1030
  }
1031
+ },
1032
+ "NFTS": {
1033
+ "BLUR": {
1034
+ "description": "The NFT marketplace for pro traders",
1035
+ "chains": [
1036
+ 1
1037
+ ],
1038
+ "image": "https://otomato-sdk-images.s3.eu-west-1.amazonaws.com/blur.jpg"
1039
+ }
1040
+ },
1041
+ "PRE_MARKET": {
1042
+ "WHALES_MARKET": {
1043
+ "description": "Trade Airdrop allocations and points",
1044
+ "chains": [
1045
+ 1
1046
+ ],
1047
+ "image": "https://otomato-sdk-images.s3.eu-west-1.amazonaws.com/whalesmarket.png"
1048
+ }
1031
1049
  }
1032
1050
  };
1033
1051
  export const ACTIONS = {
@@ -1097,6 +1115,126 @@ export const ACTIONS = {
1097
1115
  "blockId": 100011,
1098
1116
  "image": "https://otomato-sdk-images.s3.eu-west-1.amazonaws.com/delay.png"
1099
1117
  }
1118
+ },
1119
+ "SWAP": {
1120
+ "description": "Swap two assets using the best market rates accross multiple pools",
1121
+ "chains": [
1122
+ 34443
1123
+ ],
1124
+ "image": "https://otomato-sdk-images.s3.eu-west-1.amazonaws.com/delay.png",
1125
+ "SWAP": {
1126
+ "name": "Swap",
1127
+ "description": "Swap two assets using the best market rates accross multiple pools",
1128
+ "type": 1,
1129
+ "contractAddress": "0x7E15EB462cdc67Cf92Af1f7102465a8F8c784874",
1130
+ "requiredApprovals": [
1131
+ {
1132
+ "address": "{{parameters.tokenIn}}",
1133
+ "amount": "{{parameters.amount}}",
1134
+ "to": "0x7E15EB462cdc67Cf92Af1f7102465a8F8c784874"
1135
+ }
1136
+ ],
1137
+ "checks": [
1138
+ {
1139
+ "type": 0,
1140
+ "chainId": "{{parameters.chainId}}",
1141
+ "contractAddress": "{{parameters.tokenIn}}",
1142
+ "amount": "{{parameters.amount}}"
1143
+ }
1144
+ ],
1145
+ "output": {
1146
+ "amountIn": "uint256",
1147
+ "tokenIn": "erc20",
1148
+ "amountOut": "uint256",
1149
+ "tokenOut": "erc20",
1150
+ "transactionHash": "string"
1151
+ },
1152
+ "parameters": [
1153
+ {
1154
+ "key": "chainId",
1155
+ "type": "chainId",
1156
+ "description": "Chain ID of the network",
1157
+ "mandatory": true,
1158
+ "category": 0
1159
+ },
1160
+ {
1161
+ "key": "tokenIn",
1162
+ "type": "erc20",
1163
+ "description": "Token to sell",
1164
+ "mandatory": true,
1165
+ "category": 0
1166
+ },
1167
+ {
1168
+ "key": "tokenOut",
1169
+ "type": "erc20",
1170
+ "description": "Token to buy",
1171
+ "mandatory": true,
1172
+ "category": 0
1173
+ },
1174
+ {
1175
+ "key": "amount",
1176
+ "type": "uint256",
1177
+ "description": "Amount to sell",
1178
+ "mandatory": true,
1179
+ "category": 0,
1180
+ "erc20FormattedAmount": {
1181
+ "contractAddress": "0x7E15EB462cdc67Cf92Af1f7102465a8F8c784874",
1182
+ "chain": "{{parameters.chainId}}"
1183
+ }
1184
+ },
1185
+ {
1186
+ "key": "slippage",
1187
+ "type": "percentage",
1188
+ "description": "The maximum allowable difference between the expected price and the actual price at the time of execution, expressed as a percentage. This protects the transaction from significant price fluctuations.",
1189
+ "value": 0.3,
1190
+ "mandatory": true,
1191
+ "category": 1
1192
+ },
1193
+ ],
1194
+ "examples": [
1195
+ {
1196
+ "name": "Swap USDC to WETH",
1197
+ "description": "Swap 100 USDC to WETH on Mode Network using Odos",
1198
+ "parameters": [
1199
+ {
1200
+ "key": "chainId",
1201
+ "value": 34443
1202
+ },
1203
+ {
1204
+ "key": "tokenIn",
1205
+ "value": "0xd988097fb8612cc24eeC14542bC03424c656005f"
1206
+ },
1207
+ {
1208
+ "key": "tokenOut",
1209
+ "value": "0x4200000000000000000000000000000000000006"
1210
+ },
1211
+ {
1212
+ "key": "amount",
1213
+ "value": "100000000n"
1214
+ },
1215
+ {
1216
+ "key": "slippage",
1217
+ "value": 0.3
1218
+ }
1219
+ ]
1220
+ }
1221
+ ],
1222
+ "permissions": {
1223
+ "approvedTargets": [
1224
+ "0x7E15EB462cdc67Cf92Af1f7102465a8F8c784874",
1225
+ "{{parameters.tokenIn}}"
1226
+ ],
1227
+ "label": [
1228
+ "Swap {{tokenSymbol({{parameters.chainId}}, {{parameters.tokenIn}})}} to {{tokenSymbol({{parameters.chainId}}, {{parameters.tokenOut}})}}"
1229
+ ],
1230
+ "labelNotAuthorized": [
1231
+ "Transfer ETH"
1232
+ ]
1233
+ },
1234
+ "duplicate": true,
1235
+ "blockId": 100005,
1236
+ "image": "https://otomato-sdk-images.s3.eu-west-1.amazonaws.com/delay.png"
1237
+ }
1100
1238
  }
1101
1239
  },
1102
1240
  "NOTIFICATIONS": {
@@ -1187,13 +1325,6 @@ export const ACTIONS = {
1187
1325
  "message": "string"
1188
1326
  },
1189
1327
  "parameters": [
1190
- {
1191
- "key": "webhook",
1192
- "type": "url",
1193
- "description": "The webhook URL for the Telegram bot",
1194
- "mandatory": true,
1195
- "private": true
1196
- },
1197
1328
  {
1198
1329
  "key": "message",
1199
1330
  "type": "paragraph",
@@ -1227,7 +1358,7 @@ export const ACTIONS = {
1227
1358
  "ERC20": {
1228
1359
  "description": "The most used standard for tokens on ethereum compatible blockchains",
1229
1360
  "chains": [
1230
- 0
1361
+ 34443
1231
1362
  ],
1232
1363
  "image": "https://otomato-sdk-images.s3.eu-west-1.amazonaws.com/ethereum.webp",
1233
1364
  "TRANSFER": {
@@ -1272,6 +1403,14 @@ export const ACTIONS = {
1272
1403
  "category": 0
1273
1404
  },
1274
1405
  ],
1406
+ "checks": [
1407
+ {
1408
+ "type": 0,
1409
+ "chainId": "{{parameters.chainId}}",
1410
+ "contractAddress": "{{parameters.contractAddress}}",
1411
+ "amount": "{{parameters.abi.parameters.amount}}"
1412
+ }
1413
+ ],
1275
1414
  "examples": [
1276
1415
  {
1277
1416
  "name": "Transfer USDC",
@@ -1372,6 +1511,14 @@ export const ACTIONS = {
1372
1511
  ]
1373
1512
  }
1374
1513
  ],
1514
+ "checks": [
1515
+ {
1516
+ "type": 0,
1517
+ "chainId": "{{parameters.chainId}}",
1518
+ "contractAddress": "{{parameters.tokenToDeposit}}",
1519
+ "amount": "{{parameters.abi.parameters.amount}}"
1520
+ }
1521
+ ],
1375
1522
  "requiredApprovals": [
1376
1523
  {
1377
1524
  "address": "{{parameters.tokenToDeposit}}",
@@ -1379,6 +1526,7 @@ export const ACTIONS = {
1379
1526
  "to": "{{before.contractAddress}}"
1380
1527
  }
1381
1528
  ],
1529
+ "before": "\n async (env) => {\n const otomatoSdk = await import('otomato-sdk');\n \n if (!env.parameters.chainId)\n throw new Error('You need to provide the chainId first');\n \n const getIonicTokenFromToken = (chain, tokenAddress) => {\n const CHAINS = otomatoSdk.CHAINS;\n if (chain == CHAINS.MODE) {\n switch (tokenAddress.toLowerCase()) {\n case otomatoSdk.getTokenFromSymbol(CHAINS.MODE, 'USDT').contractAddress.toLowerCase():\n return '0x94812F2eEa03A49869f95e1b5868C6f3206ee3D3';\n case otomatoSdk.getTokenFromSymbol(CHAINS.MODE, 'USDC').contractAddress.toLowerCase():\n return '0x2BE717340023C9e14C1Bb12cb3ecBcfd3c3fB038';\n case otomatoSdk.getTokenFromSymbol(CHAINS.MODE, 'ezETH').contractAddress.toLowerCase():\n return '0x59e710215d45F584f44c0FEe83DA6d43D762D857';\n case otomatoSdk.getTokenFromSymbol(CHAINS.MODE, 'WETH').contractAddress.toLowerCase():\n return '0x71ef7EDa2Be775E5A7aa8afD02C45F059833e9d2';\n case otomatoSdk.getTokenFromSymbol(CHAINS.MODE, 'WBTC').contractAddress.toLowerCase():\n return '0xd70254C3baD29504789714A7c69d60Ec1127375C';\n case otomatoSdk.getTokenFromSymbol(CHAINS.MODE, 'STONE').contractAddress.toLowerCase():\n return '0x959FA710CCBb22c7Ce1e59Da82A247e686629310';\n case otomatoSdk.getTokenFromSymbol(CHAINS.MODE, 'wrsETH').contractAddress.toLowerCase():\n return '0x49950319aBE7CE5c3A6C90698381b45989C99b46';\n case otomatoSdk.getTokenFromSymbol(CHAINS.MODE, 'weETH.mode').contractAddress.toLowerCase():\n return '0xA0D844742B4abbbc43d8931a6Edb00C56325aA18';\n case otomatoSdk.getTokenFromSymbol(CHAINS.MODE, 'M-BTC').contractAddress.toLowerCase():\n return '0x19F245782b1258cf3e11Eda25784A378cC18c108';\n\n default: throw new Error('This asset is not available on Ionic');\n }\n }\n}\n \n let ionicTokenContractAddress = getIonicTokenFromToken(\n env.parameters.chainId,\n env.parameters.tokenToDeposit.toLowerCase()\n );\n return {\n contractAddress: ionicTokenContractAddress\n };\n }",
1382
1530
  "output": {
1383
1531
  "transactionHash": "string"
1384
1532
  },
@@ -1394,6 +1542,23 @@ export const ACTIONS = {
1394
1542
  "Transfer {{tokenSymbol({{parameters.chainId}}, {{parameters.tokenToDeposit}})}}"
1395
1543
  ]
1396
1544
  },
1545
+ "batchWith": [
1546
+ {
1547
+ "id": 100012,
1548
+ "type": 1,
1549
+ "conditions": [],
1550
+ "parameters": {
1551
+ "chainId": "{{parameters.chainId}}",
1552
+ "abi": {
1553
+ "parameters": {
1554
+ "tokens": [
1555
+ "{{parameters.tokenToDeposit}}"
1556
+ ]
1557
+ }
1558
+ }
1559
+ }
1560
+ }
1561
+ ],
1397
1562
  "blockId": 100006,
1398
1563
  "image": "https://otomato-sdk-images.s3.eu-west-1.amazonaws.com/ionic.jpg"
1399
1564
  },
@@ -1451,6 +1616,7 @@ export const ACTIONS = {
1451
1616
  }
1452
1617
  ],
1453
1618
  "requiredApprovals": [],
1619
+ "before": "\n async (env) => {\n const otomatoSdk = await import('otomato-sdk');\n \n if (!env.parameters.chainId)\n throw new Error('You need to provide the chainId first');\n \n const getIonicTokenFromToken = (chain, tokenAddress) => {\n const CHAINS = otomatoSdk.CHAINS;\n if (chain == CHAINS.MODE) {\n switch (tokenAddress.toLowerCase()) {\n case otomatoSdk.getTokenFromSymbol(CHAINS.MODE, 'USDT').contractAddress.toLowerCase():\n return '0x94812F2eEa03A49869f95e1b5868C6f3206ee3D3';\n case otomatoSdk.getTokenFromSymbol(CHAINS.MODE, 'USDC').contractAddress.toLowerCase():\n return '0x2BE717340023C9e14C1Bb12cb3ecBcfd3c3fB038';\n case otomatoSdk.getTokenFromSymbol(CHAINS.MODE, 'ezETH').contractAddress.toLowerCase():\n return '0x59e710215d45F584f44c0FEe83DA6d43D762D857';\n case otomatoSdk.getTokenFromSymbol(CHAINS.MODE, 'WETH').contractAddress.toLowerCase():\n return '0x71ef7EDa2Be775E5A7aa8afD02C45F059833e9d2';\n case otomatoSdk.getTokenFromSymbol(CHAINS.MODE, 'WBTC').contractAddress.toLowerCase():\n return '0xd70254C3baD29504789714A7c69d60Ec1127375C';\n case otomatoSdk.getTokenFromSymbol(CHAINS.MODE, 'STONE').contractAddress.toLowerCase():\n return '0x959FA710CCBb22c7Ce1e59Da82A247e686629310';\n case otomatoSdk.getTokenFromSymbol(CHAINS.MODE, 'wrsETH').contractAddress.toLowerCase():\n return '0x49950319aBE7CE5c3A6C90698381b45989C99b46';\n case otomatoSdk.getTokenFromSymbol(CHAINS.MODE, 'weETH.mode').contractAddress.toLowerCase():\n return '0xA0D844742B4abbbc43d8931a6Edb00C56325aA18';\n case otomatoSdk.getTokenFromSymbol(CHAINS.MODE, 'M-BTC').contractAddress.toLowerCase():\n return '0x19F245782b1258cf3e11Eda25784A378cC18c108';\n\n default: throw new Error('This asset is not available on Ionic');\n }\n }\n}\n \n let ionicTokenContractAddress = getIonicTokenFromToken(\n env.parameters.chainId,\n env.parameters.tokenToWithdraw.toLowerCase()\n );\n return {\n contractAddress: ionicTokenContractAddress\n };\n }",
1454
1620
  "output": {
1455
1621
  "transactionHash": "string"
1456
1622
  },
@@ -1522,6 +1688,7 @@ export const ACTIONS = {
1522
1688
  }
1523
1689
  ],
1524
1690
  "requiredApprovals": [],
1691
+ "before": "\n async (env) => {\n const otomatoSdk = await import('otomato-sdk');\n \n if (!env.parameters.chainId)\n throw new Error('You need to provide the chainId first');\n \n const getIonicTokenFromToken = (chain, tokenAddress) => {\n const CHAINS = otomatoSdk.CHAINS;\n if (chain == CHAINS.MODE) {\n switch (tokenAddress.toLowerCase()) {\n case otomatoSdk.getTokenFromSymbol(CHAINS.MODE, 'USDT').contractAddress.toLowerCase():\n return '0x94812F2eEa03A49869f95e1b5868C6f3206ee3D3';\n case otomatoSdk.getTokenFromSymbol(CHAINS.MODE, 'USDC').contractAddress.toLowerCase():\n return '0x2BE717340023C9e14C1Bb12cb3ecBcfd3c3fB038';\n case otomatoSdk.getTokenFromSymbol(CHAINS.MODE, 'ezETH').contractAddress.toLowerCase():\n return '0x59e710215d45F584f44c0FEe83DA6d43D762D857';\n case otomatoSdk.getTokenFromSymbol(CHAINS.MODE, 'WETH').contractAddress.toLowerCase():\n return '0x71ef7EDa2Be775E5A7aa8afD02C45F059833e9d2';\n case otomatoSdk.getTokenFromSymbol(CHAINS.MODE, 'WBTC').contractAddress.toLowerCase():\n return '0xd70254C3baD29504789714A7c69d60Ec1127375C';\n case otomatoSdk.getTokenFromSymbol(CHAINS.MODE, 'STONE').contractAddress.toLowerCase():\n return '0x959FA710CCBb22c7Ce1e59Da82A247e686629310';\n case otomatoSdk.getTokenFromSymbol(CHAINS.MODE, 'wrsETH').contractAddress.toLowerCase():\n return '0x49950319aBE7CE5c3A6C90698381b45989C99b46';\n case otomatoSdk.getTokenFromSymbol(CHAINS.MODE, 'weETH.mode').contractAddress.toLowerCase():\n return '0xA0D844742B4abbbc43d8931a6Edb00C56325aA18';\n case otomatoSdk.getTokenFromSymbol(CHAINS.MODE, 'M-BTC').contractAddress.toLowerCase():\n return '0x19F245782b1258cf3e11Eda25784A378cC18c108';\n\n default: throw new Error('This asset is not available on Ionic');\n }\n }\n}\n \n let ionicTokenContractAddress = getIonicTokenFromToken(\n env.parameters.chainId,\n env.parameters.tokenToBorrow.toLowerCase()\n );\n return {\n contractAddress: ionicTokenContractAddress\n };\n }",
1525
1692
  "output": {
1526
1693
  "transactionHash": "string"
1527
1694
  },
@@ -1572,6 +1739,14 @@ export const ACTIONS = {
1572
1739
  }
1573
1740
  },
1574
1741
  ],
1742
+ "checks": [
1743
+ {
1744
+ "type": 0,
1745
+ "chainId": "{{parameters.chainId}}",
1746
+ "contractAddress": "{{parameters.tokenToRepay}}",
1747
+ "amount": "{{parameters.abi.parameters.amount}}"
1748
+ }
1749
+ ],
1575
1750
  "examples": [
1576
1751
  {
1577
1752
  "name": "Repay 100 USDT",
@@ -1599,6 +1774,7 @@ export const ACTIONS = {
1599
1774
  "to": "{{before.contractAddress}}"
1600
1775
  }
1601
1776
  ],
1777
+ "before": "\n async (env) => {\n const otomatoSdk = await import('otomato-sdk');\n \n if (!env.parameters.chainId)\n throw new Error('You need to provide the chainId first');\n \n const getIonicTokenFromToken = (chain, tokenAddress) => {\n const CHAINS = otomatoSdk.CHAINS;\n if (chain == CHAINS.MODE) {\n switch (tokenAddress.toLowerCase()) {\n case otomatoSdk.getTokenFromSymbol(CHAINS.MODE, 'USDT').contractAddress.toLowerCase():\n return '0x94812F2eEa03A49869f95e1b5868C6f3206ee3D3';\n case otomatoSdk.getTokenFromSymbol(CHAINS.MODE, 'USDC').contractAddress.toLowerCase():\n return '0x2BE717340023C9e14C1Bb12cb3ecBcfd3c3fB038';\n case otomatoSdk.getTokenFromSymbol(CHAINS.MODE, 'ezETH').contractAddress.toLowerCase():\n return '0x59e710215d45F584f44c0FEe83DA6d43D762D857';\n case otomatoSdk.getTokenFromSymbol(CHAINS.MODE, 'WETH').contractAddress.toLowerCase():\n return '0x71ef7EDa2Be775E5A7aa8afD02C45F059833e9d2';\n case otomatoSdk.getTokenFromSymbol(CHAINS.MODE, 'WBTC').contractAddress.toLowerCase():\n return '0xd70254C3baD29504789714A7c69d60Ec1127375C';\n case otomatoSdk.getTokenFromSymbol(CHAINS.MODE, 'STONE').contractAddress.toLowerCase():\n return '0x959FA710CCBb22c7Ce1e59Da82A247e686629310';\n case otomatoSdk.getTokenFromSymbol(CHAINS.MODE, 'wrsETH').contractAddress.toLowerCase():\n return '0x49950319aBE7CE5c3A6C90698381b45989C99b46';\n case otomatoSdk.getTokenFromSymbol(CHAINS.MODE, 'weETH.mode').contractAddress.toLowerCase():\n return '0xA0D844742B4abbbc43d8931a6Edb00C56325aA18';\n case otomatoSdk.getTokenFromSymbol(CHAINS.MODE, 'M-BTC').contractAddress.toLowerCase():\n return '0x19F245782b1258cf3e11Eda25784A378cC18c108';\n\n default: throw new Error('This asset is not available on Ionic');\n }\n }\n}\n \n let ionicTokenContractAddress = getIonicTokenFromToken(\n env.parameters.chainId,\n env.parameters.tokenToRepay.toLowerCase()\n );\n return {\n contractAddress: ionicTokenContractAddress\n };\n }",
1602
1778
  "output": {
1603
1779
  "transactionHash": "string"
1604
1780
  },
@@ -1615,7 +1791,59 @@ export const ACTIONS = {
1615
1791
  },
1616
1792
  "blockId": 100009,
1617
1793
  "image": "https://otomato-sdk-images.s3.eu-west-1.amazonaws.com/ionic.jpg"
1794
+ },
1795
+ "ENABLE_COLLATERAL": {
1796
+ "showInUI": false,
1797
+ "name": "Enable collaterals",
1798
+ "description": "Enable collateral to be able to borrow against it.",
1799
+ "type": 1,
1800
+ "method": "function enterMarkets(address[] tokens) returns (uint256[])",
1801
+ "contractAddress": "0xFB3323E24743Caf4ADD0fDCCFB268565c0685556",
1802
+ "parameters": [
1803
+ {
1804
+ "key": "chainId",
1805
+ "type": "chainId",
1806
+ "description": "Chain ID of the network",
1807
+ "mandatory": true,
1808
+ "category": 0
1809
+ },
1810
+ {
1811
+ "key": "abiParams.tokens",
1812
+ "type": "uint256",
1813
+ "description": "List of collaterals",
1814
+ "mandatory": true,
1815
+ "category": 0
1816
+ },
1817
+ ],
1818
+ "examples": [],
1819
+ "permissions": {
1820
+ "approvedTargets": [
1821
+ "0xFB3323E24743Caf4ADD0fDCCFB268565c0685556"
1822
+ ],
1823
+ "label": [
1824
+ "Borrow against {{tokenSymbol({{parameters.chainId}}, {{parameters.abiParams.tokens[0]}})}} on IONIC"
1825
+ ],
1826
+ "labelNotAuthorized": [
1827
+ "Transfer {{tokenSymbol({{parameters.chainId}}, {{parameters.abiParams.tokens[0]}})}}"
1828
+ ]
1829
+ },
1830
+ "blockId": 100012,
1831
+ "image": "https://otomato-sdk-images.s3.eu-west-1.amazonaws.com/ionic.jpg"
1618
1832
  }
1833
+ },
1834
+ "ETHER_FI": {
1835
+ "description": "Liquid restaking on Ethereum",
1836
+ "chains": [
1837
+ 34443
1838
+ ],
1839
+ "image": "https://otomato-sdk-images.s3.eu-west-1.amazonaws.com/etherfi.jpg"
1840
+ },
1841
+ "RENZO": {
1842
+ "description": "Liquid restaking on Ethereum",
1843
+ "chains": [
1844
+ 34443
1845
+ ],
1846
+ "image": "https://otomato-sdk-images.s3.eu-west-1.amazonaws.com/renzo.jpg"
1619
1847
  }
1620
1848
  },
1621
1849
  "SWAP": {
@@ -1637,6 +1865,14 @@ export const ACTIONS = {
1637
1865
  "to": "0x7E15EB462cdc67Cf92Af1f7102465a8F8c784874"
1638
1866
  }
1639
1867
  ],
1868
+ "checks": [
1869
+ {
1870
+ "type": 0,
1871
+ "chainId": "{{parameters.chainId}}",
1872
+ "contractAddress": "{{parameters.tokenIn}}",
1873
+ "amount": "{{parameters.amount}}"
1874
+ }
1875
+ ],
1640
1876
  "output": {
1641
1877
  "amountIn": "uint256",
1642
1878
  "tokenIn": "erc20",
@@ -1730,5 +1966,14 @@ export const ACTIONS = {
1730
1966
  "image": "https://otomato-sdk-images.s3.eu-west-1.amazonaws.com/odos.jpg"
1731
1967
  }
1732
1968
  }
1969
+ },
1970
+ "NFTS": {
1971
+ "BLUR": {
1972
+ "description": "The NFT marketplace for pro traders",
1973
+ "chains": [
1974
+ 1
1975
+ ],
1976
+ "image": "https://otomato-sdk-images.s3.eu-west-1.amazonaws.com/blur.jpg"
1977
+ }
1733
1978
  }
1734
1979
  };
@@ -16,13 +16,18 @@ export class Action extends Node {
16
16
  super(Object.assign(Object.assign({}, action), { class: 'action', parentInfo: findActionByBlockId(action.blockId).parentInfo }));
17
17
  }
18
18
  getSessionKeyPermissions() {
19
- const parentBlock = findActionByBlockId(this.blockId).block;
20
- if (!parentBlock.permissions)
21
- return null;
22
- const permissions = SessionKeyPermission.fromJSON(parentBlock.permissions);
23
- permissions.fillParameters(this.getParameters());
24
- permissions.fillMethod();
25
- return permissions;
19
+ return __awaiter(this, void 0, void 0, function* () {
20
+ const parentBlock = findActionByBlockId(this.blockId).block;
21
+ if (!parentBlock.permissions)
22
+ return null;
23
+ const permissions = SessionKeyPermission.fromJSON(parentBlock.permissions);
24
+ permissions.fillParameters(this.getParameters());
25
+ permissions.fillMethod();
26
+ if (parentBlock.before) {
27
+ yield permissions.fillBeforeVariables(parentBlock.before, this.getParameters());
28
+ }
29
+ return permissions;
30
+ });
26
31
  }
27
32
  static fromJSON(json) {
28
33
  return __awaiter(this, void 0, void 0, function* () {
@@ -1,3 +1,12 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
1
10
  import { getToken } from "../constants/tokens.js";
2
11
  export class SessionKeyPermission {
3
12
  constructor({ approvedTargets = [], label = [], labelNotAuthorized = [], } = {}) {
@@ -5,6 +14,7 @@ export class SessionKeyPermission {
5
14
  this.label = label;
6
15
  this.labelNotAuthorized = labelNotAuthorized;
7
16
  }
17
+ // Existing method to replace placeholders with actual values
8
18
  fill(key, value) {
9
19
  const replacePlaceholder = (target) => {
10
20
  const placeholder = new RegExp(`{{${key}}}`, 'g');
@@ -14,15 +24,50 @@ export class SessionKeyPermission {
14
24
  this.label = this.label.map(replacePlaceholder);
15
25
  this.labelNotAuthorized = this.labelNotAuthorized.map(replacePlaceholder);
16
26
  }
27
+ /**
28
+ * Fill placeholders using variables returned by the 'before' string execution.
29
+ * @param beforeCode - A string representing the 'before' logic to execute.
30
+ */
31
+ fillBeforeVariables(beforeCode, parameters) {
32
+ return __awaiter(this, void 0, void 0, function* () {
33
+ try {
34
+ // Prepare the environment with parameters
35
+ const env = { parameters };
36
+ // Replace the import statement in the beforeCode string if needed
37
+ const beforeCodeUpdated = beforeCode.replace("import('otomato-sdk')", "import('../index.js')");
38
+ // Wrap the beforeCode in an async function and immediately invoke it
39
+ const asyncBeforeFn = new Function('env', `
40
+ return (async function() {
41
+ return await (${beforeCodeUpdated})(env);
42
+ })();
43
+ `);
44
+ // Execute the async function and await the result
45
+ const beforeResult = yield asyncBeforeFn(env);
46
+ // Replace placeholders like {{before.variableName}} with the corresponding values
47
+ if (beforeResult && typeof beforeResult === 'object') {
48
+ Object.keys(beforeResult).forEach(key => {
49
+ this.fill(`before.${key}`, beforeResult[key]);
50
+ });
51
+ }
52
+ else {
53
+ console.error("Before function did not return an object:", beforeResult);
54
+ }
55
+ }
56
+ catch (error) {
57
+ console.error('Error executing before code:', error);
58
+ }
59
+ });
60
+ }
61
+ // The rest of your existing code
17
62
  fillParameters(params) {
18
63
  var _a;
19
- // 1. replace non abi params
64
+ // 1. replace non-ABI params
20
65
  for (let key in params) {
21
66
  if (key !== 'abi') {
22
67
  this.fill(`parameters.${key}`, params[key]);
23
68
  }
24
69
  }
25
- // 2. replace abi params
70
+ // 2. replace ABI params
26
71
  const abiParams = (_a = params.abi) === null || _a === void 0 ? void 0 : _a.parameters;
27
72
  for (let key in abiParams) {
28
73
  this.fill(`parameters.abiParams.${key}`, abiParams[key]);
@@ -89,6 +134,7 @@ export class SessionKeyPermission {
89
134
  this.labelNotAuthorized = this.labelNotAuthorized.filter(lbl => !this.label.includes(lbl));
90
135
  }
91
136
  }
137
+ // Helper function to get a different token
92
138
  const getDifferentToken = (chain, contractAddress) => {
93
139
  var _a;
94
140
  const tokenSymbol = (_a = getToken(chain, contractAddress)) === null || _a === void 0 ? void 0 : _a.symbol;
@@ -202,20 +202,22 @@ export class Workflow {
202
202
  });
203
203
  }
204
204
  getSessionKeyPermissions() {
205
- const permissions = new SessionKeyPermission();
206
- for (const node of this.nodes) {
207
- try {
208
- if (node.class === 'action' && 'getSessionKeyPermissions' in node) {
209
- const nodePermissions = node.getSessionKeyPermissions();
210
- if (nodePermissions) {
211
- permissions.merge(nodePermissions);
205
+ return __awaiter(this, void 0, void 0, function* () {
206
+ const permissions = new SessionKeyPermission();
207
+ for (const node of this.nodes) {
208
+ try {
209
+ if (node.class === 'action' && 'getSessionKeyPermissions' in node) {
210
+ const nodePermissions = yield node.getSessionKeyPermissions();
211
+ if (nodePermissions) {
212
+ permissions.merge(nodePermissions);
213
+ }
212
214
  }
213
215
  }
216
+ catch (error) {
217
+ console.error(`Error getting session key permissions for node ${node.getRef()}:`, error);
218
+ }
214
219
  }
215
- catch (error) {
216
- console.error(`Error getting session key permissions for node ${node.getRef()}:`, error);
217
- }
218
- }
219
- return permissions;
220
+ return permissions;
221
+ });
220
222
  }
221
223
  }
@@ -187,7 +187,7 @@ export declare const TRIGGERS: {
187
187
  description: string;
188
188
  chains: number[];
189
189
  image: string;
190
- DEPOSIT: {
190
+ LENDING_RATE: {
191
191
  name: string;
192
192
  description: string;
193
193
  type: number;
@@ -390,6 +390,20 @@ export declare const TRIGGERS: {
390
390
  };
391
391
  };
392
392
  };
393
+ NFTS: {
394
+ BLUR: {
395
+ description: string;
396
+ chains: number[];
397
+ image: string;
398
+ };
399
+ };
400
+ PRE_MARKET: {
401
+ WHALES_MARKET: {
402
+ description: string;
403
+ chains: number[];
404
+ image: string;
405
+ };
406
+ };
393
407
  };
394
408
  export declare const ACTIONS: {
395
409
  CORE: {
@@ -435,6 +449,55 @@ export declare const ACTIONS: {
435
449
  image: string;
436
450
  };
437
451
  };
452
+ SWAP: {
453
+ description: string;
454
+ chains: number[];
455
+ image: string;
456
+ SWAP: {
457
+ name: string;
458
+ description: string;
459
+ type: number;
460
+ contractAddress: string;
461
+ requiredApprovals: {
462
+ address: string;
463
+ amount: string;
464
+ to: string;
465
+ }[];
466
+ checks: {
467
+ type: number;
468
+ chainId: string;
469
+ contractAddress: string;
470
+ amount: string;
471
+ }[];
472
+ output: {
473
+ amountIn: string;
474
+ tokenIn: string;
475
+ amountOut: string;
476
+ tokenOut: string;
477
+ transactionHash: string;
478
+ };
479
+ parameters: Parameter[];
480
+ examples: {
481
+ name: string;
482
+ description: string;
483
+ parameters: ({
484
+ key: string;
485
+ value: number;
486
+ } | {
487
+ key: string;
488
+ value: string;
489
+ })[];
490
+ }[];
491
+ permissions: {
492
+ approvedTargets: string[];
493
+ label: string[];
494
+ labelNotAuthorized: string[];
495
+ };
496
+ duplicate: boolean;
497
+ blockId: number;
498
+ image: string;
499
+ };
500
+ };
438
501
  };
439
502
  NOTIFICATIONS: {
440
503
  SLACK: {
@@ -519,6 +582,12 @@ export declare const ACTIONS: {
519
582
  transactionHash: string;
520
583
  };
521
584
  parameters: Parameter[];
585
+ checks: {
586
+ type: number;
587
+ chainId: string;
588
+ contractAddress: string;
589
+ amount: string;
590
+ }[];
522
591
  examples: {
523
592
  name: string;
524
593
  description: string;
@@ -562,11 +631,18 @@ export declare const ACTIONS: {
562
631
  value: string;
563
632
  })[];
564
633
  }[];
634
+ checks: {
635
+ type: number;
636
+ chainId: string;
637
+ contractAddress: string;
638
+ amount: string;
639
+ }[];
565
640
  requiredApprovals: {
566
641
  address: string;
567
642
  amount: string;
568
643
  to: string;
569
644
  }[];
645
+ before: string;
570
646
  output: {
571
647
  transactionHash: string;
572
648
  };
@@ -575,6 +651,19 @@ export declare const ACTIONS: {
575
651
  label: string[];
576
652
  labelNotAuthorized: string[];
577
653
  };
654
+ batchWith: {
655
+ id: number;
656
+ type: number;
657
+ conditions: never[];
658
+ parameters: {
659
+ chainId: string;
660
+ abi: {
661
+ parameters: {
662
+ tokens: string[];
663
+ };
664
+ };
665
+ };
666
+ }[];
578
667
  blockId: number;
579
668
  image: string;
580
669
  };
@@ -596,6 +685,7 @@ export declare const ACTIONS: {
596
685
  })[];
597
686
  }[];
598
687
  requiredApprovals: never[];
688
+ before: string;
599
689
  output: {
600
690
  transactionHash: string;
601
691
  };
@@ -625,6 +715,7 @@ export declare const ACTIONS: {
625
715
  })[];
626
716
  }[];
627
717
  requiredApprovals: never[];
718
+ before: string;
628
719
  output: {
629
720
  transactionHash: string;
630
721
  };
@@ -642,6 +733,12 @@ export declare const ACTIONS: {
642
733
  type: number;
643
734
  method: string;
644
735
  parameters: Parameter[];
736
+ checks: {
737
+ type: number;
738
+ chainId: string;
739
+ contractAddress: string;
740
+ amount: string;
741
+ }[];
645
742
  examples: {
646
743
  name: string;
647
744
  description: string;
@@ -658,6 +755,7 @@ export declare const ACTIONS: {
658
755
  amount: string;
659
756
  to: string;
660
757
  }[];
758
+ before: string;
661
759
  output: {
662
760
  transactionHash: string;
663
761
  };
@@ -669,6 +767,33 @@ export declare const ACTIONS: {
669
767
  blockId: number;
670
768
  image: string;
671
769
  };
770
+ ENABLE_COLLATERAL: {
771
+ showInUI: boolean;
772
+ name: string;
773
+ description: string;
774
+ type: number;
775
+ method: string;
776
+ contractAddress: string;
777
+ parameters: Parameter[];
778
+ examples: never[];
779
+ permissions: {
780
+ approvedTargets: string[];
781
+ label: string[];
782
+ labelNotAuthorized: string[];
783
+ };
784
+ blockId: number;
785
+ image: string;
786
+ };
787
+ };
788
+ ETHER_FI: {
789
+ description: string;
790
+ chains: number[];
791
+ image: string;
792
+ };
793
+ RENZO: {
794
+ description: string;
795
+ chains: number[];
796
+ image: string;
672
797
  };
673
798
  };
674
799
  SWAP: {
@@ -686,6 +811,12 @@ export declare const ACTIONS: {
686
811
  amount: string;
687
812
  to: string;
688
813
  }[];
814
+ checks: {
815
+ type: number;
816
+ chainId: string;
817
+ contractAddress: string;
818
+ amount: string;
819
+ }[];
689
820
  output: {
690
821
  amountIn: string;
691
822
  tokenIn: string;
@@ -715,4 +846,11 @@ export declare const ACTIONS: {
715
846
  };
716
847
  };
717
848
  };
849
+ NFTS: {
850
+ BLUR: {
851
+ description: string;
852
+ chains: number[];
853
+ image: string;
854
+ };
855
+ };
718
856
  };
@@ -16,7 +16,7 @@ export declare class Action extends Node {
16
16
  parentInfo?: ParentInfo;
17
17
  state?: NodeState;
18
18
  });
19
- getSessionKeyPermissions(): SessionKeyPermission | null;
19
+ getSessionKeyPermissions(): Promise<SessionKeyPermission | null>;
20
20
  static fromJSON(json: {
21
21
  [key: string]: any;
22
22
  }): Promise<Action>;
@@ -8,6 +8,13 @@ export declare class SessionKeyPermission {
8
8
  labelNotAuthorized?: string[];
9
9
  });
10
10
  fill(key: string, value: any): void;
11
+ /**
12
+ * Fill placeholders using variables returned by the 'before' string execution.
13
+ * @param beforeCode - A string representing the 'before' logic to execute.
14
+ */
15
+ fillBeforeVariables(beforeCode: string, parameters: {
16
+ [key: string]: any;
17
+ }): Promise<void>;
11
18
  fillParameters(params: {
12
19
  [key: string]: any;
13
20
  }): void;
@@ -49,5 +49,5 @@ export declare class Workflow {
49
49
  success: boolean;
50
50
  error?: string;
51
51
  }>;
52
- getSessionKeyPermissions(): SessionKeyPermission;
52
+ getSessionKeyPermissions(): Promise<SessionKeyPermission>;
53
53
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "otomato-sdk",
3
- "version": "1.5.36",
3
+ "version": "1.5.39",
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",