> For the complete documentation index, see [llms.txt](https://midgardfinance.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://midgardfinance.gitbook.io/docs/basics/editor/bonding.md).

# Bonding

<figure><img src="/files/2ManR0Wm4KDSaPdLwEJF" alt=""><figcaption><p>Overview of Bonding/Staking/Treasury/AI Agents Adjustment</p></figcaption></figure>

**Conceptual Overview:** Bonding allows participants to provide assets (e.g., DAI, USDC) to the protocol's treasury in exchange for MID tokens at a bond price. This price can be above or below $1, resulting in either a premium or a discount. By doing so, bonding:

* Brings stable collateral into the treasury.
* Ensures that newly issued MID always aligns with tangible value.
* Enables the protocol to accumulate premiums when bond prices exceed $1, supporting MID’s intrinsic value and potentially maintaining its price above $1.

Bonding is thus a critical mechanism for controlling MID’s supply, managing asset inflows, and stabilizing or enhancing the token’s baseline value.

***

#### Basic Mathematical Representations

1. **Bond Price (( B )):** Let ( P\_{current} ) be the current MID price and ( P\_{target} \approx 1 ) the goal. AI agents use a formula inspired by OlympusDAO models and then apply their own adjustments:

   $$
   B = B\_{base} + \alpha (P\_{target} - P\_{current})
   $$

   * If ( B > 1 ), participants pay more than $1 in collateral per MID, generating a premium.
   * If ( B < 1 ), they get a discount, paying less than $1 in collateral per MID.

   The coefficient (\alpha) and any additional parameters (like BCV - Bond Control Variable) are managed by AI agents to maintain equilibrium.
2. **MID Issuance Through Bonding:** When a user deposits ( X ) units of a stable asset (e.g., DAI), and the bond price is ( B ):

   $$
   \text{MID received} = \frac{X}{B}
   $$

   * For ( B = 1.05 ): ( \frac{X}{1.05} ) MID issued, yielding a $0.05 premium per MID to the treasury.
   * For ( B = 0.95 ): ( \frac{X}{0.95} ) MID issued, but the protocol effectively accepts a discount, attracting more stable assets to increase supply of MID.
3. **Treasury and Premium Accumulation:** The total premium accumulated from bonding (when ( B > 1 )) can be represented as:

   $$
   \text{Total Premium} = \sum (B - 1) \times \text{MID issued}
   $$

   This premium strengthens the treasury, allowing the system to support staking rewards and potentially keeping MID’s value above $1.

***

### Bonding Process: Detailed Sequence

Below is a step-by-step outline of the bonding process. This sequence assumes the protocol is running, AI agents are active, and users have stable assets (e.g., DAI) ready. It shows how a user interacts with the system, how the system determines the bond price, how the vesting applies, and how AI agents continuously influence parameters.

<figure><img src="/files/Hd2gwuqi7PMEjdQjAEEU" alt=""><figcaption></figcaption></figure>

***

### **Step-by-Step Description**

1. **User Decision to Bond:**
   * A user observes that bonding currently offers MID at a certain bond price.
   * They check the current bond price ( B ), vesting period (7 days), and whether the bond price is at a discount or premium.
   * The user’s goal: Acquire MID at a potentially advantageous rate, expecting stable or even premium-supported value over time.
2. **User Provides Assets:**
   * The user selects an asset (e.g., 1,000 DAI) and initiates the bonding transaction.
   * This transaction is submitted on-chain and sent to the bonding contract.
3. **Bonding Contract Interacts with Treasury & AI Agents:**
   * The bonding smart contract consults current protocol parameters.
   * AI agents have already determined a suitable bond price ( B ) based on:
     * Current MID price ( Pcurrent )
     * Debt ratio (how much MID is outstanding vs. treasury value)
     * BCV and other parameters
   * The bond price ( B ) might follow a formula like:

     $$
     B = \text{Base Price} + (\text{Debt Ratio} \times \text{BCV})
     $$
   * AI agents continuously update BCV or fine-tune other inputs so that ( B ) reflects real-time conditions.
4. **Calculating MID Allocation:**
   * Once the user’s Stable Coin is received, the contract determines how many MID the user will eventually get.
   * For example, if ( B = 1.05 ) and the user provides 1,000 DAI:
     * The user effectively purchases MID at $1.05 each.
     * They receive ( \frac{1000}{1.05} \approx 952.38 ) MID in total, subject to the vesting schedule.
   * If ( B < 1 ), the user gets more MID than the number of dollars they spent, representing a discount.
   * If ( B = 1 ), it’s a neutral exchange: 1,000 DAI for 1,000 MID over time.
5. **7-Day Vesting Application:**
   * The user’s allocated MID is not instantly claimable.
   * A 7-day vesting period applies, meaning each day a portion of the MID becomes redeemable.
   * This schedule prevents immediate flipping of newly bonded MID into the market, reducing volatility and price shocks.
6. **Redemption Over Time:**
   * Each day, the user may claim the unlocked portion of their MID from the contract.
   * After 7 days, the user has full access to all bonded MID.
   * If the price of MID remains stable or above $1 (due to premiums captured by bonding or AI-driven adjustments), the user can hold, stake, or sell their MID at a favorable scenario.
7. **Treasury and Market Impact:**
   * The treasury now holds the user’s 1,000 DAI.
   * If the bond price was above $1, a premium was effectively generated, strengthening the treasury’s value per MID.
   * If below $1, the protocol attracted more stable assets at a discount, to inscrease supply of  MID.
   * AI agents monitor these changes and may adjust future bond prices, staking APY, or supply parameters based on the new data.
8. **Continuous AI Adjustments:**
   * Post-bonding, AI agents re-evaluate conditions:
     * If too much MID is entering circulation, they might increase bond prices or reduce staking APY to prevent oversupply.
     * If price deviates below $1, buy back MID to restore equilibrium.
   * These ongoing loops ensure that bonding remains a dynamic, feedback-driven process, always aiming to keep MID at or above $1 in intrinsic value.

***
