otomato-sdk 1.5.1 → 1.5.3
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 +26 -0
- package/dist/src/constants/WorkflowTemplates.js +33 -0
- package/dist/src/index.js +1 -0
- package/dist/src/models/Edge.js +0 -20
- package/dist/src/services/ApiService.js +2 -2
- package/dist/types/examples/ex.d.ts +1 -0
- package/dist/types/examples/workflow-templates.d.ts +1 -0
- package/dist/types/src/constants/Blocks.d.ts +15 -0
- package/dist/types/src/constants/WorkflowTemplates.d.ts +6 -0
- package/dist/types/src/index.d.ts +1 -0
- package/dist/types/src/models/Edge.d.ts +0 -4
- package/dist/types/src/services/ApiService.d.ts +1 -1
- package/package.json +1 -1
|
@@ -357,6 +357,32 @@ export const TRIGGERS = {
|
|
|
357
357
|
"blockId": 3,
|
|
358
358
|
"image": "https://otomato-sdk-images.s3.eu-west-1.amazonaws.com/modens.png"
|
|
359
359
|
}
|
|
360
|
+
},
|
|
361
|
+
"FEAR_AND_GREED": {
|
|
362
|
+
"description": "Fetches the Fear and Greed Index",
|
|
363
|
+
"tags": {},
|
|
364
|
+
"image": "https://otomato-sdk-images.s3.eu-west-1.amazonaws.com/modens.png",
|
|
365
|
+
"GET_FEAR_AND_GREED_INDEX": {
|
|
366
|
+
"name": "Fear and Greed Index",
|
|
367
|
+
"description": "Fetches the Fear and Greed Index from the specified API and processes the result.",
|
|
368
|
+
"type": 3,
|
|
369
|
+
"url": "https://api.alternative.me/fng/",
|
|
370
|
+
"handler": "async (res) => { return res.data?.[0]?.value }",
|
|
371
|
+
"parameters": [
|
|
372
|
+
{
|
|
373
|
+
"key": "condition",
|
|
374
|
+
"type": "logic_operator",
|
|
375
|
+
"description": "Logic operator used for the comparison: <, >, <=, >=, ==, ..."
|
|
376
|
+
},
|
|
377
|
+
{
|
|
378
|
+
"key": "comparisonValue",
|
|
379
|
+
"type": "integer",
|
|
380
|
+
"description": "The value to compare to"
|
|
381
|
+
},
|
|
382
|
+
],
|
|
383
|
+
"blockId": 11,
|
|
384
|
+
"image": "https://otomato-sdk-images.s3.eu-west-1.amazonaws.com/modens.png"
|
|
385
|
+
}
|
|
360
386
|
}
|
|
361
387
|
},
|
|
362
388
|
"PRICE_ACTION": {
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Workflow, Trigger, Action, Edge, TRIGGERS, ACTIONS, CHAINS, getTokenFromSymbol } from '../index.js';
|
|
2
|
+
const createModeTransferNotificationWorkflow = () => {
|
|
3
|
+
const modeTransferTrigger = new Trigger(TRIGGERS.TOKENS.ERC20.TRANSFER);
|
|
4
|
+
modeTransferTrigger.setChainId(CHAINS.MODE);
|
|
5
|
+
modeTransferTrigger.setContractAddress(getTokenFromSymbol(CHAINS.MODE, 'MODE').contractAddress);
|
|
6
|
+
modeTransferTrigger.setParams('from', '0x74B847b308BD89Ef15639E6e4a2544E4b8b8C6B4');
|
|
7
|
+
const telegramAction = new Action(ACTIONS.NOTIFICATIONS.TELEGRAM.SEND_MESSAGE);
|
|
8
|
+
telegramAction.setParams("message", "0x74B8....C6B4 transferred $MODE");
|
|
9
|
+
const edge = new Edge({ source: modeTransferTrigger, target: telegramAction });
|
|
10
|
+
return new Workflow('Buy ETH when the market sentiment is fearful', [modeTransferTrigger, telegramAction], [edge]);
|
|
11
|
+
};
|
|
12
|
+
const createETHFearAndGreedBuy = () => {
|
|
13
|
+
const trigger = new Trigger(TRIGGERS.SOCIALS.FEAR_AND_GREED.GET_FEAR_AND_GREED_INDEX);
|
|
14
|
+
trigger.setCondition('lt');
|
|
15
|
+
trigger.setComparisonValue(30);
|
|
16
|
+
// todo: change to swap
|
|
17
|
+
const telegramAction = new Action(ACTIONS.NOTIFICATIONS.TELEGRAM.SEND_MESSAGE);
|
|
18
|
+
telegramAction.setParams("message", "0x74B8....C6B4 transferred $MODE");
|
|
19
|
+
const edge = new Edge({ source: trigger, target: telegramAction });
|
|
20
|
+
return new Workflow('MODE transfer notification', [trigger, telegramAction], [edge]);
|
|
21
|
+
};
|
|
22
|
+
export const WORKFLOW_TEMPLATES = [
|
|
23
|
+
{
|
|
24
|
+
'name': 'MODE transfer notification',
|
|
25
|
+
'description': 'Receive notifications when a top $MODE holder (0x74B8....C6B4) transfers $MODE',
|
|
26
|
+
createWorkflow: createModeTransferNotificationWorkflow
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
'name': 'Buy ETH when the market sentiment is fearful',
|
|
30
|
+
'description': 'Buy eth when the bitcoin fear and greed is below 30',
|
|
31
|
+
createWorkflow: createETHFearAndGreedBuy
|
|
32
|
+
},
|
|
33
|
+
];
|
package/dist/src/index.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
export * from './constants/Blocks.js';
|
|
3
3
|
export * from './constants/chains.js';
|
|
4
4
|
export * from './constants/tokens.js';
|
|
5
|
+
export * from './constants/WorkflowTemplates.js';
|
|
5
6
|
// Exporting models
|
|
6
7
|
export * from './models/Action.js';
|
|
7
8
|
export * from './models/Workflow.js';
|
package/dist/src/models/Edge.js
CHANGED
|
@@ -54,24 +54,4 @@ export class Edge {
|
|
|
54
54
|
}
|
|
55
55
|
});
|
|
56
56
|
}
|
|
57
|
-
update() {
|
|
58
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
59
|
-
var _a;
|
|
60
|
-
if (!this.id) {
|
|
61
|
-
throw new Error('Cannot update an edge without an ID.');
|
|
62
|
-
}
|
|
63
|
-
try {
|
|
64
|
-
const response = yield apiServices.patch(`/edges/${this.id}`, this.toJSON());
|
|
65
|
-
if (response.status === 200) {
|
|
66
|
-
return { success: true };
|
|
67
|
-
}
|
|
68
|
-
else {
|
|
69
|
-
return { success: false, error: ((_a = response.data) === null || _a === void 0 ? void 0 : _a.error) || 'Unknown error' };
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
catch (error) {
|
|
73
|
-
return { success: false, error: error.message || 'Unknown error' };
|
|
74
|
-
}
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
57
|
}
|
|
@@ -50,10 +50,10 @@ class ApiServices {
|
|
|
50
50
|
return yield axiosInstance.delete(url, { headers });
|
|
51
51
|
});
|
|
52
52
|
}
|
|
53
|
-
generateLoginPayload(address, chainId) {
|
|
53
|
+
generateLoginPayload(address, chainId, accessCode) {
|
|
54
54
|
return __awaiter(this, void 0, void 0, function* () {
|
|
55
55
|
const headers = { 'Content-Type': 'application/json' };
|
|
56
|
-
const response = yield axiosInstance.post('/auth/generate-payload', { address, chainId }, { headers });
|
|
56
|
+
const response = yield axiosInstance.post('/auth/generate-payload', { address, chainId, accessCode }, { headers });
|
|
57
57
|
return response.data;
|
|
58
58
|
});
|
|
59
59
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -115,6 +115,21 @@ export declare const TRIGGERS: {
|
|
|
115
115
|
image: string;
|
|
116
116
|
};
|
|
117
117
|
};
|
|
118
|
+
FEAR_AND_GREED: {
|
|
119
|
+
description: string;
|
|
120
|
+
tags: {};
|
|
121
|
+
image: string;
|
|
122
|
+
GET_FEAR_AND_GREED_INDEX: {
|
|
123
|
+
name: string;
|
|
124
|
+
description: string;
|
|
125
|
+
type: number;
|
|
126
|
+
url: string;
|
|
127
|
+
handler: string;
|
|
128
|
+
parameters: Parameter[];
|
|
129
|
+
blockId: number;
|
|
130
|
+
image: string;
|
|
131
|
+
};
|
|
132
|
+
};
|
|
118
133
|
};
|
|
119
134
|
PRICE_ACTION: {
|
|
120
135
|
ON_CHAIN_PRICE_MOVEMENT: {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export * from './constants/Blocks.js';
|
|
2
2
|
export * from './constants/chains.js';
|
|
3
3
|
export * from './constants/tokens.js';
|
|
4
|
+
export * from './constants/WorkflowTemplates.js';
|
|
4
5
|
export * from './models/Action.js';
|
|
5
6
|
export * from './models/Workflow.js';
|
|
6
7
|
export * from './models/Condition.js';
|
|
@@ -5,7 +5,7 @@ declare class ApiServices {
|
|
|
5
5
|
patch(url: string, data: any): Promise<import("axios").AxiosResponse<any, any>>;
|
|
6
6
|
get(url: string): Promise<any>;
|
|
7
7
|
delete(url: string): Promise<import("axios").AxiosResponse<any, any>>;
|
|
8
|
-
generateLoginPayload(address: string, chainId: number): Promise<any>;
|
|
8
|
+
generateLoginPayload(address: string, chainId: number, accessCode: string): Promise<any>;
|
|
9
9
|
getToken(loginPayload: any, signature: string): Promise<{
|
|
10
10
|
token: any;
|
|
11
11
|
}>;
|