Modifiers

onlyEOAEx()

This modifier ensures that the function is called from an externally owned account (EOA) when the allowContractCalls variable is set to false and the caller is not whitelisted. If the caller is a contract and is not whitelisted, the modifier will revert with an error message.

Parameters

  • None

Errors

  • NOT_EOA(address) - If the caller is a contract and is not whitelisted, this error is thrown.

Example Usage

function myFunction() public onlyEOAEx() {
    // Only executable by an externally owned account that is whitelisted or if allowContractCalls is true.
}

onlyWhitelistedToken(address token)

This modifier ensures that the token is already whitelisted. If the token is not whitelisted, the modifier will revert with an error message.

Parameters

  • token - The address of the token to check if it's whitelisted.

Errors

  • TOKEN_NOT_WHITELISTED(address) - If the token is not whitelisted, this error is thrown.

Example Usage

function myFunction(address token) public onlyWhitelistedToken(token) {
    // Only executable with a whitelisted token.
}

lock()

This modifier ensures that the function is not reentrant. If the function is currently being executed, the modifier will revert with an error message.

Parameters

  • None

Errors

  • LOCKED() - If the function is currently being executed, this error is thrown.

Example Usage

function myFunction() public lock() {
    // Only executable if no other function is currently executing.
}

inExec()

This modifier ensures that the function is called from within the execution scope. The POSITION_ID must be set to a non-zero value and the SPELL variable must be set to the address of the calling contract. If the function is currently being executed or the execution scope has not been set, the modifier will revert with an error message.

Parameters

  • None

Errors

  • NOT_IN_EXEC() - If the function is not called from within the execution scope, this error is thrown.

  • NOT_FROM_SPELL(address) - If the caller is not the SPELL contract, this error is thrown.

  • LOCKED() - If the function is currently being executed or the execution scope has not been set, this error is thrown.

Example Usage

function myFunction() public inExec() {
    // Only executable if called from within the execution scope.
}

poke(address token)

This modifier ensures that the interest rate of the given token is accrued before executing the function. If the token's interest rate has not been accrued, the modifier will accrue the interest rate before executing the function.

Parameters

  • token - The address of the token to accrue interest rate

Errors

  • None

Example Usage

function myFunction(address token) public poke(token) {
    // Only executable if the interest rate of the token has been accrued.
}

Last updated