Rebalancing

Whitelisting

Before rebalancing, the chosen contract to interact with must be whitelisted.

https://github.com/mangrovedao/mangrove-vault/blob/899abdb187f1801ba44621c0e25a697edda859e7/src/MangroveVault.sol#L699

This of course can be reverted here:

https://github.com/mangrovedao/mangrove-vault/blob/899abdb187f1801ba44621c0e25a697edda859e7/src/MangroveVault.sol#L717

Rebalance

In order to rebalance, you should build the calldata in order to swap, and pass the target. Slippage protection can be enforced. To put trust towards user, a slippage protection relative to the current oracle price can be set.

https://github.com/mangrovedao/mangrove-vault/blob/899abdb187f1801ba44621c0e25a697edda859e7/src/MangroveVault.sol#L881-L886

The rebalancing can then be done via this function:

https://github.com/mangrovedao/mangrove-vault/blob/899abdb187f1801ba44621c0e25a697edda859e7/src/MangroveVault.sol#L744-L748

or be accompanied by a position change like this:

https://github.com/mangrovedao/mangrove-vault/blob/899abdb187f1801ba44621c0e25a697edda859e7/src/MangroveVault.sol#L765-L772

Last updated

Was this helpful?