otomato-sdk 2.0.63 → 2.0.64
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/dist/src/constants/Blocks.js +24 -10
- package/dist/src/constants/version.js +1 -1
- package/dist/src/utils/WorkflowNodePositioner.js +45 -71
- package/dist/types/examples/UseCases/MicroSerivcesTrigger/blur.d.ts +1 -0
- package/dist/types/examples/UseCases/MicroSerivcesTrigger/x.d.ts +1 -0
- package/dist/types/examples/UseCases/Swap/aerodrome-basic.d.ts +1 -0
- package/dist/types/examples/UseCases/Swap/aerodrome-concentrated.d.ts +1 -0
- package/dist/types/examples/UseCases/Swap/uniswap-v2.d.ts +1 -0
- package/dist/types/examples/UseCases/Swap/uniswap-v3.d.ts +1 -0
- package/dist/types/examples/UseCases/Swap/velodrome-basic.d.ts +1 -0
- package/dist/types/examples/UseCases/Swap/velodrome-concentrated.d.ts +1 -0
- package/dist/types/src/constants/Blocks.d.ts +14 -0
- package/dist/types/src/constants/version.d.ts +1 -1
- package/dist/types/src/utils/WorkflowNodePositioner.d.ts +7 -15
- package/package.json +2 -2
|
@@ -151,7 +151,7 @@ export const TRIGGERS = {
|
|
|
151
151
|
"description": "Fetches the balance of an ERC20 and checks it against the specified condition.",
|
|
152
152
|
"prototype": "erc20Balance",
|
|
153
153
|
"type": 1,
|
|
154
|
-
"method": "function balanceOf(address account) view returns (uint256)",
|
|
154
|
+
"method": "function balanceOf(address account) view returns ((uint256 balance))",
|
|
155
155
|
"output": {
|
|
156
156
|
"balance": "float"
|
|
157
157
|
},
|
|
@@ -1555,6 +1555,8 @@ export const TRIGGERS = {
|
|
|
1555
1555
|
"output": {
|
|
1556
1556
|
"sender": "address",
|
|
1557
1557
|
"recipient": "address",
|
|
1558
|
+
"token0": "erc20",
|
|
1559
|
+
"token1": "erc20",
|
|
1558
1560
|
"amount0": "int256",
|
|
1559
1561
|
"amount1": "int256",
|
|
1560
1562
|
"sqrtPriceX96": "uint160",
|
|
@@ -1643,6 +1645,8 @@ export const TRIGGERS = {
|
|
|
1643
1645
|
"type": 0,
|
|
1644
1646
|
"output": {
|
|
1645
1647
|
"sender": "address",
|
|
1648
|
+
"token0": "erc20",
|
|
1649
|
+
"token1": "erc20",
|
|
1646
1650
|
"amount0In": "uint256",
|
|
1647
1651
|
"amount1In": "uint256",
|
|
1648
1652
|
"amount0Out": "uint256",
|
|
@@ -1751,6 +1755,8 @@ export const TRIGGERS = {
|
|
|
1751
1755
|
"output": {
|
|
1752
1756
|
"sender": "address",
|
|
1753
1757
|
"recipient": "address",
|
|
1758
|
+
"token0": "erc20",
|
|
1759
|
+
"token1": "erc20",
|
|
1754
1760
|
"amount0": "int256",
|
|
1755
1761
|
"amount1": "int256",
|
|
1756
1762
|
"sqrtPriceX96": "uint160",
|
|
@@ -1840,6 +1846,8 @@ export const TRIGGERS = {
|
|
|
1840
1846
|
"output": {
|
|
1841
1847
|
"sender": "address",
|
|
1842
1848
|
"to": "address",
|
|
1849
|
+
"token0": "erc20",
|
|
1850
|
+
"token1": "erc20",
|
|
1843
1851
|
"amount0In": "uint256",
|
|
1844
1852
|
"amount1In": "uint256",
|
|
1845
1853
|
"amount0Out": "uint256",
|
|
@@ -1925,7 +1933,7 @@ export const TRIGGERS = {
|
|
|
1925
1933
|
"VELODROME": {
|
|
1926
1934
|
"description": "Monitors swaps on Velodrome pools",
|
|
1927
1935
|
"chains": [
|
|
1928
|
-
|
|
1936
|
+
34443
|
|
1929
1937
|
],
|
|
1930
1938
|
"image": "https://otomato-sdk-images.s3.eu-west-1.amazonaws.com/velodrome.jpg",
|
|
1931
1939
|
"SWAP_IN_CONCENTRATED_POOL": {
|
|
@@ -1935,6 +1943,8 @@ export const TRIGGERS = {
|
|
|
1935
1943
|
"output": {
|
|
1936
1944
|
"sender": "address",
|
|
1937
1945
|
"recipient": "address",
|
|
1946
|
+
"token0": "erc20",
|
|
1947
|
+
"token1": "erc20",
|
|
1938
1948
|
"amount0": "int256",
|
|
1939
1949
|
"amount1": "int256",
|
|
1940
1950
|
"sqrtPriceX96": "uint160",
|
|
@@ -1946,7 +1956,7 @@ export const TRIGGERS = {
|
|
|
1946
1956
|
{
|
|
1947
1957
|
"key": "chainId",
|
|
1948
1958
|
"type": "chainId",
|
|
1949
|
-
"description": "The network to monitor swaps on (
|
|
1959
|
+
"description": "The network to monitor swaps on (MODE).",
|
|
1950
1960
|
"mandatory": true,
|
|
1951
1961
|
"category": 0
|
|
1952
1962
|
},
|
|
@@ -2001,15 +2011,15 @@ export const TRIGGERS = {
|
|
|
2001
2011
|
"examples": [
|
|
2002
2012
|
{
|
|
2003
2013
|
"name": "Monitor all swaps in concentrated pool",
|
|
2004
|
-
"description": "Triggers whenever a swap occurs in a Velodrome concentrated liquidity pool (WETH/
|
|
2014
|
+
"description": "Triggers whenever a swap occurs in a Velodrome concentrated liquidity pool (WETH/USDC 0.05%).",
|
|
2005
2015
|
"parameters": [
|
|
2006
2016
|
{
|
|
2007
2017
|
"key": "chainId",
|
|
2008
|
-
"value":
|
|
2018
|
+
"value": 34443
|
|
2009
2019
|
},
|
|
2010
2020
|
{
|
|
2011
2021
|
"key": "contractAddress",
|
|
2012
|
-
"value": "
|
|
2022
|
+
"value": "0x3Adf15f77F2911f84b0FE9DbdfF43ef60D40012c"
|
|
2013
2023
|
}
|
|
2014
2024
|
]
|
|
2015
2025
|
}
|
|
@@ -2034,7 +2044,7 @@ export const TRIGGERS = {
|
|
|
2034
2044
|
{
|
|
2035
2045
|
"key": "chainId",
|
|
2036
2046
|
"type": "chainId",
|
|
2037
|
-
"description": "The network to monitor swaps on (
|
|
2047
|
+
"description": "The network to monitor swaps on (MODE).",
|
|
2038
2048
|
"mandatory": true,
|
|
2039
2049
|
"category": 0
|
|
2040
2050
|
},
|
|
@@ -2093,7 +2103,7 @@ export const TRIGGERS = {
|
|
|
2093
2103
|
"parameters": [
|
|
2094
2104
|
{
|
|
2095
2105
|
"key": "chainId",
|
|
2096
|
-
"value":
|
|
2106
|
+
"value": 34443
|
|
2097
2107
|
},
|
|
2098
2108
|
{
|
|
2099
2109
|
"key": "contractAddress",
|
|
@@ -2594,7 +2604,9 @@ export const ACTIONS = {
|
|
|
2594
2604
|
"tokenIn": "erc20",
|
|
2595
2605
|
"amountOut": "uint256",
|
|
2596
2606
|
"tokenOut": "erc20",
|
|
2597
|
-
"transactionHash": "string"
|
|
2607
|
+
"transactionHash": "string",
|
|
2608
|
+
"exchangeRate": "float",
|
|
2609
|
+
"logs": "Object"
|
|
2598
2610
|
},
|
|
2599
2611
|
"frontendHelpers": {
|
|
2600
2612
|
"output": {
|
|
@@ -4477,7 +4489,9 @@ export const ACTIONS = {
|
|
|
4477
4489
|
"tokenIn": "erc20",
|
|
4478
4490
|
"amountOut": "uint256",
|
|
4479
4491
|
"tokenOut": "erc20",
|
|
4480
|
-
"transactionHash": "string"
|
|
4492
|
+
"transactionHash": "string",
|
|
4493
|
+
"exchangeRate": "float",
|
|
4494
|
+
"logs": "Object"
|
|
4481
4495
|
},
|
|
4482
4496
|
"frontendHelpers": {
|
|
4483
4497
|
"output": {
|
|
@@ -1,81 +1,60 @@
|
|
|
1
|
-
//
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
//
|
|
5
|
-
export const
|
|
6
|
-
export const
|
|
7
|
-
export const ROOT_X = 400; // we’ll keep references, but Dagre decides actual positions
|
|
8
|
-
export const ROOT_Y = 120;
|
|
1
|
+
// Import necessary functions from d3-dag
|
|
2
|
+
import { graphStratify, sugiyama, layeringLongestPath, decrossTwoLayer, coordCenter } from 'd3-dag';
|
|
3
|
+
export const xSpacing = 400; // used for horizontal spacing between nodes
|
|
4
|
+
export const ySpacing = 120; // used for vertical spacing between layers
|
|
5
|
+
export const ROOT_X = 400; // x-offset for the entire layout
|
|
6
|
+
export const ROOT_Y = 120; // y-offset for the entire layout
|
|
9
7
|
/**
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
* 3) dagre.layout(g)
|
|
15
|
-
* 4) Extract positions & write them back to workflow.nodes
|
|
8
|
+
* d3-dag based layout for the “top-down” pass.
|
|
9
|
+
*
|
|
10
|
+
* This function transforms the workflow into a DAG format for d3-dag,
|
|
11
|
+
* runs the Sugiyama layout algorithm, and updates the positions of workflow nodes.
|
|
16
12
|
*/
|
|
17
13
|
export function positionWorkflowNodes(workflow) {
|
|
18
|
-
|
|
19
|
-
//
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
marginy: 20, // how much margin to leave around the top/bottom
|
|
28
|
-
});
|
|
29
|
-
g.setDefaultEdgeLabel(() => ({}));
|
|
30
|
-
// 2) Add nodes to the graph
|
|
31
|
-
// Dagre requires each node have an id and some approximate width/height
|
|
32
|
-
workflow.nodes.forEach((node) => {
|
|
33
|
-
const nodeId = node.getRef();
|
|
34
|
-
// For a typical text-based node, approximate width & height
|
|
35
|
-
g.setNode(nodeId, {
|
|
36
|
-
label: nodeId,
|
|
37
|
-
width: 100,
|
|
38
|
-
height: 50
|
|
39
|
-
});
|
|
40
|
-
});
|
|
41
|
-
// 3) Add edges
|
|
42
|
-
// Dagre identifies edges by (sourceId, targetId). We don’t need labels for layout,
|
|
43
|
-
// but we can store them if we want. If you rely on “true/false” ordering, we can tweak
|
|
44
|
-
// e.g. use edge label as a tie-break. (See advanced docs.)
|
|
45
|
-
workflow.edges.forEach((edge) => {
|
|
46
|
-
var _a;
|
|
47
|
-
const fromId = edge.source.getRef();
|
|
48
|
-
const toId = edge.target.getRef();
|
|
49
|
-
g.setEdge(fromId, toId, { label: (_a = edge.label) !== null && _a !== void 0 ? _a : '' });
|
|
50
|
-
});
|
|
51
|
-
// 4) Run Dagre layout
|
|
52
|
-
dagre.layout(g);
|
|
53
|
-
// 5) Extract positions from Dagre graph and store them back to your Node objects
|
|
54
|
-
g.nodes().forEach((nodeId) => {
|
|
55
|
-
const dagreNode = g.node(nodeId); // { x, y, width, height, ... }
|
|
56
|
-
const nodeObj = workflow.nodes.find((n) => n.getRef() === nodeId);
|
|
57
|
-
if (!nodeObj || !dagreNode)
|
|
58
|
-
return;
|
|
59
|
-
// Store x,y in your node’s position
|
|
60
|
-
nodeObj.setPosition(dagreNode.x, dagreNode.y);
|
|
14
|
+
const nodeMap = new Map();
|
|
15
|
+
// 1) Transform workflow into data for stratification
|
|
16
|
+
const data = workflow.nodes.map((node) => {
|
|
17
|
+
const id = node.getRef();
|
|
18
|
+
nodeMap.set(id, node);
|
|
19
|
+
const parents = workflow.edges
|
|
20
|
+
.filter(edge => edge.target === node)
|
|
21
|
+
.map(edge => edge.source.getRef());
|
|
22
|
+
return { id, parentIds: parents };
|
|
61
23
|
});
|
|
24
|
+
// 2) Build the DAG using graphStratify
|
|
25
|
+
// Cast to 'any' so we can access .each(...) etc. at runtime
|
|
26
|
+
const dag = graphStratify()(data);
|
|
27
|
+
// 3) Create and configure the Sugiyama layout
|
|
28
|
+
// Note the calls to the operator factories: layeringLongestPath(), decrossTwoLayer(), coordCenter()
|
|
29
|
+
const layout = sugiyama()
|
|
30
|
+
.layering(layeringLongestPath())
|
|
31
|
+
.decross(decrossTwoLayer())
|
|
32
|
+
.coord(coordCenter())
|
|
33
|
+
// Instead of .size, we use .nodeSize for spacing between nodes
|
|
34
|
+
.nodeSize([xSpacing, ySpacing]);
|
|
35
|
+
// 4) Run layout
|
|
36
|
+
layout(dag);
|
|
37
|
+
// 5) Update workflow node positions
|
|
38
|
+
for (const node of dag.nodes()) {
|
|
39
|
+
const id = node.data.id;
|
|
40
|
+
const wfNode = nodeMap.get(id);
|
|
41
|
+
if (wfNode && typeof node.x === 'number' && typeof node.y === 'number') {
|
|
42
|
+
wfNode.setPosition(node.x + ROOT_X, node.y + ROOT_Y);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
;
|
|
62
46
|
}
|
|
63
47
|
/**
|
|
64
|
-
*
|
|
65
|
-
* but we’re not actively using them in the new Dagre-based layout.
|
|
48
|
+
* Helper functions (unchanged).
|
|
66
49
|
*/
|
|
67
50
|
export function getChildren(node, edges) {
|
|
68
|
-
return edges
|
|
69
|
-
.filter((edge) => edge.source === node)
|
|
70
|
-
.map((edge) => edge.target);
|
|
51
|
+
return edges.filter(edge => edge.source === node).map(edge => edge.target);
|
|
71
52
|
}
|
|
72
53
|
export function getParents(node, edges) {
|
|
73
|
-
return edges
|
|
74
|
-
.filter((edge) => edge.target === node)
|
|
75
|
-
.map((edge) => edge.source);
|
|
54
|
+
return edges.filter(edge => edge.target === node).map(edge => edge.source);
|
|
76
55
|
}
|
|
77
56
|
export function getEdges(node, edges) {
|
|
78
|
-
return edges.filter(
|
|
57
|
+
return edges.filter(edge => edge.source === node || edge.target === node);
|
|
79
58
|
}
|
|
80
59
|
export function getEndNodePositions(workflow) {
|
|
81
60
|
return workflow.nodes
|
|
@@ -88,11 +67,6 @@ export function getEndNodePositions(workflow) {
|
|
|
88
67
|
});
|
|
89
68
|
});
|
|
90
69
|
}
|
|
91
|
-
/**
|
|
92
|
-
* In Dagre, we no longer do an explicit “identify leaf nodes” or “center parents by average,”
|
|
93
|
-
* because the layout library handles that.
|
|
94
|
-
* But here’s your old method if something else depends on it.
|
|
95
|
-
*/
|
|
96
70
|
export function identifyLeafNodes(workflow) {
|
|
97
71
|
const sources = new Set(workflow.edges.map((edge) => edge.source.getRef()));
|
|
98
72
|
return workflow.nodes.filter((node) => !sources.has(node.getRef()));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -602,6 +602,8 @@ export declare const TRIGGERS: {
|
|
|
602
602
|
output: {
|
|
603
603
|
sender: string;
|
|
604
604
|
recipient: string;
|
|
605
|
+
token0: string;
|
|
606
|
+
token1: string;
|
|
605
607
|
amount0: string;
|
|
606
608
|
amount1: string;
|
|
607
609
|
sqrtPriceX96: string;
|
|
@@ -646,6 +648,8 @@ export declare const TRIGGERS: {
|
|
|
646
648
|
type: number;
|
|
647
649
|
output: {
|
|
648
650
|
sender: string;
|
|
651
|
+
token0: string;
|
|
652
|
+
token1: string;
|
|
649
653
|
amount0In: string;
|
|
650
654
|
amount1In: string;
|
|
651
655
|
amount0Out: string;
|
|
@@ -696,6 +700,8 @@ export declare const TRIGGERS: {
|
|
|
696
700
|
output: {
|
|
697
701
|
sender: string;
|
|
698
702
|
recipient: string;
|
|
703
|
+
token0: string;
|
|
704
|
+
token1: string;
|
|
699
705
|
amount0: string;
|
|
700
706
|
amount1: string;
|
|
701
707
|
sqrtPriceX96: string;
|
|
@@ -741,6 +747,8 @@ export declare const TRIGGERS: {
|
|
|
741
747
|
output: {
|
|
742
748
|
sender: string;
|
|
743
749
|
to: string;
|
|
750
|
+
token0: string;
|
|
751
|
+
token1: string;
|
|
744
752
|
amount0In: string;
|
|
745
753
|
amount1In: string;
|
|
746
754
|
amount0Out: string;
|
|
@@ -790,6 +798,8 @@ export declare const TRIGGERS: {
|
|
|
790
798
|
output: {
|
|
791
799
|
sender: string;
|
|
792
800
|
recipient: string;
|
|
801
|
+
token0: string;
|
|
802
|
+
token1: string;
|
|
793
803
|
amount0: string;
|
|
794
804
|
amount1: string;
|
|
795
805
|
sqrtPriceX96: string;
|
|
@@ -1137,6 +1147,8 @@ export declare const ACTIONS: {
|
|
|
1137
1147
|
amountOut: string;
|
|
1138
1148
|
tokenOut: string;
|
|
1139
1149
|
transactionHash: string;
|
|
1150
|
+
exchangeRate: string;
|
|
1151
|
+
logs: string;
|
|
1140
1152
|
};
|
|
1141
1153
|
frontendHelpers: {
|
|
1142
1154
|
output: {
|
|
@@ -1956,6 +1968,8 @@ export declare const ACTIONS: {
|
|
|
1956
1968
|
amountOut: string;
|
|
1957
1969
|
tokenOut: string;
|
|
1958
1970
|
transactionHash: string;
|
|
1971
|
+
exchangeRate: string;
|
|
1972
|
+
logs: string;
|
|
1959
1973
|
};
|
|
1960
1974
|
frontendHelpers: {
|
|
1961
1975
|
output: {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "2.0.
|
|
1
|
+
export declare const SDK_VERSION = "2.0.64";
|
|
2
2
|
export declare function compareVersions(v1: string, v2: string): number;
|
|
@@ -1,22 +1,19 @@
|
|
|
1
1
|
import { Workflow } from '../models/Workflow.js';
|
|
2
2
|
import { Node } from '../models/Node.js';
|
|
3
3
|
import { Edge } from '../models/Edge.js';
|
|
4
|
-
export declare const xSpacing =
|
|
5
|
-
export declare const ySpacing =
|
|
4
|
+
export declare const xSpacing = 400;
|
|
5
|
+
export declare const ySpacing = 120;
|
|
6
6
|
export declare const ROOT_X = 400;
|
|
7
7
|
export declare const ROOT_Y = 120;
|
|
8
8
|
/**
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
* 3) dagre.layout(g)
|
|
14
|
-
* 4) Extract positions & write them back to workflow.nodes
|
|
9
|
+
* d3-dag based layout for the “top-down” pass.
|
|
10
|
+
*
|
|
11
|
+
* This function transforms the workflow into a DAG format for d3-dag,
|
|
12
|
+
* runs the Sugiyama layout algorithm, and updates the positions of workflow nodes.
|
|
15
13
|
*/
|
|
16
14
|
export declare function positionWorkflowNodes(workflow: Workflow): void;
|
|
17
15
|
/**
|
|
18
|
-
*
|
|
19
|
-
* but we’re not actively using them in the new Dagre-based layout.
|
|
16
|
+
* Helper functions (unchanged).
|
|
20
17
|
*/
|
|
21
18
|
export declare function getChildren(node: Node, edges: Edge[]): Node[];
|
|
22
19
|
export declare function getParents(node: Node, edges: Edge[]): Node[];
|
|
@@ -25,10 +22,5 @@ export declare function getEndNodePositions(workflow: Workflow): {
|
|
|
25
22
|
x: number;
|
|
26
23
|
y: number;
|
|
27
24
|
}[];
|
|
28
|
-
/**
|
|
29
|
-
* In Dagre, we no longer do an explicit “identify leaf nodes” or “center parents by average,”
|
|
30
|
-
* because the layout library handles that.
|
|
31
|
-
* But here’s your old method if something else depends on it.
|
|
32
|
-
*/
|
|
33
25
|
export declare function identifyLeafNodes(workflow: Workflow): Node[];
|
|
34
26
|
export declare function identityStartingNodes(workflow: Workflow): Node[];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "otomato-sdk",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.64",
|
|
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",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
46
|
"axios": "^1.7.2",
|
|
47
|
-
"
|
|
47
|
+
"d3-dag": "^1.1.0",
|
|
48
48
|
"ethers": "^6.13.1",
|
|
49
49
|
"jsonwebtoken": "^9.0.2",
|
|
50
50
|
"mustache": "^4.2.0"
|