<<<<<<< HEAD python smart contract using vyper, titanoboa and moccasin to automatically rebalance portfolio using usdc and eth.
Automated portfolio rebalancing tool using Moccasin and Aave V3 on Arbitrum. This project simulates token deposit, lending, and rebalancing strategies on a forked mainnet network. This repo is modified version of Cyfrin Updraft's Algorithmic Trading (https://github.com/Cyfrin/mox-algorithmic-trading-cu)
- 🧠 Simulates deposit and withdrawal of USDC and WETH
- 💸 Automatically supplies assets to Aave V3
- 📊 Rebalances portfolio to match target allocations (e.g. 50/50 split)
- ⚙️ Forks live Arbitrum mainnet via Infura for realistic testing
.
├── abis/ # ABI JSON files for contract interaction
├── script/
│ ├── _setup_script.py # Sets up environment, token balances
│ ├── deposit.py # Handles Aave supply interactions
│ ├── rebalance.py # Rebalance logic and price reading
├── .venv/ # Python virtual environment
├── moccasin.toml # Moccasin config file
└── README.md # Project documentationThis project does the following:
- Fork Arbitrum Mainnet and connect using Infura
- Set up test wallet with ETH, USDC, and WETH balances
- Supply assets to Aave V3 lending pool
- Fetch live prices and calculate current allocations
- Rebalance portfolio according to a target ratio
git clone https://github.com/mbahmujono/aether_rebalance_sc.git
cd aether_rebalance_sc
uv venv
uv tool install moccasin
source .venv/bin/activate
uv add moccasin
uv sync
mox run deposit_and_rebalance.pyEnsure you have a working moccasin.toml with:
[default]
rpc_url = "https://arbitrum-mainnet.infura.io/v3/YOUR_INFURA_KEY"
network = "arbitrum-fork"
wallet = "your_wallet"mox run script/_setup_script.py --network arbitrum-fork
mox run script/deposit.py
mox run script/rebalance.py-
BoaError: Unknown contractMake sure you are impersonating a known whale address with token balances on the fork. -
Token Transfer Fails Ensure your ABI files are accurate and that the contract supports the function being called (e.g.
sendValuevstransfer).
Wallet after deposit USDC balance: 0.00 USDC
Wallet after deposit WETH balance: 0.00 WETH
Current aUSDC value: $5000.00
Current aWETH value: $5000.00
Current percent allocation of aUSDC: 50.00%
Current percent allocation of aWETH: 50.00%- Powered by Moccasin by Cyfrin
- Aave V3 lending protocol on Arbitrum
- Titanoboa for simulated Ethereum execution
MIT License
Let me know if you'd like it tailored for public users, educational walkthroughs, or internal fund automation!
>>>>>>> 226b4e4d7ff259904500d9d4188d6d14a35da39b