ETH Price: $3,396.34 (-1.07%)

Contract

0x66C1c25d7D2bd4A32Ed33501E202B275030f402C
 

Overview

ETH Balance

0 ETH

Eth Value

$0.00

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To
0x61014060174714562023-06-13 13:45:59532 days ago1686663959IN
 Create: SimpleSwap
0 ETH0.0641038725

View more zero value Internal Transactions in Advanced View mode

Advanced mode:
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
SimpleSwap

Compiler Version
v0.7.5+commit.eb77ed08

Optimization Enabled:
Yes with 1000000 runs

Other Settings:
default evmVersion
File 1 of 13 : SimpleSwap.sol
// SPDX-License-Identifier: ISC

pragma solidity 0.7.5;
pragma abicoder v2;

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "../lib/Utils.sol";
import "./IRouter.sol";
import "../lib/weth/IWETH.sol";
import "../fee/FeeModel.sol";
import "../fee/IFeeClaimer.sol";

contract SimpleSwap is FeeModel, IRouter {
    using SafeMath for uint256;
    address public immutable augustusRFQ;

    /*solhint-disable no-empty-blocks*/
    constructor(
        uint256 _partnerSharePercent,
        uint256 _maxFeePercent,
        uint256 _paraswapReferralShare,
        uint256 _paraswapSlippageShare,
        IFeeClaimer _feeClaimer,
        address _augustusRFQ
    )
        public
        FeeModel(_partnerSharePercent, _maxFeePercent, _paraswapReferralShare, _paraswapSlippageShare, _feeClaimer)
    {
        augustusRFQ = _augustusRFQ;
    }

    /*solhint-enable no-empty-blocks*/

    function initialize(bytes calldata) external override {
        revert("METHOD NOT IMPLEMENTED");
    }

    function getKey() external pure override returns (bytes32) {
        return keccak256(abi.encodePacked("SIMPLE_SWAP_ROUTER", "1.0.0"));
    }

    function simpleSwap(Utils.SimpleData memory data) public payable returns (uint256 receivedAmount) {
        require(data.deadline >= block.timestamp, "Deadline breached");
        address payable beneficiary = data.beneficiary == address(0) ? msg.sender : data.beneficiary;
        receivedAmount = performSimpleSwap(
            data.callees,
            data.exchangeData,
            data.startIndexes,
            data.values,
            data.fromToken,
            data.toToken,
            data.fromAmount,
            data.toAmount,
            data.expectedAmount,
            data.partner,
            data.feePercent,
            data.permit,
            beneficiary
        );

        emit SwappedV3(
            data.uuid,
            data.partner,
            data.feePercent,
            msg.sender,
            beneficiary,
            data.fromToken,
            data.toToken,
            data.fromAmount,
            receivedAmount,
            data.expectedAmount
        );

        return receivedAmount;
    }

    function simpleBuy(Utils.SimpleData calldata data) external payable {
        require(data.deadline >= block.timestamp, "Deadline breached");
        address payable beneficiary = data.beneficiary == address(0) ? msg.sender : data.beneficiary;
        (uint256 receivedAmount, uint256 remainingAmount) = performSimpleBuy(
            data.callees,
            data.exchangeData,
            data.startIndexes,
            data.values,
            data.fromToken,
            data.toToken,
            data.fromAmount,
            data.toAmount,
            data.expectedAmount,
            data.partner,
            data.feePercent,
            data.permit,
            beneficiary
        );

        emit BoughtV3(
            data.uuid,
            data.partner,
            data.feePercent,
            msg.sender,
            beneficiary,
            data.fromToken,
            data.toToken,
            data.fromAmount.sub(remainingAmount),
            receivedAmount,
            data.expectedAmount
        );
    }

    function performSimpleSwap(
        address[] memory callees,
        bytes memory exchangeData,
        uint256[] memory startIndexes,
        uint256[] memory values,
        address fromToken,
        address toToken,
        uint256 fromAmount,
        uint256 toAmount,
        uint256 expectedAmount,
        address payable partner,
        uint256 feePercent,
        bytes memory permit,
        address payable beneficiary
    ) private returns (uint256 receivedAmount) {
        require(msg.value == (fromToken == Utils.ethAddress() ? fromAmount : 0), "Incorrect msg.value");
        require(toAmount > 0, "toAmount is too low");
        require(callees.length + 1 == startIndexes.length, "Start indexes must be 1 greater then number of callees");
        require(callees.length == values.length, "callees and values must have same length");

        //If source token is not ETH than transfer required amount of tokens
        //from sender to this contract
        transferTokensFromProxy(fromToken, fromAmount, permit);

        performCalls(callees, exchangeData, startIndexes, values);

        receivedAmount = Utils.tokenBalance(toToken, address(this));

        require(receivedAmount >= toAmount, "Received amount of tokens are less then expected");

        if (
            _getFixedFeeBps(partner, feePercent) != 0 && !_isTakeFeeFromSrcToken(feePercent) && !_isReferral(feePercent)
        ) {
            // take fee from dest token
            takeToTokenFeeAndTransfer(toToken, receivedAmount, beneficiary, partner, feePercent);
        } else if (receivedAmount > expectedAmount && !_isTakeFeeFromSrcToken(feePercent)) {
            takeSlippageAndTransferSell(toToken, beneficiary, partner, receivedAmount, expectedAmount, feePercent);
        } else {
            // Transfer toToken to beneficiary
            Utils.transferTokens(toToken, beneficiary, receivedAmount);

            if (_getFixedFeeBps(partner, feePercent) != 0 && _isTakeFeeFromSrcToken(feePercent)) {
                // take fee from source token
                takeFromTokenFee(fromToken, fromAmount, partner, feePercent);
            }
        }

        return receivedAmount;
    }

    function performSimpleBuy(
        address[] memory callees,
        bytes memory exchangeData,
        uint256[] memory startIndexes,
        uint256[] memory values,
        address fromToken,
        address toToken,
        uint256 fromAmount,
        uint256 toAmount,
        uint256 expectedAmount,
        address payable partner,
        uint256 feePercent,
        bytes memory permit,
        address payable beneficiary
    ) private returns (uint256 receivedAmount, uint256 remainingAmount) {
        require(msg.value == (fromToken == Utils.ethAddress() ? fromAmount : 0), "Incorrect msg.value");
        require(toAmount > 0, "toAmount is too low");
        require(callees.length + 1 == startIndexes.length, "Start indexes must be 1 greater then number of callees");
        require(callees.length == values.length, "callees and values must have same length");

        //If source token is not ETH than transfer required amount of tokens
        //from sender to this contract
        transferTokensFromProxy(fromToken, fromAmount, permit);

        performCalls(callees, exchangeData, startIndexes, values);

        receivedAmount = Utils.tokenBalance(toToken, address(this));

        require(receivedAmount >= toAmount, "Received amount of tokens are less then expected");

        remainingAmount = Utils.tokenBalance(fromToken, address(this));
        uint256 amountIn = fromAmount.sub(remainingAmount);

        if (
            _getFixedFeeBps(partner, feePercent) != 0 && !_isTakeFeeFromSrcToken(feePercent) && !_isReferral(feePercent)
        ) {
            // take fee from dest token
            takeToTokenFeeAndTransfer(toToken, receivedAmount, beneficiary, partner, feePercent);

            // Transfer remaining token back to sender
            Utils.transferTokens(fromToken, msg.sender, remainingAmount);
        } else {
            Utils.transferTokens(toToken, beneficiary, receivedAmount);
            if (_getFixedFeeBps(partner, feePercent) != 0 && _isTakeFeeFromSrcToken(feePercent)) {
                //  take fee from source token and transfer remaining token back to sender
                takeFromTokenFeeAndTransfer(fromToken, amountIn, remainingAmount, partner, feePercent);
            } else if (amountIn < expectedAmount) {
                takeSlippageAndTransferBuy(fromToken, partner, expectedAmount, amountIn, remainingAmount, feePercent);
            } else {
                // Transfer remaining token back to sender
                Utils.transferTokens(fromToken, msg.sender, remainingAmount);
            }
        }

        return (receivedAmount, remainingAmount);
    }

    function transferTokensFromProxy(
        address token,
        uint256 amount,
        bytes memory permit
    ) private {
        if (token != Utils.ethAddress()) {
            Utils.permit(token, permit);
            tokenTransferProxy.transferFrom(token, msg.sender, address(this), amount);
        }
    }

    function performCalls(
        address[] memory callees,
        bytes memory exchangeData,
        uint256[] memory startIndexes,
        uint256[] memory values
    ) private {
        for (uint256 i = 0; i < callees.length; i++) {
            require(callees[i] != address(tokenTransferProxy), "Can not call TokenTransferProxy Contract");

            if (callees[i] == augustusRFQ) {
                verifyAugustusRFQParams(startIndexes[i], exchangeData);
            } else {
                uint256 dataOffset = startIndexes[i];
                bytes32 selector;
                assembly {
                    selector := mload(add(exchangeData, add(dataOffset, 32)))
                }
                require(bytes4(selector) != IERC20.transferFrom.selector, "transferFrom not allowed for externalCall");
            }

            bool result = externalCall(
                callees[i], //destination
                values[i], //value to send
                startIndexes[i], // start index of call data
                startIndexes[i + 1].sub(startIndexes[i]), // length of calldata
                exchangeData // total calldata
            );
            require(result, "External call failed");
        }
    }

    function verifyAugustusRFQParams(uint256 startIndex, bytes memory exchangeData) private view {
        // Load the 4 byte function signature in the lower 32 bits
        // Also load the memory address of the calldata params which follow
        uint256 sig;
        uint256 paramsStart;
        assembly {
            let tmp := add(exchangeData, startIndex)
            // Note that all bytes variables start with 32 bytes length field
            sig := shr(224, mload(add(tmp, 32)))
            paramsStart := add(tmp, 36)
        }
        if (
            sig == 0x98f9b46b || // fillOrder
            sig == 0xbbbc2372 || // fillOrderNFT
            sig == 0x00154008 || // fillOrderWithTarget
            sig == 0x3c3694ab || // fillOrderWithTargetNFT
            sig == 0xc88ae6dc || // partialFillOrder
            sig == 0xb28ace5f || // partialFillOrderNFT
            sig == 0x24abf828 || // partialFillOrderWithTarget
            sig == 0x30201ad3 || // partialFillOrderWithTargetNFT
            sig == 0xda6b84af || // partialFillOrderWithTargetPermit
            sig == 0xf6c1b371 // partialFillOrderWithTargetPermitNFT
        ) {
            // First parameter is fixed size (encoded in place) order struct
            // with nonceAndMeta being the first field, therefore:
            // nonceAndMeta is the first 32 bytes of the ABI encoding
            uint256 nonceAndMeta;
            assembly {
                nonceAndMeta := mload(paramsStart)
            }
            address userAddress = address(uint160(nonceAndMeta));
            require(userAddress == address(0) || userAddress == msg.sender, "unauthorized user");
        } else if (
            sig == 0x077822bd || // batchFillOrderWithTarget
            sig == 0xc8b81d63 || // batchFillOrderWithTargetNFT
            sig == 0x1c64b820 || // tryBatchFillOrderTakerAmount
            sig == 0x01fb36ba // tryBatchFillOrderMakerAmount
        ) {
            // First parameter is variable length array of variable size order
            // infos where first field of order info is the actual order struct
            // (fixed size so encoded in place) which starts with nonceAndMeta.
            // Therefore, the nonceAndMeta is the first 32 bytes of order info.
            // But we need to find where the order infos start!
            // Firstly, we load the offset of the array, and its length
            uint256 arrayPtr;
            uint256 arrayLength;
            uint256 arrayStart;
            assembly {
                arrayPtr := add(paramsStart, mload(paramsStart))
                arrayLength := mload(arrayPtr)
                arrayStart := add(arrayPtr, 32)
            }
            // Each of the words after the array length is an offset from the
            // start of the array data, loading this gives us nonceAndMeta
            for (uint256 i = 0; i < arrayLength; ++i) {
                uint256 nonceAndMeta;
                assembly {
                    arrayPtr := add(arrayPtr, 32)
                    nonceAndMeta := mload(add(arrayStart, mload(arrayPtr)))
                }
                address userAddress = address(uint160(nonceAndMeta));
                require(userAddress == address(0) || userAddress == msg.sender, "unauthorized user");
            }
        } else {
            revert("unrecognized AugustusRFQ method selector");
        }
    }

    /*solhint-disable no-inline-assembly*/
    /**
     * @dev Source take from GNOSIS MultiSigWallet
     * @dev https://github.com/gnosis/MultiSigWallet/blob/master/contracts/MultiSigWallet.sol
     */
    function externalCall(
        address destination,
        uint256 value,
        uint256 dataOffset,
        uint256 dataLength,
        bytes memory data
    ) private returns (bool) {
        bool result = false;

        assembly {
            let x := mload(0x40) // "Allocate" memory for output
            // (0x40 is where "free memory" pointer is stored by convention)

            let d := add(data, 32) // First 32 bytes are the padded length of data, so exclude that
            result := call(
                gas(),
                destination,
                value,
                add(d, dataOffset),
                dataLength, // Size of the input (in bytes) - this is what fixes the padding problem
                x,
                0 // Output is ignored, therefore the output size is zero
            )
            // let ptr := mload(0x40)
            // let size := returndatasize()
            // returndatacopy(ptr, 0, size)
            // revert(ptr, size)
        }
        return result;
    }

    /*solhint-enable no-inline-assembly*/
}

File 2 of 13 : IERC20.sol
// 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);
}

File 3 of 13 : Utils.sol
/*solhint-disable avoid-low-level-calls */
// SPDX-License-Identifier: ISC

pragma solidity 0.7.5;
pragma experimental ABIEncoderV2;

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/SafeERC20.sol";
import "@openzeppelin/contracts/math/SafeMath.sol";
import "../ITokenTransferProxy.sol";
import { IBalancerV2Vault } from "./balancerv2/IBalancerV2Vault.sol";

interface IERC20Permit {
    function permit(
        address owner,
        address spender,
        uint256 amount,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) external;
}

interface IERC20PermitLegacy {
    function permit(
        address holder,
        address spender,
        uint256 nonce,
        uint256 expiry,
        bool allowed,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) external;
}

library Utils {
    using SafeMath for uint256;
    using SafeERC20 for IERC20;

    address private constant ETH_ADDRESS = address(0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE);

    uint256 private constant MAX_UINT = type(uint256).max;

    enum CurveSwapType {
        EXCHANGE,
        EXCHANGE_UNDERLYING,
        EXCHANGE_GENERIC_FACTORY_ZAP
    }

    /**
     * @param fromToken Address of the source token
     * @param fromAmount Amount of source tokens to be swapped
     * @param toAmount Minimum destination token amount expected out of this swap
     * @param expectedAmount Expected amount of destination tokens without slippage
     * @param beneficiary Beneficiary address
     * 0 then 100% will be transferred to beneficiary. Pass 10000 for 100%
     * @param path Route to be taken for this swap to take place
     */
    struct SellData {
        address fromToken;
        uint256 fromAmount;
        uint256 toAmount;
        uint256 expectedAmount;
        address payable beneficiary;
        Utils.Path[] path;
        address payable partner;
        uint256 feePercent;
        bytes permit;
        uint256 deadline;
        bytes16 uuid;
    }

    struct BuyData {
        address adapter;
        address fromToken;
        address toToken;
        uint256 fromAmount;
        uint256 toAmount;
        uint256 expectedAmount;
        address payable beneficiary;
        Utils.Route[] route;
        address payable partner;
        uint256 feePercent;
        bytes permit;
        uint256 deadline;
        bytes16 uuid;
    }

    struct MegaSwapSellData {
        address fromToken;
        uint256 fromAmount;
        uint256 toAmount;
        uint256 expectedAmount;
        address payable beneficiary;
        Utils.MegaSwapPath[] path;
        address payable partner;
        uint256 feePercent;
        bytes permit;
        uint256 deadline;
        bytes16 uuid;
    }

    struct SimpleData {
        address fromToken;
        address toToken;
        uint256 fromAmount;
        uint256 toAmount;
        uint256 expectedAmount;
        address[] callees;
        bytes exchangeData;
        uint256[] startIndexes;
        uint256[] values;
        address payable beneficiary;
        address payable partner;
        uint256 feePercent;
        bytes permit;
        uint256 deadline;
        bytes16 uuid;
    }

    struct DirectUniV3 {
        address fromToken;
        address toToken;
        address exchange;
        uint256 fromAmount;
        uint256 toAmount;
        uint256 expectedAmount;
        uint256 feePercent;
        uint256 deadline;
        address payable partner;
        bool isApproved;
        address payable beneficiary;
        bytes path;
        bytes permit;
        bytes16 uuid;
    }

    struct DirectCurveV1 {
        address fromToken;
        address toToken;
        address exchange;
        uint256 fromAmount;
        uint256 toAmount;
        uint256 expectedAmount;
        uint256 feePercent;
        int128 i;
        int128 j;
        address payable partner;
        bool isApproved;
        CurveSwapType swapType;
        address payable beneficiary;
        bool needWrapNative;
        bytes permit;
        bytes16 uuid;
    }

    struct DirectCurveV2 {
        address fromToken;
        address toToken;
        address exchange;
        address poolAddress;
        uint256 fromAmount;
        uint256 toAmount;
        uint256 expectedAmount;
        uint256 feePercent;
        uint256 i;
        uint256 j;
        address payable partner;
        bool isApproved;
        CurveSwapType swapType;
        address payable beneficiary;
        bool needWrapNative;
        bytes permit;
        bytes16 uuid;
    }

    struct DirectBalancerV2 {
        IBalancerV2Vault.BatchSwapStep[] swaps;
        address[] assets;
        IBalancerV2Vault.FundManagement funds;
        int256[] limits;
        uint256 fromAmount;
        uint256 toAmount;
        uint256 expectedAmount;
        uint256 deadline;
        uint256 feePercent;
        address vault;
        address payable partner;
        bool isApproved;
        address payable beneficiary;
        bytes permit;
        bytes16 uuid;
    }

    struct Adapter {
        address payable adapter;
        uint256 percent;
        uint256 networkFee; //NOT USED
        Route[] route;
    }

    struct Route {
        uint256 index; //Adapter at which index needs to be used
        address targetExchange;
        uint256 percent;
        bytes payload;
        uint256 networkFee; //NOT USED - Network fee is associated with 0xv3 trades
    }

    struct MegaSwapPath {
        uint256 fromAmountPercent;
        Path[] path;
    }

    struct Path {
        address to;
        uint256 totalNetworkFee; //NOT USED - Network fee is associated with 0xv3 trades
        Adapter[] adapters;
    }

    function ethAddress() internal pure returns (address) {
        return ETH_ADDRESS;
    }

    function maxUint() internal pure returns (uint256) {
        return MAX_UINT;
    }

    function approve(
        address addressToApprove,
        address token,
        uint256 amount
    ) internal {
        if (token != ETH_ADDRESS) {
            IERC20 _token = IERC20(token);

            uint256 allowance = _token.allowance(address(this), addressToApprove);

            if (allowance < amount) {
                _token.safeApprove(addressToApprove, 0);
                _token.safeIncreaseAllowance(addressToApprove, MAX_UINT);
            }
        }
    }

    function transferTokens(
        address token,
        address payable destination,
        uint256 amount
    ) internal {
        if (amount > 0) {
            if (token == ETH_ADDRESS) {
                (bool result, ) = destination.call{ value: amount, gas: 10000 }("");
                require(result, "Failed to transfer Ether");
            } else {
                IERC20(token).safeTransfer(destination, amount);
            }
        }
    }

    function tokenBalance(address token, address account) internal view returns (uint256) {
        if (token == ETH_ADDRESS) {
            return account.balance;
        } else {
            return IERC20(token).balanceOf(account);
        }
    }

    function permit(address token, bytes memory permit) internal {
        if (permit.length == 32 * 7) {
            (bool success, ) = token.call(abi.encodePacked(IERC20Permit.permit.selector, permit));
            require(success, "Permit failed");
        }

        if (permit.length == 32 * 8) {
            (bool success, ) = token.call(abi.encodePacked(IERC20PermitLegacy.permit.selector, permit));
            require(success, "Permit failed");
        }
    }

    function transferETH(address payable destination, uint256 amount) internal {
        if (amount > 0) {
            (bool result, ) = destination.call{ value: amount, gas: 10000 }("");
            require(result, "Transfer ETH failed");
        }
    }
}

File 4 of 13 : IRouter.sol
// SPDX-License-Identifier: ISC

pragma solidity 0.7.5;

interface IRouter {
    /**
     * @dev Certain routers/exchanges needs to be initialized.
     * This method will be called from Augustus
     */
    function initialize(bytes calldata data) external;

    /**
     * @dev Returns unique identifier for the router
     */
    function getKey() external pure returns (bytes32);

    event SwappedV3(
        bytes16 uuid,
        address partner,
        uint256 feePercent,
        address initiator,
        address indexed beneficiary,
        address indexed srcToken,
        address indexed destToken,
        uint256 srcAmount,
        uint256 receivedAmount,
        uint256 expectedAmount
    );

    event BoughtV3(
        bytes16 uuid,
        address partner,
        uint256 feePercent,
        address initiator,
        address indexed beneficiary,
        address indexed srcToken,
        address indexed destToken,
        uint256 srcAmount,
        uint256 receivedAmount,
        uint256 expectedAmount
    );
}

File 5 of 13 : IWETH.sol
// SPDX-License-Identifier: ISC

pragma solidity 0.7.5;

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";

abstract contract IWETH is IERC20 {
    function deposit() external payable virtual;

    function withdraw(uint256 amount) external virtual;
}

File 6 of 13 : FeeModel.sol
// SPDX-License-Identifier: ISC

pragma solidity 0.7.5;

import "@openzeppelin/contracts/math/SafeMath.sol";
import "../AugustusStorage.sol";
import "../lib/Utils.sol";
import "./IFeeClaimer.sol";
// helpers
import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";

contract FeeModel is AugustusStorage {
    using SafeMath for uint256;

    uint256 public immutable partnerSharePercent;
    uint256 public immutable maxFeePercent;
    uint256 public immutable paraswapReferralShare;
    uint256 public immutable paraswapSlippageShare;
    IFeeClaimer public immutable feeClaimer;

    constructor(
        uint256 _partnerSharePercent,
        uint256 _maxFeePercent,
        uint256 _paraswapReferralShare,
        uint256 _paraswapSlippageShare,
        IFeeClaimer _feeClaimer
    ) {
        partnerSharePercent = _partnerSharePercent;
        maxFeePercent = _maxFeePercent;
        paraswapReferralShare = _paraswapReferralShare;
        paraswapSlippageShare = _paraswapSlippageShare;
        feeClaimer = _feeClaimer;
    }

    // feePercent is a packed structure.
    // Bits 255-248 = 8-bit version field
    //
    // Version 0
    // =========
    // Entire structure is interpreted as the fee percent in basis points.
    // If set to 0 then partner will not receive any fees.
    //
    // Version 1
    // =========
    // Bits 13-0 = Fee percent in basis points
    // Bit 14 = positiveSlippageToUser (positive slippage to partner if not set)
    // Bit 15 = if set, take fee from fromToken, toToken otherwise
    // Bit 16 = if set, do fee distribution as per referral program

    function takeFromTokenFee(
        address fromToken,
        uint256 fromAmount,
        address payable partner,
        uint256 feePercent
    ) internal returns (uint256 newFromAmount) {
        uint256 fixedFeeBps = _getFixedFeeBps(partner, feePercent);
        if (fixedFeeBps == 0) return fromAmount;
        (uint256 partnerShare, uint256 paraswapShare) = _calcFixedFees(fromAmount, fixedFeeBps);
        return _distributeFees(fromAmount, fromToken, partner, partnerShare, paraswapShare);
    }

    function takeFromTokenFeeAndTransfer(
        address fromToken,
        uint256 fromAmount,
        uint256 remainingAmount,
        address payable partner,
        uint256 feePercent
    ) internal {
        uint256 fixedFeeBps = _getFixedFeeBps(partner, feePercent);
        (uint256 partnerShare, uint256 paraswapShare) = _calcFixedFees(fromAmount, fixedFeeBps);
        if (partnerShare.add(paraswapShare) <= remainingAmount) {
            remainingAmount = _distributeFees(remainingAmount, fromToken, partner, partnerShare, paraswapShare);
        }
        Utils.transferTokens(fromToken, msg.sender, remainingAmount);
    }

    function takeToTokenFeeAndTransfer(
        address toToken,
        uint256 receivedAmount,
        address payable beneficiary,
        address payable partner,
        uint256 feePercent
    ) internal {
        uint256 fixedFeeBps = _getFixedFeeBps(partner, feePercent);
        (uint256 partnerShare, uint256 paraswapShare) = _calcFixedFees(receivedAmount, fixedFeeBps);
        Utils.transferTokens(
            toToken,
            beneficiary,
            _distributeFees(receivedAmount, toToken, partner, partnerShare, paraswapShare)
        );
    }

    function takeSlippageAndTransferSell(
        address toToken,
        address payable beneficiary,
        address payable partner,
        uint256 positiveAmount,
        uint256 negativeAmount,
        uint256 feePercent
    ) internal {
        uint256 totalSlippage = positiveAmount.sub(negativeAmount);
        if (partner != address(0)) {
            (uint256 referrerShare, uint256 paraswapShare) = _calcSlippageFees(totalSlippage, feePercent);
            positiveAmount = _distributeFees(positiveAmount, toToken, partner, referrerShare, paraswapShare);
        } else {
            uint256 paraswapSlippage = totalSlippage.mul(paraswapSlippageShare).div(10000);
            Utils.transferTokens(toToken, feeWallet, paraswapSlippage);
            positiveAmount = positiveAmount.sub(paraswapSlippage);
        }
        Utils.transferTokens(toToken, beneficiary, positiveAmount);
    }

    function takeSlippageAndTransferBuy(
        address fromToken,
        address payable partner,
        uint256 positiveAmount,
        uint256 negativeAmount,
        uint256 remainingAmount,
        uint256 feePercent
    ) internal {
        uint256 totalSlippage = positiveAmount.sub(negativeAmount);
        if (partner != address(0)) {
            (uint256 referrerShare, uint256 paraswapShare) = _calcSlippageFees(totalSlippage, feePercent);
            remainingAmount = _distributeFees(remainingAmount, fromToken, partner, referrerShare, paraswapShare);
        } else {
            uint256 paraswapSlippage = totalSlippage.mul(paraswapSlippageShare).div(10000);
            Utils.transferTokens(fromToken, feeWallet, paraswapSlippage);
            remainingAmount = remainingAmount.sub(paraswapSlippage);
        }
        // Transfer remaining token back to sender
        Utils.transferTokens(fromToken, msg.sender, remainingAmount);
    }

    function _getFixedFeeBps(address partner, uint256 feePercent) internal view returns (uint256 fixedFeeBps) {
        if (partner == address(0)) return 0;
        uint256 version = feePercent >> 248;
        if (version == 0) {
            fixedFeeBps = feePercent;
        } else {
            fixedFeeBps = feePercent & 0x3FFF;
        }
        return fixedFeeBps > maxFeePercent ? maxFeePercent : fixedFeeBps;
    }

    function _calcFixedFees(uint256 amount, uint256 fixedFeeBps)
        private
        view
        returns (uint256 partnerShare, uint256 paraswapShare)
    {
        uint256 fee = amount.mul(fixedFeeBps).div(10000);
        partnerShare = fee.mul(partnerSharePercent).div(10000);
        paraswapShare = fee.sub(partnerShare);
    }

    function _calcSlippageFees(uint256 slippage, uint256 feePercent)
        private
        view
        returns (uint256 partnerShare, uint256 paraswapShare)
    {
        uint256 feeBps = feePercent & 0x3FFF;
        require(feeBps + paraswapReferralShare <= 10000, "Invalid fee percent");
        paraswapShare = slippage.mul(paraswapReferralShare).div(10000);
        partnerShare = slippage.mul(feeBps).div(10000);
    }

    function _distributeFees(
        uint256 currentBalance,
        address token,
        address payable partner,
        uint256 partnerShare,
        uint256 paraswapShare
    ) private returns (uint256 newBalance) {
        uint256 totalFees = partnerShare.add(paraswapShare);
        if (totalFees == 0) return currentBalance;

        require(totalFees <= currentBalance, "Insufficient balance to pay for fees");

        Utils.transferTokens(token, payable(address(feeClaimer)), totalFees);
        if (partnerShare != 0) {
            feeClaimer.registerFee(partner, IERC20(token), partnerShare);
        }
        if (paraswapShare != 0) {
            feeClaimer.registerFee(feeWallet, IERC20(token), paraswapShare);
        }
        return currentBalance.sub(totalFees);
    }

    function _isTakeFeeFromSrcToken(uint256 feePercent) internal pure returns (bool) {
        return feePercent >> 248 != 0 && (feePercent & (1 << 15)) != 0;
    }

    function _isReferral(uint256 feePercent) internal pure returns (bool) {
        return (feePercent & (1 << 16)) != 0;
    }
}

File 7 of 13 : IFeeClaimer.sol
// SPDX-License-Identifier: ISC

pragma solidity 0.7.5;

import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";

interface IFeeClaimer {
    /**
     * @notice register partner's, affiliate's and PP's fee
     * @dev only callable by AugustusSwapper contract
     * @param _account account address used to withdraw fees
     * @param _token token address
     * @param _fee fee amount in token
     */
    function registerFee(
        address _account,
        IERC20 _token,
        uint256 _fee
    ) external;

    /**
     * @notice claim partner share fee in ERC20 token
     * @dev transfers ERC20 token balance to the caller's account
     *      the call will fail if withdrawer have zero balance in the contract
     * @param _token address of the ERC20 token
     * @param _recipient address
     * @return true if the withdraw was successfull
     */
    function withdrawAllERC20(IERC20 _token, address _recipient) external returns (bool);

    /**
     * @notice batch claim whole balance of fee share amount
     * @dev transfers ERC20 token balance to the caller's account
     *      the call will fail if withdrawer have zero balance in the contract
     * @param _tokens list of addresses of the ERC20 token
     * @param _recipient address of recipient
     * @return true if the withdraw was successfull
     */
    function batchWithdrawAllERC20(IERC20[] calldata _tokens, address _recipient) external returns (bool);

    /**
     * @notice claim some partner share fee in ERC20 token
     * @dev transfers ERC20 token amount to the caller's account
     *      the call will fail if withdrawer have zero balance in the contract
     * @param _token address of the ERC20 token
     * @param _recipient address
     * @return true if the withdraw was successfull
     */
    function withdrawSomeERC20(
        IERC20 _token,
        uint256 _tokenAmount,
        address _recipient
    ) external returns (bool);

    /**
     * @notice batch claim some amount of fee share in ERC20 token
     * @dev transfers ERC20 token balance to the caller's account
     *      the call will fail if withdrawer have zero balance in the contract
     * @param _tokens address of the ERC20 tokens
     * @param _tokenAmounts array of amounts
     * @param _recipient destination account addresses
     * @return true if the withdraw was successfull
     */
    function batchWithdrawSomeERC20(
        IERC20[] calldata _tokens,
        uint256[] calldata _tokenAmounts,
        address _recipient
    ) external returns (bool);

    /**
     * @notice compute unallocated fee in token
     * @param _token address of the ERC20 token
     * @return amount of unallocated token in fees
     */
    function getUnallocatedFees(IERC20 _token) external view returns (uint256);

    /**
     * @notice returns unclaimed fee amount given the token
     * @dev retrieves the balance of ERC20 token fee amount for a partner
     * @param _token address of the ERC20 token
     * @param _partner account address of the partner
     * @return amount of balance
     */
    function getBalance(IERC20 _token, address _partner) external view returns (uint256);

    /**
     * @notice returns unclaimed fee amount given the token in batch
     * @dev retrieves the balance of ERC20 token fee amount for a partner in batch
     * @param _tokens list of ERC20 token addresses
     * @param _partner account address of the partner
     * @return _fees array of the token amount
     */
    function batchGetBalance(IERC20[] calldata _tokens, address _partner)
        external
        view
        returns (uint256[] memory _fees);
}

File 8 of 13 : SafeERC20.sol
// 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");
        }
    }
}

File 9 of 13 : SafeMath.sol
// 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;
    }
}

File 10 of 13 : ITokenTransferProxy.sol
// SPDX-License-Identifier: ISC

pragma solidity 0.7.5;

interface ITokenTransferProxy {
    function transferFrom(
        address token,
        address from,
        address to,
        uint256 amount
    ) external;
}

File 11 of 13 : IBalancerV2Vault.sol
// SPDX-License-Identifier: ISC

pragma solidity 0.7.5;
pragma abicoder v2;

import "../Utils.sol";

interface IBalancerV2Vault {
    enum SwapKind {
        GIVEN_IN,
        GIVEN_OUT
    }

    struct SingleSwap {
        bytes32 poolId;
        SwapKind kind;
        address assetIn;
        address assetOut;
        uint256 amount;
        bytes userData;
    }

    struct BatchSwapStep {
        bytes32 poolId;
        uint256 assetInIndex;
        uint256 assetOutIndex;
        uint256 amount;
        bytes userData;
    }

    struct FundManagement {
        address sender;
        bool fromInternalBalance;
        address payable recipient;
        bool toInternalBalance;
    }

    function swap(
        SingleSwap memory singleSwap,
        FundManagement memory funds,
        uint256 limit,
        uint256 deadline
    ) external payable returns (uint256);

    function batchSwap(
        SwapKind kind,
        BatchSwapStep[] memory swaps,
        address[] memory assets,
        FundManagement memory funds,
        int256[] memory limits,
        uint256 deadline
    ) external payable returns (int256[] memory);
}

File 12 of 13 : Address.sol
// 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);
            }
        }
    }
}

File 13 of 13 : AugustusStorage.sol
// SPDX-License-Identifier: ISC

pragma solidity 0.7.5;

import "./ITokenTransferProxy.sol";

contract AugustusStorage {
    struct FeeStructure {
        uint256 partnerShare;
        bool noPositiveSlippage;
        bool positiveSlippageToUser;
        uint16 feePercent;
        string partnerId;
        bytes data;
    }

    ITokenTransferProxy internal tokenTransferProxy;
    address payable internal feeWallet;

    mapping(address => FeeStructure) internal registeredPartners;

    mapping(bytes4 => address) internal selectorVsRouter;
    mapping(bytes32 => bool) internal adapterInitialized;
    mapping(bytes32 => bytes) internal adapterVsData;

    mapping(bytes32 => bytes) internal routerData;
    mapping(bytes32 => bool) internal routerInitialized;

    bytes32 public constant WHITELISTED_ROLE = keccak256("WHITELISTED_ROLE");

    bytes32 public constant ROUTER_ROLE = keccak256("ROUTER_ROLE");
}

Settings
{
  "metadata": {
    "bytecodeHash": "none",
    "useLiteralContent": true
  },
  "optimizer": {
    "enabled": true,
    "runs": 1000000
  },
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  },
  "libraries": {}
}

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"uint256","name":"_partnerSharePercent","type":"uint256"},{"internalType":"uint256","name":"_maxFeePercent","type":"uint256"},{"internalType":"uint256","name":"_paraswapReferralShare","type":"uint256"},{"internalType":"uint256","name":"_paraswapSlippageShare","type":"uint256"},{"internalType":"contract IFeeClaimer","name":"_feeClaimer","type":"address"},{"internalType":"address","name":"_augustusRFQ","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes16","name":"uuid","type":"bytes16"},{"indexed":false,"internalType":"address","name":"partner","type":"address"},{"indexed":false,"internalType":"uint256","name":"feePercent","type":"uint256"},{"indexed":false,"internalType":"address","name":"initiator","type":"address"},{"indexed":true,"internalType":"address","name":"beneficiary","type":"address"},{"indexed":true,"internalType":"address","name":"srcToken","type":"address"},{"indexed":true,"internalType":"address","name":"destToken","type":"address"},{"indexed":false,"internalType":"uint256","name":"srcAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"receivedAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"expectedAmount","type":"uint256"}],"name":"BoughtV3","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes16","name":"uuid","type":"bytes16"},{"indexed":false,"internalType":"address","name":"partner","type":"address"},{"indexed":false,"internalType":"uint256","name":"feePercent","type":"uint256"},{"indexed":false,"internalType":"address","name":"initiator","type":"address"},{"indexed":true,"internalType":"address","name":"beneficiary","type":"address"},{"indexed":true,"internalType":"address","name":"srcToken","type":"address"},{"indexed":true,"internalType":"address","name":"destToken","type":"address"},{"indexed":false,"internalType":"uint256","name":"srcAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"receivedAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"expectedAmount","type":"uint256"}],"name":"SwappedV3","type":"event"},{"inputs":[],"name":"ROUTER_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"WHITELISTED_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"augustusRFQ","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"feeClaimer","outputs":[{"internalType":"contract IFeeClaimer","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getKey","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bytes","name":"","type":"bytes"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"maxFeePercent","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"paraswapReferralShare","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"paraswapSlippageShare","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"partnerSharePercent","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"fromToken","type":"address"},{"internalType":"address","name":"toToken","type":"address"},{"internalType":"uint256","name":"fromAmount","type":"uint256"},{"internalType":"uint256","name":"toAmount","type":"uint256"},{"internalType":"uint256","name":"expectedAmount","type":"uint256"},{"internalType":"address[]","name":"callees","type":"address[]"},{"internalType":"bytes","name":"exchangeData","type":"bytes"},{"internalType":"uint256[]","name":"startIndexes","type":"uint256[]"},{"internalType":"uint256[]","name":"values","type":"uint256[]"},{"internalType":"address payable","name":"beneficiary","type":"address"},{"internalType":"address payable","name":"partner","type":"address"},{"internalType":"uint256","name":"feePercent","type":"uint256"},{"internalType":"bytes","name":"permit","type":"bytes"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"bytes16","name":"uuid","type":"bytes16"}],"internalType":"struct Utils.SimpleData","name":"data","type":"tuple"}],"name":"simpleBuy","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"fromToken","type":"address"},{"internalType":"address","name":"toToken","type":"address"},{"internalType":"uint256","name":"fromAmount","type":"uint256"},{"internalType":"uint256","name":"toAmount","type":"uint256"},{"internalType":"uint256","name":"expectedAmount","type":"uint256"},{"internalType":"address[]","name":"callees","type":"address[]"},{"internalType":"bytes","name":"exchangeData","type":"bytes"},{"internalType":"uint256[]","name":"startIndexes","type":"uint256[]"},{"internalType":"uint256[]","name":"values","type":"uint256[]"},{"internalType":"address payable","name":"beneficiary","type":"address"},{"internalType":"address payable","name":"partner","type":"address"},{"internalType":"uint256","name":"feePercent","type":"uint256"},{"internalType":"bytes","name":"permit","type":"bytes"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"bytes16","name":"uuid","type":"bytes16"}],"internalType":"struct Utils.SimpleData","name":"data","type":"tuple"}],"name":"simpleSwap","outputs":[{"internalType":"uint256","name":"receivedAmount","type":"uint256"}],"stateMutability":"payable","type":"function"}]

6101406040523480156200001257600080fd5b5060405162002f1b38038062002f1b83398101604081905262000035916200006c565b60809590955260a09390935260c09190915260e0526001600160601b0319606091821b81166101005291901b1661012052620000e8565b60008060008060008060c0878903121562000085578182fd5b865195506020870151945060408701519350606087015192506080870151620000ae81620000cf565b60a0880151909250620000c181620000cf565b809150509295509295509295565b6001600160a01b0381168114620000e557600080fd5b50565b60805160a05160c05160e0516101005160601c6101205160601c612dac6200016f6000398061075e5280610e9452508061070e5280611ab45280611ae15280611c07525080610782528061143052806114fa5250806107a65280611d945280611e2e5250806107ca52806111c652806111f35250806101f652806119fe5250612dac6000f3fe6080604052600436106100c75760003560e01c806381cbd3ea11610074578063c25ff0261161004e578063c25ff026146101b5578063d555d4f9146101ca578063d830a05b146101df576100c7565b806381cbd3ea1461016957806382678dd61461018b5780638e81a2d4146101a0576100c7565b8063439fab91116100a5578063439fab911461012157806354e3f31b146101415780637a3226ec14610154576100c7565b806312070a41146100cc5780632298207a146100f757806330d643b51461010c575b600080fd5b3480156100d857600080fd5b506100e16101f4565b6040516100ee919061280b565b60405180910390f35b61010a610105366004612496565b610218565b005b34801561011857600080fd5b506100e1610525565b34801561012d57600080fd5b5061010a61013c366004612429565b610549565b6100e161014f3660046124cf565b61057b565b34801561016057600080fd5b506100e16106e8565b34801561017557600080fd5b5061017e61070c565b6040516100ee9190612743565b34801561019757600080fd5b506100e1610730565b3480156101ac57600080fd5b5061017e61075c565b3480156101c157600080fd5b506100e1610780565b3480156101d657600080fd5b506100e16107a4565b3480156101eb57600080fd5b506100e16107c8565b7f000000000000000000000000000000000000000000000000000000000000000081565b42816101a001351015610260576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161025790612bc3565b60405180910390fd5b600080610275610140840161012085016123f3565b73ffffffffffffffffffffffffffffffffffffffff16146102a7576102a2610140830161012084016123f3565b6102a9565b335b90506000806104516102be60a0860186612bfa565b808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152506102fd9250505060c0870187612c66565b8080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061033f9250505060e0880188612bfa565b8080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525061037f92505050610100890189612bfa565b808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152506103be9250505060208a018a6123f3565b6103ce60408b0160208c016123f3565b8a604001358b606001358c608001358d6101400160208101906103f191906123f3565b8e61016001358f8061018001906104089190612c66565b8080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f820116905080830192505050505050508f6107ec565b909250905061046660408501602086016123f3565b73ffffffffffffffffffffffffffffffffffffffff1661048960208601866123f3565b73ffffffffffffffffffffffffffffffffffffffff9081169085167f4cc7e95e48af62690313a0733e93308ac9a73326bc3c29f1788b1191c376d5b66104d76101e089016101c08a0161240f565b6104e96101608a016101408b016123f3565b6101608a0135336104fe60408d01358a610a53565b8a8d60800135604051610517979695949392919061279b565b60405180910390a450505050565b7f7a05a596cb0ce7fdea8a1e1ec73be300bdb35097c944ce1897202f7a13122eb281565b6040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161025790612999565b600042826101a0015110156105bc576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161025790612bc3565b61012082015160009073ffffffffffffffffffffffffffffffffffffffff16156105eb578261012001516105ed565b335b90506106388360a001518460c001518560e001518661010001518760000151886020015189604001518a606001518b608001518c61014001518d61016001518e61018001518d610acf565b9150826020015173ffffffffffffffffffffffffffffffffffffffff16836000015173ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff167fe00361d207b252a464323eb23d45d42583e391f2031acdd2e9fa36efddd43cb0866101c00151876101400151886101600151338a604001518a8c608001516040516106d9979695949392919061279b565b60405180910390a4505b919050565b7f8429d542926e6695b59ac6fbdcd9b37e8b1aeb757afab06ab60b1bb5878c3b4981565b7f000000000000000000000000000000000000000000000000000000000000000081565b6000604051602001610741906126f1565b60405160208183030381529060405280519060200120905090565b7f000000000000000000000000000000000000000000000000000000000000000081565b7f000000000000000000000000000000000000000000000000000000000000000081565b7f000000000000000000000000000000000000000000000000000000000000000081565b7f000000000000000000000000000000000000000000000000000000000000000081565b6000806107f7610d16565b73ffffffffffffffffffffffffffffffffffffffff168b73ffffffffffffffffffffffffffffffffffffffff1614610830576000610832565b885b341461086a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161025790612a9b565b600088116108a4576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161025790612a64565b8c518f51600101146108e2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016102579061284b565b8b518f511461091d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161025790612905565b6109288b8a86610d2e565b6109348f8f8f8f610e06565b61093e8a3061108a565b91508782101561097a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161025790612b66565b6109848b3061108a565b905060006109928a83610a53565b905061099e8787611185565b158015906109b257506109b08661121b565b155b80156109c457506109c286611235565b155b156109e6576109d68b84868a8a61123f565b6109e18c338461127f565b610a40565b6109f18b858561127f565b6109fb8787611185565b15801590610a0d5750610a0d8661121b565b15610a1f576109e18c82848a8a611386565b87811015610a35576109e18c888a84868b6113d1565b610a408c338461127f565b509d509d9b505050505050505050505050565b600082821115610ac457604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601e60248201527f536166654d6174683a207375627472616374696f6e206f766572666c6f770000604482015290519081900360640190fd5b508082035b92915050565b6000610ad9610d16565b73ffffffffffffffffffffffffffffffffffffffff168a73ffffffffffffffffffffffffffffffffffffffff1614610b12576000610b14565b875b3414610b4c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161025790612a9b565b60008711610b86576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161025790612a64565b8b518e5160010114610bc4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016102579061284b565b8a518e5114610bff576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161025790612905565b610c0a8a8985610d2e565b610c168e8e8e8e610e06565b610c20893061108a565b905086811015610c5c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161025790612b66565b610c668585611185565b15801590610c7a5750610c788461121b565b155b8015610c8c5750610c8a84611235565b155b15610ca357610c9e898284888861123f565b610d05565b8581118015610cb85750610cb68461121b565b155b15610ccb57610c9e898387848a8961149b565b610cd689838361127f565b610ce08585611185565b15801590610cf25750610cf28461121b565b15610d0557610d038a89878761155f565b505b9d9c50505050505050505050505050565b73eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee90565b610d36610d16565b73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614610e0157610d7283826115a6565b6000546040517f15dacbea00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff909116906315dacbea90610dce908690339030908890600401612764565b600060405180830381600087803b158015610de857600080fd5b505af1158015610dfc573d6000803e3d6000fd5b505050505b505050565b60005b845181101561108357600054855173ffffffffffffffffffffffffffffffffffffffff90911690869083908110610e3c57fe5b602002602001015173ffffffffffffffffffffffffffffffffffffffff161415610e92576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610257906128a8565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16858281518110610ed557fe5b602002602001015173ffffffffffffffffffffffffffffffffffffffff161415610f1b57610f16838281518110610f0857fe5b602002602001015185611791565b610fbe565b6000838281518110610f2957fe5b602090810291909101810151868101909101519091507fffffffff0000000000000000000000000000000000000000000000000000000081167f23b872dd000000000000000000000000000000000000000000000000000000001415610fbb576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161025790612a07565b50505b6000611041868381518110610fcf57fe5b6020026020010151848481518110610fe357fe5b6020026020010151868581518110610ff757fe5b602002602001015161103b88878151811061100e57fe5b602002602001015189886001018151811061102557fe5b6020026020010151610a5390919063ffffffff16565b896119b4565b90508061107a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161025790612ad2565b50600101610e09565b5050505050565b600073ffffffffffffffffffffffffffffffffffffffff831673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee14156110dc575073ffffffffffffffffffffffffffffffffffffffff811631610ac9565b6040517f70a0823100000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8416906370a082319061112e908590600401612743565b60206040518083038186803b15801561114657600080fd5b505afa15801561115a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061117e9190612660565b9050610ac9565b600073ffffffffffffffffffffffffffffffffffffffff83166111aa57506000610ac9565b60f882901c806111bc578291506111c4565b82613fff1691505b7f000000000000000000000000000000000000000000000000000000000000000082116111f15781611213565b7f00000000000000000000000000000000000000000000000000000000000000005b949350505050565b600060f882901c15801590610ac957505061800016151590565b6201000016151590565b600061124b8383611185565b905060008061125a87846119dc565b9150915061127588876112708a8c8a8888611a38565b61127f565b5050505050505050565b8015610e015773ffffffffffffffffffffffffffffffffffffffff831673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee14156113655760008273ffffffffffffffffffffffffffffffffffffffff1682612710906040516112e190612740565b600060405180830381858888f193505050503d806000811461131f576040519150601f19603f3d011682016040523d82523d6000602084013e611324565b606091505b505090508061135f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161025790612814565b50610e01565b610e0173ffffffffffffffffffffffffffffffffffffffff84168383611c7f565b60006113928383611185565b90506000806113a187846119dc565b9092509050856113b18383611d0c565b116113c6576113c38689878585611a38565b95505b61127588338861127f565b60006113dd8585610a53565b905073ffffffffffffffffffffffffffffffffffffffff861615611422576000806114088385611d87565b91509150611419858a8a8585611a38565b94505050611490565b600061145a612710611454847f0000000000000000000000000000000000000000000000000000000000000000611e6e565b90611ee1565b60015490915061148290899073ffffffffffffffffffffffffffffffffffffffff168361127f565b61148c8482610a53565b9350505b610dfc87338561127f565b60006114a78484610a53565b905073ffffffffffffffffffffffffffffffffffffffff8516156114ec576000806114d28385611d87565b915091506114e3868a898585611a38565b95505050611554565b600061151e612710611454847f0000000000000000000000000000000000000000000000000000000000000000611e6e565b60015490915061154690899073ffffffffffffffffffffffffffffffffffffffff168361127f565b6115508582610a53565b9450505b610dfc87878661127f565b60008061156c8484611185565b90508061157c5784915050611213565b60008061158987846119dc565b9150915061159a8789888585611a38565b98975050505050505050565b805160e0141561169a5760008273ffffffffffffffffffffffffffffffffffffffff1663d505accf60e01b836040516020016115e39291906126b1565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529082905261161b916126e5565b6000604051808303816000865af19150503d8060008114611658576040519150601f19603f3d011682016040523d82523d6000602084013e61165d565b606091505b5050905080611698576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161025790612962565b505b8051610100141561178d5760008273ffffffffffffffffffffffffffffffffffffffff16638fcbaf0c60e01b836040516020016116d89291906126b1565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe081840301815290829052611710916126e5565b6000604051808303816000865af19150503d806000811461174d576040519150601f19603f3d011682016040523d82523d6000602084013e611752565b606091505b5050905080610e01576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161025790612962565b5050565b818101602081015160e01c906024016398f9b46b8214806117b557508163bbbc2372145b806117c257508162154008145b806117d0575081633c3694ab145b806117de57508163c88ae6dc145b806117ec57508163b28ace5f145b806117fa5750816324abf828145b806118085750816330201ad3145b8061181657508163da6b84af145b8061182457508163f6c1b371145b156118a15780518073ffffffffffffffffffffffffffffffffffffffff81161580611864575073ffffffffffffffffffffffffffffffffffffffff811633145b61189a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610257906129d0565b50506119ae565b8163077822bd14806118b657508163c8b81d63145b806118c4575081631c64b820145b806118d25750816301fb36ba145b1561197c578051810180516020820160005b828110156119735760209390930180518201519093908073ffffffffffffffffffffffffffffffffffffffff81161580611933575073ffffffffffffffffffffffffffffffffffffffff811633145b611969576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610257906129d0565b50506001016118e4565b505050506119ae565b6040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161025790612b09565b50505050565b6000806000905060405160208401600082878984018b8d5af193505050505b95945050505050565b600080806119f06127106114548787611e6e565b9050611a22612710611454837f0000000000000000000000000000000000000000000000000000000000000000611e6e565b9250611a2e8184610a53565b9150509250929050565b600080611a458484611d0c565b905080611a5557869150506119d3565b86811115611aae576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526024815260200180612d526024913960400191505060405180910390fd5b611ad9867f00000000000000000000000000000000000000000000000000000000000000008361127f565b8315611ba7577f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663d1f4354b8688876040518463ffffffff1660e01b8152600401808473ffffffffffffffffffffffffffffffffffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019350505050600060405180830381600087803b158015611b8e57600080fd5b505af1158015611ba2573d6000803e3d6000fd5b505050505b8215611c6a57600154604080517fd1f4354b00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff928316600482015288831660248201526044810186905290517f00000000000000000000000000000000000000000000000000000000000000009092169163d1f4354b9160648082019260009290919082900301818387803b158015611c5157600080fd5b505af1158015611c65573d6000803e3d6000fd5b505050505b611c748782610a53565b979650505050505050565b6040805173ffffffffffffffffffffffffffffffffffffffff8416602482015260448082018490528251808303909101815260649091019091526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fa9059cbb00000000000000000000000000000000000000000000000000000000179052610e01908490611f62565b600082820183811015611d8057604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b9392505050565b600080613fff83166127107f000000000000000000000000000000000000000000000000000000000000000082011115611e2257604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f496e76616c6964206665652070657263656e7400000000000000000000000000604482015290519081900360640190fd5b611e52612710611454877f0000000000000000000000000000000000000000000000000000000000000000611e6e565b9150611e646127106114548784611e6e565b9250509250929050565b600082611e7d57506000610ac9565b82820282848281611e8a57fe5b0414611d80576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526021815260200180612d316021913960400191505060405180910390fd5b6000808211611f5157604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601a60248201527f536166654d6174683a206469766973696f6e206279207a65726f000000000000604482015290519081900360640190fd5b818381611f5a57fe5b049392505050565b6060611fc4826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff1661203a9092919063ffffffff16565b805190915015610e0157808060200190516020811015611fe357600080fd5b5051610e01576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602a815260200180612d76602a913960400191505060405180910390fd5b606061121384846000858561204e8561219a565b6120b957604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015290519081900360640190fd5b600060608673ffffffffffffffffffffffffffffffffffffffff1685876040518082805190602001908083835b6020831061212357805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe090920191602091820191016120e6565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d8060008114612185576040519150601f19603f3d011682016040523d82523d6000602084013e61218a565b606091505b5091509150611c748282866121a0565b3b151590565b606083156121af575081611d80565b8251156121bf5782518084602001fd5b816040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561222357818101518382015260200161220b565b50505050905090810190601f1680156122505780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b80356106e381612d0b565b600082601f830112612279578081fd5b813561228c61228782612ced565b612cc9565b8181529150602080830190848101818402860182018710156122ad57600080fd5b60005b848110156122d55781356122c381612d0b565b845292820192908201906001016122b0565b505050505092915050565b600082601f8301126122f0578081fd5b81356122fe61228782612ced565b81815291506020808301908481018184028601820187101561231f57600080fd5b60005b848110156122d557813584529282019290820190600101612322565b80357fffffffffffffffffffffffffffffffff00000000000000000000000000000000811681146106e357600080fd5b600082601f83011261237e578081fd5b813567ffffffffffffffff81111561239257fe5b6123c360207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f84011601612cc9565b91508082528360208285010111156123da57600080fd5b8060208401602084013760009082016020015292915050565b600060208284031215612404578081fd5b8135611d8081612d0b565b600060208284031215612420578081fd5b611d808261233e565b6000806020838503121561243b578081fd5b823567ffffffffffffffff80821115612452578283fd5b818501915085601f830112612465578283fd5b813581811115612473578384fd5b866020828501011115612484578384fd5b60209290920196919550909350505050565b6000602082840312156124a7578081fd5b813567ffffffffffffffff8111156124bd578182fd5b82016101e08185031215611d80578182fd5b6000602082840312156124e0578081fd5b813567ffffffffffffffff808211156124f7578283fd5b81840191506101e080838703121561250d578384fd5b61251681612cc9565b90506125218361225e565b815261252f6020840161225e565b602082015260408301356040820152606083013560608201526080830135608082015260a083013582811115612563578485fd5b61256f87828601612269565b60a08301525060c083013582811115612586578485fd5b6125928782860161236e565b60c08301525060e0830135828111156125a9578485fd5b6125b5878286016122e0565b60e08301525061010080840135838111156125ce578586fd5b6125da888287016122e0565b8284015250506101206125ee81850161225e565b9082015261014061260084820161225e565b9082015261016083810135908201526101808084013583811115612622578586fd5b61262e8882870161236e565b8284015250506101a0915081830135828201526101c0915061265182840161233e565b91810191909152949350505050565b600060208284031215612671578081fd5b5051919050565b60008151815b81811015612698576020818501810151868301520161267e565b818111156126a65782828601525b509290920192915050565b60007fffffffff00000000000000000000000000000000000000000000000000000000841682526112136004830184612678565b6000611d808284612678565b7f53494d504c455f535741505f524f55544552000000000000000000000000000081527f312e302e30000000000000000000000000000000000000000000000000000000601282015260170190565b90565b73ffffffffffffffffffffffffffffffffffffffff91909116815260200190565b73ffffffffffffffffffffffffffffffffffffffff9485168152928416602084015292166040820152606081019190915260800190565b7fffffffffffffffffffffffffffffffff0000000000000000000000000000000097909716875273ffffffffffffffffffffffffffffffffffffffff95861660208801526040870194909452919093166060850152608084019290925260a083019190915260c082015260e00190565b90815260200190565b60208082526018908201527f4661696c656420746f207472616e736665722045746865720000000000000000604082015260600190565b60208082526036908201527f537461727420696e6465786573206d757374206265203120677265617465722060408201527f7468656e206e756d626572206f662063616c6c65657300000000000000000000606082015260800190565b60208082526028908201527f43616e206e6f742063616c6c20546f6b656e5472616e7366657250726f78792060408201527f436f6e7472616374000000000000000000000000000000000000000000000000606082015260800190565b60208082526028908201527f63616c6c65657320616e642076616c756573206d75737420686176652073616d60408201527f65206c656e677468000000000000000000000000000000000000000000000000606082015260800190565b6020808252600d908201527f5065726d6974206661696c656400000000000000000000000000000000000000604082015260600190565b60208082526016908201527f4d4554484f44204e4f5420494d504c454d454e54454400000000000000000000604082015260600190565b60208082526011908201527f756e617574686f72697a65642075736572000000000000000000000000000000604082015260600190565b60208082526029908201527f7472616e7366657246726f6d206e6f7420616c6c6f77656420666f722065787460408201527f65726e616c43616c6c0000000000000000000000000000000000000000000000606082015260800190565b60208082526013908201527f746f416d6f756e7420697320746f6f206c6f7700000000000000000000000000604082015260600190565b60208082526013908201527f496e636f7272656374206d73672e76616c756500000000000000000000000000604082015260600190565b60208082526014908201527f45787465726e616c2063616c6c206661696c6564000000000000000000000000604082015260600190565b60208082526028908201527f756e7265636f676e697a6564204175677573747573524651206d6574686f642060408201527f73656c6563746f72000000000000000000000000000000000000000000000000606082015260800190565b60208082526030908201527f526563656976656420616d6f756e74206f6620746f6b656e7320617265206c6560408201527f7373207468656e20657870656374656400000000000000000000000000000000606082015260800190565b60208082526011908201527f446561646c696e65206272656163686564000000000000000000000000000000604082015260600190565b60008083357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe1843603018112612c2e578283fd5b83018035915067ffffffffffffffff821115612c48578283fd5b6020908101925081023603821315612c5f57600080fd5b9250929050565b60008083357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe1843603018112612c9a578283fd5b83018035915067ffffffffffffffff821115612cb4578283fd5b602001915036819003821315612c5f57600080fd5b60405181810167ffffffffffffffff81118282101715612ce557fe5b604052919050565b600067ffffffffffffffff821115612d0157fe5b5060209081020190565b73ffffffffffffffffffffffffffffffffffffffff81168114612d2d57600080fd5b5056fe536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f77496e73756666696369656e742062616c616e636520746f2070617920666f7220666565735361666545524332303a204552433230206f7065726174696f6e20646964206e6f742073756363656564a164736f6c6343000705000a000000000000000000000000000000000000000000000000000000000000213400000000000000000000000000000000000000000000000000000000000001f400000000000000000000000000000000000000000000000000000000000013880000000000000000000000000000000000000000000000000000000000002710000000000000000000000000ef13101c5bbd737cfb2bf00bbd38c626ad6952f7000000000000000000000000e92b586627cca7a83dc919cc7127196d70f55a06

Deployed Bytecode

0x6080604052600436106100c75760003560e01c806381cbd3ea11610074578063c25ff0261161004e578063c25ff026146101b5578063d555d4f9146101ca578063d830a05b146101df576100c7565b806381cbd3ea1461016957806382678dd61461018b5780638e81a2d4146101a0576100c7565b8063439fab91116100a5578063439fab911461012157806354e3f31b146101415780637a3226ec14610154576100c7565b806312070a41146100cc5780632298207a146100f757806330d643b51461010c575b600080fd5b3480156100d857600080fd5b506100e16101f4565b6040516100ee919061280b565b60405180910390f35b61010a610105366004612496565b610218565b005b34801561011857600080fd5b506100e1610525565b34801561012d57600080fd5b5061010a61013c366004612429565b610549565b6100e161014f3660046124cf565b61057b565b34801561016057600080fd5b506100e16106e8565b34801561017557600080fd5b5061017e61070c565b6040516100ee9190612743565b34801561019757600080fd5b506100e1610730565b3480156101ac57600080fd5b5061017e61075c565b3480156101c157600080fd5b506100e1610780565b3480156101d657600080fd5b506100e16107a4565b3480156101eb57600080fd5b506100e16107c8565b7f000000000000000000000000000000000000000000000000000000000000213481565b42816101a001351015610260576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161025790612bc3565b60405180910390fd5b600080610275610140840161012085016123f3565b73ffffffffffffffffffffffffffffffffffffffff16146102a7576102a2610140830161012084016123f3565b6102a9565b335b90506000806104516102be60a0860186612bfa565b808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152506102fd9250505060c0870187612c66565b8080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061033f9250505060e0880188612bfa565b8080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525061037f92505050610100890189612bfa565b808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152506103be9250505060208a018a6123f3565b6103ce60408b0160208c016123f3565b8a604001358b606001358c608001358d6101400160208101906103f191906123f3565b8e61016001358f8061018001906104089190612c66565b8080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f820116905080830192505050505050508f6107ec565b909250905061046660408501602086016123f3565b73ffffffffffffffffffffffffffffffffffffffff1661048960208601866123f3565b73ffffffffffffffffffffffffffffffffffffffff9081169085167f4cc7e95e48af62690313a0733e93308ac9a73326bc3c29f1788b1191c376d5b66104d76101e089016101c08a0161240f565b6104e96101608a016101408b016123f3565b6101608a0135336104fe60408d01358a610a53565b8a8d60800135604051610517979695949392919061279b565b60405180910390a450505050565b7f7a05a596cb0ce7fdea8a1e1ec73be300bdb35097c944ce1897202f7a13122eb281565b6040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161025790612999565b600042826101a0015110156105bc576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161025790612bc3565b61012082015160009073ffffffffffffffffffffffffffffffffffffffff16156105eb578261012001516105ed565b335b90506106388360a001518460c001518560e001518661010001518760000151886020015189604001518a606001518b608001518c61014001518d61016001518e61018001518d610acf565b9150826020015173ffffffffffffffffffffffffffffffffffffffff16836000015173ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff167fe00361d207b252a464323eb23d45d42583e391f2031acdd2e9fa36efddd43cb0866101c00151876101400151886101600151338a604001518a8c608001516040516106d9979695949392919061279b565b60405180910390a4505b919050565b7f8429d542926e6695b59ac6fbdcd9b37e8b1aeb757afab06ab60b1bb5878c3b4981565b7f000000000000000000000000ef13101c5bbd737cfb2bf00bbd38c626ad6952f781565b6000604051602001610741906126f1565b60405160208183030381529060405280519060200120905090565b7f000000000000000000000000e92b586627cca7a83dc919cc7127196d70f55a0681565b7f000000000000000000000000000000000000000000000000000000000000271081565b7f000000000000000000000000000000000000000000000000000000000000138881565b7f00000000000000000000000000000000000000000000000000000000000001f481565b6000806107f7610d16565b73ffffffffffffffffffffffffffffffffffffffff168b73ffffffffffffffffffffffffffffffffffffffff1614610830576000610832565b885b341461086a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161025790612a9b565b600088116108a4576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161025790612a64565b8c518f51600101146108e2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016102579061284b565b8b518f511461091d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161025790612905565b6109288b8a86610d2e565b6109348f8f8f8f610e06565b61093e8a3061108a565b91508782101561097a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161025790612b66565b6109848b3061108a565b905060006109928a83610a53565b905061099e8787611185565b158015906109b257506109b08661121b565b155b80156109c457506109c286611235565b155b156109e6576109d68b84868a8a61123f565b6109e18c338461127f565b610a40565b6109f18b858561127f565b6109fb8787611185565b15801590610a0d5750610a0d8661121b565b15610a1f576109e18c82848a8a611386565b87811015610a35576109e18c888a84868b6113d1565b610a408c338461127f565b509d509d9b505050505050505050505050565b600082821115610ac457604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601e60248201527f536166654d6174683a207375627472616374696f6e206f766572666c6f770000604482015290519081900360640190fd5b508082035b92915050565b6000610ad9610d16565b73ffffffffffffffffffffffffffffffffffffffff168a73ffffffffffffffffffffffffffffffffffffffff1614610b12576000610b14565b875b3414610b4c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161025790612a9b565b60008711610b86576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161025790612a64565b8b518e5160010114610bc4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016102579061284b565b8a518e5114610bff576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161025790612905565b610c0a8a8985610d2e565b610c168e8e8e8e610e06565b610c20893061108a565b905086811015610c5c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161025790612b66565b610c668585611185565b15801590610c7a5750610c788461121b565b155b8015610c8c5750610c8a84611235565b155b15610ca357610c9e898284888861123f565b610d05565b8581118015610cb85750610cb68461121b565b155b15610ccb57610c9e898387848a8961149b565b610cd689838361127f565b610ce08585611185565b15801590610cf25750610cf28461121b565b15610d0557610d038a89878761155f565b505b9d9c50505050505050505050505050565b73eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee90565b610d36610d16565b73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614610e0157610d7283826115a6565b6000546040517f15dacbea00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff909116906315dacbea90610dce908690339030908890600401612764565b600060405180830381600087803b158015610de857600080fd5b505af1158015610dfc573d6000803e3d6000fd5b505050505b505050565b60005b845181101561108357600054855173ffffffffffffffffffffffffffffffffffffffff90911690869083908110610e3c57fe5b602002602001015173ffffffffffffffffffffffffffffffffffffffff161415610e92576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610257906128a8565b7f000000000000000000000000e92b586627cca7a83dc919cc7127196d70f55a0673ffffffffffffffffffffffffffffffffffffffff16858281518110610ed557fe5b602002602001015173ffffffffffffffffffffffffffffffffffffffff161415610f1b57610f16838281518110610f0857fe5b602002602001015185611791565b610fbe565b6000838281518110610f2957fe5b602090810291909101810151868101909101519091507fffffffff0000000000000000000000000000000000000000000000000000000081167f23b872dd000000000000000000000000000000000000000000000000000000001415610fbb576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161025790612a07565b50505b6000611041868381518110610fcf57fe5b6020026020010151848481518110610fe357fe5b6020026020010151868581518110610ff757fe5b602002602001015161103b88878151811061100e57fe5b602002602001015189886001018151811061102557fe5b6020026020010151610a5390919063ffffffff16565b896119b4565b90508061107a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161025790612ad2565b50600101610e09565b5050505050565b600073ffffffffffffffffffffffffffffffffffffffff831673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee14156110dc575073ffffffffffffffffffffffffffffffffffffffff811631610ac9565b6040517f70a0823100000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8416906370a082319061112e908590600401612743565b60206040518083038186803b15801561114657600080fd5b505afa15801561115a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061117e9190612660565b9050610ac9565b600073ffffffffffffffffffffffffffffffffffffffff83166111aa57506000610ac9565b60f882901c806111bc578291506111c4565b82613fff1691505b7f00000000000000000000000000000000000000000000000000000000000001f482116111f15781611213565b7f00000000000000000000000000000000000000000000000000000000000001f45b949350505050565b600060f882901c15801590610ac957505061800016151590565b6201000016151590565b600061124b8383611185565b905060008061125a87846119dc565b9150915061127588876112708a8c8a8888611a38565b61127f565b5050505050505050565b8015610e015773ffffffffffffffffffffffffffffffffffffffff831673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee14156113655760008273ffffffffffffffffffffffffffffffffffffffff1682612710906040516112e190612740565b600060405180830381858888f193505050503d806000811461131f576040519150601f19603f3d011682016040523d82523d6000602084013e611324565b606091505b505090508061135f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161025790612814565b50610e01565b610e0173ffffffffffffffffffffffffffffffffffffffff84168383611c7f565b60006113928383611185565b90506000806113a187846119dc565b9092509050856113b18383611d0c565b116113c6576113c38689878585611a38565b95505b61127588338861127f565b60006113dd8585610a53565b905073ffffffffffffffffffffffffffffffffffffffff861615611422576000806114088385611d87565b91509150611419858a8a8585611a38565b94505050611490565b600061145a612710611454847f0000000000000000000000000000000000000000000000000000000000002710611e6e565b90611ee1565b60015490915061148290899073ffffffffffffffffffffffffffffffffffffffff168361127f565b61148c8482610a53565b9350505b610dfc87338561127f565b60006114a78484610a53565b905073ffffffffffffffffffffffffffffffffffffffff8516156114ec576000806114d28385611d87565b915091506114e3868a898585611a38565b95505050611554565b600061151e612710611454847f0000000000000000000000000000000000000000000000000000000000002710611e6e565b60015490915061154690899073ffffffffffffffffffffffffffffffffffffffff168361127f565b6115508582610a53565b9450505b610dfc87878661127f565b60008061156c8484611185565b90508061157c5784915050611213565b60008061158987846119dc565b9150915061159a8789888585611a38565b98975050505050505050565b805160e0141561169a5760008273ffffffffffffffffffffffffffffffffffffffff1663d505accf60e01b836040516020016115e39291906126b1565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529082905261161b916126e5565b6000604051808303816000865af19150503d8060008114611658576040519150601f19603f3d011682016040523d82523d6000602084013e61165d565b606091505b5050905080611698576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161025790612962565b505b8051610100141561178d5760008273ffffffffffffffffffffffffffffffffffffffff16638fcbaf0c60e01b836040516020016116d89291906126b1565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe081840301815290829052611710916126e5565b6000604051808303816000865af19150503d806000811461174d576040519150601f19603f3d011682016040523d82523d6000602084013e611752565b606091505b5050905080610e01576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161025790612962565b5050565b818101602081015160e01c906024016398f9b46b8214806117b557508163bbbc2372145b806117c257508162154008145b806117d0575081633c3694ab145b806117de57508163c88ae6dc145b806117ec57508163b28ace5f145b806117fa5750816324abf828145b806118085750816330201ad3145b8061181657508163da6b84af145b8061182457508163f6c1b371145b156118a15780518073ffffffffffffffffffffffffffffffffffffffff81161580611864575073ffffffffffffffffffffffffffffffffffffffff811633145b61189a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610257906129d0565b50506119ae565b8163077822bd14806118b657508163c8b81d63145b806118c4575081631c64b820145b806118d25750816301fb36ba145b1561197c578051810180516020820160005b828110156119735760209390930180518201519093908073ffffffffffffffffffffffffffffffffffffffff81161580611933575073ffffffffffffffffffffffffffffffffffffffff811633145b611969576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610257906129d0565b50506001016118e4565b505050506119ae565b6040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161025790612b09565b50505050565b6000806000905060405160208401600082878984018b8d5af193505050505b95945050505050565b600080806119f06127106114548787611e6e565b9050611a22612710611454837f0000000000000000000000000000000000000000000000000000000000002134611e6e565b9250611a2e8184610a53565b9150509250929050565b600080611a458484611d0c565b905080611a5557869150506119d3565b86811115611aae576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526024815260200180612d526024913960400191505060405180910390fd5b611ad9867f000000000000000000000000ef13101c5bbd737cfb2bf00bbd38c626ad6952f78361127f565b8315611ba7577f000000000000000000000000ef13101c5bbd737cfb2bf00bbd38c626ad6952f773ffffffffffffffffffffffffffffffffffffffff1663d1f4354b8688876040518463ffffffff1660e01b8152600401808473ffffffffffffffffffffffffffffffffffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019350505050600060405180830381600087803b158015611b8e57600080fd5b505af1158015611ba2573d6000803e3d6000fd5b505050505b8215611c6a57600154604080517fd1f4354b00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff928316600482015288831660248201526044810186905290517f000000000000000000000000ef13101c5bbd737cfb2bf00bbd38c626ad6952f79092169163d1f4354b9160648082019260009290919082900301818387803b158015611c5157600080fd5b505af1158015611c65573d6000803e3d6000fd5b505050505b611c748782610a53565b979650505050505050565b6040805173ffffffffffffffffffffffffffffffffffffffff8416602482015260448082018490528251808303909101815260649091019091526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fa9059cbb00000000000000000000000000000000000000000000000000000000179052610e01908490611f62565b600082820183811015611d8057604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b9392505050565b600080613fff83166127107f000000000000000000000000000000000000000000000000000000000000138882011115611e2257604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f496e76616c6964206665652070657263656e7400000000000000000000000000604482015290519081900360640190fd5b611e52612710611454877f0000000000000000000000000000000000000000000000000000000000001388611e6e565b9150611e646127106114548784611e6e565b9250509250929050565b600082611e7d57506000610ac9565b82820282848281611e8a57fe5b0414611d80576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526021815260200180612d316021913960400191505060405180910390fd5b6000808211611f5157604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601a60248201527f536166654d6174683a206469766973696f6e206279207a65726f000000000000604482015290519081900360640190fd5b818381611f5a57fe5b049392505050565b6060611fc4826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff1661203a9092919063ffffffff16565b805190915015610e0157808060200190516020811015611fe357600080fd5b5051610e01576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602a815260200180612d76602a913960400191505060405180910390fd5b606061121384846000858561204e8561219a565b6120b957604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015290519081900360640190fd5b600060608673ffffffffffffffffffffffffffffffffffffffff1685876040518082805190602001908083835b6020831061212357805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe090920191602091820191016120e6565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d8060008114612185576040519150601f19603f3d011682016040523d82523d6000602084013e61218a565b606091505b5091509150611c748282866121a0565b3b151590565b606083156121af575081611d80565b8251156121bf5782518084602001fd5b816040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561222357818101518382015260200161220b565b50505050905090810190601f1680156122505780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b80356106e381612d0b565b600082601f830112612279578081fd5b813561228c61228782612ced565b612cc9565b8181529150602080830190848101818402860182018710156122ad57600080fd5b60005b848110156122d55781356122c381612d0b565b845292820192908201906001016122b0565b505050505092915050565b600082601f8301126122f0578081fd5b81356122fe61228782612ced565b81815291506020808301908481018184028601820187101561231f57600080fd5b60005b848110156122d557813584529282019290820190600101612322565b80357fffffffffffffffffffffffffffffffff00000000000000000000000000000000811681146106e357600080fd5b600082601f83011261237e578081fd5b813567ffffffffffffffff81111561239257fe5b6123c360207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f84011601612cc9565b91508082528360208285010111156123da57600080fd5b8060208401602084013760009082016020015292915050565b600060208284031215612404578081fd5b8135611d8081612d0b565b600060208284031215612420578081fd5b611d808261233e565b6000806020838503121561243b578081fd5b823567ffffffffffffffff80821115612452578283fd5b818501915085601f830112612465578283fd5b813581811115612473578384fd5b866020828501011115612484578384fd5b60209290920196919550909350505050565b6000602082840312156124a7578081fd5b813567ffffffffffffffff8111156124bd578182fd5b82016101e08185031215611d80578182fd5b6000602082840312156124e0578081fd5b813567ffffffffffffffff808211156124f7578283fd5b81840191506101e080838703121561250d578384fd5b61251681612cc9565b90506125218361225e565b815261252f6020840161225e565b602082015260408301356040820152606083013560608201526080830135608082015260a083013582811115612563578485fd5b61256f87828601612269565b60a08301525060c083013582811115612586578485fd5b6125928782860161236e565b60c08301525060e0830135828111156125a9578485fd5b6125b5878286016122e0565b60e08301525061010080840135838111156125ce578586fd5b6125da888287016122e0565b8284015250506101206125ee81850161225e565b9082015261014061260084820161225e565b9082015261016083810135908201526101808084013583811115612622578586fd5b61262e8882870161236e565b8284015250506101a0915081830135828201526101c0915061265182840161233e565b91810191909152949350505050565b600060208284031215612671578081fd5b5051919050565b60008151815b81811015612698576020818501810151868301520161267e565b818111156126a65782828601525b509290920192915050565b60007fffffffff00000000000000000000000000000000000000000000000000000000841682526112136004830184612678565b6000611d808284612678565b7f53494d504c455f535741505f524f55544552000000000000000000000000000081527f312e302e30000000000000000000000000000000000000000000000000000000601282015260170190565b90565b73ffffffffffffffffffffffffffffffffffffffff91909116815260200190565b73ffffffffffffffffffffffffffffffffffffffff9485168152928416602084015292166040820152606081019190915260800190565b7fffffffffffffffffffffffffffffffff0000000000000000000000000000000097909716875273ffffffffffffffffffffffffffffffffffffffff95861660208801526040870194909452919093166060850152608084019290925260a083019190915260c082015260e00190565b90815260200190565b60208082526018908201527f4661696c656420746f207472616e736665722045746865720000000000000000604082015260600190565b60208082526036908201527f537461727420696e6465786573206d757374206265203120677265617465722060408201527f7468656e206e756d626572206f662063616c6c65657300000000000000000000606082015260800190565b60208082526028908201527f43616e206e6f742063616c6c20546f6b656e5472616e7366657250726f78792060408201527f436f6e7472616374000000000000000000000000000000000000000000000000606082015260800190565b60208082526028908201527f63616c6c65657320616e642076616c756573206d75737420686176652073616d60408201527f65206c656e677468000000000000000000000000000000000000000000000000606082015260800190565b6020808252600d908201527f5065726d6974206661696c656400000000000000000000000000000000000000604082015260600190565b60208082526016908201527f4d4554484f44204e4f5420494d504c454d454e54454400000000000000000000604082015260600190565b60208082526011908201527f756e617574686f72697a65642075736572000000000000000000000000000000604082015260600190565b60208082526029908201527f7472616e7366657246726f6d206e6f7420616c6c6f77656420666f722065787460408201527f65726e616c43616c6c0000000000000000000000000000000000000000000000606082015260800190565b60208082526013908201527f746f416d6f756e7420697320746f6f206c6f7700000000000000000000000000604082015260600190565b60208082526013908201527f496e636f7272656374206d73672e76616c756500000000000000000000000000604082015260600190565b60208082526014908201527f45787465726e616c2063616c6c206661696c6564000000000000000000000000604082015260600190565b60208082526028908201527f756e7265636f676e697a6564204175677573747573524651206d6574686f642060408201527f73656c6563746f72000000000000000000000000000000000000000000000000606082015260800190565b60208082526030908201527f526563656976656420616d6f756e74206f6620746f6b656e7320617265206c6560408201527f7373207468656e20657870656374656400000000000000000000000000000000606082015260800190565b60208082526011908201527f446561646c696e65206272656163686564000000000000000000000000000000604082015260600190565b60008083357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe1843603018112612c2e578283fd5b83018035915067ffffffffffffffff821115612c48578283fd5b6020908101925081023603821315612c5f57600080fd5b9250929050565b60008083357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe1843603018112612c9a578283fd5b83018035915067ffffffffffffffff821115612cb4578283fd5b602001915036819003821315612c5f57600080fd5b60405181810167ffffffffffffffff81118282101715612ce557fe5b604052919050565b600067ffffffffffffffff821115612d0157fe5b5060209081020190565b73ffffffffffffffffffffffffffffffffffffffff81168114612d2d57600080fd5b5056fe536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f77496e73756666696369656e742062616c616e636520746f2070617920666f7220666565735361666545524332303a204552433230206f7065726174696f6e20646964206e6f742073756363656564a164736f6c6343000705000a

Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)

000000000000000000000000000000000000000000000000000000000000213400000000000000000000000000000000000000000000000000000000000001f400000000000000000000000000000000000000000000000000000000000013880000000000000000000000000000000000000000000000000000000000002710000000000000000000000000ef13101c5bbd737cfb2bf00bbd38c626ad6952f7000000000000000000000000e92b586627cca7a83dc919cc7127196d70f55a06

-----Decoded View---------------
Arg [0] : _partnerSharePercent (uint256): 8500
Arg [1] : _maxFeePercent (uint256): 500
Arg [2] : _paraswapReferralShare (uint256): 5000
Arg [3] : _paraswapSlippageShare (uint256): 10000
Arg [4] : _feeClaimer (address): 0xeF13101C5bbD737cFb2bF00Bbd38c626AD6952F7
Arg [5] : _augustusRFQ (address): 0xe92b586627ccA7a83dC919cc7127196d70f55a06

-----Encoded View---------------
6 Constructor Arguments found :
Arg [0] : 0000000000000000000000000000000000000000000000000000000000002134
Arg [1] : 00000000000000000000000000000000000000000000000000000000000001f4
Arg [2] : 0000000000000000000000000000000000000000000000000000000000001388
Arg [3] : 0000000000000000000000000000000000000000000000000000000000002710
Arg [4] : 000000000000000000000000ef13101c5bbd737cfb2bf00bbd38c626ad6952f7
Arg [5] : 000000000000000000000000e92b586627cca7a83dc919cc7127196d70f55a06


Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

Block Uncle Number Difficulty Gas Used Reward
View All Uncles
Loading...
Loading
Loading...
Loading

Validator Index Block Amount
View All Withdrawals

Transaction Hash Block Value Eth2 PubKey Valid
View All Deposits
Loading...
Loading
[ 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.