# 🛠️ How It Works

EZE Finance simplifies decentralized finance (DeFi) by leveraging **AI, smart contracts, and an innovative agent wallet system managed by AI** to automate portfolio management and optimize returns. Below is an explanation of the platform’s workflow, detailing how it operates from start to finish.

***

#### **1. Wallet Connection 🔌**

* The process begins when a user connects their crypto wallet (e.g., MetaMask, WalletConnect) to the EZE Finance platform. This secure connection allows the platform to interact with the user’s assets while maintaining full control of private keys within the user’s primary wallet.

***

#### **2. Agent Wallet Generation 🤖**

Upon connecting their wallet, users generate an **Agent Wallet** , which is uniquely tied to their primary wallet. This Agent Wallet serves as the foundation for automation within the platform:

* The **Agent Wallet** is designed to execute transactions on behalf of the user, such as signing and rebalancing portfolios automatically.
* Each user can only have one Agent Wallet, ensuring transparency and preventing misuse.
* By delegating transaction signing to the Agent Wallet, manual approvals for staking, swapping, and rebalancing are eliminated, streamlining the investment process.

The Agent Wallet leverages **MPC (Multi-Party Computation) technology via the Coinbase SDK** , ensuring secure and trustless transaction signing while maintaining full control of private keys. This advanced cryptographic approach enhances security and eliminates single points of failure, providing users with peace of mind when interacting with decentralized protocols.

***

#### **3. Risk Profiling Questionnaire 📝**

* Users complete a questionnaire to assess their risk tolerance and financial goals. The questionnaire evaluates factors such as investment preferences, time horizon, and comfort with volatility.
* Based on the responses, the platform categorizes users into one of three risk profiles:
  * **Conservative**: Prioritizes capital preservation with stablecoin-focused strategies.
  * **Balanced**: Balances stability and growth with a mix of stablecoins and top-tier cryptocurrencies.
  * **Aggressive**: Targets maximum returns through high-yield, speculative assets.

***

#### **4. AI-Driven Risk Analysis 🎯**

* Using advanced **AI algorithms**, EZE Finance analyzes the questionnaire responses and assigns a risk category: **Low**, **Medium**, or **High**.
* Based on the assigned risk profile, the AI recommends an optimal asset allocation strategy:
  * **Conservative**: Focuses on stablecoins like USDC, USDT, and DAI, targeting the highest yields available in low-risk protocols (e.g., Compound, AAVE, Curve Finance).
  * **Balanced**: Allocates 50% to stablecoins and 50% to top-tier cryptocurrencies like BTC, ETH, SOL, and BNB, prioritizing high APY opportunities.\
    \&#xNAN;*Note: For the current development, the fund allocation is subject to change based on protocol integrations and market conditions.*
  * **Aggressive**: Targets the highest APY protocols, including speculative coins and volatile assets, for aggressive growth.

***

#### **5. Token Staking via Agent Wallet 💰**

* Once the AI provides its recommendations, the tokens required for the chosen strategy are staked automatically through the agent wallet.
  * If the user does not currently hold the specified tokens, they can be swapped for the required assets using the platform’s **"Swap" functionality**.
  * Behind the scenes, the tokens are transferred to the agent wallet, which then stakes them in the intended DeFi protocols. This ensures seamless execution of staking and rebalancing actions without requiring manual intervention from the user.

***

#### **6. Portfolio Monitoring and Withdrawals 📊**

* Users can monitor their investments through the **"Dashboard" page**, which provides real-time insights into portfolio performance. Key metrics displayed include:
  * Total investment amount.
  * Profit and loss metrics.
  * Asset allocation breakdown.
  * Transaction history.
* The dashboard also facilitates withdrawals, with funds returned directly to the user’s primary wallet whenever they choose to liquidate their position.

***

#### **7. Dynamic Rebalancing ⚖️**

EZE Finance incorporates an **automated rebalancing feature** powered by the  agent wallet, which adjusts the portfolio based on real-time market conditions while remaining firmly aligned with the user’s risk profile.

* In times of increased volatility, the AI wallet may shift assets to lower-risk strategies within the same risk category to preserve capital and maintain stability.
* Conversely, when high-yield opportunities arise, the AI wallet automatically reallocates funds to capture the highest possible APY, ensuring optimal returns without deviating from the user’s chosen risk profile.

This dynamic rebalancing ensures that the portfolio is always optimized for maximum yield within the constraints of the user’s risk tolerance, maintaining alignment with their financial goals.

***

#### **Note:**

* For the purposes of this hackathon, the **Agent Wallet's private and public keys** are stored on a local VPS (pending OPSEC implementation) server.
* For the purposes of this hackathon, we are using **mock tokens** to simulate transactions and interactions within the platform.

<br>
