WrapAndSupply

Git Source

Title: WrapAndSupply

Author: Malda Protocol

Wraps native coins and supplies to host or extension markets in a single call.

State Variables

WRAPPED_NATIVE

The wrapped native coin contract

IWrappedNative public immutable WRAPPED_NATIVE

Functions

constructor

Initializes the helper with the wrapped native token address

constructor(address _wrappedNative) ;

Parameters

NameTypeDescription
_wrappedNativeaddressWrapped native token (e.g., WETH) contract address

wrapAndSupplyOnHostMarket

Wraps a native coin into its wrapped version and supplies on a host market

function wrapAndSupplyOnHostMarket(address mToken, address receiver, uint256 minAmount) external payable;

Parameters

NameTypeDescription
mTokenaddressThe market address
receiveraddressThe mToken receiver
minAmountuint256The minimum amount of mTokens expected

wrapAndSupplyOnExtensionMarket

Wraps a native coin into its wrapped version and supplies on an extension market

function wrapAndSupplyOnExtensionMarket(address mTokenGateway, address receiver, bytes4 selector) external payable;

Parameters

NameTypeDescription
mTokenGatewayaddressThe extension market address
receiveraddressThe receiver
selectorbytes4The host chain function selector

_wrap

Wraps a native coin into its wrapped version

function _wrap(uint256 amountToWrap) private;

Parameters

NameTypeDescription
amountToWrapuint256The amount of native coin to wrap

Events

WrappedAndSupplied

Emitted when native assets are wrapped and supplied to a market

event WrappedAndSupplied(address indexed sender, address indexed receiver, address indexed market, uint256 amount);

Parameters

NameTypeDescription
senderaddressThe caller providing native funds
receiveraddressThe account receiving the minted mTokens
marketaddressThe market that received the wrapped assets
amountuint256The amount of native coin wrapped and supplied

Errors

WrapAndSupply_AddressNotValid

Error thrown when the address is not valid

error WrapAndSupply_AddressNotValid();

WrapAndSupply_AmountNotValid

Error thrown when the amount is not valid

error WrapAndSupply_AmountNotValid();