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
Initializes the contract by setting the parameters
Parameters
_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
Adds a strategy to the specific spell
Parameters
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
Parameters
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
Allows the owner to set the maxLTV values of a specific collateral type for the given strategy
Parameters
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
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
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
Refunds any remaining balance of the specified token to the current bank executor.
Parameters
token
(address): The address of the token to refund
_doCutRewardsFee
Cuts the rewards from the current bank executor to the protocols treasury.
Parameters
token
(address): The address of the token to cut
_doRefundRewards
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
Lends the specified amount of the token to the bank on behalf of the current executor
Parameters
token
address
The address of the token to lend
amount
uint256
The amount of token to lend
_doWithdraw
Withdraws the specified amount of the token from the bank on behalf of the current executor
Parameters
token
address
The address of the token to withdraw
amount
uint256
The amount of token to withdraw
_doBorrow
Borrows the specified amount of the token from the bank on behalf of the current executor
Parameters
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
Repays the specified amount of the token to the bank on behalf of the current executor
Parameters
token
address
The address of the token to repay
amount
uint256
The amount of token to repay
_doPutCollateral
This function puts collateral tokens inside the bank
Parameters
token
address
The address of the token to put in the bank
amount
uint256
The amount of token to put in the bank
_doTakeCollateral
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
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
This function allows for the user to increase their isolated collateral to support their position
Parameters
token
address
The address of the token to put in the bank
amount
uint256
The amount of token to put in the bank
reducePosition
This function allows for the user to reduce their isolated collateral in a given position
Parameters
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
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