export interface PortfolioLookupRow {
  id: number;
  name: string;
}

export interface PortfolioMintRow {
  id: number;
  pubkey: string;
  decimals: number;
  cluster_id: number;
}

export interface PortfolioProgramAccountRow {
  id: number;
  pubkey: string;
}

export interface PortfolioOwnerRow {
  id: number;
  pubkey: string;
  cluster_id: number;
}

export interface PortfolioPriceRow {
  id: number;
  mint: string;
  cluster_id: number;
  spot_price_usd: string | null;
  decimals: number;
  source: string;
  source_slot: number | null;
  refreshed_on: Date;
  created_on: Date;
  updated_on: Date;
}

export interface PortfolioSectionRefreshRow {
  id: number;
  owner_id: number;
  section: string;
  indexed: boolean;
  positions_refreshed_on: Date | null;
  last_source_slot: number | null;
  updated_on: Date;
}

export interface PortfolioStreamErrorRow {
  id: number;
  product: string;
  account_pubkey: string;
  source_slot: number | null;
  write_version: bigint | null;
  data_hash: string | null;
  error_message: string;
  error_code: string | null;
  error_detail: string | null;
  retry_count: number;
  status: string;
  resolved_on: Date | null;
  created_on: Date;
  updated_on: Date;
}

export interface PortfolioReconciliationRunRow {
  id: number;
  product: string;
  account_kind: string;
  status: string;
  started_on: Date;
  finished_on: Date | null;
  min_observed_slot: number | null;
  max_observed_slot: number | null;
  accounts_seen: number | null;
  rows_changed: number | null;
  rows_closed: number | null;
  error_message: string | null;
}

export interface PortfolioShareMintMappingRow {
  id: number;
  share_mint: string;
  cluster_id: number;
  decimals: number;
  token_program_id: string;
  product: string;
  product_account_pubkey: string;
  is_active: boolean;
  created_on: Date;
  updated_on: Date;
}

export interface PortfolioFarmVaultAuthorityRow {
  product: string;
  product_account_pubkey: string;
  farm_vaults_authority: string;
}

export interface PortfolioShareTokenAccountRow {
  id: number;
  token_account_pubkey: string;
  owner_id: number;
  share_mint: string;
  token_program_id: string;
  amount: string;
  source_slot: number;
  write_version: bigint;
  content_hash: string;
  is_closed: boolean;
  closed_on: Date | null;
  created_on: Date;
  updated_on: Date;
}

export interface PortfolioKlendObligationRow {
  id: number;
  obligation_pubkey: string;
  owner_id: number;
  program_id: string;
  market_pubkey: string;
  obligation_type: string;
  elevation_group: number;
  tag: number;
  last_update_slot: number;
  last_update_stale: boolean;
  last_update_price_status: number;
  has_debt: boolean;
  active_deposit_count: number;
  active_borrow_count: number;
  deposited_value_sf: string;
  borrowed_assets_market_value_sf: string;
  allowed_borrow_value_sf: string;
  unhealthy_borrow_value_sf: string;
  borrow_factor_adjusted_debt_value_sf: string;
  source_slot: number;
  write_version: bigint;
  content_hash: string;
  is_closed: boolean;
  closed_on: Date | null;
  refreshed_on: Date;
  created_on: Date;
  updated_on: Date;
}

export interface PortfolioKlendObligationPositionRow {
  id: number;
  obligation_pubkey: string;
  reserve_pubkey: string;
  kind: string;
  mint: string;
  raw_amount: string;
  deposit_reserve_index: number | null;
  borrow_reserve_index: number | null;
  deposit_market_value_sf: string | null;
  borrow_market_value_sf: string | null;
  cumulative_borrow_rate_at_borrow: string | null;
  source_slot: number;
  write_version: bigint;
  content_hash: string;
  is_closed: boolean;
  closed_on: Date | null;
  created_on: Date;
  updated_on: Date;
}

export interface PortfolioKlendReserveRow {
  id: number;
  reserve_pubkey: string;
  program_id: string;
  lending_market: string;
  status: number;
  liquidity_mint: string;
  liquidity_token_program_id: string;
  mint_decimals: number;
  last_update_slot: number;
  last_update_stale: boolean;
  last_update_price_status: number;
  cumulative_borrow_rate_bsf: string;
  liquidity_total_available_amount: string;
  liquidity_borrowed_amount_sf: string;
  accumulated_protocol_fees_sf: string;
  accumulated_referrer_fees_sf: string;
  pending_referrer_fees_sf: string;
  collateral_mint_total_supply: string;
  market_price_sf: string;
  host_fixed_interest_rate_bps: number;
  protocol_take_rate_pct: number;
  loan_to_value_pct: number;
  liquidation_threshold_pct: number;
  borrow_factor_pct: number;
  debt_maturity_timestamp: number | null;
  debt_term_seconds: number | null;
  source_slot: number;
  write_version: bigint;
  content_hash: string;
  refreshed_on: Date;
  created_on: Date;
  updated_on: Date;
}

export interface PortfolioKlendReserveBorrowRateCurvePointRow {
  id: number;
  reserve_pubkey: string;
  point_index: number;
  utilization_rate_bps: number;
  borrow_rate_bps: number;
  created_on: Date;
  updated_on: Date;
}

export interface PortfolioKlendReserveElevationGroupRow {
  id: number;
  reserve_pubkey: string;
  elevation_group: number;
  debt_limit_sf: string | null;
  borrow_factor_pct: number | null;
  loan_to_value_pct: number | null;
  liquidation_threshold_pct: number | null;
  created_on: Date;
  updated_on: Date;
}

export interface PortfolioKlendMarketRow {
  id: number;
  market_pubkey: string;
  program_id: string;
  lending_market_owner: string;
  name: string;
  version: number;
  referral_fee_bps: number;
  borrow_disabled: boolean;
  emergency_mode: boolean;
  liquidation_max_debt_close_factor_pct: number | null;
  insolvency_risk_unhealthy_ltv_pct: number;
  global_allowed_borrow_value_sf: string;
  min_net_value_in_obligation_sf: string;
  source_slot: number;
  write_version: bigint;
  content_hash: string;
  refreshed_on: Date;
  created_on: Date;
  updated_on: Date;
}

export interface PortfolioKlendMarketElevationGroupRow {
  id: number;
  market_pubkey: string;
  group_index: number;
  max_liquidation_bonus_bps: number | null;
  liquidation_threshold_pct: number | null;
  loan_to_value_pct: number | null;
  allow_new_loans: boolean | null;
  created_on: Date;
  updated_on: Date;
}

export interface PortfolioLiquidityPositionRow {
  id: number;
  owner_id: number;
  strategy_pubkey: string;
  shares_held: string;
  shares_in_farm: string;
  total_shares: string;
  shares_held_source_slot: number | null;
  shares_held_write_version: bigint | null;
  shares_in_farm_source_slot: number | null;
  shares_in_farm_write_version: bigint | null;
  shares_held_hash: string | null;
  shares_in_farm_hash: string | null;
  is_closed: boolean;
  closed_on: Date | null;
  refreshed_on: Date;
  created_on: Date;
  updated_on: Date;
}

export interface PortfolioLiquidityStrategyRow {
  id: number;
  strategy_pubkey: string;
  program_account_id: number;
  program_id: string;
  share_mint: string;
  token_a_mint: string;
  token_b_mint: string;
  token_a_amount_per_share: string;
  token_b_amount_per_share: string;
  creation_status: number | null;
  source_slot: number;
  write_version: bigint;
  content_hash: string;
  is_closed: boolean;
  closed_on: Date | null;
  refreshed_on: Date;
  created_on: Date;
  updated_on: Date;
}

export interface PortfolioVaultPositionRow {
  id: number;
  owner_id: number;
  vault_pubkey: string;
  vault_kind: string;
  shares_held: string;
  shares_in_farm: string;
  total_shares: string;
  shares_held_source_slot: number | null;
  shares_held_write_version: bigint | null;
  shares_in_farm_source_slot: number | null;
  shares_in_farm_write_version: bigint | null;
  shares_held_hash: string | null;
  shares_in_farm_hash: string | null;
  is_private_credit: boolean;
  is_closed: boolean;
  closed_on: Date | null;
  refreshed_on: Date;
  created_on: Date;
  updated_on: Date;
}

export interface PortfolioKvaultRow {
  id: number;
  vault_pubkey: string;
  share_mint: string;
  token_mint: string;
  token_amount_per_share: string;
  vault_name: string | null;
  is_private_credit: boolean;
  vault_farm_pubkey: string | null;
  source_slot: number;
  write_version: bigint;
  content_hash: string;
  is_closed: boolean;
  closed_on: Date | null;
  refreshed_on: Date;
  created_on: Date;
  updated_on: Date;
}

export interface PortfolioFarmUserStateRow {
  id: number;
  farm_user_pubkey: string;
  owner_id: number;
  farm_pubkey: string;
  delegatee_pubkey: string | null;
  active_stake: string;
  pending_deposit_stake: string | null;
  pending_withdrawal_unstake: string | null;
  source_slot: number;
  write_version: bigint;
  content_hash: string;
  is_closed: boolean;
  closed_on: Date | null;
  refreshed_on: Date;
  created_on: Date;
  updated_on: Date;
}

export interface PortfolioFarmUserRewardRow {
  id: number;
  farm_user_pubkey: string;
  reward_index: number;
  reward_mint: string | null;
  rewards_tally: string | null;
  rewards_pending: string | null;
  rewards_claimed: string | null;
  created_on: Date;
  updated_on: Date;
}

export interface PortfolioFarmRow {
  id: number;
  farm_pubkey: string;
  token_mint: string | null;
  strategy_pubkey: string | null;
  vault_pubkey: string | null;
  farm_vaults_authority: string | null;
  second_delegated_authority: string | null;
  source_slot: number;
  write_version: bigint;
  content_hash: string;
  is_active: boolean;
  refreshed_on: Date;
  created_on: Date;
  updated_on: Date;
}

export interface PortfolioFarmRewardRow {
  id: number;
  farm_pubkey: string;
  reward_index: number;
  reward_mint: string | null;
  reward_token_program_id: string | null;
  reward_vault_pubkey: string | null;
  reward_type: number | null;
  rewards_available: string | null;
  reward_per_share: string | null;
  is_active: boolean;
  created_on: Date;
  updated_on: Date;
}

export interface PortfolioFarmRewardCurvePointRow {
  id: number;
  farm_pubkey: string;
  reward_index: number;
  point_index: number;
  starts_at_ts: number | null;
  reward_per_second: string | null;
  created_on: Date;
  updated_on: Date;
}

export interface PortfolioStakingPositionRow {
  id: number;
  owner_id: number;
  farm_pubkey: string;
  mint: string;
  amount: string;
  source_slot: number;
  write_version: bigint;
  content_hash: string;
  is_closed: boolean;
  closed_on: Date | null;
  refreshed_on: Date;
  created_on: Date;
  updated_on: Date;
}
