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 using skipClient.balances #259

Merged
merged 20 commits into from
Sep 20, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions packages/widget-v2/src/pages/SwapPage/useSetMaxAmount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { useSourceBalance } from "./useSourceBalance";
import { BigNumber } from "bignumber.js";


const ETH_GAS_FEE = 0.1;
const ETH_GAS_FEE = 0.01;
const COSMOS_GAS_FEE = 2_000_000;

export const useGasFeeTokenAmount = () => {
Expand All @@ -21,13 +21,18 @@ export const useGasFeeTokenAmount = () => {
chainId: sourceAsset?.chainID,
});

const ethDetails = useGetAssetDetails({
assetDenom: "ethereum-native",
chainId: "1"
toddkao marked this conversation as resolved.
Show resolved Hide resolved
});

const feeAsset = chains?.find(chain => chain.chainID === sourceAsset?.chainID)?.feeAssets?.[0];

const chainType = sourceDetails?.chain?.chainType;

switch (chainType) {
case "evm":
return Number(convertHumanReadableAmountToCryptoAmount(ETH_GAS_FEE));
return Number(convertHumanReadableAmountToCryptoAmount(ETH_GAS_FEE, ethDetails.asset?.decimals));
case "cosmos":
if (!feeAsset?.gasPrice?.average || feeAsset.denom !== sourceAsset?.denom) return 0;
return Number(feeAsset.gasPrice.average) * (COSMOS_GAS_FEE);
Expand Down
Loading