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

# getHistory

Get transaction history for a wallet with optional pagination, date, and asset filters.

Rebalance entries include a typed **`rebalanceLog`** with gross APYs (`oldApy` / `newApy`) and net-of-fee APYs (`oldApy_withFee` / `newApy_withFee` = gross × 0.9). Fee collection metadata is on **`feeData`**.

<Tip title="User-facing display">
  Show `rebalanceLog.oldApy_withFee` / `newApy_withFee` as the primary APYs in your product UI. Gross fields remain available for debugging or advanced transparency.
</Tip>

<Warning title="amount vs deltaAmount">
  `HistoryPosition.amount` is the **resulting position balance after the action**, not the amount moved by it — it will look like a deposit of the entire position on every `Deposit to protocol` / `Rebalance` / partial withdraw entry. Use **`deltaAmount`** for the amount actually moved by that specific action (deposit, withdraw, or rebalance delta). `deltaAmount` is optional and absent on older history entries predating this field.
</Warning>

## Signature

```typescript theme={null}
getHistory(walletAddress: string, chainId: SupportedChainId, options?: HistoryOptions): Promise<HistoryResponse>
```

## Parameters

| Parameter       | Type               | Required | Description                                                     |
| --------------- | ------------------ | -------- | --------------------------------------------------------------- |
| `walletAddress` | `string`           | ✅        | Smart wallet address                                            |
| `chainId`       | `SupportedChainId` | ✅        | Chain ID                                                        |
| `options`       | `HistoryOptions`   | ❌        | Optional: `{ limit?, offset?, fromDate?, toDate?, assetType? }` |

## Returns

Transaction history with pagination

## Return Type

```typescript theme={null}
interface HistoryResponse {
  success: boolean;
  walletAddress: string;
  data: HistoryEntry[];
  total: number;
}
```

```typescript theme={null}
interface HistoryEntry {
  id?: string;
  action?: string;
  date?: string;
  strategy?: string;
  positions?: HistoryPosition[];
  chainId?: number;
  transactionHash?: string;
  destinationChainId?: number;
  sourceChains?: number[];
  crosschain?: boolean;
  rebalance?: boolean;
  feeData?: HistoryFeeData;
  rebalanceLog?: HistoryRebalanceLog;
  zkProofIpfsHash?: string;
  validationRegistryTxHash?: string;
  validationRegistryChainId?: number;
  validationRegistryAddress?: string;
}
```

```typescript theme={null}
interface HistoryPosition {
  pool?: string;
  amount?: string;
  token_id?: string;
  token_icon?: string;
  amountInUSD?: string;
  protocol_id?: string;
  token_symbol?: string;
  protocol_icon?: string;
  protocol_name?: string;
  deltaAmount?: string;
}

interface HistoryFeeData {
  gasCostInToken?: string;
  gasDeducted?: boolean;
  actualGasCost?: string;
}

interface HistoryRebalanceLog {
  oldApy?: string;
  newApy?: string;
  oldApy_withFee?: string; // SHOW THIS — oldApy × 0.9
  newApy_withFee?: string; // SHOW THIS — newApy × 0.9
  oldOpportunity?: string;
  newOpportunity?: string;
}
```

## Options

```typescript theme={null}
interface HistoryOptions {
  limit?: number;
  offset?: number;
  fromDate?: string;
  toDate?: string;
  assetType?: "usdc" | "eth" | "eurc";
}
```

`assetType` uses the same values as the rest of the SDK. Filter by asset when a chain has mixed USDC / WETH / EURC activity — otherwise the first page can be empty for the asset you care about.

## Example

```typescript theme={null}
const history = await sdk.getHistory("0x...", 8453, {
  limit: 50,
  fromDate: "2024-01-01",
  toDate: "2024-01-31"
});
history.data.forEach(entry => {
  console.log(`Action: ${entry.action}, Date: ${entry.date}`);
  if (entry.rebalanceLog) {
    console.log(
      `  APY ${entry.rebalanceLog.oldApy_withFee} → ${entry.rebalanceLog.newApy_withFee}`
    );
  }
  if (entry.positions) {
    entry.positions.forEach(pos => {
      console.log(`  ${pos.protocol_name} - resulting balance: ${pos.amount}, moved: ${pos.deltaAmount} ${pos.token_symbol}`);
    });
  }
});

// Filter to WETH activity only
const wethHistory = await sdk.getHistory(walletAddress, 8453, {
  limit: 50,
  assetType: "eth",
});
```
