Contract Overview
My Name Tag:
Not Available, login to update
Txn Hash | Method |
Block
|
From
|
To
|
Value | [Txn Fee] | |||
---|---|---|---|---|---|---|---|---|---|
0xd53b992f79aec8337d20090708ae35549a809952e63a0842e3ad6ba681d96176 | 0x60c06040 | 19128419 | 288 days 2 hrs ago | 0x3a893a7525c4263052c3c04f9c32d919c75cb8e0 | IN | Create: BalancerHandler | 0 MATIC | 0.01172612 |
[ Download CSV Export ]
Contract Name:
BalancerHandler
Compiler Version
v0.7.4+commit.3f05b770
Optimization Enabled:
Yes with 200 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: agpl-3.0 pragma solidity 0.7.4; pragma experimental ABIEncoderV2; import "@openzeppelin/contracts/math/SafeMath.sol"; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts/token/ERC20/SafeERC20.sol"; import "../interfaces/IHandler.sol"; import "../libraries/PercentageMath.sol"; enum SwapKind { GIVEN_IN, GIVEN_OUT } struct BatchSwapStep { bytes32 poolId; uint256 assetInIndex; uint256 assetOutIndex; uint256 amount; bytes userData; } struct FundManagement { address sender; bool fromInternalBalance; address payable recipient; bool toInternalBalance; } struct Order { address recipient; address inputToken; address outputToken; uint256 inputAmount; uint256 minReturnAmount; uint256 stoplossAmount; uint256 shares; } /// @notice Balancer Handler used to execute an order contract BalancerHandler is IHandler { using SafeMath for uint256; using SafeERC20 for IERC20; using PercentageMath for uint256; IVault public immutable vault; address public immutable symphony; /** * @notice Creates the handler */ constructor(IVault _vault, address _symphony) { vault = _vault; symphony = _symphony; } modifier onlySymphony() { require( msg.sender == symphony, "BalancerHandler: Only symphony contract can invoke this function" ); _; } /// @notice receive MATIC receive() external payable override {} /** * @notice Handle an order execution */ function handle( IOrderStructs.Order memory order, uint256 oracleAmount, uint256 feePercent, uint256 protcolFeePercent, address executor, address treasury, bytes calldata handlerdata ) external override onlySymphony { IERC20(order.inputToken).safeApprove(address(vault), order.inputAmount); // Swap Tokens uint256 returnAmount = _swap(handlerdata); require( IERC20(order.outputToken).balanceOf(address(this)) >= returnAmount, "BalancerHandler: Incorrect output token recieved !!" ); require( returnAmount >= order.minReturnAmount || returnAmount <= order.stoplossAmount, "BalancerHandler: Order condition doesn't satisfy !!" ); require( returnAmount >= oracleAmount, "BalancerHandler: Oracle amount doesn't match with return amount !!" ); _transferTokens( order.outputToken, returnAmount, // Output amount received order.recipient, executor, treasury, feePercent, protcolFeePercent ); } function simulate( address _inputToken, address _outputToken, uint256 _inputAmount, uint256 _minReturnAmount, uint256 _stoplossAmount, uint256 _oracleAmount, bytes calldata ) external view override returns (bool success, uint256 bought) {} /** * @notice Swap input token to output token */ function _swap(bytes calldata _data) internal returns (uint256 bought) { ( IAsset[] memory assets, BatchSwapStep[] memory swapSteps ) = _decodeData(_data); FundManagement memory funds = FundManagement( address(this), false, address(this), false ); bought = _multiSwap(assets, swapSteps, funds); } function _multiSwap( IAsset[] memory assets, BatchSwapStep[] memory swapSteps, FundManagement memory funds ) internal returns (uint256 bought) { int256[] memory limits = new int256[](assets.length); for (uint256 i = 0; i < limits.length; i++) { limits[i] = type(int256).max; } int256[] memory assetDeltas = IVault(vault).batchSwap( SwapKind.GIVEN_IN, swapSteps, assets, funds, limits, block.timestamp.add(1800) ); bought = uint256(-assetDeltas[assetDeltas.length - 1]); } function _transferTokens( address token, uint256 amount, address recipient, address executor, address treasury, uint256 feePercent, uint256 protcolFeePercent ) internal { uint256 protocolFee; uint256 totalFee = amount.percentMul(feePercent); IERC20(token).safeTransfer(recipient, amount.sub(totalFee)); if (treasury != address(0)) { protocolFee = totalFee.percentMul(protcolFeePercent); IERC20(token).safeTransfer(treasury, protocolFee); } IERC20(token).safeTransfer(executor, totalFee.sub(protocolFee)); } function _decodeData(bytes memory _data) internal view returns (IAsset[] memory assets, BatchSwapStep[] memory swapSteps) { (assets, swapSteps) = abi.decode(_data, (IAsset[], BatchSwapStep[])); } } interface IAsset { // solhint-disable-previous-line no-empty-blocks } interface IVault { function batchSwap( SwapKind kind, BatchSwapStep[] memory swaps, IAsset[] memory assets, FundManagement memory funds, int256[] memory limits, uint256 deadline ) external returns (int256[] memory assetDeltas); }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) { uint256 c = a + b; if (c < a) return (false, 0); return (true, c); } /** * @dev Returns the substraction of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) { if (b > a) return (false, 0); return (true, a - b); } /** * @dev Returns the multiplication of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) return (true, 0); uint256 c = a * b; if (c / a != b) return (false, 0); return (true, c); } /** * @dev Returns the division of two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) { if (b == 0) return (false, 0); return (true, a / b); } /** * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) { if (b == 0) return (false, 0); return (true, a % b); } /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { require(b <= a, "SafeMath: subtraction overflow"); return a - b; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) return 0; uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers, reverting on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0, "SafeMath: division by zero"); return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0, "SafeMath: modulo by zero"); return a % b; } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {trySub}. * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); return a - b; } /** * @dev Returns the integer division of two unsigned integers, reverting with custom message on * division by zero. The result is rounded towards zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryDiv}. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting with custom message when dividing by zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryMod}. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); return a % b; } }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.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: MIT pragma solidity >=0.6.0 <0.8.0; import "./IERC20.sol"; import "../../math/SafeMath.sol"; import "../../utils/Address.sol"; /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20 { using SafeMath for uint256; using Address for address; function safeTransfer(IERC20 token, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } /** * @dev Deprecated. This function has issues similar to the ones found in * {IERC20-approve}, and its usage is discouraged. * * Whenever possible, use {safeIncreaseAllowance} and * {safeDecreaseAllowance} instead. */ function safeApprove(IERC20 token, address spender, uint256 value) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' // solhint-disable-next-line max-line-length require((value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 newAllowance = token.allowance(address(this), spender).add(value); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 newAllowance = token.allowance(address(this), spender).sub(value, "SafeERC20: decreased allowance below zero"); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function _callOptionalReturn(IERC20 token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional // solhint-disable-next-line max-line-length require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } }
// SPDX-License-Identifier: agpl-3.0 pragma solidity 0.7.4; pragma experimental ABIEncoderV2; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "./IOrderStructs.sol"; interface IHandler { /// @notice receive ETH receive() external payable; /** * @notice Handle an order execution * @param _order - Order structure * @param _oracleAmount - Current out amount from oracle * @param _feePercent - uint256 total execution fee percent * @param _protocolFeePercent - uint256 protocol fee percent * @param _executor - Address of the order executor * @param _treasury - Address of the protocol treasury * @param _data - Bytes of arbitrary data */ function handle( IOrderStructs.Order memory _order, uint256 _oracleAmount, uint256 _feePercent, uint256 _protocolFeePercent, address _executor, address _treasury, bytes calldata _data ) external; /** * @notice Simulate an order execution * @param _inputToken - Address of the input token * @param _outputToken - Address of the output token * @param _inputAmount - uint256 of the input token amount * @param _minReturnAmount - uint256 minimum return output token * @param _stoplossAmount - uint256 stoploss amount * @param _oracleAmount - Current out amount from oracle * @param _data - Bytes of arbitrary data * @return success - Whether the execution can be handled or not * @return amountOut - Amount of output token bought */ function simulate( address _inputToken, address _outputToken, uint256 _inputAmount, uint256 _minReturnAmount, uint256 _stoplossAmount, uint256 _oracleAmount, bytes calldata _data ) external view returns (bool success, uint256 amountOut); }
// SPDX-License-Identifier: agpl-3.0 pragma solidity 0.7.4; /** * @title PercentageMath library * @author Aave * @notice Provides functions to perform percentage calculations * @dev Percentages are defined by default with 2 decimals of precision (100.00). The precision is indicated by PERCENTAGE_FACTOR * @dev Operations are rounded half up **/ library PercentageMath { uint256 constant PERCENTAGE_FACTOR = 1e4; //percentage plus two decimals uint256 constant HALF_PERCENT = PERCENTAGE_FACTOR / 2; /** * @dev Executes a percentage multiplication * @param value The value of which the percentage needs to be calculated * @param percentage The percentage of the value to be calculated * @return The percentage of value **/ function percentMul(uint256 value, uint256 percentage) internal pure returns (uint256) { if (value == 0 || percentage == 0) { return 0; } require( value <= (type(uint256).max - HALF_PERCENT) / percentage, "PercentageMath: MATH_MULTIPLICATION_OVERFLOW" ); return (value * percentage + HALF_PERCENT) / PERCENTAGE_FACTOR; } /** * @dev Executes a percentage division * @param value The value of which the percentage needs to be calculated * @param percentage The percentage of the value to be calculated * @return The value divided the percentage **/ function percentDiv(uint256 value, uint256 percentage) internal pure returns (uint256) { require(percentage != 0, "PercentageMath: MATH_DIVISION_BY_ZERO"); uint256 halfPercentage = percentage / 2; require( value <= (type(uint256).max - halfPercentage) / PERCENTAGE_FACTOR, "PercentageMath: MATH_MULTIPLICATION_OVERFLOW" ); return (value * PERCENTAGE_FACTOR + halfPercentage) / percentage; } }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.2 <0.8.0; /** * @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, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @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: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: value }(data); return _verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.staticcall(data); return _verifyCallResult(success, returndata, errorMessage); } /** * @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) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.delegatecall(data); return _verifyCallResult(success, returndata, errorMessage); } function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private 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(errorMessage); } } } }
// SPDX-License-Identifier: agpl-3.0 pragma solidity 0.7.4; pragma experimental ABIEncoderV2; interface IOrderStructs { // This is not really an interface - it just defines common structs. struct Order { address recipient; address inputToken; address outputToken; uint256 inputAmount; uint256 minReturnAmount; uint256 stoplossAmount; uint256 shares; } }
{ "optimizer": { "enabled": true, "runs": 200 }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "abi" ] } }, "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[{"internalType":"contract IVault","name":"_vault","type":"address"},{"internalType":"address","name":"_symphony","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"components":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"address","name":"inputToken","type":"address"},{"internalType":"address","name":"outputToken","type":"address"},{"internalType":"uint256","name":"inputAmount","type":"uint256"},{"internalType":"uint256","name":"minReturnAmount","type":"uint256"},{"internalType":"uint256","name":"stoplossAmount","type":"uint256"},{"internalType":"uint256","name":"shares","type":"uint256"}],"internalType":"struct IOrderStructs.Order","name":"order","type":"tuple"},{"internalType":"uint256","name":"oracleAmount","type":"uint256"},{"internalType":"uint256","name":"feePercent","type":"uint256"},{"internalType":"uint256","name":"protcolFeePercent","type":"uint256"},{"internalType":"address","name":"executor","type":"address"},{"internalType":"address","name":"treasury","type":"address"},{"internalType":"bytes","name":"handlerdata","type":"bytes"}],"name":"handle","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_inputToken","type":"address"},{"internalType":"address","name":"_outputToken","type":"address"},{"internalType":"uint256","name":"_inputAmount","type":"uint256"},{"internalType":"uint256","name":"_minReturnAmount","type":"uint256"},{"internalType":"uint256","name":"_stoplossAmount","type":"uint256"},{"internalType":"uint256","name":"_oracleAmount","type":"uint256"},{"internalType":"bytes","name":"","type":"bytes"}],"name":"simulate","outputs":[{"internalType":"bool","name":"success","type":"bool"},{"internalType":"uint256","name":"bought","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"symphony","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"vault","outputs":[{"internalType":"contract IVault","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"stateMutability":"payable","type":"receive"}]
Contract Creation Code
60c060405234801561001057600080fd5b5060405161150a38038061150a83398101604081905261002f9161004d565b6001600160601b0319606092831b8116608052911b1660a05261009e565b6000806040838503121561005f578182fd5b825161006a81610086565b602084015190925061007b81610086565b809150509250929050565b6001600160a01b038116811461009b57600080fd5b50565b60805160601c60a05160601c6114356100d56000398060fa52806102aa52508061014552806102ce528061065752506114356000f3fe6080604052600436106100435760003560e01c80632d0cd5561461004f57806381c0b22914610086578063a0956fca146100a8578063fbfa77cf146100ca5761004a565b3661004a57005b600080fd5b34801561005b57600080fd5b5061006f61006a366004610c95565b6100df565b60405161007d929190611044565b60405180910390f35b34801561009257600080fd5b506100a66100a1366004610e75565b6100ef565b005b3480156100b457600080fd5b506100bd6102a8565b60405161007d9190611030565b3480156100d657600080fd5b506100bd6102cc565b6000809850989650505050505050565b336001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016146101405760405162461bcd60e51b815260040161013790611212565b60405180910390fd5b6101867f000000000000000000000000000000000000000000000000000000000000000089606001518a602001516001600160a01b03166102f09092919063ffffffff16565b60006101928383610408565b90508089604001516001600160a01b03166370a08231306040518263ffffffff1660e01b81526004016101c59190611030565b60206040518083038186803b1580156101dd57600080fd5b505afa1580156101f1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102159190610f71565b10156102335760405162461bcd60e51b815260040161013790611157565b88608001518110158061024a57508860a001518111155b6102665760405162461bcd60e51b815260040161013790611270565b878110156102865760405162461bcd60e51b8152600401610137906111aa565b61029d8960400151828b6000015188888c8c610491565b505050505050505050565b7f000000000000000000000000000000000000000000000000000000000000000081565b7f000000000000000000000000000000000000000000000000000000000000000081565b801580610376575060408051636eb1769f60e11b81523060048201526001600160a01b03848116602483015291519185169163dd62ed3e91604480820192602092909190829003018186803b15801561034857600080fd5b505afa15801561035c573d6000803e3d6000fd5b505050506040513d602081101561037257600080fd5b5051155b6103b15760405162461bcd60e51b81526004018080602001828103825260368152602001806113ca6036913960400191505060405180910390fd5b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663095ea7b360e01b1790526104039084906104fc565b505050565b600060608061044c85858080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152506105ad92505050565b91509150610458610ad1565b5060408051608081018252308082526000602083018190529282015260608101919091526104878383836105ce565b9695505050505050565b60008061049e888561072d565b90506104bf876104ae8a846107a5565b6001600160a01b038c169190610802565b6001600160a01b038516156104ee576104d8818461072d565b91506104ee6001600160a01b038a168684610802565b61029d866104ae83856107a5565b6060610551826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166108549092919063ffffffff16565b8051909150156104035780806020019051602081101561057057600080fd5b50516104035760405162461bcd60e51b815260040180806020018281038252602a8152602001806113a0602a913960400191505060405180910390fd5b606080828060200190518101906105c49190610d22565b9094909350915050565b60006060845167ffffffffffffffff811180156105ea57600080fd5b50604051908082528060200260200182016040528015610614578160200160208202803683370190505b50905060005b815181101561064a576001600160ff1b0382828151811061063757fe5b602090810291909101015260010161061a565b5060606001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001663945bcec960008789888761068e4261070861086d565b6040518763ffffffff1660e01b81526004016106af96959493929190611054565b600060405180830381600087803b1580156106c957600080fd5b505af11580156106dd573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526107059190810190610de5565b90508060018251038151811061071757fe5b6020026020010151600003925050509392505050565b600082158061073a575081155b156107475750600061079f565b81611388198161075357fe5b048311156107925760405162461bcd60e51b815260040180806020018281038252602c81526020018061134e602c913960400191505060405180910390fd5b5061271061138882840201045b92915050565b6000828211156107fc576040805162461bcd60e51b815260206004820152601e60248201527f536166654d6174683a207375627472616374696f6e206f766572666c6f770000604482015290519081900360640190fd5b50900390565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b1790526104039084906104fc565b606061086384846000856108c7565b90505b9392505050565b600082820183811015610866576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b6060824710156109085760405162461bcd60e51b815260040180806020018281038252602681526020018061137a6026913960400191505060405180910390fd5b61091185610a23565b610962576040805162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015290519081900360640190fd5b60006060866001600160a01b031685876040518082805190602001908083835b602083106109a15780518252601f199092019160209182019101610982565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d8060008114610a03576040519150601f19603f3d011682016040523d82523d6000602084013e610a08565b606091505b5091509150610a18828286610a2d565b979650505050505050565b803b15155b919050565b60608315610a3c575081610866565b825115610a4c5782518084602001fd5b8160405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b83811015610a96578181015183820152602001610a7e565b50505050905090810190601f168015610ac35780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b60408051608081018252600080825260208201819052918101829052606081019190915290565b8035610a2881611335565b600082601f830112610b13578081fd5b8151610b26610b21826112e7565b6112c3565b818152915060208083019084810160005b84811015610bdd578151870160a080601f19838c03011215610b5857600080fd5b6040805182810167ffffffffffffffff8282108183111715610b7657fe5b818452888601518352838601518984015260609150818601518484015260809350838601518284015284860151945080851115610bb257600080fd5b5050610bc28c8885870101610c2f565b91810191909152865250509282019290820190600101610b37565b505050505092915050565b60008083601f840112610bf9578182fd5b50813567ffffffffffffffff811115610c10578182fd5b602083019150836020828501011115610c2857600080fd5b9250929050565b600082601f830112610c3f578081fd5b815167ffffffffffffffff811115610c5357fe5b610c66601f8201601f19166020016112c3565b9150808252836020828501011115610c7d57600080fd5b610c8e816020840160208601611305565b5092915050565b60008060008060008060008060e0898b031215610cb0578384fd5b8835610cbb81611335565b97506020890135610ccb81611335565b965060408901359550606089013594506080890135935060a0890135925060c089013567ffffffffffffffff811115610d02578283fd5b610d0e8b828c01610be8565b999c989b5096995094979396929594505050565b60008060408385031215610d34578182fd5b825167ffffffffffffffff80821115610d4b578384fd5b818501915085601f830112610d5e578384fd5b8151610d6c610b21826112e7565b80828252602080830192508086018a828387028901011115610d8c578889fd5b8896505b84871015610db7578051610da381611335565b845260019690960195928101928101610d90565b508801519096509350505080821115610dce578283fd5b50610ddb85828601610b03565b9150509250929050565b60006020808385031215610df7578182fd5b825167ffffffffffffffff811115610e0d578283fd5b8301601f81018513610e1d578283fd5b8051610e2b610b21826112e7565b8181528381019083850185840285018601891015610e47578687fd5b8694505b83851015610e69578051835260019490940193918501918501610e4b565b50979650505050505050565b600080600080600080600080888a036101a0811215610e92578485fd5b60e0811215610e9f578485fd5b5060405160e0810167ffffffffffffffff8282108183111715610ebe57fe5b81604052610ecb8c610af8565b8352610ed960208d01610af8565b6020840152610eea60408d01610af8565b604084015260608c0135606084015260808c0135608084015260a08c013560a084015260c08c013560c0840152829a5060e08c013599506101008c013598506101208c01359750610f3e6101408d01610af8565b9650610f4d6101608d01610af8565b95506101808c0135925080831115610f63578485fd5b5050610d0e8b828c01610be8565b600060208284031215610f82578081fd5b5051919050565b6000815180845260208085019450808401835b83811015610fc15781516001600160a01b031687529582019590820190600101610f9c565b509495945050505050565b6000815180845260208085019450808401835b83811015610fc157815187529582019590820190600101610fdf565b80516001600160a01b039081168352602080830151151590840152604080830151909116908301526060908101511515910152565b6001600160a01b0391909116815260200190565b9115158252602082015260400190565b600061012080830160028a1061106657fe5b898452602080850192909252885190819052610140808501928281028601909101918a8201855b8281101561110a5787850361013f190186528151805186528481015185870152604080820151908701526060808201519087015260809081015160a091870182905280519187018290529060c0906110ea81838a01858a01611305565b97860197601f01601f19169690960190950194509083019060010161108d565b5050505083810360408501526111208189610f89565b9150506111306060840187610ffb565b82810360e08401526111428186610fcc565b91505082610100830152979650505050505050565b60208082526033908201527f42616c616e63657248616e646c65723a20496e636f7272656374206f757470756040820152727420746f6b656e20726563696576656420212160681b606082015260800190565b60208082526042908201527f42616c616e63657248616e646c65723a204f7261636c6520616d6f756e74206460408201527f6f65736e2774206d6174636820776974682072657475726e20616d6f756e7420606082015261212160f01b608082015260a00190565b602080825260409082018190527f42616c616e63657248616e646c65723a204f6e6c792073796d70686f6e792063908201527f6f6e74726163742063616e20696e766f6b6520746869732066756e6374696f6e606082015260800190565b60208082526033908201527f42616c616e63657248616e646c65723a204f7264657220636f6e646974696f6e60408201527220646f65736e2774207361746973667920212160681b606082015260800190565b60405181810167ffffffffffffffff811182821017156112df57fe5b604052919050565b600067ffffffffffffffff8211156112fb57fe5b5060209081020190565b60005b83811015611320578181015183820152602001611308565b8381111561132f576000848401525b50505050565b6001600160a01b038116811461134a57600080fd5b5056fe50657263656e746167654d6174683a204d4154485f4d554c5449504c49434154494f4e5f4f564552464c4f57416464726573733a20696e73756666696369656e742062616c616e636520666f722063616c6c5361666545524332303a204552433230206f7065726174696f6e20646964206e6f7420737563636565645361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f20746f206e6f6e2d7a65726f20616c6c6f77616e6365a2646970667358221220a926eaafc74f40016eb70c8dc0c26f78017e9014a25047bc242e50e5fdedf44664736f6c63430007040033000000000000000000000000ba12222222228d8ba445958a75a0704d566bf2c8000000000000000000000000a9938c13f2c446c7decd9d9ebee6db8100ca4157
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
000000000000000000000000ba12222222228d8ba445958a75a0704d566bf2c8000000000000000000000000a9938c13f2c446c7decd9d9ebee6db8100ca4157
-----Decoded View---------------
Arg [0] : _vault (address): 0xba12222222228d8ba445958a75a0704d566bf2c8
Arg [1] : _symphony (address): 0xa9938c13f2c446c7decd9d9ebee6db8100ca4157
-----Encoded View---------------
2 Constructor Arguments found :
Arg [0] : 000000000000000000000000ba12222222228d8ba445958a75a0704d566bf2c8
Arg [1] : 000000000000000000000000a9938c13f2c446c7decd9d9ebee6db8100ca4157
Age | Block | Fee Address | BC Fee Address | Voting Power | Jailed | Incoming |
---|
Make sure to use the "Vote Down" button for any spammy posts, and the "Vote Up" for interesting conversations.