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
customizeBatch(customizations: CustomizationConfig[]): Promise<CustomizeBatchResponse>
Parameters
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, 9745 for Plasma) */
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
interface CustomizeBatchResponse {
success: boolean;
}
Getting Protocol IDs
You can get protocol IDs from two sources:
1. From getUserDetails()
const userDetails = await sdk.getUserDetails();
// Access configured protocols with their IDs
userDetails.user.protocols.forEach((protocol) => {
console.log(`${protocol.name}: ${protocol.id}`);
});
2. From getProtocols()
const protocolsResponse = await sdk.getProtocols(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:
getAvailablePools(protocolId: string, strategy?: "conservative" | "aggressive"): Promise<GetPoolsResponse>
getSelectedPools
Get currently selected pools for a protocol on a specific chain:
getSelectedPools(protocolId: string, chainId: number): Promise<GetSelectedPoolsResponse>
Examples
Basic Pool Configuration
await sdk.connectAccount(privateKey, chainId);
// Get user details to find protocol IDs
const userDetails = await sdk.getUserDetails();
const morphoProtocol = userDetails.user.protocols.find(
p => p.name === "Morpho"
);
if (morphoProtocol) {
// Get available pools for Morpho
const pools = await sdk.getAvailablePools(morphoProtocol.id);
console.log("Available pools:", pools.pools);
// Configure specific pools for Morpho on Base
await sdk.customizeBatch([
{
protocolId: morphoProtocol.id,
pools: ["Gauntlet USDC Core", "Steakhouse USDC"],
chainId: 8453, // Base
autoselect: false
}
]);
console.log("Morpho configured with specific pools on Base");
}
Multi-Chain Configuration
// Configure the same protocol across multiple chains
const aaveProtocol = userDetails.user.protocols.find(
p => p.name === "Aave V3"
);
if (aaveProtocol) {
await sdk.customizeBatch([
{
protocolId: aaveProtocol.id,
pools: ["USDC"],
chainId: 8453, // Base - specific pool
autoselect: false
},
{
protocolId: aaveProtocol.id,
pools: [],
chainId: 42161, // Arbitrum - autoselect
autoselect: true
},
{
protocolId: aaveProtocol.id,
pools: [],
chainId: 9745, // Plasma - autoselect
autoselect: true
}
]);
console.log("Aave configured across 3 chains");
}
Bulk Configuration
// Configure multiple protocols at once
const customizations = [];
for (const protocol of userDetails.user.protocols) {
// Check if protocol supports the chain
if (protocol.chains.includes(8453)) {
// 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
// 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
// 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
// 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.user.customization);
// Structure:
// {
// "protocolId": {
// "chainId": {
// "pools": ["pool1", "pool2"],
// "autoselect": false
// }
// }
// }
Use Cases
1. Target High-APY Pools
// 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
// 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
// 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: 9745, // Plasma - autoselect (less liquidity)
autoselect: true
}
]);
4. Dynamic Reallocation
// Periodically update based on market conditions
async function rebalanceStrategy() {
const userDetails = await sdk.getUserDetails();
for (const protocol of userDetails.user.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
autoselectflag determines whether the rebalance engine or specific pools are used - When
autoselectistrue, thepoolsarray 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.chainsto 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 - Update strategy and other profile settings
- getUserDetails - View current customizations
- getProtocols - Get available protocols for a chain