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

# customizeBatch

Configure protocol and pool customizations in batch. This provides granular control over which pools to use for each protocol on each chain, enabling advanced yield optimization strategies.

## Signature

```typescript theme={null}
customizeBatch(customizations: CustomizationConfig[]): Promise<CustomizeBatchResponse>
```

## Parameters

```typescript theme={null}
interface CustomizationConfig {
  /** Protocol UUID */
  protocolId: string;

  /** Array of pool names to use (empty array when autoselect is true) */
  pools: string[];

  /** Chain ID (8453 for Base, 42161 for Arbitrum, 1 for Ethereum Mainnet) */
  chainId: number;

  /** Enable automatic pool selection by the rebalance engine */
  autoselect: boolean;
}
```

**Array of Configurations**: Pass an array of `CustomizationConfig` objects to configure multiple protocol/chain combinations at once.

## Returns

```typescript theme={null}
interface CustomizeBatchResponse {
  success: boolean;
}
```

## Getting Protocol IDs

You can get protocol IDs from two sources:

### 1. From getUserDetails()

```typescript theme={null}
const userDetails = await sdk.getUserDetails();

// Access configured protocols with their IDs
userDetails.protocols?.forEach((protocol) => {
  console.log(`${protocol}: ${protocol}`);
});
```

### 2. From getAvailableProtocols()

```typescript theme={null}
const protocolsResponse = await sdk.getAvailableProtocols(8453);

// Get all available protocols for a chain
protocolsResponse.protocols.forEach((protocol) => {
  console.log(`${protocol.name}: ${protocol.id}`);
});
```

## Related Methods

### getAvailablePools

Get available pools for a protocol:

```typescript theme={null}
getAvailablePools(protocolId: string, strategy?: "conservative" | "aggressive"): Promise<GetPoolsResponse>
```

### getSelectedPools

Get currently selected pools for a protocol on a specific chain:

```typescript theme={null}
getSelectedPools(protocolId: string, chainId: number): Promise<GetSelectedPoolsResponse>
```

## Examples

### Basic Pool Configuration

```typescript theme={null}
await sdk.connectAccount(privateKey, chainId);

// Get user details to find protocol IDs
const userDetails = await sdk.getUserDetails();
const morphoProtocolId = userDetails.protocols?.find(
  id => id.includes("morpho")
);

if (morphoProtocolId) {
  // Get available pools for Morpho
  const pools = await sdk.getAvailablePools(morphoProtocolId);
  console.log("Available pools:", pools.pools);

  // Configure specific pools for Morpho on Base
  await sdk.customizeBatch([
    {
      protocolId: morphoProtocolId,
      pools: ["Gauntlet USDC Core", "Steakhouse USDC"],
      chainId: 8453,  // Base
      autoselect: false
    }
  ]);

  console.log("Morpho configured with specific pools on Base");
}
```

### Multi-Chain Configuration

```typescript theme={null}
// Configure the same protocol across multiple chains
const aaveProtocolId = userDetails.protocols?.find(
  id => id.includes("aave")
);

if (aaveProtocolId) {
  await sdk.customizeBatch([
    {
      protocolId: aaveProtocolId,
      pools: ["USDC"],
      chainId: 8453,  // Base - specific pool
      autoselect: false
    },
    {
      protocolId: aaveProtocolId,
      pools: [],
      chainId: 42161,  // Arbitrum - autoselect
      autoselect: true
    },
    {
      protocolId: aaveProtocol.id,
      pools: [],
      chainId: 1,  // Ethereum Mainnet - autoselect
      autoselect: true
    }
  ]);

  console.log("Aave configured across 3 chains");
}
```

### Bulk Configuration

```typescript theme={null}
// Configure multiple protocols at once using getAvailableProtocols
const protocolsResponse = await sdk.getAvailableProtocols(8453);
const customizations = [];

for (const protocol of protocolsResponse.protocols) {
  // Get available pools
  const poolsResponse = await sdk.getAvailablePools(protocol.id);

  // Select first 2 pools or use autoselect
  if (poolsResponse.pools.length > 0) {
    customizations.push({
      protocolId: protocol.id,
      pools: poolsResponse.pools.slice(0, 2),
      chainId: 8453,
      autoselect: false
    });
  } else {
    customizations.push({
      protocolId: protocol.id,
      pools: [],
      chainId: 8453,
      autoselect: true
    });
  }
}

// Apply all customizations at once
await sdk.customizeBatch(customizations);
console.log(`Configured ${customizations.length} protocols`);
```

### Autoselect Mode

```typescript theme={null}
// Enable autoselect for a protocol (let engine choose best pools)
await sdk.customizeBatch([
  {
    protocolId: "protocol-uuid",
    pools: [],  // Empty array when autoselect is true
    chainId: 8453,
    autoselect: true  // Engine will automatically select best pools
  }
]);
```

### Verify Configuration

```typescript theme={null}
// After configuration, verify the settings
const selectedPools = await sdk.getSelectedPools(
  morphoProtocol.id,
  8453
);

console.log("Currently configured:");
console.log("- Autoselect:", selectedPools.autoselect);
console.log("- Pools:", selectedPools.pools);
```

### View All Customizations

```typescript theme={null}
// Get user details to see all customizations
const userDetails = await sdk.getUserDetails();

// The customization field shows all configured pools per protocol per chain
console.log("Customizations:", userDetails.customization);

// Structure:
// {
//   "protocolId": {
//     "chainId": {
//       "pools": ["pool1", "pool2"],
//       "autoselect": false
//     }
//   }
// }
```

## Use Cases

### 1. Target High-APY Pools

```typescript theme={null}
// Get available pools for Morpho
const pools = await sdk.getAvailablePools("morpho-uuid");

// Select pools with highest APY (you'd get APY data separately)
const highApyPools = ["Gauntlet USDC Prime", "Steakhouse High Yield USDC"];

await sdk.customizeBatch([
  {
    protocolId: "morpho-uuid",
    pools: highApyPools,
    chainId: 8453,
    autoselect: false
  }
]);
```

### 2. Risk Management

```typescript theme={null}
// Conservative: Use only verified, low-risk pools
await sdk.customizeBatch([
  {
    protocolId: "aave-uuid",
    pools: ["USDC"],  // Stablecoin only
    chainId: 8453,
    autoselect: false
  }
]);

// Aggressive: Let engine optimize across all pools
await sdk.customizeBatch([
  {
    protocolId: "morpho-uuid",
    pools: [],
    chainId: 8453,
    autoselect: true  // Engine will chase highest yields
  }
]);
```

### 3. Chain-Specific Strategies

```typescript theme={null}
// Different strategies per chain based on liquidity/APY
await sdk.customizeBatch([
  {
    protocolId: "euler-uuid",
    pools: ["Euler Earn USDC", "Euler Arbitrum Yield"],
    chainId: 42161,  // Arbitrum - specific pools
    autoselect: false
  },
  {
    protocolId: "euler-uuid",
    pools: [],
    chainId: 8453,  // Base - autoselect (less liquidity)
    autoselect: true
  }
]);
```

### 4. Dynamic Reallocation

```typescript theme={null}
// Periodically update based on market conditions
async function rebalanceStrategy() {
  const protocolsResponse = await sdk.getAvailableProtocols(8453);

  for (const protocol of protocolsResponse.protocols) {
    // Get latest pools and their performance
    const pools = await sdk.getAvailablePools(protocol.id);

    // Apply your selection logic
    const selectedPools = selectBestPools(pools.pools); // Your logic

    await sdk.customizeBatch([{
      protocolId: protocol.id,
      pools: selectedPools,
      chainId: 8453,
      autoselect: false
    }]);
  }
}

// Run daily or based on APY changes
setInterval(rebalanceStrategy, 24 * 60 * 60 * 1000);
```

## Notes

### Customization Behavior

* Each customization creates or updates a record for the (user, protocol, chain) combination
* Previous customizations for the same combination are overwritten
* The `autoselect` flag determines whether the rebalance engine or specific pools are used
* When `autoselect` is `true`, the `pools` array should be empty

### Getting Pool Names

* Pool names must match exactly as returned by `getAvailablePools()`
* Pool names are case-sensitive
* Invalid pool names will cause the rebalance engine to skip that protocol

### Multi-Chain Considerations

* Configure each chain separately, even for the same protocol
* A protocol may have different pools available on different chains
* Always check `protocol.chains` to see which chains support the protocol

### Autoselect vs Manual

* **Autoselect (`true`)**: Rebalance engine automatically selects best pools based on APY, TVL, and risk
* **Manual (`false`)**: Only the specified pools will be used for that protocol on that chain
* **Recommended**: Use autoselect for most protocols, manual for specific high-conviction pools

### Batch Operations

* All customizations in a batch are processed sequentially
* If one fails, subsequent ones may still succeed
* No transaction rollback - each customization is independent
* Use separate calls if you need atomic operations

### Performance

* Fetching available pools is a read operation (no auth required)
* Batch customization requires authentication
* Large batches (50+ configurations) may take longer to process

## Related Methods

* [updateUserProfile](/docs/sdk/api/update-user-details) - Update strategy and other profile settings
* [getUserDetails](/docs/sdk/api/get-user-details) - View current customizations
* [getAvailableProtocols](/docs/sdk/api/get-available-protocols) - Get available protocols for a chain
