/
querier.go
84 lines (72 loc) · 2.5 KB
/
querier.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
package types
import (
sdkmath "cosmossdk.io/math"
sdk "github.com/cosmos/cosmos-sdk/types"
)
// Querier routes for the swap module
const (
QueryGetParams = "params"
QueryGetDeposits = "deposits"
QueryGetPool = "pool"
QueryGetPools = "pools"
)
// QueryDepositsParams is the params for a filtered deposits query
type QueryDepositsParams struct {
Page int `json:"page" yaml:"page"`
Limit int `json:"limit" yaml:"limit"`
Owner sdk.AccAddress `json:"owner" yaml:"owner"`
Pool string `json:"pool" yaml:"pool"`
}
// NewQueryDepositsParams creates a new QueryDepositsParams
func NewQueryDepositsParams(page, limit int, owner sdk.AccAddress, pool string) QueryDepositsParams {
return QueryDepositsParams{
Page: page,
Limit: limit,
Owner: owner,
Pool: pool,
}
}
// DepositsQueryResult contains the result of a deposits query
type DepositsQueryResult struct {
Depositor sdk.AccAddress `json:"depositor" yaml:"depositor"`
PoolID string `json:"pool_id" yaml:"pool_id"`
SharesOwned sdkmath.Int `json:"shares_owned" yaml:"shares_owned"`
SharesValue sdk.Coins `json:"shares_value" yaml:"shares_value"`
}
// NewDepositsQueryResult creates a new DepositsQueryResult
func NewDepositsQueryResult(shareRecord ShareRecord, sharesValue sdk.Coins) DepositsQueryResult {
return DepositsQueryResult{
Depositor: shareRecord.Depositor,
PoolID: shareRecord.PoolID,
SharesOwned: shareRecord.SharesOwned,
SharesValue: sharesValue,
}
}
// DepositsQueryResults is a slice of DepositsQueryResult
type DepositsQueryResults []DepositsQueryResult
// QueryPoolParams is the params for a pool query
type QueryPoolParams struct {
Pool string `json:"pool" yaml:"pool"`
}
// NewQueryPoolParams creates a new QueryPoolParams
func NewQueryPoolParams(pool string) QueryPoolParams {
return QueryPoolParams{
Pool: pool,
}
}
// PoolStatsQueryResult contains the result of a pool query
type PoolStatsQueryResult struct {
Name string `json:"name" yaml:"name"`
Coins sdk.Coins `json:"coins" yaml:"coins"`
TotalShares sdkmath.Int `json:"total_shares" yaml:"total_shares"`
}
// NewPoolStatsQueryResult creates a new PoolStatsQueryResult
func NewPoolStatsQueryResult(name string, coins sdk.Coins, totalShares sdkmath.Int) PoolStatsQueryResult {
return PoolStatsQueryResult{
Name: name,
Coins: coins,
TotalShares: totalShares,
}
}
// PoolStatsQueryResults is a slice of PoolStatsQueryResult
type PoolStatsQueryResults []PoolStatsQueryResult