feat: add balancer v2 executor
This commit is contained in:
@@ -0,0 +1,203 @@
|
||||
// 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;
|
||||
|
||||
/**
|
||||
* @notice Interface for ExternalWeightedMath, a contract-wrapper for Weighted Math, Joins and Exits.
|
||||
*/
|
||||
interface IExternalWeightedMath {
|
||||
/**
|
||||
* @dev See `WeightedMath._calculateInvariant`.
|
||||
*/
|
||||
function calculateInvariant(uint256[] memory normalizedWeights, uint256[] memory balances)
|
||||
external
|
||||
pure
|
||||
returns (uint256);
|
||||
|
||||
/**
|
||||
* @dev See `WeightedMath._calcOutGivenIn`.
|
||||
*/
|
||||
function calcOutGivenIn(
|
||||
uint256 balanceIn,
|
||||
uint256 weightIn,
|
||||
uint256 balanceOut,
|
||||
uint256 weightOut,
|
||||
uint256 amountIn
|
||||
) external pure returns (uint256);
|
||||
|
||||
/**
|
||||
* @dev See `WeightedMath._calcInGivenOut`.
|
||||
*/
|
||||
function calcInGivenOut(
|
||||
uint256 balanceIn,
|
||||
uint256 weightIn,
|
||||
uint256 balanceOut,
|
||||
uint256 weightOut,
|
||||
uint256 amountOut
|
||||
) external pure returns (uint256);
|
||||
|
||||
/**
|
||||
* @dev See `WeightedMath._calcBptOutGivenExactTokensIn`.
|
||||
*/
|
||||
function calcBptOutGivenExactTokensIn(
|
||||
uint256[] memory balances,
|
||||
uint256[] memory normalizedWeights,
|
||||
uint256[] memory amountsIn,
|
||||
uint256 bptTotalSupply,
|
||||
uint256 swapFeePercentage
|
||||
) external pure returns (uint256);
|
||||
|
||||
/**
|
||||
* @dev See `WeightedMath._calcBptOutGivenExactTokenIn`.
|
||||
*/
|
||||
function calcBptOutGivenExactTokenIn(
|
||||
uint256 balance,
|
||||
uint256 normalizedWeight,
|
||||
uint256 amountIn,
|
||||
uint256 bptTotalSupply,
|
||||
uint256 swapFeePercentage
|
||||
) external pure returns (uint256);
|
||||
|
||||
/**
|
||||
* @dev See `WeightedMath._calcTokenInGivenExactBptOut`.
|
||||
*/
|
||||
function calcTokenInGivenExactBptOut(
|
||||
uint256 balance,
|
||||
uint256 normalizedWeight,
|
||||
uint256 bptAmountOut,
|
||||
uint256 bptTotalSupply,
|
||||
uint256 swapFeePercentage
|
||||
) external pure returns (uint256);
|
||||
|
||||
/**
|
||||
* @dev See `WeightedMath._calcAllTokensInGivenExactBptOut`.
|
||||
*/
|
||||
function calcAllTokensInGivenExactBptOut(
|
||||
uint256[] memory balances,
|
||||
uint256 bptAmountOut,
|
||||
uint256 totalBPT
|
||||
) external pure returns (uint256[] memory);
|
||||
|
||||
/**
|
||||
* @dev See `WeightedMath._calcBptInGivenExactTokensOut`.
|
||||
*/
|
||||
function calcBptInGivenExactTokensOut(
|
||||
uint256[] memory balances,
|
||||
uint256[] memory normalizedWeights,
|
||||
uint256[] memory amountsOut,
|
||||
uint256 bptTotalSupply,
|
||||
uint256 swapFeePercentage
|
||||
) external pure returns (uint256);
|
||||
|
||||
/**
|
||||
* @dev See `WeightedMath._calcBptInGivenExactTokenOut`.
|
||||
*/
|
||||
function calcBptInGivenExactTokenOut(
|
||||
uint256 balance,
|
||||
uint256 normalizedWeight,
|
||||
uint256 amountOut,
|
||||
uint256 bptTotalSupply,
|
||||
uint256 swapFeePercentage
|
||||
) external pure returns (uint256);
|
||||
|
||||
/**
|
||||
* @dev See `WeightedMath._calcTokenOutGivenExactBptIn`.
|
||||
*/
|
||||
function calcTokenOutGivenExactBptIn(
|
||||
uint256 balance,
|
||||
uint256 normalizedWeight,
|
||||
uint256 bptAmountIn,
|
||||
uint256 bptTotalSupply,
|
||||
uint256 swapFeePercentage
|
||||
) external pure returns (uint256);
|
||||
|
||||
/**
|
||||
* @dev See `WeightedMath._calcTokensOutGivenExactBptIn`.
|
||||
*/
|
||||
function calcTokensOutGivenExactBptIn(
|
||||
uint256[] memory balances,
|
||||
uint256 bptAmountIn,
|
||||
uint256 totalBPT
|
||||
) external pure returns (uint256[] memory);
|
||||
|
||||
/**
|
||||
* @dev See `WeightedMath._calcBptOutAddToken`.
|
||||
*/
|
||||
function calcBptOutAddToken(uint256 totalSupply, uint256 normalizedWeight) external pure returns (uint256);
|
||||
|
||||
/**
|
||||
* @dev See `WeightedJoinsLib.joinExactTokensInForBPTOut`.
|
||||
*/
|
||||
function joinExactTokensInForBPTOut(
|
||||
uint256[] memory balances,
|
||||
uint256[] memory normalizedWeights,
|
||||
uint256[] memory scalingFactors,
|
||||
uint256 totalSupply,
|
||||
uint256 swapFeePercentage,
|
||||
bytes memory userData
|
||||
) external pure returns (uint256, uint256[] memory);
|
||||
|
||||
/**
|
||||
* @dev See `WeightedJoinsLib.joinTokenInForExactBPTOut`.
|
||||
*/
|
||||
function joinTokenInForExactBPTOut(
|
||||
uint256[] memory balances,
|
||||
uint256[] memory normalizedWeights,
|
||||
uint256 totalSupply,
|
||||
uint256 swapFeePercentage,
|
||||
bytes memory userData
|
||||
) external pure returns (uint256, uint256[] memory);
|
||||
|
||||
/**
|
||||
* @dev See `WeightedJoinsLib.joinAllTokensInForExactBPTOut`.
|
||||
*/
|
||||
function joinAllTokensInForExactBPTOut(
|
||||
uint256[] memory balances,
|
||||
uint256 totalSupply,
|
||||
bytes memory userData
|
||||
) external pure returns (uint256 bptAmountOut, uint256[] memory amountsIn);
|
||||
|
||||
/**
|
||||
* @dev See `WeightedExitsLib.exitExactBPTInForTokenOut`.
|
||||
*/
|
||||
function exitExactBPTInForTokenOut(
|
||||
uint256[] memory balances,
|
||||
uint256[] memory normalizedWeights,
|
||||
uint256 totalSupply,
|
||||
uint256 swapFeePercentage,
|
||||
bytes memory userData
|
||||
) external pure returns (uint256, uint256[] memory);
|
||||
|
||||
/**
|
||||
* @dev See `WeightedExitsLib.exitExactBPTInForTokensOut`.
|
||||
*/
|
||||
function exitExactBPTInForTokensOut(
|
||||
uint256[] memory balances,
|
||||
uint256 totalSupply,
|
||||
bytes memory userData
|
||||
) external pure returns (uint256 bptAmountIn, uint256[] memory amountsOut);
|
||||
|
||||
/**
|
||||
* @dev See `WeightedExitsLib.exitBPTInForExactTokensOut`.
|
||||
*/
|
||||
function exitBPTInForExactTokensOut(
|
||||
uint256[] memory balances,
|
||||
uint256[] memory normalizedWeights,
|
||||
uint256[] memory scalingFactors,
|
||||
uint256 totalSupply,
|
||||
uint256 swapFeePercentage,
|
||||
bytes memory userData
|
||||
) external pure returns (uint256, uint256[] memory);
|
||||
}
|
||||
Reference in New Issue
Block a user