otomato-sdk 1.5.30 → 1.5.32
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/WorkflowTemplates.js +10 -14
- package/dist/src/constants/tokens.js +29 -14
- package/dist/src/index.js +1 -0
- package/dist/src/models/Authorization.js +78 -0
- package/dist/types/examples/authorizations.d.ts +1 -0
- package/dist/types/src/index.d.ts +1 -0
- package/dist/types/src/models/Authorization.d.ts +28 -0
- package/package.json +2 -1
|
@@ -32,7 +32,7 @@ const createETHFearAndGreedBuy = () => {
|
|
|
32
32
|
trigger.setComparisonValue(30);
|
|
33
33
|
trigger.setPosition(400, 120);
|
|
34
34
|
const telegramAction = new Action(ACTIONS.NOTIFICATIONS.TELEGRAM.SEND_MESSAGE);
|
|
35
|
-
telegramAction.setParams("message", "The market sentiment is extremely fearful. Consider buying ETH.");
|
|
35
|
+
telegramAction.setParams("message", "The market sentiment is extremely fearful. Consider buying ETH (NFA).");
|
|
36
36
|
telegramAction.setPosition(400, 240);
|
|
37
37
|
const edge = new Edge({ source: trigger, target: telegramAction });
|
|
38
38
|
return new Workflow('Buy ETH when the market sentiment is extremely fearful', [trigger, telegramAction], [edge]);
|
|
@@ -52,20 +52,16 @@ const createSUsdeYieldBuy = () => __awaiter(void 0, void 0, void 0, function* ()
|
|
|
52
52
|
const edge = new Edge({ source: trigger, target: odosAction });
|
|
53
53
|
return new Workflow('Buy sUSDE when the yield is above 20%', [trigger, odosAction], [edge]);
|
|
54
54
|
});
|
|
55
|
-
const
|
|
55
|
+
const createSusdeYieldNotification = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
56
56
|
const trigger = new Trigger(TRIGGERS.YIELD.ETHENA.SUSDE_YIELD);
|
|
57
57
|
trigger.setCondition('lt');
|
|
58
58
|
trigger.setComparisonValue(0);
|
|
59
59
|
trigger.setPosition(400, 120);
|
|
60
|
-
const
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
odosAction.setParams("amount", yield convertToTokenUnitsFromSymbol(100, chain, 'USDC'));
|
|
66
|
-
odosAction.setPosition(400, 240);
|
|
67
|
-
const edge = new Edge({ source: trigger, target: odosAction });
|
|
68
|
-
return new Workflow('Short ENA when sUSDE yield is negative', [trigger, odosAction], [edge]);
|
|
60
|
+
const telegramAction = new Action(ACTIONS.NOTIFICATIONS.TELEGRAM.SEND_MESSAGE);
|
|
61
|
+
telegramAction.setParams("message", "The sUSDE is now negative. You're losing money by holding it.");
|
|
62
|
+
telegramAction.setPosition(400, 240);
|
|
63
|
+
const edge = new Edge({ source: trigger, target: telegramAction });
|
|
64
|
+
return new Workflow('sUSDE yield notification', [trigger, telegramAction], [edge]);
|
|
69
65
|
});
|
|
70
66
|
export const WORKFLOW_TEMPLATES = [
|
|
71
67
|
{
|
|
@@ -90,10 +86,10 @@ export const WORKFLOW_TEMPLATES = [
|
|
|
90
86
|
createWorkflow: createSUsdeYieldBuy
|
|
91
87
|
},
|
|
92
88
|
{
|
|
93
|
-
'name': '
|
|
94
|
-
'description': '
|
|
89
|
+
'name': 'sUSDE yield notification',
|
|
90
|
+
'description': 'Notify me when the sUSDe yield becomes negative',
|
|
95
91
|
'tags': [WORKFLOW_TEMPLATES_TAGS.TRADING, WORKFLOW_TEMPLATES_TAGS.ON_CHAIN_MONITORING],
|
|
96
92
|
'thumbnail': 'https://otomato-sdk-images.s3.eu-west-1.amazonaws.com/templates/shortEna.jpg',
|
|
97
|
-
createWorkflow:
|
|
93
|
+
createWorkflow: createSusdeYieldNotification
|
|
98
94
|
},
|
|
99
95
|
];
|
|
@@ -37,13 +37,6 @@ export const TOKENS = {
|
|
|
37
37
|
decimals: 18,
|
|
38
38
|
image: "https://static.debank.com/image/chain/logo_url/eth/42ba589cd077e7bdd97db6480b0ff61d.png"
|
|
39
39
|
},
|
|
40
|
-
{
|
|
41
|
-
contractAddress: "0xd988097fb8612cc24eeC14542bC03424c656005f",
|
|
42
|
-
name: "USDC",
|
|
43
|
-
symbol: "USDC",
|
|
44
|
-
decimals: 6,
|
|
45
|
-
image: "https://static.debank.com/image/coin/logo_url/usdc/e87790bfe0b3f2ea855dc29069b38818.png"
|
|
46
|
-
},
|
|
47
40
|
{
|
|
48
41
|
contractAddress: '0xcDd475325D6F564d27247D1DddBb0DAc6fA0a5CF',
|
|
49
42
|
symbol: 'WBTC',
|
|
@@ -51,13 +44,6 @@ export const TOKENS = {
|
|
|
51
44
|
decimals: 8,
|
|
52
45
|
image: "https://static.debank.com/image/eth_token/logo_url/0x2260fac5e5542a773aa44fbcfedf7c193bc2c599/d3c52e7c7449afa8bd4fad1c93f50d93.png",
|
|
53
46
|
},
|
|
54
|
-
{
|
|
55
|
-
contractAddress: '0xf0F161fDA2712DB8b566946122a5af183995e2eD',
|
|
56
|
-
symbol: 'USDT',
|
|
57
|
-
name: 'USDT',
|
|
58
|
-
decimals: 6,
|
|
59
|
-
image: "https://static.debank.com/image/coin/logo_url/usdt/23af7472292cb41dc39b3f1146ead0fe.png"
|
|
60
|
-
},
|
|
61
47
|
{
|
|
62
48
|
contractAddress: '0xDfc7C877a950e49D2610114102175A06C2e3167a',
|
|
63
49
|
symbol: 'MODE',
|
|
@@ -107,6 +93,35 @@ export const TOKENS = {
|
|
|
107
93
|
decimals: 18,
|
|
108
94
|
image: 'https://static.debank.com/image/merlin_token/logo_url/0xb880fd278198bd590252621d4cd071b1842e9bcd/ef8e2efb7606de9fb88463282c0cbef0.png'
|
|
109
95
|
},
|
|
96
|
+
// stables
|
|
97
|
+
{
|
|
98
|
+
contractAddress: "0xd988097fb8612cc24eeC14542bC03424c656005f",
|
|
99
|
+
name: "USDC",
|
|
100
|
+
symbol: "USDC",
|
|
101
|
+
decimals: 6,
|
|
102
|
+
image: "https://static.debank.com/image/coin/logo_url/usdc/e87790bfe0b3f2ea855dc29069b38818.png"
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
contractAddress: '0xf0F161fDA2712DB8b566946122a5af183995e2eD',
|
|
106
|
+
symbol: 'USDT',
|
|
107
|
+
name: 'USDT',
|
|
108
|
+
decimals: 6,
|
|
109
|
+
image: "https://static.debank.com/image/coin/logo_url/usdt/23af7472292cb41dc39b3f1146ead0fe.png"
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
contractAddress: '0x5d3a1Ff2b6BAb83b63cd9AD0787074081a52ef34',
|
|
113
|
+
symbol: 'USDe',
|
|
114
|
+
name: 'USDe',
|
|
115
|
+
decimals: 18,
|
|
116
|
+
image: "https://static.debank.com/image/eth_token/logo_url/0x4c9edd5852cd905f086c759e8383e09bff1e68b3/734064e545eabfc501b9d0e752644b7d.png"
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
contractAddress: '0x211Cc4DD073734dA055fbF44a2b4667d5E5fE5d2',
|
|
120
|
+
symbol: 'sUSDe',
|
|
121
|
+
name: 'sUSDe',
|
|
122
|
+
decimals: 18,
|
|
123
|
+
image: "https://static.debank.com/image/eth_token/logo_url/0x9d39a5de30e57443bff2a8307a4256c8797a3497/966083165927dd3c1e6b67ff4bd17060.png"
|
|
124
|
+
},
|
|
110
125
|
// ironclad
|
|
111
126
|
{
|
|
112
127
|
contractAddress: '0x9c29a8eC901DBec4fFf165cD57D4f9E03D4838f7',
|
package/dist/src/index.js
CHANGED
|
@@ -12,6 +12,7 @@ export * from './models/Trigger.js';
|
|
|
12
12
|
export * from './models/Node.js';
|
|
13
13
|
export * from './models/Edge.js';
|
|
14
14
|
export * from './models/SessionKeyPermission.js';
|
|
15
|
+
export * from './models/Authorization.js';
|
|
15
16
|
// Exporting services
|
|
16
17
|
export * from './services/ApiService.js';
|
|
17
18
|
export * from './utils/helpers.js';
|
|
@@ -0,0 +1,78 @@
|
|
|
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
|
+
};
|
|
10
|
+
// Import the apiServices instance
|
|
11
|
+
import { apiServices } from '../services/ApiService.js';
|
|
12
|
+
// Define the Authorization class with static methods
|
|
13
|
+
export class Authorization {
|
|
14
|
+
/**
|
|
15
|
+
* Verify if the contracts are authorized.
|
|
16
|
+
*
|
|
17
|
+
* @param chainId - The chain ID of the blockchain network.
|
|
18
|
+
* @param sessionKeyAddress - The session key address to verify.
|
|
19
|
+
* @param contractAddresses - The list of contract addresses to verify.
|
|
20
|
+
* @returns A promise resolving to the verification result.
|
|
21
|
+
*/
|
|
22
|
+
static verifyContracts(chainId, sessionKeyAddress, contractAddresses) {
|
|
23
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
24
|
+
const payload = {
|
|
25
|
+
chainId,
|
|
26
|
+
sessionKeyAddress,
|
|
27
|
+
contractAddresses
|
|
28
|
+
};
|
|
29
|
+
try {
|
|
30
|
+
const response = yield apiServices.post('/auth/verify-contracts', payload);
|
|
31
|
+
if (response.status === 200) {
|
|
32
|
+
return { isValid: true };
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
return { isValid: false, diff: response.data || 'Unknown error' };
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
catch (error) {
|
|
39
|
+
// Extract response body from error if it exists
|
|
40
|
+
if (error.response) {
|
|
41
|
+
return error.response.data;
|
|
42
|
+
}
|
|
43
|
+
// Handle network errors or any other type of error
|
|
44
|
+
return { isValid: false, error: error.message || 'Unknown error' };
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Grant authorization to the contracts.
|
|
50
|
+
*
|
|
51
|
+
* @param chainId - The chain ID of the blockchain network.
|
|
52
|
+
* @param sessionKeyAddress - The session key address to authorize.
|
|
53
|
+
* @param contractAddresses - The list of contract addresses to authorize.
|
|
54
|
+
* @returns A promise resolving to the authorization result.
|
|
55
|
+
*/
|
|
56
|
+
static grantContracts(chainId, sessionKeyAddress, contractAddresses) {
|
|
57
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
58
|
+
var _a;
|
|
59
|
+
const payload = {
|
|
60
|
+
chainId,
|
|
61
|
+
sessionKeyAddress,
|
|
62
|
+
contractAddresses
|
|
63
|
+
};
|
|
64
|
+
try {
|
|
65
|
+
const response = yield apiServices.post('/auth/contracts', payload);
|
|
66
|
+
if (response.status === 201) {
|
|
67
|
+
return { success: true };
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
return { success: false, error: ((_a = response.data) === null || _a === void 0 ? void 0 : _a.message) || 'Unknown error' };
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
catch (error) {
|
|
74
|
+
return { success: false, error: error.message || 'Unknown error' };
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -10,6 +10,7 @@ export * from './models/Trigger.js';
|
|
|
10
10
|
export * from './models/Node.js';
|
|
11
11
|
export * from './models/Edge.js';
|
|
12
12
|
export * from './models/SessionKeyPermission.js';
|
|
13
|
+
export * from './models/Authorization.js';
|
|
13
14
|
export * from './services/ApiService.js';
|
|
14
15
|
export * from './utils/helpers.js';
|
|
15
16
|
export * from './utils/typeValidator.js';
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export declare class Authorization {
|
|
2
|
+
/**
|
|
3
|
+
* Verify if the contracts are authorized.
|
|
4
|
+
*
|
|
5
|
+
* @param chainId - The chain ID of the blockchain network.
|
|
6
|
+
* @param sessionKeyAddress - The session key address to verify.
|
|
7
|
+
* @param contractAddresses - The list of contract addresses to verify.
|
|
8
|
+
* @returns A promise resolving to the verification result.
|
|
9
|
+
*/
|
|
10
|
+
static verifyContracts(chainId: string, sessionKeyAddress: string, contractAddresses: string[]): Promise<{
|
|
11
|
+
isValid: boolean;
|
|
12
|
+
diff?: {};
|
|
13
|
+
error?: string;
|
|
14
|
+
}>;
|
|
15
|
+
/**
|
|
16
|
+
* Grant authorization to the contracts.
|
|
17
|
+
*
|
|
18
|
+
* @param chainId - The chain ID of the blockchain network.
|
|
19
|
+
* @param sessionKeyAddress - The session key address to authorize.
|
|
20
|
+
* @param contractAddresses - The list of contract addresses to authorize.
|
|
21
|
+
* @returns A promise resolving to the authorization result.
|
|
22
|
+
*/
|
|
23
|
+
static grantContracts(chainId: string, sessionKeyAddress: string, contractAddresses: string[]): Promise<{
|
|
24
|
+
success: boolean;
|
|
25
|
+
message?: string;
|
|
26
|
+
error?: string;
|
|
27
|
+
}>;
|
|
28
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "otomato-sdk",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.32",
|
|
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",
|
|
@@ -35,6 +35,7 @@
|
|
|
35
35
|
"@types/mustache": "^4.2.5",
|
|
36
36
|
"@types/node": "^20.14.2",
|
|
37
37
|
"chai": "^5.1.1",
|
|
38
|
+
"dotenv": "^16.4.5",
|
|
38
39
|
"mocha": "^10.4.0",
|
|
39
40
|
"ts-node": "^10.9.2",
|
|
40
41
|
"typescript": "^5.4.5"
|