Skip to content

General Adapter 1

0xd2B9667F5214115E27937C410cAeE83E3a901Df7 | Git Source

Inherits: CoreAdapter

State Variables

MORPHO

The address of the Morpho contract.

solidity
IMorpho public immutable MORPHO

WRAPPED_NATIVE

The address of the wrapped native token.

solidity
IWNative public immutable WRAPPED_NATIVE

Functions

constructor

solidity
constructor(address bundler3, address morpho, address wNative) CoreAdapter(bundler3);

Parameters

NameTypeDescription
bundler3addressThe address of the Bundler3 contract.
morphoaddressThe address of the Morpho protocol.
wNativeaddressThe address of the canonical native token wrapper.

erc4626Mint

Mints shares of an ERC4626 vault.

Underlying tokens must have been previously sent to the adapter.

Assumes the given vault implements EIP-4626.

solidity
function erc4626Mint(address vault, uint256 shares, uint256 maxSharePriceE27, address receiver)
    external
    onlyBundler3;

Parameters

NameTypeDescription
vaultaddressThe address of the vault.
sharesuint256The amount of vault shares to mint.
maxSharePriceE27uint256The maximum amount of assets to pay to get 1 share, scaled by 1e27.
receiveraddressThe address to which shares will be minted.

erc4626Deposit

Deposits underlying token in an ERC4626 vault.

Underlying tokens must have been previously sent to the adapter.

Assumes the given vault implements EIP-4626.

solidity
function erc4626Deposit(address vault, uint256 assets, uint256 maxSharePriceE27, address receiver)
    external
    onlyBundler3;

Parameters

NameTypeDescription
vaultaddressThe address of the vault.
assetsuint256The amount of underlying token to deposit. Pass type(uint).max to deposit the adapter's balance.
maxSharePriceE27uint256The maximum amount of assets to pay to get 1 share, scaled by 1e27.
receiveraddressThe address to which shares will be minted.

erc4626Withdraw

Withdraws underlying token from an ERC4626 vault.

Assumes the given vault implements EIP-4626.

If owner is the initiator, they must have previously approved the adapter to spend their vault shares. Otherwise, vault shares must have been previously sent to the adapter.

solidity
function erc4626Withdraw(address vault, uint256 assets, uint256 minSharePriceE27, address receiver, address owner)
    external
    onlyBundler3;

Parameters

NameTypeDescription
vaultaddressThe address of the vault.
assetsuint256The amount of underlying token to withdraw.
minSharePriceE27uint256The minimum number of assets to receive per share, scaled by 1e27.
receiveraddressThe address that will receive the withdrawn assets.
owneraddressThe address on behalf of which the assets are withdrawn. Can only be the adapter or the initiator.

erc4626Redeem

Redeems shares of an ERC4626 vault.

Assumes the given vault implements EIP-4626.

If owner is the initiator, they must have previously approved the adapter to spend their vault shares. Otherwise, vault shares must have been previously sent to the adapter.

solidity
function erc4626Redeem(address vault, uint256 shares, uint256 minSharePriceE27, address receiver, address owner)
    external
    onlyBundler3;

Parameters

NameTypeDescription
vaultaddressThe address of the vault.
sharesuint256The amount of vault shares to redeem. Pass type(uint).max to redeem the owner's shares.
minSharePriceE27uint256The minimum number of assets to receive per share, scaled by 1e27.
receiveraddressThe address that will receive the withdrawn assets.
owneraddressThe address on behalf of which the shares are redeemed. Can only be the adapter or the initiator.

onMorphoSupply

Receives supply callback from the Morpho contract.

solidity
function onMorphoSupply(uint256, bytes calldata data) external;

Parameters

NameTypeDescription
<none>uint256
databytesBytes containing an abi-encoded Call[].

onMorphoSupplyCollateral

Receives supply collateral callback from the Morpho contract.

solidity
function onMorphoSupplyCollateral(uint256, bytes calldata data) external;

Parameters

NameTypeDescription
<none>uint256
databytesBytes containing an abi-encoded Call[].

onMorphoRepay

Receives repay callback from the Morpho contract.

solidity
function onMorphoRepay(uint256, bytes calldata data) external;

Parameters

NameTypeDescription
<none>uint256
databytesBytes containing an abi-encoded Call[].

onMorphoFlashLoan

Receives flashloan callback from the Morpho contract.

solidity
function onMorphoFlashLoan(uint256, bytes calldata data) external;

Parameters

NameTypeDescription
<none>uint256
databytesBytes containing an abi-encoded Call[].

morphoSupply

Supplies loan asset on Morpho.

Either assets or shares should be zero. Most usecases should rely on assets as an input so the adapter is guaranteed to have assets tokens pulled from its balance, but the possibility to mint a specific amount of shares is given for full compatibility and precision.

Loan tokens must have been previously sent to the adapter.

solidity
function morphoSupply(
    MarketParams calldata marketParams,
    uint256 assets,
    uint256 shares,
    uint256 maxSharePriceE27,
    address onBehalf,
    bytes calldata data
) external onlyBundler3;

Parameters

NameTypeDescription
marketParamsMarketParamsThe Morpho market to supply assets to.
assetsuint256The amount of assets to supply. Pass type(uint).max to supply the adapter's loan asset balance.
sharesuint256The amount of shares to mint.
maxSharePriceE27uint256The maximum amount of assets supplied per minted share, scaled by 1e27.
onBehalfaddressThe address that will own the increased supply position.
databytesArbitrary data to pass to the onMorphoSupply callback. Pass empty data if not needed.

morphoSupplyCollateral

Supplies collateral on Morpho.

Collateral tokens must have been previously sent to the adapter.

solidity
function morphoSupplyCollateral(
    MarketParams calldata marketParams,
    uint256 assets,
    address onBehalf,
    bytes calldata data
) external onlyBundler3;

Parameters

NameTypeDescription
marketParamsMarketParamsThe Morpho market to supply collateral to.
assetsuint256The amount of collateral to supply. Pass type(uint).max to supply the adapter's collateral balance.
onBehalfaddressThe address that will own the increased collateral position.
databytesArbitrary data to pass to the onMorphoSupplyCollateral callback. Pass empty data if not needed.

morphoBorrow

Borrows assets on Morpho.

Either assets or shares should be zero. Most usecases should rely on assets as an input so the initiator is guaranteed to borrow assets tokens, but the possibility to mint a specific amount of shares is given for full compatibility and precision.

Initiator must have previously authorized the adapter to act on their behalf on Morpho.

solidity
function morphoBorrow(
    MarketParams calldata marketParams,
    uint256 assets,
    uint256 shares,
    uint256 minSharePriceE27,
    address receiver
) external onlyBundler3;

Parameters

NameTypeDescription
marketParamsMarketParamsThe Morpho market to borrow assets from.
assetsuint256The amount of assets to borrow.
sharesuint256The amount of shares to mint.
minSharePriceE27uint256The minimum amount of assets borrowed per borrow share minted, scaled by 1e27.
receiveraddressThe address that will receive the borrowed assets.

morphoRepay

Repays assets on Morpho.

Either assets or shares should be zero. Most usecases should rely on assets as an input so the adapter is guaranteed to have assets tokens pulled from its balance, but the possibility to burn a specific amount of shares is given for full compatibility and precision.

Loan tokens must have been previously sent to the adapter.

solidity
function morphoRepay(
    MarketParams calldata marketParams,
    uint256 assets,
    uint256 shares,
    uint256 maxSharePriceE27,
    address onBehalf,
    bytes calldata data
) external onlyBundler3;

Parameters

NameTypeDescription
marketParamsMarketParamsThe Morpho market to repay assets to.
assetsuint256The amount of assets to repay. Pass type(uint).max to repay the adapter's loan asset balance.
sharesuint256The amount of shares to burn. Pass type(uint).max to repay the initiator's entire debt.
maxSharePriceE27uint256The maximum amount of assets repaid per borrow share burned, scaled by 1e27.
onBehalfaddressThe address of the owner of the debt position.
databytesArbitrary data to pass to the onMorphoRepay callback. Pass empty data if not needed.

morphoWithdraw

Withdraws assets on Morpho.

Either assets or shares should be zero. Most usecases should rely on assets as an input so the initiator is guaranteed to withdraw assets tokens, but the possibility to burn a specific amount of shares is given for full compatibility and precision.

Initiator must have previously authorized the module to act on their behalf on Morpho.

solidity
function morphoWithdraw(
    MarketParams calldata marketParams,
    uint256 assets,
    uint256 shares,
    uint256 minSharePriceE27,
    address receiver
) external onlyBundler3;

Parameters

NameTypeDescription
marketParamsMarketParamsThe Morpho market to withdraw assets from.
assetsuint256The amount of assets to withdraw.
sharesuint256The amount of shares to burn. Pass type(uint).max to burn all the initiator's supply shares.
minSharePriceE27uint256The minimum amount of assets withdraw per burn share, scaled by 1e27.
receiveraddressThe address that will receive the withdrawn assets.

morphoWithdrawCollateral

Withdraws collateral from Morpho.

Initiator must have previously authorized the adapter to act on their behalf on Morpho.

solidity
function morphoWithdrawCollateral(MarketParams calldata marketParams, uint256 assets, address receiver)
    external
    onlyBundler3;

Parameters

NameTypeDescription
marketParamsMarketParamsThe Morpho market to withdraw collateral from.
assetsuint256The amount of collateral to withdraw. Pass type(uint).max to withdraw the initiator's collateral balance.
receiveraddressThe address that will receive the collateral assets.

morphoFlashLoan

Triggers a flash loan on Morpho.

solidity
function morphoFlashLoan(address token, uint256 assets, bytes calldata data) external onlyBundler3;

Parameters

NameTypeDescription
tokenaddressThe address of the token to flash loan.
assetsuint256The amount of assets to flash loan.
databytesArbitrary data to pass to the onMorphoFlashLoan callback.

permit2TransferFrom

Transfers with Permit2.

solidity
function permit2TransferFrom(address token, address receiver, uint256 amount) external onlyBundler3;

Parameters

NameTypeDescription
tokenaddressThe address of the ERC20 token to transfer.
receiveraddressThe address that will receive the tokens.
amountuint256The amount of token to transfer. Pass type(uint).max to transfer the initiator's balance.

erc20TransferFrom

Transfers ERC20 tokens from the initiator.

Initiator must have given sufficient allowance to the Adapter to spend their tokens.

solidity
function erc20TransferFrom(address token, address receiver, uint256 amount) external onlyBundler3;

Parameters

NameTypeDescription
tokenaddressThe address of the ERC20 token to transfer.
receiveraddressThe address that will receive the tokens.
amountuint256The amount of token to transfer. Pass type(uint).max to transfer the initiator's balance.

wrapNative

Wraps native tokens to wNative.

Native tokens must have been previously sent to the adapter.

solidity
function wrapNative(uint256 amount, address receiver) external onlyBundler3;

Parameters

NameTypeDescription
amountuint256The amount of native token to wrap. Pass type(uint).max to wrap the adapter's balance.
receiveraddressThe account receiving the wrapped native tokens.

unwrapNative

Unwraps wNative tokens to the native token.

Wrapped native tokens must have been previously sent to the adapter.

solidity
function unwrapNative(uint256 amount, address receiver) external onlyBundler3;

Parameters

NameTypeDescription
amountuint256The amount of wrapped native token to unwrap. Pass type(uint).max to unwrap the adapter's balance.
receiveraddressThe account receiving the native tokens.

morphoCallback

Triggers _multicall logic during a callback.

solidity
function morphoCallback(bytes calldata data) internal;