> ## 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.

# Agent Class

> Wallet-scoped handle for managing an autonomous yield agent

## What Is an Agent

An `Agent` is a resource handle bound to a single smart-account wallet address. Every method on the `Agent` class operates on that wallet, so you never need to pass the address repeatedly. The `Agent` encapsulates the full lifecycle of an autonomous yield agent: activation, monitoring, withdrawals, rewards, and protocol management.

## How to Get One

There are three ways to obtain an `Agent` instance, all through the [`Giza`](/sdk-reference/giza) client:

| Method                  | API Call | Use Case                                 |
| ----------------------- | -------- | ---------------------------------------- |
| `giza.createAgent(eoa)` | Yes      | Create a new smart account for an EOA    |
| `giza.getAgent(eoa)`    | Yes      | Look up an existing smart account by EOA |
| `giza.agent(wallet)`    | No       | Wrap a known smart-account address       |

```typescript theme={null}
import { Giza, Chain } from '@gizatech/agent-sdk';

const giza = new Giza({ chain: Chain.BASE });

// Option 1: Create a new smart account
const agent = await giza.createAgent('0xUserEOA...');
console.log('New smart account:', agent.wallet);

// Option 2: Retrieve an existing smart account
const existing = await giza.getAgent('0xUserEOA...');
console.log('Existing smart account:', existing.wallet);

// Option 3: Wrap a known address (no API call)
const direct = giza.agent('0xSmartAccountAddress...');
```

## The `wallet` Property

Every `Agent` exposes the smart-account address it is bound to:

```typescript theme={null}
readonly wallet: Address  // `0x${string}`
```

This is the address used in all API calls made by the agent. It is set at construction time and cannot be changed.

## Method Categories

The `Agent` class groups its methods into six categories. Each is documented on its own page.

### Lifecycle

Manage the agent's activation state and trigger runs.

| Method                 | Return Type          | Description                                              |
| ---------------------- | -------------------- | -------------------------------------------------------- |
| `activate(options)`    | `ActivateResponse`   | Activate the agent with token, protocols, and deposit tx |
| `deactivate(options?)` | `DeactivateResponse` | Deactivate and optionally transfer funds back            |
| `topUp(txHash)`        | `TopUpResponse`      | Record an additional deposit                             |
| `run()`                | `RunResponse`        | Trigger a manual optimization run                        |

<Card title="Lifecycle" icon="arrows-spin" href="/sdk-reference/agent/lifecycle">
  Full method reference with parameters, types, and examples
</Card>

### Monitoring

Track portfolio value, performance history, and APR.

| Method                  | Return Type                | Description                                    |
| ----------------------- | -------------------------- | ---------------------------------------------- |
| `portfolio()`           | `AgentInfo`                | Current portfolio state, deposits, status      |
| `performance(options?)` | `PerformanceChartResponse` | Historical performance data points             |
| `apr(options?)`         | `WalletAprResponse`        | Current APR with optional sub-period breakdown |
| `aprByTokens(period?)`  | `AprByTokenResponse`       | APR broken down by token allocation            |
| `deposits()`            | `DepositListResponse`      | List of all deposits                           |

<Card title="Monitoring" icon="chart-line" href="/sdk-reference/agent/monitoring">
  Full method reference with parameters, types, and examples
</Card>

### Transactions

Browse transaction history, execution records, and logs. These methods return a `Paginator` for async iteration.

| Method                                 | Return Type                               | Description                         |
| -------------------------------------- | ----------------------------------------- | ----------------------------------- |
| `transactions(options?)`               | `Paginator<Transaction>`                  | All wallet transactions             |
| `executions(options?)`                 | `Paginator<ExecutionWithTransactionsDTO>` | Execution batches with transactions |
| `executionLogs(executionId, options?)` | `Paginator<LogDTO>`                       | Logs for a specific execution       |
| `logs(options?)`                       | `Paginator<LogDTO>`                       | All wallet logs                     |

### Withdrawals

Withdraw funds and monitor withdrawal status.

| Method                          | Return Type                | Description                           |
| ------------------------------- | -------------------------- | ------------------------------------- |
| `withdraw(amount?)`             | `WithdrawResponse`         | Initiate a partial or full withdrawal |
| `status()`                      | `WithdrawalStatusResponse` | Current agent status and dates        |
| `waitForDeactivation(options?)` | `WithdrawalStatusResponse` | Poll until deactivation completes     |
| `fees()`                        | `FeeResponse`              | Current fee structure                 |
| `limit(eoa)`                    | `LimitResponse`            | Withdrawal limit for the EOA          |

### Rewards

Claim and inspect accrued rewards. Paginated history uses the `Paginator` class.

| Method                    | Return Type              | Description                 |
| ------------------------- | ------------------------ | --------------------------- |
| `claimRewards()`          | `ClaimedRewardsResponse` | Claim all available rewards |
| `rewards(options?)`       | `Paginator<RewardDTO>`   | Paginated reward records    |
| `rewardHistory(options?)` | `Paginator<RewardDTO>`   | Paginated reward history    |

### Protocols

View and update the agent's protocol selection and constraints.

| Method                           | Return Type          | Description                            |
| -------------------------------- | -------------------- | -------------------------------------- |
| `protocols()`                    | `Protocol[]`         | Current protocol list for the agent    |
| `updateProtocols(protocols)`     | `void`               | Replace the agent's protocol selection |
| `constraints()`                  | `ConstraintConfig[]` | Current allocation constraints         |
| `updateConstraints(constraints)` | `void`               | Replace allocation constraints         |
| `whitelist()`                    | `unknown`            | Get the agent's whitelist              |

## Next Steps

<CardGroup cols={2}>
  <Card title="Lifecycle" icon="arrows-spin" href="/sdk-reference/agent/lifecycle">
    Activation, deactivation, top-ups, and runs
  </Card>

  <Card title="Monitoring" icon="chart-line" href="/sdk-reference/agent/monitoring">
    Portfolio, performance, APR, and deposits
  </Card>

  <Card title="Giza Client" icon="plug" href="/sdk-reference/giza">
    Agent factory methods and chain-level queries
  </Card>

  <Card title="Overview" icon="book" href="/sdk-reference/overview">
    SDK architecture and configuration
  </Card>
</CardGroup>
