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

# Allocations

> AllocationsAPI — Query positions and earnings

## AllocationsAPI

Access via `client.allocations`.

### list

List all allocations for a wallet. Accepts `walletId`, `walletAddress`, or `userId`.

```typescript theme={null}
async list(query: AllocationListRequest | AllocationQuery): Promise<AllocationListResponse>
```

```typescript theme={null}
interface AllocationListRequest {
  /** Wallet address */
  walletAddress?: string;
  /** Wallet ID from registration */
  walletId?: number;
  /** External user ID */
  userId?: string;
  /** Filter by blockchain */
  blockchain?: 'solana' | 'polygon' | 'ethereum' | 'base';
}

interface AllocationListResponse {
  allocations: Allocation[];
  totalValue: string;
  totalYieldEarned: string;
}
```

### get

Get allocation by strategy ID. Pass wallet address (string) or wallet ID (number).

```typescript theme={null}
async get(strategyId: number, wallet: string | number): Promise<Allocation>
```

### earnings

Get historical earnings data. Identify the wallet with `walletAddress`, `walletId`, or `userId`.

```typescript theme={null}
async earnings(query: EarningsQuery): Promise<EarningsResponse>
```

```typescript theme={null}
interface EarningsQuery {
  walletAddress?: string;
  walletId?: number;
  userId?: string;
  blockchain: 'solana' | 'polygon' | 'ethereum' | 'base';
  token: string;
  days?: number;
  includeBreakdown?: boolean;
}

interface EarningsResponse {
  walletAddress: string;
  blockchain: string;
  token: string;
  periodStart: string;
  periodEnd: string;
  firstActivityDate: string | null;
  totalYieldEarned: string;
  totalYieldEarnedUsd: string;
  history: EarningsDay[];
  byVenue?: VenueEarnings[];
}

interface EarningsDay {
  date: string;
  yieldEarned: string;
  yieldEarnedUsd: string;
  cumulativeYield: string;
  positionValue: string;
}

interface VenueEarnings {
  venueId: number;
  venueName: string;
  totalYieldEarned: string;
  totalYieldEarnedUsd: string;
  history: { date: string; yieldEarned: string; yieldEarnedUsd: string }[];
}
```

### overview

Get org-level overview of all wallet allocations. Returns aggregate metrics scoped to the wallet profile associated with your API key.

```typescript theme={null}
async overview(): Promise<OrgOverview>
```

```typescript theme={null}
interface OrgOverview {
  /** Wallet profile ID */
  walletProfileId: number;
  /** Wallet profile name */
  walletProfileName: string;
  /** Total number of wallets */
  totalWallets: number;
  /** Wallets with active allocations */
  activeWallets: number;
  /** Total value across all wallets (USD) */
  totalValueUsd: string;
  /** Total yield earned across all wallets (USD) */
  totalYieldEarnedUsd: string;
  /** Weighted average APY as decimal (e.g., 0.065 for 6.5%) */
  averageApyDecimal: number;
  /** Breakdown by protocol */
  protocolDistribution: DistributionEntry[];
  /** Breakdown by token */
  assetDistribution: DistributionEntry[];
  /** Breakdown by blockchain */
  blockchainDistribution: DistributionEntry[];
}

interface DistributionEntry {
  /** Protocol name, token symbol, or blockchain name */
  name: string;
  /** Total value in USD */
  valueUsd: string;
  /** Percentage of total value (0-100) */
  percentage: number;
  /** Number of wallets in this category */
  walletCount: number;
}
```

### overviewAll

Get aggregate overview across all wallet profiles. Requires an admin API key.
Optionally filter to a specific profile by passing `walletProfileId`.

```typescript theme={null}
async overviewAll(walletProfileId?: number): Promise<OrgOverviewAll>
```

```typescript theme={null}
interface OrgOverviewAll {
  /** Per-profile overview breakdown */
  profiles: OrgOverview[];
  /** Aggregated totals across all profiles */
  totals: OrgOverviewTotals;
}

interface OrgOverviewTotals {
  totalWallets: number;
  activeWallets: number;
  totalValueUsd: string;
  totalYieldEarnedUsd: string;
  averageApyDecimal: number;
  protocolDistribution: DistributionEntry[];
  assetDistribution: DistributionEntry[];
  blockchainDistribution: DistributionEntry[];
}
```

### Allocation Type

```typescript theme={null}
interface Allocation {
  strategyId: number;
  strategyName: string;
  venueId: number;
  venueName: string;
  walletAddress: string;
  blockchain: 'solana' | 'polygon' | 'ethereum' | 'base';
  token: string;
  tokenAddress: string;
  principal: string;
  currentValue: string;
  yieldEarned: string;
  apy: number;
  lastUpdated: string;
}
```
