Skip to main content

Manual trigger of the Public Allocator contract

The PublicAllocator will be automatically triggered by the Morpho Interface if there is insufficient liquidity to facilitate a borrowing transaction.

This section explains how to manually trigger the PublicAllocator contract without going through Morpho's interface.

Prerequisites

  1. Verify that the PublicAllocator contract has the Allocator role on the vault you are expecting to reallocate liquidity from.
  2. Ensure that the vault has specified maxOut and maxIn limits for the markets from which you intend to reallocate liquidity:
    • maxOut is the maximum amount of tokens that can be withdrawn from a specific market.
    • maxIn is the maximum amount of tokens that can be supplied to a specific market.
  3. Order the withdrawals tuples in alphabetical order by market id.
  4. Retrieve the fee that the vault owner set up on the PublicAllocator readme section of the contract by simply pasting the vault address.

Make sure to have the following information:

  • fee in ETH,
  • vault address,
  • withdrawals tuples,
  • supplyMarketParams tuple.

Trigger the PublicAllocator

Example

Assuming that the vault 0x38989bba00bdf8181f4082995b3deae96163ac5d has been set up, we are going to:

  • reallocate 70 WETH from the Idle Market,
  • reallocate 800 WETH from the wstETH/WETH (94.5%) markets,
  • supply those 870 WETH in the rETH/WETH (94.5%) market.
// if the vault owner put `X` ETH as a fee, don't forget to add `X` ETH to the transaction.

{
"vault": "0x38989bba00bdf8181f4082995b3deae96163ac5d",
"withdrawals": [
{
"marketParams": {
"loanToken": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
"collateralToken": "0x0000000000000000000000000000000000000000",
"oracle": "0x0000000000000000000000000000000000000000",
"irm": "0x0000000000000000000000000000000000000000",
"lltv": "0"
},
"amount": "70000000000000000000"
},
{
"marketParams": {
"loanToken": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
"collateralToken": "0x7f39c581f595b53c5cb19bd0b3f8da6c935e2ca0",
"oracle": "0x2a01eb9496094da03c4e364def50f5ad1280ad72",
"irm": "0x870ac11d48b15db9a138cf899d20f13f79ba00bc",
"lltv": "945000000000000000"
},
"amount": "800000000000000000000"
}
],
"supplyMarketParams": {
"loanToken": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
"collateralToken": "0xae78736cd615f374d3085123a210448e74fc6393",
"oracle": "0x1b4a3f92e5fffd1d35a98751c9fe4472483579bb",
"irm": "0x870ac11d48b15db9a138cf899d20f13f79ba00bc",
"lltv": "945000000000000000"
}
}

After the transaction is successfully mined and all conditions are met, you will be able to borrow at least 870 WETH from the rETH/WETH (94.5%) market.