curl -X POST "https://partners-backend-1038109371738.europe-west1.run.app/api/v1/optimizer/8453/optimize" \
-H "Content-Type: application/json" \
-H "X-Partner-API-Key: your-api-key" \
-H "X-Partner-Name: your-partner-name" \
-d '{
"total_capital": "1000000000",
"token_address": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
"current_allocations": {
"aave": "500000000",
"compound": "500000000"
},
"protocols": ["aave", "compound", "moonwell", "fluid"],
"wallet_address": "0x1234567890123456789012345678901234567890"
}'
curl -X POST "https://partners-backend-1038109371738.europe-west1.run.app/api/v1/optimizer/8453/optimize" \
-H "Content-Type: application/json" \
-H "X-Partner-API-Key: your-api-key" \
-H "X-Partner-Name: your-partner-name" \
-d '{
"total_capital": "1000000000",
"token_address": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
"current_allocations": {
"aave": "500000000",
"compound": "500000000"
},
"protocols": ["aave", "compound", "moonwell", "fluid"],
"wallet_address": "0x1234567890123456789012345678901234567890",
"constraints": [
{ "kind": "min_protocols", "params": { "min_protocols": 2 } },
{ "kind": "max_amount_per_protocol", "params": { "protocol": "aave", "max_ratio": 0.5 } },
{ "kind": "max_amount_per_protocol", "params": { "protocol": "compound", "max_ratio": 0.5 } },
{ "kind": "max_amount_per_protocol", "params": { "protocol": "moonwell", "max_ratio": 0.5 } },
{ "kind": "max_amount_per_protocol", "params": { "protocol": "fluid", "max_ratio": 0.5 } }
]
}'
const response = await fetch(
'https://partners-backend-1038109371738.europe-west1.run.app/api/v1/optimizer/8453/optimize',
{
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-Partner-API-Key': 'your-api-key',
'X-Partner-Name': 'your-partner-name',
},
body: JSON.stringify({
total_capital: '1000000000',
token_address: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913',
current_allocations: {
aave: '500000000',
compound: '500000000',
},
protocols: ['aave', 'compound', 'moonwell', 'fluid'],
wallet_address: '0x1234567890123456789012345678901234567890',
constraints: [
{ kind: 'min_protocols', params: { min_protocols: 2 } },
{ kind: 'max_amount_per_protocol', params: { protocol: 'fluid', max_ratio: 0.5 } }
]
}),
}
);
const data = await response.json();
import requests
response = requests.post(
'https://partners-backend-1038109371738.europe-west1.run.app/api/v1/optimizer/8453/optimize',
headers={
'X-Partner-API-Key': 'your-api-key',
'X-Partner-Name': 'your-partner-name',
},
json={
'total_capital': '1000000000',
'token_address': '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913',
'current_allocations': {
'aave': '500000000',
'compound': '500000000',
},
'protocols': ['aave', 'compound', 'moonwell', 'fluid'],
'wallet_address': '0x1234567890123456789012345678901234567890',
'constraints': [
{'kind': 'min_protocols', 'params': {'min_protocols': 2}},
{'kind': 'max_amount_per_protocol', 'params': {'protocol': 'fluid', 'max_ratio': 0.5}}
]
}
)
data = response.json()
{
"optimization_result": {
"allocations": [
{
"protocol": "aave",
"allocation": "700000000",
"apr": 5.5
},
{
"protocol": "compound",
"allocation": "300000000",
"apr": 4.8
}
],
"total_costs": 0.05,
"weighted_apr_initial": 5.0,
"weighted_apr_final": 5.29,
"apr_improvement": 5.8,
"gas_estimate_usd": 2.50,
"break_even_days": 15.3
},
"action_plan": [
{
"action_type": "withdraw",
"protocol": "compound",
"amount": "200000000",
"underlying_amount": "200000000"
},
{
"action_type": "deposit",
"protocol": "aave",
"amount": "200000000"
}
],
"calldata": [
{
"contract_address": "0xA88594D404727625A9437C3f886C7643872296AE",
"function_name": "withdraw",
"parameters": ["200000000"],
"value": "0",
"protocol": "compound",
"description": "Withdraw 200000000 from Compound"
},
{
"contract_address": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
"function_name": "approve",
"parameters": ["0x9c4ec768c28520B50860ea7a15bd7213a9fF58bf", "200000000"],
"value": "0",
"protocol": "aave",
"description": "Approve USDC for Aave"
},
{
"contract_address": "0x9c4ec768c28520B50860ea7a15bd7213a9fF58bf",
"function_name": "supply",
"parameters": ["0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", "200000000", "0x0000000000000000000000000000000000000000", "0"],
"value": "0",
"protocol": "aave",
"description": "Deposit 200000000 to Aave"
}
]
}
{
"detail": "Invalid input parameters"
}
Optimizer
Optimize Allocations
Calculate optimal capital allocation across protocols
POST
/
api
/
v1
/
optimizer
/
{chain_id}
/
optimize
curl -X POST "https://partners-backend-1038109371738.europe-west1.run.app/api/v1/optimizer/8453/optimize" \
-H "Content-Type: application/json" \
-H "X-Partner-API-Key: your-api-key" \
-H "X-Partner-Name: your-partner-name" \
-d '{
"total_capital": "1000000000",
"token_address": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
"current_allocations": {
"aave": "500000000",
"compound": "500000000"
},
"protocols": ["aave", "compound", "moonwell", "fluid"],
"wallet_address": "0x1234567890123456789012345678901234567890"
}'
curl -X POST "https://partners-backend-1038109371738.europe-west1.run.app/api/v1/optimizer/8453/optimize" \
-H "Content-Type: application/json" \
-H "X-Partner-API-Key: your-api-key" \
-H "X-Partner-Name: your-partner-name" \
-d '{
"total_capital": "1000000000",
"token_address": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
"current_allocations": {
"aave": "500000000",
"compound": "500000000"
},
"protocols": ["aave", "compound", "moonwell", "fluid"],
"wallet_address": "0x1234567890123456789012345678901234567890",
"constraints": [
{ "kind": "min_protocols", "params": { "min_protocols": 2 } },
{ "kind": "max_amount_per_protocol", "params": { "protocol": "aave", "max_ratio": 0.5 } },
{ "kind": "max_amount_per_protocol", "params": { "protocol": "compound", "max_ratio": 0.5 } },
{ "kind": "max_amount_per_protocol", "params": { "protocol": "moonwell", "max_ratio": 0.5 } },
{ "kind": "max_amount_per_protocol", "params": { "protocol": "fluid", "max_ratio": 0.5 } }
]
}'
const response = await fetch(
'https://partners-backend-1038109371738.europe-west1.run.app/api/v1/optimizer/8453/optimize',
{
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-Partner-API-Key': 'your-api-key',
'X-Partner-Name': 'your-partner-name',
},
body: JSON.stringify({
total_capital: '1000000000',
token_address: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913',
current_allocations: {
aave: '500000000',
compound: '500000000',
},
protocols: ['aave', 'compound', 'moonwell', 'fluid'],
wallet_address: '0x1234567890123456789012345678901234567890',
constraints: [
{ kind: 'min_protocols', params: { min_protocols: 2 } },
{ kind: 'max_amount_per_protocol', params: { protocol: 'fluid', max_ratio: 0.5 } }
]
}),
}
);
const data = await response.json();
import requests
response = requests.post(
'https://partners-backend-1038109371738.europe-west1.run.app/api/v1/optimizer/8453/optimize',
headers={
'X-Partner-API-Key': 'your-api-key',
'X-Partner-Name': 'your-partner-name',
},
json={
'total_capital': '1000000000',
'token_address': '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913',
'current_allocations': {
'aave': '500000000',
'compound': '500000000',
},
'protocols': ['aave', 'compound', 'moonwell', 'fluid'],
'wallet_address': '0x1234567890123456789012345678901234567890',
'constraints': [
{'kind': 'min_protocols', 'params': {'min_protocols': 2}},
{'kind': 'max_amount_per_protocol', 'params': {'protocol': 'fluid', 'max_ratio': 0.5}}
]
}
)
data = response.json()
{
"optimization_result": {
"allocations": [
{
"protocol": "aave",
"allocation": "700000000",
"apr": 5.5
},
{
"protocol": "compound",
"allocation": "300000000",
"apr": 4.8
}
],
"total_costs": 0.05,
"weighted_apr_initial": 5.0,
"weighted_apr_final": 5.29,
"apr_improvement": 5.8,
"gas_estimate_usd": 2.50,
"break_even_days": 15.3
},
"action_plan": [
{
"action_type": "withdraw",
"protocol": "compound",
"amount": "200000000",
"underlying_amount": "200000000"
},
{
"action_type": "deposit",
"protocol": "aave",
"amount": "200000000"
}
],
"calldata": [
{
"contract_address": "0xA88594D404727625A9437C3f886C7643872296AE",
"function_name": "withdraw",
"parameters": ["200000000"],
"value": "0",
"protocol": "compound",
"description": "Withdraw 200000000 from Compound"
},
{
"contract_address": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
"function_name": "approve",
"parameters": ["0x9c4ec768c28520B50860ea7a15bd7213a9fF58bf", "200000000"],
"value": "0",
"protocol": "aave",
"description": "Approve USDC for Aave"
},
{
"contract_address": "0x9c4ec768c28520B50860ea7a15bd7213a9fF58bf",
"function_name": "supply",
"parameters": ["0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", "200000000", "0x0000000000000000000000000000000000000000", "0"],
"value": "0",
"protocol": "aave",
"description": "Deposit 200000000 to Aave"
}
]
}
{
"detail": "Invalid input parameters"
}
SDK Alternative: Use
giza.optimize(options) for a simpler TypeScript interface. See SDK docsDescription
Calculates the optimal capital allocation across DeFi lending protocols. Returns the optimal allocation, an action plan to achieve it, and execution-ready calldata. This endpoint is the core of the IaaS (Intelligence as a Service) integration.Path Parameters
Request Body
Current allocations by protocol (protocol name → amount as bigint string)Example:
{"aave": "500000000", "compound": "500000000"}Optional constraints for optimization. Each constraint is an object with
Example:
kind and params.Constraint types and required parameters:| Kind | Params | Description |
|---|---|---|
min_protocols | min_protocols (int), min_fraction_per_protocol (float, optional) | Minimum number of protocols to use |
max_amount_per_protocol | protocol (string), max_ratio (float 0-1) | Cap a protocol at a percentage of total capital |
max_allocation_amount_per_protocol | protocol (string), max_amount (int) | Cap a protocol at an absolute amount |
min_amount | min_amount (int) | Minimum amount for any used protocol |
min_allocation_amount_per_protocol | protocol (string), min_amount (int) | Minimum amount for a specific protocol |
exclude_protocol | protocol (string) | Exclude a protocol from optimization |
[
{ "kind": "min_protocols", "params": { "min_protocols": 2 } },
{ "kind": "max_amount_per_protocol", "params": { "protocol": "aave", "max_ratio": 0.5 } },
{ "kind": "exclude_protocol", "params": { "protocol": "compound" } }
]
Optional wallet address that will execute the transactions.
Example:
"0x1234567890123456789012345678901234567890"Response
Optimization results
Show child attributes
Show child attributes
curl -X POST "https://partners-backend-1038109371738.europe-west1.run.app/api/v1/optimizer/8453/optimize" \
-H "Content-Type: application/json" \
-H "X-Partner-API-Key: your-api-key" \
-H "X-Partner-Name: your-partner-name" \
-d '{
"total_capital": "1000000000",
"token_address": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
"current_allocations": {
"aave": "500000000",
"compound": "500000000"
},
"protocols": ["aave", "compound", "moonwell", "fluid"],
"wallet_address": "0x1234567890123456789012345678901234567890"
}'
curl -X POST "https://partners-backend-1038109371738.europe-west1.run.app/api/v1/optimizer/8453/optimize" \
-H "Content-Type: application/json" \
-H "X-Partner-API-Key: your-api-key" \
-H "X-Partner-Name: your-partner-name" \
-d '{
"total_capital": "1000000000",
"token_address": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
"current_allocations": {
"aave": "500000000",
"compound": "500000000"
},
"protocols": ["aave", "compound", "moonwell", "fluid"],
"wallet_address": "0x1234567890123456789012345678901234567890",
"constraints": [
{ "kind": "min_protocols", "params": { "min_protocols": 2 } },
{ "kind": "max_amount_per_protocol", "params": { "protocol": "aave", "max_ratio": 0.5 } },
{ "kind": "max_amount_per_protocol", "params": { "protocol": "compound", "max_ratio": 0.5 } },
{ "kind": "max_amount_per_protocol", "params": { "protocol": "moonwell", "max_ratio": 0.5 } },
{ "kind": "max_amount_per_protocol", "params": { "protocol": "fluid", "max_ratio": 0.5 } }
]
}'
const response = await fetch(
'https://partners-backend-1038109371738.europe-west1.run.app/api/v1/optimizer/8453/optimize',
{
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-Partner-API-Key': 'your-api-key',
'X-Partner-Name': 'your-partner-name',
},
body: JSON.stringify({
total_capital: '1000000000',
token_address: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913',
current_allocations: {
aave: '500000000',
compound: '500000000',
},
protocols: ['aave', 'compound', 'moonwell', 'fluid'],
wallet_address: '0x1234567890123456789012345678901234567890',
constraints: [
{ kind: 'min_protocols', params: { min_protocols: 2 } },
{ kind: 'max_amount_per_protocol', params: { protocol: 'fluid', max_ratio: 0.5 } }
]
}),
}
);
const data = await response.json();
import requests
response = requests.post(
'https://partners-backend-1038109371738.europe-west1.run.app/api/v1/optimizer/8453/optimize',
headers={
'X-Partner-API-Key': 'your-api-key',
'X-Partner-Name': 'your-partner-name',
},
json={
'total_capital': '1000000000',
'token_address': '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913',
'current_allocations': {
'aave': '500000000',
'compound': '500000000',
},
'protocols': ['aave', 'compound', 'moonwell', 'fluid'],
'wallet_address': '0x1234567890123456789012345678901234567890',
'constraints': [
{'kind': 'min_protocols', 'params': {'min_protocols': 2}},
{'kind': 'max_amount_per_protocol', 'params': {'protocol': 'fluid', 'max_ratio': 0.5}}
]
}
)
data = response.json()
{
"optimization_result": {
"allocations": [
{
"protocol": "aave",
"allocation": "700000000",
"apr": 5.5
},
{
"protocol": "compound",
"allocation": "300000000",
"apr": 4.8
}
],
"total_costs": 0.05,
"weighted_apr_initial": 5.0,
"weighted_apr_final": 5.29,
"apr_improvement": 5.8,
"gas_estimate_usd": 2.50,
"break_even_days": 15.3
},
"action_plan": [
{
"action_type": "withdraw",
"protocol": "compound",
"amount": "200000000",
"underlying_amount": "200000000"
},
{
"action_type": "deposit",
"protocol": "aave",
"amount": "200000000"
}
],
"calldata": [
{
"contract_address": "0xA88594D404727625A9437C3f886C7643872296AE",
"function_name": "withdraw",
"parameters": ["200000000"],
"value": "0",
"protocol": "compound",
"description": "Withdraw 200000000 from Compound"
},
{
"contract_address": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
"function_name": "approve",
"parameters": ["0x9c4ec768c28520B50860ea7a15bd7213a9fF58bf", "200000000"],
"value": "0",
"protocol": "aave",
"description": "Approve USDC for Aave"
},
{
"contract_address": "0x9c4ec768c28520B50860ea7a15bd7213a9fF58bf",
"function_name": "supply",
"parameters": ["0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", "200000000", "0x0000000000000000000000000000000000000000", "0"],
"value": "0",
"protocol": "aave",
"description": "Deposit 200000000 to Aave"
}
]
}
{
"detail": "Invalid input parameters"
}