@cyberk/hyperion-sdk
Version:
Hyperion SDK from Cyberk
52 lines • 1.59 kB
JavaScript
import { queryContractSmart } from "../utils";
export const getQuoteQueryMsg = (options) => {
const { offerAmount, offerAsset, askAsset } = options;
return {
simulate_swap_operations: {
operations: [
{
hyperion: {
offer_asset_info: {
native_token: {
denom: offerAsset,
},
},
ask_asset_info: {
native_token: {
denom: askAsset,
},
},
},
},
],
offer_amount: offerAmount,
},
};
};
export const getQuoteQueryKey = (options) => {
return [
"simulateSwapOperations",
options.routerContract,
options.offerAsset,
options.askAsset,
options.offerAmount,
];
};
export const getQuoteFn = async (options) => {
const { client, routerContract } = options;
if (!client) {
throw new Error("Client is required");
}
if (!routerContract) {
throw new Error("Router contract address is required");
}
const result = await queryContractSmart(client, routerContract, getQuoteQueryMsg(options));
return result;
};
export const getQuoteQueryOptions = (options) => {
return {
queryFn: async () => getQuoteFn(options),
queryKey: getQuoteQueryKey(options),
};
};
//# sourceMappingURL=getQuote.js.map