From c8622611dc1ae54b144ba23c7293c6411b061d3b Mon Sep 17 00:00:00 2001 From: bearpong <178402093+bearpong@users.noreply.github.com> Date: Mon, 16 Sep 2024 17:14:08 +0200 Subject: [PATCH 1/4] refactor: moved token hooks to subfolder --- packages/berajs/src/hooks/index.ts | 22 +++++++++---------- .../src/hooks/{ => modules/perps}/useTpsl.ts | 2 +- .../hooks/{ => tokens}/usePollAllowance.ts | 0 .../hooks/{ => tokens}/usePollAllowances.ts | 2 +- .../src/hooks/{ => tokens}/usePollBalance.ts | 2 +- .../hooks/{ => tokens}/usePollBeraBalance.ts | 0 .../{ => tokens}/usePollWalletBalances.ts | 6 ++--- .../useSubgraphTokenInformation.ts | 2 +- .../useSubgraphTokenInformations.ts | 2 +- .../hooks/{ => tokens}/useTokenHoneyPrice.ts | 2 +- .../hooks/{ => tokens}/useTokenHoneyPrices.ts | 2 +- .../hooks/{ => tokens}/useTokenInformation.ts | 4 ++-- 12 files changed, 23 insertions(+), 23 deletions(-) rename packages/berajs/src/hooks/{ => modules/perps}/useTpsl.ts (99%) rename packages/berajs/src/hooks/{ => tokens}/usePollAllowance.ts (100%) rename packages/berajs/src/hooks/{ => tokens}/usePollAllowances.ts (97%) rename packages/berajs/src/hooks/{ => tokens}/usePollBalance.ts (98%) rename packages/berajs/src/hooks/{ => tokens}/usePollBeraBalance.ts (100%) rename packages/berajs/src/hooks/{ => tokens}/usePollWalletBalances.ts (95%) rename packages/berajs/src/hooks/{ => tokens}/useSubgraphTokenInformation.ts (96%) rename packages/berajs/src/hooks/{ => tokens}/useSubgraphTokenInformations.ts (97%) rename packages/berajs/src/hooks/{ => tokens}/useTokenHoneyPrice.ts (96%) rename packages/berajs/src/hooks/{ => tokens}/useTokenHoneyPrices.ts (96%) rename packages/berajs/src/hooks/{ => tokens}/useTokenInformation.ts (95%) diff --git a/packages/berajs/src/hooks/index.ts b/packages/berajs/src/hooks/index.ts index 046449677..e9ae773cf 100755 --- a/packages/berajs/src/hooks/index.ts +++ b/packages/berajs/src/hooks/index.ts @@ -1,25 +1,25 @@ -export * from "./useTokenInformation"; +export * from "./tokens/useTokenInformation"; export * from "./useTokens"; export * from "./useChainId"; -export * from "./usePollAllowances"; +export * from "./tokens/usePollAllowances"; export * from "./useContractWrite"; export * from "./transactions"; export * from "./modules"; -export * from "./usePollBalance"; -export * from "./usePollAllowance"; +export * from "./tokens/usePollBalance"; +export * from "./tokens/usePollAllowance"; export * from "./useOct"; -export * from "./usePollBeraBalance"; +export * from "./tokens/usePollBeraBalance"; export * from "./usePollTransactionCount"; export * from "./useGasData"; -export * from "./useTokenHoneyPrice"; -export * from "./useTokenHoneyPrices"; -export * from "./usePollWalletBalances"; +export * from "./tokens/useTokenHoneyPrice"; +export * from "./tokens/useTokenHoneyPrices"; +export * from "./tokens/usePollWalletBalances"; export * from "./usePollEstimateFeesPerGas"; -export * from "./useSubgraphTokenInformation"; -export * from "./useSubgraphTokenInformations"; +export * from "./tokens/useSubgraphTokenInformation"; +export * from "./tokens/useSubgraphTokenInformations"; export * from "./useValidatorList"; export * from "./useGaugesMetadata"; -export * from "./useTpsl"; +export * from "./modules/perps/useTpsl"; export * from "./usePrevious"; export * from "./useInterval"; export * from "./useGetVerifiedAbi"; diff --git a/packages/berajs/src/hooks/useTpsl.ts b/packages/berajs/src/hooks/modules/perps/useTpsl.ts similarity index 99% rename from packages/berajs/src/hooks/useTpsl.ts rename to packages/berajs/src/hooks/modules/perps/useTpsl.ts index e8137a0dd..50092a6b1 100644 --- a/packages/berajs/src/hooks/useTpsl.ts +++ b/packages/berajs/src/hooks/modules/perps/useTpsl.ts @@ -1,6 +1,6 @@ import BigNumber from "bignumber.js"; import { useCallback, useEffect, useState } from "react"; -import { usePrevious } from "./usePrevious"; +import { usePrevious } from "../../usePrevious"; function atLeastZero(value: string | BigNumber): string { return BigNumber(value).lt(0) ? "0" : value.toString(10); diff --git a/packages/berajs/src/hooks/usePollAllowance.ts b/packages/berajs/src/hooks/tokens/usePollAllowance.ts similarity index 100% rename from packages/berajs/src/hooks/usePollAllowance.ts rename to packages/berajs/src/hooks/tokens/usePollAllowance.ts diff --git a/packages/berajs/src/hooks/usePollAllowances.ts b/packages/berajs/src/hooks/tokens/usePollAllowances.ts similarity index 97% rename from packages/berajs/src/hooks/usePollAllowances.ts rename to packages/berajs/src/hooks/tokens/usePollAllowances.ts index 629f14c63..919740695 100755 --- a/packages/berajs/src/hooks/usePollAllowances.ts +++ b/packages/berajs/src/hooks/tokens/usePollAllowances.ts @@ -10,7 +10,7 @@ import { DefaultHookOptions, DefaultHookReturnType, } from "~/types/global"; -import { getAllowances } from "../actions/dex"; +import { getAllowances } from "../../actions/dex"; export type UsePollAllowancesArgs = { spender: string; diff --git a/packages/berajs/src/hooks/usePollBalance.ts b/packages/berajs/src/hooks/tokens/usePollBalance.ts similarity index 98% rename from packages/berajs/src/hooks/usePollBalance.ts rename to packages/berajs/src/hooks/tokens/usePollBalance.ts index 93b5b6dd9..f4ad8b022 100755 --- a/packages/berajs/src/hooks/usePollBalance.ts +++ b/packages/berajs/src/hooks/tokens/usePollBalance.ts @@ -6,7 +6,7 @@ import { usePublicClient } from "wagmi"; import { multicall3Abi } from "~/abi"; import POLLING from "~/enum/polling"; -import { useBeraJs } from "../contexts"; +import { useBeraJs } from "../../contexts"; import { BalanceToken } from "~/types/dex"; import { DefaultHookReturnType } from ".."; diff --git a/packages/berajs/src/hooks/usePollBeraBalance.ts b/packages/berajs/src/hooks/tokens/usePollBeraBalance.ts similarity index 100% rename from packages/berajs/src/hooks/usePollBeraBalance.ts rename to packages/berajs/src/hooks/tokens/usePollBeraBalance.ts diff --git a/packages/berajs/src/hooks/usePollWalletBalances.ts b/packages/berajs/src/hooks/tokens/usePollWalletBalances.ts similarity index 95% rename from packages/berajs/src/hooks/usePollWalletBalances.ts rename to packages/berajs/src/hooks/tokens/usePollWalletBalances.ts index a98cbe4a3..f9fd5fa8e 100755 --- a/packages/berajs/src/hooks/usePollWalletBalances.ts +++ b/packages/berajs/src/hooks/tokens/usePollWalletBalances.ts @@ -9,9 +9,9 @@ import { DefaultHookOptions, DefaultHookReturnType, type Token, -} from ".."; -import { useBeraJs } from "../contexts"; -import { useTokens } from "./useTokens"; +} from "../.."; +import { useBeraJs } from "../../contexts"; +import { useTokens } from "../useTokens"; export type UsePollWalletBalancesArgs = { externalTokenList?: Token[]; diff --git a/packages/berajs/src/hooks/useSubgraphTokenInformation.ts b/packages/berajs/src/hooks/tokens/useSubgraphTokenInformation.ts similarity index 96% rename from packages/berajs/src/hooks/useSubgraphTokenInformation.ts rename to packages/berajs/src/hooks/tokens/useSubgraphTokenInformation.ts index 08b65c834..3e1b1acdb 100644 --- a/packages/berajs/src/hooks/useSubgraphTokenInformation.ts +++ b/packages/berajs/src/hooks/tokens/useSubgraphTokenInformation.ts @@ -3,7 +3,7 @@ import useSWR, { mutate } from "swr"; import { getTokenHoneyPrice } from "~/actions/honey"; import POLLING from "~/enum/polling"; import { DefaultHookOptions, DefaultHookReturnType } from "~/types/global"; -import { Token, useBeraJs } from ".."; +import { Token, useBeraJs } from "../.."; import { getSubgraphTokenInformation } from "~/actions/shared/getSubgraphTokenInformation"; /** diff --git a/packages/berajs/src/hooks/useSubgraphTokenInformations.ts b/packages/berajs/src/hooks/tokens/useSubgraphTokenInformations.ts similarity index 97% rename from packages/berajs/src/hooks/useSubgraphTokenInformations.ts rename to packages/berajs/src/hooks/tokens/useSubgraphTokenInformations.ts index 8791f6592..0e4c7ee6c 100644 --- a/packages/berajs/src/hooks/useSubgraphTokenInformations.ts +++ b/packages/berajs/src/hooks/tokens/useSubgraphTokenInformations.ts @@ -2,7 +2,7 @@ import useSWR, { mutate } from "swr"; import POLLING from "~/enum/polling"; import { DefaultHookOptions, DefaultHookReturnType } from "~/types/global"; -import { useBeraJs } from ".."; +import { useBeraJs } from "../.."; import { getSubgraphTokenInformations, SubgraphTokenInformations, diff --git a/packages/berajs/src/hooks/useTokenHoneyPrice.ts b/packages/berajs/src/hooks/tokens/useTokenHoneyPrice.ts similarity index 96% rename from packages/berajs/src/hooks/useTokenHoneyPrice.ts rename to packages/berajs/src/hooks/tokens/useTokenHoneyPrice.ts index f3fb89f26..224fcf961 100755 --- a/packages/berajs/src/hooks/useTokenHoneyPrice.ts +++ b/packages/berajs/src/hooks/tokens/useTokenHoneyPrice.ts @@ -3,7 +3,7 @@ import useSWR, { mutate } from "swr"; import { getTokenHoneyPrice } from "~/actions/honey"; import POLLING from "~/enum/polling"; import { DefaultHookOptions, DefaultHookReturnType } from "~/types/global"; -import { useBeraJs } from ".."; +import { useBeraJs } from "../.."; /** * diff --git a/packages/berajs/src/hooks/useTokenHoneyPrices.ts b/packages/berajs/src/hooks/tokens/useTokenHoneyPrices.ts similarity index 96% rename from packages/berajs/src/hooks/useTokenHoneyPrices.ts rename to packages/berajs/src/hooks/tokens/useTokenHoneyPrices.ts index 7c04b2d9a..a0c200eed 100755 --- a/packages/berajs/src/hooks/useTokenHoneyPrices.ts +++ b/packages/berajs/src/hooks/tokens/useTokenHoneyPrices.ts @@ -3,7 +3,7 @@ import useSWR, { mutate } from "swr"; import { TokenHoneyPrices, getTokenHoneyPrices } from "~/actions/honey"; import POLLING from "~/enum/polling"; import { DefaultHookOptions, DefaultHookReturnType } from "~/types/global"; -import { useBeraJs } from ".."; +import { useBeraJs } from "../.."; /** * diff --git a/packages/berajs/src/hooks/useTokenInformation.ts b/packages/berajs/src/hooks/tokens/useTokenInformation.ts similarity index 95% rename from packages/berajs/src/hooks/useTokenInformation.ts rename to packages/berajs/src/hooks/tokens/useTokenInformation.ts index 591cf688a..5f8e473db 100755 --- a/packages/berajs/src/hooks/useTokenInformation.ts +++ b/packages/berajs/src/hooks/tokens/useTokenInformation.ts @@ -1,5 +1,5 @@ import useSWRImmutable from "swr/immutable"; -import { Address, isAddress } from "viem"; +import { isAddress } from "viem"; import { usePublicClient } from "wagmi"; import { getTokenInformation } from "~/actions"; @@ -8,7 +8,7 @@ import { DefaultHookReturnType, Token, useBeraJs, -} from ".."; +} from "../.."; export type UseTokenInformationResponse = DefaultHookReturnType< Token | undefined From 051849f79206a4e87ee5d887f96484d04ef9b57c Mon Sep 17 00:00:00 2001 From: bearpong <178402093+bearpong@users.noreply.github.com> Date: Mon, 16 Sep 2024 18:01:33 +0200 Subject: [PATCH 2/4] perf: use immutable query for token information when fetching balace --- .../berajs/src/hooks/tokens/usePollBalance.ts | 134 +++++++----------- .../src/hooks/tokens/useTokenInformation.ts | 6 + 2 files changed, 59 insertions(+), 81 deletions(-) diff --git a/packages/berajs/src/hooks/tokens/usePollBalance.ts b/packages/berajs/src/hooks/tokens/usePollBalance.ts index f4ad8b022..5eabd1005 100755 --- a/packages/berajs/src/hooks/tokens/usePollBalance.ts +++ b/packages/berajs/src/hooks/tokens/usePollBalance.ts @@ -1,29 +1,26 @@ -import { multicallAddress, nativeTokenAddress } from "@bera/config"; +import { + gasTokenDecimals, + gasTokenName, + gasTokenSymbol, + nativeTokenAddress, +} from "@bera/config"; import useSWR from "swr"; -import useSWRImmutable from "swr/immutable"; -import { erc20Abi, formatEther, formatUnits, getAddress } from "viem"; +import { Address, erc20Abi, formatEther, formatUnits } from "viem"; import { usePublicClient } from "wagmi"; -import { multicall3Abi } from "~/abi"; import POLLING from "~/enum/polling"; -import { useBeraJs } from "../../contexts"; +import { DefaultHookReturnType } from "~/types"; import { BalanceToken } from "~/types/dex"; -import { DefaultHookReturnType } from ".."; - -interface Call { - abi: typeof erc20Abi; - address: `0x${string}`; - functionName: string; - args: any[]; -} +import { useBeraJs } from "../../contexts"; +import { useTokenInformation } from "./useTokenInformation"; export const usePollBalance = ({ address, owner, }: { address: string | undefined; - owner?: string | undefined; -}): DefaultHookReturnType & { + owner?: Address | undefined; +}): Omit, "mutate"> & { /** * * @deprecated you can use data instead @@ -35,75 +32,28 @@ export const usePollBalance = ({ const assetOwner = owner ?? account; const QUERY_KEY = - publicClient && address ? [assetOwner, address, "balance"] : null; + publicClient && assetOwner ? [assetOwner, address, "balance"] : null; + const { data: tokenInformation, isLoading: isLoadingTokenInformation } = + useTokenInformation({ address }); + + const isNativeToken = address === nativeTokenAddress; - // TODO: it would be better if we used useSWRImmutable here for token info, and a dynamic query for balance - const { isLoading, data, ...rest } = useSWR( + const { isLoading, data, error, ...rest } = useSWR( QUERY_KEY, async () => { if (!publicClient) return undefined; if (assetOwner && address) { if (address !== nativeTokenAddress) { - const call: Call[] = [ - { - address: address as `0x${string}`, - abi: erc20Abi, - functionName: "balanceOf", - args: [assetOwner], - }, - { - address: address as `0x${string}`, - abi: erc20Abi, - functionName: "symbol", - args: [], - }, - { - address: address as `0x${string}`, - abi: erc20Abi, - functionName: "name", - args: [], - }, - { - address: address as `0x${string}`, - abi: erc20Abi, - functionName: "decimals", - args: [], - }, - ]; - const result = await publicClient.multicall({ - contracts: call, - multicallAddress: multicallAddress, - allowFailure: false, + return await publicClient.readContract({ + address: address as `0x${string}`, + abi: erc20Abi, + functionName: "balanceOf", + args: [assetOwner!], }); - - const balance: BalanceToken = { - balance: result[0] as bigint, - formattedBalance: formatUnits( - result[0] as bigint, - (result[3] as number) ?? 18, - ), - address: getAddress(address), - decimals: result[3] as number, - symbol: result[1] as string, - name: result[2] as string, - }; - return balance; } - const call = { - address: multicallAddress, - abi: multicall3Abi, - functionName: "getEthBalance", - args: [assetOwner], - }; - const result = await publicClient.readContract(call); - return { - balance: result as bigint, - formattedBalance: formatEther((result as bigint) ?? 0n), - address, - decimals: 18, - symbol: "BERA", - name: "Berachain", - } satisfies BalanceToken; + return await publicClient.getBalance({ + address: assetOwner!, + }); } return undefined; }, @@ -112,16 +62,38 @@ export const usePollBalance = ({ }, ); + const formattedBalance = + !error && data + ? address === nativeTokenAddress + ? formatEther(data as bigint) + : tokenInformation && !isLoadingTokenInformation + ? formatUnits(data, tokenInformation.decimals) + : undefined + : undefined; + + const tokenBalance = { + balance: data ?? 0n, + formattedBalance: formattedBalance ?? "0", + address: address as `0x${string}`, + decimals: isNativeToken + ? gasTokenDecimals + : tokenInformation?.decimals ?? 0, + symbol: isNativeToken ? gasTokenSymbol : tokenInformation?.symbol ?? "", + name: isNativeToken ? gasTokenName : tokenInformation?.name ?? "", + } satisfies BalanceToken; + const useBalance = () => { - const { data = undefined } = useSWRImmutable(QUERY_KEY); - return data; + return tokenBalance; }; return { ...rest, - isLoading, - data, - refresh: () => rest.mutate(), + refresh: () => { + rest.mutate(); + }, + isLoading: isLoading || isNativeToken ? isLoadingTokenInformation : false, + error: error || !isNativeToken ? error : undefined, + data: tokenBalance, useBalance, }; }; diff --git a/packages/berajs/src/hooks/tokens/useTokenInformation.ts b/packages/berajs/src/hooks/tokens/useTokenInformation.ts index 5f8e473db..901e0f076 100755 --- a/packages/berajs/src/hooks/tokens/useTokenInformation.ts +++ b/packages/berajs/src/hooks/tokens/useTokenInformation.ts @@ -9,6 +9,12 @@ import { Token, useBeraJs, } from "../.."; +import { + gasTokenDecimals, + gasTokenName, + gasTokenSymbol, + nativeTokenAddress, +} from "@bera/config"; export type UseTokenInformationResponse = DefaultHookReturnType< Token | undefined From c5a7706fff7850f827cc8d5c9c76ba73846b5423 Mon Sep 17 00:00:00 2001 From: bearpong <178402093+bearpong@users.noreply.github.com> Date: Sun, 20 Oct 2024 19:56:40 +0200 Subject: [PATCH 3/4] refactor: moved abis to topic subfolders --- .../{ => bend}/lendPoolImplementationAbi.js | 0 .../src/abi/{ => bend}/lendRewardHelperAbi.js | 0 .../abi/{ => bend}/lendUiDataProviderAbi.js | 0 .../berajs/src/abi/{ => bend}/multiswapAbi.js | 0 .../berajs/src/abi/{ => berps}/bTokenAbi.ts | 0 .../src/abi/{ => berps}/berpsErrorsAbi.ts | 0 .../src/abi/{ => berps}/borrowingAbi.ts | 0 .../berajs/src/abi/{ => berps}/pythAbi.ts | 0 .../src/abi/{ => berps}/pythErrorsAbi.ts | 0 .../src/abi/{ => berps}/referralsAbi.ts | 0 .../berajs/src/abi/{ => berps}/tradingAbi.ts | 0 .../src/abi/{ => bex}/balancerVaultAbi.ts | 0 packages/berajs/src/abi/{ => bex}/wberaAbi.js | 0 packages/berajs/src/abi/epochs.ts | 34 -------------- .../{ => governance}/governance-timelock.ts | 0 .../src/abi/{ => governance}/governance.ts | 0 .../src/abi/{ => honey}/honeyRouterAbi.js | 0 packages/berajs/src/abi/index.ts | 47 +++++++++---------- .../src/abi/{ => misc}/multicall3Abi.js | 0 packages/berajs/src/abi/{ => pol}/beraChef.ts | 0 packages/berajs/src/abi/{ => pol}/bgt.ts | 0 .../abi/{bgtStaker.js => pol/bgtStaker.ts} | 2 +- .../src/abi/{vault.ts => pol/reward-vault.ts} | 0 packages/berajs/src/abi/{ => pol}/rewards.js | 0 packages/berajs/src/abi/{ => pol}/staking.js | 0 25 files changed, 24 insertions(+), 59 deletions(-) rename packages/berajs/src/abi/{ => bend}/lendPoolImplementationAbi.js (100%) rename packages/berajs/src/abi/{ => bend}/lendRewardHelperAbi.js (100%) rename packages/berajs/src/abi/{ => bend}/lendUiDataProviderAbi.js (100%) rename packages/berajs/src/abi/{ => bend}/multiswapAbi.js (100%) rename packages/berajs/src/abi/{ => berps}/bTokenAbi.ts (100%) rename packages/berajs/src/abi/{ => berps}/berpsErrorsAbi.ts (100%) rename packages/berajs/src/abi/{ => berps}/borrowingAbi.ts (100%) rename packages/berajs/src/abi/{ => berps}/pythAbi.ts (100%) rename packages/berajs/src/abi/{ => berps}/pythErrorsAbi.ts (100%) rename packages/berajs/src/abi/{ => berps}/referralsAbi.ts (100%) rename packages/berajs/src/abi/{ => berps}/tradingAbi.ts (100%) rename packages/berajs/src/abi/{ => bex}/balancerVaultAbi.ts (100%) rename packages/berajs/src/abi/{ => bex}/wberaAbi.js (100%) delete mode 100755 packages/berajs/src/abi/epochs.ts rename packages/berajs/src/abi/{ => governance}/governance-timelock.ts (100%) rename packages/berajs/src/abi/{ => governance}/governance.ts (100%) rename packages/berajs/src/abi/{ => honey}/honeyRouterAbi.js (100%) rename packages/berajs/src/abi/{ => misc}/multicall3Abi.js (100%) rename packages/berajs/src/abi/{ => pol}/beraChef.ts (100%) rename packages/berajs/src/abi/{ => pol}/bgt.ts (100%) rename packages/berajs/src/abi/{bgtStaker.js => pol/bgtStaker.ts} (99%) rename packages/berajs/src/abi/{vault.ts => pol/reward-vault.ts} (100%) rename packages/berajs/src/abi/{ => pol}/rewards.js (100%) rename packages/berajs/src/abi/{ => pol}/staking.js (100%) diff --git a/packages/berajs/src/abi/lendPoolImplementationAbi.js b/packages/berajs/src/abi/bend/lendPoolImplementationAbi.js similarity index 100% rename from packages/berajs/src/abi/lendPoolImplementationAbi.js rename to packages/berajs/src/abi/bend/lendPoolImplementationAbi.js diff --git a/packages/berajs/src/abi/lendRewardHelperAbi.js b/packages/berajs/src/abi/bend/lendRewardHelperAbi.js similarity index 100% rename from packages/berajs/src/abi/lendRewardHelperAbi.js rename to packages/berajs/src/abi/bend/lendRewardHelperAbi.js diff --git a/packages/berajs/src/abi/lendUiDataProviderAbi.js b/packages/berajs/src/abi/bend/lendUiDataProviderAbi.js similarity index 100% rename from packages/berajs/src/abi/lendUiDataProviderAbi.js rename to packages/berajs/src/abi/bend/lendUiDataProviderAbi.js diff --git a/packages/berajs/src/abi/multiswapAbi.js b/packages/berajs/src/abi/bend/multiswapAbi.js similarity index 100% rename from packages/berajs/src/abi/multiswapAbi.js rename to packages/berajs/src/abi/bend/multiswapAbi.js diff --git a/packages/berajs/src/abi/bTokenAbi.ts b/packages/berajs/src/abi/berps/bTokenAbi.ts similarity index 100% rename from packages/berajs/src/abi/bTokenAbi.ts rename to packages/berajs/src/abi/berps/bTokenAbi.ts diff --git a/packages/berajs/src/abi/berpsErrorsAbi.ts b/packages/berajs/src/abi/berps/berpsErrorsAbi.ts similarity index 100% rename from packages/berajs/src/abi/berpsErrorsAbi.ts rename to packages/berajs/src/abi/berps/berpsErrorsAbi.ts diff --git a/packages/berajs/src/abi/borrowingAbi.ts b/packages/berajs/src/abi/berps/borrowingAbi.ts similarity index 100% rename from packages/berajs/src/abi/borrowingAbi.ts rename to packages/berajs/src/abi/berps/borrowingAbi.ts diff --git a/packages/berajs/src/abi/pythAbi.ts b/packages/berajs/src/abi/berps/pythAbi.ts similarity index 100% rename from packages/berajs/src/abi/pythAbi.ts rename to packages/berajs/src/abi/berps/pythAbi.ts diff --git a/packages/berajs/src/abi/pythErrorsAbi.ts b/packages/berajs/src/abi/berps/pythErrorsAbi.ts similarity index 100% rename from packages/berajs/src/abi/pythErrorsAbi.ts rename to packages/berajs/src/abi/berps/pythErrorsAbi.ts diff --git a/packages/berajs/src/abi/referralsAbi.ts b/packages/berajs/src/abi/berps/referralsAbi.ts similarity index 100% rename from packages/berajs/src/abi/referralsAbi.ts rename to packages/berajs/src/abi/berps/referralsAbi.ts diff --git a/packages/berajs/src/abi/tradingAbi.ts b/packages/berajs/src/abi/berps/tradingAbi.ts similarity index 100% rename from packages/berajs/src/abi/tradingAbi.ts rename to packages/berajs/src/abi/berps/tradingAbi.ts diff --git a/packages/berajs/src/abi/balancerVaultAbi.ts b/packages/berajs/src/abi/bex/balancerVaultAbi.ts similarity index 100% rename from packages/berajs/src/abi/balancerVaultAbi.ts rename to packages/berajs/src/abi/bex/balancerVaultAbi.ts diff --git a/packages/berajs/src/abi/wberaAbi.js b/packages/berajs/src/abi/bex/wberaAbi.js similarity index 100% rename from packages/berajs/src/abi/wberaAbi.js rename to packages/berajs/src/abi/bex/wberaAbi.js diff --git a/packages/berajs/src/abi/epochs.ts b/packages/berajs/src/abi/epochs.ts deleted file mode 100755 index 894d2b325..000000000 --- a/packages/berajs/src/abi/epochs.ts +++ /dev/null @@ -1,34 +0,0 @@ -/** - * @deprecated - */ -export const EPOCHS_PRECOMPILE_ABI = [ - { - inputs: [ - { - internalType: "string", - name: "identifier", - type: "string", - }, - ], - name: "getCurrentEpoch", - outputs: [ - { - internalType: "int64", - name: "epochNumber", - type: "int64", - }, - { - internalType: "int64", - name: "startTimestamp", - type: "int64", - }, - { - internalType: "int64", - name: "endTimestamp", - type: "int64", - }, - ], - stateMutability: "view", - type: "function", - }, -] as const; diff --git a/packages/berajs/src/abi/governance-timelock.ts b/packages/berajs/src/abi/governance/governance-timelock.ts similarity index 100% rename from packages/berajs/src/abi/governance-timelock.ts rename to packages/berajs/src/abi/governance/governance-timelock.ts diff --git a/packages/berajs/src/abi/governance.ts b/packages/berajs/src/abi/governance/governance.ts similarity index 100% rename from packages/berajs/src/abi/governance.ts rename to packages/berajs/src/abi/governance/governance.ts diff --git a/packages/berajs/src/abi/honeyRouterAbi.js b/packages/berajs/src/abi/honey/honeyRouterAbi.js similarity index 100% rename from packages/berajs/src/abi/honeyRouterAbi.js rename to packages/berajs/src/abi/honey/honeyRouterAbi.js diff --git a/packages/berajs/src/abi/index.ts b/packages/berajs/src/abi/index.ts index 3b2783cfe..226e4f46a 100755 --- a/packages/berajs/src/abi/index.ts +++ b/packages/berajs/src/abi/index.ts @@ -1,24 +1,23 @@ -export * from "./staking"; -export * from "./epochs"; -export * from "./bgt"; -export * from "./governance"; -export * from "./governance-timelock"; -export * from "./rewards"; -export * from "./honeyRouterAbi"; -export * from "./multicall3Abi"; -export * from "./wberaAbi"; -export * from "./tradingAbi"; -export * from "./bTokenAbi"; -export * from "./lendPoolImplementationAbi"; -export * from "./lendUiDataProviderAbi"; -export * from "./lendRewardHelperAbi"; -export * from "./multiswapAbi"; -export * from "./referralsAbi"; -export * from "./pythAbi"; -export * from "./vault"; -export * from "./bgtStaker"; -export * from "./borrowingAbi"; -export * from "./berpsErrorsAbi"; -export * from "./pythErrorsAbi"; -export * from "./beraChef"; -export * from "./balancerVaultAbi"; +export * from "./pol/staking"; +export * from "./pol/bgt"; +export * from "./governance/governance"; +export * from "./governance/governance-timelock"; +export * from "./pol/rewards"; +export * from "./honey/honeyRouterAbi"; +export * from "./misc/multicall3Abi"; +export * from "./berps/tradingAbi"; +export * from "./berps/bTokenAbi"; +export * from "./bend/lendPoolImplementationAbi"; +export * from "./bend/lendUiDataProviderAbi"; +export * from "./bend/lendRewardHelperAbi"; +export * from "./bend/multiswapAbi"; +export * from "./berps/referralsAbi"; +export * from "./berps/pythAbi"; +export * from "./pol/reward-vault"; +export * from "./pol/bgtStaker"; +export * from "./berps/borrowingAbi"; +export * from "./berps/berpsErrorsAbi"; +export * from "./berps/pythErrorsAbi"; +export * from "./pol/beraChef"; +export * from "./bex/wberaAbi"; +export * from "./bex/balancerVaultAbi"; diff --git a/packages/berajs/src/abi/multicall3Abi.js b/packages/berajs/src/abi/misc/multicall3Abi.js similarity index 100% rename from packages/berajs/src/abi/multicall3Abi.js rename to packages/berajs/src/abi/misc/multicall3Abi.js diff --git a/packages/berajs/src/abi/beraChef.ts b/packages/berajs/src/abi/pol/beraChef.ts similarity index 100% rename from packages/berajs/src/abi/beraChef.ts rename to packages/berajs/src/abi/pol/beraChef.ts diff --git a/packages/berajs/src/abi/bgt.ts b/packages/berajs/src/abi/pol/bgt.ts similarity index 100% rename from packages/berajs/src/abi/bgt.ts rename to packages/berajs/src/abi/pol/bgt.ts diff --git a/packages/berajs/src/abi/bgtStaker.js b/packages/berajs/src/abi/pol/bgtStaker.ts similarity index 99% rename from packages/berajs/src/abi/bgtStaker.js rename to packages/berajs/src/abi/pol/bgtStaker.ts index da6761a9b..d7329b8f4 100755 --- a/packages/berajs/src/abi/bgtStaker.js +++ b/packages/berajs/src/abi/pol/bgtStaker.ts @@ -456,4 +456,4 @@ export const BGT_STAKER_ABI = [ { type: "error", name: "VaultAlreadyExists", inputs: [] }, { type: "error", name: "WithdrawAmountIsZero", inputs: [] }, { type: "error", name: "ZeroAddress", inputs: [] }, -]; +] as const; diff --git a/packages/berajs/src/abi/vault.ts b/packages/berajs/src/abi/pol/reward-vault.ts similarity index 100% rename from packages/berajs/src/abi/vault.ts rename to packages/berajs/src/abi/pol/reward-vault.ts diff --git a/packages/berajs/src/abi/rewards.js b/packages/berajs/src/abi/pol/rewards.js similarity index 100% rename from packages/berajs/src/abi/rewards.js rename to packages/berajs/src/abi/pol/rewards.js diff --git a/packages/berajs/src/abi/staking.js b/packages/berajs/src/abi/pol/staking.js similarity index 100% rename from packages/berajs/src/abi/staking.js rename to packages/berajs/src/abi/pol/staking.js From b097b6cc7e18792d7522d53324cafe6c6dada298 Mon Sep 17 00:00:00 2001 From: bearpong <178402093+bearpong@users.noreply.github.com> Date: Mon, 4 Nov 2024 10:07:17 +0100 Subject: [PATCH 4/4] ci: restricts ipfs build --- .github/workflows/ipfs-deploy.yml | 10 +++++----- .github/workflows/ipfs-static-build-test.yml | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ipfs-deploy.yml b/.github/workflows/ipfs-deploy.yml index d5ff33395..79237d2d1 100644 --- a/.github/workflows/ipfs-deploy.yml +++ b/.github/workflows/ipfs-deploy.yml @@ -44,13 +44,13 @@ jobs: - name: Build all projects env: NODE_OPTIONS: "--max_old_space_size=8192" - run: NEXT_PUBLIC_HOST="ipfs" pnpm run build --filter='!berajs-docs' --filter='!storybook' --filter='!apps/perp' + run: NEXT_PUBLIC_HOST="ipfs" pnpm run build --filter='packages/*' --filter='apps/hub' --filter='apps/honey' - - name: Deploy Berps - run: cd apps/perp && fleek sites deploy + # - name: Deploy Berps + # run: cd apps/perp && fleek sites deploy - - name: Deploy Bend - run: cd apps/lend && fleek sites deploy + # - name: Deploy Bend + # run: cd apps/lend && fleek sites deploy - name: Deploy Hub run: cd apps/hub && fleek sites deploy diff --git a/.github/workflows/ipfs-static-build-test.yml b/.github/workflows/ipfs-static-build-test.yml index 3a85d6e9d..fc79b2255 100644 --- a/.github/workflows/ipfs-static-build-test.yml +++ b/.github/workflows/ipfs-static-build-test.yml @@ -39,6 +39,6 @@ jobs: PERPS_OCT_KEY: ${{ secrets.PERPS_OCT_KEY }} CHARTING_ACCESS_TOKEN: ${{ secrets.CHARTING_ACCESS_TOKEN }} NODE_OPTIONS: "--max_old_space_size=8192" - run: NEXT_PUBLIC_HOST="ipfs" pnpm run build --filter='!berajs-docs' --filter='!storybook' --filter='!apps/perp' + run: NEXT_PUBLIC_HOST="ipfs" pnpm run build --filter='packages/*' --filter='apps/hub' --filter='apps/honey' \ No newline at end of file