Skip to main content

Getting Started

This guide helps you integrate [Morpho Optimizers](/morpho-optimizers/overview into your project.

The onchain scripts are written in Solidity, and based on the Foundry toolkit. The offchain version is written in Typescript, and based on ethers-v6 library.

Installation

git submodule add https://github.com/morpho-org/morpho-optimizers lib/morpho-org/morpho-optimizers
git submodule add https://github.com/morpho-org/morpho-utils lib/morpho-org/morpho-utils
git submodule add https://github.com/morpho-org/morpho-tokenized-vaults lib/morpho-org/morpho-tokenized-vaults

git submodule add https://github.com/OpenZeppelin/openzeppelin-contracts lib/openzeppelin/contracts
git submodule add https://github.com/OpenZeppelin/openzeppelin-contracts-upgradeable lib/openzeppelin/contracts-upgradeable

If you're using forge, also add the following remapping to remappings.txt:

@morpho-org/=lib/morpho-org@openzeppelin=lib/openzeppelin

Getting Started

Learn how to query & interact with Morpho.

There are two ways to query & interact with Morpho Optimizers:

  1. Onchain using a smart contract,
  2. Offchain, for instance, using ethers.js.

In this section, you will find concrete examples showing how to interact with Morpho Optimizers and how to query information about users!

  • The Morpho protocol is open-source and its source code can be found on the morpho-optimizers repository.
  • It uses utility libraries open-sourced on the morpho-utils repository.

All deployed contracts addresses are available in the deployments glossary in the Links section.

Full code examples

  • Morpho AaveV2 Optimizer & Morpho Compound:
    The complete codebases of the examples provided in this section are also available on the morpho-onchain-examples for Solidity integration and on the morpho-offchain-examples for ethers.js and more generic offchain integration repositories.
  • Morpho AaveV3 Optimizer:
    The examples provided in the following sections are provided in this github repository.

Error Logic

While executing transactions on Morpho contracts, one can fall on unrecognized "custom" errors. More details in the corresponding section.