rssnyder / discord-stock-ticker

Add live stock & crypto prices to your discord sidebar.
https://rssnyder.github.io/discord-stock-ticker/
MIT License
294 stars 113 forks source link

Hotfix/gas price api fix #157

Closed theding0x closed 2 years ago

theding0x commented 2 years ago

I noticed an issue with the gas price bot failing to get data from the API endpoints. I updated the code to use Zapper's v2 endpoints and removed the ethgaswatch.go file because that endpoint doesn't seem to be live anymore. ETH gas just gets the price from Zapper in this version.

rssnyder commented 2 years ago

thanks for the PR!

seems to work for ETH but not for binance-smart-chain or polygon:

INFO[0009] Watching gas price for binance-smart-chain
ERRO[0012] Error getting rates: json: cannot unmarshal number into Go struct field ZapperData.standard of type struct { BaseFeePerGas int64 "json:\"baseFeePerGas\""; MaxPriorityFeePerGas int64 "json:\"maxPriorityFeePerGas\""; MaxFeePerGas int64 "json:\"maxFeePerGas\"" }
INFO[0008] Watching gas price for polygon
ERRO[0011] Error getting rates: json: cannot unmarshal number into Go struct field ZapperData.standard of type struct { BaseFeePerGas int64 "json:\"baseFeePerGas\""; MaxPriorityFeePerGas int64 "json:\"maxPriorityFeePerGas\""; MaxFeePerGas int64 "json:\"maxFeePerGas\"" }

it looks like the data format for the other chains is different than ETH's:

{
  "eip1559": false,
  "standard": 78,
  "fast": 115,
  "instant": 129
}

you will need to add some logic for this.

rssnyder commented 2 years ago

I had some time to work on this today so I recreated your work over in https://github.com/rssnyder/discord-stock-ticker/pull/158 and tagged you as co-author so I could push it out while I'm online. Thanks for the contribution!