Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 31 additions & 3 deletions apps/price_pusher/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -211,12 +211,12 @@ and the on-chain Pyth contract and deciding whether to push a new price. You can

### Example

For example, to push `BTC/USD` and `BNB/USD` prices on Fantom testnet, run the following command:
For example, to push `BTC/USD` and `BNB/USD` prices on Sonic blaze testnet, run the following command:

```sh
pnpm run dev evm \
--endpoint https://endpoints.omniatech.io/v1/fantom/testnet/public \
--pyth-contract-address 0x5744Cbf430D99456a0A8771208b674F27f8EF0Fb \
--endpoint https://rpc.blaze.soniclabs.com \
--pyth-contract-address 0x2880aB155794e7179c9eE2e38200202908C17B43 \
--price-service-endpoint https://hermes.pyth.network \
--mnemonic-file "./mnemonic" \
--price-config-file "./price-config.stable.sample.yaml" \
Expand Down Expand Up @@ -272,6 +272,8 @@ The following metrics are available:
- **pyth_price_last_published_time** (Gauge): The last published time of a price feed in unix timestamp, labeled by price_id and alias
- **pyth_price_update_attempts_total** (Counter): Total number of price update attempts with their trigger condition and status, labeled by price_id, alias, trigger, and status
- **pyth_price_feeds_total** (Gauge): Total number of price feeds being monitored
- **pyth_source_price** (Gauge): Latest price value from Pyth source, labeled by price_id and alias
- **pyth_target_price** (Gauge): Latest price value from target chain, labeled by price_id and alias
- **pyth_wallet_balance** (Gauge): Current wallet balance of the price pusher in native token units, labeled by wallet_address and network

### Configuration
Expand Down Expand Up @@ -343,6 +345,30 @@ pyth_wallet_balance
pyth_wallet_balance < 0.1
```

7. Monitor current source price values:

```
pyth_source_price
```

8. Monitor current target price values:

```
pyth_target_price
```

9. Compare source vs target price differences:

```
abs(pyth_source_price - pyth_target_price) / pyth_source_price * 100
```

10. Detect significant price deviations (>1%):

```
abs(pyth_source_price - pyth_target_price) / pyth_source_price * 100 > 1
```

### Dashboard

The docker-compose setup includes a pre-configured Grafana dashboard (`grafana-dashboard.sample.json`) that provides monitoring of your price pusher operations. The dashboard includes the following panels:
Expand All @@ -353,6 +379,8 @@ The docker-compose setup includes a pre-configured Grafana dashboard (`grafana-d
- **Price Feeds List**: A table listing all configured price feeds with their details.
- **Successful Updates (Current Range)**: Graph showing the number of successful price updates over the current range with timeline.
- **Update Conditions Distribution**: Pie chart showing the distribution of update conditions (YES/NO/EARLY) over the selected time range.
- **Source vs Target Price Values**: Graphs showing current price values from both Pyth source and target chains for comparison.
- **Price Deviation Monitoring**: Panels to track price differences between source and target chains.
- **Wallet Balance**: Current balance of your wallet in native token units.
- **Wallet Balance Over Time**: Graph tracking your wallet balance over time to monitor consumption.
- **Failed Updates (Current Range)**: Graph showing the number of failed price updates over the current range with timeline.
Expand Down
2 changes: 1 addition & 1 deletion apps/price_pusher/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pythnetwork/price-pusher",
"version": "10.0.0",
"version": "10.1.0",
"description": "Pyth Price Pusher",
"homepage": "https://pyth.network",
"main": "lib/index.js",
Expand Down
6 changes: 6 additions & 0 deletions apps/price_pusher/src/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@ export class Controller {
sourceLatestPrice.publishTime,
priceConfig.timeDifference,
);
this.metrics.updatePriceValues(
priceId,
alias,
sourceLatestPrice.price,
targetLatestPrice.price,
);
}

const priceShouldUpdate = shouldUpdate(
Expand Down
37 changes: 37 additions & 0 deletions apps/price_pusher/src/metrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ export class PricePusherMetrics {
public priceFeedsTotal: Gauge<string>;
public sourceTimestamp: Gauge<string>;
public configuredTimeDifference: Gauge<string>;
public sourcePriceValue: Gauge<string>;
public targetPriceValue: Gauge<string>;
// Wallet metrics
public walletBalance: Gauge<string>;

Expand Down Expand Up @@ -61,6 +63,20 @@ export class PricePusherMetrics {
registers: [this.registry],
});

this.sourcePriceValue = new Gauge({
name: "pyth_source_price",
help: "Latest price value from Pyth source",
labelNames: ["price_id", "alias"],
registers: [this.registry],
});

this.targetPriceValue = new Gauge({
name: "pyth_target_price",
help: "Latest price value from target chain",
labelNames: ["price_id", "alias"],
registers: [this.registry],
});

// Wallet balance metric
this.walletBalance = new Gauge({
name: "pyth_wallet_balance",
Expand Down Expand Up @@ -158,6 +174,27 @@ export class PricePusherMetrics {
);
}

// Update price values
public updatePriceValues(
priceId: string,
alias: string,
sourcePrice: string | undefined,
targetPrice: string | undefined,
): void {
if (sourcePrice !== undefined) {
this.sourcePriceValue.set(
{ price_id: priceId, alias },
Number(sourcePrice),
);
}
if (targetPrice !== undefined) {
this.targetPriceValue.set(
{ price_id: priceId, alias },
Number(targetPrice),
);
}
}

// Update wallet balance
public updateWalletBalance(
walletAddress: string,
Expand Down
Loading