import { ALL } from '@constants/withdrawTypes'
import ExplorerToastLink from '@components/ExplorerToastLink'
import { getSwapDepositContractFields } from '@/utils/getSwapDepositContractFields'
import { txErrorHandler } from '@utils/txErrorHandler'
import { Token } from '@types'
import toast from 'react-hot-toast'
import { approveErc20Token } from '@/actions/approveErc20Token'
import { type Address } from 'viem'
import { swapPoolRemoveLiquidity } from '@/actions/swapPoolRemoveLiquidity'
import { swapPoolRemoveLiquidityOneToken } from '@/actions/swapPoolRemoveLiquidityOneToken'
import { segmentAnalyticsEvent } from '@/contexts/SegmentAnalyticsProvider'
import { TranslatedText } from '@/components/ui/TranslatedText'
export const approve = async (
pool: Token,
depositQuote: any,
inputValue: bigint,
chainId: number
) => {
if (inputValue === 0n || inputValue < depositQuote.allowance) {
return
}
const { poolAddress } = getSwapDepositContractFields(pool, chainId)
return await approveErc20Token({
chainId,
tokenAddress: pool.addresses[chainId] as Address,
spender: poolAddress,
amount: inputValue,
})
}
export const withdraw = async (
pool: Token,
slippageSelected: any,
slippageCustom: any,
inputAmount: bigint,
chainId: number,
withdrawType: string,
outputs: Record<
string,
{
value: any
index: number
}
>
) => {
let spendTransaction
let pendingPopup: any
let successPopup: any
const msg = (