classic-terra / oracle-feeder

Oracle Feeder Daemon
Apache License 2.0
6 stars 8 forks source link

Add SDR calculation #30

Closed StrathCole closed 4 weeks ago

StrathCole commented 1 year ago

To address missing price sources for SDR, this implements a price calculation based on the SDR currency basket as a fallback if all sources fail to provide a SDR price.

https://github.com/classic-terra/oracle-feeder/issues/28

StrathCole commented 1 year ago

@nghuyenthevinh2000

StrathCole commented 1 year ago
[INFO][Fri, 29 Sep 2023 11:32:58 GMT] [VOTE] Requesting prices from price server http://oracle-price-server:8532/latest
[INFO][Fri, 29 Sep 2023 11:32:58 GMT] [VOTE] SDR price: 1.31140786
[INFO][Fri, 29 Sep 2023 11:32:58 GMT] [VOTE] Create transaction and sign
[INFO][Fri, 29 Sep 2023 11:32:58 GMT] [PREVOTE] msg: ["{\"@type\":\"/terra.oracle.v1beta1.MsgAggregateExchangeRateVote\",\"exchange_rates\":\"0.000098681498928411uaud,0.00008504989229897ucad,0.000057939360514083uchf,0.000460890895542999ucny,0.00044638106543924udkk,0.000059869023246832ueur,0.000051688345703151ugbp,0.000493863209140862uhkd,0.985874431247445781uidr,0.005244884754766129uinr,0.009417307999975601ujpy,0.08526481567545477ukrw,0.0umnt,0.000297061975517121umyr,0.000677504172660115unok,0.00359111915764579uphp,0.000048113150396885usdr,0.000694889466958552usek,0.000086397321100694usgd,0.002314598811439344uthb,0.0utwd,0.000063095963599837uusd\",\"feeder\":\"terra184wr7j2qgpgvk3vqdg79vpvdw5ave2n22ndq9g\",\"salt\":\"ca07\",\"validator\":\"terravaloper1cvypxvg8xa4n34rtk8408p5wxcdchan7fjvwmv\"}","{\"@type\":\"/terra.oracle.v1beta1.MsgAggregateExchangeRatePrevote\",\"feeder\":\"terra184wr7j2qgpgvk3vqdg79vpvdw5ave2n22ndq9g\",\"hash\":\"d574d9d7796a7bc19b117e85de7d0499a5132bba\",\"validator\":\"terravaloper1cvypxvg8xa4n34rtk8408p5wxcdchan7fjvwmv\"}"]

[INFO][Fri, 29 Sep 2023 11:33:03 GMT] [VOTE] Broadcast success 4D967F35E79CEABCFF9D071FA5B431C00CA534CD1D09DF8F0BEC9810AFF73129
[INFO][Fri, 29 Sep 2023 11:33:07 GMT] [VOTE] Included at height: 16358971
StrathCole commented 1 year ago

Looks good 👍🏼 Just need to be a bit careful with the testing.

I reworked it after a suggestion from PFC and moved all logic to the price server.

StrathCole commented 1 year ago

Alternative or additional approach: https://github.com/aeuser999/test_oracle_feeder/commit/141872a89fb5ddeb5b915c8d8b8380600eec02a5

inon-man commented 1 year ago

31 added a fallback provider IMF for SDR/USD