generated from storming0x/foundry_strategy_mix
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
478 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
@yearnvaults/=lib/yearn-vaults/ | ||
@openzeppelin/=lib/openzeppelin-contracts/ | ||
forge-std/=lib/forge-std/src/ | ||
@mellowvaults/=lib/mellow-vaults/ | ||
forge-std/=lib/forge-std/src/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.12; | ||
|
||
import "@openzeppelin/contracts/access/IAccessControlEnumerable.sol"; | ||
|
||
interface IDefaultAccessControl is IAccessControlEnumerable { | ||
/// @notice Checks that the address is contract admin. | ||
/// @param who Address to check | ||
/// @return `true` if who is admin, `false` otherwise | ||
function isAdmin(address who) external view returns (bool); | ||
|
||
/// @notice Checks that the address is contract admin. | ||
/// @param who Address to check | ||
/// @return `true` if who is operator, `false` otherwise | ||
function isOperator(address who) external view returns (bool); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.12; | ||
|
||
interface IERC1271 { | ||
/// @notice Verifies offchain signature. | ||
/// @dev Should return whether the signature provided is valid for the provided hash | ||
/// | ||
/// MUST return the bytes4 magic value 0x1626ba7e when function passes. | ||
/// | ||
/// MUST NOT modify state (using STATICCALL for solc < 0.5, view modifier for solc > 0.5) | ||
/// | ||
/// MUST allow external calls | ||
/// @param _hash Hash of the data to be signed | ||
/// @param _signature Signature byte array associated with _hash | ||
/// @return magicValue 0x1626ba7e if valid, 0xffffffff otherwise | ||
function isValidSignature(bytes32 _hash, bytes memory _signature) | ||
external | ||
view | ||
returns (bytes4 magicValue); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.12; | ||
|
||
import "./IERC1271.sol"; | ||
import "./IVault.sol"; | ||
|
||
interface IIntegrationVault is IVault, IERC1271 { | ||
/// @notice Pushes tokens on the vault balance to the underlying protocol. For example, for Yearn this operation will take USDC from | ||
/// the contract balance and convert it to yUSDC. | ||
/// @dev Tokens **must** be a subset of Vault Tokens. However, the convention is that if tokenAmount == 0 it is the same as token is missing. | ||
/// | ||
/// Also notice that this operation doesn't guarantee that tokenAmounts will be invested in full. | ||
/// @param tokens Tokens to push | ||
/// @param tokenAmounts Amounts of tokens to push | ||
/// @param options Additional options that could be needed for some vaults. E.g. for Uniswap this could be `deadline` param. For the exact bytes structure see concrete vault descriptions | ||
/// @return actualTokenAmounts The amounts actually invested. It could be less than tokenAmounts (but not higher) | ||
function push( | ||
address[] memory tokens, | ||
uint256[] memory tokenAmounts, | ||
bytes memory options | ||
) external returns (uint256[] memory actualTokenAmounts); | ||
|
||
/// @notice The same as `push` method above but transfers tokens to vault balance prior to calling push. | ||
/// After the `push` it returns all the leftover tokens back (`push` method doesn't guarantee that tokenAmounts will be invested in full). | ||
/// @param tokens Tokens to push | ||
/// @param tokenAmounts Amounts of tokens to push | ||
/// @param options Additional options that could be needed for some vaults. E.g. for Uniswap this could be `deadline` param. For the exact bytes structure see concrete vault descriptions | ||
/// @return actualTokenAmounts The amounts actually invested. It could be less than tokenAmounts (but not higher) | ||
function transferAndPush( | ||
address from, | ||
address[] memory tokens, | ||
uint256[] memory tokenAmounts, | ||
bytes memory options | ||
) external returns (uint256[] memory actualTokenAmounts); | ||
|
||
/// @notice Pulls tokens from the underlying protocol to the `to` address. | ||
/// @dev Can only be called but Vault Owner or Strategy. Vault owner is the owner of NFT for this vault in VaultManager. | ||
/// Strategy is approved address for the vault NFT. | ||
/// When called by vault owner this method just pulls the tokens from the protocol to the `to` address | ||
/// When called by strategy on vault other than zero vault it pulls the tokens to zero vault (required `to` == zero vault) | ||
/// When called by strategy on zero vault it pulls the tokens to zero vault, pushes tokens on the `to` vault, and reclaims everything that's left. | ||
/// Thus any vault other than zero vault cannot have any tokens on it | ||
/// | ||
/// Tokens **must** be a subset of Vault Tokens. However, the convention is that if tokenAmount == 0 it is the same as token is missing. | ||
/// | ||
/// Pull is fulfilled on the best effort basis, i.e. if the tokenAmounts overflows available funds it withdraws all the funds. | ||
/// @param to Address to receive the tokens | ||
/// @param tokens Tokens to pull | ||
/// @param tokenAmounts Amounts of tokens to pull | ||
/// @param options Additional options that could be needed for some vaults. E.g. for Uniswap this could be `deadline` param. For the exact bytes structure see concrete vault descriptions | ||
/// @return actualTokenAmounts The amounts actually withdrawn. It could be less than tokenAmounts (but not higher) | ||
function pull( | ||
address to, | ||
address[] memory tokens, | ||
uint256[] memory tokenAmounts, | ||
bytes memory options | ||
) external returns (uint256[] memory actualTokenAmounts); | ||
|
||
/// @notice Claim ERC20 tokens from vault balance to zero vault. | ||
/// @dev Cannot be called from zero vault. | ||
/// @param tokens Tokens to claim | ||
/// @return actualTokenAmounts Amounts reclaimed | ||
function reclaimTokens(address[] memory tokens) | ||
external | ||
returns (uint256[] memory actualTokenAmounts); | ||
|
||
/// @notice Execute one of whitelisted calls. | ||
/// @dev Can only be called by Vault Owner or Strategy. Vault owner is the owner of NFT for this vault in VaultManager. | ||
/// Strategy is approved address for the vault NFT. | ||
/// | ||
/// Since this method allows sending arbitrary transactions, the destinations of the calls | ||
/// are whitelisted by Protocol Governance. | ||
/// @param to Address of the reward pool | ||
/// @param selector Selector of the call | ||
/// @param data Abi encoded parameters to `to::selector` | ||
/// @return result Result of execution of the call | ||
function externalCall( | ||
address to, | ||
bytes4 selector, | ||
bytes memory data | ||
) external payable returns (bytes memory result); | ||
} |
Oops, something went wrong.