Skip to content

Commit

Permalink
feat: pass the storage pointer (#74)
Browse files Browse the repository at this point in the history
* feat: pass the storage pointer

* chore: rebase

* chore: formatting and comments

* chore: rebase

* fix: formatting functions

* fix: test coverage

* fix: remove lcov file

* fix: ignore coverage file
  • Loading branch information
Schlagonia committed Jan 27, 2024
1 parent ea7ccb5 commit 176e3f0
Show file tree
Hide file tree
Showing 7 changed files with 379 additions and 213 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ docs/
.env

node_modules/
.gas-snapshot
.gas-snapshot
lcov.info
25 changes: 20 additions & 5 deletions src/BaseStrategy.sol
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ abstract contract BaseStrategy {
_;
}

/**
* @dev Require that the msg.sender is this address.
*/
function _onlySelf() internal view {
require(msg.sender == address(this), "!self");
}
Expand All @@ -86,7 +89,7 @@ abstract contract BaseStrategy {
//////////////////////////////////////////////////////////////*/

/**
* This is the address of the TokenizedStrategy implementation
* @dev This is the address of the TokenizedStrategy implementation
* contract that will be used by all strategies to handle the
* accounting, logic, storage etc.
*
Expand All @@ -106,7 +109,7 @@ abstract contract BaseStrategy {
//////////////////////////////////////////////////////////////*/

/**
* This variable is set to address(this) during initialization of each strategy.
* @dev This variable is set to address(this) during initialization of each strategy.
*
* This can be used to retrieve storage data within the strategy
* contract as if it were a linked library.
Expand All @@ -119,8 +122,10 @@ abstract contract BaseStrategy {
*/
ITokenizedStrategy internal immutable TokenizedStrategy;

// Underlying asset the Strategy is earning yield on.
// Stored here for cheap retrievals within the strategy.
/**
* @dev Underlying asset the Strategy is earning yield on.
* Stored here for cheap retrievals within the strategy.
*/
ERC20 internal immutable asset;

/**
Expand Down Expand Up @@ -470,7 +475,17 @@ abstract contract BaseStrategy {
return result;
}

// execute a function on the TokenizedStrategy and return any value.
/**
* @dev execute a function on the TokenizedStrategy and return any value.
*
* This fallback function will be execute when any of the standard functions
* defined in the TokenizedStrategy are called since they wont be defined in
* this contract.
*
* It will delegatecall the TokenizedStrategy implementation with the exact
* calldata and return any relevant values.
*
*/
fallback() external {
// load our target address
address _tokenizedStrategyAddress = tokenizedStrategyAddress;
Expand Down
Loading

0 comments on commit 176e3f0

Please sign in to comment.