Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Taker Fee Query #6680

Merged
merged 13 commits into from
Oct 13, 2023
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* [#6421](https://github.com/osmosis-labs/osmosis/pull/6421) Moves ValidatePermissionlessPoolCreationEnabled out of poolmanager module
* [#6627](https://github.com/osmosis-labs/osmosis/pull/6627) Limit pow iterations in osmomath.
* [#6586](https://github.com/osmosis-labs/osmosis/pull/6586) add auth.moduleaccounts to the stargate whitelist
* [#6680](https://github.com/osmosis-labs/osmosis/pull/6680) Add Taker Fee query and add it to stargate whitelist

### Bug Fixes
* [#6644](https://github.com/osmosis-labs/osmosis/pull/6644) fix: genesis bug in pool incentives linking NoLock gauges and PoolIDs
Expand Down
20 changes: 20 additions & 0 deletions proto/osmosis/poolmanager/v1beta1/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,13 @@ service Query {
"/osmosis/poolmanager/v1beta1/pools/{pool_id}/total_volume";
}

// TotalVolumeForPool returns the total volume of the specified pool.
mattverse marked this conversation as resolved.
Show resolved Hide resolved
rpc TradingPairTakerFee(TradingPairTakerFeeRequest)
returns (TradingPairTakerFeeResponse) {
option (google.api.http).get =
"/osmosis/poolmanager/v1beta1/pools/trading_pair_takerfee";
}

// EstimateTradeBasedOnPriceImpact returns an estimated trade based on price
// impact, if a trade cannot be estimated a 0 input and 0 output would be
// returned.
Expand Down Expand Up @@ -281,6 +288,19 @@ message TotalVolumeForPoolResponse {
];
}

//=============================== TotalVolumeForPool
mattverse marked this conversation as resolved.
Show resolved Hide resolved
message TradingPairTakerFeeRequest {
string denom_0 = 1 [ (gogoproto.moretags) = "yaml:\"denom_0\"" ];
string denom_1 = 2 [ (gogoproto.moretags) = "yaml:\"denom_1\"" ];
}

message TradingPairTakerFeeResponse {
string taker_fee = 1 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
}

//=============================== EstimateTradeBasedOnPriceImpact

// EstimateTradeBasedOnPriceImpactRequest represents a request to estimate a
Expand Down
1 change: 1 addition & 0 deletions wasmbinding/stargate_whitelist.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ func init() {
setWhitelistedQuery("/osmosis.poolmanager.v1beta1.Query/SpotPrice", &poolmanagerqueryproto.SpotPriceResponse{})
setWhitelistedQuery("/osmosis.poolmanager.v1beta1.Query/TotalPoolLiquidity", &poolmanagerqueryproto.TotalPoolLiquidityResponse{})
setWhitelistedQuery("/osmosis.poolmanager.v1beta1.Query/Params", &poolmanagerqueryproto.ParamsResponse{})
setWhitelistedQuery("/osmosis.poolmanager.v1beta1.Query/TradingPairTakerFee", &poolmanagerqueryproto.TradingPairTakerFeeResponse{})

// txfees
setWhitelistedQuery("/osmosis.txfees.v1beta1.Query/FeeTokens", &txfeestypes.QueryFeeTokensResponse{})
Expand Down
12 changes: 12 additions & 0 deletions x/poolmanager/client/query_proto_wrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,18 @@ func (q Querier) TotalVolumeForPool(ctx sdk.Context, req queryproto.TotalVolumeF
}, nil
}

// TradingPairTakerFee returns the taker fee for the given trading pair
func (q Querier) TradingPairTakerFee(ctx sdk.Context, req queryproto.TradingPairTakerFeeRequest) (*queryproto.TradingPairTakerFeeResponse, error) {
tradingPairTakerFee, err := q.K.GetTradingPairTakerFee(ctx, req.Denom_0, req.Denom_1)
if err != nil {
return nil, status.Error(codes.Internal, err.Error())
}

return &queryproto.TradingPairTakerFeeResponse{
TakerFee: tradingPairTakerFee,
}, nil
}

// EstimateTradeBasedOnPriceImpact returns the input and output amount of coins for a pool trade
// based on external price and maximum price impact.
func (q Querier) EstimateTradeBasedOnPriceImpact(
Expand Down
Loading