Skip to content

Commit

Permalink
chore: lint 2nd
Browse files Browse the repository at this point in the history
  • Loading branch information
nick134-bit committed Sep 3, 2024
1 parent cf4e883 commit 323347a
Show file tree
Hide file tree
Showing 12 changed files with 30 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useMemo } from 'react'
import { useMutation } from 'react-query'

import { useChain } from '@cosmos-kit/react-lite'
import { PoolEntityType, usePoolFromListQueryById } from 'components/Pages/Trade/Pools/hooks/usePoolsListQuery'
import { PoolEntityType } from 'components/Pages/Trade/Pools/hooks/usePoolsListQuery'
import { ADV_MEMO, ChainId } from 'constants/index'
import { TxRaw } from 'cosmjs-types/cosmos/tx/v1beta1/tx';
import { useClients } from 'hooks/useClients'
Expand Down
2 changes: 1 addition & 1 deletion components/Pages/Trade/Incentivize/hooks/useOpenFlow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export const useOpenFlow = ({ poolId, token, startDate, endDate }: Props) => {
const { signingClient, injectiveSigningClient } = useClients(walletChainName)
const { address } = useChain(walletChainName)
const config: Config = useConfig(network, chainId)
const { data: pool, isLoading } = usePoolFromListQueryById({ poolId })
const { data: pool } = usePoolFromListQueryById({ poolId })
const { onError, onSuccess, onMutate } = useTxStatus({
transactionType: 'Open Flow',
signingClient,
Expand Down
1 change: 0 additions & 1 deletion components/Pages/Trade/Liquidity/Claim.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import { chainState } from 'state/chainState'
import { TxStep } from 'types/common'

import { PoolEntityType } from '../Pools/hooks/usePoolsListQuery'
import { Pool } from '../Pools/types'

const AvailableRewards = ({ totalValue }: { totalValue: string }) => (
<HStack
Expand Down
2 changes: 1 addition & 1 deletion components/Pages/Trade/Liquidity/ManageLiquidity.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import {
PoolEntityTypeWithLiquidity,
useQueryPoolsLiquidity,
} from 'components/Pages/Trade/Pools/hooks/useQueryPoolsLiquidity'
import { ACTIVE_INCENTIVE_NETWORKS, ChainId } from 'constants/networks'
import { ACTIVE_INCENTIVE_NETWORKS } from 'constants/networks'
import { kBg, kBorderRadius } from 'constants/visualComponentConstants'
import { useChainInfos } from 'hooks/useChainInfo'
import { useClients } from 'hooks/useClients'
Expand Down
2 changes: 0 additions & 2 deletions components/Pages/Trade/Liquidity/StakingForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ const StakeForm = ({ pool, isWalletConnected, clearForm, mobile, openView }: Pro
swap_address: swapAddress = null,
lp_token: contract = null,
liquidity = {},
staking_address = null,
} = {},
] = useQueryPoolLiquidity({ poolId: pool.pool_id })

Expand Down Expand Up @@ -95,7 +94,6 @@ const StakeForm = ({ pool, isWalletConnected, clearForm, mobile, openView }: Pro
const tx = useStake({
amount: lp || '0',
contract,
swapAddress,
})

const isInputDisabled = tx?.txStep === TxStep.Posting
Expand Down
2 changes: 1 addition & 1 deletion components/Pages/Trade/Liquidity/hooks/useClaim.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useMemo } from 'react'
import { useMutation } from 'react-query'

import { useChain } from '@cosmos-kit/react-lite'
import { PoolEntityType, usePoolFromListQueryById } from 'components/Pages/Trade/Pools/hooks/usePoolsListQuery'
import { PoolEntityType } from 'components/Pages/Trade/Pools/hooks/usePoolsListQuery'
import { ADV_MEMO, ChainId } from 'constants/index'
import { TxRaw } from 'cosmjs-types/cosmos/tx/v1beta1/tx';
import { useClients } from 'hooks/useClients'
Expand Down
2 changes: 1 addition & 1 deletion components/Pages/Trade/Liquidity/hooks/useClosePosition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useMemo } from 'react'
import { useMutation } from 'react-query'

import { useChain } from '@cosmos-kit/react-lite'
import { PoolEntityType, usePoolFromListQueryById } from 'components/Pages/Trade/Pools/hooks/usePoolsListQuery'
import { PoolEntityType } from 'components/Pages/Trade/Pools/hooks/usePoolsListQuery'
import { ADV_MEMO, ChainId } from 'constants/index'
import { TxRaw } from 'cosmjs-types/cosmos/tx/v1beta1/tx';
import { useClients } from 'hooks/useClients'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useQuery } from 'react-query'

import { CosmWasmClient } from '@cosmjs/cosmwasm-stargate';
import { useChain } from '@cosmos-kit/react-lite'
import { PoolEntityType, TokenInfo, usePoolFromListQueryById } from 'components/Pages/Trade/Pools/hooks/usePoolsListQuery'
import { PoolEntityType, TokenInfo } from 'components/Pages/Trade/Pools/hooks/usePoolsListQuery'
import { useQueryPoolLiquidity } from 'components/Pages/Trade/Pools/hooks/useQueryPoolsLiquidity'
import { PositionState } from 'constants/state'
import dayjs from 'dayjs'
Expand Down
6 changes: 2 additions & 4 deletions components/Pages/Trade/Liquidity/hooks/useStakePosition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,13 @@ import { isNativeToken } from 'services/asset'
import { chainState } from 'state/chainState'
import { protectAgainstNaN } from 'util/conversion/index'

import { TERRA2_BRIBE_MARKETS } from '../../../../../constants'
import { createExecuteMessage } from '../../../../../util/messages'
import { createExecuteMessage } from 'util/messages'
import { useFetchLiquidityAlliances } from './useLiquidityAlliancePositions'
import { useStakeTransaction } from './useStakeTransaction'

interface StakeProps {
amount: string
contract: string
swapAddress: string
}

interface SimulateProps {
Expand All @@ -32,7 +30,7 @@ interface SimulationResult {
simulated: string
}

const useStake = ({ amount, contract, swapAddress }: StakeProps) => {
const useStake = ({ amount, contract }: StakeProps) => {
const { walletChainName } = useRecoilValue(chainState)
const { address } = useChain(walletChainName)
const { signingClient } = useClients(walletChainName)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,14 +121,14 @@ export const useStakeTransaction = ({
onSuccess: async (data: any) => {
setTxState((prev) => ({ ...prev,
step: TxStep.Broadcasting,
hash: data.transactionHash || data?.txHash }))
hash: data?.transactionHash || data?.txHash }))
const chainId = await signingClient.getChainId()
await queryClient.invalidateQueries(['@pool-liquidity', 'multipleTokenBalances', 'tokenBalance', 'positions', 'alliance-positions', 'signingClient'])
onBroadcasting?.(data.transactionHash || data?.txHash)

toast({
title: 'Staking Success',
description: <Finder txHash={data.transactionHash || data?.txHash} chainId={chainId.toString()} />,
description: <Finder txHash={data?.transactionHash || data?.txHash} chainId={chainId.toString()} />,
status: 'success',
duration: 9000,
position: 'top-right',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { useMemo } from 'react'
import { useMutation } from 'react-query'

import { useChain } from '@cosmos-kit/react-lite';
import { usePoolFromListQueryById } from 'components/Pages/Trade/Pools/hooks/usePoolsListQuery'
import { ADV_MEMO, ChainId } from 'constants/index'
import { TxRaw } from 'cosmjs-types/cosmos/tx/v1beta1/tx';
import { useClients } from 'hooks/useClients';
Expand Down
35 changes: 20 additions & 15 deletions components/Pages/Trade/Pools/hooks/useQueryPoolsLiquidity.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useEffect, useMemo, useState } from 'react'
import { useMemo } from 'react'
import { useQueries, useQuery } from 'react-query'

import { CosmWasmClient } from '@cosmjs/cosmwasm-stargate'
Expand Down Expand Up @@ -170,10 +170,7 @@ const fetchLockedLp = async ({ pools, cosmWasmClient, address, chain_id }: Fetch
}

// Fetch alliance positions
let filteredAlliancePositions: any[] = [];
if (chain_id === 'phoenix-1') {
filteredAlliancePositions = (await queryAllStakedBalances(cosmWasmClient, address))?.filter((position: any) => position.open_position?.lp === pool.lp_token) || [];
}
let filteredAlliancePositions: any[] = (await queryAllStakedBalances(cosmWasmClient, address))?.filter((position: any) => position.open_position?.lp === pool.lp_token) || []

// Combine and sum up all positions
const totalLocked = sumPositions(stakingPositions) + sumPositions(filteredAlliancePositions);
Expand All @@ -185,10 +182,12 @@ const fetchLockedLp = async ({ pools, cosmWasmClient, address, chain_id }: Fetch

export const useFetchMyLockedLps = ({ pools, cosmWasmClient, address, chain_id }: FetchParams) => useQuery<Map<string, number>, Error>(
['lockedLps', pools, address, chain_id],
() => fetchLockedLp({ pools,
() => fetchLockedLp({
pools,
cosmWasmClient,
address,
chain_id }),
chain_id
}),
{
enabled: Boolean(pools) && Boolean(cosmWasmClient) && Boolean(address),
staleTime: 60000, // 1 minute
Expand Down Expand Up @@ -237,10 +236,12 @@ export const useQueryPoolsLiquidity = ({
const prices = usePrices();
const { walletChainName, chainId } = useRecoilValue(chainState);
const { address } = useChain(walletChainName);
const { data: lps, isLoading } = useFetchMyLockedLps({ pools,
const { data: lps, isLoading } = useFetchMyLockedLps({
pools,
cosmWasmClient,
address,
chain_id: chainId });
chain_id: chainId
});
const [tokenList] = useTokenList();
const { epochToDate, currentEpoch } = useEpoch();

Expand Down Expand Up @@ -324,8 +325,10 @@ export const useQueryPoolsLiquidity = ({
myNotLockedLp,
} = await queryMyLiquidity({
cosmWasmClient,
swap: { ...poolInfo,
...pool },
swap: {
...poolInfo,
...pool
},
address,
totalLockedLp,
myLockedLp,
Expand Down Expand Up @@ -367,16 +370,18 @@ export const useQueryPoolsLiquidity = ({
},
};

return { ...pool,
return {
...pool,
flows,
liquidity };
liquidity
};
};

return useQueries((pools ?? []).map((pool) => ({
queryKey: `@pool-liquidity/${pool.pool_id}/${address}`,
enabled:
Boolean(cosmWasmClient && pool.pool_id && tokenList?.tokens.length > 0) &&
Boolean(prices) && !isLoading,
Boolean(cosmWasmClient && pool.pool_id && tokenList?.tokens.length > 0) &&
Boolean(prices) && !isLoading,
refetchOnMount: false,
refetchInterval: refetchInBackground ? DEFAULT_TOKEN_BALANCE_REFETCH_INTERVAL : null,
refetchIntervalInBackground: refetchInBackground,
Expand Down

0 comments on commit 323347a

Please sign in to comment.