Skip to main content

Set Up as Allocator

Overview

As the vault curator of a Morpho Vault (formerly known as MetaMorpho), you can designate the PublicAllocator address as an allocator of the vault. This will allow borrowers or Morpho's interface to trigger reallocations, amplifying the available liquidity for end users while limiting the flow of tokens that can be supplied or withdrawn from a market listed in the vault.

Prerequisites

Jump on the Morpho Vault contract you are curating and follow the instructions.

As a curator of your own vault, provide the allocator role to the PublicAllocator contract as described in this section, via the setIsAllocator function (0xNewAllocator, true).

Providing the allocator role to the PublicAllocator contract on the Morpho Vault contract

Now you can jump on the PublicAllocator contract to set it up.

Setting an admin

By default, only the owner of the vault can configure the PublicAllocator for a given vault. However, the owner can appoint an additional admin by triggering the setAdmin function.

Setting the fee

The PublicAllocator has a fee that is charged on every reallocation. The fee is paid in ETH and can be changed at any time by the owner of the vault or the admin by triggering the setFee function.

This fee prevents griefing attacks and helps the vault curators to cover the gas costs reallocations in the case the reallocation through the PublicAllocator has created an imbalance.

Setting the flow caps

Flow caps determine the maximum amount of tokens that can be supplied or withdrawn from a market listed in the vault. The flow caps can be set by the owner of the vault or the admin for a specific market by triggering the setFlowCap function.

A flow cap is composed of the maxIn and maxOut in this order. The maxIn is the maximum amount of tokens that can be supplied to a market and the maxOut is the maximum amount of tokens that can be withdrawn from a market.

For example, if amount x is withdrawn from a market during reallocation, the market's maxIn increases by x, while maxOut decreases by x. Conversely, if x is supplied to the market, maxIn decreases by x and maxOut increases by x.

This mechanism helps maintain balance and limits excessive token flows in and out of the market.

setFlowCap example

Assume that the vault has the following markets:

  • 0xc54d7acf14de29e0e5527cabd7a576506870346a78a11a6762e2cca66322ec41
  • 0x58e212060645d18eab6d9b2af3d56fbc906a92ff5667385f616f662c70372284
  • 0x3c83f77bde9541f8d3d82533b19bbc1f97eb2f1098bb991728acbfbede09cc5d

Consider the following input for the setFlowCap function as an example:

[
{
"id": "0xc54d7acf14de29e0e5527cabd7a576506870346a78a11a6762e2cca66322ec41", // wstETH/WETH (94.5%)
"caps": {
"maxIn": "199000000000000000000", // 199 WETH
"maxOut": "199000000000000000000" // 199 WETH
}
},
{
"id": "0x58e212060645d18eab6d9b2af3d56fbc906a92ff5667385f616f662c70372284", // wstETH/WETH (96.5%)
"caps": {
"maxIn": "0", // 0 WETH
"maxOut": "459000000000000000000" // 459 WETH
}
},
{
"id": "0x3c83f77bde9541f8d3d82533b19bbc1f97eb2f1098bb991728acbfbede09cc5d", // rETH/WETH (94.5%)
"caps": {
"maxIn": "500000000000000000000", // 500 WETH
"maxOut": "150000000000000000000" // 15 WETH
}
}
]

Corresponding Etherscan input below:

[["0xc54d7acf14de29e0e5527cabd7a576506870346a78a11a6762e2cca66322ec41", ["199000000000000000000", "199000000000000000000"]], ["0x58e212060645d18eab6d9b2af3d56fbc906a92ff5667385f616f662c70372284", ["0", "459000000000000000000"]], ["0x3c83f77bde9541f8d3d82533b19bbc1f97eb2f1098bb991728acbfbede09cc5d", ["500000000000000000000", "150000000000000000000"]]]