/**
 * LP 流动性池相关类型定义
 */

// 池子代币信息
export interface PoolToken {
  address: `0x${string}`
  symbol: string
  name: string
  decimals: number
}

// 添加流动性表单
export interface AddLiquidityForm {
  token: string
  amount: string
  slippage: string
}

// 移除流动性表单
export interface RemoveLiquidityForm {
  token: string
  amount: string
  slippage: string
}

// 交换表单
export interface SwapForm {
  tokenIn: string
  tokenOut: string
  amount: string
  slippage: string
}

// 价格配置表单
export interface PriceConfigForm {
  token: string
  price: string
  spreadBps: string
}

// Vault 配置表单
export interface VaultConfigForm {
  token: string
  tokenDecimals: string
  tokenWeight: string
  maxUsdyAmount: string
}

// YT 价格表单
export interface YtPriceForm {
  ytPrice: string
}

// 稳定代币配置
export interface StableTokenConfig {
  token: string
  isStable: boolean
}

// P1: 冷却时间表单
export interface CooldownForm {
  duration: string
}

// P1: 交换手续费表单
export interface SwapFeesForm {
  swapFee: string
  stableSwapFee: string
  taxBasisPoints: string
  stableTaxBasisPoints: string
}

// P1: 提取代币表单
export interface WithdrawForm {
  token: string
  receiver: string
  amount: string
}

// P2: AUM 调整表单
export interface AumAdjustForm {
  addition: string
  deduction: string
}

// P2: 限制表单
export interface LimitsForm {
  maxSwapSlippageBps: string
  maxPriceChangeBps: string
}

// P2: 最大交换金额表单
export interface MaxSwapForm {
  token: string
  amount: string
}

// P3: 权限管理表单
export interface PermissionForm {
  govAddress: string
  handlerAddress: string
  handlerActive: boolean
  keeperAddress: string
  keeperActive: boolean
  swapperAddress: string
  swapperActive: boolean
  minterAddress: string
  minterActive: boolean
  poolManagerAddress: string
}

// LP Panel Context - 共享状态
export interface LPPanelContext {
  address: `0x${string}` | undefined
  isConnected: boolean
  isProcessing: boolean
  poolTokens: PoolToken[]
  allAvailableTokens: PoolToken[]
  showToast: (type: 'success' | 'error' | 'info' | 'warning', message: string) => void
  recordTx: (type: string, amount?: string, token?: string) => void
  writeContract: (config: any) => void
  refetchAll: () => void
}

// ERC20 基础 ABI
export const ERC20_BASE_ABI = [
  { inputs: [], name: 'symbol', outputs: [{ type: 'string' }], stateMutability: 'view', type: 'function' },
  { inputs: [], name: 'name', outputs: [{ type: 'string' }], stateMutability: 'view', type: 'function' },
  { inputs: [{ type: 'address' }], name: 'balanceOf', outputs: [{ type: 'uint256' }], stateMutability: 'view', type: 'function' },
  { inputs: [{ type: 'address' }, { type: 'address' }], name: 'allowance', outputs: [{ type: 'uint256' }], stateMutability: 'view', type: 'function' },
  { inputs: [{ type: 'address' }, { type: 'uint256' }], name: 'approve', outputs: [{ type: 'bool' }], stateMutability: 'nonpayable', type: 'function' },
  { inputs: [{ type: 'address' }, { type: 'uint256' }], name: 'transfer', outputs: [{ type: 'bool' }], stateMutability: 'nonpayable', type: 'function' },
] as const
