BasicSpell

The BasicSpell contract is an abstract contract that provides a set of functions to be implemented by its inheriting contracts. This contract is designed to facilitate borrowing, lending, and collateral management functionalities for other contracts in the BlueBerry Protocol

Variables

bank

  • Type: IBank

  • Description: The bank contract that provides borrowing, lending, and collateral management functionalities

werc20

  • Type: IWERC20

  • Description: The wrapped ERC20 contract that is used as collateral for borrowing and lending operations

weth

  • Type: address

  • Description: The address of the WETH contract

Functions

__BasicSpell_init

function __BasicSpell_init(IBank _bank, address _werc20, address _weth) internal onlyInitializing 

Initializes the contract by setting the parameters

Parameters

NameTypeDescription

_bank

IBank

The address of the bank contract

_werc20

address

The address of the wrapped ERC20 contract

_weth

address

The address of the WETH contract

_addStrategy

function _addStrategy(address vault, uint256 maxPosSize) internal

Adds a strategy to the specific spell

Parameters

NameTypeDescription

vault

address

The address of the vault to add

maxPosSize

uint256

the USD price of the maximum position size for the given strategy based 1e18

setMaxPosSize

function setMaxPosSize(uint256 strategyID, uint256 maxPosSize) external existingStrategy(strategyId) onlyOWner

Parameters

NameTypeDescription

strategyId

uint256

The strategy ID to be adjusted

maxPosSize

uint256

the new USD price of the maximum position size for the given strategy based 1e18

setCollateralsMaxLTVs

function setCollateralsMaxLTVs(uint256 strategyId, address[] memory collaterals, uint256[] memory maxLTVs) external existingStrategy(strategyId) onlyOwner

Allows the owner to set the maxLTV values of a specific collateral type for the given strategy

Parameters

NameTypeDescription

strategyId

uint256

The strategy ID to be adjusted

collaterals

array

An array of addresses of the collaterals to have their max values set

maxLTVs

array

An array of the values for the given collaterals to set their maximums.

_validateMaxLTV

function _validateMaxLTV(uint256 strategyId) internal view

An internal function to ensure that the ltv of a strategy is within the maximum value bounds.

  • strategyId (uint256) - The given ID to be checked and validated

_validateMaxPosSize

function _validateMaxPosSize(uint256 strategyId) internal view

An internal function to ensure that the max Position Size of a strategy is within the maximum value bounds.

strategyId (uint256) - The given ID to be checked and validated

_doRefund

function _doRefund(address token) internal

Refunds any remaining balance of the specified token to the current bank executor.

Parameters

  • token (address): The address of the token to refund

_doCutRewardsFee

function _doCutRewardsFee(address token) internal

Cuts the rewards from the current bank executor to the protocols treasury.

Parameters

  • token (address): The address of the token to cut

_doRefundRewards

function _doRefundRewards(address token) internal

Cut rewards fee and refund the rewards tokens from spell to the current bank executor

Parameters

token (address): The address of the token to refund

_doLend

function _doLend(address token, uint256 amount) internal 

Lends the specified amount of the token to the bank on behalf of the current executor

Parameters

NameTypeDescription

token

address

The address of the token to lend

amount

uint256

The amount of token to lend

_doWithdraw

function _doWithdraw(address token, uint256 amount) internal

Withdraws the specified amount of the token from the bank on behalf of the current executor

Parameters

NameTypeDescription

token

address

The address of the token to withdraw

amount

uint256

The amount of token to withdraw

_doBorrow

function _doBorrow(address token, uint256 amount) internal returns (uint256 borrowedAmount)

Borrows the specified amount of the token from the bank on behalf of the current executor

Parameters

NameTypeDescription

token

address

The address of the token to borrow

amount

uint256

The amount of token to borrow

Returns

  • borrowedAmount : The number of tokens actually borrowed

_doRepay

function _doRepay(address token, uint256 amount) internal

Repays the specified amount of the token to the bank on behalf of the current executor

Parameters

NameTypeDescription

token

address

The address of the token to repay

amount

uint256

The amount of token to repay

_doPutCollateral

function _doPutCollateral(address token, uint256 amount) internal

This function puts collateral tokens inside the bank

Parameters

NameTypeDescription

token

address

The address of the token to put in the bank

amount

uint256

The amount of token to put in the bank

_doTakeCollateral

function _doTakeCollateral(address token, uint256 amount) internal

This function takes collateral tokens out of the bank by burning the equivalent amount of wrapped ERC20 tokens (wERC20) using the burn function of the wERC20 token contract.

Parameters

NameTypeDescription

token

address

The address of the token to take out of the bank

amount

uint256

The amount of token to take out of the bank

increasePosition

function increasePosition(address token, uint256 amount) external

This function allows for the user to increase their isolated collateral to support their position

Parameters

NameTypeDescription

token

address

The address of the token to put in the bank

amount

uint256

The amount of token to put in the bank

reducePosition

function reducePosition(uint256 strategyID, address collToken, uint256 collShareAmount) external

This function allows for the user to reduce their isolated collateral in a given position

Parameters

NameTypeDescription

strategyId

uint256

The strategy to be targeted

collToken

address

The address of the isolated collateral token

collShareAmount

uint256

The amount of isolated collateral to be removed

receive

receive() external payable

This is a fallback function that is used to receive Ether only from the Wrapped Ether (WETH) contract. If the function receives Ether from an address other than the WETH contract, it reverts with an error.

Last updated