-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathworker-config.ts
182 lines (172 loc) · 7.04 KB
/
worker-config.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
import { AdrastiaConfig, BatchConfig } from "../../src/config/adrastia-config";
const STD_WRITE_DELAY = 5_000; // Workers incrementally push updates with higher gas prices at 5 second intervals
const workerIndex = parseInt(process.env.ADRASTIA_WORKER_INDEX ?? "1");
const GRAVITY_UPTIME_WEBHOOK_URL = process.env.GRAVITY_UPTIME_WEBHOOK_URL;
const STANDARD_BATCH_CONFIG: BatchConfig = {
// Primary polls every second, secondary every 2 seconds, others every 4 seconds
pollingInterval: workerIndex == 1 ? 1_000 : workerIndex == 2 ? 2_000 : 4_000,
writeDelay: STD_WRITE_DELAY * (workerIndex - 1),
logging: [
process.env.DATADOG_API_KEY
? {
type: "datadog",
sourceToken: process.env.DATADOG_API_KEY,
region: process.env.DATADOG_REGION,
level: "notice",
}
: undefined,
process.env.ADRASTIA_LOGTAIL_TOKEN
? {
type: "logtail",
sourceToken: process.env.ADRASTIA_LOGTAIL_TOKEN,
level: "info",
}
: undefined,
],
customerId: "pyth-gravity",
type: "pyth-feeds",
};
// The primary worker uses 1 wei per feed update to calculate the update fee. Others call the Pyth contract to calculate
// the update fee.
const UPDATE_FEE = workerIndex == 1 ? 1n : undefined;
const MULTICALL3_ADDRESS = "0xcA11bde05977b3631167028862bE2a173976CA11";
// Priority is based on the worker index. Lower value means higher priority.
const PYTH_HERMES_ENDPOINTS = [
{
name: "Extrnode",
url: process.env.PYTH_HERMES_EXTRNODE_URL,
priority: {
1: 1,
2: 2,
3: 1,
4: 2,
},
},
{
name: "Pyth Official",
url: "https://hermes.pyth.network",
priority: {
1: 2,
2: 1,
3: 2,
4: 1,
},
},
];
const sortedHermesEndpoints = PYTH_HERMES_ENDPOINTS.sort((a, b) => {
return a.priority[workerIndex] - b.priority[workerIndex];
}).map((endpoint) => {
// Only return name and url
return {
name: endpoint.name,
url: endpoint.url,
};
});
const config: AdrastiaConfig = {
httpCacheSeconds: 0,
pythHermesEndpoints: sortedHermesEndpoints,
chains: {
gravity: {
txConfig: {
gasLimitMultiplier: {
dividend: 2n,
divisor: 1n,
},
transactionTimeout: STD_WRITE_DELAY * 2,
txType: 2,
eip1559: {
// Gas prices are based on the 75th percentile
percentile: 75,
historicalBlocks: Math.ceil(5 * 4), // 5 seconds of blocks
// Base fee multiplier of 1.25
baseFeeMultiplierDividend: 125n,
baseFeeMultiplierDivisor: 100n,
},
// Gas prices are incrementally scaled based on worker index
gasPriceMultiplierDividend: 100n + BigInt(workerIndex - 1) * 50n,
gasPriceMultiplierDivisor: 100n,
// Check for tx confirmations every 250ms
confirmationPollingInterval: 250,
// Wait up to 5 seconds for tx confirmations
transactionConfirmationTimeout: 5_000,
// Wait for 5 confirmations
waitForConfirmations: 5,
// Gas limit is hardcoded for the primary worker, others use the RPC to estimate gas
gasLimit: workerIndex == 1 ? 30_000_000n : undefined,
},
multicall2Address: MULTICALL3_ADDRESS,
pythAddress: "0x2880aB155794e7179c9eE2e38200202908C17B43",
uptimeWebhookUrl: GRAVITY_UPTIME_WEBHOOK_URL,
batches: {
0: {
...STANDARD_BATCH_CONFIG,
batchId: "0-pyth-feeds",
},
},
oracles: [
{
type: "pyth-feeds",
address: "0x86C25Cd48783b1f006BD7BD61692bfCF0755fb1B", // Adrastia Pyth Updater contract address
tokens: [
{
address: "0x9d4294bbcd1174d6f2003ec365831e64cc31d9f6f15a2b85399db8d5000960f6",
batch: 0,
extra: {
desc: "WETH/USD",
heartbeat: 60, // 1 minute
updateThreshold: 10, // 10 bips, 0.1%
earlyUpdateTime: 30, // 30 seconds
updateFee: UPDATE_FEE,
},
},
{
address: "0xc9d8b075a5c69303365ae23633d4e085199bf5c520a3b90fed1322a0342ffc33",
batch: 0,
extra: {
desc: "WBTC/USD",
heartbeat: 60, // 1 minute
updateThreshold: 10, // 10 bips, 0.1%
earlyUpdateTime: 30, // 30 seconds
updateFee: UPDATE_FEE,
},
},
{
address: "0xeaa020c61cc479712813461ce153894a96a6c00b21ed0cfc2798d1f9a9e9c94a",
batch: 0,
extra: {
desc: "USDC/USD",
heartbeat: 60, // 1 minute
updateThreshold: 10, // 10 bips, 0.1%
earlyUpdateTime: 30, // 30 seconds
updateFee: UPDATE_FEE,
},
},
{
address: "0x2b89b9dc8fdf9f34709a5b106b472f0f39bb6ca9ce04b0fd7f2e971688e2e53b",
batch: 0,
extra: {
desc: "USDT/USD",
heartbeat: 60, // 1 minute
updateThreshold: 10, // 10 bips, 0.1%
earlyUpdateTime: 30, // 30 seconds
updateFee: UPDATE_FEE,
},
},
{
address: "0x0f6539d2f188eef5cb9dfba796f4c40407e55df14bb668a81a9ba3678d5a625c",
batch: 0,
extra: {
desc: "G/USD",
heartbeat: 60, // 1 minute
updateThreshold: 10, // 10 bips, 0.1%
earlyUpdateTime: 30, // 30 seconds
updateFee: UPDATE_FEE,
},
},
],
},
],
},
},
};
export default config;