From 1afb23ebc178512df9ba32bb2f344a6912e0dc43 Mon Sep 17 00:00:00 2001 From: Roman Date: Fri, 23 Dec 2022 18:30:06 -0500 Subject: [PATCH] feat(x/twap): whitelist GeometricTwap and GeometricTwapToNow (#3852) * feat(x/twap): GeometricTwap and GeometricTwapToNow queries added to Stargate whitelist * update docs --- CHANGELOG.md | 23 ++++------------------- wasmbinding/stargate_whitelist.go | 2 ++ x/twap/README.md | 7 ++++++- 3 files changed, 12 insertions(+), 20 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index df83ddd6249..4e09c10781c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -54,25 +54,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 * [#3677](https://github.com/osmosis-labs/osmosis/pull/3677) Add methods for cloning and mutative multiplication on osmomath.BigDec. * [#3676](https://github.com/osmosis-labs/osmosis/pull/3676) implement `PowerInteger` function on `osmomath.BigDec` * [#3678](https://github.com/osmosis-labs/osmosis/pull/3678) implement mutative `PowerIntegerMut` function on `osmomath.BigDec`. - -### Features - -### Bug fixes - -## v13.1.2 - -### Bug fixes - -* Fix state export -* Update swagger files for v13 - -## v13.1.1 - -* Add a check in the makefile for using go v1.18 - -## v13.1.0 - -* Correctly apply DragonBerry IBC patch +* [#3708](https://github.com/osmosis-labs/osmosis/pull/3708) `Exp2` function to compute 2^decimal. +* [#3693](https://github.com/osmosis-labs/osmosis/pull/3693) Add `EstimateSwapExactAmountOut` query to stargate whitelist +* [#3731](https://github.com/osmosis-labs/osmosis/pull/3731) BigDec Power functions with decimal exponent. +* [#3847](https://github.com/osmosis-labs/osmosis/pull/3847) GeometricTwap and GeometricTwapToNow queries added to Stargate whitelist. ### API breaks diff --git a/wasmbinding/stargate_whitelist.go b/wasmbinding/stargate_whitelist.go index e3fd3fae74e..b7217e50527 100644 --- a/wasmbinding/stargate_whitelist.go +++ b/wasmbinding/stargate_whitelist.go @@ -123,6 +123,8 @@ func init() { // twap setWhitelistedQuery("/osmosis.twap.v1beta1.Query/ArithmeticTwap", &twapquerytypes.ArithmeticTwapResponse{}) setWhitelistedQuery("/osmosis.twap.v1beta1.Query/ArithmeticTwapToNow", &twapquerytypes.ArithmeticTwapToNowResponse{}) + setWhitelistedQuery("/osmosis.twap.v1beta1.Query/GeometricTwap", &twapquerytypes.GeometricTwapResponse{}) + setWhitelistedQuery("/osmosis.twap.v1beta1.Query/GeometricTwapToNow", &twapquerytypes.GeometricTwapToNowResponse{}) setWhitelistedQuery("/osmosis.twap.v1beta1.Query/Params", &twapquerytypes.ParamsResponse{}) } diff --git a/x/twap/README.md b/x/twap/README.md index aaae5be05f4..1a00a8369e3 100644 --- a/x/twap/README.md +++ b/x/twap/README.md @@ -30,7 +30,8 @@ Given these interpolated accumulation values, we can compute the TWAP as before. ## Module API -The primary intended API is `GetArithmeticTwap`, which is documented below, and has a similar cosmwasm binding. +The primary intended APIs are `GetArithmeticTwap` and `GetGeometricTwap`, which are documented below, +and have a similar cosmwasm binding. ```go // GetArithmeticTwap returns an arithmetic time weighted average price. @@ -68,6 +69,10 @@ func (k Keeper) GetArithmeticTwap(ctx sdk.Context, There are convenience methods for `GetArithmeticTwapToNow` which sets `endTime = ctx.BlockTime()`, and has minor gas reduction. For users who need TWAPs outside the 48 hours stored in the state machine, you can get the latest accumulation store record from `GetBeginBlockAccumulatorRecord`. +Geometric TWAP has comparable methods with the same parameters. Namely, `GetGeometricTwap` and `GetGeometricTwapToNow`. +The semantics of these methods are the same with the arithmetic version. The only difference is the low-level +computation of the TWAP, which is done via the geometric mean. + ## Code layout **api.go** is the main file you should look at as a user of this module.