Skip to content

Commit

Permalink
refactor: Update median tracking for historacle pricing (#1632)
Browse files Browse the repository at this point in the history
* Refactor historacle median tracking

* lint

* Update historacle keeper methods

* Add pricestats unit test

* Add Get to getter keeper methods

* PR comments

* Update x/oracle/types/keys.go

Co-authored-by: Kyle <zarazan@users.noreply.github.com>

* Add ParseBlockFromKey comment

* lint

* Add decmath util package

* Update keeper methods in historacle design doc

* Update WithinMedianDeviation

* revert file picked up by gofmt

* switch umee version from v3.2.0 -> ../ (again)

this is due to e2e tests failing with a change in the oracle parameters query

* Fix keeper method names

* Update util/decmath/decmath.go

Co-authored-by: Robert Zaremba <robert@zaremba.ch>

* Update util/decmath/decmath.go

Co-authored-by: Robert Zaremba <robert@zaremba.ch>

* Update util/decmath/decmath.go

Co-authored-by: Robert Zaremba <robert@zaremba.ch>

* Update x/oracle/abci.go

Co-authored-by: Robert Zaremba <robert@zaremba.ch>

* PR comments

* lint

* update method names in design doc

* Use KVStoreReversePrefixIteratorPaginated

* Update iterator method names and comments

Co-authored-by: Kyle <zarazan@users.noreply.github.com>
Co-authored-by: Adam Wozniak <29418299+adamewozniak@users.noreply.github.com>
Co-authored-by: Robert Zaremba <robert@zaremba.ch>
  • Loading branch information
4 people authored Dec 9, 2022
1 parent 0032834 commit 0903f03
Show file tree
Hide file tree
Showing 30 changed files with 983 additions and 906 deletions.
4 changes: 2 additions & 2 deletions app/upgradev3x3/gov_legacy.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions docs/design_docs/011-historacle-pricing.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,12 @@ We define two Maximum values, which correspond to the most we will store of a me

Modules will have access to the following `keeper` functions from the `x/oracle` module:

- `HistoricMedian(denom) ([]sdk.Dec, error)` returns list median prices of an asset in the last `Pruning Period`
- `WithinHistoricDeviation(denom) (bool, error)` returns whether or not the current price of an asset is within the Standard Deviation around the Median.
- `MedianOfMedians(denom string, blockNum int) sdk.Dec` returns the Median of the all the Medians recorded within the past `blockNum`. TODO: what does it mean "within the past blockNum"?
- `AverageOfMedians(denom string, blockNum int) sdk.Dec` returns the Average of all the Medians recorded within the past `blockNum`.
- `MaxMedian(denom string, blockNum int) sdk.Dec` returns the Maximum of all the Medians recorded within the past `blockNum`.
- `MinMedian(denom string, blockNum int) sdk.Dec` returns the Minimum of all the Medians recorded within the past `blockNum`.
- `HistoricMedians(denom string, numStamps uint64) []sdk.Dec` returns list of last `numStamps` amount of median prices of an asset
- `WithinHistoricDeviation(denom string) (bool, error)` returns whether or not the current price of an asset is within the Standard Deviation around the Median.
- `MedianOfHistoricMedians(denom string, numStamps uint64) (sdk.Dec, error)` returns the Median of the all the Medians recorded within the past `numStamps` of medians.
- `AverageOfHistoricMedians(denom string, numStamps uint64) (sdk.Dec, error)` returns the Average of all the Medians recorded within the past `numStamps` of medians.
- `MaxOfHistoricMedians(denom string, numStamps uint64) (sdk.Dec, error)` returns the Maximum of all the Medians recorded within the past `numStamps` of medians.
- `MinOfHistoricMedians(denom string, numStamps uint64) (sdk.Dec, error)` returns the Minimum of all the Medians recorded within the past `numStamps` of medians.

### Outcomes

Expand Down
22 changes: 11 additions & 11 deletions price-feeder/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ require (

require (
4d63.com/gochecknoglobals v0.1.0 // indirect
cloud.google.com/go v0.104.0 // indirect
cloud.google.com/go v0.105.0 // indirect
cloud.google.com/go/compute v1.12.1 // indirect
cloud.google.com/go/compute/metadata v0.2.1 // indirect
cloud.google.com/go/iam v0.4.0 // indirect
cloud.google.com/go/storage v1.23.0 // indirect
cloud.google.com/go/iam v0.7.0 // indirect
cloud.google.com/go/storage v1.27.0 // indirect
cosmossdk.io/errors v1.0.0-beta.7 // indirect
cosmossdk.io/math v1.0.0-beta.3 // indirect
cosmossdk.io/math v1.0.0-beta.4 // indirect
filippo.io/edwards25519 v1.0.0-rc.1 // indirect
github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect
github.com/99designs/keyring v1.2.1 // indirect
Expand Down Expand Up @@ -74,7 +74,7 @@ require (
github.com/coinbase/rosetta-sdk-go v0.7.9 // indirect
github.com/confio/ics23/go v0.7.0 // indirect
github.com/cosmos/btcutil v1.0.4 // indirect
github.com/cosmos/cosmos-proto v1.0.0-alpha8 // indirect
github.com/cosmos/cosmos-proto v1.0.0-beta.1 // indirect
github.com/cosmos/go-bip39 v1.0.0 // indirect
github.com/cosmos/gogoproto v1.4.2 // indirect
github.com/cosmos/gorocksdb v1.2.0 // indirect
Expand Down Expand Up @@ -143,7 +143,6 @@ require (
github.com/google/uuid v1.3.0 // indirect
github.com/googleapis/enterprise-certificate-proxy v0.2.0 // indirect
github.com/googleapis/gax-go/v2 v2.6.0 // indirect
github.com/googleapis/go-type-adapters v1.0.0 // indirect
github.com/gordonklaus/ineffassign v0.0.0-20210914165742-4cc7213b9bc8 // indirect
github.com/gorilla/handlers v1.5.1 // indirect
github.com/gostaticanalysis/analysisutil v0.7.1 // indirect
Expand Down Expand Up @@ -282,16 +281,16 @@ require (
golang.org/x/exp v0.0.0-20220722155223-a9213eeb770e // indirect
golang.org/x/exp/typeparams v0.0.0-20220827204233-334a2380cb91 // indirect
golang.org/x/mod v0.6.0 // indirect
golang.org/x/net v0.1.0 // indirect
golang.org/x/oauth2 v0.0.0-20221014153046-6fdb5e3db783 // indirect
golang.org/x/sys v0.1.0 // indirect
golang.org/x/term v0.1.0 // indirect
golang.org/x/net v0.2.0 // indirect
golang.org/x/oauth2 v0.2.0 // indirect
golang.org/x/sys v0.2.0 // indirect
golang.org/x/term v0.2.0 // indirect
golang.org/x/text v0.4.0 // indirect
golang.org/x/tools v0.2.0 // indirect
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect
google.golang.org/api v0.102.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto v0.0.0-20221024183307-1bc688fe9f3e // indirect
google.golang.org/genproto v0.0.0-20221114212237-e4508ebdbee1 // indirect
google.golang.org/protobuf v1.28.2-0.20220831092852-f930b1dc76e8 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
Expand All @@ -313,4 +312,5 @@ replace (
github.com/dgrijalva/jwt-go => github.com/golang-jwt/jwt/v4 v4.4.2
github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1
github.com/osmosis-labs/bech32-ibc => github.com/umee-network/bech32-ibc v0.3.1
github.com/umee-network/umee/v3 => ../
)
Loading

0 comments on commit 0903f03

Please sign in to comment.