
bedrockfi
Solid Assets, Liquid Capital
Demo
About
The problem it solves This project develops an autonomous crypto portfolio rebalancing agent that leverages cutting-edge AI from AWS Bedrock and robust decentralized services from Chainlink. Users can benefit from it by automating the tedious and often emotionally-driven task of maintaining their desired cryptocurrency asset allocation. Instead of manually monitoring market fluctuations and executing trades, this system will automatically detect portfolio imbalances (enabled by Chainlink Automation and real-time Chainlink Data Feeds), and then the Bedrock AI agent will intelligently decide on and initiate the necessary rebalancing transactions on the blockchain. This significantly enhances efficiency, reduces the risk of human error or emotional trading, and maintains a user's target risk profile with increased security through AWS KMS for wallet key management and the transparent, tamper-proof nature of blockchain operations.
How it's made
Challenges we ran into It's frustrating when the pieces don't quite connect as expected, especially in a distributed system like this! Building this autonomous rebalancer agent involved navigating several specific hurdles, which are common in the intersection of cloud infrastructure, blockchain, and AI. One significant challenge arose during the AWS CDK deployment phase. Initially, the cdk bootstrap command failed with an AccessDenied error, as the configured IAM user lacked specific CloudFormation permissions like cloudformation:DescribeStacks. This was resolved by ensuring the IAM user had adequate permissions, specifically by attaching the AdministratorAccess managed policy for development purposes. Immediately following, another deployment hurdle appeared: a docker login error indicating "pass not initialized" when the CDK tried to push container images to AWS ECR. This stemmed from Docker's credential helper defaulting to a non-configured pass utility. The solution involved configuring Docker to leverage the amazon-ecr-credential-helper, which seamlessly integrates with existing AWS CLI credentials, streamlining the authentication process. Beyond infrastructure, Solidity smart contract development presented its own set of puzzles. A persistent "Undeclared identifier" error within the RebalancerKeeper.sol contract's performUpkeep function, specifically when calling checkUpkeep, caused compilation failures. This was a nuanced Solidity visibility issue: external functions cannot be called directly within the same contract without explicitly referencing this. The fix required changing checkUpkeep() to this.checkUpkeep(), ensuring the compiler understood it was an external call back to the contract instance. Furthermore, integrating the Chainlink Price Feed brought a TypeError: bad address checksum from ethers.js v6. This was tackled by explicitly passing the Chainlink contract address through ethers.getAddress() in the deployment script, ensuring it conformed to the strict checksum validation enforced by the ethers.js library. Finally, ensuring Chainlink Automation correctly triggered the rebalancing logic proved to be an iterative process. Initially, the RebalancerKeeper's checkUpkeep function, intended to detect portfolio imbalances, wasn't returning true under test conditions. This prevented performUpkeep from ever being called by Chainlink Automation. The immediate workaround involved temporarily forcing checkUpkeep to return true to verify the full Automation-to-Lambda-to-Bedrock pipeline. The long-term solution, currently underway, involves refining the checkUpkeep logic to dynamically read real portfolio balances and Chainlink Price Feeds to intelligently determine when a rebalance is genuinely needed, transforming the system from a forced trigger into an truly intelligent, automated agent.