> For the complete documentation index, see [llms.txt](https://docs.idle.finance/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.idle.finance/developers/best-yield/methods/rebalance.md).

# rebalance

This method dynamically allocates all the pooled funds across different lending protocols if needed.&#x20;

Everyone should be incentivized in calling this method if they spot an allocation that is not the optimal one.

This method will read allocations set by IdleRebalancer and check if current IdleToken allocations should be updated. It then calculates the exact amount to redeem and mint for each protocol.

In case of low liquidity on a protocol where we are trying to redeem, the rebalance process will try to redeem all the liquidity available, but it won't update the IdleToken allocations. In this way every subsequent rebalance (and also mint and redeem which calls the rebalance method) will try to redeem all the liquidity available at that moment until the correct allocations submitted by IdleRebalancer are enforced.

If a `maxUnlentPerc` is set in the contract this method will lend everything except for a small unlent pool (usually 1%) used for cheap redeems

### Function

```solidity
function rebalance(
) external returns (bool);
```

### **Return values**

<table><thead><tr><th width="299">Value</th><th>Description</th></tr></thead><tbody><tr><td><code>bool</code></td><td>A boolean representing whether a rebalance has been performed or not</td></tr></tbody></table>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.idle.finance/developers/best-yield/methods/rebalance.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
