Skip to content

Commit 5e356f4

Browse files
authored
fix(apps/price_pusher): handle gas overrides properly (#2669)
* fix(apps/price_pusher): handle gas overrides properly * chore: discourage using confidence check * fix: remove the timeout that was added by mistake
1 parent 5755a64 commit 5e356f4

File tree

5 files changed

+17
-18
lines changed

5 files changed

+17
-18
lines changed

apps/price_pusher/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ It then pushes a price update to an on-chain Pyth contract if any of the followi
2727
- Price deviation: The latest Pyth price feed has changed more than `price_deviation` percent
2828
from the on-chain price feed price.
2929
- Confidence ratio: The latest Pyth price feed has confidence to price ratio of more than
30-
`confidence_ratio`.
30+
`confidence_ratio`. *We discourage using low values for this because it triggers push for every update in high confidence periods.*
3131

3232
The parameters above are configured per price feed in a price configuration YAML file. The structure looks like this:
3333

@@ -36,7 +36,7 @@ The parameters above are configured per price feed in a price configuration YAML
3636
id: 0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef # id of a price feed, a 32-byte hex string.
3737
time_difference: 60 # Time difference threshold (in seconds) to push a newer price feed.
3838
price_deviation: 0.5 # The price deviation (%) threshold to push a newer price feed.
39-
confidence_ratio: 1 # The confidence/price (%) threshold to push a newer price feed.
39+
confidence_ratio: 50 # The confidence/price (%) threshold to push a newer price feed.
4040

4141
# Optional block to configure whether this feed can be early updated. If at least one feed meets the
4242
# triggering conditions above, all other feeds who meet the early update conditions will be included in
@@ -46,7 +46,7 @@ The parameters above are configured per price feed in a price configuration YAML
4646
early_update:
4747
time_difference: 30
4848
price_deviation: 0.1
49-
confidence_ratio: 0.5
49+
confidence_ratio: 5
5050
- ...
5151
```
5252
@@ -65,7 +65,7 @@ the feed.
6565
early_update:
6666
time_difference: 30
6767
price_deviation: 0.1
68-
confidence_ratio: 0.5
68+
confidence_ratio: 5
6969
```
7070

7171
Two sample YAML configuration files are available in the root of this repo.

apps/price_pusher/price-config.beta.sample.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
id: f9c0172ba10dfa4d19088d94f5bf61d3b54d5bd7483a322a982e1373ee8ea31b
33
time_difference: 60
44
price_deviation: 0.5
5-
confidence_ratio: 1
5+
confidence_ratio: 100
66
- alias: BNB/USD
77
id: ecf553770d9b10965f8fb64771e93f5690a182edc32be4a3236e0caaa6e0581a
88
time_difference: 60
99
price_deviation: 1
10-
confidence_ratio: 1
10+
confidence_ratio: 100
1111
early_update:
1212
time_difference: 30
1313
price_deviation: 0.5
14-
confidence_ratio: 0.1
14+
confidence_ratio: 10

apps/price_pusher/price-config.stable.sample.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,18 @@
22
id: e62df6c8b4a85fe1a67db44dc12de5db330f7ac66b72dc658afedf0f4a415b43
33
time_difference: 60
44
price_deviation: 0.5
5-
confidence_ratio: 1
5+
confidence_ratio: 100
66
- alias: BNB/USD
77
id: 2f95862b045670cd22bee3114c39763a4a08beeb663b145d283c31d7d1101c4f
88
time_difference: 60
99
price_deviation: 1
10-
confidence_ratio: 1
10+
confidence_ratio: 100
1111
early_update:
1212
time_difference: 30
1313
price_deviation: 0.5
14-
confidence_ratio: 0.1
14+
confidence_ratio: 10
1515
- alias: PYTH/USD
1616
id: 0bbf28e9a841a1cc788f6a361b17ca072d0ea3098a1e5df1c3922d06719579ff
1717
time_difference: 60
1818
price_deviation: 0.5
19-
confidence_ratio: 1
19+
confidence_ratio: 100

apps/price_pusher/src/evm/command.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,6 @@ export default {
110110
enableMetrics,
111111
metricsPort,
112112
} = argv;
113-
console.log("***** priceServiceEndpoint *****", priceServiceEndpoint);
114113

115114
const logger = pino({
116115
level: logLevel,

apps/price_pusher/src/evm/evm.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,12 @@ export class EvmPricePusher implements IPricePusher {
235235

236236
const priceIdsWith0x = priceIds.map((priceId) => addLeading0x(priceId));
237237

238+
// Update lastAttempt
239+
this.lastPushAttempt = {
240+
nonce: txNonce,
241+
gasPrice: gasPrice,
242+
};
243+
238244
try {
239245
const { request } =
240246
await this.pythContract.simulate.updatePriceFeedsIfNecessary(
@@ -383,12 +389,6 @@ export class EvmPricePusher implements IPricePusher {
383389
);
384390
throw err;
385391
}
386-
387-
// Update lastAttempt
388-
this.lastPushAttempt = {
389-
nonce: txNonce,
390-
gasPrice: gasPrice,
391-
};
392392
}
393393

394394
private async waitForTransactionReceipt(hash: `0x${string}`): Promise<void> {

0 commit comments

Comments
 (0)