Source Code
Overview
ETH Balance
0 ETH
More Info
ContractCreator
Multichain Info
N/A
Latest 1 from a total of 1 transactions
Transaction Hash |
Method
|
Block
|
From
|
To
|
Value | ||||
---|---|---|---|---|---|---|---|---|---|
0x61014060 | 7169138 | 633 days ago | IN | Create: BatchRelayerLibrary | 0 ETH | 0.00605792 |
Latest 3 internal transactions
Advanced mode:
Parent Txn Hash | Block | From | To | Value | ||
---|---|---|---|---|---|---|
7169138 | 633 days ago | 0 ETH | ||||
7169138 | 633 days ago | Contract Creation | 0 ETH | |||
7169138 | 633 days ago | 0 ETH |
Loading...
Loading
Contract Name:
BatchRelayerLibrary
Compiler Version
v0.7.1+commit.f4a555be
Optimization Enabled:
Yes with 9999 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
// 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; pragma experimental ABIEncoderV2; import "./relayer/BaseRelayerLibrary.sol"; import "./relayer/AaveWrapping.sol"; import "./relayer/LidoWrapping.sol"; import "./relayer/ERC4626Wrapping.sol"; import "./relayer/UnbuttonWrapping.sol"; import "./relayer/VaultActions.sol"; import "./relayer/VaultPermit.sol"; /** * @title Batch Relayer Library * @notice This contract is not a relayer by itself and calls into it directly will fail. * The associated relayer can be found by calling `getEntrypoint` on this contract. */ contract BatchRelayerLibrary is BaseRelayerLibrary, AaveWrapping, LidoWrapping, VaultActions, VaultPermit, ERC4626Wrapping, UnbuttonWrapping { constructor(IVault vault, IERC20 wstETH) BaseRelayerLibrary(vault) LidoWrapping(wstETH) { // solhint-disable-previous-line no-empty-blocks } }
// SPDX-License-Identifier: MIT pragma solidity ^0.7.0; import "../helpers/BalancerErrors.sol"; /** * @dev Wrappers over Solidity's arithmetic operations with added overflow checks. * Adapted from OpenZeppelin's SafeMath library. */ library Math { /** * @dev Returns the absolute value of a signed integer. */ function abs(int256 a) internal pure returns (uint256) { return a > 0 ? uint256(a) : uint256(-a); } /** * @dev Returns the addition of two unsigned integers of 256 bits, reverting on overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; _require(c >= a, Errors.ADD_OVERFLOW); return c; } /** * @dev Returns the addition of two signed integers, reverting on overflow. */ function add(int256 a, int256 b) internal pure returns (int256) { int256 c = a + b; _require((b >= 0 && c >= a) || (b < 0 && c < a), Errors.ADD_OVERFLOW); return c; } /** * @dev Returns the subtraction of two unsigned integers of 256 bits, reverting on overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { _require(b <= a, Errors.SUB_OVERFLOW); uint256 c = a - b; return c; } /** * @dev Returns the subtraction of two signed integers, reverting on overflow. */ function sub(int256 a, int256 b) internal pure returns (int256) { int256 c = a - b; _require((b >= 0 && c <= a) || (b < 0 && c > a), Errors.SUB_OVERFLOW); return c; } /** * @dev Returns the largest of two numbers of 256 bits. */ function max(uint256 a, uint256 b) internal pure returns (uint256) { return a >= b ? a : b; } /** * @dev Returns the smallest of two numbers of 256 bits. */ function min(uint256 a, uint256 b) internal pure returns (uint256) { return a < b ? a : b; } function mul(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a * b; _require(a == 0 || c / a == b, Errors.MUL_OVERFLOW); return c; } function div( uint256 a, uint256 b, bool roundUp ) internal pure returns (uint256) { return roundUp ? divUp(a, b) : divDown(a, b); } function divDown(uint256 a, uint256 b) internal pure returns (uint256) { _require(b != 0, Errors.ZERO_DIVISION); return a / b; } function divUp(uint256 a, uint256 b) internal pure returns (uint256) { _require(b != 0, Errors.ZERO_DIVISION); if (a == 0) { return 0; } else { return 1 + (a - 1) / b; } } }
// 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; import "../openzeppelin/IERC20.sol"; import "./BalancerErrors.sol"; library InputHelpers { function ensureInputLengthMatch(uint256 a, uint256 b) internal pure { _require(a == b, Errors.INPUT_LENGTH_MISMATCH); } function ensureInputLengthMatch( uint256 a, uint256 b, uint256 c ) internal pure { _require(a == b && b == c, Errors.INPUT_LENGTH_MISMATCH); } function ensureArrayIsSorted(IERC20[] memory array) internal pure { address[] memory addressArray; // solhint-disable-next-line no-inline-assembly assembly { addressArray := array } ensureArrayIsSorted(addressArray); } function ensureArrayIsSorted(address[] memory array) internal pure { if (array.length < 2) { return; } address previous = array[0]; for (uint256 i = 1; i < array.length; ++i) { address current = array[i]; _require(previous < current, Errors.UNSORTED_ARRAY); previous = current; } } }
// 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; // solhint-disable /** * @dev Reverts if `condition` is false, with a revert reason containing `errorCode`. Only codes up to 999 are * supported. */ function _require(bool condition, uint256 errorCode) pure { if (!condition) _revert(errorCode); } /** * @dev Reverts with a revert reason containing `errorCode`. Only codes up to 999 are supported. */ function _revert(uint256 errorCode) pure { // We're going to dynamically create a revert string based on the error code, with the following format: // 'BAL#{errorCode}' // where the code is left-padded with zeroes to three digits (so they range from 000 to 999). // // We don't have revert strings embedded in the contract to save bytecode size: it takes much less space to store a // number (8 to 16 bits) than the individual string characters. // // The dynamic string creation algorithm that follows could be implemented in Solidity, but assembly allows for a // much denser implementation, again saving bytecode size. Given this function unconditionally reverts, this is a // safe place to rely on it without worrying about how its usage might affect e.g. memory contents. assembly { // First, we need to compute the ASCII representation of the error code. We assume that it is in the 0-999 // range, so we only need to convert three digits. To convert the digits to ASCII, we add 0x30, the value for // the '0' character. let units := add(mod(errorCode, 10), 0x30) errorCode := div(errorCode, 10) let tenths := add(mod(errorCode, 10), 0x30) errorCode := div(errorCode, 10) let hundreds := add(mod(errorCode, 10), 0x30) // With the individual characters, we can now construct the full string. The "BAL#" part is a known constant // (0x42414c23): we simply shift this by 24 (to provide space for the 3 bytes of the error code), and add the // characters to it, each shifted by a multiple of 8. // The revert reason is then shifted left by 200 bits (256 minus the length of the string, 7 characters * 8 bits // per character = 56) to locate it in the most significant part of the 256 slot (the beginning of a byte // array). let revertReason := shl(200, add(0x42414c23000000, add(add(units, shl(8, tenths)), shl(16, hundreds)))) // We can now encode the reason in memory, which can be safely overwritten as we're about to revert. The encoded // message will have the following layout: // [ revert reason identifier ] [ string location offset ] [ string length ] [ string contents ] // The Solidity revert reason identifier is 0x08c739a0, the function selector of the Error(string) function. We // also write zeroes to the next 28 bytes of memory, but those are about to be overwritten. mstore(0x0, 0x08c379a000000000000000000000000000000000000000000000000000000000) // Next is the offset to the location of the string, which will be placed immediately after (20 bytes away). mstore(0x04, 0x0000000000000000000000000000000000000000000000000000000000000020) // The string length is fixed: 7 characters. mstore(0x24, 7) // Finally, the string itself is stored. mstore(0x44, revertReason) // Even if the string is only 7 bytes long, we need to return a full 32 byte slot containing it. The length of // the encoded message is therefore 4 + 32 + 32 + 32 = 100. revert(0, 100) } } library Errors { // Math uint256 internal constant ADD_OVERFLOW = 0; uint256 internal constant SUB_OVERFLOW = 1; uint256 internal constant SUB_UNDERFLOW = 2; uint256 internal constant MUL_OVERFLOW = 3; uint256 internal constant ZERO_DIVISION = 4; uint256 internal constant DIV_INTERNAL = 5; uint256 internal constant X_OUT_OF_BOUNDS = 6; uint256 internal constant Y_OUT_OF_BOUNDS = 7; uint256 internal constant PRODUCT_OUT_OF_BOUNDS = 8; uint256 internal constant INVALID_EXPONENT = 9; // Input uint256 internal constant OUT_OF_BOUNDS = 100; uint256 internal constant UNSORTED_ARRAY = 101; uint256 internal constant UNSORTED_TOKENS = 102; uint256 internal constant INPUT_LENGTH_MISMATCH = 103; uint256 internal constant ZERO_TOKEN = 104; // Shared pools uint256 internal constant MIN_TOKENS = 200; uint256 internal constant MAX_TOKENS = 201; uint256 internal constant MAX_SWAP_FEE_PERCENTAGE = 202; uint256 internal constant MIN_SWAP_FEE_PERCENTAGE = 203; uint256 internal constant MINIMUM_BPT = 204; uint256 internal constant CALLER_NOT_VAULT = 205; uint256 internal constant UNINITIALIZED = 206; uint256 internal constant BPT_IN_MAX_AMOUNT = 207; uint256 internal constant BPT_OUT_MIN_AMOUNT = 208; uint256 internal constant EXPIRED_PERMIT = 209; uint256 internal constant NOT_TWO_TOKENS = 210; uint256 internal constant DISABLED = 211; // Pools uint256 internal constant MIN_AMP = 300; uint256 internal constant MAX_AMP = 301; uint256 internal constant MIN_WEIGHT = 302; uint256 internal constant MAX_STABLE_TOKENS = 303; uint256 internal constant MAX_IN_RATIO = 304; uint256 internal constant MAX_OUT_RATIO = 305; uint256 internal constant MIN_BPT_IN_FOR_TOKEN_OUT = 306; uint256 internal constant MAX_OUT_BPT_FOR_TOKEN_IN = 307; uint256 internal constant NORMALIZED_WEIGHT_INVARIANT = 308; uint256 internal constant INVALID_TOKEN = 309; uint256 internal constant UNHANDLED_JOIN_KIND = 310; uint256 internal constant ZERO_INVARIANT = 311; uint256 internal constant ORACLE_INVALID_SECONDS_QUERY = 312; uint256 internal constant ORACLE_NOT_INITIALIZED = 313; uint256 internal constant ORACLE_QUERY_TOO_OLD = 314; uint256 internal constant ORACLE_INVALID_INDEX = 315; uint256 internal constant ORACLE_BAD_SECS = 316; uint256 internal constant AMP_END_TIME_TOO_CLOSE = 317; uint256 internal constant AMP_ONGOING_UPDATE = 318; uint256 internal constant AMP_RATE_TOO_HIGH = 319; uint256 internal constant AMP_NO_ONGOING_UPDATE = 320; uint256 internal constant STABLE_INVARIANT_DIDNT_CONVERGE = 321; uint256 internal constant STABLE_GET_BALANCE_DIDNT_CONVERGE = 322; uint256 internal constant RELAYER_NOT_CONTRACT = 323; uint256 internal constant BASE_POOL_RELAYER_NOT_CALLED = 324; uint256 internal constant REBALANCING_RELAYER_REENTERED = 325; uint256 internal constant GRADUAL_UPDATE_TIME_TRAVEL = 326; uint256 internal constant SWAPS_DISABLED = 327; uint256 internal constant CALLER_IS_NOT_LBP_OWNER = 328; uint256 internal constant PRICE_RATE_OVERFLOW = 329; uint256 internal constant INVALID_JOIN_EXIT_KIND_WHILE_SWAPS_DISABLED = 330; uint256 internal constant WEIGHT_CHANGE_TOO_FAST = 331; uint256 internal constant LOWER_GREATER_THAN_UPPER_TARGET = 332; uint256 internal constant UPPER_TARGET_TOO_HIGH = 333; uint256 internal constant UNHANDLED_BY_LINEAR_POOL = 334; uint256 internal constant OUT_OF_TARGET_RANGE = 335; uint256 internal constant UNHANDLED_EXIT_KIND = 336; uint256 internal constant UNAUTHORIZED_EXIT = 337; uint256 internal constant MAX_MANAGEMENT_SWAP_FEE_PERCENTAGE = 338; uint256 internal constant UNHANDLED_BY_MANAGED_POOL = 339; uint256 internal constant UNHANDLED_BY_PHANTOM_POOL = 340; uint256 internal constant TOKEN_DOES_NOT_HAVE_RATE_PROVIDER = 341; uint256 internal constant INVALID_INITIALIZATION = 342; uint256 internal constant OUT_OF_NEW_TARGET_RANGE = 343; uint256 internal constant UNAUTHORIZED_OPERATION = 344; uint256 internal constant UNINITIALIZED_POOL_CONTROLLER = 345; // Lib uint256 internal constant REENTRANCY = 400; uint256 internal constant SENDER_NOT_ALLOWED = 401; uint256 internal constant PAUSED = 402; uint256 internal constant PAUSE_WINDOW_EXPIRED = 403; uint256 internal constant MAX_PAUSE_WINDOW_DURATION = 404; uint256 internal constant MAX_BUFFER_PERIOD_DURATION = 405; uint256 internal constant INSUFFICIENT_BALANCE = 406; uint256 internal constant INSUFFICIENT_ALLOWANCE = 407; uint256 internal constant ERC20_TRANSFER_FROM_ZERO_ADDRESS = 408; uint256 internal constant ERC20_TRANSFER_TO_ZERO_ADDRESS = 409; uint256 internal constant ERC20_MINT_TO_ZERO_ADDRESS = 410; uint256 internal constant ERC20_BURN_FROM_ZERO_ADDRESS = 411; uint256 internal constant ERC20_APPROVE_FROM_ZERO_ADDRESS = 412; uint256 internal constant ERC20_APPROVE_TO_ZERO_ADDRESS = 413; uint256 internal constant ERC20_TRANSFER_EXCEEDS_ALLOWANCE = 414; uint256 internal constant ERC20_DECREASED_ALLOWANCE_BELOW_ZERO = 415; uint256 internal constant ERC20_TRANSFER_EXCEEDS_BALANCE = 416; uint256 internal constant ERC20_BURN_EXCEEDS_ALLOWANCE = 417; uint256 internal constant SAFE_ERC20_CALL_FAILED = 418; uint256 internal constant ADDRESS_INSUFFICIENT_BALANCE = 419; uint256 internal constant ADDRESS_CANNOT_SEND_VALUE = 420; uint256 internal constant SAFE_CAST_VALUE_CANT_FIT_INT256 = 421; uint256 internal constant GRANT_SENDER_NOT_ADMIN = 422; uint256 internal constant REVOKE_SENDER_NOT_ADMIN = 423; uint256 internal constant RENOUNCE_SENDER_NOT_ALLOWED = 424; uint256 internal constant BUFFER_PERIOD_EXPIRED = 425; uint256 internal constant CALLER_IS_NOT_OWNER = 426; uint256 internal constant NEW_OWNER_IS_ZERO = 427; uint256 internal constant CODE_DEPLOYMENT_FAILED = 428; uint256 internal constant CALL_TO_NON_CONTRACT = 429; uint256 internal constant LOW_LEVEL_CALL_FAILED = 430; uint256 internal constant NOT_PAUSED = 431; uint256 internal constant ADDRESS_ALREADY_ALLOWLISTED = 432; uint256 internal constant ADDRESS_NOT_ALLOWLISTED = 433; uint256 internal constant ERC20_BURN_EXCEEDS_BALANCE = 434; // Vault uint256 internal constant INVALID_POOL_ID = 500; uint256 internal constant CALLER_NOT_POOL = 501; uint256 internal constant SENDER_NOT_ASSET_MANAGER = 502; uint256 internal constant USER_DOESNT_ALLOW_RELAYER = 503; uint256 internal constant INVALID_SIGNATURE = 504; uint256 internal constant EXIT_BELOW_MIN = 505; uint256 internal constant JOIN_ABOVE_MAX = 506; uint256 internal constant SWAP_LIMIT = 507; uint256 internal constant SWAP_DEADLINE = 508; uint256 internal constant CANNOT_SWAP_SAME_TOKEN = 509; uint256 internal constant UNKNOWN_AMOUNT_IN_FIRST_SWAP = 510; uint256 internal constant MALCONSTRUCTED_MULTIHOP_SWAP = 511; uint256 internal constant INTERNAL_BALANCE_OVERFLOW = 512; uint256 internal constant INSUFFICIENT_INTERNAL_BALANCE = 513; uint256 internal constant INVALID_ETH_INTERNAL_BALANCE = 514; uint256 internal constant INVALID_POST_LOAN_BALANCE = 515; uint256 internal constant INSUFFICIENT_ETH = 516; uint256 internal constant UNALLOCATED_ETH = 517; uint256 internal constant ETH_TRANSFER = 518; uint256 internal constant CANNOT_USE_ETH_SENTINEL = 519; uint256 internal constant TOKENS_MISMATCH = 520; uint256 internal constant TOKEN_NOT_REGISTERED = 521; uint256 internal constant TOKEN_ALREADY_REGISTERED = 522; uint256 internal constant TOKENS_ALREADY_SET = 523; uint256 internal constant TOKENS_LENGTH_MUST_BE_2 = 524; uint256 internal constant NONZERO_TOKEN_BALANCE = 525; uint256 internal constant BALANCE_TOTAL_OVERFLOW = 526; uint256 internal constant POOL_NO_TOKENS = 527; uint256 internal constant INSUFFICIENT_FLASH_LOAN_BALANCE = 528; // Fees uint256 internal constant SWAP_FEE_PERCENTAGE_TOO_HIGH = 600; uint256 internal constant FLASH_LOAN_FEE_PERCENTAGE_TOO_HIGH = 601; uint256 internal constant INSUFFICIENT_FLASH_LOAN_FEE_AMOUNT = 602; }
// 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; import "../openzeppelin/IERC20.sol"; /** * @dev Interface for WETH9. * See https://github.com/gnosis/canonical-weth/blob/0dd1ea3e295eef916d0c6223ec63141137d22d67/contracts/WETH9.sol */ interface IWETH is IERC20 { function deposit() external payable; function withdraw(uint256 amount) external; }
// 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; import "@balancer-labs/v2-solidity-utils/contracts/openzeppelin/IERC20.sol"; import "@balancer-labs/v2-solidity-utils/contracts/misc/IWETH.sol"; import "./interfaces/IAsset.sol"; abstract contract AssetHelpers { // solhint-disable-next-line var-name-mixedcase IWETH private immutable _weth; // Sentinel value used to indicate WETH with wrapping/unwrapping semantics. The zero address is a good choice for // multiple reasons: it is cheap to pass as a calldata argument, it is a known invalid token and non-contract, and // it is an address Pools cannot register as a token. address private constant _ETH = address(0); constructor(IWETH weth) { _weth = weth; } // solhint-disable-next-line func-name-mixedcase function _WETH() internal view returns (IWETH) { return _weth; } /** * @dev Returns true if `asset` is the sentinel value that represents ETH. */ function _isETH(IAsset asset) internal pure returns (bool) { return address(asset) == _ETH; } /** * @dev Translates `asset` into an equivalent IERC20 token address. If `asset` represents ETH, it will be translated * to the WETH contract. */ function _translateToIERC20(IAsset asset) internal view returns (IERC20) { return _isETH(asset) ? _WETH() : _asIERC20(asset); } /** * @dev Same as `_translateToIERC20(IAsset)`, but for an entire array. */ function _translateToIERC20(IAsset[] memory assets) internal view returns (IERC20[] memory) { IERC20[] memory tokens = new IERC20[](assets.length); for (uint256 i = 0; i < assets.length; ++i) { tokens[i] = _translateToIERC20(assets[i]); } return tokens; } /** * @dev Interprets `asset` as an IERC20 token. This function should only be called on `asset` if `_isETH` previously * returned false for it, that is, if `asset` is guaranteed not to be the ETH sentinel value. */ function _asIERC20(IAsset asset) internal pure returns (IERC20) { return IERC20(address(asset)); } }
// 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 experimental ABIEncoderV2; import "@balancer-labs/v2-solidity-utils/contracts/openzeppelin/IERC20.sol"; import "@balancer-labs/v2-solidity-utils/contracts/helpers/ISignaturesValidator.sol"; import "@balancer-labs/v2-solidity-utils/contracts/helpers/ITemporarilyPausable.sol"; import "@balancer-labs/v2-solidity-utils/contracts/misc/IWETH.sol"; import "./IAsset.sol"; import "./IAuthorizer.sol"; import "./IFlashLoanRecipient.sol"; import "./IProtocolFeesCollector.sol"; pragma solidity ^0.7.0; /** * @dev Full external interface for the Vault core contract - no external or public methods exist in the contract that * don't override one of these declarations. */ interface IVault is ISignaturesValidator, ITemporarilyPausable { // Generalities about the Vault: // // - Whenever documentation refers to 'tokens', it strictly refers to ERC20-compliant token contracts. Tokens are // transferred out of the Vault by calling the `IERC20.transfer` function, and transferred in by calling // `IERC20.transferFrom`. In these cases, the sender must have previously allowed the Vault to use their tokens by // calling `IERC20.approve`. The only deviation from the ERC20 standard that is supported is functions not returning // a boolean value: in these scenarios, a non-reverting call is assumed to be successful. // // - All non-view functions in the Vault are non-reentrant: calling them while another one is mid-execution (e.g. // while execution control is transferred to a token contract during a swap) will result in a revert. View // functions can be called in a re-reentrant way, but doing so might cause them to return inconsistent results. // Contracts calling view functions in the Vault must make sure the Vault has not already been entered. // // - View functions revert if referring to either unregistered Pools, or unregistered tokens for registered Pools. // Authorizer // // Some system actions are permissioned, like setting and collecting protocol fees. This permissioning system exists // outside of the Vault in the Authorizer contract: the Vault simply calls the Authorizer to check if the caller // can perform a given action. /** * @dev Returns the Vault's Authorizer. */ function getAuthorizer() external view returns (IAuthorizer); /** * @dev Sets a new Authorizer for the Vault. The caller must be allowed by the current Authorizer to do this. * * Emits an `AuthorizerChanged` event. */ function setAuthorizer(IAuthorizer newAuthorizer) external; /** * @dev Emitted when a new authorizer is set by `setAuthorizer`. */ event AuthorizerChanged(IAuthorizer indexed newAuthorizer); // Relayers // // Additionally, it is possible for an account to perform certain actions on behalf of another one, using their // Vault ERC20 allowance and Internal Balance. These accounts are said to be 'relayers' for these Vault functions, // and are expected to be smart contracts with sound authentication mechanisms. For an account to be able to wield // this power, two things must occur: // - The Authorizer must grant the account the permission to be a relayer for the relevant Vault function. This // means that Balancer governance must approve each individual contract to act as a relayer for the intended // functions. // - Each user must approve the relayer to act on their behalf. // This double protection means users cannot be tricked into approving malicious relayers (because they will not // have been allowed by the Authorizer via governance), nor can malicious relayers approved by a compromised // Authorizer or governance drain user funds, since they would also need to be approved by each individual user. /** * @dev Returns true if `user` has approved `relayer` to act as a relayer for them. */ function hasApprovedRelayer(address user, address relayer) external view returns (bool); /** * @dev Allows `relayer` to act as a relayer for `sender` if `approved` is true, and disallows it otherwise. * * Emits a `RelayerApprovalChanged` event. */ function setRelayerApproval( address sender, address relayer, bool approved ) external; /** * @dev Emitted every time a relayer is approved or disapproved by `setRelayerApproval`. */ event RelayerApprovalChanged(address indexed relayer, address indexed sender, bool approved); // Internal Balance // // Users can deposit tokens into the Vault, where they are allocated to their Internal Balance, and later // transferred or withdrawn. It can also be used as a source of tokens when joining Pools, as a destination // when exiting them, and as either when performing swaps. This usage of Internal Balance results in greatly reduced // gas costs when compared to relying on plain ERC20 transfers, leading to large savings for frequent users. // // Internal Balance management features batching, which means a single contract call can be used to perform multiple // operations of different kinds, with different senders and recipients, at once. /** * @dev Returns `user`'s Internal Balance for a set of tokens. */ function getInternalBalance(address user, IERC20[] memory tokens) external view returns (uint256[] memory); /** * @dev Performs a set of user balance operations, which involve Internal Balance (deposit, withdraw or transfer) * and plain ERC20 transfers using the Vault's allowance. This last feature is particularly useful for relayers, as * it lets integrators reuse a user's Vault allowance. * * For each operation, if the caller is not `sender`, it must be an authorized relayer for them. */ function manageUserBalance(UserBalanceOp[] memory ops) external payable; /** * @dev Data for `manageUserBalance` operations, which include the possibility for ETH to be sent and received without manual WETH wrapping or unwrapping. */ struct UserBalanceOp { UserBalanceOpKind kind; IAsset asset; uint256 amount; address sender; address payable recipient; } // There are four possible operations in `manageUserBalance`: // // - DEPOSIT_INTERNAL // Increases the Internal Balance of the `recipient` account by transferring tokens from the corresponding // `sender`. The sender must have allowed the Vault to use their tokens via `IERC20.approve()`. // // ETH can be used by passing the ETH sentinel value as the asset and forwarding ETH in the call: it will be wrapped // and deposited as WETH. Any ETH amount remaining will be sent back to the caller (not the sender, which is // relevant for relayers). // // Emits an `InternalBalanceChanged` event. // // // - WITHDRAW_INTERNAL // Decreases the Internal Balance of the `sender` account by transferring tokens to the `recipient`. // // ETH can be used by passing the ETH sentinel value as the asset. This will deduct WETH instead, unwrap it and send // it to the recipient as ETH. // // Emits an `InternalBalanceChanged` event. // // // - TRANSFER_INTERNAL // Transfers tokens from the Internal Balance of the `sender` account to the Internal Balance of `recipient`. // // Reverts if the ETH sentinel value is passed. // // Emits an `InternalBalanceChanged` event. // // // - TRANSFER_EXTERNAL // Transfers tokens from `sender` to `recipient`, using the Vault's ERC20 allowance. This is typically used by // relayers, as it lets them reuse a user's Vault allowance. // // Reverts if the ETH sentinel value is passed. // // Emits an `ExternalBalanceTransfer` event. enum UserBalanceOpKind { DEPOSIT_INTERNAL, WITHDRAW_INTERNAL, TRANSFER_INTERNAL, TRANSFER_EXTERNAL } /** * @dev Emitted when a user's Internal Balance changes, either from calls to `manageUserBalance`, or through * interacting with Pools using Internal Balance. * * Because Internal Balance works exclusively with ERC20 tokens, ETH deposits and withdrawals will use the WETH * address. */ event InternalBalanceChanged(address indexed user, IERC20 indexed token, int256 delta); /** * @dev Emitted when a user's Vault ERC20 allowance is used by the Vault to transfer tokens to an external account. */ event ExternalBalanceTransfer(IERC20 indexed token, address indexed sender, address recipient, uint256 amount); // Pools // // There are three specialization settings for Pools, which allow for cheaper swaps at the cost of reduced // functionality: // // - General: no specialization, suited for all Pools. IGeneralPool is used for swap request callbacks, passing the // balance of all tokens in the Pool. These Pools have the largest swap costs (because of the extra storage reads), // which increase with the number of registered tokens. // // - Minimal Swap Info: IMinimalSwapInfoPool is used instead of IGeneralPool, which saves gas by only passing the // balance of the two tokens involved in the swap. This is suitable for some pricing algorithms, like the weighted // constant product one popularized by Balancer V1. Swap costs are smaller compared to general Pools, and are // independent of the number of registered tokens. // // - Two Token: only allows two tokens to be registered. This achieves the lowest possible swap gas cost. Like // minimal swap info Pools, these are called via IMinimalSwapInfoPool. enum PoolSpecialization { GENERAL, MINIMAL_SWAP_INFO, TWO_TOKEN } /** * @dev Registers the caller account as a Pool with a given specialization setting. Returns the Pool's ID, which * is used in all Pool-related functions. Pools cannot be deregistered, nor can the Pool's specialization be * changed. * * The caller is expected to be a smart contract that implements either `IGeneralPool` or `IMinimalSwapInfoPool`, * depending on the chosen specialization setting. This contract is known as the Pool's contract. * * Note that the same contract may register itself as multiple Pools with unique Pool IDs, or in other words, * multiple Pools may share the same contract. * * Emits a `PoolRegistered` event. */ function registerPool(PoolSpecialization specialization) external returns (bytes32); /** * @dev Emitted when a Pool is registered by calling `registerPool`. */ event PoolRegistered(bytes32 indexed poolId, address indexed poolAddress, PoolSpecialization specialization); /** * @dev Returns a Pool's contract address and specialization setting. */ function getPool(bytes32 poolId) external view returns (address, PoolSpecialization); /** * @dev Registers `tokens` for the `poolId` Pool. Must be called by the Pool's contract. * * Pools can only interact with tokens they have registered. Users join a Pool by transferring registered tokens, * exit by receiving registered tokens, and can only swap registered tokens. * * Each token can only be registered once. For Pools with the Two Token specialization, `tokens` must have a length * of two, that is, both tokens must be registered in the same `registerTokens` call, and they must be sorted in * ascending order. * * The `tokens` and `assetManagers` arrays must have the same length, and each entry in these indicates the Asset * Manager for the corresponding token. Asset Managers can manage a Pool's tokens via `managePoolBalance`, * depositing and withdrawing them directly, and can even set their balance to arbitrary amounts. They are therefore * expected to be highly secured smart contracts with sound design principles, and the decision to register an * Asset Manager should not be made lightly. * * Pools can choose not to assign an Asset Manager to a given token by passing in the zero address. Once an Asset * Manager is set, it cannot be changed except by deregistering the associated token and registering again with a * different Asset Manager. * * Emits a `TokensRegistered` event. */ function registerTokens( bytes32 poolId, IERC20[] memory tokens, address[] memory assetManagers ) external; /** * @dev Emitted when a Pool registers tokens by calling `registerTokens`. */ event TokensRegistered(bytes32 indexed poolId, IERC20[] tokens, address[] assetManagers); /** * @dev Deregisters `tokens` for the `poolId` Pool. Must be called by the Pool's contract. * * Only registered tokens (via `registerTokens`) can be deregistered. Additionally, they must have zero total * balance. For Pools with the Two Token specialization, `tokens` must have a length of two, that is, both tokens * must be deregistered in the same `deregisterTokens` call. * * A deregistered token can be re-registered later on, possibly with a different Asset Manager. * * Emits a `TokensDeregistered` event. */ function deregisterTokens(bytes32 poolId, IERC20[] memory tokens) external; /** * @dev Emitted when a Pool deregisters tokens by calling `deregisterTokens`. */ event TokensDeregistered(bytes32 indexed poolId, IERC20[] tokens); /** * @dev Returns detailed information for a Pool's registered token. * * `cash` is the number of tokens the Vault currently holds for the Pool. `managed` is the number of tokens * withdrawn and held outside the Vault by the Pool's token Asset Manager. The Pool's total balance for `token` * equals the sum of `cash` and `managed`. * * Internally, `cash` and `managed` are stored using 112 bits. No action can ever cause a Pool's token `cash`, * `managed` or `total` balance to be greater than 2^112 - 1. * * `lastChangeBlock` is the number of the block in which `token`'s total balance was last modified (via either a * join, exit, swap, or Asset Manager update). This value is useful to avoid so-called 'sandwich attacks', for * example when developing price oracles. A change of zero (e.g. caused by a swap with amount zero) is considered a * change for this purpose, and will update `lastChangeBlock`. * * `assetManager` is the Pool's token Asset Manager. */ function getPoolTokenInfo(bytes32 poolId, IERC20 token) external view returns ( uint256 cash, uint256 managed, uint256 lastChangeBlock, address assetManager ); /** * @dev Returns a Pool's registered tokens, the total balance for each, and the latest block when *any* of * the tokens' `balances` changed. * * The order of the `tokens` array is the same order that will be used in `joinPool`, `exitPool`, as well as in all * Pool hooks (where applicable). Calls to `registerTokens` and `deregisterTokens` may change this order. * * If a Pool only registers tokens once, and these are sorted in ascending order, they will be stored in the same * order as passed to `registerTokens`. * * Total balances include both tokens held by the Vault and those withdrawn by the Pool's Asset Managers. These are * the amounts used by joins, exits and swaps. For a detailed breakdown of token balances, use `getPoolTokenInfo` * instead. */ function getPoolTokens(bytes32 poolId) external view returns ( IERC20[] memory tokens, uint256[] memory balances, uint256 lastChangeBlock ); /** * @dev Called by users to join a Pool, which transfers tokens from `sender` into the Pool's balance. This will * trigger custom Pool behavior, which will typically grant something in return to `recipient` - often tokenized * Pool shares. * * If the caller is not `sender`, it must be an authorized relayer for them. * * The `assets` and `maxAmountsIn` arrays must have the same length, and each entry indicates the maximum amount * to send for each asset. The amounts to send are decided by the Pool and not the Vault: it just enforces * these maximums. * * If joining a Pool that holds WETH, it is possible to send ETH directly: the Vault will do the wrapping. To enable * this mechanism, the IAsset sentinel value (the zero address) must be passed in the `assets` array instead of the * WETH address. Note that it is not possible to combine ETH and WETH in the same join. Any excess ETH will be sent * back to the caller (not the sender, which is important for relayers). * * `assets` must have the same length and order as the array returned by `getPoolTokens`. This prevents issues when * interacting with Pools that register and deregister tokens frequently. If sending ETH however, the array must be * sorted *before* replacing the WETH address with the ETH sentinel value (the zero address), which means the final * `assets` array might not be sorted. Pools with no registered tokens cannot be joined. * * If `fromInternalBalance` is true, the caller's Internal Balance will be preferred: ERC20 transfers will only * be made for the difference between the requested amount and Internal Balance (if any). Note that ETH cannot be * withdrawn from Internal Balance: attempting to do so will trigger a revert. * * This causes the Vault to call the `IBasePool.onJoinPool` hook on the Pool's contract, where Pools implement * their own custom logic. This typically requires additional information from the user (such as the expected number * of Pool shares). This can be encoded in the `userData` argument, which is ignored by the Vault and passed * directly to the Pool's contract, as is `recipient`. * * Emits a `PoolBalanceChanged` event. */ function joinPool( bytes32 poolId, address sender, address recipient, JoinPoolRequest memory request ) external payable; struct JoinPoolRequest { IAsset[] assets; uint256[] maxAmountsIn; bytes userData; bool fromInternalBalance; } /** * @dev Called by users to exit a Pool, which transfers tokens from the Pool's balance to `recipient`. This will * trigger custom Pool behavior, which will typically ask for something in return from `sender` - often tokenized * Pool shares. The amount of tokens that can be withdrawn is limited by the Pool's `cash` balance (see * `getPoolTokenInfo`). * * If the caller is not `sender`, it must be an authorized relayer for them. * * The `tokens` and `minAmountsOut` arrays must have the same length, and each entry in these indicates the minimum * token amount to receive for each token contract. The amounts to send are decided by the Pool and not the Vault: * it just enforces these minimums. * * If exiting a Pool that holds WETH, it is possible to receive ETH directly: the Vault will do the unwrapping. To * enable this mechanism, the IAsset sentinel value (the zero address) must be passed in the `assets` array instead * of the WETH address. Note that it is not possible to combine ETH and WETH in the same exit. * * `assets` must have the same length and order as the array returned by `getPoolTokens`. This prevents issues when * interacting with Pools that register and deregister tokens frequently. If receiving ETH however, the array must * be sorted *before* replacing the WETH address with the ETH sentinel value (the zero address), which means the * final `assets` array might not be sorted. Pools with no registered tokens cannot be exited. * * If `toInternalBalance` is true, the tokens will be deposited to `recipient`'s Internal Balance. Otherwise, * an ERC20 transfer will be performed. Note that ETH cannot be deposited to Internal Balance: attempting to * do so will trigger a revert. * * `minAmountsOut` is the minimum amount of tokens the user expects to get out of the Pool, for each token in the * `tokens` array. This array must match the Pool's registered tokens. * * This causes the Vault to call the `IBasePool.onExitPool` hook on the Pool's contract, where Pools implement * their own custom logic. This typically requires additional information from the user (such as the expected number * of Pool shares to return). This can be encoded in the `userData` argument, which is ignored by the Vault and * passed directly to the Pool's contract. * * Emits a `PoolBalanceChanged` event. */ function exitPool( bytes32 poolId, address sender, address payable recipient, ExitPoolRequest memory request ) external; struct ExitPoolRequest { IAsset[] assets; uint256[] minAmountsOut; bytes userData; bool toInternalBalance; } /** * @dev Emitted when a user joins or exits a Pool by calling `joinPool` or `exitPool`, respectively. */ event PoolBalanceChanged( bytes32 indexed poolId, address indexed liquidityProvider, IERC20[] tokens, int256[] deltas, uint256[] protocolFeeAmounts ); enum PoolBalanceChangeKind { JOIN, EXIT } // Swaps // // Users can swap tokens with Pools by calling the `swap` and `batchSwap` functions. To do this, // they need not trust Pool contracts in any way: all security checks are made by the Vault. They must however be // aware of the Pools' pricing algorithms in order to estimate the prices Pools will quote. // // The `swap` function executes a single swap, while `batchSwap` can perform multiple swaps in sequence. // In each individual swap, tokens of one kind are sent from the sender to the Pool (this is the 'token in'), // and tokens of another kind are sent from the Pool to the recipient in exchange (this is the 'token out'). // More complex swaps, such as one token in to multiple tokens out can be achieved by batching together // individual swaps. // // There are two swap kinds: // - 'given in' swaps, where the amount of tokens in (sent to the Pool) is known, and the Pool determines (via the // `onSwap` hook) the amount of tokens out (to send to the recipient). // - 'given out' swaps, where the amount of tokens out (received from the Pool) is known, and the Pool determines // (via the `onSwap` hook) the amount of tokens in (to receive from the sender). // // Additionally, it is possible to chain swaps using a placeholder input amount, which the Vault replaces with // the calculated output of the previous swap. If the previous swap was 'given in', this will be the calculated // tokenOut amount. If the previous swap was 'given out', it will use the calculated tokenIn amount. These extended // swaps are known as 'multihop' swaps, since they 'hop' through a number of intermediate tokens before arriving at // the final intended token. // // In all cases, tokens are only transferred in and out of the Vault (or withdrawn from and deposited into Internal // Balance) after all individual swaps have been completed, and the net token balance change computed. This makes // certain swap patterns, such as multihops, or swaps that interact with the same token pair in multiple Pools, cost // much less gas than they would otherwise. // // It also means that under certain conditions it is possible to perform arbitrage by swapping with multiple // Pools in a way that results in net token movement out of the Vault (profit), with no tokens being sent in (only // updating the Pool's internal accounting). // // To protect users from front-running or the market changing rapidly, they supply a list of 'limits' for each token // involved in the swap, where either the maximum number of tokens to send (by passing a positive value) or the // minimum amount of tokens to receive (by passing a negative value) is specified. // // Additionally, a 'deadline' timestamp can also be provided, forcing the swap to fail if it occurs after // this point in time (e.g. if the transaction failed to be included in a block promptly). // // If interacting with Pools that hold WETH, it is possible to both send and receive ETH directly: the Vault will do // the wrapping and unwrapping. To enable this mechanism, the IAsset sentinel value (the zero address) must be // passed in the `assets` array instead of the WETH address. Note that it is possible to combine ETH and WETH in the // same swap. Any excess ETH will be sent back to the caller (not the sender, which is relevant for relayers). // // Finally, Internal Balance can be used when either sending or receiving tokens. enum SwapKind { GIVEN_IN, GIVEN_OUT } /** * @dev Performs a swap with a single Pool. * * If the swap is 'given in' (the number of tokens to send to the Pool is known), it returns the amount of tokens * taken from the Pool, which must be greater than or equal to `limit`. * * If the swap is 'given out' (the number of tokens to take from the Pool is known), it returns the amount of tokens * sent to the Pool, which must be less than or equal to `limit`. * * Internal Balance usage and the recipient are determined by the `funds` struct. * * Emits a `Swap` event. */ function swap( SingleSwap memory singleSwap, FundManagement memory funds, uint256 limit, uint256 deadline ) external payable returns (uint256); /** * @dev Data for a single swap executed by `swap`. `amount` is either `amountIn` or `amountOut` depending on * the `kind` value. * * `assetIn` and `assetOut` are either token addresses, or the IAsset sentinel value for ETH (the zero address). * Note that Pools never interact with ETH directly: it will be wrapped to or unwrapped from WETH by the Vault. * * The `userData` field is ignored by the Vault, but forwarded to the Pool in the `onSwap` hook, and may be * used to extend swap behavior. */ struct SingleSwap { bytes32 poolId; SwapKind kind; IAsset assetIn; IAsset assetOut; uint256 amount; bytes userData; } /** * @dev Performs a series of swaps with one or multiple Pools. In each individual swap, the caller determines either * the amount of tokens sent to or received from the Pool, depending on the `kind` value. * * Returns an array with the net Vault asset balance deltas. Positive amounts represent tokens (or ETH) sent to the * Vault, and negative amounts represent tokens (or ETH) sent by the Vault. Each delta corresponds to the asset at * the same index in the `assets` array. * * Swaps are executed sequentially, in the order specified by the `swaps` array. Each array element describes a * Pool, the token to be sent to this Pool, the token to receive from it, and an amount that is either `amountIn` or * `amountOut` depending on the swap kind. * * Multihop swaps can be executed by passing an `amount` value of zero for a swap. This will cause the amount in/out * of the previous swap to be used as the amount in for the current one. In a 'given in' swap, 'tokenIn' must equal * the previous swap's `tokenOut`. For a 'given out' swap, `tokenOut` must equal the previous swap's `tokenIn`. * * The `assets` array contains the addresses of all assets involved in the swaps. These are either token addresses, * or the IAsset sentinel value for ETH (the zero address). Each entry in the `swaps` array specifies tokens in and * out by referencing an index in `assets`. Note that Pools never interact with ETH directly: it will be wrapped to * or unwrapped from WETH by the Vault. * * Internal Balance usage, sender, and recipient are determined by the `funds` struct. The `limits` array specifies * the minimum or maximum amount of each token the vault is allowed to transfer. * * `batchSwap` can be used to make a single swap, like `swap` does, but doing so requires more gas than the * equivalent `swap` call. * * Emits `Swap` events. */ function batchSwap( SwapKind kind, BatchSwapStep[] memory swaps, IAsset[] memory assets, FundManagement memory funds, int256[] memory limits, uint256 deadline ) external payable returns (int256[] memory); /** * @dev Data for each individual swap executed by `batchSwap`. The asset in and out fields are indexes into the * `assets` array passed to that function, and ETH assets are converted to WETH. * * If `amount` is zero, the multihop mechanism is used to determine the actual amount based on the amount in/out * from the previous swap, depending on the swap kind. * * The `userData` field is ignored by the Vault, but forwarded to the Pool in the `onSwap` hook, and may be * used to extend swap behavior. */ struct BatchSwapStep { bytes32 poolId; uint256 assetInIndex; uint256 assetOutIndex; uint256 amount; bytes userData; } /** * @dev Emitted for each individual swap performed by `swap` or `batchSwap`. */ event Swap( bytes32 indexed poolId, IERC20 indexed tokenIn, IERC20 indexed tokenOut, uint256 amountIn, uint256 amountOut ); /** * @dev All tokens in a swap are either sent from the `sender` account to the Vault, or from the Vault to the * `recipient` account. * * If the caller is not `sender`, it must be an authorized relayer for them. * * If `fromInternalBalance` is true, the `sender`'s Internal Balance will be preferred, performing an ERC20 * transfer for the difference between the requested amount and the User's Internal Balance (if any). The `sender` * must have allowed the Vault to use their tokens via `IERC20.approve()`. This matches the behavior of * `joinPool`. * * If `toInternalBalance` is true, tokens will be deposited to `recipient`'s internal balance instead of * transferred. This matches the behavior of `exitPool`. * * Note that ETH cannot be deposited to or withdrawn from Internal Balance: attempting to do so will trigger a * revert. */ struct FundManagement { address sender; bool fromInternalBalance; address payable recipient; bool toInternalBalance; } /** * @dev Simulates a call to `batchSwap`, returning an array of Vault asset deltas. Calls to `swap` cannot be * simulated directly, but an equivalent `batchSwap` call can and will yield the exact same result. * * Each element in the array corresponds to the asset at the same index, and indicates the number of tokens (or ETH) * the Vault would take from the sender (if positive) or send to the recipient (if negative). The arguments it * receives are the same that an equivalent `batchSwap` call would receive. * * Unlike `batchSwap`, this function performs no checks on the sender or recipient field in the `funds` struct. * This makes it suitable to be called by off-chain applications via eth_call without needing to hold tokens, * approve them for the Vault, or even know a user's address. * * Note that this function is not 'view' (due to implementation details): the client code must explicitly execute * eth_call instead of eth_sendTransaction. */ function queryBatchSwap( SwapKind kind, BatchSwapStep[] memory swaps, IAsset[] memory assets, FundManagement memory funds ) external returns (int256[] memory assetDeltas); // Flash Loans /** * @dev Performs a 'flash loan', sending tokens to `recipient`, executing the `receiveFlashLoan` hook on it, * and then reverting unless the tokens plus a proportional protocol fee have been returned. * * The `tokens` and `amounts` arrays must have the same length, and each entry in these indicates the loan amount * for each token contract. `tokens` must be sorted in ascending order. * * The 'userData' field is ignored by the Vault, and forwarded as-is to `recipient` as part of the * `receiveFlashLoan` call. * * Emits `FlashLoan` events. */ function flashLoan( IFlashLoanRecipient recipient, IERC20[] memory tokens, uint256[] memory amounts, bytes memory userData ) external; /** * @dev Emitted for each individual flash loan performed by `flashLoan`. */ event FlashLoan(IFlashLoanRecipient indexed recipient, IERC20 indexed token, uint256 amount, uint256 feeAmount); // Asset Management // // Each token registered for a Pool can be assigned an Asset Manager, which is able to freely withdraw the Pool's // tokens from the Vault, deposit them, or assign arbitrary values to its `managed` balance (see // `getPoolTokenInfo`). This makes them extremely powerful and dangerous. Even if an Asset Manager only directly // controls one of the tokens in a Pool, a malicious manager could set that token's balance to manipulate the // prices of the other tokens, and then drain the Pool with swaps. The risk of using Asset Managers is therefore // not constrained to the tokens they are managing, but extends to the entire Pool's holdings. // // However, a properly designed Asset Manager smart contract can be safely used for the Pool's benefit, // for example by lending unused tokens out for interest, or using them to participate in voting protocols. // // This concept is unrelated to the IAsset interface. /** * @dev Performs a set of Pool balance operations, which may be either withdrawals, deposits or updates. * * Pool Balance management features batching, which means a single contract call can be used to perform multiple * operations of different kinds, with different Pools and tokens, at once. * * For each operation, the caller must be registered as the Asset Manager for `token` in `poolId`. */ function managePoolBalance(PoolBalanceOp[] memory ops) external; struct PoolBalanceOp { PoolBalanceOpKind kind; bytes32 poolId; IERC20 token; uint256 amount; } /** * Withdrawals decrease the Pool's cash, but increase its managed balance, leaving the total balance unchanged. * * Deposits increase the Pool's cash, but decrease its managed balance, leaving the total balance unchanged. * * Updates don't affect the Pool's cash balance, but because the managed balance changes, it does alter the total. * The external amount can be either increased or decreased by this call (i.e., reporting a gain or a loss). */ enum PoolBalanceOpKind { WITHDRAW, DEPOSIT, UPDATE } /** * @dev Emitted when a Pool's token Asset Manager alters its balance via `managePoolBalance`. */ event PoolBalanceManaged( bytes32 indexed poolId, address indexed assetManager, IERC20 indexed token, int256 cashDelta, int256 managedDelta ); // Protocol Fees // // Some operations cause the Vault to collect tokens in the form of protocol fees, which can then be withdrawn by // permissioned accounts. // // There are two kinds of protocol fees: // // - flash loan fees: charged on all flash loans, as a percentage of the amounts lent. // // - swap fees: a percentage of the fees charged by Pools when performing swaps. For a number of reasons, including // swap gas costs and interface simplicity, protocol swap fees are not charged on each individual swap. Rather, // Pools are expected to keep track of how much they have charged in swap fees, and pay any outstanding debts to the // Vault when they are joined or exited. This prevents users from joining a Pool with unpaid debt, as well as // exiting a Pool in debt without first paying their share. /** * @dev Returns the current protocol fee module. */ function getProtocolFeesCollector() external view returns (IProtocolFeesCollector); /** * @dev Safety mechanism to pause most Vault operations in the event of an emergency - typically detection of an * error in some part of the system. * * The Vault can only be paused during an initial time period, after which pausing is forever disabled. * * While the contract is paused, the following features are disabled: * - depositing and transferring internal balance * - transferring external balance (using the Vault's allowance) * - swaps * - joining Pools * - Asset Manager interactions * * Internal Balance can still be withdrawn, and Pools exited. */ function setPaused(bool paused) external; /** * @dev Returns the Vault's WETH instance. */ function WETH() external view returns (IWETH); // solhint-disable-previous-line func-name-mixedcase }
// SPDX-License-Identifier: MIT pragma solidity ^0.7.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom( address sender, address recipient, uint256 amount ) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); }
// 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; /** * @dev This is an empty interface used to represent either ERC20-conforming token contracts or ETH (using the zero * address sentinel value). We're just relying on the fact that `interface` can be used to declare new address-like * types. * * This concept is unrelated to a Pool's Asset Managers. */ interface IAsset { // solhint-disable-previous-line no-empty-blocks }
// 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; /** * @dev Interface for the SignatureValidator helper, used to support meta-transactions. */ interface ISignaturesValidator { /** * @dev Returns the EIP712 domain separator. */ function getDomainSeparator() external view returns (bytes32); /** * @dev Returns the next nonce used by an address to sign messages. */ function getNextNonce(address user) external view returns (uint256); }
// 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; /** * @dev Interface for the TemporarilyPausable helper. */ interface ITemporarilyPausable { /** * @dev Emitted every time the pause state changes by `_setPaused`. */ event PausedStateChanged(bool paused); /** * @dev Returns the current paused state. */ function getPausedState() external view returns ( bool paused, uint256 pauseWindowEndTime, uint256 bufferPeriodEndTime ); }
// 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; interface IAuthorizer { /** * @dev Returns true if `account` can perform the action described by `actionId` in the contract `where`. */ function canPerform( bytes32 actionId, address account, address where ) external view returns (bool); }
// 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; // Inspired by Aave Protocol's IFlashLoanReceiver. import "@balancer-labs/v2-solidity-utils/contracts/openzeppelin/IERC20.sol"; interface IFlashLoanRecipient { /** * @dev When `flashLoan` is called on the Vault, it invokes the `receiveFlashLoan` hook on the recipient. * * At the time of the call, the Vault will have transferred `amounts` for `tokens` to the recipient. Before this * call returns, the recipient must have transferred `amounts` plus `feeAmounts` for each token back to the * Vault, or else the entire flash loan will revert. * * `userData` is the same value passed in the `IVault.flashLoan` call. */ function receiveFlashLoan( IERC20[] memory tokens, uint256[] memory amounts, uint256[] memory feeAmounts, bytes memory userData ) external; }
// 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; pragma experimental ABIEncoderV2; import "@balancer-labs/v2-solidity-utils/contracts/openzeppelin/IERC20.sol"; import "./IVault.sol"; import "./IAuthorizer.sol"; interface IProtocolFeesCollector { event SwapFeePercentageChanged(uint256 newSwapFeePercentage); event FlashLoanFeePercentageChanged(uint256 newFlashLoanFeePercentage); function withdrawCollectedFees( IERC20[] calldata tokens, uint256[] calldata amounts, address recipient ) external; function setSwapFeePercentage(uint256 newSwapFeePercentage) external; function setFlashLoanFeePercentage(uint256 newFlashLoanFeePercentage) external; function getSwapFeePercentage() external view returns (uint256); function getFlashLoanFeePercentage() external view returns (uint256); function getCollectedFeeAmounts(IERC20[] memory tokens) external view returns (uint256[] memory feeAmounts); function getAuthorizer() external view returns (IAuthorizer); function vault() external view returns (IVault); }
// SPDX-License-Identifier: MIT pragma solidity ^0.7.0; /** * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612]. * * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by * presenting a message signed by the account. By not relying on `{IERC20-approve}`, the token holder account doesn't * need to send a transaction, and thus is not required to hold Ether at all. */ interface IERC20Permit { /** * @dev Sets `value` as the allowance of `spender` over `owner`'s tokens, * given `owner`'s signed approval. * * IMPORTANT: The same issues {IERC20-approve} has related to transaction * ordering also apply here. * * Emits an {Approval} event. * * Requirements: * * - `spender` cannot be the zero address. * - `deadline` must be a timestamp in the future. * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner` * over the EIP712-formatted function arguments. * - the signature must use ``owner``'s current nonce (see {nonces}). * * For more information on the signature format, see the * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP * section]. */ function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) external; /** * @dev Returns the current nonce for `owner`. This value must be * included whenever a signature is generated for {permit}. * * Every successful call to {permit} increases ``owner``'s nonce by one. This * prevents a signature from being used multiple times. */ function nonces(address owner) external view returns (uint256); /** * @dev Returns the domain separator used in the encoding of the signature for `permit`, as defined by {EIP712}. */ // solhint-disable-next-line func-name-mixedcase function DOMAIN_SEPARATOR() external view returns (bytes32); }
// SPDX-License-Identifier: MIT // Based on the ReentrancyGuard library from OpenZeppelin Contracts, altered to reduce bytecode size. // Modifier code is inlined by the compiler, which causes its code to appear multiple times in the codebase. By using // private functions, we achieve the same end result with slightly higher runtime gas costs, but reduced bytecode size. pragma solidity ^0.7.0; import "../helpers/BalancerErrors.sol"; /** * @dev Contract module that helps prevent reentrant calls to a function. * * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier * available, which can be applied to functions to make sure there are no nested * (reentrant) calls to them. * * Note that because there is a single `nonReentrant` guard, functions marked as * `nonReentrant` may not call one another. This can be worked around by making * those functions `private`, and then adding `external` `nonReentrant` entry * points to them. * * TIP: If you would like to learn more about reentrancy and alternative ways * to protect against it, check out our blog post * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul]. */ abstract contract ReentrancyGuard { // Booleans are more expensive than uint256 or any type that takes up a full // word because each write operation emits an extra SLOAD to first read the // slot's contents, replace the bits taken up by the boolean, and then write // back. This is the compiler's defense against contract upgrades and // pointer aliasing, and it cannot be disabled. // The values being non-zero value makes deployment a bit more expensive, // but in exchange the refund on every call to nonReentrant will be lower in // amount. Since refunds are capped to a percentage of the total // transaction's gas, it is best to keep them low in cases like this one, to // increase the likelihood of the full refund coming into effect. uint256 private constant _NOT_ENTERED = 1; uint256 private constant _ENTERED = 2; uint256 private _status; constructor() { _status = _NOT_ENTERED; } /** * @dev Prevents a contract from calling itself, directly or indirectly. * Calling a `nonReentrant` function from another `nonReentrant` * function is not supported. It is possible to prevent this from happening * by making the `nonReentrant` function external, and make it call a * `private` function that does the actual work. */ modifier nonReentrant() { _enterNonReentrant(); _; _exitNonReentrant(); } function _enterNonReentrant() private { // On the first call to nonReentrant, _status will be _NOT_ENTERED _require(_status != _ENTERED, Errors.REENTRANCY); // Any calls to nonReentrant after this point will fail _status = _ENTERED; } function _exitNonReentrant() private { // By storing the original value once again, a refund is triggered (see // https://eips.ethereum.org/EIPS/eip-2200) _status = _NOT_ENTERED; } }
// 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; pragma experimental ABIEncoderV2; import "@balancer-labs/v2-solidity-utils/contracts/openzeppelin/Address.sol"; import "@balancer-labs/v2-solidity-utils/contracts/openzeppelin/ReentrancyGuard.sol"; import "@balancer-labs/v2-vault/contracts/interfaces/IVault.sol"; /** * @title IBalancerRelayer * @notice Allows safe multicall execution of a relayer's functions */ interface IBalancerRelayer { function getLibrary() external view returns (address); function getVault() external view returns (IVault); function multicall(bytes[] calldata data) external payable returns (bytes[] memory results); }
// SPDX-License-Identifier: MIT // Based on the Address library from OpenZeppelin Contracts, altered by removing the `isContract` checks on // `functionCall` and `functionDelegateCall` in order to save gas, as the recipients are known to be contracts. pragma solidity ^0.7.0; import "../helpers/BalancerErrors.sol"; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; // solhint-disable-next-line no-inline-assembly assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { _require(address(this).balance >= amount, Errors.ADDRESS_INSUFFICIENT_BALANCE); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); _require(success, Errors.ADDRESS_CANNOT_SEND_VALUE); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { (bool success, bytes memory returndata) = target.call(data); return verifyCallResult(success, returndata); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but passing some native ETH as msg.value to the call. * * _Available since v3.4._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata); } /** * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling up the * revert reason or using the one provided. * * _Available since v4.3._ */ function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { _revert(Errors.LOW_LEVEL_CALL_FAILED); } } } }
// 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; pragma experimental ABIEncoderV2; import "@balancer-labs/v2-vault/contracts/AssetHelpers.sol"; import "@balancer-labs/v2-vault/contracts/interfaces/IVault.sol"; /** * @title IBaseRelayerLibrary */ abstract contract IBaseRelayerLibrary is AssetHelpers { constructor(IWETH weth) AssetHelpers(weth) { // solhint-disable-previous-line no-empty-blocks } function getVault() public view virtual returns (IVault); function approveVault(IERC20 token, uint256 amount) public virtual; function _pullToken( address sender, IERC20 token, uint256 amount ) internal virtual; function _pullTokens( address sender, IERC20[] memory tokens, uint256[] memory amounts ) internal virtual; function _isChainedReference(uint256 amount) internal pure virtual returns (bool); function _setChainedReferenceValue(uint256 ref, uint256 value) internal virtual; function _getChainedReferenceValue(uint256 ref) internal virtual returns (uint256); }
// 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; pragma experimental ABIEncoderV2; import "@balancer-labs/v2-solidity-utils/contracts/openzeppelin/IERC20Permit.sol"; import "@balancer-labs/v2-solidity-utils/contracts/openzeppelin/IERC20PermitDAI.sol"; import "@balancer-labs/v2-vault/contracts/interfaces/IVault.sol"; import "../interfaces/IBaseRelayerLibrary.sol"; /** * @title VaultPermit * @notice Allows users to use permit (where supported) to approve the Balancer Vault to use their tokens * @dev All functions must be payable so they can be called from a multicall involving ETH */ abstract contract VaultPermit is IBaseRelayerLibrary { function vaultPermit( IERC20Permit token, address owner, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) public payable { token.permit(owner, address(getVault()), value, deadline, v, r, s); } function vaultPermitDAI( IERC20PermitDAI token, address holder, uint256 nonce, uint256 expiry, bool allowed, uint8 v, bytes32 r, bytes32 s ) public payable { token.permit(holder, address(getVault()), nonce, expiry, allowed, v, r, s); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.7.0; interface IERC20PermitDAI { /** * @notice update allowance with a signed permit * @param holder Token owner's address (Authorizer) * @param spender Spender's address * @param nonce The permit nonce * @param expiry The time at which this expires (unix time) * @param allowed Whether the spender is allowed or disallowed from spending * @param v v of the signature * @param r r of the signature * @param s s of the signature */ function permit( address holder, address spender, uint256 nonce, uint256 expiry, bool allowed, uint8 v, bytes32 r, bytes32 s ) external; }
// 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; import "@balancer-labs/v2-solidity-utils/contracts/openzeppelin/IERC20.sol"; // solhint-disable-next-line max-line-length // Based on https://github.com/lidofinance/lido-dao/blob/816bf1d0995ba5cfdfc264de4acda34a7fe93eba/contracts/0.4.24/Lido.sol interface IstETH is IERC20 { function submit(address referral) external payable returns (uint256); }
// 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; import "@balancer-labs/v2-solidity-utils/contracts/openzeppelin/IERC20.sol"; import "./IstETH.sol"; // solhint-disable-next-line max-line-length // Based on https://github.com/lidofinance/lido-dao/blob/2b46615a11dee77d4d22066f942f6c6afab9b87a/contracts/0.6.12/WstETH.sol /** * @title StETH token wrapper with static balances. * @dev It's an ERC20 token that represents the account's share of the total * supply of stETH tokens. WstETH token's balance only changes on transfers, * unlike StETH that is also changed when oracles report staking rewards and * penalties. It's a "power user" token for DeFi protocols which don't * support rebasable tokens. * * The contract is also a trustless wrapper that accepts stETH tokens and mints * wstETH in return. Then the user unwraps, the contract burns user's wstETH * and sends user locked stETH in return. * * The contract provides the staking shortcut: user can send ETH with regular * transfer and get wstETH in return. The contract will send ETH to Lido submit * method, staking it and wrapping the received stETH. * */ interface IwstETH is IERC20 { function stETH() external returns (IstETH); /** * @notice Exchanges stETH to wstETH * @param _stETHAmount amount of stETH to wrap in exchange for wstETH * @dev Requirements: * - `_stETHAmount` must be non-zero * - msg.sender must approve at least `_stETHAmount` stETH to this * contract. * - msg.sender must have at least `_stETHAmount` of stETH. * User should first approve _stETHAmount to the WstETH contract * @return Amount of wstETH user receives after wrap */ function wrap(uint256 _stETHAmount) external returns (uint256); /** * @notice Exchanges wstETH to stETH * @param _wstETHAmount amount of wstETH to uwrap in exchange for stETH * @dev Requirements: * - `_wstETHAmount` must be non-zero * - msg.sender must have at least `_wstETHAmount` wstETH. * @return Amount of stETH user receives after unwrap */ function unwrap(uint256 _wstETHAmount) external returns (uint256); /** * @notice Get amount of wstETH for a given amount of stETH * @param _stETHAmount amount of stETH * @return Amount of wstETH for a given stETH amount */ function getWstETHByStETH(uint256 _stETHAmount) external view returns (uint256); /** * @notice Get amount of stETH for a given amount of wstETH * @param _wstETHAmount amount of wstETH * @return Amount of stETH for a given wstETH amount */ function getStETHByWstETH(uint256 _wstETHAmount) external view returns (uint256); /** * @notice Get amount of wstETH for a one stETH * @return Amount of stETH for 1 wstETH */ function stEthPerToken() external view returns (uint256); /** * @notice Get amount of stETH for a one wstETH * @return Amount of wstETH for a 1 stETH */ function tokensPerStEth() external view returns (uint256); }
// 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; pragma experimental ABIEncoderV2; import "@balancer-labs/v2-solidity-utils/contracts/openzeppelin/Address.sol"; import "@balancer-labs/v2-vault/contracts/interfaces/IVault.sol"; import "../interfaces/IBaseRelayerLibrary.sol"; import "../interfaces/IstETH.sol"; import "../interfaces/IwstETH.sol"; /** * @title LidoWrapping * @notice Allows users to wrap and unwrap stETH * @dev All functions must be payable so they can be called from a multicall involving ETH */ abstract contract LidoWrapping is IBaseRelayerLibrary { using Address for address payable; IstETH private immutable _stETH; IwstETH private immutable _wstETH; /** * @dev The zero address may be passed as wstETH to safely disable this module * @param wstETH - the address of Lido's wrapped stETH contract */ constructor(IERC20 wstETH) { // Safely disable stETH wrapping if no address has been passed for wstETH _stETH = wstETH != IERC20(0) ? IwstETH(address(wstETH)).stETH() : IstETH(0); _wstETH = IwstETH(address(wstETH)); } function wrapStETH( address sender, address recipient, uint256 amount, uint256 outputReference ) external payable { if (_isChainedReference(amount)) { amount = _getChainedReferenceValue(amount); } // The wrap caller is the implicit token sender, so if the goal is for the tokens // to be sourced from outside the relayer, we must first pull them here. if (sender != address(this)) { require(sender == msg.sender, "Incorrect sender"); _pullToken(sender, _stETH, amount); } _stETH.approve(address(_wstETH), amount); uint256 result = IwstETH(_wstETH).wrap(amount); if (recipient != address(this)) { _wstETH.transfer(recipient, result); } if (_isChainedReference(outputReference)) { _setChainedReferenceValue(outputReference, result); } } function unwrapWstETH( address sender, address recipient, uint256 amount, uint256 outputReference ) external payable { if (_isChainedReference(amount)) { amount = _getChainedReferenceValue(amount); } // The unwrap caller is the implicit token sender, so if the goal is for the tokens // to be sourced from outside the relayer, we must first pull them here. if (sender != address(this)) { require(sender == msg.sender, "Incorrect sender"); _pullToken(sender, _wstETH, amount); } // No approval is needed here, as wstETH is burned directly from the relayer's account uint256 result = _wstETH.unwrap(amount); if (recipient != address(this)) { _stETH.transfer(recipient, result); } if (_isChainedReference(outputReference)) { _setChainedReferenceValue(outputReference, result); } } function stakeETH( address recipient, uint256 amount, uint256 outputReference ) external payable { if (_isChainedReference(amount)) { amount = _getChainedReferenceValue(amount); } uint256 result = _stETH.submit{ value: amount }(address(this)); if (recipient != address(this)) { _stETH.transfer(recipient, result); } if (_isChainedReference(outputReference)) { _setChainedReferenceValue(outputReference, result); } } function stakeETHAndWrap( address recipient, uint256 amount, uint256 outputReference ) external payable { if (_isChainedReference(amount)) { amount = _getChainedReferenceValue(amount); } // We must query this separately, since the wstETH contract doesn't return how much wstETH is minted. uint256 result = _wstETH.getWstETHByStETH(amount); // The fallback function on the wstETH contract automatically stakes and wraps any ETH sent to it. // We can then send the ETH safely, and only have to ensure that the call doesn't revert. // // This would be dangerous if `_wstETH` were set to the zero address. However, in this scenario, // this function would have already reverted during the call to `getWstETHByStETH`, preventing loss of funds. payable(address(_wstETH)).sendValue(amount); if (recipient != address(this)) { _wstETH.transfer(recipient, result); } if (_isChainedReference(outputReference)) { _setChainedReferenceValue(outputReference, result); } } }
// 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; pragma experimental ABIEncoderV2; import "@balancer-labs/v2-solidity-utils/contracts/openzeppelin/Address.sol"; import "@balancer-labs/v2-solidity-utils/contracts/openzeppelin/IERC20.sol"; import "../interfaces/IBaseRelayerLibrary.sol"; import "../interfaces/IUnbuttonToken.sol"; /** * @title UnbuttonWrapping * @author @aalavandhan1984 ([email protected]) * @notice Allows users to wrap and unwrap any rebasing elastic balance token into a * a non-rebasing static balance version using the Unbutton wrapper. * @dev All functions must be payable so that it can be called as part of a multicall involving ETH. * The rebasing token to be wrapped is called the "underlying" token. * The wrapped non-rebasing token is called the "wrapped" token. * Learn more: https://github.com/buttonwood-protocol/button-wrappers/blob/main/contracts/UnbuttonToken.sol */ abstract contract UnbuttonWrapping is IBaseRelayerLibrary { using Address for address payable; /// @param wrapperToken The address of the wrapper. /// @param sender The address of sender. /// @param sender The address of recepient. /// @param uAmount The underling token amount to be deposited into the wrapper. /// @param outputReference Chained output reference. function wrapUnbuttonToken( IUnbuttonToken wrapperToken, address sender, address recipient, uint256 uAmount, uint256 outputReference ) external payable { if (_isChainedReference(uAmount)) { uAmount = _getChainedReferenceValue(uAmount); } IERC20 underlyingToken = IERC20(wrapperToken.underlying()); // The wrap caller is the implicit sender of tokens, so if the goal is for the tokens // to be sourced from outside the relayer, we must first pull them here. if (sender != address(this)) { require(sender == msg.sender, "Incorrect sender"); _pullToken(sender, underlyingToken, uAmount); } underlyingToken.approve(address(wrapperToken), uAmount); uint256 mintAmount = wrapperToken.depositFor(recipient, uAmount); if (_isChainedReference(outputReference)) { _setChainedReferenceValue(outputReference, mintAmount); } } /// @param wrapperToken The address of the wrapper. /// @param sender The address of sender. /// @param sender The address of recepient. /// @param amount The amount of wrapped tokens to be burnt for underlying tokens. /// @param outputReference Chained output reference. function unwrapUnbuttonToken( IUnbuttonToken wrapperToken, address sender, address recipient, uint256 amount, uint256 outputReference ) external payable { if (_isChainedReference(amount)) { amount = _getChainedReferenceValue(amount); } // The wrap caller is the implicit sender of tokens, so if the goal is for the tokens // to be sourced from outside the relayer, we must first them pull them here. if (sender != address(this)) { require(sender == msg.sender, "Incorrect sender"); _pullToken(sender, wrapperToken, amount); } uint256 withdrawnUAmount = wrapperToken.burnTo(recipient, amount); if (_isChainedReference(outputReference)) { _setChainedReferenceValue(outputReference, withdrawnUAmount); } } }
// 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; import "@balancer-labs/v2-solidity-utils/contracts/openzeppelin/IERC20.sol"; import "./IButtonWrapper.sol"; // Balancer only supports ERC20 tokens, so we use this intermediate interface // to enforce ERC20-ness of UnbuttonTokens. interface IUnbuttonToken is IButtonWrapper, IERC20 { // solhint-disable-previous-line no-empty-blocks }
// 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; // Source: https://github.com/buttonwood-protocol/button-wrappers/blob/main/contracts/interfaces/IButtonWrapper.sol // Interface definition for ButtonWrapper contract, which wraps an // underlying ERC20 token into a new ERC20 with different characteristics. // NOTE: "uAmount" => underlying token (wrapped) amount and // "amount" => wrapper token amount interface IButtonWrapper { //-------------------------------------------------------------------------- // ButtonWrapper write methods /// @notice Transfers underlying tokens from {msg.sender} to the contract and /// mints wrapper tokens. /// @param amount The amount of wrapper tokens to mint. /// @return The amount of underlying tokens deposited. function mint(uint256 amount) external returns (uint256); /// @notice Transfers underlying tokens from {msg.sender} to the contract and /// mints wrapper tokens to the specified beneficiary. /// @param to The beneficiary account. /// @param amount The amount of wrapper tokens to mint. /// @return The amount of underlying tokens deposited. function mintFor(address to, uint256 amount) external returns (uint256); /// @notice Burns wrapper tokens from {msg.sender} and transfers /// the underlying tokens back. /// @param amount The amount of wrapper tokens to burn. /// @return The amount of underlying tokens withdrawn. function burn(uint256 amount) external returns (uint256); /// @notice Burns wrapper tokens from {msg.sender} and transfers /// the underlying tokens to the specified beneficiary. /// @param to The beneficiary account. /// @param amount The amount of wrapper tokens to burn. /// @return The amount of underlying tokens withdrawn. function burnTo(address to, uint256 amount) external returns (uint256); /// @notice Burns all wrapper tokens from {msg.sender} and transfers /// the underlying tokens back. /// @return The amount of underlying tokens withdrawn. function burnAll() external returns (uint256); /// @notice Burns all wrapper tokens from {msg.sender} and transfers /// the underlying tokens back. /// @param to The beneficiary account. /// @return The amount of underlying tokens withdrawn. function burnAllTo(address to) external returns (uint256); /// @notice Transfers underlying tokens from {msg.sender} to the contract and /// mints wrapper tokens to the specified beneficiary. /// @param uAmount The amount of underlying tokens to deposit. /// @return The amount of wrapper tokens mint. function deposit(uint256 uAmount) external returns (uint256); /// @notice Transfers underlying tokens from {msg.sender} to the contract and /// mints wrapper tokens to the specified beneficiary. /// @param to The beneficiary account. /// @param uAmount The amount of underlying tokens to deposit. /// @return The amount of wrapper tokens mint. function depositFor(address to, uint256 uAmount) external returns (uint256); /// @notice Burns wrapper tokens from {msg.sender} and transfers /// the underlying tokens back. /// @param uAmount The amount of underlying tokens to withdraw. /// @return The amount of wrapper tokens burnt. function withdraw(uint256 uAmount) external returns (uint256); /// @notice Burns wrapper tokens from {msg.sender} and transfers /// the underlying tokens back to the specified beneficiary. /// @param to The beneficiary account. /// @param uAmount The amount of underlying tokens to withdraw. /// @return The amount of wrapper tokens burnt. function withdrawTo(address to, uint256 uAmount) external returns (uint256); /// @notice Burns all wrapper tokens from {msg.sender} and transfers /// the underlying tokens back. /// @return The amount of wrapper tokens burnt. function withdrawAll() external returns (uint256); /// @notice Burns all wrapper tokens from {msg.sender} and transfers /// the underlying tokens back. /// @param to The beneficiary account. /// @return The amount of wrapper tokens burnt. function withdrawAllTo(address to) external returns (uint256); //-------------------------------------------------------------------------- // ButtonWrapper view methods /// @return The address of the underlying token. function underlying() external view returns (address); /// @return The total underlying tokens held by the wrapper contract. function totalUnderlying() external view returns (uint256); /// @param who The account address. /// @return The underlying token balance of the account. function balanceOfUnderlying(address who) external view returns (uint256); /// @param uAmount The amount of underlying tokens. /// @return The amount of wrapper tokens exchangeable. function underlyingToWrapper(uint256 uAmount) external view returns (uint256); /// @param amount The amount of wrapper tokens. /// @return The amount of underlying tokens exchangeable. function wrapperToUnderlying(uint256 amount) external view returns (uint256); }
// 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; pragma experimental ABIEncoderV2; import "@balancer-labs/v2-vault/contracts/interfaces/IVault.sol"; import "./BalancerRelayer.sol"; import "../interfaces/IBalancerRelayer.sol"; import "../interfaces/IBaseRelayerLibrary.sol"; /** * @title Base Relayer Library * @notice Core functionality of a relayer. Allow users to use a signature to approve this contract * to take further actions on their behalf. * @dev * Relayers are composed of two contracts: * - A `BalancerRelayer` contract, which acts as a single point of entry into the system through a multicall function * - A library contract such as this one, which defines the allowed behaviour of the relayer * NOTE: Only the entrypoint contract should be allowlisted by Balancer governance as a relayer, so that the Vault * will reject calls from outside the entrypoint context. * * This contract should neither be allowlisted as a relayer, nor called directly by the user. * No guarantees can be made about fund safety when calling this contract in an improper manner. */ contract BaseRelayerLibrary is IBaseRelayerLibrary { using Address for address; IVault private immutable _vault; IBalancerRelayer private immutable _entrypoint; constructor(IVault vault) IBaseRelayerLibrary(vault.WETH()) { _vault = vault; _entrypoint = new BalancerRelayer(vault, address(this)); } function getVault() public view override returns (IVault) { return _vault; } function getEntrypoint() public view returns (IBalancerRelayer) { return _entrypoint; } /** * @notice Sets whether a particular relayer is authorised to act on behalf of the user */ function setRelayerApproval( address relayer, bool approved, bytes calldata authorisation ) external payable { require(relayer == address(this) || !approved, "Relayer can only approve itself"); bytes memory data = abi.encodePacked( abi.encodeWithSelector(_vault.setRelayerApproval.selector, msg.sender, relayer, approved), authorisation ); address(_vault).functionCall(data); } /** * @notice Approves the Vault to use tokens held in the relayer * @dev This is needed to avoid having to send intermediate tokens back to the user */ function approveVault(IERC20 token, uint256 amount) public override { // TODO: gas golf this a bit token.approve(address(getVault()), amount); } function _pullToken( address sender, IERC20 token, uint256 amount ) internal override { if (amount == 0) return; IERC20[] memory tokens = new IERC20[](1); tokens[0] = token; uint256[] memory amounts = new uint256[](1); amounts[0] = amount; _pullTokens(sender, tokens, amounts); } function _pullTokens( address sender, IERC20[] memory tokens, uint256[] memory amounts ) internal override { IVault.UserBalanceOp[] memory ops = new IVault.UserBalanceOp[](tokens.length); for (uint256 i; i < tokens.length; i++) { ops[i] = IVault.UserBalanceOp({ asset: IAsset(address(tokens[i])), amount: amounts[i], sender: sender, recipient: payable(address(this)), kind: IVault.UserBalanceOpKind.TRANSFER_EXTERNAL }); } getVault().manageUserBalance(ops); } /** * @dev Returns true if `amount` is not actually an amount, but rather a chained reference. */ function _isChainedReference(uint256 amount) internal pure override returns (bool) { return (amount & 0xffff000000000000000000000000000000000000000000000000000000000000) == 0xba10000000000000000000000000000000000000000000000000000000000000; } /** * @dev Stores `value` as the amount referenced by chained reference `ref`. */ function _setChainedReferenceValue(uint256 ref, uint256 value) internal override { bytes32 slot = _getTempStorageSlot(ref); // Since we do manual calculation of storage slots, it is easier (and cheaper) to rely on internal assembly to // access it. // solhint-disable-next-line no-inline-assembly assembly { sstore(slot, value) } } /** * @dev Returns the amount referenced by chained reference `ref`. Reading an amount clears it, so they can each * only be read once. */ function _getChainedReferenceValue(uint256 ref) internal override returns (uint256 value) { bytes32 slot = _getTempStorageSlot(ref); // Since we do manual calculation of storage slots, it is easier (and cheaper) to rely on internal assembly to // access it. // solhint-disable-next-line no-inline-assembly assembly { value := sload(slot) sstore(slot, 0) } } // solhint-disable-next-line var-name-mixedcase bytes32 private immutable _TEMP_STORAGE_SUFFIX = keccak256("balancer.base-relayer-library"); function _getTempStorageSlot(uint256 ref) private view returns (bytes32) { // This replicates the mechanism Solidity uses to allocate storage slots for mappings, but using a hash as the // mapping's storage slot, and subtracting 1 at the end. This should be more than enough to prevent collisions // with other state variables this or derived contracts might use. // See https://docs.soliditylang.org/en/v0.8.9/internals/layout_in_storage.html return bytes32(uint256(keccak256(abi.encodePacked(ref, _TEMP_STORAGE_SUFFIX))) - 1); } }
// 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; pragma experimental ABIEncoderV2; import "@balancer-labs/v2-solidity-utils/contracts/openzeppelin/Address.sol"; import "@balancer-labs/v2-vault/contracts/interfaces/IVault.sol"; import "../interfaces/IBaseRelayerLibrary.sol"; import "../interfaces/IStaticATokenLM.sol"; /** * @title AaveWrapping * @notice Allows users to wrap and unwrap Aave's aTokens into their StaticAToken wrappers * @dev All functions must be payable so they can be called from a multicall involving ETH */ abstract contract AaveWrapping is IBaseRelayerLibrary { using Address for address payable; function wrapAaveDynamicToken( IStaticATokenLM staticToken, address sender, address recipient, uint256 amount, bool fromUnderlying, uint256 outputReference ) external payable { if (_isChainedReference(amount)) { amount = _getChainedReferenceValue(amount); } // Aave's StaticATokens allow wrapping either an aToken or the underlying asset. // We can query which token to pull and approve from the wrapper contract. IERC20 dynamicToken = fromUnderlying ? staticToken.ASSET() : staticToken.ATOKEN(); // The wrap caller is the implicit sender of tokens, so if the goal is for the tokens // to be sourced from outside the relayer, we must first pull them here. if (sender != address(this)) { require(sender == msg.sender, "Incorrect sender"); _pullToken(sender, dynamicToken, amount); } dynamicToken.approve(address(staticToken), amount); // Use 0 for the referral code uint256 result = staticToken.deposit(recipient, amount, 0, fromUnderlying); if (_isChainedReference(outputReference)) { _setChainedReferenceValue(outputReference, result); } } function unwrapAaveStaticToken( IStaticATokenLM staticToken, address sender, address recipient, uint256 amount, bool toUnderlying, uint256 outputReference ) external payable { if (_isChainedReference(amount)) { amount = _getChainedReferenceValue(amount); } // The unwrap caller is the implicit sender of tokens, so if the goal is for the tokens // to be sourced from outside the relayer, we must first pull them here. if (sender != address(this)) { require(sender == msg.sender, "Incorrect sender"); _pullToken(sender, staticToken, amount); } // No approval is needed here, as the Static Tokens are burned directly from the relayer's account (, uint256 result) = staticToken.withdraw(recipient, amount, toUnderlying); if (_isChainedReference(outputReference)) { _setChainedReferenceValue(outputReference, result); } } }
// 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; pragma experimental ABIEncoderV2; import "@balancer-labs/v2-solidity-utils/contracts/openzeppelin/Address.sol"; import "@balancer-labs/v2-solidity-utils/contracts/misc/IERC4626.sol"; import "@balancer-labs/v2-vault/contracts/interfaces/IVault.sol"; import "../interfaces/IBaseRelayerLibrary.sol"; /** * @title ERC4626Wrapping * @notice Allows users to wrap and unwrap ERC4626 tokens * @dev All functions must be payable so they can be called from a multicall involving ETH */ abstract contract ERC4626Wrapping is IBaseRelayerLibrary { using Address for address payable; function wrapERC4626( IERC4626 wrappedToken, address sender, address recipient, uint256 amount, uint256 outputReference ) external payable { if (_isChainedReference(amount)) { amount = _getChainedReferenceValue(amount); } IERC20 underlying = IERC20(wrappedToken.asset()); // The wrap caller is the implicit sender of tokens, so if the goal is for the tokens // to be sourced from outside the relayer, we must first pull them here. if (sender != address(this)) { require(sender == msg.sender, "Incorrect sender"); _pullToken(sender, underlying, amount); } underlying.approve(address(wrappedToken), amount); uint256 result = wrappedToken.deposit(amount, recipient); if (_isChainedReference(outputReference)) { _setChainedReferenceValue(outputReference, result); } } function unwrapERC4626( IERC4626 wrappedToken, address sender, address recipient, uint256 amount, uint256 outputReference ) external payable { if (_isChainedReference(amount)) { amount = _getChainedReferenceValue(amount); } // The unwrap caller is the implicit sender of tokens, so if the goal is for the tokens // to be sourced from outside the relayer, we must first pull them here. if (sender != address(this)) { require(sender == msg.sender, "Incorrect sender"); _pullToken(sender, wrappedToken, amount); } uint256 result = wrappedToken.redeem(amount, recipient, address(this)); if (_isChainedReference(outputReference)) { _setChainedReferenceValue(outputReference, result); } } }
// 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; pragma experimental ABIEncoderV2; import "@balancer-labs/v2-solidity-utils/contracts/helpers/InputHelpers.sol"; import "@balancer-labs/v2-solidity-utils/contracts/helpers/VaultHelpers.sol"; import "@balancer-labs/v2-solidity-utils/contracts/math/Math.sol"; import "@balancer-labs/v2-vault/contracts/interfaces/IVault.sol"; import "@balancer-labs/v2-pool-weighted/contracts/WeightedPoolUserData.sol"; import "../interfaces/IBaseRelayerLibrary.sol"; /** * @title VaultActions * @notice Allows users to call the core functions on the Balancer Vault (swaps/joins/exits/user balance management) * @dev * Since the relayer is not expected to hold user funds, we expect the user to be the recipient of any token transfers * from the Vault. * * All functions must be payable so they can be called from a multicall involving ETH */ abstract contract VaultActions is IBaseRelayerLibrary { using Math for uint256; struct OutputReference { uint256 index; uint256 key; } function swap( IVault.SingleSwap memory singleSwap, IVault.FundManagement calldata funds, uint256 limit, uint256 deadline, uint256 value, uint256 outputReference ) external payable returns (uint256) { require(funds.sender == msg.sender || funds.sender == address(this), "Incorrect sender"); if (_isChainedReference(singleSwap.amount)) { singleSwap.amount = _getChainedReferenceValue(singleSwap.amount); } uint256 result = getVault().swap{ value: value }(singleSwap, funds, limit, deadline); if (_isChainedReference(outputReference)) { _setChainedReferenceValue(outputReference, result); } return result; } function batchSwap( IVault.SwapKind kind, IVault.BatchSwapStep[] memory swaps, IAsset[] calldata assets, IVault.FundManagement calldata funds, int256[] calldata limits, uint256 deadline, uint256 value, OutputReference[] calldata outputReferences ) external payable returns (int256[] memory) { require(funds.sender == msg.sender || funds.sender == address(this), "Incorrect sender"); for (uint256 i = 0; i < swaps.length; ++i) { uint256 amount = swaps[i].amount; if (_isChainedReference(amount)) { swaps[i].amount = _getChainedReferenceValue(amount); } } int256[] memory results = getVault().batchSwap{ value: value }(kind, swaps, assets, funds, limits, deadline); for (uint256 i = 0; i < outputReferences.length; ++i) { require(_isChainedReference(outputReferences[i].key), "invalid chained reference"); // Batch swap return values are signed, as they are Vault deltas (positive values correspond to assets sent // to the Vault, and negative values are assets received from the Vault). To simplify the chained reference // value model, we simply store the absolute value. // This should be fine for most use cases, as the caller can reason about swap results via the `limits` // parameter. _setChainedReferenceValue(outputReferences[i].key, Math.abs(results[outputReferences[i].index])); } return results; } function manageUserBalance(IVault.UserBalanceOp[] calldata ops, uint256 value) external payable { for (uint256 i = 0; i < ops.length; i++) { require(ops[i].sender == msg.sender || ops[i].sender == address(this), "Incorrect sender"); } getVault().manageUserBalance{ value: value }(ops); } enum PoolKind { WEIGHTED } function joinPool( bytes32 poolId, PoolKind kind, address sender, address recipient, IVault.JoinPoolRequest memory request, uint256 value, uint256 outputReference ) external payable { require(sender == msg.sender || sender == address(this), "Incorrect sender"); // The output of a join will be the Pool's token contract, typically known as BPT (Balancer Pool Tokens). // Since the Vault is unaware of this (BPT tokens are minted directly to the recipient), we manually // measure this balance increase: but only if an output reference is provided. IERC20 bpt = IERC20(VaultHelpers.toPoolAddress(poolId)); uint256 maybeInitialRecipientBPT = _isChainedReference(outputReference) ? bpt.balanceOf(recipient) : 0; request.userData = _doJoinPoolChainedReferenceReplacements(kind, request.userData); getVault().joinPool{ value: value }(poolId, sender, recipient, request); if (_isChainedReference(outputReference)) { // In this context, `maybeInitialRecipientBPT` is guaranteed to have been initialized, so we can safely read // from it. Note that we assume the recipient balance change has a positive sign (i.e. the recipient // received BPT). uint256 finalRecipientBPT = bpt.balanceOf(recipient); _setChainedReferenceValue(outputReference, finalRecipientBPT.sub(maybeInitialRecipientBPT)); } } function _doJoinPoolChainedReferenceReplacements(PoolKind kind, bytes memory userData) private returns (bytes memory) { if (kind == PoolKind.WEIGHTED) { return _doWeightedJoinChainedReferenceReplacements(userData); } else { _revert(Errors.UNHANDLED_JOIN_KIND); } } function _doWeightedJoinChainedReferenceReplacements(bytes memory userData) private returns (bytes memory) { WeightedPoolUserData.JoinKind kind = WeightedPoolUserData.joinKind(userData); if (kind == WeightedPoolUserData.JoinKind.EXACT_TOKENS_IN_FOR_BPT_OUT) { return _doWeightedExactTokensInForBPTOutReplacements(userData); } else { // All other join kinds are 'given out' (i.e the parameter is a BPT amount), so we don't do replacements for // those. return userData; } } function _doWeightedExactTokensInForBPTOutReplacements(bytes memory userData) private returns (bytes memory) { (uint256[] memory amountsIn, uint256 minBPTAmountOut) = WeightedPoolUserData.exactTokensInForBptOut(userData); bool replacedAmounts = false; for (uint256 i = 0; i < amountsIn.length; ++i) { uint256 amount = amountsIn[i]; if (_isChainedReference(amount)) { amountsIn[i] = _getChainedReferenceValue(amount); replacedAmounts = true; } } // Save gas by only re-encoding the data if we actually performed a replacement return replacedAmounts ? abi.encode(WeightedPoolUserData.JoinKind.EXACT_TOKENS_IN_FOR_BPT_OUT, amountsIn, minBPTAmountOut) : userData; } function exitPool( bytes32 poolId, PoolKind kind, address sender, address payable recipient, IVault.ExitPoolRequest memory request, OutputReference[] calldata outputReferences ) external payable { require(sender == msg.sender || sender == address(this), "Incorrect sender"); // To track the changes of internal balances, we need an array of token addresses. // We save this here to avoid having to recalculate after the exit. IERC20[] memory trackedTokens = new IERC20[](outputReferences.length); // Query initial balances for all tokens, and record them as chained references uint256[] memory initialRecipientBalances = new uint256[](outputReferences.length); for (uint256 i = 0; i < outputReferences.length; i++) { require(_isChainedReference(outputReferences[i].key), "invalid chained reference"); IAsset asset = request.assets[outputReferences[i].index]; if (request.toInternalBalance) { trackedTokens[i] = _asIERC20(asset); } else { initialRecipientBalances[i] = _isETH(asset) ? recipient.balance : _asIERC20(asset).balanceOf(recipient); } } if (request.toInternalBalance) { initialRecipientBalances = getVault().getInternalBalance(recipient, trackedTokens); } // Exit the Pool request.userData = _doExitPoolChainedReferenceReplacements(kind, request.userData); getVault().exitPool(poolId, sender, recipient, request); // Query final balances for all tokens of interest uint256[] memory finalRecipientTokenBalances = new uint256[](outputReferences.length); if (request.toInternalBalance) { finalRecipientTokenBalances = getVault().getInternalBalance(recipient, trackedTokens); } else { for (uint256 i = 0; i < outputReferences.length; i++) { IAsset asset = request.assets[outputReferences[i].index]; finalRecipientTokenBalances[i] = _isETH(asset) ? recipient.balance : _asIERC20(asset).balanceOf(recipient); } } // Calculate deltas and save as chained references for (uint256 i = 0; i < outputReferences.length; i++) { _setChainedReferenceValue( outputReferences[i].key, finalRecipientTokenBalances[i].sub(initialRecipientBalances[i]) ); } } function _doExitPoolChainedReferenceReplacements(PoolKind kind, bytes memory userData) private returns (bytes memory) { if (kind == PoolKind.WEIGHTED) { return _doWeightedExitChainedReferenceReplacements(userData); } else { _revert(Errors.UNHANDLED_EXIT_KIND); } } function _doWeightedExitChainedReferenceReplacements(bytes memory userData) private returns (bytes memory) { WeightedPoolUserData.ExitKind kind = WeightedPoolUserData.exitKind(userData); if (kind == WeightedPoolUserData.ExitKind.EXACT_BPT_IN_FOR_ONE_TOKEN_OUT) { return _doWeightedExactBptInForOneTokenOutReplacements(userData); } else if (kind == WeightedPoolUserData.ExitKind.EXACT_BPT_IN_FOR_TOKENS_OUT) { return _doWeightedExactBptInForTokensOutReplacements(userData); } else { // All other exit kinds are 'given out' (i.e the parameter is a token amount), // so we don't do replacements for those. return userData; } } function _doWeightedExactBptInForOneTokenOutReplacements(bytes memory userData) private returns (bytes memory) { (uint256 bptAmountIn, uint256 tokenIndex) = WeightedPoolUserData.exactBptInForTokenOut(userData); if (_isChainedReference(bptAmountIn)) { bptAmountIn = _getChainedReferenceValue(bptAmountIn); return abi.encode(WeightedPoolUserData.ExitKind.EXACT_BPT_IN_FOR_ONE_TOKEN_OUT, bptAmountIn, tokenIndex); } else { // Save gas by only re-encoding the data if we actually performed a replacement return userData; } } function _doWeightedExactBptInForTokensOutReplacements(bytes memory userData) private returns (bytes memory) { uint256 bptAmountIn = WeightedPoolUserData.exactBptInForTokensOut(userData); if (_isChainedReference(bptAmountIn)) { bptAmountIn = _getChainedReferenceValue(bptAmountIn); return abi.encode(WeightedPoolUserData.ExitKind.EXACT_BPT_IN_FOR_TOKENS_OUT, bptAmountIn); } else { // Save gas by only re-encoding the data if we actually performed a replacement return userData; } } }
// 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; pragma experimental ABIEncoderV2; import "@balancer-labs/v2-solidity-utils/contracts/openzeppelin/Address.sol"; import "@balancer-labs/v2-solidity-utils/contracts/openzeppelin/ReentrancyGuard.sol"; import "../interfaces/IBalancerRelayer.sol"; /** * @title Balancer Relayer * @notice Allows safe multicall execution of a relayer's functions * @dev * Relayers are composed of two contracts: * - This contract, which acts as a single point of entry into the system through a multicall function. * - A library contract, which defines the allowed behaviour of the relayer. * * The relayer entrypoint can then repeatedly delegatecall into the library's code to perform actions. * We can then run combinations of the library contract's functions in the context of the relayer entrypoint, * without having to expose all these functions on the entrypoint contract itself. The multicall function is * then a single point of entry for all actions, so we can easily prevent reentrancy. * * This design gives much stronger reentrancy guarantees, as otherwise a malicious contract could reenter * the relayer through another function (which must allow reentrancy for multicall logic), and that would * potentially allow them to manipulate global state, resulting in loss of funds in some cases: * e.g., sweeping any leftover ETH that should have been refunded to the user. * * NOTE: Only the entrypoint contract should be allowlisted by Balancer governance as a relayer, so that the * Vault will reject calls from outside the context of the entrypoint: e.g., if a user mistakenly called directly * into the library contract. */ contract BalancerRelayer is IBalancerRelayer, ReentrancyGuard { using Address for address payable; using Address for address; IVault private immutable _vault; address private immutable _library; /** * @dev This contract is not meant to be deployed directly by an EOA, but rather during construction of a contract * derived from `BaseRelayerLibrary`, which will provide its own address as the relayer's library. */ constructor(IVault vault, address libraryAddress) { _vault = vault; _library = libraryAddress; } receive() external payable { // Only accept ETH transfers from the Vault. This is expected to happen due to a swap/exit/withdrawal // with ETH as an output, should the relayer be listed as the recipient. This may also happen when // joining a pool, performing a swap, or if managing a user's balance uses less than the full ETH value // provided. Any excess ETH will be refunded to this contract, and then forwarded to the original sender. _require(msg.sender == address(_vault), Errors.ETH_TRANSFER); } function getVault() external view override returns (IVault) { return _vault; } function getLibrary() external view override returns (address) { return _library; } function multicall(bytes[] calldata data) external payable override nonReentrant returns (bytes[] memory results) { results = new bytes[](data.length); for (uint256 i = 0; i < data.length; i++) { results[i] = _library.functionDelegateCall(data[i]); } _refundETH(); } function _refundETH() private { uint256 remainingEth = address(this).balance; if (remainingEth > 0) { msg.sender.sendValue(remainingEth); } } }
// SPDX-License-Identifier: GPL-3.0-or-later pragma solidity ^0.7.0; pragma experimental ABIEncoderV2; import "@balancer-labs/v2-solidity-utils/contracts/openzeppelin/IERC20.sol"; // solhint-disable-next-line max-line-length // Based on https://github.com/aave/protocol-v2/blob/ac58fea62bb8afee23f66197e8bce6d79ecda292/contracts/interfaces/IStaticATokenLM.sol interface IStaticATokenLM is IERC20 { struct SignatureParams { uint8 v; bytes32 r; bytes32 s; } /** * @notice Deposits `ASSET` in the Aave protocol and mints static aTokens to msg.sender * @param recipient The address that will receive the static aTokens * @param amount The amount of underlying `ASSET` to deposit (e.g. deposit of 100 USDC) * @param referralCode Code used to register the integrator originating the operation, for potential rewards. * 0 if the action is executed directly by the user, without any middle-man * @param fromUnderlying bool * - `true` if the msg.sender comes with underlying tokens (e.g. USDC) * - `false` if the msg.sender comes already with aTokens (e.g. aUSDC) * @return uint256 The amount of StaticAToken minted, static balance **/ function deposit( address recipient, uint256 amount, uint16 referralCode, bool fromUnderlying ) external returns (uint256); /** * @notice Burns `amount` of static aToken, with recipient receiving the corresponding amount of `ASSET` * @param recipient The address that will receive the amount of `ASSET` withdrawn from the Aave protocol * @param amount The amount to withdraw, in static balance of StaticAToken * @param toUnderlying bool * - `true` for the recipient to get underlying tokens (e.g. USDC) * - `false` for the recipient to get aTokens (e.g. aUSDC) * @return amountToBurn: StaticATokens burnt, static balance * @return amountToWithdraw: underlying/aToken send to `recipient`, dynamic balance **/ function withdraw( address recipient, uint256 amount, bool toUnderlying ) external returns (uint256, uint256); /** * @notice Burns `amount` of static aToken, with recipient receiving the corresponding amount of `ASSET` * @param recipient The address that will receive the amount of `ASSET` withdrawn from the Aave protocol * @param amount The amount to withdraw, in dynamic balance of aToken/underlying asset * @param toUnderlying bool * - `true` for the recipient to get underlying tokens (e.g. USDC) * - `false` for the recipient to get aTokens (e.g. aUSDC) * @return amountToBurn: StaticATokens burnt, static balance * @return amountToWithdraw: underlying/aToken send to `recipient`, dynamic balance **/ function withdrawDynamicAmount( address recipient, uint256 amount, bool toUnderlying ) external returns (uint256, uint256); /** * @notice Implements the permit function as for * https://github.com/ethereum/EIPs/blob/8a34d644aacf0f9f8f00815307fd7dd5da07655f/EIPS/eip-2612.md * @param owner The owner of the funds * @param spender The spender * @param value The amount * @param deadline The deadline timestamp, type(uint256).max for max deadline * @param v Signature param * @param s Signature param * @param r Signature param */ function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) external; /** * @notice Allows to deposit on Aave via meta-transaction * https://github.com/ethereum/EIPs/blob/8a34d644aacf0f9f8f00815307fd7dd5da07655f/EIPS/eip-2612.md * @param depositor Address from which the funds to deposit are going to be pulled * @param recipient Address that will receive the staticATokens, in the average case, same as the `depositor` * @param value The amount to deposit * @param referralCode Code used to register the integrator originating the operation, for potential rewards. * 0 if the action is executed directly by the user, without any middle-man * @param fromUnderlying bool * - `true` if the msg.sender comes with underlying tokens (e.g. USDC) * - `false` if the msg.sender comes already with aTokens (e.g. aUSDC) * @param deadline The deadline timestamp, type(uint256).max for max deadline * @param sigParams Signature params: v,r,s * @return uint256 The amount of StaticAToken minted, static balance */ function metaDeposit( address depositor, address recipient, uint256 value, uint16 referralCode, bool fromUnderlying, uint256 deadline, SignatureParams calldata sigParams ) external returns (uint256); /** * @notice Allows to withdraw from Aave via meta-transaction * https://github.com/ethereum/EIPs/blob/8a34d644aacf0f9f8f00815307fd7dd5da07655f/EIPS/eip-2612.md * @param owner Address owning the staticATokens * @param recipient Address that will receive the underlying withdrawn from Aave * @param staticAmount The amount of staticAToken to withdraw. If > 0, `dynamicAmount` needs to be 0 * @param dynamicAmount The amount of underlying/aToken to withdraw. If > 0, `staticAmount` needs to be 0 * @param toUnderlying bool * - `true` for the recipient to get underlying tokens (e.g. USDC) * - `false` for the recipient to get aTokens (e.g. aUSDC) * @param deadline The deadline timestamp, type(uint256).max for max deadline * @param sigParams Signature params: v,r,s * @return amountToBurn: StaticATokens burnt, static balance * @return amountToWithdraw: underlying/aToken send to `recipient`, dynamic balance */ function metaWithdraw( address owner, address recipient, uint256 staticAmount, uint256 dynamicAmount, bool toUnderlying, uint256 deadline, SignatureParams calldata sigParams ) external returns (uint256, uint256); /** * @notice Utility method to get the current aToken balance of an user, from his staticAToken balance * @param account The address of the user * @return uint256 The aToken balance **/ function dynamicBalanceOf(address account) external view returns (uint256); /** * @notice Converts a static amount (scaled balance on aToken) to the aToken/underlying value, * using the current liquidity index on Aave * @param amount The amount to convert from * @return uint256 The dynamic amount **/ function staticToDynamicAmount(uint256 amount) external view returns (uint256); /** * @notice Converts an aToken or underlying amount to the what it is denominated on the aToken as * scaled balance, function of the principal and the liquidity index * @param amount The amount to convert from * @return uint256 The static (scaled) amount **/ function dynamicToStaticAmount(uint256 amount) external view returns (uint256); /** * @notice Returns the Aave liquidity index of the underlying aToken, denominated rate here * as it can be considered as an ever-increasing exchange rate * @return The liquidity index **/ function rate() external view returns (uint256); /** * @notice Function to return a dynamic domain separator, in order to be compatible with forks changing chainId * @return bytes32 The domain separator **/ function getDomainSeparator() external view returns (bytes32); /** * @notice Claims rewards from `INCENTIVES_CONTROLLER` and updates internal accounting of rewards. */ function collectAndUpdateRewards() external; /** * @notice Claim rewards on behalf of a user and send them to a receiver * @dev Only callable by if sender is onBehalfOf or sender is approved claimer * @param onBehalfOf The address to claim on behalf of * @param receiver The address to receive the rewards * @param forceUpdate Flag to retrieve latest rewards from `INCENTIVES_CONTROLLER` */ function claimRewardsOnBehalf( address onBehalfOf, address receiver, bool forceUpdate ) external; /** * @notice Claim rewards and send them to a receiver * @param receiver The address to receive the rewards * @param forceUpdate Flag to retrieve latest rewards from `INCENTIVES_CONTROLLER` */ function claimRewards(address receiver, bool forceUpdate) external; /** * @notice Claim rewards * @param forceUpdate Flag to retrieve latest rewards from `INCENTIVES_CONTROLLER` */ function claimRewardsToSelf(bool forceUpdate) external; /** * @notice Get the total claimable rewards of the contract. * @return The current balance + pending rewards from the `_incentivesController` */ function getTotalClaimableRewards() external view returns (uint256); /** * @notice Get the total claimable rewards for a user in WAD * @param user The address of the user * @return The claimable amount of rewards in WAD */ function getClaimableRewards(address user) external view returns (uint256); /** * @notice The unclaimed rewards for a user in WAD * @param user The address of the user * @return The unclaimed amount of rewards in WAD */ function getUnclaimedRewards(address user) external view returns (uint256); function getAccRewardsPerToken() external view returns (uint256); function getLifetimeRewardsClaimed() external view returns (uint256); function getLifetimeRewards() external view returns (uint256); function getLastRewardBlock() external view returns (uint256); // solhint-disable-next-line func-name-mixedcase function LENDING_POOL() external returns (address); // solhint-disable-next-line func-name-mixedcase function INCENTIVES_CONTROLLER() external returns (address); // solhint-disable-next-line func-name-mixedcase function ATOKEN() external returns (IERC20); // solhint-disable-next-line func-name-mixedcase function ASSET() external returns (IERC20); // solhint-disable-next-line func-name-mixedcase function REWARD_TOKEN() external returns (IERC20); }
// 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; import "../openzeppelin/IERC20.sol"; interface IERC4626 is IERC20 { /** * @dev `sender` has exchanged `assets` for `shares`, and transferred those `shares` to `receiver`. */ event Deposit(address indexed sender, address indexed receiver, uint256 assets, uint256 shares); /** * @dev `sender` has exchanged `shares` for `assets`, and transferred those `assets` to `receiver`. */ event Withdraw(address indexed sender, address indexed receiver, uint256 assets, uint256 shares); /** * @dev Mints `shares` Vault shares to `receiver` by depositing exactly `amount` of underlying tokens. */ function deposit(uint256 assets, address receiver) external returns (uint256); /** * @dev Redeems `shares` from `owner` and sends `assets` of underlying tokens to `receiver`. */ function redeem( uint256 shares, address receiver, address owner ) external returns (uint256); /** * @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); }
// 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; library VaultHelpers { /** * @dev Returns the address of a Pool's contract. * * This is the same code the Vault runs in `PoolRegistry._getPoolAddress`. */ function toPoolAddress(bytes32 poolId) internal pure returns (address) { // 12 byte logical shift left to remove the nonce and specialization setting. We don't need to mask, // since the logical shift already sets the upper bits to zero. return address(uint256(poolId) >> (12 * 8)); } }
// 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; import "@balancer-labs/v2-solidity-utils/contracts/openzeppelin/IERC20.sol"; library WeightedPoolUserData { // In order to preserve backwards compatibility, make sure new join and exit kinds are added at the end of the enum. enum JoinKind { INIT, EXACT_TOKENS_IN_FOR_BPT_OUT, TOKEN_IN_FOR_EXACT_BPT_OUT, ALL_TOKENS_IN_FOR_EXACT_BPT_OUT } enum ExitKind { EXACT_BPT_IN_FOR_ONE_TOKEN_OUT, EXACT_BPT_IN_FOR_TOKENS_OUT, BPT_IN_FOR_EXACT_TOKENS_OUT, MANAGEMENT_FEE_TOKENS_OUT // for ManagedPool } function joinKind(bytes memory self) internal pure returns (JoinKind) { return abi.decode(self, (JoinKind)); } function exitKind(bytes memory self) internal pure returns (ExitKind) { return abi.decode(self, (ExitKind)); } // Joins function initialAmountsIn(bytes memory self) internal pure returns (uint256[] memory amountsIn) { (, amountsIn) = abi.decode(self, (JoinKind, uint256[])); } function exactTokensInForBptOut(bytes memory self) internal pure returns (uint256[] memory amountsIn, uint256 minBPTAmountOut) { (, amountsIn, minBPTAmountOut) = abi.decode(self, (JoinKind, uint256[], uint256)); } function tokenInForExactBptOut(bytes memory self) internal pure returns (uint256 bptAmountOut, uint256 tokenIndex) { (, bptAmountOut, tokenIndex) = abi.decode(self, (JoinKind, uint256, uint256)); } function allTokensInForExactBptOut(bytes memory self) internal pure returns (uint256 bptAmountOut) { (, bptAmountOut) = abi.decode(self, (JoinKind, uint256)); } // Exits function exactBptInForTokenOut(bytes memory self) internal pure returns (uint256 bptAmountIn, uint256 tokenIndex) { (, bptAmountIn, tokenIndex) = abi.decode(self, (ExitKind, uint256, uint256)); } function exactBptInForTokensOut(bytes memory self) internal pure returns (uint256 bptAmountIn) { (, bptAmountIn) = abi.decode(self, (ExitKind, uint256)); } function bptInForExactTokensOut(bytes memory self) internal pure returns (uint256[] memory amountsOut, uint256 maxBPTAmountIn) { (, amountsOut, maxBPTAmountIn) = abi.decode(self, (ExitKind, uint256[], uint256)); } }
{ "optimizer": { "enabled": true, "runs": 9999 }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "libraries": {} }
[{"inputs":[{"internalType":"contract IVault","name":"vault","type":"address"},{"internalType":"contract IERC20","name":"wstETH","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"contract IERC20","name":"token","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"approveVault","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"enum IVault.SwapKind","name":"kind","type":"uint8"},{"components":[{"internalType":"bytes32","name":"poolId","type":"bytes32"},{"internalType":"uint256","name":"assetInIndex","type":"uint256"},{"internalType":"uint256","name":"assetOutIndex","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bytes","name":"userData","type":"bytes"}],"internalType":"struct IVault.BatchSwapStep[]","name":"swaps","type":"tuple[]"},{"internalType":"contract IAsset[]","name":"assets","type":"address[]"},{"components":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"bool","name":"fromInternalBalance","type":"bool"},{"internalType":"address payable","name":"recipient","type":"address"},{"internalType":"bool","name":"toInternalBalance","type":"bool"}],"internalType":"struct IVault.FundManagement","name":"funds","type":"tuple"},{"internalType":"int256[]","name":"limits","type":"int256[]"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"uint256","name":"value","type":"uint256"},{"components":[{"internalType":"uint256","name":"index","type":"uint256"},{"internalType":"uint256","name":"key","type":"uint256"}],"internalType":"struct VaultActions.OutputReference[]","name":"outputReferences","type":"tuple[]"}],"name":"batchSwap","outputs":[{"internalType":"int256[]","name":"","type":"int256[]"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"poolId","type":"bytes32"},{"internalType":"enum VaultActions.PoolKind","name":"kind","type":"uint8"},{"internalType":"address","name":"sender","type":"address"},{"internalType":"address payable","name":"recipient","type":"address"},{"components":[{"internalType":"contract IAsset[]","name":"assets","type":"address[]"},{"internalType":"uint256[]","name":"minAmountsOut","type":"uint256[]"},{"internalType":"bytes","name":"userData","type":"bytes"},{"internalType":"bool","name":"toInternalBalance","type":"bool"}],"internalType":"struct IVault.ExitPoolRequest","name":"request","type":"tuple"},{"components":[{"internalType":"uint256","name":"index","type":"uint256"},{"internalType":"uint256","name":"key","type":"uint256"}],"internalType":"struct VaultActions.OutputReference[]","name":"outputReferences","type":"tuple[]"}],"name":"exitPool","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"getEntrypoint","outputs":[{"internalType":"contract IBalancerRelayer","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getVault","outputs":[{"internalType":"contract IVault","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"poolId","type":"bytes32"},{"internalType":"enum VaultActions.PoolKind","name":"kind","type":"uint8"},{"internalType":"address","name":"sender","type":"address"},{"internalType":"address","name":"recipient","type":"address"},{"components":[{"internalType":"contract IAsset[]","name":"assets","type":"address[]"},{"internalType":"uint256[]","name":"maxAmountsIn","type":"uint256[]"},{"internalType":"bytes","name":"userData","type":"bytes"},{"internalType":"bool","name":"fromInternalBalance","type":"bool"}],"internalType":"struct IVault.JoinPoolRequest","name":"request","type":"tuple"},{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"uint256","name":"outputReference","type":"uint256"}],"name":"joinPool","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"components":[{"internalType":"enum IVault.UserBalanceOpKind","name":"kind","type":"uint8"},{"internalType":"contract IAsset","name":"asset","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"address","name":"sender","type":"address"},{"internalType":"address payable","name":"recipient","type":"address"}],"internalType":"struct IVault.UserBalanceOp[]","name":"ops","type":"tuple[]"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"manageUserBalance","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"relayer","type":"address"},{"internalType":"bool","name":"approved","type":"bool"},{"internalType":"bytes","name":"authorisation","type":"bytes"}],"name":"setRelayerApproval","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"outputReference","type":"uint256"}],"name":"stakeETH","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"outputReference","type":"uint256"}],"name":"stakeETHAndWrap","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"components":[{"internalType":"bytes32","name":"poolId","type":"bytes32"},{"internalType":"enum IVault.SwapKind","name":"kind","type":"uint8"},{"internalType":"contract IAsset","name":"assetIn","type":"address"},{"internalType":"contract IAsset","name":"assetOut","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bytes","name":"userData","type":"bytes"}],"internalType":"struct IVault.SingleSwap","name":"singleSwap","type":"tuple"},{"components":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"bool","name":"fromInternalBalance","type":"bool"},{"internalType":"address payable","name":"recipient","type":"address"},{"internalType":"bool","name":"toInternalBalance","type":"bool"}],"internalType":"struct IVault.FundManagement","name":"funds","type":"tuple"},{"internalType":"uint256","name":"limit","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"uint256","name":"outputReference","type":"uint256"}],"name":"swap","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"contract IStaticATokenLM","name":"staticToken","type":"address"},{"internalType":"address","name":"sender","type":"address"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bool","name":"toUnderlying","type":"bool"},{"internalType":"uint256","name":"outputReference","type":"uint256"}],"name":"unwrapAaveStaticToken","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"contract IERC4626","name":"wrappedToken","type":"address"},{"internalType":"address","name":"sender","type":"address"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"outputReference","type":"uint256"}],"name":"unwrapERC4626","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"contract IUnbuttonToken","name":"wrapperToken","type":"address"},{"internalType":"address","name":"sender","type":"address"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"outputReference","type":"uint256"}],"name":"unwrapUnbuttonToken","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"outputReference","type":"uint256"}],"name":"unwrapWstETH","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"contract IERC20Permit","name":"token","type":"address"},{"internalType":"address","name":"owner","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"name":"vaultPermit","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"contract IERC20PermitDAI","name":"token","type":"address"},{"internalType":"address","name":"holder","type":"address"},{"internalType":"uint256","name":"nonce","type":"uint256"},{"internalType":"uint256","name":"expiry","type":"uint256"},{"internalType":"bool","name":"allowed","type":"bool"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"name":"vaultPermitDAI","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"contract IStaticATokenLM","name":"staticToken","type":"address"},{"internalType":"address","name":"sender","type":"address"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bool","name":"fromUnderlying","type":"bool"},{"internalType":"uint256","name":"outputReference","type":"uint256"}],"name":"wrapAaveDynamicToken","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"contract IERC4626","name":"wrappedToken","type":"address"},{"internalType":"address","name":"sender","type":"address"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"outputReference","type":"uint256"}],"name":"wrapERC4626","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"outputReference","type":"uint256"}],"name":"wrapStETH","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"contract IUnbuttonToken","name":"wrapperToken","type":"address"},{"internalType":"address","name":"sender","type":"address"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"uAmount","type":"uint256"},{"internalType":"uint256","name":"outputReference","type":"uint256"}],"name":"wrapUnbuttonToken","outputs":[],"stateMutability":"payable","type":"function"}]
Contract Creation Code
6101406040527fae1dc54057af8e8e5ce068cdd4383149c7efcb30e8fb95b592ee1594367fb50960e0523480156200003657600080fd5b5060405162004ae138038062004ae18339810160408190526200005991620001fa565b8082806001600160a01b031663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b1580156200009557600080fd5b505afa158015620000aa573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620000d0919062000238565b6001600160601b0319606091821b81166080529082901b1660a05260405181903090620000fd90620001ec565b6200010a9291906200025e565b604051809103906000f08015801562000127573d6000803e3d6000fd5b5060601b6001600160601b03191660c052506001600160a01b03811662000150576000620001c7565b806001600160a01b031663c1fe3e486040518163ffffffff1660e01b8152600401602060405180830381600087803b1580156200018c57600080fd5b505af1158015620001a1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620001c7919062000238565b6001600160601b0319606091821b81166101005291901b166101205250620002919050565b61074f806200439283390190565b600080604083850312156200020d578182fd5b82516200021a8162000278565b60208401519092506200022d8162000278565b809150509250929050565b6000602082840312156200024a578081fd5b8151620002578162000278565b9392505050565b6001600160a01b0392831681529116602082015260400190565b6001600160a01b03811681146200028e57600080fd5b50565b60805160601c60a05160601c60c05160601c60e0516101005160601c6101205160601c614071620003216000398061038e52806104225280610488528061081852806108c85280610991528061204852806120a052508061079652806107eb5280610a595280610b3852806121695250806125e95250806113a85250806114a8528061154a5250506140716000f3fe60806040526004361061016a5760003560e01c806380db15bd116100cb578063abf6d3991161007f578063db4c0e9111610059578063db4c0e9114610308578063ecc026371461031b578063efe691081461032e5761016a565b8063abf6d399146102c2578063b6d24737146102d5578063d80952d5146102f55761016a565b80638d928af8116100b05780638d928af8146102875780638fe4624f1461029c578063959fc17a146102af5761016a565b806380db15bd146102615780638d64cfbc146102745761016a565b8063433b0865116101225780636d307ea8116101075780636d307ea8146102195780637ab6e03c1461022c5780637fd0e5d51461023f5761016a565b8063433b0865146101f3578063611b90dd146102065761016a565b80631c982441116101535780631c982441146101ad5780632cbec84e146101c05780632e6272ea146101d35761016a565b80631089e5e31461016f5780631836944614610184575b600080fd5b61018261017d366004612f7e565b610341565b005b610197610192366004613500565b610531565b6040516101a49190613ace565b60405180910390f35b6101826101bb366004612eac565b61073e565b6101826101ce366004612f7e565b610a3b565b6101e66101e13660046135fc565b610b6f565b6040516101a49190613f35565b6101826102013660046133ba565b610c9c565b610182610214366004613360565b610f4b565b610182610227366004613360565b611066565b61018261023a3660046133ba565b611291565b34801561024b57600080fd5b506102546113a6565b6040516101a4919061394a565b61018261026f366004612ef1565b6113ca565b6101826102823660046132c7565b6114ce565b34801561029357600080fd5b50610254611548565b6101826102aa3660046131b7565b61156c565b6101826102bd366004613246565b6117a3565b6101826102d0366004613360565b611820565b3480156102e157600080fd5b506101826102f0366004613335565b6119d6565b61018261030336600461310f565b611a62565b610182610316366004612eac565b611ff0565b610182610329366004613042565b6121a0565b61018261033c366004613360565b612298565b61034a82612341565b1561035b576103588261238c565b91505b6040517fb0e389000000000000000000000000000000000000000000000000000000000081526000906001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169063b0e38900906103c3908690600401613f35565b60206040518083038186803b1580156103db57600080fd5b505afa1580156103ef573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061041391906136ea565b90506104486001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016846123a6565b6001600160a01b0384163014610513576040517fa9059cbb0000000000000000000000000000000000000000000000000000000081526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169063a9059cbb906104bf9087908590600401613a66565b602060405180830381600087803b1580156104d957600080fd5b505af11580156104ed573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061051191906130f3565b505b61051c82612341565b1561052b5761052b8282612420565b50505050565b60603361054160208a018a612e74565b6001600160a01b0316148061056a57503061055f60208a018a612e74565b6001600160a01b0316145b61058f5760405162461bcd60e51b815260040161058690613e05565b60405180910390fd5b60005b8b518110156105f45760008c82815181106105a957fe5b60200260200101516060015190506105c081612341565b156105eb576105ce8161238c565b8d83815181106105da57fe5b602002602001015160600181815250505b50600101610592565b5060606105ff611548565b6001600160a01b031663945bcec9868f8f8f8f8f8f8f8f6040518a63ffffffff1660e01b8152600401610639989796959493929190613cfc565b6000604051808303818588803b15801561065257600080fd5b505af1158015610666573d6000803e3d6000fd5b50505050506040513d6000823e601f3d908101601f1916820160405261068f9190810190612fb2565b905060005b8381101561072d576106ba8585838181106106ab57fe5b90506040020160200135612341565b6106d65760405162461bcd60e51b815260040161058690613e73565b6107258585838181106106e557fe5b90506040020160200135610720848888868181106106ff57fe5b905060400201600001358151811061071357fe5b6020026020010151612433565b612420565b600101610694565b509c9b505050505050505050505050565b61074782612341565b15610758576107558261238c565b91505b6001600160a01b03841630146107bb576001600160a01b03841633146107905760405162461bcd60e51b815260040161058690613e05565b6107bb847f00000000000000000000000000000000000000000000000000000000000000008461244d565b6040517f095ea7b30000000000000000000000000000000000000000000000000000000081526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169063095ea7b390610842907f0000000000000000000000000000000000000000000000000000000000000000908690600401613a66565b602060405180830381600087803b15801561085c57600080fd5b505af1158015610870573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061089491906130f3565b506040517fea598cb00000000000000000000000000000000000000000000000000000000081526000906001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169063ea598cb0906108fd908690600401613f35565b602060405180830381600087803b15801561091757600080fd5b505af115801561092b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061094f91906136ea565b90506001600160a01b0384163014610a1c576040517fa9059cbb0000000000000000000000000000000000000000000000000000000081526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169063a9059cbb906109c89087908590600401613a66565b602060405180830381600087803b1580156109e257600080fd5b505af11580156109f6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a1a91906130f3565b505b610a2582612341565b15610a3457610a348282612420565b5050505050565b610a4482612341565b15610a5557610a528261238c565b91505b60007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663a1903eab84306040518363ffffffff1660e01b8152600401610aa4919061394a565b6020604051808303818588803b158015610abd57600080fd5b505af1158015610ad1573d6000803e3d6000fd5b50505050506040513d601f19601f82011682018060405250810190610af691906136ea565b90506001600160a01b0384163014610513576040517fa9059cbb0000000000000000000000000000000000000000000000000000000081526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169063a9059cbb906104bf9087908590600401613a66565b600033610b7f6020880188612e74565b6001600160a01b03161480610ba8575030610b9d6020880188612e74565b6001600160a01b0316145b610bc45760405162461bcd60e51b815260040161058690613e05565b610bd18760800151612341565b15610be957610be3876080015161238c565b60808801525b6000610bf3611548565b6001600160a01b03166352bbbe29858a8a8a8a6040518663ffffffff1660e01b8152600401610c259493929190613eaa565b6020604051808303818588803b158015610c3e57600080fd5b505af1158015610c52573d6000803e3d6000fd5b50505050506040513d601f19601f82011682018060405250810190610c7791906136ea565b9050610c8283612341565b15610c9157610c918382612420565b979650505050505050565b610ca583612341565b15610cb657610cb38361238c565b92505b600082610d3557866001600160a01b03166351c0e0616040518163ffffffff1660e01b8152600401602060405180830381600087803b158015610cf857600080fd5b505af1158015610d0c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d309190612e90565b610da8565b866001600160a01b0316634800d97f6040518163ffffffff1660e01b8152600401602060405180830381600087803b158015610d7057600080fd5b505af1158015610d84573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610da89190612e90565b90506001600160a01b0386163014610ded576001600160a01b0386163314610de25760405162461bcd60e51b815260040161058690613e05565b610ded86828661244d565b6040517f095ea7b30000000000000000000000000000000000000000000000000000000081526001600160a01b0382169063095ea7b390610e34908a908890600401613a66565b602060405180830381600087803b158015610e4e57600080fd5b505af1158015610e62573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e8691906130f3565b506040517f2f2cab870000000000000000000000000000000000000000000000000000000081526000906001600160a01b03891690632f2cab8790610ed5908990899086908a90600401613aa2565b602060405180830381600087803b158015610eef57600080fd5b505af1158015610f03573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f2791906136ea565b9050610f3283612341565b15610f4157610f418382612420565b5050505050505050565b610f5482612341565b15610f6557610f628261238c565b91505b6001600160a01b0384163014610fa8576001600160a01b0384163314610f9d5760405162461bcd60e51b815260040161058690613e05565b610fa884868461244d565b6040517fea785a5e0000000000000000000000000000000000000000000000000000000081526000906001600160a01b0387169063ea785a5e90610ff29087908790600401613a66565b602060405180830381600087803b15801561100c57600080fd5b505af1158015611020573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061104491906136ea565b905061104f82612341565b1561105e5761105e8282612420565b505050505050565b61106f82612341565b156110805761107d8261238c565b91505b6000856001600160a01b03166338d52e0f6040518163ffffffff1660e01b815260040160206040518083038186803b1580156110bb57600080fd5b505afa1580156110cf573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110f39190612e90565b90506001600160a01b0385163014611138576001600160a01b038516331461112d5760405162461bcd60e51b815260040161058690613e05565b61113885828561244d565b6040517f095ea7b30000000000000000000000000000000000000000000000000000000081526001600160a01b0382169063095ea7b39061117f9089908790600401613a66565b602060405180830381600087803b15801561119957600080fd5b505af11580156111ad573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111d191906130f3565b506040517f6e553f650000000000000000000000000000000000000000000000000000000081526000906001600160a01b03881690636e553f659061121c9087908990600401613f3e565b602060405180830381600087803b15801561123657600080fd5b505af115801561124a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061126e91906136ea565b905061127983612341565b15611288576112888382612420565b50505050505050565b61129a83612341565b156112ab576112a88361238c565b92505b6001600160a01b03851630146112ee576001600160a01b03851633146112e35760405162461bcd60e51b815260040161058690613e05565b6112ee85878561244d565b6040517fead5d3590000000000000000000000000000000000000000000000000000000081526000906001600160a01b0388169063ead5d3599061133a90889088908890600401613a7f565b6040805180830381600087803b15801561135357600080fd5b505af1158015611367573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061138b9190613702565b91505061139782612341565b15611288576112888282612420565b7f000000000000000000000000000000000000000000000000000000000000000090565b6001600160a01b0384163014806113df575082155b6113fb5760405162461bcd60e51b815260040161058690613e3c565b606063fa6e671d60e01b33868660405160240161141a9392919061395e565b60408051601f19818403018152918152602080830180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff000000000000000000000000000000000000000000000000000000009095169490941790935251611489928691869101613917565b60408051601f19818403018152919052905061105e6001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016826124e9565b866001600160a01b031663d505accf876114e6611548565b88888888886040518863ffffffff1660e01b815260040161150d9796959493929190613a25565b600060405180830381600087803b15801561152757600080fd5b505af115801561153b573d6000803e3d6000fd5b5050505050505050505050565b7f000000000000000000000000000000000000000000000000000000000000000090565b6001600160a01b03851633148061158b57506001600160a01b03851630145b6115a75760405162461bcd60e51b815260040161058690613e05565b60006115b288612561565b905060006115bf83612341565b6115ca57600061165f565b6040517f70a082310000000000000000000000000000000000000000000000000000000081526001600160a01b038316906370a082319061160f90899060040161394a565b60206040518083038186803b15801561162757600080fd5b505afa15801561163b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061165f91906136ea565b905061166f888660400151612567565b604086015261167c611548565b6001600160a01b031663b95cac28858b8a8a8a6040518663ffffffff1660e01b81526004016116ae9493929190613c56565b6000604051808303818588803b1580156116c757600080fd5b505af11580156116db573d6000803e3d6000fd5b50505050506116e983612341565b15611798576040517f70a082310000000000000000000000000000000000000000000000000000000081526000906001600160a01b038416906370a0823190611736908a9060040161394a565b60206040518083038186803b15801561174e57600080fd5b505afa158015611762573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061178691906136ea565b9050611796846107208385612595565b505b505050505050505050565b876001600160a01b0316638fcbaf0c886117bb611548565b8989898989896040518963ffffffff1660e01b81526004016117e49897969594939291906139dc565b600060405180830381600087803b1580156117fe57600080fd5b505af1158015611812573d6000803e3d6000fd5b505050505050505050505050565b61182982612341565b1561183a576118378261238c565b91505b6000856001600160a01b0316636f307dc36040518163ffffffff1660e01b815260040160206040518083038186803b15801561187557600080fd5b505afa158015611889573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118ad9190612e90565b90506001600160a01b03851630146118f2576001600160a01b03851633146118e75760405162461bcd60e51b815260040161058690613e05565b6118f285828561244d565b6040517f095ea7b30000000000000000000000000000000000000000000000000000000081526001600160a01b0382169063095ea7b3906119399089908790600401613a66565b602060405180830381600087803b15801561195357600080fd5b505af1158015611967573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061198b91906130f3565b506040517f2f4f21e20000000000000000000000000000000000000000000000000000000081526000906001600160a01b03881690632f4f21e29061121c9088908890600401613a66565b816001600160a01b031663095ea7b36119ed611548565b836040518363ffffffff1660e01b8152600401611a0b929190613a66565b602060405180830381600087803b158015611a2557600080fd5b505af1158015611a39573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a5d91906130f3565b505050565b6001600160a01b038516331480611a8157506001600160a01b03851630145b611a9d5760405162461bcd60e51b815260040161058690613e05565b60608167ffffffffffffffff81118015611ab657600080fd5b50604051908082528060200260200182016040528015611ae0578160200160208202803683370190505b50905060608267ffffffffffffffff81118015611afc57600080fd5b50604051908082528060200260200182016040528015611b26578160200160208202803683370190505b50905060005b83811015611c9657611b438585838181106106ab57fe5b611b5f5760405162461bcd60e51b815260040161058690613e73565b8551600090868684818110611b7057fe5b9050604002016000013581518110611b8457fe5b60200260200101519050866060015115611bd257611ba1816125ab565b848381518110611bad57fe5b60200260200101906001600160a01b031690816001600160a01b031681525050611c8d565b611bdb816125ae565b611c6857611be8816125ab565b6001600160a01b03166370a08231896040518263ffffffff1660e01b8152600401611c13919061394a565b60206040518083038186803b158015611c2b57600080fd5b505afa158015611c3f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c6391906136ea565b611c74565b876001600160a01b0316315b838381518110611c8057fe5b6020026020010181815250505b50600101611b2c565b50846060015115611d2d57611ca9611548565b6001600160a01b0316630f5a6efa87846040518363ffffffff1660e01b8152600401611cd6929190613982565b60006040518083038186803b158015611cee57600080fd5b505afa158015611d02573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052611d2a91908101906130b8565b90505b611d3b8886604001516125bb565b6040860152611d48611548565b6001600160a01b0316638bdb39138a8989896040518563ffffffff1660e01b8152600401611d799493929190613c56565b600060405180830381600087803b158015611d9357600080fd5b505af1158015611da7573d6000803e3d6000fd5b50606092508591505067ffffffffffffffff81118015611dc657600080fd5b50604051908082528060200260200182016040528015611df0578160200160208202803683370190505b509050856060015115611e8d57611e05611548565b6001600160a01b0316630f5a6efa88856040518363ffffffff1660e01b8152600401611e32929190613982565b60006040518083038186803b158015611e4a57600080fd5b505afa158015611e5e573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052611e8691908101906130b8565b9050611f8b565b60005b84811015611f89578651600090878784818110611ea957fe5b9050604002016000013581518110611ebd57fe5b60200260200101519050611ed0816125ae565b611f5d57611edd816125ab565b6001600160a01b03166370a082318a6040518263ffffffff1660e01b8152600401611f08919061394a565b60206040518083038186803b158015611f2057600080fd5b505afa158015611f34573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f5891906136ea565b611f69565b886001600160a01b0316315b838381518110611f7557fe5b602090810291909101015250600101611e90565b505b60005b8481101561153b57611fe8868683818110611fa557fe5b90506040020160200135610720858481518110611fbe57fe5b6020026020010151858581518110611fd257fe5b602002602001015161259590919063ffffffff16565b600101611f8e565b611ff982612341565b1561200a576120078261238c565b91505b6001600160a01b038416301461206d576001600160a01b03841633146120425760405162461bcd60e51b815260040161058690613e05565b61206d847f00000000000000000000000000000000000000000000000000000000000000008461244d565b6040517fde0e9a3e0000000000000000000000000000000000000000000000000000000081526000906001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169063de0e9a3e906120d5908690600401613f35565b602060405180830381600087803b1580156120ef57600080fd5b505af1158015612103573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061212791906136ea565b90506001600160a01b0384163014610a1c576040517fa9059cbb0000000000000000000000000000000000000000000000000000000081526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169063a9059cbb906109c89087908590600401613a66565b60005b8281101561223457338484838181106121b857fe5b905060a0020160600160208101906121d09190612e74565b6001600160a01b031614806122105750308484838181106121ed57fe5b905060a0020160600160208101906122059190612e74565b6001600160a01b0316145b61222c5760405162461bcd60e51b815260040161058690613e05565b6001016121a3565b5061223d611548565b6001600160a01b0316630e8e3e848285856040518463ffffffff1660e01b815260040161226b929190613b12565b6000604051808303818588803b15801561228457600080fd5b505af1158015610f41573d6000803e3d6000fd5b6122a182612341565b156122b2576122af8261238c565b91505b6001600160a01b03841630146122f5576001600160a01b03841633146122ea5760405162461bcd60e51b815260040161058690613e05565b6122f584868461244d565b6040517fba0876520000000000000000000000000000000000000000000000000000000081526000906001600160a01b0387169063ba08765290610ff290869088903090600401613f55565b7fba100000000000000000000000000000000000000000000000000000000000007fffff0000000000000000000000000000000000000000000000000000000000008216145b919050565b600080612398836125e2565b805460009091559392505050565b6123b5814710156101a3612638565b6000826001600160a01b0316826040516123ce906125ab565b60006040518083038185875af1925050503d806000811461240b576040519150601f19603f3d011682016040523d82523d6000602084013e612410565b606091505b50509050611a5d816101a4612638565b600061242b836125e2565b919091555050565b60008082136124455781600003612447565b815b92915050565b8061245757611a5d565b60408051600180825281830190925260609160208083019080368337019050509050828160008151811061248757fe5b6001600160a01b03929092166020928302919091019091015260408051600180825281830190925260609181602001602082028036833701905050905082816000815181106124d257fe5b602002602001018181525050610a3485838361264a565b606060006060846001600160a01b03168460405161250791906138fb565b6000604051808303816000865af19150503d8060008114612544576040519150601f19603f3d011682016040523d82523d6000602084013e612549565b606091505b50915091506125588282612784565b95945050505050565b60601c90565b6060600083801561257457fe5b141561258a57612583826127ae565b9050612447565b6124476101366127eb565b60006125a5838311156001612638565b50900390565b90565b6001600160a01b03161590565b606060008380156125c857fe5b14156125d7576125838261283e565b6124476101506127eb565b60006001827f000000000000000000000000000000000000000000000000000000000000000060405160200161261992919061393c565b60408051808303601f1901815291905280516020909101200392915050565b8161264657612646816127eb565b5050565b6060825167ffffffffffffffff8111801561266457600080fd5b5060405190808252806020026020018201604052801561269e57816020015b61268b612a58565b8152602001906001900390816126835790505b50905060005b8351811015612736576040805160a0810190915280600381526020018583815181106126cc57fe5b60200260200101516001600160a01b031681526020018483815181106126ee57fe5b60200260200101518152602001866001600160a01b03168152602001306001600160a01b031681525082828151811061272357fe5b60209081029190910101526001016126a4565b5061273f611548565b6001600160a01b0316630e8e3e84826040518263ffffffff1660e01b815260040161276a9190613bc0565b600060405180830381600087803b15801561228457600080fd5b60608215612793575080612447565b8151156127a35781518083602001fd5b6124476101ae6127eb565b606060006127bb83612887565b905060018160038111156127cb57fe5b14156127e2576127da8361289d565b915050612387565b82915050612387565b62461bcd60e51b6000908152602060045260076024526642414c23000030600a808404818106603090810160081b95839006959095019082900491820690940160101b939093010160c81b604452606490fd5b6060600061284b83612887565b9050600081600381111561285b57fe5b141561286a576127da8361294b565b600181600381111561287857fe5b14156127e2576127da836129ae565b6000818060200190518101906124479190613429565b60608060006128ab84612a01565b915091506000805b83518110156129115760008482815181106128ca57fe5b602002602001015190506128dd81612341565b15612908576128eb8161238c565b8583815181106128f757fe5b602002602001018181525050600192505b506001016128b3565b508061291d5784612558565b6001838360405160200161293393929190613cca565b60405160208183030381529060405295945050505050565b606060008061295984612a24565b9150915061296682612341565b156129a4576129748261238c565b91506000828260405160200161298c93929190613ca9565b60405160208183030381529060405292505050612387565b8392505050612387565b606060006129bb83612a3b565b90506129c681612341565b156127e2576129d48161238c565b90506001816040516020016129ea929190613c92565b604051602081830303815290604052915050612387565b6060600082806020019051810190612a1991906134a8565b909590945092505050565b60008082806020019051810190612a199190613472565b600081806020019051810190612a519190613445565b9392505050565b6040805160a081019091528060008152600060208201819052604082018190526060820181905260809091015290565b80356124478161400b565b60008083601f840112612aa4578182fd5b50813567ffffffffffffffff811115612abb578182fd5b6020830191508360208083028501011115612ad557600080fd5b9250929050565b600082601f830112612aec578081fd5b8135612aff612afa82613f9b565b613f74565b818152915060208083019084810181840286018201871015612b2057600080fd5b60005b84811015612b48578135612b368161400b565b84529282019290820190600101612b23565b505050505092915050565b600082601f830112612b63578081fd5b8135612b71612afa82613f9b565b818152915060208083019084810160005b84811015612b48578135870160a080601f19838c03011215612ba357600080fd5b612bac81613f74565b85830135815260408084013587830152606080850135828401526080915081850135818401525082840135925067ffffffffffffffff831115612bee57600080fd5b612bfc8c8885870101612d1e565b90820152865250509282019290820190600101612b82565b60008083601f840112612c25578182fd5b50813567ffffffffffffffff811115612c3c578182fd5b602083019150836020604083028501011115612ad557600080fd5b600082601f830112612c67578081fd5b8135612c75612afa82613f9b565b818152915060208083019084810181840286018201871015612c9657600080fd5b60005b84811015612b4857813584529282019290820190600101612c99565b600082601f830112612cc5578081fd5b8151612cd3612afa82613f9b565b818152915060208083019084810181840286018201871015612cf457600080fd5b60005b84811015612b4857815184529282019290820190600101612cf7565b803561244781614020565b600082601f830112612d2e578081fd5b813567ffffffffffffffff811115612d44578182fd5b612d576020601f19601f84011601613f74565b9150808252836020828501011115612d6e57600080fd5b8060208401602084013760009082016020015292915050565b80356001811061244757600080fd5b80356002811061244757600080fd5b600060808284031215612db6578081fd5b612dc06080613f74565b9050813567ffffffffffffffff80821115612dda57600080fd5b612de685838601612adc565b83526020840135915080821115612dfc57600080fd5b612e0885838601612c57565b60208401526040840135915080821115612e2157600080fd5b50612e2e84828501612d1e565b604083015250612e418360608401612d13565b606082015292915050565b600060808284031215612e5d578081fd5b50919050565b803560ff8116811461244757600080fd5b600060208284031215612e85578081fd5b8135612a518161400b565b600060208284031215612ea1578081fd5b8151612a518161400b565b60008060008060808587031215612ec1578283fd5b8435612ecc8161400b565b93506020850135612edc8161400b565b93969395505050506040820135916060013590565b60008060008060608587031215612f06578182fd5b8435612f118161400b565b93506020850135612f2181614020565b9250604085013567ffffffffffffffff80821115612f3d578384fd5b818701915087601f830112612f50578384fd5b813581811115612f5e578485fd5b886020828501011115612f6f578485fd5b95989497505060200194505050565b600080600060608486031215612f92578081fd5b8335612f9d8161400b565b95602085013595506040909401359392505050565b60006020808385031215612fc4578182fd5b825167ffffffffffffffff811115612fda578283fd5b8301601f81018513612fea578283fd5b8051612ff8612afa82613f9b565b8181528381019083850185840285018601891015613014578687fd5b8694505b83851015613036578051835260019490940193918501918501613018565b50979650505050505050565b600080600060408486031215613056578081fd5b833567ffffffffffffffff8082111561306d578283fd5b818601915086601f830112613080578283fd5b81358181111561308e578384fd5b87602060a0830285010111156130a2578384fd5b6020928301989097509590910135949350505050565b6000602082840312156130c9578081fd5b815167ffffffffffffffff8111156130df578182fd5b6130eb84828501612cb5565b949350505050565b600060208284031215613104578081fd5b8151612a5181614020565b600080600080600080600060c0888a031215613129578485fd5b8735965061313a8960208a01612d87565b9550604088013561314a8161400b565b9450606088013561315a8161400b565b9350608088013567ffffffffffffffff80821115613176578485fd5b6131828b838c01612da5565b945060a08a0135915080821115613197578384fd5b506131a48a828b01612c14565b989b979a50959850939692959293505050565b600080600080600080600060e0888a0312156131d1578081fd5b873596506131e28960208a01612d87565b955060408801356131f28161400b565b945060608801356132028161400b565b9350608088013567ffffffffffffffff81111561321d578182fd5b6132298a828b01612da5565b93505060a0880135915060c0880135905092959891949750929550565b600080600080600080600080610100898b031215613262578182fd5b883561326d8161400b565b9750602089013561327d8161400b565b96506040890135955060608901359450608089013561329b81614020565b93506132aa8a60a08b01612e63565b925060c0890135915060e089013590509295985092959890939650565b600080600080600080600060e0888a0312156132e1578081fd5b87356132ec8161400b565b965060208801356132fc8161400b565b955060408801359450606088013593506133198960808a01612e63565b925060a0880135915060c0880135905092959891949750929550565b60008060408385031215613347578182fd5b82356133528161400b565b946020939093013593505050565b600080600080600060a08688031215613377578283fd5b85356133828161400b565b945060208601356133928161400b565b935060408601356133a28161400b565b94979396509394606081013594506080013592915050565b60008060008060008060c087890312156133d2578384fd5b86356133dd8161400b565b955060208701356133ed8161400b565b945060408701356133fd8161400b565b935060608701359250608087013561341481614020565b8092505060a087013590509295509295509295565b60006020828403121561343a578081fd5b8151612a518161402e565b60008060408385031215613457578182fd5b82516134628161402e565b6020939093015192949293505050565b600080600060608486031215613486578081fd5b83516134918161402e565b602085015160409095015190969495509392505050565b6000806000606084860312156134bc578081fd5b83516134c78161402e565b602085015190935067ffffffffffffffff8111156134e3578182fd5b6134ef86828701612cb5565b925050604084015190509250925092565b60008060008060008060008060008060006101608c8e031215613521578485fd5b61352b8d8d612d96565b9a5067ffffffffffffffff8060208e01351115613546578586fd5b6135568e60208f01358f01612b53565b9a508060408e01351115613568578586fd5b6135788e60408f01358f01612a93565b909a50985061358a8e60608f01612e4c565b97508060e08e0135111561359c578586fd5b6135ac8e60e08f01358f01612a93565b90975095506101008d013594506101208d013593506101408d01358110156135d2578283fd5b506135e48d6101408e01358e01612c14565b81935080925050509295989b509295989b9093969950565b6000806000806000806101208789031215613615578384fd5b863567ffffffffffffffff8082111561362c578586fd5b9088019060c0828b03121561363f578586fd5b61364960c0613f74565b8235815261365a8b60208501612d96565b6020820152604083013561366d8161400b565b604082015261367f8b60608501612a88565b60608201526080830135608082015260a08301358281111561369f578788fd5b6136ab8c828601612d1e565b60a0830152508098505050506136c48860208901612e4c565b959895975050505060a08401359360c08101359360e08201359350610100909101359150565b6000602082840312156136fb578081fd5b5051919050565b60008060408385031215613714578182fd5b505080516020909101519092909150565b6001600160a01b03169052565b60008284526020808501945082825b8581101561376f5781356137548161400b565b6001600160a01b031687529582019590820190600101613741565b509495945050505050565b60008284526020808501945082825b8581101561376f57813587529582019590820190600101613789565b6000815180845260208085019450808401835b8381101561376f578151875295820195908201906001016137b8565b15159052565b600081518084526137f2816020860160208601613fc8565b601f01601f19169290920160200192915050565b8051608080845281519084018190526000916020919082019060a0860190845b8181101561384b5783516001600160a01b031683529284019291840191600101613826565b50508285015191508581038387015261386481836137a5565b925050506040830151848203604086015261387f82826137da565b915050606083015161389460608601826137d4565b509392505050565b80356138a78161400b565b6001600160a01b0390811683526020820135906138c382614020565b90151560208401526040820135906138da8261400b565b16604083015260608101356138ee81614020565b8015156060840152505050565b6000825161390d818460208701613fc8565b9190910192915050565b60008451613929818460208901613fc8565b8201838582379092019182525092915050565b918252602082015260400190565b6001600160a01b0391909116815260200190565b6001600160a01b039384168152919092166020820152901515604082015260600190565b6000604082016001600160a01b03808616845260206040818601528286518085526060870191508288019450855b818110156139ce5785518516835294830194918301916001016139b0565b509098975050505050505050565b6001600160a01b039889168152969097166020870152604086019490945260608501929092521515608084015260ff1660a083015260c082015260e08101919091526101000190565b6001600160a01b0397881681529590961660208601526040850193909352606084019190915260ff16608083015260a082015260c081019190915260e00190565b6001600160a01b03929092168252602082015260400190565b6001600160a01b0393909316835260208301919091521515604082015260600190565b6001600160a01b03949094168452602084019290925261ffff1660408301521515606082015260800190565b6020808252825182820181905260009190848201906040850190845b81811015613b0657835183529284019291840191600101613aea565b50909695505050505050565b6020808252818101839052600090604080840186845b87811015613bb3578135613b3b8161402e565b613b4481613ff4565b835281850135613b538161400b565b6001600160a01b03168386015281840135848401526060613b7681840184613fbb565b613b8282860182613725565b50506080613b9281840184613fbb565b613b9e82860182613725565b505060a0928301929190910190600101613b28565b5090979650505050505050565b602080825282518282018190526000919060409081850190868401855b82811015613c495781518051613bf281613ff4565b8552808701516001600160a01b0316878601528581015186860152606080820151613c1f82880182613725565b505060809081015190613c3486820183613725565b505060a0939093019290850190600101613bdd565b5091979650505050505050565b60008582526001600160a01b03808616602084015280851660408401525060806060830152613c886080830184613806565b9695505050505050565b60408101613c9f84613ff4565b9281526020015290565b60608101613cb685613ff4565b938152602081019290925260409091015290565b6000613cd585613ff4565b84825260606020830152613cec60608301856137a5565b9050826040830152949350505050565b6000610120808301613d0d8c614001565b8b84526020808501929092528a5190819052610140808501928281028601909101918c8201855b82811015613db4578785037ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec00186528151805186528481015185870152604080820151908701526060808201519087015260809081015160a091870182905290613da0818801836137da565b978601979650505090830190600101613d34565b505050508381036040850152613dcb818a8c613732565b915050613ddb606084018861389c565b82810360e0840152613dee81868861377a565b915050826101008301529998505050505050505050565b60208082526010908201527f496e636f72726563742073656e64657200000000000000000000000000000000604082015260600190565b6020808252601f908201527f52656c617965722063616e206f6e6c7920617070726f766520697473656c6600604082015260600190565b60208082526019908201527f696e76616c696420636861696e6564207265666572656e636500000000000000604082015260600190565b600060e08252855160e08301526020860151613ec581614001565b61010083015260408601516001600160a01b03908116610120840152606087015116610140830152608086015161016083015260a086015160c0610180840152613f136101a08401826137da565b915050613f23602083018661389c565b60a082019390935260c0015292915050565b90815260200190565b9182526001600160a01b0316602082015260400190565b9283526001600160a01b03918216602084015216604082015260600190565b60405181810167ffffffffffffffff81118282101715613f9357600080fd5b604052919050565b600067ffffffffffffffff821115613fb1578081fd5b5060209081020190565b60008235612a518161400b565b60005b83811015613fe3578181015183820152602001613fcb565b8381111561052b5750506000910152565b60048110613ffe57fe5b50565b60028110613ffe57fe5b6001600160a01b0381168114613ffe57600080fd5b8015158114613ffe57600080fd5b60048110613ffe57600080fdfea264697066735822122025243bbdfb65ba86b5f803d93a3a51b76dfd9a870b570145fb0333e20f93cf5f64736f6c6343000701003360c060405234801561001057600080fd5b5060405161074f38038061074f83398101604081905261002f91610052565b60016000556001600160601b0319606092831b8116608052911b1660a0526100a3565b60008060408385031215610064578182fd5b825161006f8161008b565b60208401519092506100808161008b565b809150509250929050565b6001600160a01b03811681146100a057600080fd5b50565b60805160601c60a05160601c61067b6100d46000398060fc528061020f52508060585280610120525061067b6000f3fe6080604052600436106100385760003560e01c80637678922e146100885780638d928af8146100b3578063ac9650d8146100c857610083565b36610083576100813373ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000000000000000000000000000000000000000000016146102066100e8565b005b600080fd5b34801561009457600080fd5b5061009d6100fa565b6040516100aa91906104d6565b60405180910390f35b3480156100bf57600080fd5b5061009d61011e565b6100db6100d6366004610448565b610142565b6040516100aa91906104f7565b816100f6576100f68161026e565b5050565b7f000000000000000000000000000000000000000000000000000000000000000090565b7f000000000000000000000000000000000000000000000000000000000000000090565b606061014c6102db565b8167ffffffffffffffff8111801561016357600080fd5b5060405190808252806020026020018201604052801561019757816020015b60608152602001906001900390816101825790505b50905060005b82811015610257576102388484838181106101b457fe5b90506020028101906101c691906105ab565b8080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152505073ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000000000000000000000000000000000000000000016929150506102f4565b82828151811061024457fe5b602090810291909101015260010161019d565b50610260610377565b61026861038b565b92915050565b7f08c379a0000000000000000000000000000000000000000000000000000000006000908152602060045260076024526642414c23000030600a808404818106603090810160081b95839006959095019082900491820690940160101b939093010160c81b604452606490fd5b6102ed600260005414156101906100e8565b6002600055565b6060600060608473ffffffffffffffffffffffffffffffffffffffff168460405161031f91906104b7565b600060405180830381855af49150503d806000811461035a576040519150601f19603f3d011682016040523d82523d6000602084013e61035f565b606091505b509150915061036e8282610392565b95945050505050565b4780156103885761038833826103bc565b50565b6001600055565b606082156103a1575080610268565b8151156103b15781518083602001fd5b6102686101ae61026e565b6103cb814710156101a36100e8565b60008273ffffffffffffffffffffffffffffffffffffffff16826040516103f1906104d3565b60006040518083038185875af1925050503d806000811461042e576040519150601f19603f3d011682016040523d82523d6000602084013e610433565b606091505b50509050610443816101a46100e8565b505050565b6000806020838503121561045a578182fd5b823567ffffffffffffffff80821115610471578384fd5b818501915085601f830112610484578384fd5b813581811115610492578485fd5b86602080830285010111156104a5578485fd5b60209290920196919550909350505050565b600082516104c9818460208701610615565b9190910192915050565b90565b73ffffffffffffffffffffffffffffffffffffffff91909116815260200190565b6000602080830181845280855180835260408601915060408482028701019250838701855b8281101561059e577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc088860301845281518051808752610561818989018a8501610615565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169590950186019450928501929085019060010161051c565b5092979650505050505050565b60008083357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe18436030181126105df578283fd5b83018035915067ffffffffffffffff8211156105f9578283fd5b60200191503681900382131561060e57600080fd5b9250929050565b60005b83811015610630578181015183820152602001610618565b8381111561063f576000848401525b5050505056fea26469706673582212207bec353e9208321ecbb5e97f79b940fc6df900afa85b759a6fc41b9c6709c0fe64736f6c63430007010033000000000000000000000000ba12222222228d8ba445958a75a0704d566bf2c80000000000000000000000006320cd32aa674d2898a68ec82e869385fc5f7e2f
Deployed Bytecode
0x60806040526004361061016a5760003560e01c806380db15bd116100cb578063abf6d3991161007f578063db4c0e9111610059578063db4c0e9114610308578063ecc026371461031b578063efe691081461032e5761016a565b8063abf6d399146102c2578063b6d24737146102d5578063d80952d5146102f55761016a565b80638d928af8116100b05780638d928af8146102875780638fe4624f1461029c578063959fc17a146102af5761016a565b806380db15bd146102615780638d64cfbc146102745761016a565b8063433b0865116101225780636d307ea8116101075780636d307ea8146102195780637ab6e03c1461022c5780637fd0e5d51461023f5761016a565b8063433b0865146101f3578063611b90dd146102065761016a565b80631c982441116101535780631c982441146101ad5780632cbec84e146101c05780632e6272ea146101d35761016a565b80631089e5e31461016f5780631836944614610184575b600080fd5b61018261017d366004612f7e565b610341565b005b610197610192366004613500565b610531565b6040516101a49190613ace565b60405180910390f35b6101826101bb366004612eac565b61073e565b6101826101ce366004612f7e565b610a3b565b6101e66101e13660046135fc565b610b6f565b6040516101a49190613f35565b6101826102013660046133ba565b610c9c565b610182610214366004613360565b610f4b565b610182610227366004613360565b611066565b61018261023a3660046133ba565b611291565b34801561024b57600080fd5b506102546113a6565b6040516101a4919061394a565b61018261026f366004612ef1565b6113ca565b6101826102823660046132c7565b6114ce565b34801561029357600080fd5b50610254611548565b6101826102aa3660046131b7565b61156c565b6101826102bd366004613246565b6117a3565b6101826102d0366004613360565b611820565b3480156102e157600080fd5b506101826102f0366004613335565b6119d6565b61018261030336600461310f565b611a62565b610182610316366004612eac565b611ff0565b610182610329366004613042565b6121a0565b61018261033c366004613360565b612298565b61034a82612341565b1561035b576103588261238c565b91505b6040517fb0e389000000000000000000000000000000000000000000000000000000000081526000906001600160a01b037f0000000000000000000000006320cd32aa674d2898a68ec82e869385fc5f7e2f169063b0e38900906103c3908690600401613f35565b60206040518083038186803b1580156103db57600080fd5b505afa1580156103ef573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061041391906136ea565b90506104486001600160a01b037f0000000000000000000000006320cd32aa674d2898a68ec82e869385fc5f7e2f16846123a6565b6001600160a01b0384163014610513576040517fa9059cbb0000000000000000000000000000000000000000000000000000000081526001600160a01b037f0000000000000000000000006320cd32aa674d2898a68ec82e869385fc5f7e2f169063a9059cbb906104bf9087908590600401613a66565b602060405180830381600087803b1580156104d957600080fd5b505af11580156104ed573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061051191906130f3565b505b61051c82612341565b1561052b5761052b8282612420565b50505050565b60603361054160208a018a612e74565b6001600160a01b0316148061056a57503061055f60208a018a612e74565b6001600160a01b0316145b61058f5760405162461bcd60e51b815260040161058690613e05565b60405180910390fd5b60005b8b518110156105f45760008c82815181106105a957fe5b60200260200101516060015190506105c081612341565b156105eb576105ce8161238c565b8d83815181106105da57fe5b602002602001015160600181815250505b50600101610592565b5060606105ff611548565b6001600160a01b031663945bcec9868f8f8f8f8f8f8f8f6040518a63ffffffff1660e01b8152600401610639989796959493929190613cfc565b6000604051808303818588803b15801561065257600080fd5b505af1158015610666573d6000803e3d6000fd5b50505050506040513d6000823e601f3d908101601f1916820160405261068f9190810190612fb2565b905060005b8381101561072d576106ba8585838181106106ab57fe5b90506040020160200135612341565b6106d65760405162461bcd60e51b815260040161058690613e73565b6107258585838181106106e557fe5b90506040020160200135610720848888868181106106ff57fe5b905060400201600001358151811061071357fe5b6020026020010151612433565b612420565b600101610694565b509c9b505050505050505050505050565b61074782612341565b15610758576107558261238c565b91505b6001600160a01b03841630146107bb576001600160a01b03841633146107905760405162461bcd60e51b815260040161058690613e05565b6107bb847f0000000000000000000000001643e812ae58766192cf7d2cf9567df2c37e9b7f8461244d565b6040517f095ea7b30000000000000000000000000000000000000000000000000000000081526001600160a01b037f0000000000000000000000001643e812ae58766192cf7d2cf9567df2c37e9b7f169063095ea7b390610842907f0000000000000000000000006320cd32aa674d2898a68ec82e869385fc5f7e2f908690600401613a66565b602060405180830381600087803b15801561085c57600080fd5b505af1158015610870573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061089491906130f3565b506040517fea598cb00000000000000000000000000000000000000000000000000000000081526000906001600160a01b037f0000000000000000000000006320cd32aa674d2898a68ec82e869385fc5f7e2f169063ea598cb0906108fd908690600401613f35565b602060405180830381600087803b15801561091757600080fd5b505af115801561092b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061094f91906136ea565b90506001600160a01b0384163014610a1c576040517fa9059cbb0000000000000000000000000000000000000000000000000000000081526001600160a01b037f0000000000000000000000006320cd32aa674d2898a68ec82e869385fc5f7e2f169063a9059cbb906109c89087908590600401613a66565b602060405180830381600087803b1580156109e257600080fd5b505af11580156109f6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a1a91906130f3565b505b610a2582612341565b15610a3457610a348282612420565b5050505050565b610a4482612341565b15610a5557610a528261238c565b91505b60007f0000000000000000000000001643e812ae58766192cf7d2cf9567df2c37e9b7f6001600160a01b031663a1903eab84306040518363ffffffff1660e01b8152600401610aa4919061394a565b6020604051808303818588803b158015610abd57600080fd5b505af1158015610ad1573d6000803e3d6000fd5b50505050506040513d601f19601f82011682018060405250810190610af691906136ea565b90506001600160a01b0384163014610513576040517fa9059cbb0000000000000000000000000000000000000000000000000000000081526001600160a01b037f0000000000000000000000001643e812ae58766192cf7d2cf9567df2c37e9b7f169063a9059cbb906104bf9087908590600401613a66565b600033610b7f6020880188612e74565b6001600160a01b03161480610ba8575030610b9d6020880188612e74565b6001600160a01b0316145b610bc45760405162461bcd60e51b815260040161058690613e05565b610bd18760800151612341565b15610be957610be3876080015161238c565b60808801525b6000610bf3611548565b6001600160a01b03166352bbbe29858a8a8a8a6040518663ffffffff1660e01b8152600401610c259493929190613eaa565b6020604051808303818588803b158015610c3e57600080fd5b505af1158015610c52573d6000803e3d6000fd5b50505050506040513d601f19601f82011682018060405250810190610c7791906136ea565b9050610c8283612341565b15610c9157610c918382612420565b979650505050505050565b610ca583612341565b15610cb657610cb38361238c565b92505b600082610d3557866001600160a01b03166351c0e0616040518163ffffffff1660e01b8152600401602060405180830381600087803b158015610cf857600080fd5b505af1158015610d0c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d309190612e90565b610da8565b866001600160a01b0316634800d97f6040518163ffffffff1660e01b8152600401602060405180830381600087803b158015610d7057600080fd5b505af1158015610d84573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610da89190612e90565b90506001600160a01b0386163014610ded576001600160a01b0386163314610de25760405162461bcd60e51b815260040161058690613e05565b610ded86828661244d565b6040517f095ea7b30000000000000000000000000000000000000000000000000000000081526001600160a01b0382169063095ea7b390610e34908a908890600401613a66565b602060405180830381600087803b158015610e4e57600080fd5b505af1158015610e62573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e8691906130f3565b506040517f2f2cab870000000000000000000000000000000000000000000000000000000081526000906001600160a01b03891690632f2cab8790610ed5908990899086908a90600401613aa2565b602060405180830381600087803b158015610eef57600080fd5b505af1158015610f03573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f2791906136ea565b9050610f3283612341565b15610f4157610f418382612420565b5050505050505050565b610f5482612341565b15610f6557610f628261238c565b91505b6001600160a01b0384163014610fa8576001600160a01b0384163314610f9d5760405162461bcd60e51b815260040161058690613e05565b610fa884868461244d565b6040517fea785a5e0000000000000000000000000000000000000000000000000000000081526000906001600160a01b0387169063ea785a5e90610ff29087908790600401613a66565b602060405180830381600087803b15801561100c57600080fd5b505af1158015611020573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061104491906136ea565b905061104f82612341565b1561105e5761105e8282612420565b505050505050565b61106f82612341565b156110805761107d8261238c565b91505b6000856001600160a01b03166338d52e0f6040518163ffffffff1660e01b815260040160206040518083038186803b1580156110bb57600080fd5b505afa1580156110cf573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110f39190612e90565b90506001600160a01b0385163014611138576001600160a01b038516331461112d5760405162461bcd60e51b815260040161058690613e05565b61113885828561244d565b6040517f095ea7b30000000000000000000000000000000000000000000000000000000081526001600160a01b0382169063095ea7b39061117f9089908790600401613a66565b602060405180830381600087803b15801561119957600080fd5b505af11580156111ad573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111d191906130f3565b506040517f6e553f650000000000000000000000000000000000000000000000000000000081526000906001600160a01b03881690636e553f659061121c9087908990600401613f3e565b602060405180830381600087803b15801561123657600080fd5b505af115801561124a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061126e91906136ea565b905061127983612341565b15611288576112888382612420565b50505050505050565b61129a83612341565b156112ab576112a88361238c565b92505b6001600160a01b03851630146112ee576001600160a01b03851633146112e35760405162461bcd60e51b815260040161058690613e05565b6112ee85878561244d565b6040517fead5d3590000000000000000000000000000000000000000000000000000000081526000906001600160a01b0388169063ead5d3599061133a90889088908890600401613a7f565b6040805180830381600087803b15801561135357600080fd5b505af1158015611367573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061138b9190613702565b91505061139782612341565b15611288576112888282612420565b7f00000000000000000000000012a39c1a0d17f354d02670961def678223aa15da90565b6001600160a01b0384163014806113df575082155b6113fb5760405162461bcd60e51b815260040161058690613e3c565b606063fa6e671d60e01b33868660405160240161141a9392919061395e565b60408051601f19818403018152918152602080830180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff000000000000000000000000000000000000000000000000000000009095169490941790935251611489928691869101613917565b60408051601f19818403018152919052905061105e6001600160a01b037f000000000000000000000000ba12222222228d8ba445958a75a0704d566bf2c816826124e9565b866001600160a01b031663d505accf876114e6611548565b88888888886040518863ffffffff1660e01b815260040161150d9796959493929190613a25565b600060405180830381600087803b15801561152757600080fd5b505af115801561153b573d6000803e3d6000fd5b5050505050505050505050565b7f000000000000000000000000ba12222222228d8ba445958a75a0704d566bf2c890565b6001600160a01b03851633148061158b57506001600160a01b03851630145b6115a75760405162461bcd60e51b815260040161058690613e05565b60006115b288612561565b905060006115bf83612341565b6115ca57600061165f565b6040517f70a082310000000000000000000000000000000000000000000000000000000081526001600160a01b038316906370a082319061160f90899060040161394a565b60206040518083038186803b15801561162757600080fd5b505afa15801561163b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061165f91906136ea565b905061166f888660400151612567565b604086015261167c611548565b6001600160a01b031663b95cac28858b8a8a8a6040518663ffffffff1660e01b81526004016116ae9493929190613c56565b6000604051808303818588803b1580156116c757600080fd5b505af11580156116db573d6000803e3d6000fd5b50505050506116e983612341565b15611798576040517f70a082310000000000000000000000000000000000000000000000000000000081526000906001600160a01b038416906370a0823190611736908a9060040161394a565b60206040518083038186803b15801561174e57600080fd5b505afa158015611762573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061178691906136ea565b9050611796846107208385612595565b505b505050505050505050565b876001600160a01b0316638fcbaf0c886117bb611548565b8989898989896040518963ffffffff1660e01b81526004016117e49897969594939291906139dc565b600060405180830381600087803b1580156117fe57600080fd5b505af1158015611812573d6000803e3d6000fd5b505050505050505050505050565b61182982612341565b1561183a576118378261238c565b91505b6000856001600160a01b0316636f307dc36040518163ffffffff1660e01b815260040160206040518083038186803b15801561187557600080fd5b505afa158015611889573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118ad9190612e90565b90506001600160a01b03851630146118f2576001600160a01b03851633146118e75760405162461bcd60e51b815260040161058690613e05565b6118f285828561244d565b6040517f095ea7b30000000000000000000000000000000000000000000000000000000081526001600160a01b0382169063095ea7b3906119399089908790600401613a66565b602060405180830381600087803b15801561195357600080fd5b505af1158015611967573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061198b91906130f3565b506040517f2f4f21e20000000000000000000000000000000000000000000000000000000081526000906001600160a01b03881690632f4f21e29061121c9088908890600401613a66565b816001600160a01b031663095ea7b36119ed611548565b836040518363ffffffff1660e01b8152600401611a0b929190613a66565b602060405180830381600087803b158015611a2557600080fd5b505af1158015611a39573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a5d91906130f3565b505050565b6001600160a01b038516331480611a8157506001600160a01b03851630145b611a9d5760405162461bcd60e51b815260040161058690613e05565b60608167ffffffffffffffff81118015611ab657600080fd5b50604051908082528060200260200182016040528015611ae0578160200160208202803683370190505b50905060608267ffffffffffffffff81118015611afc57600080fd5b50604051908082528060200260200182016040528015611b26578160200160208202803683370190505b50905060005b83811015611c9657611b438585838181106106ab57fe5b611b5f5760405162461bcd60e51b815260040161058690613e73565b8551600090868684818110611b7057fe5b9050604002016000013581518110611b8457fe5b60200260200101519050866060015115611bd257611ba1816125ab565b848381518110611bad57fe5b60200260200101906001600160a01b031690816001600160a01b031681525050611c8d565b611bdb816125ae565b611c6857611be8816125ab565b6001600160a01b03166370a08231896040518263ffffffff1660e01b8152600401611c13919061394a565b60206040518083038186803b158015611c2b57600080fd5b505afa158015611c3f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c6391906136ea565b611c74565b876001600160a01b0316315b838381518110611c8057fe5b6020026020010181815250505b50600101611b2c565b50846060015115611d2d57611ca9611548565b6001600160a01b0316630f5a6efa87846040518363ffffffff1660e01b8152600401611cd6929190613982565b60006040518083038186803b158015611cee57600080fd5b505afa158015611d02573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052611d2a91908101906130b8565b90505b611d3b8886604001516125bb565b6040860152611d48611548565b6001600160a01b0316638bdb39138a8989896040518563ffffffff1660e01b8152600401611d799493929190613c56565b600060405180830381600087803b158015611d9357600080fd5b505af1158015611da7573d6000803e3d6000fd5b50606092508591505067ffffffffffffffff81118015611dc657600080fd5b50604051908082528060200260200182016040528015611df0578160200160208202803683370190505b509050856060015115611e8d57611e05611548565b6001600160a01b0316630f5a6efa88856040518363ffffffff1660e01b8152600401611e32929190613982565b60006040518083038186803b158015611e4a57600080fd5b505afa158015611e5e573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052611e8691908101906130b8565b9050611f8b565b60005b84811015611f89578651600090878784818110611ea957fe5b9050604002016000013581518110611ebd57fe5b60200260200101519050611ed0816125ae565b611f5d57611edd816125ab565b6001600160a01b03166370a082318a6040518263ffffffff1660e01b8152600401611f08919061394a565b60206040518083038186803b158015611f2057600080fd5b505afa158015611f34573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f5891906136ea565b611f69565b886001600160a01b0316315b838381518110611f7557fe5b602090810291909101015250600101611e90565b505b60005b8481101561153b57611fe8868683818110611fa557fe5b90506040020160200135610720858481518110611fbe57fe5b6020026020010151858581518110611fd257fe5b602002602001015161259590919063ffffffff16565b600101611f8e565b611ff982612341565b1561200a576120078261238c565b91505b6001600160a01b038416301461206d576001600160a01b03841633146120425760405162461bcd60e51b815260040161058690613e05565b61206d847f0000000000000000000000006320cd32aa674d2898a68ec82e869385fc5f7e2f8461244d565b6040517fde0e9a3e0000000000000000000000000000000000000000000000000000000081526000906001600160a01b037f0000000000000000000000006320cd32aa674d2898a68ec82e869385fc5f7e2f169063de0e9a3e906120d5908690600401613f35565b602060405180830381600087803b1580156120ef57600080fd5b505af1158015612103573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061212791906136ea565b90506001600160a01b0384163014610a1c576040517fa9059cbb0000000000000000000000000000000000000000000000000000000081526001600160a01b037f0000000000000000000000001643e812ae58766192cf7d2cf9567df2c37e9b7f169063a9059cbb906109c89087908590600401613a66565b60005b8281101561223457338484838181106121b857fe5b905060a0020160600160208101906121d09190612e74565b6001600160a01b031614806122105750308484838181106121ed57fe5b905060a0020160600160208101906122059190612e74565b6001600160a01b0316145b61222c5760405162461bcd60e51b815260040161058690613e05565b6001016121a3565b5061223d611548565b6001600160a01b0316630e8e3e848285856040518463ffffffff1660e01b815260040161226b929190613b12565b6000604051808303818588803b15801561228457600080fd5b505af1158015610f41573d6000803e3d6000fd5b6122a182612341565b156122b2576122af8261238c565b91505b6001600160a01b03841630146122f5576001600160a01b03841633146122ea5760405162461bcd60e51b815260040161058690613e05565b6122f584868461244d565b6040517fba0876520000000000000000000000000000000000000000000000000000000081526000906001600160a01b0387169063ba08765290610ff290869088903090600401613f55565b7fba100000000000000000000000000000000000000000000000000000000000007fffff0000000000000000000000000000000000000000000000000000000000008216145b919050565b600080612398836125e2565b805460009091559392505050565b6123b5814710156101a3612638565b6000826001600160a01b0316826040516123ce906125ab565b60006040518083038185875af1925050503d806000811461240b576040519150601f19603f3d011682016040523d82523d6000602084013e612410565b606091505b50509050611a5d816101a4612638565b600061242b836125e2565b919091555050565b60008082136124455781600003612447565b815b92915050565b8061245757611a5d565b60408051600180825281830190925260609160208083019080368337019050509050828160008151811061248757fe5b6001600160a01b03929092166020928302919091019091015260408051600180825281830190925260609181602001602082028036833701905050905082816000815181106124d257fe5b602002602001018181525050610a3485838361264a565b606060006060846001600160a01b03168460405161250791906138fb565b6000604051808303816000865af19150503d8060008114612544576040519150601f19603f3d011682016040523d82523d6000602084013e612549565b606091505b50915091506125588282612784565b95945050505050565b60601c90565b6060600083801561257457fe5b141561258a57612583826127ae565b9050612447565b6124476101366127eb565b60006125a5838311156001612638565b50900390565b90565b6001600160a01b03161590565b606060008380156125c857fe5b14156125d7576125838261283e565b6124476101506127eb565b60006001827fae1dc54057af8e8e5ce068cdd4383149c7efcb30e8fb95b592ee1594367fb50960405160200161261992919061393c565b60408051808303601f1901815291905280516020909101200392915050565b8161264657612646816127eb565b5050565b6060825167ffffffffffffffff8111801561266457600080fd5b5060405190808252806020026020018201604052801561269e57816020015b61268b612a58565b8152602001906001900390816126835790505b50905060005b8351811015612736576040805160a0810190915280600381526020018583815181106126cc57fe5b60200260200101516001600160a01b031681526020018483815181106126ee57fe5b60200260200101518152602001866001600160a01b03168152602001306001600160a01b031681525082828151811061272357fe5b60209081029190910101526001016126a4565b5061273f611548565b6001600160a01b0316630e8e3e84826040518263ffffffff1660e01b815260040161276a9190613bc0565b600060405180830381600087803b15801561228457600080fd5b60608215612793575080612447565b8151156127a35781518083602001fd5b6124476101ae6127eb565b606060006127bb83612887565b905060018160038111156127cb57fe5b14156127e2576127da8361289d565b915050612387565b82915050612387565b62461bcd60e51b6000908152602060045260076024526642414c23000030600a808404818106603090810160081b95839006959095019082900491820690940160101b939093010160c81b604452606490fd5b6060600061284b83612887565b9050600081600381111561285b57fe5b141561286a576127da8361294b565b600181600381111561287857fe5b14156127e2576127da836129ae565b6000818060200190518101906124479190613429565b60608060006128ab84612a01565b915091506000805b83518110156129115760008482815181106128ca57fe5b602002602001015190506128dd81612341565b15612908576128eb8161238c565b8583815181106128f757fe5b602002602001018181525050600192505b506001016128b3565b508061291d5784612558565b6001838360405160200161293393929190613cca565b60405160208183030381529060405295945050505050565b606060008061295984612a24565b9150915061296682612341565b156129a4576129748261238c565b91506000828260405160200161298c93929190613ca9565b60405160208183030381529060405292505050612387565b8392505050612387565b606060006129bb83612a3b565b90506129c681612341565b156127e2576129d48161238c565b90506001816040516020016129ea929190613c92565b604051602081830303815290604052915050612387565b6060600082806020019051810190612a1991906134a8565b909590945092505050565b60008082806020019051810190612a199190613472565b600081806020019051810190612a519190613445565b9392505050565b6040805160a081019091528060008152600060208201819052604082018190526060820181905260809091015290565b80356124478161400b565b60008083601f840112612aa4578182fd5b50813567ffffffffffffffff811115612abb578182fd5b6020830191508360208083028501011115612ad557600080fd5b9250929050565b600082601f830112612aec578081fd5b8135612aff612afa82613f9b565b613f74565b818152915060208083019084810181840286018201871015612b2057600080fd5b60005b84811015612b48578135612b368161400b565b84529282019290820190600101612b23565b505050505092915050565b600082601f830112612b63578081fd5b8135612b71612afa82613f9b565b818152915060208083019084810160005b84811015612b48578135870160a080601f19838c03011215612ba357600080fd5b612bac81613f74565b85830135815260408084013587830152606080850135828401526080915081850135818401525082840135925067ffffffffffffffff831115612bee57600080fd5b612bfc8c8885870101612d1e565b90820152865250509282019290820190600101612b82565b60008083601f840112612c25578182fd5b50813567ffffffffffffffff811115612c3c578182fd5b602083019150836020604083028501011115612ad557600080fd5b600082601f830112612c67578081fd5b8135612c75612afa82613f9b565b818152915060208083019084810181840286018201871015612c9657600080fd5b60005b84811015612b4857813584529282019290820190600101612c99565b600082601f830112612cc5578081fd5b8151612cd3612afa82613f9b565b818152915060208083019084810181840286018201871015612cf457600080fd5b60005b84811015612b4857815184529282019290820190600101612cf7565b803561244781614020565b600082601f830112612d2e578081fd5b813567ffffffffffffffff811115612d44578182fd5b612d576020601f19601f84011601613f74565b9150808252836020828501011115612d6e57600080fd5b8060208401602084013760009082016020015292915050565b80356001811061244757600080fd5b80356002811061244757600080fd5b600060808284031215612db6578081fd5b612dc06080613f74565b9050813567ffffffffffffffff80821115612dda57600080fd5b612de685838601612adc565b83526020840135915080821115612dfc57600080fd5b612e0885838601612c57565b60208401526040840135915080821115612e2157600080fd5b50612e2e84828501612d1e565b604083015250612e418360608401612d13565b606082015292915050565b600060808284031215612e5d578081fd5b50919050565b803560ff8116811461244757600080fd5b600060208284031215612e85578081fd5b8135612a518161400b565b600060208284031215612ea1578081fd5b8151612a518161400b565b60008060008060808587031215612ec1578283fd5b8435612ecc8161400b565b93506020850135612edc8161400b565b93969395505050506040820135916060013590565b60008060008060608587031215612f06578182fd5b8435612f118161400b565b93506020850135612f2181614020565b9250604085013567ffffffffffffffff80821115612f3d578384fd5b818701915087601f830112612f50578384fd5b813581811115612f5e578485fd5b886020828501011115612f6f578485fd5b95989497505060200194505050565b600080600060608486031215612f92578081fd5b8335612f9d8161400b565b95602085013595506040909401359392505050565b60006020808385031215612fc4578182fd5b825167ffffffffffffffff811115612fda578283fd5b8301601f81018513612fea578283fd5b8051612ff8612afa82613f9b565b8181528381019083850185840285018601891015613014578687fd5b8694505b83851015613036578051835260019490940193918501918501613018565b50979650505050505050565b600080600060408486031215613056578081fd5b833567ffffffffffffffff8082111561306d578283fd5b818601915086601f830112613080578283fd5b81358181111561308e578384fd5b87602060a0830285010111156130a2578384fd5b6020928301989097509590910135949350505050565b6000602082840312156130c9578081fd5b815167ffffffffffffffff8111156130df578182fd5b6130eb84828501612cb5565b949350505050565b600060208284031215613104578081fd5b8151612a5181614020565b600080600080600080600060c0888a031215613129578485fd5b8735965061313a8960208a01612d87565b9550604088013561314a8161400b565b9450606088013561315a8161400b565b9350608088013567ffffffffffffffff80821115613176578485fd5b6131828b838c01612da5565b945060a08a0135915080821115613197578384fd5b506131a48a828b01612c14565b989b979a50959850939692959293505050565b600080600080600080600060e0888a0312156131d1578081fd5b873596506131e28960208a01612d87565b955060408801356131f28161400b565b945060608801356132028161400b565b9350608088013567ffffffffffffffff81111561321d578182fd5b6132298a828b01612da5565b93505060a0880135915060c0880135905092959891949750929550565b600080600080600080600080610100898b031215613262578182fd5b883561326d8161400b565b9750602089013561327d8161400b565b96506040890135955060608901359450608089013561329b81614020565b93506132aa8a60a08b01612e63565b925060c0890135915060e089013590509295985092959890939650565b600080600080600080600060e0888a0312156132e1578081fd5b87356132ec8161400b565b965060208801356132fc8161400b565b955060408801359450606088013593506133198960808a01612e63565b925060a0880135915060c0880135905092959891949750929550565b60008060408385031215613347578182fd5b82356133528161400b565b946020939093013593505050565b600080600080600060a08688031215613377578283fd5b85356133828161400b565b945060208601356133928161400b565b935060408601356133a28161400b565b94979396509394606081013594506080013592915050565b60008060008060008060c087890312156133d2578384fd5b86356133dd8161400b565b955060208701356133ed8161400b565b945060408701356133fd8161400b565b935060608701359250608087013561341481614020565b8092505060a087013590509295509295509295565b60006020828403121561343a578081fd5b8151612a518161402e565b60008060408385031215613457578182fd5b82516134628161402e565b6020939093015192949293505050565b600080600060608486031215613486578081fd5b83516134918161402e565b602085015160409095015190969495509392505050565b6000806000606084860312156134bc578081fd5b83516134c78161402e565b602085015190935067ffffffffffffffff8111156134e3578182fd5b6134ef86828701612cb5565b925050604084015190509250925092565b60008060008060008060008060008060006101608c8e031215613521578485fd5b61352b8d8d612d96565b9a5067ffffffffffffffff8060208e01351115613546578586fd5b6135568e60208f01358f01612b53565b9a508060408e01351115613568578586fd5b6135788e60408f01358f01612a93565b909a50985061358a8e60608f01612e4c565b97508060e08e0135111561359c578586fd5b6135ac8e60e08f01358f01612a93565b90975095506101008d013594506101208d013593506101408d01358110156135d2578283fd5b506135e48d6101408e01358e01612c14565b81935080925050509295989b509295989b9093969950565b6000806000806000806101208789031215613615578384fd5b863567ffffffffffffffff8082111561362c578586fd5b9088019060c0828b03121561363f578586fd5b61364960c0613f74565b8235815261365a8b60208501612d96565b6020820152604083013561366d8161400b565b604082015261367f8b60608501612a88565b60608201526080830135608082015260a08301358281111561369f578788fd5b6136ab8c828601612d1e565b60a0830152508098505050506136c48860208901612e4c565b959895975050505060a08401359360c08101359360e08201359350610100909101359150565b6000602082840312156136fb578081fd5b5051919050565b60008060408385031215613714578182fd5b505080516020909101519092909150565b6001600160a01b03169052565b60008284526020808501945082825b8581101561376f5781356137548161400b565b6001600160a01b031687529582019590820190600101613741565b509495945050505050565b60008284526020808501945082825b8581101561376f57813587529582019590820190600101613789565b6000815180845260208085019450808401835b8381101561376f578151875295820195908201906001016137b8565b15159052565b600081518084526137f2816020860160208601613fc8565b601f01601f19169290920160200192915050565b8051608080845281519084018190526000916020919082019060a0860190845b8181101561384b5783516001600160a01b031683529284019291840191600101613826565b50508285015191508581038387015261386481836137a5565b925050506040830151848203604086015261387f82826137da565b915050606083015161389460608601826137d4565b509392505050565b80356138a78161400b565b6001600160a01b0390811683526020820135906138c382614020565b90151560208401526040820135906138da8261400b565b16604083015260608101356138ee81614020565b8015156060840152505050565b6000825161390d818460208701613fc8565b9190910192915050565b60008451613929818460208901613fc8565b8201838582379092019182525092915050565b918252602082015260400190565b6001600160a01b0391909116815260200190565b6001600160a01b039384168152919092166020820152901515604082015260600190565b6000604082016001600160a01b03808616845260206040818601528286518085526060870191508288019450855b818110156139ce5785518516835294830194918301916001016139b0565b509098975050505050505050565b6001600160a01b039889168152969097166020870152604086019490945260608501929092521515608084015260ff1660a083015260c082015260e08101919091526101000190565b6001600160a01b0397881681529590961660208601526040850193909352606084019190915260ff16608083015260a082015260c081019190915260e00190565b6001600160a01b03929092168252602082015260400190565b6001600160a01b0393909316835260208301919091521515604082015260600190565b6001600160a01b03949094168452602084019290925261ffff1660408301521515606082015260800190565b6020808252825182820181905260009190848201906040850190845b81811015613b0657835183529284019291840191600101613aea565b50909695505050505050565b6020808252818101839052600090604080840186845b87811015613bb3578135613b3b8161402e565b613b4481613ff4565b835281850135613b538161400b565b6001600160a01b03168386015281840135848401526060613b7681840184613fbb565b613b8282860182613725565b50506080613b9281840184613fbb565b613b9e82860182613725565b505060a0928301929190910190600101613b28565b5090979650505050505050565b602080825282518282018190526000919060409081850190868401855b82811015613c495781518051613bf281613ff4565b8552808701516001600160a01b0316878601528581015186860152606080820151613c1f82880182613725565b505060809081015190613c3486820183613725565b505060a0939093019290850190600101613bdd565b5091979650505050505050565b60008582526001600160a01b03808616602084015280851660408401525060806060830152613c886080830184613806565b9695505050505050565b60408101613c9f84613ff4565b9281526020015290565b60608101613cb685613ff4565b938152602081019290925260409091015290565b6000613cd585613ff4565b84825260606020830152613cec60608301856137a5565b9050826040830152949350505050565b6000610120808301613d0d8c614001565b8b84526020808501929092528a5190819052610140808501928281028601909101918c8201855b82811015613db4578785037ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec00186528151805186528481015185870152604080820151908701526060808201519087015260809081015160a091870182905290613da0818801836137da565b978601979650505090830190600101613d34565b505050508381036040850152613dcb818a8c613732565b915050613ddb606084018861389c565b82810360e0840152613dee81868861377a565b915050826101008301529998505050505050505050565b60208082526010908201527f496e636f72726563742073656e64657200000000000000000000000000000000604082015260600190565b6020808252601f908201527f52656c617965722063616e206f6e6c7920617070726f766520697473656c6600604082015260600190565b60208082526019908201527f696e76616c696420636861696e6564207265666572656e636500000000000000604082015260600190565b600060e08252855160e08301526020860151613ec581614001565b61010083015260408601516001600160a01b03908116610120840152606087015116610140830152608086015161016083015260a086015160c0610180840152613f136101a08401826137da565b915050613f23602083018661389c565b60a082019390935260c0015292915050565b90815260200190565b9182526001600160a01b0316602082015260400190565b9283526001600160a01b03918216602084015216604082015260600190565b60405181810167ffffffffffffffff81118282101715613f9357600080fd5b604052919050565b600067ffffffffffffffff821115613fb1578081fd5b5060209081020190565b60008235612a518161400b565b60005b83811015613fe3578181015183820152602001613fcb565b8381111561052b5750506000910152565b60048110613ffe57fe5b50565b60028110613ffe57fe5b6001600160a01b0381168114613ffe57600080fd5b8015158114613ffe57600080fd5b60048110613ffe57600080fdfea264697066735822122025243bbdfb65ba86b5f803d93a3a51b76dfd9a870b570145fb0333e20f93cf5f64736f6c63430007010033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
000000000000000000000000ba12222222228d8ba445958a75a0704d566bf2c80000000000000000000000006320cd32aa674d2898a68ec82e869385fc5f7e2f
-----Decoded View---------------
Arg [0] : vault (address): 0xBA12222222228d8Ba445958a75a0704d566BF2C8
Arg [1] : wstETH (address): 0x6320cD32aA674d2898A68ec82e869385Fc5f7E2f
-----Encoded View---------------
2 Constructor Arguments found :
Arg [0] : 000000000000000000000000ba12222222228d8ba445958a75a0704d566bf2c8
Arg [1] : 0000000000000000000000006320cd32aa674d2898a68ec82e869385fc5f7e2f
Loading...
Loading
[ Download: CSV Export ]
[ Download: CSV Export ]
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.