@bze/bze-ui-kit 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +35 -2
- package/dist/index.d.ts +35 -2
- package/dist/index.js +210 -32
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +240 -64
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1036,6 +1036,7 @@ declare function useEpochs(): {
|
|
|
1036
1036
|
declare function useLiquidityPools(): {
|
|
1037
1037
|
pools: LiquidityPoolSDKType[];
|
|
1038
1038
|
poolsMap: Map<string, LiquidityPoolSDKType>;
|
|
1039
|
+
poolsData: Map<string, LiquidityPoolData>;
|
|
1039
1040
|
poolsDataMap: Map<string, LiquidityPoolData>;
|
|
1040
1041
|
isLoading: boolean;
|
|
1041
1042
|
updateLiquidityPools: () => Promise<void>;
|
|
@@ -1046,11 +1047,27 @@ declare function useLiquidityPools(): {
|
|
|
1046
1047
|
declare function useAssetLiquidityPools(denom: string): {
|
|
1047
1048
|
assetPools: LiquidityPoolSDKType[];
|
|
1048
1049
|
poolsDataMap: Map<string, LiquidityPoolData>;
|
|
1050
|
+
isLoading: boolean;
|
|
1051
|
+
asset24HoursVolume: BigNumber;
|
|
1052
|
+
assetPoolsData: Map<string, LiquidityPoolData>;
|
|
1053
|
+
};
|
|
1054
|
+
declare function useLiquidityPool(poolId: string): {
|
|
1055
|
+
isLoading: boolean;
|
|
1056
|
+
pool: LiquidityPoolSDKType | undefined;
|
|
1057
|
+
poolData: LiquidityPoolData | undefined;
|
|
1058
|
+
userShares: BigNumber;
|
|
1059
|
+
totalShares: BigNumber;
|
|
1060
|
+
userSharesPercentage: string | BigNumber;
|
|
1061
|
+
userReserveBase: BigNumber;
|
|
1062
|
+
userReserveQuote: BigNumber;
|
|
1063
|
+
calculateOppositeAmount: (amount: string | BigNumber, isBase: boolean) => BigNumber;
|
|
1064
|
+
calculateSharesFromAmounts: (baseAmount: string | BigNumber, quoteAmount: string | BigNumber) => BigNumber;
|
|
1049
1065
|
};
|
|
1050
1066
|
|
|
1051
1067
|
declare function useAssetsValue(): {
|
|
1052
1068
|
totalUsdValue: BigNumber;
|
|
1053
1069
|
denomUsdValue: (denom: string, uAmount: BigNumber) => BigNumber;
|
|
1070
|
+
compareValues: (a: PrettyBalance, b: PrettyBalance) => 0 | 1 | -1;
|
|
1054
1071
|
isLoading: boolean;
|
|
1055
1072
|
};
|
|
1056
1073
|
|
|
@@ -1062,19 +1079,35 @@ declare function useFeeTokens(): {
|
|
|
1062
1079
|
|
|
1063
1080
|
declare function useMarkets(): {
|
|
1064
1081
|
markets: _bze_bzejs_bze_tradebin_store.MarketSDKType[];
|
|
1082
|
+
marketsData: MarketData[];
|
|
1065
1083
|
marketsMap: Map<string, _bze_bzejs_bze_tradebin_store.MarketSDKType>;
|
|
1066
1084
|
marketsDataMap: Map<string, MarketData>;
|
|
1067
1085
|
isLoading: boolean;
|
|
1068
1086
|
updateMarkets: () => void;
|
|
1087
|
+
marketExists: (marketId: string) => boolean;
|
|
1088
|
+
getMarketData: (marketId: string) => MarketData | undefined;
|
|
1089
|
+
getMarket: (marketId: string) => Market | undefined;
|
|
1069
1090
|
};
|
|
1070
1091
|
declare function useAssetMarkets(denom: string): {
|
|
1092
|
+
isLoading: boolean;
|
|
1071
1093
|
assetMarkets: _bze_bzejs_bze_tradebin_store.MarketSDKType[];
|
|
1094
|
+
assetMarketsData: MarketData[];
|
|
1095
|
+
asset24hTradedVolume: BigNumber;
|
|
1072
1096
|
};
|
|
1073
|
-
|
|
1097
|
+
/**
|
|
1098
|
+
* Hook to get a market by its ID string.
|
|
1099
|
+
*/
|
|
1100
|
+
declare function useMarket(marketId: string): {
|
|
1101
|
+
isLoading: boolean;
|
|
1074
1102
|
market: _bze_bzejs_bze_tradebin_store.MarketSDKType | undefined;
|
|
1075
1103
|
marketData: MarketData | undefined;
|
|
1104
|
+
marketSymbol: string;
|
|
1105
|
+
marketId: string;
|
|
1076
1106
|
marketExists: boolean;
|
|
1077
1107
|
volume24h: BigNumber;
|
|
1108
|
+
};
|
|
1109
|
+
declare function useMarketsManager(): {
|
|
1110
|
+
updateMarkets: () => void;
|
|
1078
1111
|
isLoading: boolean;
|
|
1079
1112
|
};
|
|
1080
1113
|
|
|
@@ -1169,4 +1202,4 @@ interface SettingsToggleProps {
|
|
|
1169
1202
|
}
|
|
1170
1203
|
declare function SettingsToggle({ accentColor }: SettingsToggleProps): react_jsx_runtime.JSX.Element;
|
|
1171
1204
|
|
|
1172
|
-
export { ASSET_TYPE_FACTORY, ASSET_TYPE_IBC, ASSET_TYPE_LP, ASSET_TYPE_NATIVE, type ActiveOrders, type AddressRewardsStaking, type AddressValidationResult, type AppSettings, type Asset, type AssetBalance, AssetsContext, type AssetsContextType, type Attribute, BZE_CIRCLE_LOGO, BZE_TESTNET_2_SUGGEST_CHAIN, BZE_TESTNET_NETWORK, type Balance, type BeeZeeEndpoints, CHART_1D, CHART_1Y, CHART_30D, CHART_4H, CHART_7D, CONNECTION_TYPE_NONE, CONNECTION_TYPE_POLLING, CONNECTION_TYPE_WS, CURRENT_WALLET_BALANCE_EVENT, type ChainAssets, type ConnectionType, type CounterpartyChainForChannel, DEFAULT_SETTINGS, DEFAULT_TX_MEMO, type DenomTrace, ECOSYSTEM_MENU_LABEL, EPOCH_START_EVENT, EXCLUDED_ASSETS, EXCLUDED_MARKETS, type EcosystemApp, type EndpointValidationResults, type EventCallback, type ExtendedPendingUnlockParticipantSDKType, HighlightText, type HistoryOrder, type IBCCounterparty, type IBCData, type IbcTransitionMock, type InternalEvent, LOCK_CHANGED_EVENT, LP_ASSETS_DECIMALS, type LiquidityPoolData, MAINNET_CHAIN_INFO_FALLBACK, type Market, type MarketData, NEXT_BURN_CHANGED_EVENT, type NativeStakingData, type NativeUnbondingSummary, ORDER_BOOK_CHANGED_EVENT, ORDER_EXECUTED_EVENT, ORDER_TYPE_BUY, ORDER_TYPE_SELL, type PrettyBalance, type PriceApiResponse, RAFFLE_CHANGED_EVENT, SETTINGS_STORAGE_KEY, STABLE_COINS, SUPPLY_CHANGED_EVENT, SWAP_EXECUTED_EVENT, SettingsSidebarContent, SettingsToggle, Sidebar, type SwapHistory, type SwapRouteResult, TESTNET_CHAIN_INFO_FALLBACK, TOKEN_LOGO_PLACEHOLDER, TTL_NO_EXPIRY, type TendermintEvent, Toaster, type TradeViewChart, type TxOptions, TxStatus, type UserNativeStakingData, type UserNativeStakingRewards, type UserPoolData, VALIDATION_ERRORS, VERIFIED_ASSETS, type ValidationResult, WalletSidebarContent, addDebounce, addMultipleDebounce, ammRouter, amountToBigNumberUAmount, amountToUAmount, blockchainEventManager, calcNativeStakingApr, calculateAmountFromPrice, calculatePoolOppositeAmount, calculatePoolPrice, calculatePricePerUnit, calculateRewardsStakingApr, calculateRewardsStakingPendingRewards, calculateTotalAmount, calculateUserPoolData, canDepositFromIBC, canSendToIBC, cancelDebounce, convertToWebSocketUrl, counterpartyChainForChannel, createMarketId, createPoolId, createRestClient, denomOnFirstHopChainFromTrace, formatDate, formatTimeRemaining, formatTimeRemainingFromEpochs, formatUsdAmount, getAddressBalances, getAddressDelegations, getAddressFullMarketOrders, getAddressHistory, getAddressMarketOrders, getAddressNativeDelegatedBalance, getAddressNativeTotalRewards, getAddressPendingUnlock, getAddressRewards, getAddressStakingRewards, getAddressSwapHistory, getAddressUnbondingDelegations, getAddressUnbondingDelegationsSummary, getAggregatorHost, getAllBurnedCoins, getAllSupply, getAllSupplyMetadata, getAllTickers, getAnnualProvisions, getAppName, getArchwayRestURL, getArchwayRpcURL, getAssetLists, getAtomOneRestURL, getAtomOneRpcUrl, getBZEUSDPrice, getBurnerParams, getBurnerParamsWithClient, getChainAddressPrefix, getChainAssets, getChainByChainId, getChainByName, getChainExplorerURL, getChainId, getChainName, getChainNativeAssetDenom, getChains, getChartIntervalsLimit, getChartMinutes, getCurrentEpoch, getCurrentWeekEpochEndTime, getDefaultTxMemo, getDenomType, getDistributionParams, getEcosystemApps, getEpochDurationByIdentifier, getEpochsInfo, getFactoryDenomAdminAddress, getFromLocalStorage, getHashIBCTrace, getHourEpochInfo, getIBCAssetList, getIBCTraces, getIbcTransferTimeout, getJackalRestURL, getJackalRpcUrl, getKeyExpiry, getLiquidityPool, getLiquidityPools, getLockedBalances, getLockerAddress, getMarketBuyOrders, getMarketEventKey, getMarketHistory, getMarketOrder, getMarketOrderBookChangedEvent, getMarketOrders, getMarketOrdersHistory, getMarketSellOrders, getMarkets, getMinAmount, getNoOfIntervalsNeeded, getNobleRestURL, getNobleRpcUrl, getOmniFlixRestURL, getOmniFlixRpcUrl, getOsmosisRestURL, getOsmosisRpcUrl, getPageRequestWithLimit, getPendingUnlockParticipants, getPeriodicEpochEndTime, getPeriodicWeekEpochEndTime, getRestClient, getRestURL, getRpcURL, getSettings, getStakingParams, getStakingPool, getStakingRewardParticipantByAddress, getStakingRewards, getTradingViewIntervals, getUSDCDenom, getValidatorPageUrl, getValidatorSupportedDenoms, getWalletChainsNames, getWeekEpochInfo, intlDateFormat, isFactoryDenom, isIbcAsset, isIbcDenom, isLpDenom, isNativeDenom, isPoolSupportedByValidator, isTestnetChain, keplrSuggestChain, mapEventAttributes, openExternalLink, parseUnbondingDays, poolIdFromPoolDenom, prettyAmount, prettyError, priceToBigNumberUPrice, priceToUPrice, removeFromLocalStorage, removeLeadingZeros, sanitizeIntegerInput, sanitizeNumberInput, setDefaultTxMemo, setInLocalStorage, setKeyExpiry, setSettings, setStorageKeyVersion, shortNumberFormat, sleep, stringTruncateFromCenter, toBigNumber, toPercentage, truncateAddress, truncateDenom, uAmountToAmount, uAmountToBigNumberAmount, uPriceToBigNumberPrice, uPriceToPrice, useAsset, useAssetLiquidityPools, useAssetMarkets, useAssetPrice, useAssets, useAssetsContext, useAssetsManager, useAssetsValue, useBZETx, useBalance, useBalances, useConnectionType, useEpochs, useFeeTokens, useIBCChains, useIBCTx, useLiquidityPools, useMarket, useMarkets, useSDKTx, useSettings, useSigningClient, useToast, validateBZEBech32Address, validateBech32Address, validateEndpoints, validateRestEndpoint, validateRpcEndpoint };
|
|
1205
|
+
export { ASSET_TYPE_FACTORY, ASSET_TYPE_IBC, ASSET_TYPE_LP, ASSET_TYPE_NATIVE, type ActiveOrders, type AddressRewardsStaking, type AddressValidationResult, type AppSettings, type Asset, type AssetBalance, AssetsContext, type AssetsContextType, type Attribute, BZE_CIRCLE_LOGO, BZE_TESTNET_2_SUGGEST_CHAIN, BZE_TESTNET_NETWORK, type Balance, type BeeZeeEndpoints, CHART_1D, CHART_1Y, CHART_30D, CHART_4H, CHART_7D, CONNECTION_TYPE_NONE, CONNECTION_TYPE_POLLING, CONNECTION_TYPE_WS, CURRENT_WALLET_BALANCE_EVENT, type ChainAssets, type ConnectionType, type CounterpartyChainForChannel, DEFAULT_SETTINGS, DEFAULT_TX_MEMO, type DenomTrace, ECOSYSTEM_MENU_LABEL, EPOCH_START_EVENT, EXCLUDED_ASSETS, EXCLUDED_MARKETS, type EcosystemApp, type EndpointValidationResults, type EventCallback, type ExtendedPendingUnlockParticipantSDKType, HighlightText, type HistoryOrder, type IBCCounterparty, type IBCData, type IbcTransitionMock, type InternalEvent, LOCK_CHANGED_EVENT, LP_ASSETS_DECIMALS, type LiquidityPoolData, MAINNET_CHAIN_INFO_FALLBACK, type Market, type MarketData, NEXT_BURN_CHANGED_EVENT, type NativeStakingData, type NativeUnbondingSummary, ORDER_BOOK_CHANGED_EVENT, ORDER_EXECUTED_EVENT, ORDER_TYPE_BUY, ORDER_TYPE_SELL, type PrettyBalance, type PriceApiResponse, RAFFLE_CHANGED_EVENT, SETTINGS_STORAGE_KEY, STABLE_COINS, SUPPLY_CHANGED_EVENT, SWAP_EXECUTED_EVENT, SettingsSidebarContent, SettingsToggle, Sidebar, type SwapHistory, type SwapRouteResult, TESTNET_CHAIN_INFO_FALLBACK, TOKEN_LOGO_PLACEHOLDER, TTL_NO_EXPIRY, type TendermintEvent, Toaster, type TradeViewChart, type TxOptions, TxStatus, type UserNativeStakingData, type UserNativeStakingRewards, type UserPoolData, VALIDATION_ERRORS, VERIFIED_ASSETS, type ValidationResult, WalletSidebarContent, addDebounce, addMultipleDebounce, ammRouter, amountToBigNumberUAmount, amountToUAmount, blockchainEventManager, calcNativeStakingApr, calculateAmountFromPrice, calculatePoolOppositeAmount, calculatePoolPrice, calculatePricePerUnit, calculateRewardsStakingApr, calculateRewardsStakingPendingRewards, calculateTotalAmount, calculateUserPoolData, canDepositFromIBC, canSendToIBC, cancelDebounce, convertToWebSocketUrl, counterpartyChainForChannel, createMarketId, createPoolId, createRestClient, denomOnFirstHopChainFromTrace, formatDate, formatTimeRemaining, formatTimeRemainingFromEpochs, formatUsdAmount, getAddressBalances, getAddressDelegations, getAddressFullMarketOrders, getAddressHistory, getAddressMarketOrders, getAddressNativeDelegatedBalance, getAddressNativeTotalRewards, getAddressPendingUnlock, getAddressRewards, getAddressStakingRewards, getAddressSwapHistory, getAddressUnbondingDelegations, getAddressUnbondingDelegationsSummary, getAggregatorHost, getAllBurnedCoins, getAllSupply, getAllSupplyMetadata, getAllTickers, getAnnualProvisions, getAppName, getArchwayRestURL, getArchwayRpcURL, getAssetLists, getAtomOneRestURL, getAtomOneRpcUrl, getBZEUSDPrice, getBurnerParams, getBurnerParamsWithClient, getChainAddressPrefix, getChainAssets, getChainByChainId, getChainByName, getChainExplorerURL, getChainId, getChainName, getChainNativeAssetDenom, getChains, getChartIntervalsLimit, getChartMinutes, getCurrentEpoch, getCurrentWeekEpochEndTime, getDefaultTxMemo, getDenomType, getDistributionParams, getEcosystemApps, getEpochDurationByIdentifier, getEpochsInfo, getFactoryDenomAdminAddress, getFromLocalStorage, getHashIBCTrace, getHourEpochInfo, getIBCAssetList, getIBCTraces, getIbcTransferTimeout, getJackalRestURL, getJackalRpcUrl, getKeyExpiry, getLiquidityPool, getLiquidityPools, getLockedBalances, getLockerAddress, getMarketBuyOrders, getMarketEventKey, getMarketHistory, getMarketOrder, getMarketOrderBookChangedEvent, getMarketOrders, getMarketOrdersHistory, getMarketSellOrders, getMarkets, getMinAmount, getNoOfIntervalsNeeded, getNobleRestURL, getNobleRpcUrl, getOmniFlixRestURL, getOmniFlixRpcUrl, getOsmosisRestURL, getOsmosisRpcUrl, getPageRequestWithLimit, getPendingUnlockParticipants, getPeriodicEpochEndTime, getPeriodicWeekEpochEndTime, getRestClient, getRestURL, getRpcURL, getSettings, getStakingParams, getStakingPool, getStakingRewardParticipantByAddress, getStakingRewards, getTradingViewIntervals, getUSDCDenom, getValidatorPageUrl, getValidatorSupportedDenoms, getWalletChainsNames, getWeekEpochInfo, intlDateFormat, isFactoryDenom, isIbcAsset, isIbcDenom, isLpDenom, isNativeDenom, isPoolSupportedByValidator, isTestnetChain, keplrSuggestChain, mapEventAttributes, openExternalLink, parseUnbondingDays, poolIdFromPoolDenom, prettyAmount, prettyError, priceToBigNumberUPrice, priceToUPrice, removeFromLocalStorage, removeLeadingZeros, sanitizeIntegerInput, sanitizeNumberInput, setDefaultTxMemo, setInLocalStorage, setKeyExpiry, setSettings, setStorageKeyVersion, shortNumberFormat, sleep, stringTruncateFromCenter, toBigNumber, toPercentage, truncateAddress, truncateDenom, uAmountToAmount, uAmountToBigNumberAmount, uPriceToBigNumberPrice, uPriceToPrice, useAsset, useAssetLiquidityPools, useAssetMarkets, useAssetPrice, useAssets, useAssetsContext, useAssetsManager, useAssetsValue, useBZETx, useBalance, useBalances, useConnectionType, useEpochs, useFeeTokens, useIBCChains, useIBCTx, useLiquidityPool, useLiquidityPools, useMarket, useMarkets, useMarketsManager, useSDKTx, useSettings, useSigningClient, useToast, validateBZEBech32Address, validateBech32Address, validateEndpoints, validateRestEndpoint, validateRpcEndpoint };
|
package/dist/index.d.ts
CHANGED
|
@@ -1036,6 +1036,7 @@ declare function useEpochs(): {
|
|
|
1036
1036
|
declare function useLiquidityPools(): {
|
|
1037
1037
|
pools: LiquidityPoolSDKType[];
|
|
1038
1038
|
poolsMap: Map<string, LiquidityPoolSDKType>;
|
|
1039
|
+
poolsData: Map<string, LiquidityPoolData>;
|
|
1039
1040
|
poolsDataMap: Map<string, LiquidityPoolData>;
|
|
1040
1041
|
isLoading: boolean;
|
|
1041
1042
|
updateLiquidityPools: () => Promise<void>;
|
|
@@ -1046,11 +1047,27 @@ declare function useLiquidityPools(): {
|
|
|
1046
1047
|
declare function useAssetLiquidityPools(denom: string): {
|
|
1047
1048
|
assetPools: LiquidityPoolSDKType[];
|
|
1048
1049
|
poolsDataMap: Map<string, LiquidityPoolData>;
|
|
1050
|
+
isLoading: boolean;
|
|
1051
|
+
asset24HoursVolume: BigNumber;
|
|
1052
|
+
assetPoolsData: Map<string, LiquidityPoolData>;
|
|
1053
|
+
};
|
|
1054
|
+
declare function useLiquidityPool(poolId: string): {
|
|
1055
|
+
isLoading: boolean;
|
|
1056
|
+
pool: LiquidityPoolSDKType | undefined;
|
|
1057
|
+
poolData: LiquidityPoolData | undefined;
|
|
1058
|
+
userShares: BigNumber;
|
|
1059
|
+
totalShares: BigNumber;
|
|
1060
|
+
userSharesPercentage: string | BigNumber;
|
|
1061
|
+
userReserveBase: BigNumber;
|
|
1062
|
+
userReserveQuote: BigNumber;
|
|
1063
|
+
calculateOppositeAmount: (amount: string | BigNumber, isBase: boolean) => BigNumber;
|
|
1064
|
+
calculateSharesFromAmounts: (baseAmount: string | BigNumber, quoteAmount: string | BigNumber) => BigNumber;
|
|
1049
1065
|
};
|
|
1050
1066
|
|
|
1051
1067
|
declare function useAssetsValue(): {
|
|
1052
1068
|
totalUsdValue: BigNumber;
|
|
1053
1069
|
denomUsdValue: (denom: string, uAmount: BigNumber) => BigNumber;
|
|
1070
|
+
compareValues: (a: PrettyBalance, b: PrettyBalance) => 0 | 1 | -1;
|
|
1054
1071
|
isLoading: boolean;
|
|
1055
1072
|
};
|
|
1056
1073
|
|
|
@@ -1062,19 +1079,35 @@ declare function useFeeTokens(): {
|
|
|
1062
1079
|
|
|
1063
1080
|
declare function useMarkets(): {
|
|
1064
1081
|
markets: _bze_bzejs_bze_tradebin_store.MarketSDKType[];
|
|
1082
|
+
marketsData: MarketData[];
|
|
1065
1083
|
marketsMap: Map<string, _bze_bzejs_bze_tradebin_store.MarketSDKType>;
|
|
1066
1084
|
marketsDataMap: Map<string, MarketData>;
|
|
1067
1085
|
isLoading: boolean;
|
|
1068
1086
|
updateMarkets: () => void;
|
|
1087
|
+
marketExists: (marketId: string) => boolean;
|
|
1088
|
+
getMarketData: (marketId: string) => MarketData | undefined;
|
|
1089
|
+
getMarket: (marketId: string) => Market | undefined;
|
|
1069
1090
|
};
|
|
1070
1091
|
declare function useAssetMarkets(denom: string): {
|
|
1092
|
+
isLoading: boolean;
|
|
1071
1093
|
assetMarkets: _bze_bzejs_bze_tradebin_store.MarketSDKType[];
|
|
1094
|
+
assetMarketsData: MarketData[];
|
|
1095
|
+
asset24hTradedVolume: BigNumber;
|
|
1072
1096
|
};
|
|
1073
|
-
|
|
1097
|
+
/**
|
|
1098
|
+
* Hook to get a market by its ID string.
|
|
1099
|
+
*/
|
|
1100
|
+
declare function useMarket(marketId: string): {
|
|
1101
|
+
isLoading: boolean;
|
|
1074
1102
|
market: _bze_bzejs_bze_tradebin_store.MarketSDKType | undefined;
|
|
1075
1103
|
marketData: MarketData | undefined;
|
|
1104
|
+
marketSymbol: string;
|
|
1105
|
+
marketId: string;
|
|
1076
1106
|
marketExists: boolean;
|
|
1077
1107
|
volume24h: BigNumber;
|
|
1108
|
+
};
|
|
1109
|
+
declare function useMarketsManager(): {
|
|
1110
|
+
updateMarkets: () => void;
|
|
1078
1111
|
isLoading: boolean;
|
|
1079
1112
|
};
|
|
1080
1113
|
|
|
@@ -1169,4 +1202,4 @@ interface SettingsToggleProps {
|
|
|
1169
1202
|
}
|
|
1170
1203
|
declare function SettingsToggle({ accentColor }: SettingsToggleProps): react_jsx_runtime.JSX.Element;
|
|
1171
1204
|
|
|
1172
|
-
export { ASSET_TYPE_FACTORY, ASSET_TYPE_IBC, ASSET_TYPE_LP, ASSET_TYPE_NATIVE, type ActiveOrders, type AddressRewardsStaking, type AddressValidationResult, type AppSettings, type Asset, type AssetBalance, AssetsContext, type AssetsContextType, type Attribute, BZE_CIRCLE_LOGO, BZE_TESTNET_2_SUGGEST_CHAIN, BZE_TESTNET_NETWORK, type Balance, type BeeZeeEndpoints, CHART_1D, CHART_1Y, CHART_30D, CHART_4H, CHART_7D, CONNECTION_TYPE_NONE, CONNECTION_TYPE_POLLING, CONNECTION_TYPE_WS, CURRENT_WALLET_BALANCE_EVENT, type ChainAssets, type ConnectionType, type CounterpartyChainForChannel, DEFAULT_SETTINGS, DEFAULT_TX_MEMO, type DenomTrace, ECOSYSTEM_MENU_LABEL, EPOCH_START_EVENT, EXCLUDED_ASSETS, EXCLUDED_MARKETS, type EcosystemApp, type EndpointValidationResults, type EventCallback, type ExtendedPendingUnlockParticipantSDKType, HighlightText, type HistoryOrder, type IBCCounterparty, type IBCData, type IbcTransitionMock, type InternalEvent, LOCK_CHANGED_EVENT, LP_ASSETS_DECIMALS, type LiquidityPoolData, MAINNET_CHAIN_INFO_FALLBACK, type Market, type MarketData, NEXT_BURN_CHANGED_EVENT, type NativeStakingData, type NativeUnbondingSummary, ORDER_BOOK_CHANGED_EVENT, ORDER_EXECUTED_EVENT, ORDER_TYPE_BUY, ORDER_TYPE_SELL, type PrettyBalance, type PriceApiResponse, RAFFLE_CHANGED_EVENT, SETTINGS_STORAGE_KEY, STABLE_COINS, SUPPLY_CHANGED_EVENT, SWAP_EXECUTED_EVENT, SettingsSidebarContent, SettingsToggle, Sidebar, type SwapHistory, type SwapRouteResult, TESTNET_CHAIN_INFO_FALLBACK, TOKEN_LOGO_PLACEHOLDER, TTL_NO_EXPIRY, type TendermintEvent, Toaster, type TradeViewChart, type TxOptions, TxStatus, type UserNativeStakingData, type UserNativeStakingRewards, type UserPoolData, VALIDATION_ERRORS, VERIFIED_ASSETS, type ValidationResult, WalletSidebarContent, addDebounce, addMultipleDebounce, ammRouter, amountToBigNumberUAmount, amountToUAmount, blockchainEventManager, calcNativeStakingApr, calculateAmountFromPrice, calculatePoolOppositeAmount, calculatePoolPrice, calculatePricePerUnit, calculateRewardsStakingApr, calculateRewardsStakingPendingRewards, calculateTotalAmount, calculateUserPoolData, canDepositFromIBC, canSendToIBC, cancelDebounce, convertToWebSocketUrl, counterpartyChainForChannel, createMarketId, createPoolId, createRestClient, denomOnFirstHopChainFromTrace, formatDate, formatTimeRemaining, formatTimeRemainingFromEpochs, formatUsdAmount, getAddressBalances, getAddressDelegations, getAddressFullMarketOrders, getAddressHistory, getAddressMarketOrders, getAddressNativeDelegatedBalance, getAddressNativeTotalRewards, getAddressPendingUnlock, getAddressRewards, getAddressStakingRewards, getAddressSwapHistory, getAddressUnbondingDelegations, getAddressUnbondingDelegationsSummary, getAggregatorHost, getAllBurnedCoins, getAllSupply, getAllSupplyMetadata, getAllTickers, getAnnualProvisions, getAppName, getArchwayRestURL, getArchwayRpcURL, getAssetLists, getAtomOneRestURL, getAtomOneRpcUrl, getBZEUSDPrice, getBurnerParams, getBurnerParamsWithClient, getChainAddressPrefix, getChainAssets, getChainByChainId, getChainByName, getChainExplorerURL, getChainId, getChainName, getChainNativeAssetDenom, getChains, getChartIntervalsLimit, getChartMinutes, getCurrentEpoch, getCurrentWeekEpochEndTime, getDefaultTxMemo, getDenomType, getDistributionParams, getEcosystemApps, getEpochDurationByIdentifier, getEpochsInfo, getFactoryDenomAdminAddress, getFromLocalStorage, getHashIBCTrace, getHourEpochInfo, getIBCAssetList, getIBCTraces, getIbcTransferTimeout, getJackalRestURL, getJackalRpcUrl, getKeyExpiry, getLiquidityPool, getLiquidityPools, getLockedBalances, getLockerAddress, getMarketBuyOrders, getMarketEventKey, getMarketHistory, getMarketOrder, getMarketOrderBookChangedEvent, getMarketOrders, getMarketOrdersHistory, getMarketSellOrders, getMarkets, getMinAmount, getNoOfIntervalsNeeded, getNobleRestURL, getNobleRpcUrl, getOmniFlixRestURL, getOmniFlixRpcUrl, getOsmosisRestURL, getOsmosisRpcUrl, getPageRequestWithLimit, getPendingUnlockParticipants, getPeriodicEpochEndTime, getPeriodicWeekEpochEndTime, getRestClient, getRestURL, getRpcURL, getSettings, getStakingParams, getStakingPool, getStakingRewardParticipantByAddress, getStakingRewards, getTradingViewIntervals, getUSDCDenom, getValidatorPageUrl, getValidatorSupportedDenoms, getWalletChainsNames, getWeekEpochInfo, intlDateFormat, isFactoryDenom, isIbcAsset, isIbcDenom, isLpDenom, isNativeDenom, isPoolSupportedByValidator, isTestnetChain, keplrSuggestChain, mapEventAttributes, openExternalLink, parseUnbondingDays, poolIdFromPoolDenom, prettyAmount, prettyError, priceToBigNumberUPrice, priceToUPrice, removeFromLocalStorage, removeLeadingZeros, sanitizeIntegerInput, sanitizeNumberInput, setDefaultTxMemo, setInLocalStorage, setKeyExpiry, setSettings, setStorageKeyVersion, shortNumberFormat, sleep, stringTruncateFromCenter, toBigNumber, toPercentage, truncateAddress, truncateDenom, uAmountToAmount, uAmountToBigNumberAmount, uPriceToBigNumberPrice, uPriceToPrice, useAsset, useAssetLiquidityPools, useAssetMarkets, useAssetPrice, useAssets, useAssetsContext, useAssetsManager, useAssetsValue, useBZETx, useBalance, useBalances, useConnectionType, useEpochs, useFeeTokens, useIBCChains, useIBCTx, useLiquidityPools, useMarket, useMarkets, useSDKTx, useSettings, useSigningClient, useToast, validateBZEBech32Address, validateBech32Address, validateEndpoints, validateRestEndpoint, validateRpcEndpoint };
|
|
1205
|
+
export { ASSET_TYPE_FACTORY, ASSET_TYPE_IBC, ASSET_TYPE_LP, ASSET_TYPE_NATIVE, type ActiveOrders, type AddressRewardsStaking, type AddressValidationResult, type AppSettings, type Asset, type AssetBalance, AssetsContext, type AssetsContextType, type Attribute, BZE_CIRCLE_LOGO, BZE_TESTNET_2_SUGGEST_CHAIN, BZE_TESTNET_NETWORK, type Balance, type BeeZeeEndpoints, CHART_1D, CHART_1Y, CHART_30D, CHART_4H, CHART_7D, CONNECTION_TYPE_NONE, CONNECTION_TYPE_POLLING, CONNECTION_TYPE_WS, CURRENT_WALLET_BALANCE_EVENT, type ChainAssets, type ConnectionType, type CounterpartyChainForChannel, DEFAULT_SETTINGS, DEFAULT_TX_MEMO, type DenomTrace, ECOSYSTEM_MENU_LABEL, EPOCH_START_EVENT, EXCLUDED_ASSETS, EXCLUDED_MARKETS, type EcosystemApp, type EndpointValidationResults, type EventCallback, type ExtendedPendingUnlockParticipantSDKType, HighlightText, type HistoryOrder, type IBCCounterparty, type IBCData, type IbcTransitionMock, type InternalEvent, LOCK_CHANGED_EVENT, LP_ASSETS_DECIMALS, type LiquidityPoolData, MAINNET_CHAIN_INFO_FALLBACK, type Market, type MarketData, NEXT_BURN_CHANGED_EVENT, type NativeStakingData, type NativeUnbondingSummary, ORDER_BOOK_CHANGED_EVENT, ORDER_EXECUTED_EVENT, ORDER_TYPE_BUY, ORDER_TYPE_SELL, type PrettyBalance, type PriceApiResponse, RAFFLE_CHANGED_EVENT, SETTINGS_STORAGE_KEY, STABLE_COINS, SUPPLY_CHANGED_EVENT, SWAP_EXECUTED_EVENT, SettingsSidebarContent, SettingsToggle, Sidebar, type SwapHistory, type SwapRouteResult, TESTNET_CHAIN_INFO_FALLBACK, TOKEN_LOGO_PLACEHOLDER, TTL_NO_EXPIRY, type TendermintEvent, Toaster, type TradeViewChart, type TxOptions, TxStatus, type UserNativeStakingData, type UserNativeStakingRewards, type UserPoolData, VALIDATION_ERRORS, VERIFIED_ASSETS, type ValidationResult, WalletSidebarContent, addDebounce, addMultipleDebounce, ammRouter, amountToBigNumberUAmount, amountToUAmount, blockchainEventManager, calcNativeStakingApr, calculateAmountFromPrice, calculatePoolOppositeAmount, calculatePoolPrice, calculatePricePerUnit, calculateRewardsStakingApr, calculateRewardsStakingPendingRewards, calculateTotalAmount, calculateUserPoolData, canDepositFromIBC, canSendToIBC, cancelDebounce, convertToWebSocketUrl, counterpartyChainForChannel, createMarketId, createPoolId, createRestClient, denomOnFirstHopChainFromTrace, formatDate, formatTimeRemaining, formatTimeRemainingFromEpochs, formatUsdAmount, getAddressBalances, getAddressDelegations, getAddressFullMarketOrders, getAddressHistory, getAddressMarketOrders, getAddressNativeDelegatedBalance, getAddressNativeTotalRewards, getAddressPendingUnlock, getAddressRewards, getAddressStakingRewards, getAddressSwapHistory, getAddressUnbondingDelegations, getAddressUnbondingDelegationsSummary, getAggregatorHost, getAllBurnedCoins, getAllSupply, getAllSupplyMetadata, getAllTickers, getAnnualProvisions, getAppName, getArchwayRestURL, getArchwayRpcURL, getAssetLists, getAtomOneRestURL, getAtomOneRpcUrl, getBZEUSDPrice, getBurnerParams, getBurnerParamsWithClient, getChainAddressPrefix, getChainAssets, getChainByChainId, getChainByName, getChainExplorerURL, getChainId, getChainName, getChainNativeAssetDenom, getChains, getChartIntervalsLimit, getChartMinutes, getCurrentEpoch, getCurrentWeekEpochEndTime, getDefaultTxMemo, getDenomType, getDistributionParams, getEcosystemApps, getEpochDurationByIdentifier, getEpochsInfo, getFactoryDenomAdminAddress, getFromLocalStorage, getHashIBCTrace, getHourEpochInfo, getIBCAssetList, getIBCTraces, getIbcTransferTimeout, getJackalRestURL, getJackalRpcUrl, getKeyExpiry, getLiquidityPool, getLiquidityPools, getLockedBalances, getLockerAddress, getMarketBuyOrders, getMarketEventKey, getMarketHistory, getMarketOrder, getMarketOrderBookChangedEvent, getMarketOrders, getMarketOrdersHistory, getMarketSellOrders, getMarkets, getMinAmount, getNoOfIntervalsNeeded, getNobleRestURL, getNobleRpcUrl, getOmniFlixRestURL, getOmniFlixRpcUrl, getOsmosisRestURL, getOsmosisRpcUrl, getPageRequestWithLimit, getPendingUnlockParticipants, getPeriodicEpochEndTime, getPeriodicWeekEpochEndTime, getRestClient, getRestURL, getRpcURL, getSettings, getStakingParams, getStakingPool, getStakingRewardParticipantByAddress, getStakingRewards, getTradingViewIntervals, getUSDCDenom, getValidatorPageUrl, getValidatorSupportedDenoms, getWalletChainsNames, getWeekEpochInfo, intlDateFormat, isFactoryDenom, isIbcAsset, isIbcDenom, isLpDenom, isNativeDenom, isPoolSupportedByValidator, isTestnetChain, keplrSuggestChain, mapEventAttributes, openExternalLink, parseUnbondingDays, poolIdFromPoolDenom, prettyAmount, prettyError, priceToBigNumberUPrice, priceToUPrice, removeFromLocalStorage, removeLeadingZeros, sanitizeIntegerInput, sanitizeNumberInput, setDefaultTxMemo, setInLocalStorage, setKeyExpiry, setSettings, setStorageKeyVersion, shortNumberFormat, sleep, stringTruncateFromCenter, toBigNumber, toPercentage, truncateAddress, truncateDenom, uAmountToAmount, uAmountToBigNumberAmount, uPriceToBigNumberPrice, uPriceToPrice, useAsset, useAssetLiquidityPools, useAssetMarkets, useAssetPrice, useAssets, useAssetsContext, useAssetsManager, useAssetsValue, useBZETx, useBalance, useBalances, useConnectionType, useEpochs, useFeeTokens, useIBCChains, useIBCTx, useLiquidityPool, useLiquidityPools, useMarket, useMarkets, useMarketsManager, useSDKTx, useSettings, useSigningClient, useToast, validateBZEBech32Address, validateBech32Address, validateEndpoints, validateRestEndpoint, validateRpcEndpoint };
|
package/dist/index.js
CHANGED
|
@@ -284,9 +284,11 @@ __export(index_exports, {
|
|
|
284
284
|
useFeeTokens: () => useFeeTokens,
|
|
285
285
|
useIBCChains: () => useIBCChains,
|
|
286
286
|
useIBCTx: () => useIBCTx,
|
|
287
|
+
useLiquidityPool: () => useLiquidityPool,
|
|
287
288
|
useLiquidityPools: () => useLiquidityPools,
|
|
288
289
|
useMarket: () => useMarket,
|
|
289
290
|
useMarkets: () => useMarkets,
|
|
291
|
+
useMarketsManager: () => useMarketsManager,
|
|
290
292
|
useSDKTx: () => useSDKTx,
|
|
291
293
|
useSettings: () => useSettings,
|
|
292
294
|
useSigningClient: () => useSigningClient,
|
|
@@ -3235,6 +3237,7 @@ function useEpochs() {
|
|
|
3235
3237
|
|
|
3236
3238
|
// src/hooks/useLiquidityPools.ts
|
|
3237
3239
|
var import_react9 = require("react");
|
|
3240
|
+
var import_bignumber9 = __toESM(require("bignumber.js"));
|
|
3238
3241
|
function useLiquidityPools() {
|
|
3239
3242
|
const { poolsMap, poolsDataMap, updateLiquidityPools, isLoading, assetsMap } = useAssetsContext();
|
|
3240
3243
|
const pools = (0, import_react9.useMemo)(() => {
|
|
@@ -3260,6 +3263,7 @@ function useLiquidityPools() {
|
|
|
3260
3263
|
return {
|
|
3261
3264
|
pools,
|
|
3262
3265
|
poolsMap,
|
|
3266
|
+
poolsData: poolsDataMap,
|
|
3263
3267
|
poolsDataMap,
|
|
3264
3268
|
isLoading,
|
|
3265
3269
|
updateLiquidityPools,
|
|
@@ -3269,22 +3273,124 @@ function useLiquidityPools() {
|
|
|
3269
3273
|
};
|
|
3270
3274
|
}
|
|
3271
3275
|
function useAssetLiquidityPools(denom) {
|
|
3272
|
-
const { poolsMap, poolsDataMap } = useAssetsContext();
|
|
3276
|
+
const { poolsMap, poolsDataMap, isLoading } = useAssetsContext();
|
|
3273
3277
|
const assetPools = (0, import_react9.useMemo)(() => {
|
|
3274
3278
|
return Array.from(poolsMap.values()).filter(
|
|
3275
3279
|
(pool) => pool.base === denom || pool.quote === denom
|
|
3276
3280
|
);
|
|
3277
3281
|
}, [poolsMap, denom]);
|
|
3282
|
+
const assetPoolsData = (0, import_react9.useMemo)(() => {
|
|
3283
|
+
const newMap = /* @__PURE__ */ new Map();
|
|
3284
|
+
if (isLoading || denom === "") return newMap;
|
|
3285
|
+
assetPools.forEach((pool) => {
|
|
3286
|
+
const poolData = poolsDataMap.get(pool.id);
|
|
3287
|
+
if (poolData) {
|
|
3288
|
+
newMap.set(pool.id, poolData);
|
|
3289
|
+
}
|
|
3290
|
+
});
|
|
3291
|
+
return newMap;
|
|
3292
|
+
}, [assetPools, poolsDataMap, isLoading, denom]);
|
|
3293
|
+
const asset24HoursVolume = (0, import_react9.useMemo)(() => {
|
|
3294
|
+
let volume = (0, import_bignumber9.default)(0);
|
|
3295
|
+
if (isLoading || denom === "") return volume;
|
|
3296
|
+
assetPoolsData.forEach((poolData) => {
|
|
3297
|
+
if (poolData.base === denom) {
|
|
3298
|
+
volume = volume.plus(poolData.baseVolume);
|
|
3299
|
+
} else if (poolData.quote === denom) {
|
|
3300
|
+
volume = volume.plus(poolData.quoteVolume);
|
|
3301
|
+
}
|
|
3302
|
+
});
|
|
3303
|
+
return volume;
|
|
3304
|
+
}, [isLoading, assetPoolsData, denom]);
|
|
3278
3305
|
return {
|
|
3279
3306
|
assetPools,
|
|
3280
|
-
poolsDataMap
|
|
3307
|
+
poolsDataMap,
|
|
3308
|
+
isLoading,
|
|
3309
|
+
asset24HoursVolume,
|
|
3310
|
+
assetPoolsData
|
|
3311
|
+
};
|
|
3312
|
+
}
|
|
3313
|
+
function useLiquidityPool(poolId) {
|
|
3314
|
+
const { balancesMap, assetsMap, poolsMap, poolsDataMap, isLoading } = useAssetsContext();
|
|
3315
|
+
const pool = (0, import_react9.useMemo)(() => poolsMap.get(poolId), [poolsMap, poolId]);
|
|
3316
|
+
const poolData = (0, import_react9.useMemo)(() => poolsDataMap.get(poolId), [poolsDataMap, poolId]);
|
|
3317
|
+
const userShares = (0, import_react9.useMemo)(() => {
|
|
3318
|
+
if (!pool) return toBigNumber(0);
|
|
3319
|
+
const balance = balancesMap.get(pool.lp_denom);
|
|
3320
|
+
if (!balance) return toBigNumber(0);
|
|
3321
|
+
return toBigNumber(balance.amount);
|
|
3322
|
+
}, [balancesMap, pool]);
|
|
3323
|
+
const totalShares = (0, import_react9.useMemo)(() => {
|
|
3324
|
+
if (!assetsMap || !pool) return toBigNumber(0);
|
|
3325
|
+
const sharesAsset = assetsMap.get(pool.lp_denom);
|
|
3326
|
+
if (!sharesAsset) return toBigNumber(0);
|
|
3327
|
+
return toBigNumber((sharesAsset == null ? void 0 : sharesAsset.supply) || 0);
|
|
3328
|
+
}, [assetsMap, pool]);
|
|
3329
|
+
const userSharesPercentage = (0, import_react9.useMemo)(() => {
|
|
3330
|
+
if (!userShares || !totalShares || totalShares.isZero()) {
|
|
3331
|
+
return toBigNumber(0);
|
|
3332
|
+
}
|
|
3333
|
+
return userShares.dividedBy(totalShares).multipliedBy(100).toFixed(2);
|
|
3334
|
+
}, [userShares, totalShares]);
|
|
3335
|
+
const userReserveBase = (0, import_react9.useMemo)(() => {
|
|
3336
|
+
if (!pool || !userShares || !totalShares || totalShares.isZero()) {
|
|
3337
|
+
return toBigNumber(0);
|
|
3338
|
+
}
|
|
3339
|
+
const reserveBase = toBigNumber(pool.reserve_base);
|
|
3340
|
+
return userShares.dividedBy(totalShares).multipliedBy(reserveBase);
|
|
3341
|
+
}, [pool, userShares, totalShares]);
|
|
3342
|
+
const userReserveQuote = (0, import_react9.useMemo)(() => {
|
|
3343
|
+
if (!pool || !userShares || !totalShares || totalShares.isZero()) {
|
|
3344
|
+
return toBigNumber(0);
|
|
3345
|
+
}
|
|
3346
|
+
const reserveQuote = toBigNumber(pool.reserve_quote);
|
|
3347
|
+
return userShares.dividedBy(totalShares).multipliedBy(reserveQuote);
|
|
3348
|
+
}, [pool, userShares, totalShares]);
|
|
3349
|
+
const calculateOppositeAmount = (0, import_react9.useCallback)((amount, isBase) => {
|
|
3350
|
+
if (!pool) {
|
|
3351
|
+
return toBigNumber(0);
|
|
3352
|
+
}
|
|
3353
|
+
return calculatePoolOppositeAmount(pool, amount, isBase);
|
|
3354
|
+
}, [pool]);
|
|
3355
|
+
const calculateSharesFromAmounts = (0, import_react9.useCallback)((baseAmount, quoteAmount) => {
|
|
3356
|
+
if (!pool || !totalShares) {
|
|
3357
|
+
return toBigNumber(0);
|
|
3358
|
+
}
|
|
3359
|
+
const baseAmountBN = toBigNumber(baseAmount);
|
|
3360
|
+
const quoteAmountBN = toBigNumber(quoteAmount);
|
|
3361
|
+
if (baseAmountBN.isZero() || baseAmountBN.isNaN() || quoteAmountBN.isZero() || quoteAmountBN.isNaN()) {
|
|
3362
|
+
return toBigNumber(0);
|
|
3363
|
+
}
|
|
3364
|
+
const reserveBase = toBigNumber(pool.reserve_base);
|
|
3365
|
+
const reserveQuote = toBigNumber(pool.reserve_quote);
|
|
3366
|
+
if (reserveBase.isZero() || reserveQuote.isZero() || totalShares.isZero()) {
|
|
3367
|
+
return toBigNumber(0);
|
|
3368
|
+
}
|
|
3369
|
+
const baseRatio = baseAmountBN.dividedBy(reserveBase);
|
|
3370
|
+
const quoteRatio = quoteAmountBN.dividedBy(reserveQuote);
|
|
3371
|
+
const mintRatio = import_bignumber9.default.minimum(baseRatio, quoteRatio);
|
|
3372
|
+
const tokensToMint = mintRatio.multipliedBy(totalShares);
|
|
3373
|
+
return tokensToMint.integerValue(import_bignumber9.default.ROUND_DOWN);
|
|
3374
|
+
}, [pool, totalShares]);
|
|
3375
|
+
return {
|
|
3376
|
+
isLoading,
|
|
3377
|
+
pool,
|
|
3378
|
+
poolData,
|
|
3379
|
+
userShares,
|
|
3380
|
+
totalShares,
|
|
3381
|
+
userSharesPercentage,
|
|
3382
|
+
userReserveBase,
|
|
3383
|
+
userReserveQuote,
|
|
3384
|
+
calculateOppositeAmount,
|
|
3385
|
+
calculateSharesFromAmounts
|
|
3281
3386
|
};
|
|
3282
3387
|
}
|
|
3283
3388
|
|
|
3284
3389
|
// src/hooks/useAssetsValue.ts
|
|
3285
3390
|
var import_react10 = require("react");
|
|
3391
|
+
var import_bignumber10 = __toESM(require("bignumber.js"));
|
|
3286
3392
|
function useAssetsValue() {
|
|
3287
|
-
const { assetsMap, usdPricesMap, balancesMap, isLoading } = useAssetsContext();
|
|
3393
|
+
const { assetsMap, usdPricesMap, balancesMap, isLoading: isLoadingPrices } = useAssetsContext();
|
|
3288
3394
|
const totalUsdValue = (0, import_react10.useMemo)(() => {
|
|
3289
3395
|
let total = toBigNumber(0);
|
|
3290
3396
|
balancesMap.forEach((balance, denom) => {
|
|
@@ -3296,17 +3402,32 @@ function useAssetsValue() {
|
|
|
3296
3402
|
});
|
|
3297
3403
|
return total;
|
|
3298
3404
|
}, [balancesMap, usdPricesMap, assetsMap]);
|
|
3299
|
-
const denomUsdValue = (denom, uAmount) => {
|
|
3405
|
+
const denomUsdValue = (0, import_react10.useCallback)((denom, uAmount) => {
|
|
3300
3406
|
const price = usdPricesMap.get(denom);
|
|
3301
3407
|
if (!price || !price.gt(0)) return toBigNumber(0);
|
|
3302
3408
|
const asset = assetsMap.get(denom);
|
|
3303
3409
|
if (!asset) return toBigNumber(0);
|
|
3304
3410
|
return price.multipliedBy(uAmountToBigNumberAmount(uAmount, asset.decimals));
|
|
3305
|
-
};
|
|
3411
|
+
}, [usdPricesMap, assetsMap]);
|
|
3412
|
+
const compareValues = (0, import_react10.useCallback)((a, b) => {
|
|
3413
|
+
var _a2;
|
|
3414
|
+
let aValue = (0, import_bignumber10.default)(0);
|
|
3415
|
+
const aPrice = usdPricesMap.get(a.denom);
|
|
3416
|
+
if (aPrice) {
|
|
3417
|
+
aValue = aPrice.multipliedBy(a.amount);
|
|
3418
|
+
}
|
|
3419
|
+
let bValue = (0, import_bignumber10.default)(0);
|
|
3420
|
+
const bPrice = usdPricesMap.get(b.denom);
|
|
3421
|
+
if (bPrice) {
|
|
3422
|
+
bValue = bPrice.multipliedBy(b.amount);
|
|
3423
|
+
}
|
|
3424
|
+
return (_a2 = aValue.comparedTo(bValue)) != null ? _a2 : 0;
|
|
3425
|
+
}, [usdPricesMap]);
|
|
3306
3426
|
return {
|
|
3307
3427
|
totalUsdValue,
|
|
3308
3428
|
denomUsdValue,
|
|
3309
|
-
|
|
3429
|
+
compareValues,
|
|
3430
|
+
isLoading: isLoadingPrices
|
|
3310
3431
|
};
|
|
3311
3432
|
}
|
|
3312
3433
|
|
|
@@ -3348,51 +3469,106 @@ function useFeeTokens() {
|
|
|
3348
3469
|
|
|
3349
3470
|
// src/hooks/useMarkets.ts
|
|
3350
3471
|
var import_react12 = require("react");
|
|
3472
|
+
var import_bignumber11 = __toESM(require("bignumber.js"));
|
|
3351
3473
|
function useMarkets() {
|
|
3352
3474
|
const { marketsMap, marketsDataMap, updateMarkets, isLoading } = useAssetsContext();
|
|
3353
3475
|
const markets = (0, import_react12.useMemo)(() => {
|
|
3354
3476
|
return Array.from(marketsMap.values());
|
|
3355
3477
|
}, [marketsMap]);
|
|
3478
|
+
const marketsData = (0, import_react12.useMemo)(() => Array.from(marketsDataMap.values()), [marketsDataMap]);
|
|
3479
|
+
const marketExists = (0, import_react12.useCallback)((marketId) => marketsMap.has(marketId), [marketsMap]);
|
|
3480
|
+
const getMarketData = (0, import_react12.useCallback)((marketId) => marketsDataMap.get(marketId), [marketsDataMap]);
|
|
3481
|
+
const getMarket = (0, import_react12.useCallback)((marketId) => marketsMap.get(marketId), [marketsMap]);
|
|
3356
3482
|
return {
|
|
3357
3483
|
markets,
|
|
3484
|
+
marketsData,
|
|
3358
3485
|
marketsMap,
|
|
3359
3486
|
marketsDataMap,
|
|
3360
3487
|
isLoading,
|
|
3361
|
-
updateMarkets
|
|
3488
|
+
updateMarkets,
|
|
3489
|
+
marketExists,
|
|
3490
|
+
getMarketData,
|
|
3491
|
+
getMarket
|
|
3362
3492
|
};
|
|
3363
3493
|
}
|
|
3364
3494
|
function useAssetMarkets(denom) {
|
|
3365
|
-
const { marketsMap } = useAssetsContext();
|
|
3495
|
+
const { isLoading, marketsMap, marketsDataMap } = useAssetsContext();
|
|
3496
|
+
const markets = (0, import_react12.useMemo)(() => Array.from(marketsMap.values()), [marketsMap]);
|
|
3497
|
+
const marketsData = (0, import_react12.useMemo)(() => Array.from(marketsDataMap.values()), [marketsDataMap]);
|
|
3366
3498
|
const assetMarkets = (0, import_react12.useMemo)(() => {
|
|
3367
|
-
|
|
3368
|
-
|
|
3369
|
-
)
|
|
3370
|
-
|
|
3499
|
+
const baseMatches = [];
|
|
3500
|
+
const quoteMatches = [];
|
|
3501
|
+
for (const market of markets) {
|
|
3502
|
+
if (market.base === denom) baseMatches.push(market);
|
|
3503
|
+
else if (market.quote === denom) quoteMatches.push(market);
|
|
3504
|
+
}
|
|
3505
|
+
return [...baseMatches, ...quoteMatches];
|
|
3506
|
+
}, [markets, denom]);
|
|
3507
|
+
const assetMarketsData = (0, import_react12.useMemo)(() => {
|
|
3508
|
+
const baseMatches = [];
|
|
3509
|
+
const quoteMatches = [];
|
|
3510
|
+
for (const market of marketsData) {
|
|
3511
|
+
if (market.base === denom) baseMatches.push(market);
|
|
3512
|
+
else if (market.quote === denom) quoteMatches.push(market);
|
|
3513
|
+
}
|
|
3514
|
+
return [...baseMatches, ...quoteMatches];
|
|
3515
|
+
}, [marketsData, denom]);
|
|
3516
|
+
const asset24hTradedVolume = (0, import_react12.useMemo)(() => {
|
|
3517
|
+
return assetMarketsData.reduce((acc, market) => {
|
|
3518
|
+
if (denom === market.base) {
|
|
3519
|
+
return acc.plus(market.base_volume || 0);
|
|
3520
|
+
} else if (denom === market.quote) {
|
|
3521
|
+
return acc.plus(market.quote_volume || 0);
|
|
3522
|
+
}
|
|
3523
|
+
return acc;
|
|
3524
|
+
}, new import_bignumber11.default(0));
|
|
3525
|
+
}, [assetMarketsData, denom]);
|
|
3371
3526
|
return {
|
|
3372
|
-
|
|
3527
|
+
isLoading,
|
|
3528
|
+
assetMarkets,
|
|
3529
|
+
assetMarketsData,
|
|
3530
|
+
asset24hTradedVolume
|
|
3373
3531
|
};
|
|
3374
3532
|
}
|
|
3375
|
-
function useMarket(
|
|
3376
|
-
const { marketsMap, marketsDataMap,
|
|
3377
|
-
const
|
|
3378
|
-
const
|
|
3379
|
-
|
|
3380
|
-
|
|
3381
|
-
|
|
3382
|
-
|
|
3383
|
-
|
|
3533
|
+
function useMarket(marketId) {
|
|
3534
|
+
const { marketsMap, marketsDataMap, isLoading, assetsMap } = useAssetsContext();
|
|
3535
|
+
const market = (0, import_react12.useMemo)(() => marketsMap.get(marketId), [marketsMap, marketId]);
|
|
3536
|
+
const marketSymbol = (0, import_react12.useMemo)(() => {
|
|
3537
|
+
var _a2, _b2;
|
|
3538
|
+
if (isLoading) return "";
|
|
3539
|
+
if (!market) return "";
|
|
3540
|
+
let base = (_a2 = assetsMap.get(market.base)) == null ? void 0 : _a2.ticker;
|
|
3541
|
+
if (!base) {
|
|
3542
|
+
base = truncateDenom(market.base);
|
|
3543
|
+
}
|
|
3544
|
+
let quote = (_b2 = assetsMap.get(market.quote)) == null ? void 0 : _b2.ticker;
|
|
3545
|
+
if (!quote) {
|
|
3546
|
+
quote = truncateDenom(market.quote);
|
|
3547
|
+
}
|
|
3548
|
+
return `${base}/${quote}`;
|
|
3549
|
+
}, [market, isLoading, assetsMap]);
|
|
3550
|
+
const marketData = (0, import_react12.useMemo)(() => marketsDataMap.get(marketId), [marketsDataMap, marketId]);
|
|
3384
3551
|
const marketExists = (0, import_react12.useMemo)(() => !!market, [market]);
|
|
3385
3552
|
const volume24h = (0, import_react12.useMemo)(() => {
|
|
3386
|
-
if (!marketData) return toBigNumber(0);
|
|
3387
|
-
const quoteAsset = assetsMap.get(quote);
|
|
3553
|
+
if (!marketData || !market) return toBigNumber(0);
|
|
3554
|
+
const quoteAsset = assetsMap.get(market.quote);
|
|
3388
3555
|
if (!quoteAsset) return toBigNumber(0);
|
|
3389
3556
|
return uAmountToBigNumberAmount(toBigNumber(marketData.quote_volume), quoteAsset.decimals);
|
|
3390
|
-
}, [marketData, assetsMap,
|
|
3557
|
+
}, [marketData, assetsMap, market]);
|
|
3391
3558
|
return {
|
|
3559
|
+
isLoading,
|
|
3392
3560
|
market,
|
|
3393
3561
|
marketData,
|
|
3562
|
+
marketSymbol,
|
|
3563
|
+
marketId,
|
|
3394
3564
|
marketExists,
|
|
3395
|
-
volume24h
|
|
3565
|
+
volume24h
|
|
3566
|
+
};
|
|
3567
|
+
}
|
|
3568
|
+
function useMarketsManager() {
|
|
3569
|
+
const { updateMarkets, isLoading } = useAssetsContext();
|
|
3570
|
+
return {
|
|
3571
|
+
updateMarkets,
|
|
3396
3572
|
isLoading
|
|
3397
3573
|
};
|
|
3398
3574
|
}
|
|
@@ -3496,7 +3672,7 @@ var useToast = () => {
|
|
|
3496
3672
|
// src/hooks/useTx.tsx
|
|
3497
3673
|
var import_stargate = require("@cosmjs/stargate");
|
|
3498
3674
|
var import_react15 = require("@interchain-kit/react");
|
|
3499
|
-
var
|
|
3675
|
+
var import_bignumber12 = __toESM(require("bignumber.js"));
|
|
3500
3676
|
var import_react16 = require("react");
|
|
3501
3677
|
var TxStatus = /* @__PURE__ */ ((TxStatus2) => {
|
|
3502
3678
|
TxStatus2["Failed"] = "Transaction Failed";
|
|
@@ -3548,7 +3724,7 @@ var useTx = (chainName, isCosmos, isIBC) => {
|
|
|
3548
3724
|
const gasPrice = 0.02;
|
|
3549
3725
|
const nativeDenom = getChainNativeAssetDenom();
|
|
3550
3726
|
const gasEstimated = await signingClient.simulate(address, messages, memo);
|
|
3551
|
-
const gasAmount = (0,
|
|
3727
|
+
const gasAmount = (0, import_bignumber12.default)(gasEstimated).multipliedBy(1.5);
|
|
3552
3728
|
const gasPayment = gasAmount.multipliedBy(gasPrice);
|
|
3553
3729
|
const nativeFee = {
|
|
3554
3730
|
amount: (0, import_stargate.coins)(gasPayment.toFixed(0).toString(), nativeDenom),
|
|
@@ -3565,9 +3741,9 @@ var useTx = (chainName, isCosmos, isIBC) => {
|
|
|
3565
3741
|
if (!expectedAmount.isPositive()) {
|
|
3566
3742
|
return nativeFee;
|
|
3567
3743
|
}
|
|
3568
|
-
expectedAmount = expectedAmount.multipliedBy(1.5).integerValue(
|
|
3744
|
+
expectedAmount = expectedAmount.multipliedBy(1.5).integerValue(import_bignumber12.default.ROUND_FLOOR);
|
|
3569
3745
|
if (expectedAmount.multipliedBy(pool.fee).lt(1)) {
|
|
3570
|
-
expectedAmount = toBigNumber(1).dividedBy(pool.fee).integerValue(
|
|
3746
|
+
expectedAmount = toBigNumber(1).dividedBy(pool.fee).integerValue(import_bignumber12.default.ROUND_CEIL);
|
|
3571
3747
|
}
|
|
3572
3748
|
return {
|
|
3573
3749
|
amount: (0, import_stargate.coins)(expectedAmount.toFixed(0).toString(), feeDenom),
|
|
@@ -4088,13 +4264,13 @@ var import_react25 = require("@chakra-ui/react");
|
|
|
4088
4264
|
var import_lu3 = require("react-icons/lu");
|
|
4089
4265
|
var import_react26 = require("react");
|
|
4090
4266
|
var import_core = require("@interchain-kit/core");
|
|
4091
|
-
var
|
|
4267
|
+
var import_bignumber13 = __toESM(require("bignumber.js"));
|
|
4092
4268
|
var import_bzejs5 = require("@bze/bzejs");
|
|
4093
4269
|
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
4094
4270
|
var validateAmount = (amount, coin, onError) => {
|
|
4095
4271
|
if (!coin) return;
|
|
4096
4272
|
if (amount === "") return;
|
|
4097
|
-
const amountNumber = (0,
|
|
4273
|
+
const amountNumber = (0, import_bignumber13.default)(amount);
|
|
4098
4274
|
if (amountNumber.isNaN()) {
|
|
4099
4275
|
onError("Invalid amount");
|
|
4100
4276
|
return;
|
|
@@ -4873,9 +5049,11 @@ function SettingsToggle({ accentColor }) {
|
|
|
4873
5049
|
useFeeTokens,
|
|
4874
5050
|
useIBCChains,
|
|
4875
5051
|
useIBCTx,
|
|
5052
|
+
useLiquidityPool,
|
|
4876
5053
|
useLiquidityPools,
|
|
4877
5054
|
useMarket,
|
|
4878
5055
|
useMarkets,
|
|
5056
|
+
useMarketsManager,
|
|
4879
5057
|
useSDKTx,
|
|
4880
5058
|
useSettings,
|
|
4881
5059
|
useSigningClient,
|