Skip to content

Commit

Permalink
feat(x/twap): whitelist GeometricTwap and GeometricTwapToNow (#3852)
Browse files Browse the repository at this point in the history
* feat(x/twap): GeometricTwap and GeometricTwapToNow queries added to Stargate whitelist

* update docs
  • Loading branch information
p0mvn authored and czarcas7ic committed Jan 4, 2023
1 parent c7c0222 commit 1afb23e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 20 deletions.
23 changes: 4 additions & 19 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 2 additions & 0 deletions wasmbinding/stargate_whitelist.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{})
}

Expand Down
7 changes: 6 additions & 1 deletion x/twap/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 1afb23e

Please sign in to comment.