Contract 0x875b5f3908e37367533b7d6c92535f9ab579b072

 
Txn Hash Method
Block
From
To
Value [Txn Fee]
0x1a4ff23d8e767eb0de0ab594e92de56738bf85db33635f6dd175c164a8f1758dSet Gov284496932022-10-05 6:41:4156 days 4 hrs agoMycelium: Deployer IN  0x875b5f3908e37367533b7d6c92535f9ab579b0720 ETH0.00000654
0x28765c5088ec42f61c89497a25f75709c19577af6d0164d37e3d2ad98540e2e90x60806040202099872022-08-14 7:39:28108 days 3 hrs agoMycelium: Deployer IN  Create: VaultUtils0 ETH0.001917638191 ETH
[ Download CSV Export 
Latest 25 internal transaction
Parent Txn Hash Block From To Value
0x8d699d7c988db0b9bf154cbc9f0df675ac1023eb0a067ced968947eb695eb319424208252022-11-30 11:25:0334 secs ago 0x875b5f3908e37367533b7d6c92535f9ab579b072 0xdfba8ad57d2c62f61f0a60b2c508bcdeb182f8550 ETH
0x8d699d7c988db0b9bf154cbc9f0df675ac1023eb0a067ced968947eb695eb319424208252022-11-30 11:25:0334 secs ago 0x875b5f3908e37367533b7d6c92535f9ab579b072 0xdfba8ad57d2c62f61f0a60b2c508bcdeb182f8550 ETH
0x8d699d7c988db0b9bf154cbc9f0df675ac1023eb0a067ced968947eb695eb319424208252022-11-30 11:25:0334 secs ago 0x875b5f3908e37367533b7d6c92535f9ab579b072 0xdfba8ad57d2c62f61f0a60b2c508bcdeb182f8550 ETH
0x8d699d7c988db0b9bf154cbc9f0df675ac1023eb0a067ced968947eb695eb319424208252022-11-30 11:25:0334 secs ago 0xdfba8ad57d2c62f61f0a60b2c508bcdeb182f855 0x875b5f3908e37367533b7d6c92535f9ab579b0720 ETH
0x8d699d7c988db0b9bf154cbc9f0df675ac1023eb0a067ced968947eb695eb319424208252022-11-30 11:25:0334 secs ago 0x875b5f3908e37367533b7d6c92535f9ab579b072 0xdfba8ad57d2c62f61f0a60b2c508bcdeb182f8550 ETH
0x8d699d7c988db0b9bf154cbc9f0df675ac1023eb0a067ced968947eb695eb319424208252022-11-30 11:25:0334 secs ago 0x875b5f3908e37367533b7d6c92535f9ab579b072 0xdfba8ad57d2c62f61f0a60b2c508bcdeb182f8550 ETH
0x8d699d7c988db0b9bf154cbc9f0df675ac1023eb0a067ced968947eb695eb319424208252022-11-30 11:25:0334 secs ago 0x875b5f3908e37367533b7d6c92535f9ab579b072 0xdfba8ad57d2c62f61f0a60b2c508bcdeb182f8550 ETH
0x8d699d7c988db0b9bf154cbc9f0df675ac1023eb0a067ced968947eb695eb319424208252022-11-30 11:25:0334 secs ago 0xdfba8ad57d2c62f61f0a60b2c508bcdeb182f855 0x875b5f3908e37367533b7d6c92535f9ab579b0720 ETH
0xa091308872c64ec3fa99e19b6a89401b71e03b059c5fc5766bd791c4201e3b5e424208242022-11-30 11:25:0334 secs ago 0x875b5f3908e37367533b7d6c92535f9ab579b072 0xdfba8ad57d2c62f61f0a60b2c508bcdeb182f8550 ETH
0xa091308872c64ec3fa99e19b6a89401b71e03b059c5fc5766bd791c4201e3b5e424208242022-11-30 11:25:0334 secs ago 0x875b5f3908e37367533b7d6c92535f9ab579b072 0xdfba8ad57d2c62f61f0a60b2c508bcdeb182f8550 ETH
0xa091308872c64ec3fa99e19b6a89401b71e03b059c5fc5766bd791c4201e3b5e424208242022-11-30 11:25:0334 secs ago 0x875b5f3908e37367533b7d6c92535f9ab579b072 0xdfba8ad57d2c62f61f0a60b2c508bcdeb182f8550 ETH
0xa091308872c64ec3fa99e19b6a89401b71e03b059c5fc5766bd791c4201e3b5e424208242022-11-30 11:25:0334 secs ago 0xdfba8ad57d2c62f61f0a60b2c508bcdeb182f855 0x875b5f3908e37367533b7d6c92535f9ab579b0720 ETH
0xa091308872c64ec3fa99e19b6a89401b71e03b059c5fc5766bd791c4201e3b5e424208242022-11-30 11:25:0334 secs ago 0x875b5f3908e37367533b7d6c92535f9ab579b072 0xdfba8ad57d2c62f61f0a60b2c508bcdeb182f8550 ETH
0xa091308872c64ec3fa99e19b6a89401b71e03b059c5fc5766bd791c4201e3b5e424208242022-11-30 11:25:0334 secs ago 0x875b5f3908e37367533b7d6c92535f9ab579b072 0xdfba8ad57d2c62f61f0a60b2c508bcdeb182f8550 ETH
0xa091308872c64ec3fa99e19b6a89401b71e03b059c5fc5766bd791c4201e3b5e424208242022-11-30 11:25:0334 secs ago 0x875b5f3908e37367533b7d6c92535f9ab579b072 0xdfba8ad57d2c62f61f0a60b2c508bcdeb182f8550 ETH
0xa091308872c64ec3fa99e19b6a89401b71e03b059c5fc5766bd791c4201e3b5e424208242022-11-30 11:25:0334 secs ago 0xdfba8ad57d2c62f61f0a60b2c508bcdeb182f855 0x875b5f3908e37367533b7d6c92535f9ab579b0720 ETH
0xdd9914a851bb4d2e7930cb2bb2c016800948d67b724cc7f66ac5f1f72a5b1ae3424208232022-11-30 11:25:0334 secs ago 0x875b5f3908e37367533b7d6c92535f9ab579b072 0xdfba8ad57d2c62f61f0a60b2c508bcdeb182f8550 ETH
0xdd9914a851bb4d2e7930cb2bb2c016800948d67b724cc7f66ac5f1f72a5b1ae3424208232022-11-30 11:25:0334 secs ago 0x875b5f3908e37367533b7d6c92535f9ab579b072 0xdfba8ad57d2c62f61f0a60b2c508bcdeb182f8550 ETH
0xdd9914a851bb4d2e7930cb2bb2c016800948d67b724cc7f66ac5f1f72a5b1ae3424208232022-11-30 11:25:0334 secs ago 0x875b5f3908e37367533b7d6c92535f9ab579b072 0xdfba8ad57d2c62f61f0a60b2c508bcdeb182f8550 ETH
0xdd9914a851bb4d2e7930cb2bb2c016800948d67b724cc7f66ac5f1f72a5b1ae3424208232022-11-30 11:25:0334 secs ago 0xdfba8ad57d2c62f61f0a60b2c508bcdeb182f855 0x875b5f3908e37367533b7d6c92535f9ab579b0720 ETH
0xdd9914a851bb4d2e7930cb2bb2c016800948d67b724cc7f66ac5f1f72a5b1ae3424208232022-11-30 11:25:0334 secs ago 0x875b5f3908e37367533b7d6c92535f9ab579b072 0xdfba8ad57d2c62f61f0a60b2c508bcdeb182f8550 ETH
0xdd9914a851bb4d2e7930cb2bb2c016800948d67b724cc7f66ac5f1f72a5b1ae3424208232022-11-30 11:25:0334 secs ago 0x875b5f3908e37367533b7d6c92535f9ab579b072 0xdfba8ad57d2c62f61f0a60b2c508bcdeb182f8550 ETH
0xdd9914a851bb4d2e7930cb2bb2c016800948d67b724cc7f66ac5f1f72a5b1ae3424208232022-11-30 11:25:0334 secs ago 0x875b5f3908e37367533b7d6c92535f9ab579b072 0xdfba8ad57d2c62f61f0a60b2c508bcdeb182f8550 ETH
0xdd9914a851bb4d2e7930cb2bb2c016800948d67b724cc7f66ac5f1f72a5b1ae3424208232022-11-30 11:25:0334 secs ago 0xdfba8ad57d2c62f61f0a60b2c508bcdeb182f855 0x875b5f3908e37367533b7d6c92535f9ab579b0720 ETH
0x8bfafdfdb5f962e2aad70411c00cad5b482e2b18d01bc965b36c436c4d4cc4c7424208232022-11-30 11:25:0334 secs ago 0x875b5f3908e37367533b7d6c92535f9ab579b072 0xdfba8ad57d2c62f61f0a60b2c508bcdeb182f8550 ETH
[ Download CSV Export 
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
VaultUtils

Compiler Version
v0.6.12+commit.27d51765

Optimization Enabled:
Yes with 1 runs

Other Settings:
default evmVersion, MIT license

Contract Source Code (Solidity)

/**
 *Submitted for verification at Arbiscan on 2022-08-19
*/

// Sources flattened with hardhat v2.9.3 https://hardhat.org

// File contracts/libraries/math/SafeMath.sol

// SPDX-License-Identifier: MIT

pragma solidity 0.6.12;

/**
 * @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, 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) {
        return sub(a, b, "SafeMath: subtraction overflow");
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, reverting with custom message on
     * overflow (when the result is negative).
     *
     * 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);
        uint256 c = a - b;

        return c;
    }

    /**
     * @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) {
        // 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 0;
        }

        uint256 c = a * b;
        require(c / a == b, "SafeMath: multiplication overflow");

        return c;
    }

    /**
     * @dev Returns the integer division of two unsigned integers. Reverts 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) {
        return div(a, b, "SafeMath: division by zero");
    }

    /**
     * @dev Returns the integer division of two unsigned integers. Reverts with custom message 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,
        string memory errorMessage
    ) internal pure returns (uint256) {
        require(b > 0, errorMessage);
        uint256 c = a / b;
        // assert(a == b * c + a % b); // There is no case in which this doesn't hold

        return c;
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * Reverts 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) {
        return mod(a, b, "SafeMath: modulo by zero");
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * Reverts with custom message 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,
        string memory errorMessage
    ) internal pure returns (uint256) {
        require(b != 0, errorMessage);
        return a % b;
    }
}


// File contracts/libraries/token/IERC20.sol


pragma solidity 0.6.12;

/**
 * @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 contracts/core/interfaces/IVaultUtils.sol


pragma solidity 0.6.12;

interface IVaultUtils {
    function updateCumulativeFundingRate(address _collateralToken, address _indexToken) external returns (bool);

    function validateIncreasePosition(
        address _account,
        address _collateralToken,
        address _indexToken,
        uint256 _sizeDelta,
        bool _isLong
    ) external view;

    function validateDecreasePosition(
        address _account,
        address _collateralToken,
        address _indexToken,
        uint256 _collateralDelta,
        uint256 _sizeDelta,
        bool _isLong,
        address _receiver
    ) external view;

    function validateLiquidation(
        address _account,
        address _collateralToken,
        address _indexToken,
        bool _isLong,
        bool _raise
    ) external view returns (uint256, uint256);

    function getEntryFundingRate(
        address _collateralToken,
        address _indexToken,
        bool _isLong
    ) external view returns (uint256);

    function getPositionFee(
        address _account,
        address _collateralToken,
        address _indexToken,
        bool _isLong,
        uint256 _sizeDelta
    ) external view returns (uint256);

    function getFundingFee(
        address _account,
        address _collateralToken,
        address _indexToken,
        bool _isLong,
        uint256 _size,
        uint256 _entryFundingRate
    ) external view returns (uint256);

    function getBuyUsdgFeeBasisPoints(address _token, uint256 _usdgAmount) external view returns (uint256);

    function getSellUsdgFeeBasisPoints(address _token, uint256 _usdgAmount) external view returns (uint256);

    function getSwapFeeBasisPoints(
        address _tokenIn,
        address _tokenOut,
        uint256 _usdgAmount
    ) external view returns (uint256);

    function getFeeBasisPoints(
        address _token,
        uint256 _usdgDelta,
        uint256 _feeBasisPoints,
        uint256 _taxBasisPoints,
        bool _increment
    ) external view returns (uint256);
}


// File contracts/core/interfaces/IVault.sol


pragma solidity 0.6.12;

interface IVault {
    function isInitialized() external view returns (bool);

    function isSwapEnabled() external view returns (bool);

    function isLeverageEnabled() external view returns (bool);

    function setVaultUtils(IVaultUtils _vaultUtils) external;

    function setError(uint256 _errorCode, string calldata _error) external;

    function router() external view returns (address);

    function usdg() external view returns (address);

    function gov() external view returns (address);

    function whitelistedTokenCount() external view returns (uint256);

    function maxLeverage() external view returns (uint256);

    function minProfitTime() external view returns (uint256);

    function hasDynamicFees() external view returns (bool);

    function fundingInterval() external view returns (uint256);

    function totalTokenWeights() external view returns (uint256);

    function getTargetUsdgAmount(address _token) external view returns (uint256);

    function inManagerMode() external view returns (bool);

    function inPrivateLiquidationMode() external view returns (bool);

    function maxGasPrice() external view returns (uint256);

    function approvedRouters(address _account, address _router) external view returns (bool);

    function isLiquidator(address _account) external view returns (bool);

    function isManager(address _account) external view returns (bool);

    function minProfitBasisPoints(address _token) external view returns (uint256);

    function tokenBalances(address _token) external view returns (uint256);

    function lastFundingTimes(address _token) external view returns (uint256);

    function setMaxLeverage(uint256 _maxLeverage) external;

    function setInManagerMode(bool _inManagerMode) external;

    function setManager(address _manager, bool _isManager) external;

    function setIsSwapEnabled(bool _isSwapEnabled) external;

    function setIsLeverageEnabled(bool _isLeverageEnabled) external;

    function setMaxGasPrice(uint256 _maxGasPrice) external;

    function setUsdgAmount(address _token, uint256 _amount) external;

    function setBufferAmount(address _token, uint256 _amount) external;

    function setMaxGlobalShortSize(address _token, uint256 _amount) external;

    function setInPrivateLiquidationMode(bool _inPrivateLiquidationMode) external;

    function setLiquidator(address _liquidator, bool _isActive) external;

    function setFundingRate(
        uint256 _fundingInterval,
        uint256 _fundingRateFactor,
        uint256 _stableFundingRateFactor
    ) external;

    function setFees(
        uint256 _taxBasisPoints,
        uint256 _stableTaxBasisPoints,
        uint256 _mintBurnFeeBasisPoints,
        uint256 _swapFeeBasisPoints,
        uint256 _stableSwapFeeBasisPoints,
        uint256 _marginFeeBasisPoints,
        uint256 _liquidationFeeUsd,
        uint256 _minProfitTime,
        bool _hasDynamicFees
    ) external;

    function setTokenConfig(
        address _token,
        uint256 _tokenDecimals,
        uint256 _redemptionBps,
        uint256 _minProfitBps,
        uint256 _maxUsdgAmount,
        bool _isStable,
        bool _isShortable
    ) external;

    function setPriceFeed(address _priceFeed) external;

    function withdrawFees(address _token, address _receiver) external returns (uint256);

    function directPoolDeposit(address _token) external;

    function buyUSDG(address _token, address _receiver) external returns (uint256);

    function sellUSDG(address _token, address _receiver) external returns (uint256);

    function swap(
        address _tokenIn,
        address _tokenOut,
        address _receiver
    ) external returns (uint256);

    function increasePosition(
        address _account,
        address _collateralToken,
        address _indexToken,
        uint256 _sizeDelta,
        bool _isLong
    ) external;

    function decreasePosition(
        address _account,
        address _collateralToken,
        address _indexToken,
        uint256 _collateralDelta,
        uint256 _sizeDelta,
        bool _isLong,
        address _receiver
    ) external returns (uint256);

    function liquidatePosition(
        address _account,
        address _collateralToken,
        address _indexToken,
        bool _isLong,
        address _feeReceiver
    ) external;

    function tokenToUsdMin(address _token, uint256 _tokenAmount) external view returns (uint256);

    function priceFeed() external view returns (address);

    function fundingRateFactor() external view returns (uint256);

    function stableFundingRateFactor() external view returns (uint256);

    function cumulativeFundingRates(address _token) external view returns (uint256);

    function getNextFundingRate(address _token) external view returns (uint256);

    function getFeeBasisPoints(
        address _token,
        uint256 _usdgDelta,
        uint256 _feeBasisPoints,
        uint256 _taxBasisPoints,
        bool _increment
    ) external view returns (uint256);

    function liquidationFeeUsd() external view returns (uint256);

    function taxBasisPoints() external view returns (uint256);

    function stableTaxBasisPoints() external view returns (uint256);

    function mintBurnFeeBasisPoints() external view returns (uint256);

    function swapFeeBasisPoints() external view returns (uint256);

    function stableSwapFeeBasisPoints() external view returns (uint256);

    function marginFeeBasisPoints() external view returns (uint256);

    function allWhitelistedTokensLength() external view returns (uint256);

    function allWhitelistedTokens(uint256) external view returns (address);

    function whitelistedTokens(address _token) external view returns (bool);

    function stableTokens(address _token) external view returns (bool);

    function shortableTokens(address _token) external view returns (bool);

    function feeReserves(address _token) external view returns (uint256);

    function globalShortSizes(address _token) external view returns (uint256);

    function globalShortAveragePrices(address _token) external view returns (uint256);

    function maxGlobalShortSizes(address _token) external view returns (uint256);

    function tokenDecimals(address _token) external view returns (uint256);

    function tokenWeights(address _token) external view returns (uint256);

    function guaranteedUsd(address _token) external view returns (uint256);

    function poolAmounts(address _token) external view returns (uint256);

    function bufferAmounts(address _token) external view returns (uint256);

    function reservedAmounts(address _token) external view returns (uint256);

    function usdgAmounts(address _token) external view returns (uint256);

    function maxUsdgAmounts(address _token) external view returns (uint256);

    function getRedemptionAmount(address _token, uint256 _usdgAmount) external view returns (uint256);

    function getMaxPrice(address _token) external view returns (uint256);

    function getMinPrice(address _token) external view returns (uint256);

    function getDelta(
        address _indexToken,
        uint256 _size,
        uint256 _averagePrice,
        bool _isLong,
        uint256 _lastIncreasedTime
    ) external view returns (bool, uint256);

    function getPosition(
        address _account,
        address _collateralToken,
        address _indexToken,
        bool _isLong
    )
        external
        view
        returns (
            uint256,
            uint256,
            uint256,
            uint256,
            uint256,
            uint256,
            bool,
            uint256
        );
}


// File contracts/access/Governable.sol


pragma solidity 0.6.12;

contract Governable {
    address public gov;

    constructor() public {
        gov = msg.sender;
    }

    modifier onlyGov() {
        require(msg.sender == gov, "Governable: forbidden");
        _;
    }

    function setGov(address _gov) external onlyGov {
        gov = _gov;
    }
}


// File contracts/core/VaultUtils.sol

pragma solidity 0.6.12;


contract VaultUtils is IVaultUtils, Governable {
    using SafeMath for uint256;

    struct Position {
        uint256 size;
        uint256 collateral;
        uint256 averagePrice;
        uint256 entryFundingRate;
        uint256 reserveAmount;
        int256 realisedPnl;
        uint256 lastIncreasedTime;
    }

    IVault public vault;

    uint256 public constant BASIS_POINTS_DIVISOR = 10000;
    uint256 public constant FUNDING_RATE_PRECISION = 1000000;

    constructor(IVault _vault) public {
        vault = _vault;
    }

    function updateCumulativeFundingRate(
        address, /* _collateralToken */
        address /* _indexToken */
    ) public override returns (bool) {
        return true;
    }

    function validateIncreasePosition(
        address, /* _account */
        address, /* _collateralToken */
        address, /* _indexToken */
        uint256, /* _sizeDelta */
        bool /* _isLong */
    ) external view override {
        // no additional validations
    }

    function validateDecreasePosition(
        address, /* _account */
        address, /* _collateralToken */
        address, /* _indexToken */
        uint256, /* _collateralDelta */
        uint256, /* _sizeDelta */
        bool, /* _isLong */
        address /* _receiver */
    ) external view override {
        // no additional validations
    }

    function getPosition(
        address _account,
        address _collateralToken,
        address _indexToken,
        bool _isLong
    ) internal view returns (Position memory) {
        IVault _vault = vault;
        Position memory position;
        {
            (
                uint256 size,
                uint256 collateral,
                uint256 averagePrice,
                uint256 entryFundingRate, /* reserveAmount */ /* realisedPnl */ /* hasProfit */
                ,
                ,
                ,
                uint256 lastIncreasedTime
            ) = _vault.getPosition(_account, _collateralToken, _indexToken, _isLong);
            position.size = size;
            position.collateral = collateral;
            position.averagePrice = averagePrice;
            position.entryFundingRate = entryFundingRate;
            position.lastIncreasedTime = lastIncreasedTime;
        }
        return position;
    }

    function validateLiquidation(
        address _account,
        address _collateralToken,
        address _indexToken,
        bool _isLong,
        bool _raise
    ) public view override returns (uint256, uint256) {
        Position memory position = getPosition(_account, _collateralToken, _indexToken, _isLong);
        IVault _vault = vault;

        (bool hasProfit, uint256 delta) = _vault.getDelta(
            _indexToken,
            position.size,
            position.averagePrice,
            _isLong,
            position.lastIncreasedTime
        );
        uint256 marginFees = getFundingFee(
            _account,
            _collateralToken,
            _indexToken,
            _isLong,
            position.size,
            position.entryFundingRate
        );
        marginFees = marginFees.add(getPositionFee(_account, _collateralToken, _indexToken, _isLong, position.size));

        if (!hasProfit && position.collateral < delta) {
            if (_raise) {
                revert("Vault: losses exceed collateral");
            }
            return (1, marginFees);
        }

        uint256 remainingCollateral = position.collateral;
        if (!hasProfit) {
            remainingCollateral = position.collateral.sub(delta);
        }

        if (remainingCollateral < marginFees) {
            if (_raise) {
                revert("Vault: fees exceed collateral");
            }
            // cap the fees to the remainingCollateral
            return (1, remainingCollateral);
        }

        if (remainingCollateral < marginFees.add(_vault.liquidationFeeUsd())) {
            if (_raise) {
                revert("Vault: liquidation fees exceed collateral");
            }
            return (1, marginFees);
        }

        if (remainingCollateral.mul(_vault.maxLeverage()) < position.size.mul(BASIS_POINTS_DIVISOR)) {
            if (_raise) {
                revert("Vault: maxLeverage exceeded");
            }
            return (2, marginFees);
        }

        return (0, marginFees);
    }

    function getEntryFundingRate(
        address _collateralToken,
        address, /* _indexToken */
        bool /* _isLong */
    ) public view override returns (uint256) {
        return vault.cumulativeFundingRates(_collateralToken);
    }

    function getPositionFee(
        address, /* _account */
        address, /* _collateralToken */
        address, /* _indexToken */
        bool, /* _isLong */
        uint256 _sizeDelta
    ) public view override returns (uint256) {
        if (_sizeDelta == 0) {
            return 0;
        }
        uint256 afterFeeUsd = _sizeDelta.mul(BASIS_POINTS_DIVISOR.sub(vault.marginFeeBasisPoints())).div(
            BASIS_POINTS_DIVISOR
        );
        return _sizeDelta.sub(afterFeeUsd);
    }

    function getFundingFee(
        address, /* _account */
        address _collateralToken,
        address, /* _indexToken */
        bool, /* _isLong */
        uint256 _size,
        uint256 _entryFundingRate
    ) public view override returns (uint256) {
        if (_size == 0) {
            return 0;
        }

        uint256 fundingRate = vault.cumulativeFundingRates(_collateralToken).sub(_entryFundingRate);
        if (fundingRate == 0) {
            return 0;
        }

        return _size.mul(fundingRate).div(FUNDING_RATE_PRECISION);
    }

    function getBuyUsdgFeeBasisPoints(address _token, uint256 _usdgAmount) public view override returns (uint256) {
        return getFeeBasisPoints(_token, _usdgAmount, vault.mintBurnFeeBasisPoints(), vault.taxBasisPoints(), true);
    }

    function getSellUsdgFeeBasisPoints(address _token, uint256 _usdgAmount) public view override returns (uint256) {
        return getFeeBasisPoints(_token, _usdgAmount, vault.mintBurnFeeBasisPoints(), vault.taxBasisPoints(), false);
    }

    function getSwapFeeBasisPoints(
        address _tokenIn,
        address _tokenOut,
        uint256 _usdgAmount
    ) public view override returns (uint256) {
        bool isStableSwap = vault.stableTokens(_tokenIn) && vault.stableTokens(_tokenOut);
        uint256 baseBps = isStableSwap ? vault.stableSwapFeeBasisPoints() : vault.swapFeeBasisPoints();
        uint256 taxBps = isStableSwap ? vault.stableTaxBasisPoints() : vault.taxBasisPoints();
        uint256 feesBasisPoints0 = getFeeBasisPoints(_tokenIn, _usdgAmount, baseBps, taxBps, true);
        uint256 feesBasisPoints1 = getFeeBasisPoints(_tokenOut, _usdgAmount, baseBps, taxBps, false);
        // use the higher of the two fee basis points
        return feesBasisPoints0 > feesBasisPoints1 ? feesBasisPoints0 : feesBasisPoints1;
    }

    // cases to consider
    // 1. initialAmount is far from targetAmount, action increases balance slightly => high rebate
    // 2. initialAmount is far from targetAmount, action increases balance largely => high rebate
    // 3. initialAmount is close to targetAmount, action increases balance slightly => low rebate
    // 4. initialAmount is far from targetAmount, action reduces balance slightly => high tax
    // 5. initialAmount is far from targetAmount, action reduces balance largely => high tax
    // 6. initialAmount is close to targetAmount, action reduces balance largely => low tax
    // 7. initialAmount is above targetAmount, nextAmount is below targetAmount and vice versa
    // 8. a large swap should have similar fees as the same trade split into multiple smaller swaps
    function getFeeBasisPoints(
        address _token,
        uint256 _usdgDelta,
        uint256 _feeBasisPoints,
        uint256 _taxBasisPoints,
        bool _increment
    ) public view override returns (uint256) {
        if (!vault.hasDynamicFees()) {
            return _feeBasisPoints;
        }

        uint256 initialAmount = vault.usdgAmounts(_token);
        uint256 nextAmount = initialAmount.add(_usdgDelta);
        if (!_increment) {
            nextAmount = _usdgDelta > initialAmount ? 0 : initialAmount.sub(_usdgDelta);
        }

        uint256 targetAmount = vault.getTargetUsdgAmount(_token);
        if (targetAmount == 0) {
            return _feeBasisPoints;
        }

        uint256 initialDiff = initialAmount > targetAmount
            ? initialAmount.sub(targetAmount)
            : targetAmount.sub(initialAmount);
        uint256 nextDiff = nextAmount > targetAmount ? nextAmount.sub(targetAmount) : targetAmount.sub(nextAmount);

        // action improves relative asset balance
        if (nextDiff < initialDiff) {
            uint256 rebateBps = _taxBasisPoints.mul(initialDiff).div(targetAmount);
            return rebateBps > _feeBasisPoints ? 0 : _feeBasisPoints.sub(rebateBps);
        }

        uint256 averageDiff = initialDiff.add(nextDiff).div(2);
        if (averageDiff > targetAmount) {
            averageDiff = targetAmount;
        }
        uint256 taxBps = _taxBasisPoints.mul(averageDiff).div(targetAmount);
        return _feeBasisPoints.add(taxBps);
    }
}

Contract ABI

[{"inputs":[{"internalType":"contract IVault","name":"_vault","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"BASIS_POINTS_DIVISOR","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"FUNDING_RATE_PRECISION","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_token","type":"address"},{"internalType":"uint256","name":"_usdgAmount","type":"uint256"}],"name":"getBuyUsdgFeeBasisPoints","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_collateralToken","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"bool","name":"","type":"bool"}],"name":"getEntryFundingRate","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_token","type":"address"},{"internalType":"uint256","name":"_usdgDelta","type":"uint256"},{"internalType":"uint256","name":"_feeBasisPoints","type":"uint256"},{"internalType":"uint256","name":"_taxBasisPoints","type":"uint256"},{"internalType":"bool","name":"_increment","type":"bool"}],"name":"getFeeBasisPoints","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"_collateralToken","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"bool","name":"","type":"bool"},{"internalType":"uint256","name":"_size","type":"uint256"},{"internalType":"uint256","name":"_entryFundingRate","type":"uint256"}],"name":"getFundingFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"bool","name":"","type":"bool"},{"internalType":"uint256","name":"_sizeDelta","type":"uint256"}],"name":"getPositionFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_token","type":"address"},{"internalType":"uint256","name":"_usdgAmount","type":"uint256"}],"name":"getSellUsdgFeeBasisPoints","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_tokenIn","type":"address"},{"internalType":"address","name":"_tokenOut","type":"address"},{"internalType":"uint256","name":"_usdgAmount","type":"uint256"}],"name":"getSwapFeeBasisPoints","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"gov","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_gov","type":"address"}],"name":"setGov","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"}],"name":"updateCumulativeFundingRate","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bool","name":"","type":"bool"},{"internalType":"address","name":"","type":"address"}],"name":"validateDecreasePosition","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bool","name":"","type":"bool"}],"name":"validateIncreasePosition","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_account","type":"address"},{"internalType":"address","name":"_collateralToken","type":"address"},{"internalType":"address","name":"_indexToken","type":"address"},{"internalType":"bool","name":"_isLong","type":"bool"},{"internalType":"bool","name":"_raise","type":"bool"}],"name":"validateLiquidation","outputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"vault","outputs":[{"internalType":"contract IVault","name":"","type":"address"}],"stateMutability":"view","type":"function"}]

608060405234801561001057600080fd5b506040516116e13803806116e18339818101604052602081101561003357600080fd5b5051600080546001600160a01b03199081163317909155600180546001600160a01b039093169290911691909117905561166f806100726000396000f3fe608060405234801561001057600080fd5b50600436106100d05760003560e01c8063126082cf146100d557806312d43a51146100ef5780634adeddc6146101135780636be6026b1461013f57806381d11a23146101475780639d5c28fa1461019d578063b1cc53ab146101e1578063c7e074c314610219578063cfad57a214610259578063d54d5a9f1461027f578063da133816146102de578063da76524c14610314578063eb0835bf1461035e578063fbfa77cf1461038a578063fbfded6d14610392578063fdaf6ac3146103d4575b600080fd5b6100dd610418565b60408051918252519081900360200190f35b6100f761041e565b604080516001600160a01b039092168252519081900360200190f35b6100dd6004803603604081101561012957600080fd5b506001600160a01b03813516906020013561042d565b6100dd61052f565b61019b600480360360e081101561015d57600080fd5b506001600160a01b0381358116916020810135821691604082013581169160608101359160808201359160a081013515159160c09091013516610536565b005b61019b600480360360a08110156101b357600080fd5b506001600160a01b03813581169160208101358216916040820135169060608101359060800135151561053f565b6100dd600480360360608110156101f757600080fd5b506001600160a01b038135811691602081013590911690604001351515610546565b6100dd600480360360a081101561022f57600080fd5b506001600160a01b03813516906020810135906040810135906060810135906080013515156105cb565b61019b6004803603602081101561026f57600080fd5b50356001600160a01b031661085f565b6102c5600480360360a081101561029557600080fd5b506001600160a01b03813581169160208101358216916040820135169060608101351515906080013515156108d8565b6040805192835260208301919091528051918290030190f35b6100dd600480360360608110156102f457600080fd5b506001600160a01b03813581169160208101359091169060400135610ca0565b6100dd600480360360c081101561032a57600080fd5b506001600160a01b038135811691602081013582169160408201351690606081013515159060808101359060a00135610fe4565b6100dd6004803603604081101561037457600080fd5b506001600160a01b0381351690602001356110aa565b6100f76111a3565b6103c0600480360360408110156103a857600080fd5b506001600160a01b03813581169160200135166111b2565b604080519115158252519081900360200190f35b6100dd600480360360a08110156103ea57600080fd5b506001600160a01b0381358116916020810135821691604082013516906060810135151590608001356111ba565b61271081565b6000546001600160a01b031681565b60006105268383600160009054906101000a90046001600160a01b03166001600160a01b0316634d47b3046040518163ffffffff1660e01b815260040160206040518083038186803b15801561048257600080fd5b505afa158015610496573d6000803e3d6000fd5b505050506040513d60208110156104ac57600080fd5b505160015460408051637a210a2b60e01b815290516001600160a01b0390921691637a210a2b91600480820192602092909190829003018186803b1580156104f357600080fd5b505afa158015610507573d6000803e3d6000fd5b505050506040513d602081101561051d57600080fd5b505160016105cb565b90505b92915050565b620f424081565b50505050505050565b5050505050565b6001546040805163c65bc7b160e01b81526001600160a01b0386811660048301529151600093929092169163c65bc7b191602480820192602092909190829003018186803b15801561059757600080fd5b505afa1580156105ab573d6000803e3d6000fd5b505050506040513d60208110156105c157600080fd5b5051949350505050565b60015460408051639f392eb360e01b815290516000926001600160a01b031691639f392eb3916004808301926020929190829003018186803b15801561061057600080fd5b505afa158015610624573d6000803e3d6000fd5b505050506040513d602081101561063a57600080fd5b5051610647575082610856565b60015460408051631aa4ace560e01b81526001600160a01b03898116600483015291516000939290921691631aa4ace591602480820192602092909190829003018186803b15801561069857600080fd5b505afa1580156106ac573d6000803e3d6000fd5b505050506040513d60208110156106c257600080fd5b5051905060006106d28288611278565b9050836106f5578187116106ef576106ea82886112d0565b6106f2565b60005b90505b60015460408051633a05dcc160e01b81526001600160a01b038b8116600483015291516000939290921691633a05dcc191602480820192602092909190829003018186803b15801561074657600080fd5b505afa15801561075a573d6000803e3d6000fd5b505050506040513d602081101561077057600080fd5b505190508061078457869350505050610856565b600081841161079c5761079782856112d0565b6107a6565b6107a684836112d0565b905060008284116107c0576107bb83856112d0565b6107ca565b6107ca84846112d0565b9050818110156108125760006107ea846107e48b86611312565b9061136b565b9050898111610802576107fd8a826112d0565b610805565b60005b9650505050505050610856565b600061082360026107e48585611278565b9050838111156108305750825b6000610840856107e48c85611312565b905061084c8b82611278565b9750505050505050505b95945050505050565b6000546001600160a01b031633146108b6576040805162461bcd60e51b815260206004820152601560248201527423b7bb32b93730b136329d103337b93134b23232b760591b604482015290519081900360640190fd5b600080546001600160a01b0319166001600160a01b0392909216919091179055565b6000806108e36115b2565b6108ef888888886113aa565b600154815160408084015160c08501518251635c07eaab60e01b81526001600160a01b038d81166004830152602482019590955260448101929092528a1515606483015260848201528151949550919092169260009283928592635c07eaab9260a480840193919291829003018186803b15801561096c57600080fd5b505afa158015610980573d6000803e3d6000fd5b505050506040513d604081101561099657600080fd5b508051602090910151855160608701519294509092506000916109c1918e918e918e918e9190610fe4565b90506109de6109d78d8d8d8d8a600001516111ba565b8290611278565b9050821580156109f15750818560200151105b15610a59578715610a49576040805162461bcd60e51b815260206004820152601f60248201527f5661756c743a206c6f737365732065786365656420636f6c6c61746572616c00604482015290519081900360640190fd5b600196509450610c969350505050565b602085015183610a75576020860151610a7290846112d0565b90505b81811015610ae1578815610ad0576040805162461bcd60e51b815260206004820152601d60248201527f5661756c743a20666565732065786365656420636f6c6c61746572616c000000604482015290519081900360640190fd5b600197509550610c96945050505050565b610b50856001600160a01b031663174d26946040518163ffffffff1660e01b815260040160206040518083038186803b158015610b1d57600080fd5b505afa158015610b31573d6000803e3d6000fd5b505050506040513d6020811015610b4757600080fd5b50518390611278565b811015610ba5578815610b945760405162461bcd60e51b81526004018080602001828103825260298152602001806115f06029913960400191505060405180910390fd5b50600196509450610c969350505050565b8551610bb390612710611312565b610c22866001600160a01b031663ae3302c26040518163ffffffff1660e01b815260040160206040518083038186803b158015610bef57600080fd5b505afa158015610c03573d6000803e3d6000fd5b505050506040513d6020811015610c1957600080fd5b50518390611312565b1015610c8a578815610c79576040805162461bcd60e51b815260206004820152601b60248201527a15985d5b1d0e881b585e13195d995c9859d948195e18d959591959602a1b604482015290519081900360640190fd5b50600296509450610c969350505050565b50600096509450505050505b9550959350505050565b600154604080516342b60b0360e01b81526001600160a01b0386811660048301529151600093849316916342b60b03916024808301926020929190829003018186803b158015610cef57600080fd5b505afa158015610d03573d6000803e3d6000fd5b505050506040513d6020811015610d1957600080fd5b50518015610d9c5750600154604080516342b60b0360e01b81526001600160a01b038781166004830152915191909216916342b60b03916024808301926020929190829003018186803b158015610d6f57600080fd5b505afa158015610d83573d6000803e3d6000fd5b505050506040513d6020811015610d9957600080fd5b50515b9050600081610e2457600160009054906101000a90046001600160a01b03166001600160a01b031663a22f23926040518163ffffffff1660e01b815260040160206040518083038186803b158015610df357600080fd5b505afa158015610e07573d6000803e3d6000fd5b505050506040513d6020811015610e1d57600080fd5b5051610e9f565b600160009054906101000a90046001600160a01b03166001600160a01b031663df73a2676040518163ffffffff1660e01b815260040160206040518083038186803b158015610e7257600080fd5b505afa158015610e86573d6000803e3d6000fd5b505050506040513d6020811015610e9c57600080fd5b50515b9050600082610f2757600160009054906101000a90046001600160a01b03166001600160a01b0316637a210a2b6040518163ffffffff1660e01b815260040160206040518083038186803b158015610ef657600080fd5b505afa158015610f0a573d6000803e3d6000fd5b505050506040513d6020811015610f2057600080fd5b5051610fa2565b600160009054906101000a90046001600160a01b03166001600160a01b03166310eb56c26040518163ffffffff1660e01b815260040160206040518083038186803b158015610f7557600080fd5b505afa158015610f89573d6000803e3d6000fd5b505050506040513d6020811015610f9f57600080fd5b50515b90506000610fb48887858560016105cb565b90506000610fc68888868660006105cb565b9050808211610fd55780610fd7565b815b9998505050505050505050565b600082610ff3575060006110a0565b6001546040805163c65bc7b160e01b81526001600160a01b038981166004830152915160009361107a93879391169163c65bc7b191602480820192602092909190829003018186803b15801561104857600080fd5b505afa15801561105c573d6000803e3d6000fd5b505050506040513d602081101561107257600080fd5b5051906112d0565b90508061108b5760009150506110a0565b61109c620f42406107e48684611312565b9150505b9695505050505050565b60006105268383600160009054906101000a90046001600160a01b03166001600160a01b0316634d47b3046040518163ffffffff1660e01b815260040160206040518083038186803b1580156110ff57600080fd5b505afa158015611113573d6000803e3d6000fd5b505050506040513d602081101561112957600080fd5b505160015460408051637a210a2b60e01b815290516001600160a01b0390921691637a210a2b91600480820192602092909190829003018186803b15801561117057600080fd5b505afa158015611184573d6000803e3d6000fd5b505050506040513d602081101561119a57600080fd5b505160006105cb565b6001546001600160a01b031681565b600192915050565b6000816111c957506000610856565b60006112616127106107e461125a600160009054906101000a90046001600160a01b03166001600160a01b031663318bc6896040518163ffffffff1660e01b815260040160206040518083038186803b15801561122557600080fd5b505afa158015611239573d6000803e3d6000fd5b505050506040513d602081101561124f57600080fd5b5051612710906112d0565b8690611312565b905061126d83826112d0565b979650505050505050565b600082820183811015610526576040805162461bcd60e51b815260206004820152601b60248201527a536166654d6174683a206164646974696f6e206f766572666c6f7760281b604482015290519081900360640190fd5b600061052683836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f7700008152506114b6565b60008261132157506000610529565b8282028284828161132e57fe5b04146105265760405162461bcd60e51b81526004018080602001828103825260218152602001806116196021913960400191505060405180910390fd5b600061052683836040518060400160405280601a815260200179536166654d6174683a206469766973696f6e206279207a65726f60301b81525061154d565b6113b26115b2565b6001546001600160a01b03166113c66115b2565b6000806000806000866001600160a01b0316634a3f088d8d8d8d8d6040518563ffffffff1660e01b815260040180856001600160a01b03168152602001846001600160a01b03168152602001836001600160a01b0316815260200182151581526020019450505050506101006040518083038186803b15801561144857600080fd5b505afa15801561145c573d6000803e3d6000fd5b505050506040513d61010081101561147357600080fd5b50805160208083015160408085015160608087015160e090970151958d52938c01929092528a015288019190915260c087015250939a9950505050505050505050565b600081848411156115455760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561150a5781810151838201526020016114f2565b50505050905090810190601f1680156115375780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b6000818361159c5760405162461bcd60e51b815260206004820181815283516024840152835190928392604490910191908501908083836000831561150a5781810151838201526020016114f2565b5060008385816115a857fe5b0495945050505050565b6040518060e0016040528060008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152509056fe5661756c743a206c69717569646174696f6e20666565732065786365656420636f6c6c61746572616c536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f77a2646970667358221220265a0ca38f47f15fbdfc902f92c5bccc54050877cfde601d96e9a6195f91279e64736f6c634300060c0033000000000000000000000000dfba8ad57d2c62f61f0a60b2c508bcdeb182f855

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

000000000000000000000000dfba8ad57d2c62f61f0a60b2c508bcdeb182f855

-----Decoded View---------------
Arg [0] : _vault (address): 0xdfba8ad57d2c62f61f0a60b2c508bcdeb182f855

-----Encoded View---------------
1 Constructor Arguments found :
Arg [0] : 000000000000000000000000dfba8ad57d2c62f61f0a60b2c508bcdeb182f855


Deployed ByteCode Sourcemap

18997:9518:0:-:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;19361:52;;;:::i;:::-;;;;;;;;;;;;;;;;18642:18;;;:::i;:::-;;;;-1:-1:-1;;;;;18642:18:0;;;;;;;;;;;;;;24845:236;;;;;;;;;;;;;;;;-1:-1:-1;;;;;;24845:236:0;;;;;;;;:::i;19420:56::-;;;:::i;20042:359::-;;;;;;;;;;;;;;;;-1:-1:-1;;;;;;20042:359:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;19750:284;;;;;;;;;;;;;;;;-1:-1:-1;;;;;;19750:284:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;23492:247::-;;;;;;;;;;;;;;;;-1:-1:-1;;;;;;23492:247:0;;;;;;;;;;;;;;;;;;;:::i;26959:1553::-;;;;;;;;;;;;;;;;-1:-1:-1;;;;;;26959:1553:0;;;;;;;;;;;;;;;;;;;;;;;;;:::i;18842:76::-;;;;;;;;;;;;;;;;-1:-1:-1;18842:76:0;-1:-1:-1;;;;;18842:76:0;;:::i;21382:2102::-;;;;;;;;;;;;;;;;-1:-1:-1;;;;;;21382:2102:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;25335:813;;;;;;;;;;;;;;;;-1:-1:-1;;;;;;25335:813:0;;;;;;;;;;;;;;;;;:::i;24265:572::-;;;;;;;;;;;;;;;;-1:-1:-1;;;;;;24265:572:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;25089:238::-;;;;;;;;;;;;;;;;-1:-1:-1;;;;;;25089:238:0;;;;;;;;:::i;19333:19::-;;;:::i;19560:182::-;;;;;;;;;;;;;;;;-1:-1:-1;;;;;;19560:182:0;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;23747:510;;;;;;;;;;;;;;;;-1:-1:-1;;;;;;23747:510:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;19361:52::-;19408:5;19361:52;:::o;18642:18::-;;;-1:-1:-1;;;;;18642:18:0;;:::o;24845:236::-;24946:7;24973:100;24991:6;24999:11;25012:5;;;;;;;;;-1:-1:-1;;;;;25012:5:0;-1:-1:-1;;;;;25012:28:0;;:30;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;25012:30:0;25044:5;;:22;;;-1:-1:-1;;;25044:22:0;;;;-1:-1:-1;;;;;25044:5:0;;;;:20;;:22;;;;;25012:30;;25044:22;;;;;;;;:5;:22;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;25044:22:0;25068:4;24973:17;:100::i;:::-;24966:107;;24845:236;;;;;:::o;19420:56::-;19469:7;19420:56;:::o;20042:359::-;;;;;;;;:::o;19750:284::-;;;;;;:::o;23492:247::-;23685:5;;:46;;;-1:-1:-1;;;23685:46:0;;-1:-1:-1;;;;;23685:46:0;;;;;;;;;23658:7;;23685:5;;;;;:28;;:46;;;;;;;;;;;;;;;:5;:46;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;23685:46:0;;23492:247;-1:-1:-1;;;;23492:247:0:o;26959:1553::-;27196:5;;:22;;;-1:-1:-1;;;27196:22:0;;;;27171:7;;-1:-1:-1;;;;;27196:5:0;;:20;;:22;;;;;;;;;;;;;;:5;:22;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;27196:22:0;27191:78;;-1:-1:-1;27242:15:0;27235:22;;27191:78;27305:5;;:25;;;-1:-1:-1;;;27305:25:0;;-1:-1:-1;;;;;27305:25:0;;;;;;;;;27281:21;;27305:5;;;;;:17;;:25;;;;;;;;;;;;;;;:5;:25;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;27305:25:0;;-1:-1:-1;27341:18:0;27362:29;27305:25;27380:10;27362:17;:29::i;:::-;27341:50;;27407:10;27402:119;;27460:13;27447:10;:26;:62;;27480:29;:13;27498:10;27480:17;:29::i;:::-;27447:62;;;27476:1;27447:62;27434:75;;27402:119;27556:5;;:33;;;-1:-1:-1;;;27556:33:0;;-1:-1:-1;;;;;27556:33:0;;;;;;;;;27533:20;;27556:5;;;;;:25;;:33;;;;;;;;;;;;;;;:5;:33;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;27556:33:0;;-1:-1:-1;27604:17:0;27600:72;;27645:15;27638:22;;;;;;;27600:72;27684:19;27722:12;27706:13;:28;:122;;27797:31;:12;27814:13;27797:16;:31::i;:::-;27706:122;;;27750:31;:13;27768:12;27750:17;:31::i;:::-;27684:144;;27839:16;27871:12;27858:10;:25;:87;;27917:28;:12;27934:10;27917:16;:28::i;:::-;27858:87;;;27886:28;:10;27901:12;27886:14;:28::i;:::-;27839:106;;28024:11;28013:8;:22;28009:211;;;28052:17;28072:50;28109:12;28072:32;:15;28092:11;28072:19;:32::i;:::-;:36;;:50::i;:::-;28052:70;;28156:15;28144:9;:27;:64;;28178:30;:15;28198:9;28178:19;:30::i;:::-;28144:64;;;28174:1;28144:64;28137:71;;;;;;;;;;28009:211;28232:19;28254:32;28284:1;28254:25;:11;28270:8;28254:15;:25::i;:32::-;28232:54;;28315:12;28301:11;:26;28297:85;;;-1:-1:-1;28358:12:0;28297:85;28392:14;28409:50;28446:12;28409:32;:15;28429:11;28409:19;:32::i;:50::-;28392:67;-1:-1:-1;28477:27:0;:15;28392:67;28477:19;:27::i;:::-;28470:34;;;;;;;;;26959:1553;;;;;;;;:::o;18842:76::-;18785:3;;-1:-1:-1;;;;;18785:3:0;18771:10;:17;18763:51;;;;;-1:-1:-1;;;18763:51:0;;;;;;;;;;;;-1:-1:-1;;;18763:51:0;;;;;;;;;;;;;;;18900:3:::1;:10:::0;;-1:-1:-1;;;;;;18900:10:0::1;-1:-1:-1::0;;;;;18900:10:0;;;::::1;::::0;;;::::1;::::0;;18842:76::o;21382:2102::-;21585:7;21594;21614:24;;:::i;:::-;21641:61;21653:8;21663:16;21681:11;21694:7;21641:11;:61::i;:::-;21729:5;;21837:13;;21865:21;;;;;21923:26;;;;21781:179;;-1:-1:-1;;;21781:179:0;;-1:-1:-1;;;;;21781:179:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;21614:88;;-1:-1:-1;21729:5:0;;;;;21713:13;;;;21729:5;;21781:15;;:179;;;;;21865:21;;21781:179;;;;;;21729:5;21781:179;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;21781:179:0;;;;;;;22122:13;;22150:25;;;;21781:179;;-1:-1:-1;21781:179:0;;-1:-1:-1;21971:18:0;;21992:194;;22020:8;;22043:16;;22074:11;;22100:7;;22122:13;21992;:194::i;:::-;21971:215;;22210:95;22225:79;22240:8;22250:16;22268:11;22281:7;22290:8;:13;;;22225:14;:79::i;:::-;22210:10;;:14;:95::i;:::-;22197:108;;22323:9;22322:10;:41;;;;;22358:5;22336:8;:19;;;:27;22322:41;22318:198;;;22384:6;22380:88;;;22411:41;;;-1:-1:-1;;;22411:41:0;;;;;;;;;;;;;;;;;;;;;;;;;;;22380:88;22490:1;;-1:-1:-1;22493:10:0;-1:-1:-1;22482:22:0;;-1:-1:-1;;;;22482:22:0;22318:198;22558:19;;;;22593:9;22588:95;;22641:19;;;;:30;;22665:5;22641:23;:30::i;:::-;22619:52;;22588:95;22721:10;22699:19;:32;22695:252;;;22752:6;22748:86;;;22779:39;;;-1:-1:-1;;;22779:39:0;;;;;;;;;;;;;;;;;;;;;;;;;;;22748:86;22912:1;;-1:-1:-1;22915:19:0;-1:-1:-1;22904:31:0;;-1:-1:-1;;;;;22904:31:0;22695:252;22985:42;23000:6;-1:-1:-1;;;;;23000:24:0;;:26;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;23000:26:0;22985:10;;:14;:42::i;:::-;22963:19;:64;22959:231;;;23048:6;23044:98;;;23075:51;;-1:-1:-1;;;23075:51:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;23044:98;-1:-1:-1;23164:1:0;;-1:-1:-1;23167:10:0;-1:-1:-1;23156:22:0;;-1:-1:-1;;;;23156:22:0;22959:231;23254:13;;:39;;19408:5;23254:17;:39::i;:::-;23206:45;23230:6;-1:-1:-1;;;;;23230:18:0;;:20;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;23230:20:0;23206:19;;:23;:45::i;:::-;:87;23202:240;;;23314:6;23310:84;;;23341:37;;;-1:-1:-1;;;23341:37:0;;;;;;;;;;;;-1:-1:-1;;;23341:37:0;;;;;;;;;;;;;;23310:84;-1:-1:-1;23416:1:0;;-1:-1:-1;23419:10:0;-1:-1:-1;23408:22:0;;-1:-1:-1;;;;23408:22:0;23202:240;-1:-1:-1;23462:1:0;;-1:-1:-1;23465:10:0;-1:-1:-1;;;;;21382:2102:0;;;;;;;;;:::o;25335:813::-;25528:5;;:28;;;-1:-1:-1;;;25528:28:0;;-1:-1:-1;;;;;25528:28:0;;;;;;;;;25488:7;;;;25528:5;;:18;;:28;;;;;;;;;;;;;;:5;:28;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;25528:28:0;:61;;;;-1:-1:-1;25560:5:0;;:29;;;-1:-1:-1;;;25560:29:0;;-1:-1:-1;;;;;25560:29:0;;;;;;;;;:5;;;;;:18;;:29;;;;;;;;;;;;;;:5;:29;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;25560:29:0;25528:61;25508:81;;25600:15;25618:12;:76;;25668:5;;;;;;;;;-1:-1:-1;;;;;25668:5:0;-1:-1:-1;;;;;25668:24:0;;:26;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;25668:26:0;25618:76;;;25633:5;;;;;;;;;-1:-1:-1;;;;;25633:5:0;-1:-1:-1;;;;;25633:30:0;;:32;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;25633:32:0;25618:76;25600:94;;25705:14;25722:12;:68;;25768:5;;;;;;;;;-1:-1:-1;;;;;25768:5:0;-1:-1:-1;;;;;25768:20:0;;:22;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;25768:22:0;25722:68;;;25737:5;;;;;;;;;-1:-1:-1;;;;;25737:5:0;-1:-1:-1;;;;;25737:26:0;;:28;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;25737:28:0;25722:68;25705:85;;25801:24;25828:63;25846:8;25856:11;25869:7;25878:6;25886:4;25828:17;:63::i;:::-;25801:90;;25902:24;25929:65;25947:9;25958:11;25971:7;25980:6;25988:5;25929:17;:65::i;:::-;25902:92;;26086:16;26067;:35;:73;;26124:16;26067:73;;;26105:16;26067:73;26060:80;25335:813;-1:-1:-1;;;;;;;;;25335:813:0:o;24265:572::-;24518:7;24542:10;24538:51;;-1:-1:-1;24576:1:0;24569:8;;24538:51;24623:5;;:46;;;-1:-1:-1;;;24623:46:0;;-1:-1:-1;;;;;24623:46:0;;;;;;;;;24601:19;;24623:69;;24674:17;;24623:5;;;:28;;:46;;;;;;;;;;;;;;;:5;:46;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;24623:46:0;;:50;:69::i;:::-;24601:91;-1:-1:-1;24707:16:0;24703:57;;24747:1;24740:8;;;;;24703:57;24779:50;19469:7;24779:22;:5;24789:11;24779:9;:22::i;:50::-;24772:57;;;24265:572;;;;;;;;;:::o;25089:238::-;25191:7;25218:101;25236:6;25244:11;25257:5;;;;;;;;;-1:-1:-1;;;;;25257:5:0;-1:-1:-1;;;;;25257:28:0;;:30;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;25257:30:0;25289:5;;:22;;;-1:-1:-1;;;25289:22:0;;;;-1:-1:-1;;;;;25289:5:0;;;;:20;;:22;;;;;25257:30;;25289:22;;;;;;;;:5;:22;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;25289:22:0;25313:5;25218:17;:101::i;19333:19::-;;;-1:-1:-1;;;;;19333:19:0;;:::o;19560:182::-;19730:4;19560:182;;;;:::o;23747:510::-;23976:7;24000:15;23996:56;;-1:-1:-1;24039:1:0;24032:8;;23996:56;24062:19;24084:120;19408:5;24084:70;24099:54;24124:5;;;;;;;;;-1:-1:-1;;;;;24124:5:0;-1:-1:-1;;;;;24124:26:0;;:28;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;24124:28:0;19408:5;;24099:24;:54::i;:::-;24084:10;;:14;:70::i;:120::-;24062:142;-1:-1:-1;24222:27:0;:10;24062:142;24222:14;:27::i;:::-;24215:34;23747:510;-1:-1:-1;;;;;;;23747:510:0:o;1015:181::-;1073:7;1105:5;;;1129:6;;;;1121:46;;;;;-1:-1:-1;;;1121:46:0;;;;;;;;;;;;-1:-1:-1;;;1121:46:0;;;;;;;;;;;;;;1479:136;1537:7;1564:43;1568:1;1571;1564:43;;;;;;;;;;;;;;;;;:3;:43::i;2403:471::-;2461:7;2706:6;2702:47;;-1:-1:-1;2736:1:0;2729:8;;2702:47;2773:5;;;2777:1;2773;:5;:1;2797:5;;;;;:10;2789:56;;;;-1:-1:-1;;;2789:56:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;3350:132;3408:7;3435:39;3439:1;3442;3435:39;;;;;;;;;;;;;-1:-1:-1;;;3435:39:0;;;:3;:39::i;20409:965::-;20575:15;;:::i;:::-;20619:5;;-1:-1:-1;;;;;20619:5:0;20635:24;;:::i;:::-;20704:12;20735:18;20772:20;20811:24;20965:25;21008:6;-1:-1:-1;;;;;21008:18:0;;21027:8;21037:16;21055:11;21068:7;21008:68;;;;;;;;;;;;;-1:-1:-1;;;;;21008:68:0;;;;;;-1:-1:-1;;;;;21008:68:0;;;;;;-1:-1:-1;;;;;21008:68:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;21008:68:0;;;;;;;;;;;;;;;;;;;;;;21091:20;;;21126:19;;;:32;;;;21173:21;;:36;21224:25;;:44;;;;21008:68;21283:26;;:46;-1:-1:-1;21091:20:0;;20409:965;-1:-1:-1;;;;;;;;;;20409:965:0:o;1918:226::-;2038:7;2074:12;2066:6;;;;2058:29;;;;-1:-1:-1;;;2058:29:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;;2110:5:0;;;1918:226::o;3978:312::-;4098:7;4133:12;4126:5;4118:28;;;;-1:-1:-1;;;4118:28:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;4157:9;4173:1;4169;:5;;;;;;;3978:312;-1:-1:-1;;;;;3978:312:0:o;-1:-1:-1:-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::o

Metadata Hash

265a0ca38f47f15fbdfc902f92c5bccc54050877cfde601d96e9a6195f91279e
Block Transaction Gas Used Reward
Age Block Fee Address BC Fee Address Voting Power Jailed Incoming
Block Uncle Number Difficulty Gas Used Reward
Loading
Make sure to use the "Vote Down" button for any spammy posts, and the "Vote Up" for interesting conversations.