mToken Contract
Unlocking DeFi Capabilities with the mToken Contract
The mToken Contract on Maven Finance is an essential building block of the platform, managing the minting, transfer, and operations of the native mToken used in our Lending Controller loan token liquidity pools.
Representing a 1-to-1 match with the underlying loan token asset in the liquidity pool, the mToken contract enables holders to automatically and passively gain yield based on their total amount held whenever interest is repaid from borrowers back to the Lending Controller.
The mToken Contract is fundamental to Maven Finance's vibrant ecosystem and are essential tools for unlocking the platform's full DeFi potential.
FA2 Token Contract Entrypoints
assertMetadata
function assertMetadata(string key, bytes hash)
Asserts whether the given metadata matches the one on the token contract
key
string
The key in the metadata bigmap on the token contract
hash
bytes
The metadata hash to be compared with the result from the key-value given
transfer
function transfer(fa2TransferType transferList)
Transfers tokens from one user to another
transferList
fa2TransferType: list(transferType transfer)
A list of transfers to be processed
transfer
transferType: address from_, list(transferDestinationType tx) txs
Specifies the sender from_ and a list of transfer destination transactions
from_
address
Sender of the token
txs
list(transferDestinationType tx)
List of transfer destination transactions
tx
transferDestinationType: address to_, nat tokenId, nat amount
Specifies the transfer destination of the transaction
to_
address
Recipient of the transfer operation
tokenId
nat
The id of the token to be transferred
amount
nat
The total amount of tokens to be transferred
balance_of
function balance_of(list(balanceOfRequestType balanceOfRequest) requests, contract(list(balanceOfResponseType balanceOfResponse) callback)
Facilitates inter-contract calls to retrieve the balance of a given user
requests
list(balanceOfRequestType balanceOfRequest)
A list of balance_of requests for the balance of given addresses
callback
contract(list(balanceOfResponseType balanceOfResponse))
A list of contracts to send the balanceOf requests to
balanceOfResponse
balanceOfResponseType: balanceOfRequestType balanceOfRequest, nat balance
A balanceOf response to be forwarded to the contract specified in the callback
balanceOfRequest
balanceOfRequestType: address owner, nat tokenId
Specifies the token id and balance of owner requested from
owner
address
The requested user address to find the balance of
tokenId
nat
The requested token id to find the balance of
balance
nat
The balance of the requested user address and token id
update_operators
function update_operators(list(updateOperatorVariantType updateOperatorVariant) updateOperatorsList)
Updates the operators for a given token id and owner
updateOperatorsList
list(updateOperatorVariantType updateOperatorVariant)
A list of updateOperators transactions to be processed
updateOperatorVariant
updateOperatorVariantType: | operatorParameterType Add_operator | operatorParameterType Remove_operator
Specify whether an operator should be added or removed
Add_operator
operatorParameterType: address owner, address operator, nat tokenId
Authorises an operator to act on behalf of the owner for the given token id
Remove_operator
operatorParameterType: address owner, address operator, nat tokenId
Removes the authority of an operator to act on behalf of the owner for the given token id
owner
address
Address of the user to set the operator on
operator
address
Address of the operator to be authorized
tokenId
nat
Id of the token where the operator will be set
Housekeeping Entrypoints
setAdmin
function setAdmin(address newAdminAddress)
Sets a new admin address for the contract
newAdminAddress
address
The address of the new admin
setGovernance
function setGovernance(address newGovernanceAddress)
Sets a new governance contract address
newGovernanceAddress
address
The address of the new governance contract
updateWhitelistContracts
function updateWhitelistContracts(address whitelistContractAddress, updateType update)
Add, update or remove a whitelist contract in the whitelistContracts map in the storage
whitelistContractAddress
address
The contract address to be updated in the whitelist contracts bigmap
updateType
updateType: | unit Update | unit Remove
Specifies whether the whitelistContractAddress should be updated or removed from the whitelist contracts bigmap
mistakenTransfer
function mistakenTransfer(transferActionType transferList)
Transfers any MAV or token that may have mistakenly been sent to this contract
transferList
transferActionType:
list(address to_, nat tokenAmount, token tokenType)
A list of transfers of tokens to recipients
to_
address
The recipient of the mistaken transfer
tokenAmount
nat
The amount of tokens to be transferred
token
tokenType: | unit Mav | (address tokenContractAddress) Fa12 | (address tokenContractAddress, nat tokenId) MRC-20
The token type of the token to be transferred, corresponding to either Mav, MRC-10 OR MRC-20
Protected Entrypoints
mintOrBurn
function mintOrBurn(address targetAddress, nat tokenId, nat quantity)
Mints or burns a given token quantity to or from the target address specified
targetAddress
address
The target address to receive new minted tokens, or burn existing tokens
tokenId
nat
The token id to be minted or burned
quantity
nat
The token amount to be minted or burned
compound
function compound(set(address userAddress) userAddressSet)
Compounds the balance of users specified in the address set
userAddressSet
set(address userAddress)
The set of user addresses for the compound operation
userAddress
address
The user address to run the compound operation on
View Methods
getAdmin
function getAdmin()
Returns the contract admin
getGovernanceAddress
function getGovernanceAddress()
Returns the contract governance address
getWhitelistContractOpt
function getWhitelistContractOpt(address contractAddress)
Returns unit if contract address is whitelisted, else returns none
get_balance
function get_balance(address userAddress * nat tokenId)
Returns the balance for the given userAddress and tokenId, else returns 0
all_tokens
function all_tokens()
Returns a list of token ids used by the token contract (in this case, only the zero token id is used)
is_operator
function is_operator(address ownerAddress, address operatorAddress, nat tokenId)
Returns the operator record for the given ownerAddress and tokenId, else returns none
token_metadata
function token_metadata(nat tokenId)
Returns the token metadata for the given token id, else returns none
get_reward_index
function get_reward_index(address userAddress)
Returns the current reward index for the specified user address
get_raw_total_supply
function get_raw_total_supply(nat _tokenId)
Returns the raw total supply of mTokens
get_raw_token_reward_index
function get_raw_token_reward_index(nat _tokenId)
Returns the raw token reward index of the mToken
get_raw_supply_and_reward_index
function get_raw_supply_and_reward_index(nat _tokenId)
Returns the raw total supply and token reward index of the mToken
Last updated