-
Notifications
You must be signed in to change notification settings - Fork 590
/
query_proto_wrap.go
41 lines (32 loc) · 1.24 KB
/
query_proto_wrap.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package client
import (
"time"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/osmosis-labs/osmosis/v12/x/twap"
"github.com/osmosis-labs/osmosis/v12/x/twap/client/queryproto"
)
// This file should evolve to being code gen'd, off of `proto/twap/v1beta/query.yml`
type Querier struct {
K twap.Keeper
}
func (q Querier) ArithmeticTwap(ctx sdk.Context,
req queryproto.ArithmeticTwapRequest,
) (*queryproto.ArithmeticTwapResponse, error) {
if (req.EndTime == nil || *req.EndTime == time.Time{}) {
*req.EndTime = ctx.BlockTime()
}
twap, err := q.K.GetArithmeticTwap(ctx, req.PoolId, req.BaseAsset, req.QuoteAsset, req.StartTime, *req.EndTime)
return &queryproto.ArithmeticTwapResponse{ArithmeticTwap: twap}, err
}
func (q Querier) ArithmeticTwapToNow(ctx sdk.Context,
req queryproto.ArithmeticTwapToNowRequest,
) (*queryproto.ArithmeticTwapToNowResponse, error) {
twap, err := q.K.GetArithmeticTwapToNow(ctx, req.PoolId, req.BaseAsset, req.QuoteAsset, req.StartTime)
return &queryproto.ArithmeticTwapToNowResponse{ArithmeticTwap: twap}, err
}
func (q Querier) Params(ctx sdk.Context,
req queryproto.ParamsRequest,
) (*queryproto.ParamsResponse, error) {
params := q.K.GetParams(ctx)
return &queryproto.ParamsResponse{Params: params}, nil
}