|
5 | 5 |
|
6 | 6 | sdk "github.com/cosmos/cosmos-sdk/types" |
7 | 7 |
|
8 | | - "github.com/dydxprotocol/v4-chain/protocol/dtypes" |
9 | 8 | "github.com/dydxprotocol/v4-chain/protocol/lib" |
10 | 9 | "github.com/dydxprotocol/v4-chain/protocol/x/feetiers/types" |
11 | 10 | "google.golang.org/grpc/codes" |
@@ -59,107 +58,3 @@ func (k Keeper) UserFeeTier( |
59 | 58 | Tier: tier, |
60 | 59 | }, nil |
61 | 60 | } |
62 | | -<<<<<<< HEAD |
63 | | -======= |
64 | | - |
65 | | -// PerMarketFeeDiscountParams processes a query for fee discount parameters for a specific market/CLOB pair. |
66 | | -func (k Keeper) PerMarketFeeDiscountParams( |
67 | | - c context.Context, |
68 | | - req *types.QueryPerMarketFeeDiscountParamsRequest, |
69 | | -) ( |
70 | | - *types.QueryPerMarketFeeDiscountParamsResponse, |
71 | | - error, |
72 | | -) { |
73 | | - if req == nil { |
74 | | - return nil, status.Error(codes.InvalidArgument, "invalid request") |
75 | | - } |
76 | | - |
77 | | - ctx := lib.UnwrapSDKContext(c, types.ModuleName) |
78 | | - params, err := k.GetPerMarketFeeDiscountParams(ctx, req.ClobPairId) |
79 | | - if err != nil { |
80 | | - if errors.Is(err, types.ErrMarketFeeDiscountNotFound) { |
81 | | - return nil, status.Error(codes.NotFound, "fee discount not found for the specified market/CLOB pair") |
82 | | - } |
83 | | - return nil, status.Errorf(codes.Internal, "failed to get per-market fee discount: %v", err) |
84 | | - } |
85 | | - |
86 | | - return &types.QueryPerMarketFeeDiscountParamsResponse{ |
87 | | - Params: params, |
88 | | - }, nil |
89 | | -} |
90 | | - |
91 | | -// AllMarketFeeDiscountParams processes a query for all market fee discount parameters. |
92 | | -func (k Keeper) AllMarketFeeDiscountParams( |
93 | | - c context.Context, |
94 | | - req *types.QueryAllMarketFeeDiscountParamsRequest, |
95 | | -) ( |
96 | | - *types.QueryAllMarketFeeDiscountParamsResponse, |
97 | | - error, |
98 | | -) { |
99 | | - if req == nil { |
100 | | - return nil, status.Error(codes.InvalidArgument, "invalid request") |
101 | | - } |
102 | | - |
103 | | - ctx := lib.UnwrapSDKContext(c, types.ModuleName) |
104 | | - params := k.GetAllMarketFeeDiscountParams(ctx) |
105 | | - |
106 | | - return &types.QueryAllMarketFeeDiscountParamsResponse{ |
107 | | - Params: params, |
108 | | - }, nil |
109 | | -} |
110 | | - |
111 | | -func (k Keeper) StakingTiers( |
112 | | - c context.Context, |
113 | | - req *types.QueryStakingTiersRequest, |
114 | | -) ( |
115 | | - *types.QueryStakingTiersResponse, |
116 | | - error, |
117 | | -) { |
118 | | - if req == nil { |
119 | | - return nil, status.Error(codes.InvalidArgument, "invalid request") |
120 | | - } |
121 | | - |
122 | | - ctx := lib.UnwrapSDKContext(c, types.ModuleName) |
123 | | - stakingTiers := k.GetAllStakingTiers(ctx) |
124 | | - return &types.QueryStakingTiersResponse{ |
125 | | - StakingTiers: stakingTiers, |
126 | | - }, nil |
127 | | -} |
128 | | - |
129 | | -func (k Keeper) UserStakingTier( |
130 | | - c context.Context, |
131 | | - req *types.QueryUserStakingTierRequest, |
132 | | -) ( |
133 | | - *types.QueryUserStakingTierResponse, |
134 | | - error, |
135 | | -) { |
136 | | - if req == nil { |
137 | | - return nil, status.Error(codes.InvalidArgument, "invalid request") |
138 | | - } |
139 | | - |
140 | | - ctx := lib.UnwrapSDKContext(c, types.ModuleName) |
141 | | - |
142 | | - // Validate address |
143 | | - _, err := sdk.AccAddressFromBech32(req.Address) |
144 | | - if err != nil { |
145 | | - return nil, status.Error(codes.InvalidArgument, "invalid bech32 address") |
146 | | - } |
147 | | - |
148 | | - // Get the user's fee tier |
149 | | - affiliateParameters, err := k.affiliatesKeeper.GetAffiliateParameters(ctx) |
150 | | - if err != nil { |
151 | | - return nil, err |
152 | | - } |
153 | | - _, userFeeTier := k.getUserFeeTier(ctx, req.Address, affiliateParameters.RefereeMinimumFeeTierIdx) |
154 | | - |
155 | | - // Get user's staking info |
156 | | - stakedAmount := k.statsKeeper.GetStakedAmount(ctx, req.Address) |
157 | | - discountPpm := k.GetStakingDiscountPpm(ctx, userFeeTier.Name, stakedAmount) |
158 | | - |
159 | | - return &types.QueryUserStakingTierResponse{ |
160 | | - FeeTierName: userFeeTier.Name, |
161 | | - StakedBaseTokens: dtypes.NewIntFromBigInt(stakedAmount), |
162 | | - DiscountPpm: discountPpm, |
163 | | - }, nil |
164 | | -} |
165 | | ->>>>>>> c667de27 (consider staking tiers when calculating fees (#3195)) |
0 commit comments