hyperlane-xyz / hyperlane-monorepo

The home for Hyperlane core contracts, sdk packages, and other infrastructure
https://hyperlane.xyz
Other
331 stars 360 forks source link

Agents: use configured `nativeToken.decimals` for balance metrics #3354

Open tkporter opened 8 months ago

tkporter commented 8 months ago

Problem

At the moment, we assume that a particular protocol type will always have the same number of decimals for their native token: https://github.com/hyperlane-xyz/hyperlane-monorepo/blob/e737d998ff23b5aa6cf2be9634789ca5dc5a4275/rust/hyperlane-core/src/metrics/agent.rs#L24-L29

This is not the case for Cosmos - atm our COSMOS_DECIMALS is set to 6, which is correct for Neutron, but Injective's decimal count is 18: https://github.com/cosmos/chain-registry/blob/9a9a5860aebc27b280f4377adca93eab82c59e78/injective/assetlist.json#L14

Iiuc this led to us misinterpreting injective balance metrics in alerts / dashboards

Solution

We already have the nativeToken config that comes from the SDK chain metadatas (at least for EVM chains - recall that atm all non-EVM chain configs are handcrafted. This should be addressed in https://github.com/hyperlane-xyz/hyperlane-monorepo/issues/3325).

yorhodes commented 7 months ago

note that the chainMetadata.nativeToken definitions are being moved out of the SDK to the registry