API and Contract Reference
Contract addresses, key function signatures, and integration examples.
Contract Addresses
Anvil (Local Testnet)
Chain ID: 31337 | RPC: http://localhost:8545
| Contract | Address |
|---|---|
| MockWETH | 0x5FbDB2315678afecb367f032d93F642f64180aa3 |
| PoolController | 0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0 |
| StrategyRouter | 0xCf7Ed3AccA5a467e9e704C703E8D87F634fB0Fc9 |
| AIRecommendationCommitment | 0xDc64a140Aa3E981100a9becA4E685f962f0cF6C9 |
| DAOConstraintManager | 0x5FC8d32690cc91D4c39d9d3abcBD16989F875707 |
| Groth16Verifier | 0xa513E6E4b8f2a923D98304ec87F64353C4D5C853 |
| AaveStrategyAdapter | 0x2279B7A0a67DB372996a5FaB50D91eAA73d2eBe6 |
| LidoStrategyAdapter | 0x8A791620dd6260079BF849Dc5567aDC3F2FdC318 |
| CompoundStrategyAdapter | 0x610178dA211FEF7D417bC0e6FeD39F05609AD788 |
⚠️
Addresses Change on Restart
Anvil resets on restart, deploying contracts to new addresses. Check
app/lib/contracts.ts for current addresses, or run the seed script which outputs the new addresses.Key Functions
PoolController
// Deposit wETH with commitment
function deposit(
bytes32 commitment,
uint256 amount
) external returns (uint256 index);
// Withdraw with ZK proof
function withdraw(
bytes32 nullifier,
address recipient,
uint256 amount,
bytes calldata proof
) external;
// Update allocation with AI verification
function updateAllocationWeightsWithAI(
uint256 aaveWeight,
uint256 lidoWeight,
uint256 compoundWeight,
bytes32 commitmentHash
) external onlyAIService;StrategyRouter
// Get current allocation breakdown
function getAllocationBreakdown() external view returns (
uint256 aaveAmount,
uint256 lidoAmount,
uint256 compoundAmount,
uint256 total
);
// Trigger rebalancing
function rebalance() external onlyController;AIRecommendationCommitment
// Commit AI recommendation
function commitRecommendationWithConstraints(
bytes32 commitmentHash,
string[] calldata protocols,
uint256[] calldata percentages,
string calldata riskModel,
string calldata reason,
AIConstraints calldata constraints
) external onlyAIService returns (uint256 recommendationId);
// Verify recommendation matches commitment
function verifyRecommendation(
uint256 recommendationId,
uint256 aaveAllocation,
uint256 lidoAllocation,
uint256 compoundAllocation,
string calldata reason
) external view returns (bool);AI Service API
Base URL: http://localhost:8000 (local) or https://obsqra.fi/ai (hosted)
GET
/risk-score/allGet risk scores for all protocols.
// Response
{
"aave": 32,
"lido": 41,
"compound": 35,
"timestamp": "2025-11-26T..."
}POST
/generate-recommendationGenerate a new allocation recommendation.
// Request
{
"pool_tvl": 100000,
"current_allocations": {"aave": 40000, "lido": 35000, "compound": 25000},
"dao_constraints": null
}POST
/simulate/scenarioTrigger a volatility scenario (demo mode only).
Scenarios: stable, mild_stress, flash_crash,exploit_scare, bull_run
Contract Events
Event
Deposit(bytes32, uint256, uint256)
Contract
PoolController
Description
User deposited funds
Event
Withdraw(bytes32, address, uint256)
Contract
PoolController
Description
User withdrew funds
Event
AllocationUpdated(...)
Contract
StrategyRouter
Description
Funds moved between protocols
Event
AllocationWeightsUpdated(...)
Contract
PoolController
Description
Weights changed
Event
RecommendationCommitted(...)
Contract
AICommitment
Description
AI committed recommendation
Event
AIVerifiedAllocation(...)
Contract
PoolController
Description
AI recommendation executed
| Event | Contract | Description |
|---|---|---|
| Deposit(bytes32, uint256, uint256) | PoolController | User deposited funds |
| Withdraw(bytes32, address, uint256) | PoolController | User withdrew funds |
| AllocationUpdated(...) | StrategyRouter | Funds moved between protocols |
| AllocationWeightsUpdated(...) | PoolController | Weights changed |
| RecommendationCommitted(...) | AICommitment | AI committed recommendation |
| AIVerifiedAllocation(...) | PoolController | AI recommendation executed |
Integration Example
Reading pool state using ethers.js:
import { ethers } from 'ethers';
const provider = new ethers.JsonRpcProvider('http://localhost:8545');
const poolController = new ethers.Contract(
'0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0',
POOL_CONTROLLER_ABI,
provider
);
// Get total deposits
const totalDeposits = await poolController.totalDeposits();
console.log('Total TVL:', ethers.formatEther(totalDeposits));
// Listen for deposits
poolController.on('Deposit', (commitment, amount, index) => {
console.log('New deposit:', ethers.formatEther(amount));
});