-
Notifications
You must be signed in to change notification settings - Fork 208
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
45 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package keeper | ||
|
||
import ( | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
|
||
"github.com/Stride-Labs/stride/v16/utils" | ||
icqtypes "github.com/Stride-Labs/stride/v16/x/interchainquery/types" | ||
) | ||
|
||
// TradeRewardBalanceCallback is a callback handler for TradeRewardBalance queries. | ||
// The query response will return the trade ICA account balance for a specific (foreign ibc) denom | ||
// If the balance is non-zero, ICA MsgSends are submitted to initiate a swap on the tradeZone | ||
// | ||
// Note: for now, to get proofs in your ICQs, you need to query the entire store on the host zone! e.g. "store/bank/key" | ||
func PoolPriceCallback(k Keeper, ctx sdk.Context, args []byte, query icqtypes.Query) error { | ||
k.Logger(ctx).Info(utils.LogICQCallbackWithHostZone(query.ChainId, ICQCallbackID_PoolPrice, | ||
"Starting pool spot price callback, QueryId: %vs, QueryType: %s, Connection: %s", query.Id, query.QueryType, query.ConnectionId)) | ||
|
||
// chainId := query.ChainId // should be the tradeZoneId, used in logging | ||
|
||
// TODO: [DYDX] Fix in separate PR | ||
// Unmarshal the query response args, should be a SpotPriceResponse type | ||
// var reponse types.QuerySpotPriceResponse | ||
// err := reponse.Unmarshal(args) | ||
// if err != nil { | ||
// return errorsmod.Wrap(err, "unable to unmarshal the query response") | ||
// } | ||
|
||
// response.SpotPrice should be a string representation of the denom ratios in pool like "10.203" | ||
|
||
// Unmarshal the callback data containing the tradeRoute we are on | ||
// var tradeRoute types.TradeRoute | ||
// if err := proto.Unmarshal(query.CallbackData, &tradeRoute); err != nil { | ||
// return errorsmod.Wrapf(err, "unable to unmarshal trade reward balance callback data") | ||
// } | ||
// k.Logger(ctx).Info(utils.LogICQCallbackWithHostZone(chainId, ICQCallbackID_PoolSpotPrice, | ||
// "Query response - spot price ratio of %s to %s is %s", | ||
// tradeRoute.RewardDenomOnTradeZone, tradeRoute.TargetDenomOnTradeZone, reponse.SpotPrice)) | ||
|
||
// // Update the spot price stored on the trade route data in the keeper | ||
// tradeRoute.SpotPrice = reponse.SpotPrice | ||
// k.SetTradeRoute(ctx, tradeRoute) | ||
|
||
return nil | ||
} |