feat: add balancer v2 executor
This commit is contained in:
@@ -0,0 +1,67 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
pragma solidity >=0.7.0 <0.9.0;
|
||||
|
||||
/**
|
||||
* @title IERC4626, to support the yield-bearing token standard.
|
||||
* @notice Used for ERC4626-derived Linear Pools.
|
||||
* @dev There is another version of this in /solidity-utils/misc, used in standalone-utils tests.
|
||||
* This version has an additional `previewMint` function, and is used in tests of derived Linear Pools.
|
||||
*/
|
||||
interface IERC4626 {
|
||||
/**
|
||||
* @dev Mints `shares` Vault shares to `receiver` by depositing exactly `amount` of underlying tokens.
|
||||
*/
|
||||
function deposit(uint256 assets, address receiver) external returns (uint256 shares);
|
||||
|
||||
/**
|
||||
* @dev Burns exactly `shares` from `owner` and sends `assets` of underlying tokens to `receiver`.
|
||||
*/
|
||||
function redeem(
|
||||
uint256 shares,
|
||||
address receiver,
|
||||
address owner
|
||||
) external returns (uint256 assets);
|
||||
|
||||
/**
|
||||
* @dev The address of the underlying token that the Vault uses for accounting, depositing, and withdrawing.
|
||||
*/
|
||||
function asset() external view returns (address);
|
||||
|
||||
/**
|
||||
* @dev Total amount of the underlying asset that is “managed” by Vault.
|
||||
*/
|
||||
function totalAssets() external view returns (uint256);
|
||||
|
||||
/**
|
||||
* @dev The amount of `assets` that the Vault would exchange for the amount
|
||||
* of `shares` provided, in an ideal scenario where all the conditions are met.
|
||||
*/
|
||||
function convertToAssets(uint256 shares) external view returns (uint256 assets);
|
||||
|
||||
/**
|
||||
* @dev The amount of `shares` that the Vault would exchange for the amount
|
||||
* of `assets` provided, in an ideal scenario where all the conditions are met.
|
||||
*/
|
||||
function convertToShares(uint256 assets) external view returns (uint256 shares);
|
||||
|
||||
/**
|
||||
* @dev Allows an on-chain or off-chain user to simulate the effects of their mint at the current block,
|
||||
* given current on-chain conditions. MUST return as close to and no fewer than the exact amount of assets that
|
||||
* would be deposited in a mint call in the same transaction. I.e. mint should return the same or fewer assets
|
||||
* as previewMint if called in the same transaction.
|
||||
*/
|
||||
function previewMint(uint256 shares) external view returns (uint256 assets);
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
pragma solidity >=0.7.0 <0.9.0;
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
import "../solidity-utils/openzeppelin/IERC20.sol";
|
||||
import "../vault/IBasePool.sol";
|
||||
|
||||
interface ILinearPool is IBasePool {
|
||||
/**
|
||||
* @dev Returns the Pool's main token.
|
||||
*/
|
||||
function getMainToken() external view returns (IERC20);
|
||||
|
||||
/**
|
||||
* @dev Returns the Pool's wrapped token.
|
||||
*/
|
||||
function getWrappedToken() external view returns (IERC20);
|
||||
|
||||
/**
|
||||
* @dev Returns the index of the Pool's BPT in the Pool tokens array (as returned by IVault.getPoolTokens).
|
||||
*/
|
||||
function getBptIndex() external view returns (uint256);
|
||||
|
||||
/**
|
||||
* @dev Returns the index of the Pool's main token in the Pool tokens array (as returned by IVault.getPoolTokens).
|
||||
*/
|
||||
function getMainIndex() external view returns (uint256);
|
||||
|
||||
/**
|
||||
* @dev Returns the index of the Pool's wrapped token in the Pool tokens array (as returned by
|
||||
* IVault.getPoolTokens).
|
||||
*/
|
||||
function getWrappedIndex() external view returns (uint256);
|
||||
|
||||
/**
|
||||
* @dev Returns the Pool's targets for the main token balance. These values have had the main token's scaling
|
||||
* factor applied to them.
|
||||
*/
|
||||
function getTargets() external view returns (uint256 lowerTarget, uint256 upperTarget);
|
||||
|
||||
/**
|
||||
* @notice Set the lower and upper bounds of the zero-fee trading range for the main token balance.
|
||||
* @dev For a new target range to be valid:
|
||||
* - the current balance must be between the current targets (meaning no fees are currently pending)
|
||||
* - the current balance must be between the new targets (meaning setting them does not create pending fees)
|
||||
*
|
||||
* The first requirement could be relaxed, as the LPs actually benefit from the pending fees not being paid out,
|
||||
* but being stricter makes analysis easier at little expense.
|
||||
*
|
||||
* This is a permissioned function, reserved for the pool owner. It will revert when called within a Vault context
|
||||
* (i.e. in the middle of a join or an exit).
|
||||
*
|
||||
* Correct behavior depends on the token balances from the Vault, which may be out of sync with the state of
|
||||
* the pool during execution of a Vault hook.
|
||||
*
|
||||
* See https://forum.balancer.fi/t/reentrancy-vulnerability-scope-expanded/4345 for reference.
|
||||
*/
|
||||
function setTargets(uint256 newLowerTarget, uint256 newUpperTarget) external;
|
||||
|
||||
/**
|
||||
* @notice Set the swap fee percentage.
|
||||
* @dev This is a permissioned function, reserved for the pool owner. It will revert when called within a Vault
|
||||
* context (i.e. in the middle of a join or an exit).
|
||||
*
|
||||
* Correct behavior depends on the token balances from the Vault, which may be out of sync with the state of
|
||||
* the pool during execution of a Vault hook.
|
||||
*
|
||||
* See https://forum.balancer.fi/t/reentrancy-vulnerability-scope-expanded/4345 for reference.
|
||||
*/
|
||||
function setSwapFeePercentage(uint256 swapFeePercentage) external;
|
||||
}
|
||||
Reference in New Issue
Block a user