> ## Documentation Index
> Fetch the complete documentation index at: https://docs.gizatech.xyz/llms.txt
> Use this file to discover all available pages before exploring further.

# Types Reference

> Complete reference of all exported types, interfaces, enums, and constants

## Overview

This page lists every type exported from `@gizatech/agent-sdk`. Types are grouped by category. All types can be imported directly:

```typescript theme={null}
import {
  Giza, Agent, Chain, Paginator,
  type Address, type Transaction, type OptimizeOptions,
} from '@gizatech/agent-sdk';
```

***

## Configuration

### GizaConfig

Options passed to the `Giza` constructor. Credentials fall back to environment variables when omitted.

```typescript theme={null}
interface GizaConfig {
  chain: Chain;
  apiKey?: string;
  partner?: string;
  apiUrl?: string;
  timeout?: number;
  enableRetry?: boolean;
}
```

### ResolvedGizaConfig

Internal configuration after defaults and environment variables are resolved.

```typescript theme={null}
interface ResolvedGizaConfig {
  chain: Chain;
  apiKey: string;
  partner: string;
  apiUrl: string;
  agentId: string;
  timeout: number;
  enableRetry: boolean;
}
```

***

## Common

### Address

Ethereum address type. A `0x`-prefixed hex string.

```typescript theme={null}
type Address = `0x${string}`;
```

### Chain

Supported blockchain networks.

```typescript theme={null}
enum Chain {
  DEVNET = -1,
  ETHEREUM = 1,
  POLYGON = 137,
  CHAIN_999 = 999,
  BASE = 8453,
  CHAIN_9745 = 9745,
  SEPOLIA = 11155111,
  ARBITRUM = 42161,
  BASE_SEPOLIA = 84532,
}
```

### GizaError

Base error class for all SDK errors.

```typescript theme={null}
class GizaError extends Error {
  constructor(message: string);
}
```

### ValidationError

Thrown when input validation fails (invalid address, missing required fields, etc.).

```typescript theme={null}
class ValidationError extends GizaError {
  constructor(message: string);
}
```

### NotImplementedError

Thrown when a feature is not yet implemented.

```typescript theme={null}
class NotImplementedError extends GizaError {
  constructor(message: string);
}
```

***

## Agent Options

### ActivateOptions

```typescript theme={null}
interface ActivateOptions {
  owner: Address;
  token: Address;
  protocols: string[];
  txHash: string;
  constraints?: ConstraintConfig[];
}
```

### AprOptions

```typescript theme={null}
interface AprOptions {
  startDate?: string;
  endDate?: string;
  useExactEndDate?: boolean;
}
```

### DeactivateOptions

```typescript theme={null}
interface DeactivateOptions {
  transfer?: boolean;
}
```

### PaginationOptions

```typescript theme={null}
interface PaginationOptions {
  limit?: number;
  sort?: string;
}
```

### PerformanceOptions

```typescript theme={null}
interface PerformanceOptions {
  from?: string;
}
```

### WaitForDeactivationOptions

```typescript theme={null}
interface WaitForDeactivationOptions {
  interval?: number;
  timeout?: number;
  onUpdate?: (status: AgentStatus) => void;
}
```

***

## Agent Responses

### SmartAccountInfo

```typescript theme={null}
interface SmartAccountInfo {
  smartAccountAddress: Address;
  backendWallet: Address;
  origin_wallet: Address;
  chain: Chain;
}
```

### ActivateResponse

```typescript theme={null}
interface ActivateResponse {
  message: string;
  wallet: string;
}
```

### DeactivateResponse

```typescript theme={null}
interface DeactivateResponse {
  message: string;
}
```

### TopUpResponse

```typescript theme={null}
interface TopUpResponse {
  message: string;
}
```

### RunResponse

```typescript theme={null}
interface RunResponse {
  status: string;
}
```

### AgentInfo

```typescript theme={null}
interface AgentInfo {
  wallet: Address;
  deposits: Deposit[];
  withdraws?: Withdraw[];
  status: AgentStatus;
  activation_date: string;
  last_deactivation_date?: string;
  last_reactivation_date?: string;
  selected_protocols: string[];
  current_protocols?: string[];
  current_token?: string;
  eoa?: Address;
}
```

### PerformanceChartResponse

```typescript theme={null}
interface PerformanceChartResponse {
  performance: PerformanceData[];
}
```

### PerformanceData

```typescript theme={null}
interface PerformanceData {
  date: string;
  value: number;
  value_in_usd?: number;
  accrued_rewards?: AccruedRewardsBySymbol;
  portfolio?: Portfolio;
  agent_token_amount?: number;
}
```

### WalletAprResponse

```typescript theme={null}
interface WalletAprResponse {
  apr: number;
  sub_periods?: WalletAprSubPeriod[];
}
```

### WalletAprSubPeriod

```typescript theme={null}
interface WalletAprSubPeriod {
  start_date: string;
  end_date: string;
  return_: number;
  initial_value: number;
}
```

### AprByTokenResponse

```typescript theme={null}
type AprByTokenResponse = AllocatedValue[];
```

### AllocatedValue

```typescript theme={null}
interface AllocatedValue {
  value: number;
  value_in_usd: number;
  base_apr?: number;
  total_apr?: number;
}
```

### Portfolio

```typescript theme={null}
type Portfolio = Record<string, AllocatedValue>;
```

### AccruedRewardsWithValue

```typescript theme={null}
interface AccruedRewardsWithValue {
  locked: number;
  unlocked: number;
  locked_value: number;
  locked_value_usd: number;
  unlocked_value: number;
  unlocked_value_usd: number;
  claimed?: number;
  claimed_value?: number;
  claimed_value_usd?: number;
}
```

### AccruedRewardsBySymbol

```typescript theme={null}
type AccruedRewardsBySymbol = Record<string, AccruedRewardsWithValue>;
```

### Transaction

```typescript theme={null}
interface Transaction {
  action: TxAction;
  date: string;
  amount: number;
  amount_out?: number;
  token_type: string;
  status: TxStatus;
  transaction_hash?: string;
  protocol?: string;
  new_token?: string;
  correlation_id?: string;
  apr?: number;
  block_number?: number;
}
```

### TransactionHistoryResponse

```typescript theme={null}
interface TransactionHistoryResponse {
  transactions: Transaction[];
  pagination: PaginationInfo;
}
```

### PaginationInfo

```typescript theme={null}
interface PaginationInfo {
  page: number;
  items_per_page: number;
  total_pages: number;
  total_items: number;
}
```

### WithdrawResponse

```typescript theme={null}
type WithdrawResponse =
  | FullWithdrawResponse
  | PartialWithdrawResponse;
```

### FullWithdrawResponse

```typescript theme={null}
interface FullWithdrawResponse {
  message: string;
}
```

### PartialWithdrawResponse

```typescript theme={null}
interface PartialWithdrawResponse {
  date: string;
  amount: number;
  value: number;
  withdraw_details: WithdrawDetail[];
}
```

### WithdrawDetail

```typescript theme={null}
interface WithdrawDetail {
  token: string;
  amount: string;
  value: number;
  value_in_usd: number;
  principal_amount?: number;
  yield_amount?: number;
  fee_amount?: number;
  tx_hash?: string;
  block_number?: number;
}
```

### WithdrawalStatusResponse

```typescript theme={null}
interface WithdrawalStatusResponse {
  status: AgentStatus;
  wallet: Address;
  activation_date: string;
  last_deactivation_date?: string;
  last_reactivation_date?: string;
}
```

### FeeResponse

```typescript theme={null}
interface FeeResponse {
  percentage_fee: number;
  fee: number;
}
```

### LimitResponse

```typescript theme={null}
interface LimitResponse {
  limit: number;
}
```

### ClaimedReward

```typescript theme={null}
interface ClaimedReward {
  token: string;
  amount: number;
  amount_float: number;
  current_price_in_underlying: number;
}
```

### ClaimedRewardsResponse

```typescript theme={null}
interface ClaimedRewardsResponse {
  rewards: ClaimedReward[];
}
```

### DepositListResponse

```typescript theme={null}
interface DepositListResponse {
  deposits: Deposit[];
}
```

### Deposit

```typescript theme={null}
interface Deposit {
  amount: number;
  token_type: string;
  date?: string;
  tx_hash?: string;
  block_number?: number;
}
```

### Withdraw

```typescript theme={null}
interface Withdraw {
  date: string;
  amount: number;
  value: number;
  withdraw_details: WithdrawDetail[];
}
```

### ExecutionWithTransactionsDTO

```typescript theme={null}
interface ExecutionWithTransactionsDTO {
  id: string;
  execution_plan: unknown;
  execution_type: string;
  status: ExecutionStatus;
  created_at: string;
  transactions: Transaction[];
}
```

### PaginatedExecutionDTO

```typescript theme={null}
interface PaginatedExecutionDTO {
  items: ExecutionWithTransactionsDTO[];
  total: number;
}
```

### LogDTO

```typescript theme={null}
interface LogDTO {
  type: string;
  data: unknown;
}
```

### PaginatedLogDTO

```typescript theme={null}
interface PaginatedLogDTO {
  items: LogDTO[];
  total: number;
}
```

### RewardDTO

```typescript theme={null}
interface RewardDTO {
  user_id: string;
  base_apr: number;
  extra_apr: number;
  ticker: string;
  reward_amount: number;
  group: string;
  transaction_hash: string;
  start_date: string;
  end_date: string;
  id: string;
  created_at: string;
  updated_at: string;
}
```

### PaginatedRewardDTO

```typescript theme={null}
interface PaginatedRewardDTO {
  items: RewardDTO[];
  total: number;
}
```

### Protocol

```typescript theme={null}
interface Protocol {
  name: string;
  is_active: boolean;
  description: string;
  tvl: number;
  apr: number | null;
  pools: ProtocolPool[] | null;
  created_at: string;
  updated_at: string | null;
  chain_id: number;
  parent_protocol: string;
  link: string;
  address: string | null;
  agent_token: string | null;
  title: string | null;
}
```

### ProtocolPool

```typescript theme={null}
interface ProtocolPool {
  name: string;
  apy: number;
}
```

### ProtocolsResponse

```typescript theme={null}
interface ProtocolsResponse {
  protocols: string[];
}
```

### ProtocolsRawResponse

```typescript theme={null}
interface ProtocolsRawResponse {
  protocols: Protocol[];
}
```

### ProtocolSupply

```typescript theme={null}
interface ProtocolSupply {
  protocol: string;
  supply: number;
  tokens: string[];
}
```

### ProtocolsSupplyResponse

```typescript theme={null}
interface ProtocolsSupplyResponse {
  protocols: ProtocolSupply[];
}
```

### ConstraintConfig (Agent)

```typescript theme={null}
interface ConstraintConfig {
  kind: string;
  params: Record<string, unknown>;
}
```

### ConstraintConfigResponse

```typescript theme={null}
interface ConstraintConfigResponse {
  [key: string]: unknown;
}
```

### ChainConfigResponse

```typescript theme={null}
interface ChainConfigResponse {
  [key: string]: unknown;
}
```

### GlobalConfigResponse

```typescript theme={null}
interface GlobalConfigResponse {
  min_withdraw_usd: number;
  optimizer_threshold_usd: number;
  max_protocol_liquidity_percentage: number;
  constraints: ConstraintConfigResponse;
  chains: Record<string, ChainConfigResponse>;
}
```

### HealthcheckResponse

```typescript theme={null}
interface HealthcheckResponse {
  message: string;
  version: string;
  time: string;
}
```

### ChainsResponse

```typescript theme={null}
interface ChainsResponse {
  chain_ids: number[];
}
```

### TokenDistributionItem

```typescript theme={null}
interface TokenDistributionItem {
  token: string;
  amount: number;
  percentage: number;
}
```

### ProtocolDistribution

```typescript theme={null}
interface ProtocolDistribution {
  protocol: string;
  amount: number;
  percentage: number;
}
```

### LiquidityDistribution

```typescript theme={null}
interface LiquidityDistribution {
  initial_deposits: TokenDistributionItem[];
  current_tokens: TokenDistributionItem[];
  protocols: ProtocolDistribution[];
}
```

### Statistics

```typescript theme={null}
interface Statistics {
  total_balance: number;
  total_deposits: number;
  total_users: number;
  total_transactions: number;
  total_apr: number;
  liquidity_distribution: LiquidityDistribution;
}
```

### TVLResponse

```typescript theme={null}
interface TVLResponse {
  tvl: number;
}
```

### TokenInfo

```typescript theme={null}
interface TokenInfo {
  address: string;
  symbol: string;
  decimals: number;
  balance: number;
  current_price: number;
}
```

### TokensResponse

```typescript theme={null}
interface TokensResponse {
  tokens: TokenInfo[];
}
```

***

## Agent Enums

### AgentStatus

```typescript theme={null}
enum AgentStatus {
  UNKNOWN = 'unknown',
  ACTIVATING = 'activating',
  ACTIVATION_FAILED = 'activation_failed',
  ACTIVATED = 'activated',
  RUNNING = 'running',
  RUN_FAILED = 'run_failed',
  BLOCKED = 'blocked',
  DEACTIVATING = 'deactivating',
  DEACTIVATION_FAILED = 'deactivation_failed',
  DEACTIVATED = 'deactivated',
  EMERGENCY = 'emergency',
  DEACTIVATED_FEE_NOT_PAID = 'deactivated_fee_not_paid',
  BRIDGING = 'bridging',
}
```

### TxAction

```typescript theme={null}
enum TxAction {
  UNKNOWN = 'unknown',
  APPROVE = 'approve',
  DEPOSIT = 'deposit',
  TRANSFER = 'transfer',
  BRIDGE = 'bridge',
  WITHDRAW = 'withdraw',
  SWAP = 'swap',
  REFILL_GAS_TANK = 'refill_gas_tank',
  WRAP = 'wrap',
  UNWRAP = 'unwrap',
  FEE_TRANSFER = 'fee_transfer',
}
```

### TxStatus

```typescript theme={null}
enum TxStatus {
  UNKNOWN = 'unknown',
  PENDING = 'pending',
  APPROVED = 'approved',
  CANCELLED = 'cancelled',
  FAILED = 'failed',
}
```

### SortOrder

```typescript theme={null}
enum SortOrder {
  DATE_ASC = 'date_asc',
  DATE_DESC = 'date_desc',
}
```

### Order

```typescript theme={null}
enum Order {
  ASC = 'asc',
  DESC = 'desc',
}
```

### Period

```typescript theme={null}
enum Period {
  ALL = 'all',
  DAY = 'day',
}
```

### ExecutionStatus

```typescript theme={null}
enum ExecutionStatus {
  RUNNING = 'running',
  FAILED = 'failed',
  SUCCESS = 'success',
}
```

***

## Optimizer Types

### OptimizeOptions

```typescript theme={null}
interface OptimizeOptions {
  chain?: Chain;
  token: Address;
  capital: string;
  currentAllocations: Record<string, string>;
  protocols: string[];
  constraints?: ConstraintConfig[];
  wallet?: Address;
}
```

### OptimizeResponse

```typescript theme={null}
interface OptimizeResponse {
  optimization_result: OptimizationResult;
  action_plan: ActionDetail[];
  calldata: CalldataInfo[];
}
```

### OptimizationResult

```typescript theme={null}
interface OptimizationResult {
  allocations: ProtocolAllocation[];
  total_costs: number;
  weighted_apr_initial: number;
  weighted_apr_final: number;
  apr_improvement: number;
  gas_estimate_usd?: number;
  break_even_days?: number;
}
```

### ProtocolAllocation

```typescript theme={null}
interface ProtocolAllocation {
  protocol: string;
  allocation: string;
  apr: number;
}
```

### ActionDetail

```typescript theme={null}
interface ActionDetail {
  action_type: 'deposit' | 'withdraw';
  protocol: string;
  amount: string;
  underlying_amount?: string;
}
```

### CalldataInfo

```typescript theme={null}
interface CalldataInfo {
  contract_address: string;
  function_name: string;
  parameters: string[];
  value: string;
  protocol: string;
  description: string;
}
```

### WalletConstraints

```typescript theme={null}
enum WalletConstraints {
  MIN_PROTOCOLS = 'min_protocols',
  MAX_ALLOCATION_AMOUNT_PER_PROTOCOL = 'max_allocation_amount_per_protocol',
  MAX_AMOUNT_PER_PROTOCOL = 'max_amount_per_protocol',
  MIN_AMOUNT = 'min_amount',
  EXCLUDE_PROTOCOL = 'exclude_protocol',
  MIN_ALLOCATION_AMOUNT_PER_PROTOCOL = 'min_allocation_amount_per_protocol',
}
```

### ConstraintConfig (Optimizer)

Imported as `OptimizerConstraintConfig` to distinguish from the agent variant.

```typescript theme={null}
interface ConstraintConfig {
  kind: WalletConstraints;
  params: Record<string, unknown>;
}
```

***

## Paginator Types

### Paginator\<T>

Async-iterable paginator returned by collection methods. See [Paginator reference](/sdk-reference/paginator).

```typescript theme={null}
class Paginator<T> implements AsyncIterable<T> {
  async *[Symbol.asyncIterator](): AsyncIterableIterator<T>;
  async page(num: number, opts?: { limit?: number }): Promise<PaginatedResponse<T>>;
  async first(count?: number): Promise<T[]>;
}
```

### PaginatedResponse\<T>

```typescript theme={null}
interface PaginatedResponse<T> {
  items: T[];
  total: number;
  page: number;
  limit: number;
  hasMore: boolean;
}
```

### PageFetcher\<T>

Internal type used by the `Paginator` constructor.

```typescript theme={null}
type PageFetcher<T> = (
  page: number,
  limit: number,
) => Promise<PaginatedResponse<T>>;
```

***

## Error Classes

### GizaError

Base class for all SDK errors. Extends `Error`.

```typescript theme={null}
class GizaError extends Error {
  constructor(message: string);
}
```

### ValidationError

Thrown on invalid input (bad addresses, missing fields, invalid values).

```typescript theme={null}
class ValidationError extends GizaError {
  constructor(message: string);
}
```

### NotImplementedError

Thrown when calling a feature that is not yet implemented.

```typescript theme={null}
class NotImplementedError extends GizaError {
  constructor(message: string);
}
```

### GizaAPIError

Thrown when the Giza API returns a non-2xx response.

```typescript theme={null}
class GizaAPIError extends GizaError {
  readonly statusCode: number;
  readonly responseData: unknown;
  readonly requestUrl?: string;
  readonly requestMethod?: string;
  readonly friendlyMessage: string;

  constructor(
    message: string,
    statusCode: number,
    responseData?: unknown,
    requestUrl?: string,
    requestMethod?: string,
  );

  static fromResponse(
    statusCode: number,
    responseData: unknown,
    requestUrl?: string,
    requestMethod?: string,
  ): GizaAPIError;

  toJSON(): object;
}
```

### TimeoutError

Thrown when a request or polling operation exceeds its timeout.

```typescript theme={null}
class TimeoutError extends GizaError {
  constructor(timeout: number, message?: string);
}
```

### NetworkError

Thrown on network connectivity failures (DNS resolution, connection refused, etc.).

```typescript theme={null}
class NetworkError extends GizaError {
  constructor(message: string);
}
```

***

## Constants

### DEFAULT\_AGENT\_ID

Default agent identifier used for smart account creation.

```typescript theme={null}
const DEFAULT_AGENT_ID = 'giza-app';
```

### DEFAULT\_TIMEOUT

Default HTTP request timeout in milliseconds.

```typescript theme={null}
const DEFAULT_TIMEOUT = 45000;
```

### CHAIN\_NAMES

Map of chain IDs to human-readable names.

```typescript theme={null}
const CHAIN_NAMES: Record<Chain, string> = {
  [-1]: 'Devnet',
  [1]: 'Ethereum',
  [137]: 'Polygon',
  [999]: 'Chain 999',
  [8453]: 'Base',
  [9745]: 'Chain 9745',
  [11155111]: 'Sepolia',
  [42161]: 'Arbitrum',
  [84532]: 'Base Sepolia',
};
```
