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

_addStrategy

function _addStrategy(address vault, uint256 maxPosSize) internal

Adds a strategy to the specific spell

Parameters

setMaxPosSize

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

Parameters

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

_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

_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

_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

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

_doPutCollateral

function _doPutCollateral(address token, uint256 amount) internal

This function puts collateral tokens inside the bank

Parameters

_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

increasePosition

function increasePosition(address token, uint256 amount) external

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

Parameters

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

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