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
Name | Type | Description |
---|---|---|
|
| The address of the bank contract |
|
| The address of the wrapped ERC20 contract |
|
| The address of the WETH contract |
_addStrategy
Adds a strategy to the specific spell
Parameters
Name | Type | Description |
---|---|---|
| address | The address of the vault to add |
| uint256 | the USD price of the maximum position size for the given strategy based 1e18 |
setMaxPosSize
Parameters
Name | Type | Description |
---|---|---|
| uint256 | The strategy ID to be adjusted |
| 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
Name | Type | Description |
---|---|---|
| uint256 | The strategy ID to be adjusted |
| array | An array of addresses of the collaterals to have their max values set |
| 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
Name | Type | Description |
---|---|---|
|
| The address of the token to lend |
|
| The amount of token to lend |
_doWithdraw
Withdraws the specified amount of the token from the bank on behalf of the current executor
Parameters
Name | Type | Description |
---|---|---|
|
| The address of the token to withdraw |
|
| The amount of token to withdraw |
_doBorrow
Borrows the specified amount of the token from the bank on behalf of the current executor
Parameters
Name | Type | Description |
---|---|---|
|
| The address of the token to borrow |
|
| 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
Name | Type | Description |
---|---|---|
|
| The address of the token to repay |
|
| The amount of token to repay |
_doPutCollateral
This function puts collateral tokens inside the bank
Parameters
Name | Type | Description |
---|---|---|
|
| The address of the token to put in the bank |
|
| 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
Name | Type | Description |
---|---|---|
|
| The address of the token to take out of the bank |
|
| 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
Name | Type | Description |
---|---|---|
|
| The address of the token to put in the bank |
|
| 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
Name | Type | Description |
---|---|---|
|
| The strategy to be targeted |
|
| The address of the isolated collateral token |
|
| 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