otomato-sdk 1.5.46 → 1.5.48
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.
|
@@ -1155,9 +1155,8 @@ export const ACTIONS = {
|
|
|
1155
1155
|
"chains": [
|
|
1156
1156
|
34443
|
|
1157
1157
|
],
|
|
1158
|
-
"image": "https://otomato-sdk-images.s3.eu-west-1.amazonaws.com/swap.png",
|
|
1159
1158
|
"SWAP": {
|
|
1160
|
-
"id":
|
|
1159
|
+
"id": 100013,
|
|
1161
1160
|
"name": "Swap",
|
|
1162
1161
|
"description": "Swap two assets using the best market rates accross multiple pools",
|
|
1163
1162
|
"type": 1,
|
|
@@ -1213,7 +1212,7 @@ export const ACTIONS = {
|
|
|
1213
1212
|
"mandatory": true,
|
|
1214
1213
|
"category": 0,
|
|
1215
1214
|
"erc20FormattedAmount": {
|
|
1216
|
-
"contractAddress": "
|
|
1215
|
+
"contractAddress": "{{parameters.tokenIn}}",
|
|
1217
1216
|
"chain": "{{parameters.chainId}}"
|
|
1218
1217
|
}
|
|
1219
1218
|
},
|
|
@@ -1265,10 +1264,9 @@ export const ACTIONS = {
|
|
|
1265
1264
|
"labelNotAuthorized": [
|
|
1266
1265
|
"Transfer ETH"
|
|
1267
1266
|
]
|
|
1268
|
-
}
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
}
|
|
1267
|
+
}
|
|
1268
|
+
},
|
|
1269
|
+
"blockId": 100013
|
|
1272
1270
|
}
|
|
1273
1271
|
},
|
|
1274
1272
|
"NOTIFICATIONS": {
|
|
@@ -1394,7 +1392,7 @@ export const ACTIONS = {
|
|
|
1394
1392
|
"chains": [
|
|
1395
1393
|
34443
|
|
1396
1394
|
],
|
|
1397
|
-
"image": "https://otomato-sdk-images.s3.eu-west-1.amazonaws.com/
|
|
1395
|
+
"image": "https://otomato-sdk-images.s3.eu-west-1.amazonaws.com/Transfer.svg",
|
|
1398
1396
|
"TRANSFER": {
|
|
1399
1397
|
"name": "Transfer token",
|
|
1400
1398
|
"description": "Transfers an ERC20 token",
|
|
@@ -1481,7 +1479,7 @@ export const ACTIONS = {
|
|
|
1481
1479
|
]
|
|
1482
1480
|
},
|
|
1483
1481
|
"blockId": 100004,
|
|
1484
|
-
"image": "https://otomato-sdk-images.s3.eu-west-1.amazonaws.com/
|
|
1482
|
+
"image": "https://otomato-sdk-images.s3.eu-west-1.amazonaws.com/Transfer.svg"
|
|
1485
1483
|
}
|
|
1486
1484
|
}
|
|
1487
1485
|
},
|
|
@@ -1943,7 +1941,7 @@ export const ACTIONS = {
|
|
|
1943
1941
|
"mandatory": true,
|
|
1944
1942
|
"category": 0,
|
|
1945
1943
|
"erc20FormattedAmount": {
|
|
1946
|
-
"contractAddress": "
|
|
1944
|
+
"contractAddress": "{{parameters.tokenIn}}",
|
|
1947
1945
|
"chain": "{{parameters.chainId}}"
|
|
1948
1946
|
}
|
|
1949
1947
|
},
|
|
@@ -45,7 +45,7 @@ const createETHFearAndGreedBuy = () => __awaiter(void 0, void 0, void 0, functio
|
|
|
45
45
|
const createETHFearAndGreedCapitalEfficientBuy = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
46
46
|
const trigger = new Trigger(TRIGGERS.SOCIALS.FEAR_AND_GREED.GET_FEAR_AND_GREED_INDEX);
|
|
47
47
|
trigger.setCondition('lt');
|
|
48
|
-
trigger.setComparisonValue(
|
|
48
|
+
trigger.setComparisonValue(45);
|
|
49
49
|
trigger.setPosition(400, 120);
|
|
50
50
|
const chain = CHAINS.MODE;
|
|
51
51
|
const tokenIn = 'USDC';
|
|
@@ -7,7 +7,8 @@ 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 {
|
|
10
|
+
import { CHAINS } from "../constants/chains.js";
|
|
11
|
+
import { getToken, getTokenFromSymbol } from "../constants/tokens.js";
|
|
11
12
|
export class SessionKeyPermission {
|
|
12
13
|
constructor({ approvedTargets = [], label = [], labelNotAuthorized = [], } = {}) {
|
|
13
14
|
this.approvedTargets = approvedTargets;
|
|
@@ -31,22 +32,30 @@ export class SessionKeyPermission {
|
|
|
31
32
|
*/
|
|
32
33
|
fillBeforeVariables(beforeCode, parameters) {
|
|
33
34
|
return __awaiter(this, void 0, void 0, function* () {
|
|
35
|
+
console.log("filling before variable");
|
|
34
36
|
try {
|
|
35
|
-
// Prepare the
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
// Prepare the otomatoSdk object with required functions
|
|
38
|
+
const otomatoSdk = {
|
|
39
|
+
getToken,
|
|
40
|
+
getTokenFromSymbol,
|
|
41
|
+
CHAINS
|
|
42
|
+
// Include any other functions you need from otomato-sdk
|
|
43
|
+
};
|
|
44
|
+
// Prepare the environment with parameters and otomatoSdk
|
|
45
|
+
const env = { parameters, otomatoSdk };
|
|
46
|
+
// Replace the dynamic import in beforeCode
|
|
47
|
+
const beforeCodeUpdated = beforeCode.replace(/const\s+otomatoSdk\s*=\s*await\s*import\(['"]otomato-sdk['"]\);/, 'const otomatoSdk = env.otomatoSdk;');
|
|
39
48
|
// Wrap the beforeCode in an async function and immediately invoke it
|
|
40
49
|
const asyncBeforeFn = new Function('env', `
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
50
|
+
return (async function() {
|
|
51
|
+
return await (${beforeCodeUpdated})(env);
|
|
52
|
+
})();
|
|
53
|
+
`);
|
|
45
54
|
// Execute the async function and await the result
|
|
46
55
|
const beforeResult = yield asyncBeforeFn(env);
|
|
47
56
|
// Replace placeholders like {{before.variableName}} with the corresponding values
|
|
48
57
|
if (beforeResult && typeof beforeResult === 'object') {
|
|
49
|
-
Object.keys(beforeResult).forEach(key => {
|
|
58
|
+
Object.keys(beforeResult).forEach((key) => {
|
|
50
59
|
this.fill(`before.${key}`, beforeResult[key]);
|
|
51
60
|
});
|
|
52
61
|
}
|
|
@@ -55,7 +64,7 @@ export class SessionKeyPermission {
|
|
|
55
64
|
}
|
|
56
65
|
}
|
|
57
66
|
catch (error) {
|
|
58
|
-
console.error(
|
|
67
|
+
console.error("Error executing before code:", error);
|
|
59
68
|
}
|
|
60
69
|
});
|
|
61
70
|
}
|
|
@@ -458,7 +458,6 @@ export declare const ACTIONS: {
|
|
|
458
458
|
SWAP: {
|
|
459
459
|
description: string;
|
|
460
460
|
chains: number[];
|
|
461
|
-
image: string;
|
|
462
461
|
SWAP: {
|
|
463
462
|
id: number;
|
|
464
463
|
name: string;
|
|
@@ -527,9 +526,8 @@ export declare const ACTIONS: {
|
|
|
527
526
|
label: string[];
|
|
528
527
|
labelNotAuthorized: string[];
|
|
529
528
|
};
|
|
530
|
-
blockId: number;
|
|
531
|
-
image: string;
|
|
532
529
|
};
|
|
530
|
+
blockId: number;
|
|
533
531
|
};
|
|
534
532
|
};
|
|
535
533
|
NOTIFICATIONS: {
|