# Rebasing Mechanism

### Overview

CeDeFi V2 introduces an advanced rebasing mechanism that automatically reflects yield earnings in token balances, marking a significant improvement over V1. This implementation leverages the ERC-4626 tokenized vault standard to provide a more streamlined and efficient yield distribution system.

### Key Features

* **Automatic Yield Reflection**: Token balances automatically update to reflect earned yield
* **ERC-4626 Compliance**: Implements the standardized tokenized vault interface
* **Flexible Position Management**: Supports partial position modifications and seamless subscription/unsubscription

### Technical Implementation

#### ERC-4626 Integration

The protocol implements the ERC-4626 standard, which provides a standardized interface for tokenized vaults. This offers several advantages:

```solidity
interface IERC4626 is IERC20, IERC20Metadata {
    function asset() external view returns (address assetTokenAddress);
    function totalAssets() external view returns (uint256 totalManagedAssets);
    function convertToShares(uint256 assets) external view returns (uint256 shares);
    function convertToAssets(uint256 shares) external view returns (uint256 assets);
    // ... additional interface methods
}
```

#### Rebasing Mechanism

**How It Works**

1. When yield is generated, it is automatically distributed proportionally to all token holders
2. Token balances increase to reflect the earned yield
3. The underlying asset-to-share ratio is continuously updated

### Advantages Over V1

| Feature                | V1                         | V2                            |
| ---------------------- | -------------------------- | ----------------------------- |
| Yield Distribution     | Manual claim required      | Automatic reflection          |
| Position Management    | All-or-nothing withdrawals | Partial withdrawals supported |
| Standard Compliance    | Custom implementation      | ERC-4626 compliant            |
| Integration Complexity | High                       | Low                           |

### Security Considerations

* All rebasing calculations are performed atomically to prevent exploitation
* Share-to-asset conversions include safety checks against slippage
* Integrators should implement proper decimal handling for share calculations

### Further Resources

* [ERC-4626 Standard Specification](https://eips.ethereum.org/EIPS/eip-4626)
* Technical Audits: [Smart Contract Audit Report](/assets/smart-contract-audit-report.md)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.bouncebit.io/bouncebit-cedefi/cedefi-yield/rebasing-mechanism.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
