diff --git a/proto/oracle/oracle.proto b/proto/oracle/oracle.proto index 6fa5d8f938..98a97f676b 100644 --- a/proto/oracle/oracle.proto +++ b/proto/oracle/oracle.proto @@ -119,3 +119,13 @@ message PriceSnapshot { (gogoproto.nullable) = false ]; } + +message OracleTwap { + string denom = 1; + string twap = 2 [ + (gogoproto.moretags) = "yaml:\"twap\"", + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; + int64 lookbackSeconds = 3; +} diff --git a/proto/oracle/query.proto b/proto/oracle/query.proto index 2dc4bdc2ee..ba79594469 100644 --- a/proto/oracle/query.proto +++ b/proto/oracle/query.proto @@ -34,6 +34,10 @@ service Query { option (google.api.http).get = "/sei-protocol/sei-chain/oracle/denoms/price_snapshot_history"; } + rpc Twaps(QueryTwapsRequest) returns (QueryTwapsResponse) { + option (google.api.http).get = "/sei-protocol/sei-chain/oracle/denoms/twaps"; + } + // FeederDelegation returns feeder delegation of a validator rpc FeederDelegation(QueryFeederDelegationRequest) returns (QueryFeederDelegationResponse) { option (google.api.http).get = "/sei-protocol/sei-chain/oracle/validators/{validator_addr}/feeder"; @@ -133,6 +137,18 @@ message QueryPriceSnapshotHistoryResponse { ]; } +// request type for twap RPC method +message QueryTwapsRequest { + int64 lookback_seconds = 1; +} + +message QueryTwapsResponse { + repeated OracleTwap oracle_twaps = 1 [ + (gogoproto.nullable) = false, + (gogoproto.castrepeated) = "OracleTwaps" + ]; +} + // QueryFeederDelegationRequest is the request type for the Query/FeederDelegation RPC method. message QueryFeederDelegationRequest { option (gogoproto.equal) = false; diff --git a/x/oracle/abci.go b/x/oracle/abci.go index 82a9e1d88f..65ffa12211 100755 --- a/x/oracle/abci.go +++ b/x/oracle/abci.go @@ -122,11 +122,13 @@ func EndBlocker(ctx sdk.Context, k keeper.Keeper) { priceSnapshotItems = append(priceSnapshotItems, priceSnapshotItem) return false }) - priceSnapshot := types.PriceSnapshot{ - SnapshotTimestamp: ctx.BlockTime().Unix(), - PriceSnapshotItems: priceSnapshotItems, + if len(priceSnapshotItems) > 0 { + priceSnapshot := types.PriceSnapshot{ + SnapshotTimestamp: ctx.BlockTime().Unix(), + PriceSnapshotItems: priceSnapshotItems, + } + k.AddPriceSnapshot(ctx, priceSnapshot) } - k.AddPriceSnapshot(ctx, priceSnapshot) } // Do slash who did miss voting over threshold and diff --git a/x/oracle/client/cli/query.go b/x/oracle/client/cli/query.go index a91bf74a6c..5dc76b9431 100755 --- a/x/oracle/client/cli/query.go +++ b/x/oracle/client/cli/query.go @@ -2,6 +2,7 @@ package cli import ( "context" + "strconv" "strings" "github.com/spf13/cobra" @@ -26,6 +27,7 @@ func GetQueryCmd() *cobra.Command { oracleQueryCmd.AddCommand( GetCmdQueryExchangeRates(), GetCmdQueryPriceSnapshotHistory(), + GetCmdQueryTwaps(), GetCmdQueryActives(), GetCmdQueryParams(), GetCmdQueryFeederDelegation(), @@ -120,6 +122,45 @@ $ seid query oracle price-snapshot-history return cmd } +func GetCmdQueryTwaps() *cobra.Command { + cmd := &cobra.Command{ + Use: "twaps [lookback-seconds]", + Args: cobra.ExactArgs(1), + Short: "Query the time weighted average prices for denoms with price snapshot data", + Long: strings.TrimSpace(` +Query the time weighted average prices for denoms with price snapshot data +Example: + +$ seid query oracle twaps +`), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + queryClient := types.NewQueryClient(clientCtx) + + lookbackSeconds, err := strconv.ParseInt(args[0], 10, 64) + if err != nil { + return err + } + + res, err := queryClient.Twaps( + context.Background(), + &types.QueryTwapsRequest{LookbackSeconds: lookbackSeconds}, + ) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + return cmd +} + // GetCmdQueryActives implements the query actives command. func GetCmdQueryActives() *cobra.Command { cmd := &cobra.Command{ diff --git a/x/oracle/client/rest/query.go b/x/oracle/client/rest/query.go index f7ca849acf..a70caa6a97 100755 --- a/x/oracle/client/rest/query.go +++ b/x/oracle/client/rest/query.go @@ -3,6 +3,7 @@ package rest import ( "fmt" "net/http" + "strconv" "github.com/gorilla/mux" @@ -18,6 +19,7 @@ func registerQueryRoutes(cliCtx client.Context, rtr *mux.Router) { rtr.HandleFunc("/oracle/denoms/price_snapshot_history", queryPriceSnapshotHistoryHandlerFunction(cliCtx)).Methods("GET") rtr.HandleFunc("/oracle/denoms/actives", queryActivesHandlerFunction(cliCtx)).Methods("GET") rtr.HandleFunc("/oracle/denoms/exchange_rates", queryExchangeRatesHandlerFunction(cliCtx)).Methods("GET") + rtr.HandleFunc("/oracle/denoms/twaps", queryTwapsHandlerFunction(cliCtx)).Methods("GET") rtr.HandleFunc("/oracle/denoms/vote_targets", queryVoteTargetsHandlerFunction(cliCtx)).Methods("GET") rtr.HandleFunc(fmt.Sprintf("/oracle/voters/{%s}/feeder", RestVoter), queryFeederDelegationHandlerFunction(cliCtx)).Methods("GET") rtr.HandleFunc(fmt.Sprintf("/oracle/voters/{%s}/miss", RestVoter), queryMissHandlerFunction(cliCtx)).Methods("GET") @@ -89,6 +91,34 @@ func queryPriceSnapshotHistoryHandlerFunction(cliCtx client.Context) http.Handle } } +func queryTwapsHandlerFunction(cliCtx client.Context) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + cliCtx, ok := rest.ParseQueryHeightOrReturnBadRequest(w, cliCtx, r) + if !ok { + return + } + + lookbackSeconds, ok := checkLookbackSecondsVar(w, r) + if !ok { + return + } + + params := types.NewQueryTwapsParams(lookbackSeconds) + bz, err := cliCtx.LegacyAmino.MarshalJSON(params) + if rest.CheckBadRequestError(w, err) { + return + } + + res, height, err := cliCtx.QueryWithData(fmt.Sprintf("custom/%s/%s", types.QuerierRoute, types.QueryTwaps), bz) + if rest.CheckInternalServerError(w, err) { + return + } + + cliCtx = cliCtx.WithHeight(height) + rest.PostProcessResponse(w, cliCtx, res) + } +} + func queryActivesHandlerFunction(cliCtx client.Context) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { cliCtx, ok := rest.ParseQueryHeightOrReturnBadRequest(w, cliCtx, r) @@ -292,6 +322,18 @@ func checkDenomVar(w http.ResponseWriter, r *http.Request) (string, bool) { return denom, true } +func checkLookbackSecondsVar(w http.ResponseWriter, r *http.Request) (int64, bool) { + lookbackSecondsStr := mux.Vars(r)[RestLookbackSeconds] + lookbackSeconds, err := strconv.ParseInt(lookbackSecondsStr, 10, 64) + if err != nil { + return 0, false + } + if lookbackSeconds <= 0 { + return 0, false + } + return lookbackSeconds, true +} + func checkVoterAddressVar(w http.ResponseWriter, r *http.Request) (sdk.ValAddress, bool) { addr, err := sdk.ValAddressFromBech32(mux.Vars(r)[RestVoter]) if rest.CheckBadRequestError(w, err) { diff --git a/x/oracle/client/rest/rest.go b/x/oracle/client/rest/rest.go index 008dad1ca5..44ef9312b0 100755 --- a/x/oracle/client/rest/rest.go +++ b/x/oracle/client/rest/rest.go @@ -9,8 +9,9 @@ import ( //nolint const ( - RestDenom = "denom" - RestVoter = "voter" + RestDenom = "denom" + RestVoter = "voter" + RestLookbackSeconds = "lookback_seconds" ) // RegisterRoutes registers oracle-related REST handlers to a router diff --git a/x/oracle/keeper/keeper.go b/x/oracle/keeper/keeper.go index 52098cdf83..e4b1935842 100755 --- a/x/oracle/keeper/keeper.go +++ b/x/oracle/keeper/keeper.go @@ -2,6 +2,7 @@ package keeper import ( "fmt" + "sort" "github.com/tendermint/tendermint/libs/log" @@ -417,7 +418,110 @@ func (k Keeper) IteratePriceSnapshots(ctx sdk.Context, handler func(snapshot typ } } +func (k Keeper) IteratePriceSnapshotsReverse(ctx sdk.Context, handler func(snapshot types.PriceSnapshot) (stop bool)) { + store := ctx.KVStore(k.storeKey) + iterator := sdk.KVStoreReversePrefixIterator(store, types.PriceSnapshotKey) + defer iterator.Close() + + for ; iterator.Valid(); iterator.Next() { + var val types.PriceSnapshot + k.cdc.MustUnmarshal(iterator.Value(), &val) + if handler(val) { + break + } + } +} + func (k Keeper) DeletePriceSnapshot(ctx sdk.Context, timestamp int64) { store := ctx.KVStore(k.storeKey) store.Delete(types.GetPriceSnapshotKey(uint64(timestamp))) } + +func (k Keeper) CalculateTwaps(ctx sdk.Context, lookbackSeconds int64) (types.OracleTwaps, error) { + oracleTwaps := types.OracleTwaps{} + currentTime := ctx.BlockTime().Unix() + err := k.ValidateLookbackSeconds(ctx, lookbackSeconds) + if err != nil { + return oracleTwaps, err + } + var timeTraversed int64 = 0 + denomToTimeWeightedMap := make(map[string]sdk.Dec) + denomDurationMap := make(map[string]int64) + + k.IteratePriceSnapshotsReverse(ctx, func(snapshot types.PriceSnapshot) (stop bool) { + stop = false + snapshotTimestamp := snapshot.SnapshotTimestamp + if currentTime-lookbackSeconds > snapshotTimestamp { + snapshotTimestamp = currentTime - lookbackSeconds + stop = true + } + // update time traversed to represent current snapshot + // replace SnapshotTimestamp with lookback duration bounding + timeTraversed = currentTime - snapshotTimestamp + + // iterate through denoms in the snapshot + // if we find a new one, we have to setup the TWAP calc for that one + snapshotPriceItems := snapshot.PriceSnapshotItems + for _, priceItem := range snapshotPriceItems { + denom := priceItem.Denom + + _, exists := denomToTimeWeightedMap[denom] + if !exists { + // set up the TWAP info for a denom + denomToTimeWeightedMap[denom] = sdk.ZeroDec() + denomDurationMap[denom] = 0 + } + // get the denom specific TWAP data + denomTimeWeightedSum := denomToTimeWeightedMap[denom] + denomDuration := denomDurationMap[denom] + + // calculate the new Time Weighted Sum for the denom exchange rate + // we calculate a weighted sum of exchange rates previously by multiplying each exchange rate by time interval that it was active + // then we divide by the overall time in the lookback window, which gives us the time weighted average + durationDifference := timeTraversed - denomDuration + exchangeRate := priceItem.OracleExchangeRate.ExchangeRate + denomTimeWeightedSum = denomTimeWeightedSum.Add(exchangeRate.MulInt64(durationDifference)) + + // set the denom TWAP data + denomToTimeWeightedMap[denom] = denomTimeWeightedSum + denomDurationMap[denom] = timeTraversed + } + return + }) + + denomKeys := make([]string, 0, len(denomToTimeWeightedMap)) + for k := range denomToTimeWeightedMap { + denomKeys = append(denomKeys, k) + } + sort.Strings(denomKeys) + + // iterate over all denoms with TWAP data + for _, denomKey := range denomKeys { + // divide the denom time weighed sum by denom duration + denomTimeWeightedSum := denomToTimeWeightedMap[denomKey] + denomDuration := denomDurationMap[denomKey] + denomTwap := denomTimeWeightedSum.QuoInt64(denomDuration) + + denomOracleTwap := types.OracleTwap{ + Denom: denomKey, + Twap: denomTwap, + LookbackSeconds: denomDuration, + } + oracleTwaps = append(oracleTwaps, denomOracleTwap) + } + + if len(oracleTwaps) == 0 { + return oracleTwaps, types.ErrNoTwapData + } + + return oracleTwaps, nil +} + +func (k Keeper) ValidateLookbackSeconds(ctx sdk.Context, lookbackSeconds int64) error { + lookbackDuration := k.LookbackDuration(ctx) + if lookbackSeconds > lookbackDuration || lookbackSeconds <= 0 { + return types.ErrInvalidTwapLookback + } + + return nil +} diff --git a/x/oracle/keeper/keeper_test.go b/x/oracle/keeper/keeper_test.go index e4f60b2d20..edee08b8d5 100755 --- a/x/oracle/keeper/keeper_test.go +++ b/x/oracle/keeper/keeper_test.go @@ -509,6 +509,15 @@ func TestPriceSnapshotAdd(t *testing.T) { return false }) + // test iterate reverse + expectedTimestampsReverse := []int64{3660, 100, 50} + input.OracleKeeper.IteratePriceSnapshotsReverse(input.Ctx, func(snapshot types.PriceSnapshot) (stop bool) { + // assert that all the timestamps are correct + require.Equal(t, expectedTimestampsReverse[0], snapshot.SnapshotTimestamp) + expectedTimestampsReverse = expectedTimestampsReverse[1:] + return false + }) + input.Ctx = input.Ctx.WithBlockTime(time.Unix(10000, 0)) newSnapshot2 := types.NewPriceSnapshot( @@ -540,3 +549,125 @@ func TestPriceSnapshotAdd(t *testing.T) { }) require.Equal(t, 2, totalSnapshots) } + +func TestCalculateTwaps(t *testing.T) { + input := CreateTestInput(t) + + _, err := input.OracleKeeper.CalculateTwaps(input.Ctx, 3600) + require.Error(t, err) + require.Equal(t, types.ErrNoTwapData, err) + + priceSnapshots := types.PriceSnapshots{ + types.NewPriceSnapshot(types.PriceSnapshotItems{ + types.NewPriceSnapshotItem(utils.MicroAtomDenom, types.OracleExchangeRate{ + ExchangeRate: sdk.NewDec(40), + LastUpdate: sdk.NewInt(1800), + }), + }, 1200), + types.NewPriceSnapshot(types.PriceSnapshotItems{ + types.NewPriceSnapshotItem(utils.MicroEthDenom, types.OracleExchangeRate{ + ExchangeRate: sdk.NewDec(10), + LastUpdate: sdk.NewInt(3600), + }), + types.NewPriceSnapshotItem(utils.MicroAtomDenom, types.OracleExchangeRate{ + ExchangeRate: sdk.NewDec(20), + LastUpdate: sdk.NewInt(3600), + }), + }, 3600), + types.NewPriceSnapshot(types.PriceSnapshotItems{ + types.NewPriceSnapshotItem(utils.MicroEthDenom, types.OracleExchangeRate{ + ExchangeRate: sdk.NewDec(20), + LastUpdate: sdk.NewInt(4500), + }), + types.NewPriceSnapshotItem(utils.MicroAtomDenom, types.OracleExchangeRate{ + ExchangeRate: sdk.NewDec(40), + LastUpdate: sdk.NewInt(4500), + }), + }, 4500), + } + for _, snap := range priceSnapshots { + input.OracleKeeper.SetPriceSnapshot(input.Ctx, snap) + } + input.Ctx = input.Ctx.WithBlockTime(time.Unix(5400, 0)) + twaps, err := input.OracleKeeper.CalculateTwaps(input.Ctx, 3600) + require.NoError(t, err) + require.Equal(t, 2, len(twaps)) + atomTwap := twaps[0] + ethTwap := twaps[1] + require.Equal(t, utils.MicroAtomDenom, atomTwap.Denom) + require.Equal(t, int64(3600), atomTwap.LookbackSeconds) + require.Equal(t, sdk.NewDec(35), atomTwap.Twap) + + require.Equal(t, utils.MicroEthDenom, ethTwap.Denom) + // we expect each to have a lookback of 1800 instead of 3600 because the first interval data is missing + require.Equal(t, int64(1800), ethTwap.LookbackSeconds) + require.Equal(t, sdk.NewDec(15), ethTwap.Twap) + + input.Ctx = input.Ctx.WithBlockTime(time.Unix(6000, 0)) + + // we still expect the out of range data point from 1200 to be kept for calculating TWAP for the full interval + input.OracleKeeper.AddPriceSnapshot(input.Ctx, types.NewPriceSnapshot(types.PriceSnapshotItems{ + types.NewPriceSnapshotItem(utils.MicroAtomDenom, types.OracleExchangeRate{ + ExchangeRate: sdk.NewDec(30), + LastUpdate: sdk.NewInt(6000), + }), + }, 6000)) + + input.Ctx = input.Ctx.WithBlockTime(time.Unix(6600, 0)) + + twaps, err = input.OracleKeeper.CalculateTwaps(input.Ctx, 3600) + require.NoError(t, err) + require.Equal(t, 2, len(twaps)) + atomTwap = twaps[0] + ethTwap = twaps[1] + require.Equal(t, utils.MicroAtomDenom, atomTwap.Denom) + require.Equal(t, int64(3600), atomTwap.LookbackSeconds) + + expectedTwap, _ := sdk.NewDecFromStr("33.333333333333333333") + require.Equal(t, expectedTwap, atomTwap.Twap) + + // microeth is included even though its not in the latest snapshot because its in one of the intermediate ones + require.Equal(t, utils.MicroEthDenom, ethTwap.Denom) + // we expect each to have a lookback of 3000 instead of 3600 because the first interval data is missing + require.Equal(t, int64(3000), ethTwap.LookbackSeconds) + require.Equal(t, sdk.NewDec(17), ethTwap.Twap) + + // test with shorter lookback + // microeth is not in this one because it's not in the snapshot used for TWAP calculation + twaps, err = input.OracleKeeper.CalculateTwaps(input.Ctx, 300) + require.NoError(t, err) + require.Equal(t, 1, len(twaps)) + atomTwap = twaps[0] + require.Equal(t, utils.MicroAtomDenom, atomTwap.Denom) + require.Equal(t, int64(300), atomTwap.LookbackSeconds) + require.Equal(t, sdk.NewDec(30), atomTwap.Twap) + + input.OracleKeeper.AddPriceSnapshot(input.Ctx, types.NewPriceSnapshot(types.PriceSnapshotItems{ + types.NewPriceSnapshotItem(utils.MicroAtomDenom, types.OracleExchangeRate{ + ExchangeRate: sdk.NewDec(20), + LastUpdate: sdk.NewInt(6000), + }), + }, 6600)) + + input.Ctx = input.Ctx.WithBlockTime(time.Unix(6900, 0)) + + // the older interval weight should be appropriately shorted to the start of the lookback interval, + // so the TWAP should be 25 instead of 26.666 because the 20 and 30 are weighted 50-50 instead of 33.3-66.6 + twaps, err = input.OracleKeeper.CalculateTwaps(input.Ctx, 600) + require.NoError(t, err) + require.Equal(t, 1, len(twaps)) + atomTwap = twaps[0] + require.Equal(t, utils.MicroAtomDenom, atomTwap.Denom) + require.Equal(t, int64(600), atomTwap.LookbackSeconds) + require.Equal(t, sdk.NewDec(25), atomTwap.Twap) + + // test error when lookback too large + twaps, err = input.OracleKeeper.CalculateTwaps(input.Ctx, 3700) + require.Error(t, err) + require.Equal(t, types.ErrInvalidTwapLookback, err) + + // test error when lookback is negative + twaps, err = input.OracleKeeper.CalculateTwaps(input.Ctx, -10) + require.Error(t, err) + require.Equal(t, types.ErrInvalidTwapLookback, err) +} diff --git a/x/oracle/keeper/querier.go b/x/oracle/keeper/querier.go index 48cc75b644..c5cb3b48cd 100755 --- a/x/oracle/keeper/querier.go +++ b/x/oracle/keeper/querier.go @@ -107,6 +107,27 @@ func (q querier) PriceSnapshotHistory(c context.Context, req *types.QueryPriceSn return &response, nil } +func (q querier) Twaps(c context.Context, req *types.QueryTwapsRequest) (*types.QueryTwapsResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + + ctx := sdk.UnwrapSDKContext(c) + twaps, err := q.CalculateTwaps(ctx, req.LookbackSeconds) + if err != nil { + if err == types.ErrInvalidTwapLookback { + return nil, status.Error(codes.InvalidArgument, err.Error()) + } + if err == types.ErrNoTwapData { + return nil, status.Error(codes.FailedPrecondition, err.Error()) + } + // we shouldnt get this + return nil, status.Error(codes.Unknown, err.Error()) + } + response := types.QueryTwapsResponse{OracleTwaps: twaps} + return &response, nil +} + // FeederDelegation queries the account address that the validator operator delegated oracle vote rights to func (q querier) FeederDelegation(c context.Context, req *types.QueryFeederDelegationRequest) (*types.QueryFeederDelegationResponse, error) { if req == nil { diff --git a/x/oracle/keeper/querier_test.go b/x/oracle/keeper/querier_test.go index 39d71945c2..1a80c2a548 100755 --- a/x/oracle/keeper/querier_test.go +++ b/x/oracle/keeper/querier_test.go @@ -4,6 +4,7 @@ import ( "bytes" "sort" "testing" + "time" "github.com/stretchr/testify/require" @@ -224,3 +225,57 @@ func TestQueryPriceSnapshotHistory(t *testing.T) { require.Equal(t, priceSnapshots, res.PriceSnapshots) } + +func TestQueryTwaps(t *testing.T) { + input := CreateTestInput(t) + input.Ctx = input.Ctx.WithBlockTime(time.Unix(5400, 0)) + ctx := sdk.WrapSDKContext(input.Ctx) + querier := NewQuerier(input.OracleKeeper) + _, err := querier.Twaps(ctx, &types.QueryTwapsRequest{LookbackSeconds: 3600}) + require.Error(t, err) + + priceSnapshots := types.PriceSnapshots{ + types.NewPriceSnapshot(types.PriceSnapshotItems{ + types.NewPriceSnapshotItem(utils.MicroAtomDenom, types.OracleExchangeRate{ + ExchangeRate: sdk.NewDec(40), + LastUpdate: sdk.NewInt(1800), + }), + }, 1200), + types.NewPriceSnapshot(types.PriceSnapshotItems{ + types.NewPriceSnapshotItem(utils.MicroEthDenom, types.OracleExchangeRate{ + ExchangeRate: sdk.NewDec(10), + LastUpdate: sdk.NewInt(3600), + }), + types.NewPriceSnapshotItem(utils.MicroAtomDenom, types.OracleExchangeRate{ + ExchangeRate: sdk.NewDec(20), + LastUpdate: sdk.NewInt(3600), + }), + }, 3600), + types.NewPriceSnapshot(types.PriceSnapshotItems{ + types.NewPriceSnapshotItem(utils.MicroEthDenom, types.OracleExchangeRate{ + ExchangeRate: sdk.NewDec(20), + LastUpdate: sdk.NewInt(4500), + }), + types.NewPriceSnapshotItem(utils.MicroAtomDenom, types.OracleExchangeRate{ + ExchangeRate: sdk.NewDec(40), + LastUpdate: sdk.NewInt(4500), + }), + }, 4500), + } + for _, snap := range priceSnapshots { + input.OracleKeeper.SetPriceSnapshot(input.Ctx, snap) + } + twaps, err := querier.Twaps(ctx, &types.QueryTwapsRequest{LookbackSeconds: 3600}) + require.NoError(t, err) + oracleTwaps := twaps.OracleTwaps + require.Equal(t, 2, len(oracleTwaps)) + atomTwap := oracleTwaps[0] + ethTwap := oracleTwaps[1] + require.Equal(t, utils.MicroAtomDenom, atomTwap.Denom) + require.Equal(t, int64(3600), atomTwap.LookbackSeconds) + require.Equal(t, sdk.NewDec(35), atomTwap.Twap) + + require.Equal(t, utils.MicroEthDenom, ethTwap.Denom) + require.Equal(t, int64(1800), ethTwap.LookbackSeconds) + require.Equal(t, sdk.NewDec(15), ethTwap.Twap) +} diff --git a/x/oracle/types/errors.go b/x/oracle/types/errors.go index 1dc29182ae..9aba1e38cd 100755 --- a/x/oracle/types/errors.go +++ b/x/oracle/types/errors.go @@ -24,4 +24,6 @@ var ( ErrNoVoteTarget = sdkerrors.Register(ModuleName, 13, "no vote target") ErrUnknownDenom = sdkerrors.Register(ModuleName, 14, "unknown denom") ErrNoLatestPriceSnapshot = sdkerrors.Register(ModuleName, 15, "no latest snapshot") + ErrInvalidTwapLookback = sdkerrors.Register(ModuleName, 16, "Twap lookback seconds is greater than max lookback duration or less than or equal to 0") + ErrNoTwapData = sdkerrors.Register(ModuleName, 17, "No data for the twap calculation") ) diff --git a/x/oracle/types/oracle.pb.go b/x/oracle/types/oracle.pb.go index 84650f69dc..6ebdd5d167 100644 --- a/x/oracle/types/oracle.pb.go +++ b/x/oracle/types/oracle.pb.go @@ -385,6 +385,59 @@ func (m *PriceSnapshot) GetPriceSnapshotItems() PriceSnapshotItems { return nil } +type OracleTwap struct { + Denom string `protobuf:"bytes,1,opt,name=denom,proto3" json:"denom,omitempty"` + Twap github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,2,opt,name=twap,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"twap" yaml:"twap"` + LookbackSeconds int64 `protobuf:"varint,3,opt,name=lookbackSeconds,proto3" json:"lookbackSeconds,omitempty"` +} + +func (m *OracleTwap) Reset() { *m = OracleTwap{} } +func (m *OracleTwap) String() string { return proto.CompactTextString(m) } +func (*OracleTwap) ProtoMessage() {} +func (*OracleTwap) Descriptor() ([]byte, []int) { + return fileDescriptor_dc470b50b143d488, []int{8} +} +func (m *OracleTwap) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *OracleTwap) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_OracleTwap.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *OracleTwap) XXX_Merge(src proto.Message) { + xxx_messageInfo_OracleTwap.Merge(m, src) +} +func (m *OracleTwap) XXX_Size() int { + return m.Size() +} +func (m *OracleTwap) XXX_DiscardUnknown() { + xxx_messageInfo_OracleTwap.DiscardUnknown(m) +} + +var xxx_messageInfo_OracleTwap proto.InternalMessageInfo + +func (m *OracleTwap) GetDenom() string { + if m != nil { + return m.Denom + } + return "" +} + +func (m *OracleTwap) GetLookbackSeconds() int64 { + if m != nil { + return m.LookbackSeconds + } + return 0 +} + func init() { proto.RegisterType((*Params)(nil), "seiprotocol.seichain.oracle.Params") proto.RegisterType((*Denom)(nil), "seiprotocol.seichain.oracle.Denom") @@ -394,69 +447,73 @@ func init() { proto.RegisterType((*OracleExchangeRate)(nil), "seiprotocol.seichain.oracle.OracleExchangeRate") proto.RegisterType((*PriceSnapshotItem)(nil), "seiprotocol.seichain.oracle.PriceSnapshotItem") proto.RegisterType((*PriceSnapshot)(nil), "seiprotocol.seichain.oracle.PriceSnapshot") + proto.RegisterType((*OracleTwap)(nil), "seiprotocol.seichain.oracle.OracleTwap") } func init() { proto.RegisterFile("oracle/oracle.proto", fileDescriptor_dc470b50b143d488) } var fileDescriptor_dc470b50b143d488 = []byte{ - // 902 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x56, 0xbb, 0x6f, 0xe4, 0x44, - 0x18, 0xdf, 0xb9, 0x3c, 0x60, 0x67, 0x13, 0xc8, 0xce, 0x2d, 0xe0, 0x7b, 0xb0, 0x8e, 0x06, 0x71, - 0x4a, 0x73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x9b, 0xcd, 0x75, 0xd7, 0x75, 0x69, 0x04, - 0x89, 0x86, 0x05, 0xff, 0x03, 0xe0, 0xf6, 0x02, 0x29, 0xf4, 0x11, 0xec, 0xca, 0xea, 0xfb, 0x90, - 0x27, 0x4c, 0x2a, 0x9a, 0x64, 0x86, 0xdc, 0x9a, 0xfb, 0xfa, 0xac, 0xb0, 0x6f, 0x55, 0x97, 0x59, - 0xb9, 0x78, 0x6a, 0xee, 0x83, 0x49, 0x33, 0xce, 0x5c, 0x5e, 0xa6, 0xe1, 0xbd, 0xf3, 0x00, 0xae, - 0x58, 0x22, 0xad, 0x1b, 0x57, 0xb8, 0xbc, 0x46, 0xb3, 0x96, 0x2f, 0x6f, 0x15, 0xb2, 0xb9, 0xbc, - 0x46, 0xa4, 0x24, 0x28, 0x6b, 0xe8, 0xdc, 0x0f, 0x9f, 0x9d, 0xf6, 0xc1, 0xf3, 0xd3, 0x3e, 0xf8, - 0xe3, 0xb4, 0x0f, 0xbe, 0x3b, 0xeb, 0xb7, 0x9e, 0x9f, 0xf5, 0x5b, 0xbf, 0x9e, 0xf5, 0x5b, 0x5f, - 0xbe, 0x55, 0xdb, 0x01, 0xc9, 0xf8, 0xfd, 0x39, 0x47, 0x23, 0x18, 0x92, 0xce, 0x93, 0xea, 0xdf, - 0x4c, 0xb9, 0x11, 0xe3, 0x4d, 0xe3, 0xf2, 0xf6, 0xbf, 0x01, 0x00, 0x00, 0xff, 0xff, 0x10, 0xb5, - 0xce, 0x78, 0xeb, 0x08, 0x00, 0x00, + // 953 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x56, 0xbd, 0x8f, 0xe3, 0x44, + 0x14, 0x8f, 0x2f, 0xd9, 0x85, 0x4c, 0x76, 0xb9, 0xcd, 0x5c, 0x80, 0xdc, 0x07, 0xf1, 0x6a, 0x10, + 0xa7, 0x34, 0x97, 0x70, 0x47, 0x81, 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x00, } func (this *Params) Equal(that interface{}) bool { @@ -882,6 +939,51 @@ func (m *PriceSnapshot) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *OracleTwap) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *OracleTwap) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *OracleTwap) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.LookbackSeconds != 0 { + i = encodeVarintOracle(dAtA, i, uint64(m.LookbackSeconds)) + i-- + dAtA[i] = 0x18 + } + { + size := m.Twap.Size() + i -= size + if _, err := m.Twap.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintOracle(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + if len(m.Denom) > 0 { + i -= len(m.Denom) + copy(dAtA[i:], m.Denom) + i = encodeVarintOracle(dAtA, i, uint64(len(m.Denom))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func encodeVarintOracle(dAtA []byte, offset int, v uint64) int { offset -= sovOracle(v) base := offset @@ -1038,6 +1140,24 @@ func (m *PriceSnapshot) Size() (n int) { return n } +func (m *OracleTwap) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Denom) + if l > 0 { + n += 1 + l + sovOracle(uint64(l)) + } + l = m.Twap.Size() + n += 1 + l + sovOracle(uint64(l)) + if m.LookbackSeconds != 0 { + n += 1 + sovOracle(uint64(m.LookbackSeconds)) + } + return n +} + func sovOracle(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -2104,6 +2224,141 @@ func (m *PriceSnapshot) Unmarshal(dAtA []byte) error { } return nil } +func (m *OracleTwap) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOracle + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: OracleTwap: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: OracleTwap: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Denom", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOracle + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthOracle + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthOracle + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Denom = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Twap", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOracle + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthOracle + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthOracle + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Twap.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field LookbackSeconds", wireType) + } + m.LookbackSeconds = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOracle + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.LookbackSeconds |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipOracle(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthOracle + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipOracle(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/oracle/types/querier.go b/x/oracle/types/querier.go index efd3605cc8..d64ee50cfa 100755 --- a/x/oracle/types/querier.go +++ b/x/oracle/types/querier.go @@ -10,6 +10,7 @@ const ( QueryExchangeRate = "exchangeRate" QueryExchangeRates = "exchangeRates" QueryPriceSnapshotHistory = "priceSnapshotHistory" + QueryTwaps = "twaps" QueryActives = "actives" QueryFeederDelegation = "feederDelegation" QueryMissCounter = "missCounter" @@ -31,6 +32,17 @@ func NewQueryExchangeRateParams(denom string) QueryExchangeRateParams { return QueryExchangeRateParams{denom} } +// QueryTwapParams defines the params for the following queries: +// - 'custom/oracle/twap' +type QueryTwapsParams struct { + LookbackSeconds int64 +} + +// NewQueryExchangeRateParams returns params for exchange_rate query +func NewQueryTwapsParams(lookbackSeconds int64) QueryTwapsParams { + return QueryTwapsParams{lookbackSeconds} +} + // QueryPrevotesParams defines the params for the following queries: // - 'custom/oracle/prevotes' type QueryPrevotesParams struct { diff --git a/x/oracle/types/query.pb.go b/x/oracle/types/query.pb.go index 715441eb81..71b9a8d032 100644 --- a/x/oracle/types/query.pb.go +++ b/x/oracle/types/query.pb.go @@ -501,6 +501,95 @@ func (m *QueryPriceSnapshotHistoryResponse) GetPriceSnapshots() PriceSnapshots { return nil } +// request type for twap RPC method +type QueryTwapsRequest struct { + LookbackSeconds int64 `protobuf:"varint,1,opt,name=lookback_seconds,json=lookbackSeconds,proto3" json:"lookback_seconds,omitempty"` +} + +func (m *QueryTwapsRequest) Reset() { *m = QueryTwapsRequest{} } +func (m *QueryTwapsRequest) String() string { return proto.CompactTextString(m) } +func (*QueryTwapsRequest) ProtoMessage() {} +func (*QueryTwapsRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_562b782cb9ac197e, []int{11} +} +func (m *QueryTwapsRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryTwapsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryTwapsRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryTwapsRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryTwapsRequest.Merge(m, src) +} +func (m *QueryTwapsRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryTwapsRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryTwapsRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryTwapsRequest proto.InternalMessageInfo + +func (m *QueryTwapsRequest) GetLookbackSeconds() int64 { + if m != nil { + return m.LookbackSeconds + } + return 0 +} + +type QueryTwapsResponse struct { + OracleTwaps OracleTwaps `protobuf:"bytes,1,rep,name=oracle_twaps,json=oracleTwaps,proto3,castrepeated=OracleTwaps" json:"oracle_twaps"` +} + +func (m *QueryTwapsResponse) Reset() { *m = QueryTwapsResponse{} } +func (m *QueryTwapsResponse) String() string { return proto.CompactTextString(m) } +func (*QueryTwapsResponse) ProtoMessage() {} +func (*QueryTwapsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_562b782cb9ac197e, []int{12} +} +func (m *QueryTwapsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryTwapsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryTwapsResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryTwapsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryTwapsResponse.Merge(m, src) +} +func (m *QueryTwapsResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryTwapsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryTwapsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryTwapsResponse proto.InternalMessageInfo + +func (m *QueryTwapsResponse) GetOracleTwaps() OracleTwaps { + if m != nil { + return m.OracleTwaps + } + return nil +} + // QueryFeederDelegationRequest is the request type for the Query/FeederDelegation RPC method. type QueryFeederDelegationRequest struct { // validator defines the validator address to query for. @@ -511,7 +600,7 @@ func (m *QueryFeederDelegationRequest) Reset() { *m = QueryFeederDelegat func (m *QueryFeederDelegationRequest) String() string { return proto.CompactTextString(m) } func (*QueryFeederDelegationRequest) ProtoMessage() {} func (*QueryFeederDelegationRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_562b782cb9ac197e, []int{11} + return fileDescriptor_562b782cb9ac197e, []int{13} } func (m *QueryFeederDelegationRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -551,7 +640,7 @@ func (m *QueryFeederDelegationResponse) Reset() { *m = QueryFeederDelega func (m *QueryFeederDelegationResponse) String() string { return proto.CompactTextString(m) } func (*QueryFeederDelegationResponse) ProtoMessage() {} func (*QueryFeederDelegationResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_562b782cb9ac197e, []int{12} + return fileDescriptor_562b782cb9ac197e, []int{14} } func (m *QueryFeederDelegationResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -597,7 +686,7 @@ func (m *QueryMissCounterRequest) Reset() { *m = QueryMissCounterRequest func (m *QueryMissCounterRequest) String() string { return proto.CompactTextString(m) } func (*QueryMissCounterRequest) ProtoMessage() {} func (*QueryMissCounterRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_562b782cb9ac197e, []int{13} + return fileDescriptor_562b782cb9ac197e, []int{15} } func (m *QueryMissCounterRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -637,7 +726,7 @@ func (m *QueryMissCounterResponse) Reset() { *m = QueryMissCounterRespon func (m *QueryMissCounterResponse) String() string { return proto.CompactTextString(m) } func (*QueryMissCounterResponse) ProtoMessage() {} func (*QueryMissCounterResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_562b782cb9ac197e, []int{14} + return fileDescriptor_562b782cb9ac197e, []int{16} } func (m *QueryMissCounterResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -683,7 +772,7 @@ func (m *QueryAggregatePrevoteRequest) Reset() { *m = QueryAggregatePrev func (m *QueryAggregatePrevoteRequest) String() string { return proto.CompactTextString(m) } func (*QueryAggregatePrevoteRequest) ProtoMessage() {} func (*QueryAggregatePrevoteRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_562b782cb9ac197e, []int{15} + return fileDescriptor_562b782cb9ac197e, []int{17} } func (m *QueryAggregatePrevoteRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -723,7 +812,7 @@ func (m *QueryAggregatePrevoteResponse) Reset() { *m = QueryAggregatePre func (m *QueryAggregatePrevoteResponse) String() string { return proto.CompactTextString(m) } func (*QueryAggregatePrevoteResponse) ProtoMessage() {} func (*QueryAggregatePrevoteResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_562b782cb9ac197e, []int{16} + return fileDescriptor_562b782cb9ac197e, []int{18} } func (m *QueryAggregatePrevoteResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -767,7 +856,7 @@ func (m *QueryAggregatePrevotesRequest) Reset() { *m = QueryAggregatePre func (m *QueryAggregatePrevotesRequest) String() string { return proto.CompactTextString(m) } func (*QueryAggregatePrevotesRequest) ProtoMessage() {} func (*QueryAggregatePrevotesRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_562b782cb9ac197e, []int{17} + return fileDescriptor_562b782cb9ac197e, []int{19} } func (m *QueryAggregatePrevotesRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -807,7 +896,7 @@ func (m *QueryAggregatePrevotesResponse) Reset() { *m = QueryAggregatePr func (m *QueryAggregatePrevotesResponse) String() string { return proto.CompactTextString(m) } func (*QueryAggregatePrevotesResponse) ProtoMessage() {} func (*QueryAggregatePrevotesResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_562b782cb9ac197e, []int{18} + return fileDescriptor_562b782cb9ac197e, []int{20} } func (m *QueryAggregatePrevotesResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -853,7 +942,7 @@ func (m *QueryAggregateVoteRequest) Reset() { *m = QueryAggregateVoteReq func (m *QueryAggregateVoteRequest) String() string { return proto.CompactTextString(m) } func (*QueryAggregateVoteRequest) ProtoMessage() {} func (*QueryAggregateVoteRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_562b782cb9ac197e, []int{19} + return fileDescriptor_562b782cb9ac197e, []int{21} } func (m *QueryAggregateVoteRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -893,7 +982,7 @@ func (m *QueryAggregateVoteResponse) Reset() { *m = QueryAggregateVoteRe func (m *QueryAggregateVoteResponse) String() string { return proto.CompactTextString(m) } func (*QueryAggregateVoteResponse) ProtoMessage() {} func (*QueryAggregateVoteResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_562b782cb9ac197e, []int{20} + return fileDescriptor_562b782cb9ac197e, []int{22} } func (m *QueryAggregateVoteResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -937,7 +1026,7 @@ func (m *QueryAggregateVotesRequest) Reset() { *m = QueryAggregateVotesR func (m *QueryAggregateVotesRequest) String() string { return proto.CompactTextString(m) } func (*QueryAggregateVotesRequest) ProtoMessage() {} func (*QueryAggregateVotesRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_562b782cb9ac197e, []int{21} + return fileDescriptor_562b782cb9ac197e, []int{23} } func (m *QueryAggregateVotesRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -977,7 +1066,7 @@ func (m *QueryAggregateVotesResponse) Reset() { *m = QueryAggregateVotes func (m *QueryAggregateVotesResponse) String() string { return proto.CompactTextString(m) } func (*QueryAggregateVotesResponse) ProtoMessage() {} func (*QueryAggregateVotesResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_562b782cb9ac197e, []int{22} + return fileDescriptor_562b782cb9ac197e, []int{24} } func (m *QueryAggregateVotesResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1021,7 +1110,7 @@ func (m *QueryParamsRequest) Reset() { *m = QueryParamsRequest{} } func (m *QueryParamsRequest) String() string { return proto.CompactTextString(m) } func (*QueryParamsRequest) ProtoMessage() {} func (*QueryParamsRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_562b782cb9ac197e, []int{23} + return fileDescriptor_562b782cb9ac197e, []int{25} } func (m *QueryParamsRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1060,7 +1149,7 @@ func (m *QueryParamsResponse) Reset() { *m = QueryParamsResponse{} } func (m *QueryParamsResponse) String() string { return proto.CompactTextString(m) } func (*QueryParamsResponse) ProtoMessage() {} func (*QueryParamsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_562b782cb9ac197e, []int{24} + return fileDescriptor_562b782cb9ac197e, []int{26} } func (m *QueryParamsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1108,6 +1197,8 @@ func init() { proto.RegisterType((*QueryVoteTargetsResponse)(nil), "seiprotocol.seichain.oracle.QueryVoteTargetsResponse") proto.RegisterType((*QueryPriceSnapshotHistoryRequest)(nil), "seiprotocol.seichain.oracle.QueryPriceSnapshotHistoryRequest") proto.RegisterType((*QueryPriceSnapshotHistoryResponse)(nil), "seiprotocol.seichain.oracle.QueryPriceSnapshotHistoryResponse") + proto.RegisterType((*QueryTwapsRequest)(nil), "seiprotocol.seichain.oracle.QueryTwapsRequest") + proto.RegisterType((*QueryTwapsResponse)(nil), "seiprotocol.seichain.oracle.QueryTwapsResponse") proto.RegisterType((*QueryFeederDelegationRequest)(nil), "seiprotocol.seichain.oracle.QueryFeederDelegationRequest") proto.RegisterType((*QueryFeederDelegationResponse)(nil), "seiprotocol.seichain.oracle.QueryFeederDelegationResponse") proto.RegisterType((*QueryMissCounterRequest)(nil), "seiprotocol.seichain.oracle.QueryMissCounterRequest") @@ -1127,81 +1218,87 @@ func init() { func init() { proto.RegisterFile("oracle/query.proto", fileDescriptor_562b782cb9ac197e) } var fileDescriptor_562b782cb9ac197e = []byte{ - // 1172 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x56, 0xcf, 0x6f, 0x1b, 0xc5, - 0x17, 0xf7, 0xf4, 0xdb, 0xa6, 0xdf, 0x3e, 0x37, 0x6e, 0x32, 0x35, 0x90, 0x6e, 0x82, 0x9d, 0x2e, - 0x54, 0x54, 0x48, 0xf1, 0x86, 0x90, 0x84, 0x26, 0x69, 0x0a, 0x4e, 0xc2, 0x8f, 0x96, 0x42, 0x53, - 0x53, 0x45, 0x88, 0xcb, 0x6a, 0x6a, 0x0f, 0x9b, 0x15, 0xce, 0xee, 0x76, 0x67, 0x13, 0x35, 0xaa, - 0x7a, 0x00, 0xf5, 0xc0, 0x05, 0xa9, 0x12, 0x37, 0xc4, 0xa1, 0x17, 0x38, 0xf0, 0x07, 0x70, 0xe4, - 0x00, 0x02, 0xf5, 0x58, 0x51, 0x0e, 0x48, 0x20, 0x8a, 0x12, 0x0e, 0xfc, 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, 0xa1, 0xbf, 0x12, 0x18, 0xed, 0xb0, - 0x30, 0x74, 0x00, 0x9e, 0xe1, 0x0b, 0xb1, 0x34, 0x50, 0x6e, 0x9f, 0x77, 0x2a, 0x22, 0xb2, 0xd3, - 0x63, 0xd1, 0xc7, 0x04, 0x86, 0x63, 0xa6, 0x20, 0x4b, 0x4f, 0x49, 0xb2, 0x4d, 0x59, 0x7a, 0x4a, - 0xa2, 0x3f, 0x52, 0xaf, 0x4b, 0x21, 0xef, 0xd2, 0xcb, 0x4f, 0xa5, 0x5a, 0xb2, 0x54, 0xbf, 0x10, - 0x28, 0xc4, 0xad, 0x0e, 0xed, 0x97, 0x5e, 0x58, 0xa4, 0x0b, 0xfd, 0x27, 0xa2, 0xb0, 0xaa, 0x14, - 0xb6, 0x44, 0x17, 0x06, 0xa9, 0x90, 0x5f, 0x9e, 0xaf, 0x08, 0x0c, 0xf9, 0xd6, 0x86, 0x6a, 0x19, - 0xde, 0xe0, 0xa8, 0xaf, 0x52, 0xa6, 0xb3, 0x27, 0x20, 0xe1, 0x29, 0x49, 0xf8, 0x25, 0x7a, 0xae, - 0x07, 0x61, 0xdf, 0x5e, 0xad, 0x5c, 0x79, 0xb8, 0x57, 0x22, 0x8f, 0xf6, 0x4a, 0xe4, 0xef, 0xbd, - 0x12, 0xb9, 0xbf, 0x5f, 0xca, 0x3d, 0xda, 0x2f, 0xe5, 0x7e, 0xdf, 0x2f, 0xe5, 0x3e, 0x9a, 0x36, - 0x4c, 0x6f, 0x73, 0xfb, 0x66, 0xa5, 0x6e, 0x6f, 0x75, 0x83, 0xba, 0x1d, 0x80, 0x79, 0xbb, 0x0e, - 0x17, 0x37, 0x87, 0xe4, 0x94, 0x57, 0xff, 0x0b, 0x00, 0x00, 0xff, 0xff, 0x9e, 0x3a, 0x18, 0xc9, - 0x68, 0x12, 0x00, 0x00, + // 1268 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x96, 0xcf, 0x6f, 0x1b, 0x45, + 0x14, 0xc7, 0x3d, 0xfd, 0x91, 0xd2, 0xe7, 0xc4, 0x49, 0x26, 0x06, 0x52, 0x27, 0xd8, 0xe9, 0x42, + 0xd5, 0x52, 0x11, 0x6f, 0x08, 0x49, 0x68, 0x92, 0x26, 0xe0, 0x24, 0xfc, 0x68, 0x29, 0x34, 0x75, + 0xa3, 0x08, 0x71, 0x59, 0x4d, 0xec, 0xc1, 0x59, 0xc5, 0xf1, 0xb8, 0x3b, 0x9b, 0xd0, 0xa8, 0xea, + 0x01, 0xd4, 0x03, 0x17, 0xa4, 0x4a, 0xdc, 0x50, 0x0f, 0xbd, 0xc0, 0x81, 0x3f, 0x80, 0x23, 0x07, + 0x10, 0xa8, 0xc7, 0x8a, 0x72, 0x40, 0x42, 0xa2, 0x28, 0xe1, 0xc0, 0xff, 0xc0, 0x05, 0xed, 0xec, + 0x5b, 0x7b, 0x37, 0xb6, 0xd7, 0x6b, 0xa7, 0x27, 0x7b, 0xdf, 0xcc, 0x7b, 0xf3, 0xf9, 0xce, 0xcf, + 0x2f, 0x50, 0x61, 0xb1, 0x42, 0x99, 0xeb, 0xb7, 0x76, 0xb8, 0xb5, 0x97, 0xad, 0x5a, 0xc2, 0x16, + 0x74, 0x44, 0x72, 0x53, 0xfd, 0x2b, 0x88, 0x72, 0x56, 0x72, 0xb3, 0xb0, 0xc9, 0xcc, 0x4a, 0xd6, + 0xed, 0x98, 0x4a, 0x96, 0x44, 0x49, 0xa8, 0x56, 0xdd, 0xf9, 0xe7, 0xa6, 0xa4, 0x46, 0x4b, 0x42, + 0x94, 0xca, 0x5c, 0x67, 0x55, 0x53, 0x67, 0x95, 0x8a, 0xb0, 0x99, 0x6d, 0x8a, 0x8a, 0xc4, 0xd6, + 0x21, 0x1c, 0xc4, 0xfd, 0x71, 0x83, 0xda, 0x1c, 0x0c, 0xdf, 0x70, 0x06, 0x7d, 0xe7, 0x76, 0x61, + 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f4, 0x37, 0x02, 0x83, 0x0d, 0x0e, + 0x8b, 0x76, 0xc1, 0x59, 0x3b, 0x35, 0xf3, 0x5d, 0xe5, 0x76, 0x78, 0xe4, 0x7d, 0x22, 0x1b, 0x2d, + 0x20, 0x7d, 0x42, 0xa0, 0x2f, 0xe0, 0x59, 0xa2, 0x3c, 0x79, 0xcd, 0x5c, 0x5d, 0x94, 0x27, 0xaf, + 0xa9, 0x7d, 0xd3, 0x6e, 0x28, 0x21, 0x1f, 0xd0, 0x2b, 0xcf, 0x64, 0xb5, 0xd4, 0x52, 0xfd, 0x4a, + 0x20, 0x11, 0x74, 0x62, 0xb4, 0x53, 0xbc, 0xda, 0x22, 0x5d, 0xea, 0x3c, 0x11, 0x85, 0xe5, 0x94, + 0xb0, 0x79, 0x3a, 0xdb, 0xcd, 0x0a, 0xb9, 0xcb, 0xf3, 0x0d, 0x81, 0x1e, 0xd7, 0x79, 0xd1, 0x08, + 0x57, 0x6c, 0xc0, 0xf6, 0xa5, 0x26, 0xa2, 0x27, 0x20, 0xf0, 0xb8, 0x02, 0x3e, 0x4f, 0xcf, 0xb5, + 0x01, 0x76, 0xdd, 0xdf, 0xd2, 0xd5, 0x47, 0xfb, 0x69, 0xf2, 0x78, 0x3f, 0x4d, 0xfe, 0xde, 0x4f, + 0x93, 0xfb, 0x07, 0xe9, 0xd8, 0xe3, 0x83, 0x74, 0xec, 0x8f, 0x83, 0x74, 0xec, 0x93, 0x89, 0x92, + 0x69, 0x6f, 0xee, 0x6c, 0x64, 0x0b, 0x62, 0xbb, 0x55, 0xa9, 0xdb, 0x5e, 0x31, 0x7b, 0xaf, 0xca, + 0xe5, 0x46, 0x8f, 0xea, 0xf2, 0xc6, 0xff, 0x01, 0x00, 0x00, 0xff, 0xff, 0xd5, 0x3a, 0xae, 0x5b, + 0xbe, 0x13, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -1226,6 +1323,7 @@ type QueryClient interface { VoteTargets(ctx context.Context, in *QueryVoteTargetsRequest, opts ...grpc.CallOption) (*QueryVoteTargetsResponse, error) // PriceSnapshotHistory returns the history of price snapshots for all assets PriceSnapshotHistory(ctx context.Context, in *QueryPriceSnapshotHistoryRequest, opts ...grpc.CallOption) (*QueryPriceSnapshotHistoryResponse, error) + Twaps(ctx context.Context, in *QueryTwapsRequest, opts ...grpc.CallOption) (*QueryTwapsResponse, error) // FeederDelegation returns feeder delegation of a validator FeederDelegation(ctx context.Context, in *QueryFeederDelegationRequest, opts ...grpc.CallOption) (*QueryFeederDelegationResponse, error) // MissCounter returns oracle miss counter of a validator @@ -1295,6 +1393,15 @@ func (c *queryClient) PriceSnapshotHistory(ctx context.Context, in *QueryPriceSn return out, nil } +func (c *queryClient) Twaps(ctx context.Context, in *QueryTwapsRequest, opts ...grpc.CallOption) (*QueryTwapsResponse, error) { + out := new(QueryTwapsResponse) + err := c.cc.Invoke(ctx, "/seiprotocol.seichain.oracle.Query/Twaps", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + func (c *queryClient) FeederDelegation(ctx context.Context, in *QueryFeederDelegationRequest, opts ...grpc.CallOption) (*QueryFeederDelegationResponse, error) { out := new(QueryFeederDelegationResponse) err := c.cc.Invoke(ctx, "/seiprotocol.seichain.oracle.Query/FeederDelegation", in, out, opts...) @@ -1370,6 +1477,7 @@ type QueryServer interface { VoteTargets(context.Context, *QueryVoteTargetsRequest) (*QueryVoteTargetsResponse, error) // PriceSnapshotHistory returns the history of price snapshots for all assets PriceSnapshotHistory(context.Context, *QueryPriceSnapshotHistoryRequest) (*QueryPriceSnapshotHistoryResponse, error) + Twaps(context.Context, *QueryTwapsRequest) (*QueryTwapsResponse, error) // FeederDelegation returns feeder delegation of a validator FeederDelegation(context.Context, *QueryFeederDelegationRequest) (*QueryFeederDelegationResponse, error) // MissCounter returns oracle miss counter of a validator @@ -1405,6 +1513,9 @@ func (*UnimplementedQueryServer) VoteTargets(ctx context.Context, req *QueryVote func (*UnimplementedQueryServer) PriceSnapshotHistory(ctx context.Context, req *QueryPriceSnapshotHistoryRequest) (*QueryPriceSnapshotHistoryResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method PriceSnapshotHistory not implemented") } +func (*UnimplementedQueryServer) Twaps(ctx context.Context, req *QueryTwapsRequest) (*QueryTwapsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Twaps not implemented") +} func (*UnimplementedQueryServer) FeederDelegation(ctx context.Context, req *QueryFeederDelegationRequest) (*QueryFeederDelegationResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method FeederDelegation not implemented") } @@ -1521,6 +1632,24 @@ func _Query_PriceSnapshotHistory_Handler(srv interface{}, ctx context.Context, d return interceptor(ctx, in, info, handler) } +func _Query_Twaps_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryTwapsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).Twaps(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/seiprotocol.seichain.oracle.Query/Twaps", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).Twaps(ctx, req.(*QueryTwapsRequest)) + } + return interceptor(ctx, in, info, handler) +} + func _Query_FeederDelegation_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(QueryFeederDelegationRequest) if err := dec(in); err != nil { @@ -1671,6 +1800,10 @@ var _Query_serviceDesc = grpc.ServiceDesc{ MethodName: "PriceSnapshotHistory", Handler: _Query_PriceSnapshotHistory_Handler, }, + { + MethodName: "Twaps", + Handler: _Query_Twaps_Handler, + }, { MethodName: "FeederDelegation", Handler: _Query_FeederDelegation_Handler, @@ -2037,6 +2170,71 @@ func (m *QueryPriceSnapshotHistoryResponse) MarshalToSizedBuffer(dAtA []byte) (i return len(dAtA) - i, nil } +func (m *QueryTwapsRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryTwapsRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryTwapsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.LookbackSeconds != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.LookbackSeconds)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *QueryTwapsResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryTwapsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryTwapsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.OracleTwaps) > 0 { + for iNdEx := len(m.OracleTwaps) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.OracleTwaps[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + func (m *QueryFeederDelegationRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -2603,6 +2801,33 @@ func (m *QueryPriceSnapshotHistoryResponse) Size() (n int) { return n } +func (m *QueryTwapsRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.LookbackSeconds != 0 { + n += 1 + sovQuery(uint64(m.LookbackSeconds)) + } + return n +} + +func (m *QueryTwapsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.OracleTwaps) > 0 { + for _, e := range m.OracleTwaps { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + return n +} + func (m *QueryFeederDelegationRequest) Size() (n int) { if m == nil { return 0 @@ -3588,6 +3813,159 @@ func (m *QueryPriceSnapshotHistoryResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *QueryTwapsRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryTwapsRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryTwapsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field LookbackSeconds", wireType) + } + m.LookbackSeconds = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.LookbackSeconds |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryTwapsResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryTwapsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryTwapsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field OracleTwaps", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.OracleTwaps = append(m.OracleTwaps, OracleTwap{}) + if err := m.OracleTwaps[len(m.OracleTwaps)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func (m *QueryFeederDelegationRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 diff --git a/x/oracle/types/query.pb.gw.go b/x/oracle/types/query.pb.gw.go index 94f4ade9bf..e5736cd92d 100644 --- a/x/oracle/types/query.pb.gw.go +++ b/x/oracle/types/query.pb.gw.go @@ -159,6 +159,42 @@ func local_request_Query_PriceSnapshotHistory_0(ctx context.Context, marshaler r } +var ( + filter_Query_Twaps_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} +) + +func request_Query_Twaps_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryTwapsRequest + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_Twaps_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.Twaps(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_Twaps_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryTwapsRequest + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_Twaps_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.Twaps(ctx, &protoReq) + return msg, metadata, err + +} + func request_Query_FeederDelegation_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq QueryFeederDelegationRequest var metadata runtime.ServerMetadata @@ -550,6 +586,29 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) + mux.Handle("GET", pattern_Query_Twaps_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_Twaps_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_Twaps_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + mux.Handle("GET", pattern_Query_FeederDelegation_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -852,6 +911,26 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) + mux.Handle("GET", pattern_Query_Twaps_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_Twaps_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_Twaps_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + mux.Handle("GET", pattern_Query_FeederDelegation_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -1006,6 +1085,8 @@ var ( pattern_Query_PriceSnapshotHistory_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4}, []string{"sei-protocol", "sei-chain", "oracle", "denoms", "price_snapshot_history"}, "", runtime.AssumeColonVerbOpt(true))) + pattern_Query_Twaps_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4}, []string{"sei-protocol", "sei-chain", "oracle", "denoms", "twap"}, "", runtime.AssumeColonVerbOpt(true))) + pattern_Query_FeederDelegation_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 2, 5}, []string{"sei-protocol", "sei-chain", "oracle", "validators", "validator_addr", "feeder"}, "", runtime.AssumeColonVerbOpt(true))) pattern_Query_MissCounter_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 2, 5}, []string{"sei-protocol", "sei-chain", "oracle", "validators", "validator_addr", "miss"}, "", runtime.AssumeColonVerbOpt(true))) @@ -1032,6 +1113,8 @@ var ( forward_Query_PriceSnapshotHistory_0 = runtime.ForwardResponseMessage + forward_Query_Twaps_0 = runtime.ForwardResponseMessage + forward_Query_FeederDelegation_0 = runtime.ForwardResponseMessage forward_Query_MissCounter_0 = runtime.ForwardResponseMessage diff --git a/x/oracle/types/snapshots.go b/x/oracle/types/snapshots.go index a38cb6806d..a2ebfd69ad 100644 --- a/x/oracle/types/snapshots.go +++ b/x/oracle/types/snapshots.go @@ -7,6 +7,7 @@ import ( // OracleExchangeRates - array of OracleExchangeRate type PriceSnapshots []PriceSnapshot type PriceSnapshotItems []PriceSnapshotItem +type OracleTwaps []OracleTwap // String implements fmt.Stringer interface func (snapshots PriceSnapshots) String() string {