Address Details
contract
0x5CB8FB4cF7247de5fD514243d72B5e90C1b7BAb7
- Contract Name
- Broker
- Creator
- 0x56fd3f–9b8d81 at 0x1dd40f–b01e7c
- Balance
- 0 CELO ( )
- Locked CELO Balance
- 0.00 CELO
- Voting CELO Balance
- 0.00 CELO
- Pending Unlocked Gold
- 0.00 CELO
- Tokens
-
Fetching tokens...
- Transactions
- 1 Transactions
- Transfers
- 0 Transfers
- Gas Used
- 28,941
- Last Balance Update
- 21371643
This contract has been verified via Sourcify.
View contract in Sourcify repository
- Contract name:
- Broker
- Optimization enabled
- true
- Compiler version
- v0.5.17+commit.d19bba13
- Optimization runs
- 10000
- EVM Version
- istanbul
- Verified at
- 2023-05-25T19:43:51.075193Z
lib/mento-core/contracts/Broker.sol
// SPDX-License-Identifier: GPL-3.0-or-later pragma solidity ^0.5.13; pragma experimental ABIEncoderV2; import { Ownable } from "openzeppelin-solidity/contracts/ownership/Ownable.sol"; import { SafeERC20 } from "openzeppelin-solidity/contracts/token/ERC20/SafeERC20.sol"; import { SafeMath } from "openzeppelin-solidity/contracts/math/SafeMath.sol"; import { IExchangeProvider } from "./interfaces/IExchangeProvider.sol"; import { IBroker } from "./interfaces/IBroker.sol"; import { IBrokerAdmin } from "./interfaces/IBrokerAdmin.sol"; import { IReserve } from "./interfaces/IReserve.sol"; import { IStableToken } from "./interfaces/IStableToken.sol"; import { IERC20Metadata } from "./common/interfaces/IERC20Metadata.sol"; import { IERC20 } from "openzeppelin-solidity/contracts/token/ERC20/IERC20.sol"; import { Initializable } from "./common/Initializable.sol"; import { TradingLimits } from "./common/TradingLimits.sol"; import { ReentrancyGuard } from "./common/ReentrancyGuard.sol"; /** * @title Broker * @notice The broker executes swaps and keeps track of spending limits per pair. */ contract Broker is IBroker, IBrokerAdmin, Initializable, Ownable, ReentrancyGuard { using TradingLimits for TradingLimits.State; using TradingLimits for TradingLimits.Config; using SafeERC20 for IERC20; using SafeMath for uint256; /* ==================== State Variables ==================== */ address[] public exchangeProviders; mapping(address => bool) public isExchangeProvider; mapping(bytes32 => TradingLimits.State) public tradingLimitsState; mapping(bytes32 => TradingLimits.Config) public tradingLimitsConfig; // Address of the reserve. IReserve public reserve; uint256 private constant MAX_INT256 = uint256(-1) / 2; /* ==================== Constructor ==================== */ /** * @notice Sets initialized == true on implementation contracts. * @param test Set to true to skip implementation initialization. */ constructor(bool test) public Initializable(test) {} /** * @notice Allows the contract to be upgradable via the proxy. * @param _exchangeProviders The addresses of the ExchangeProvider contracts. * @param _reserve The address of the Reserve contract. */ function initialize(address[] calldata _exchangeProviders, address _reserve) external initializer { _transferOwnership(msg.sender); for (uint256 i = 0; i < _exchangeProviders.length; i++) { addExchangeProvider(_exchangeProviders[i]); } setReserve(_reserve); } /* ==================== Mutative Functions ==================== */ /** * @notice Add an exchange provider to the list of providers. * @param exchangeProvider The address of the exchange provider to add. * @return index The index of the newly added specified exchange provider. */ function addExchangeProvider(address exchangeProvider) public onlyOwner returns (uint256 index) { require(!isExchangeProvider[exchangeProvider], "ExchangeProvider already exists in the list"); require(exchangeProvider != address(0), "ExchangeProvider address can't be 0"); exchangeProviders.push(exchangeProvider); isExchangeProvider[exchangeProvider] = true; emit ExchangeProviderAdded(exchangeProvider); index = exchangeProviders.length.sub(1); } /** * @notice Remove an exchange provider from the list of providers. * @param exchangeProvider The address of the exchange provider to remove. * @param index The index of the exchange provider being removed. */ function removeExchangeProvider(address exchangeProvider, uint256 index) public onlyOwner { require(exchangeProviders[index] == exchangeProvider, "index doesn't match provider"); exchangeProviders[index] = exchangeProviders[exchangeProviders.length.sub(1)]; exchangeProviders.pop(); delete isExchangeProvider[exchangeProvider]; emit ExchangeProviderRemoved(exchangeProvider); } /** * @notice Set the Mento reserve address. * @param _reserve The Mento reserve address. */ function setReserve(address _reserve) public onlyOwner { require(_reserve != address(0), "Reserve address must be set"); emit ReserveSet(_reserve, address(reserve)); reserve = IReserve(_reserve); } /** * @notice Calculate the amount of tokenIn to be sold for a given amountOut of tokenOut * @param exchangeProvider the address of the exchange manager for the pair * @param exchangeId The id of the exchange to use * @param tokenIn The token to be sold * @param tokenOut The token to be bought * @param amountOut The amount of tokenOut to be bought * @return amountIn The amount of tokenIn to be sold */ function getAmountIn( address exchangeProvider, bytes32 exchangeId, address tokenIn, address tokenOut, uint256 amountOut ) external view returns (uint256 amountIn) { require(isExchangeProvider[exchangeProvider], "ExchangeProvider does not exist"); amountIn = IExchangeProvider(exchangeProvider).getAmountIn(exchangeId, tokenIn, tokenOut, amountOut); } /** * @notice Calculate the amount of tokenOut to be bought for a given amount of tokenIn to be sold * @param exchangeProvider the address of the exchange manager for the pair * @param exchangeId The id of the exchange to use * @param tokenIn The token to be sold * @param tokenOut The token to be bought * @param amountIn The amount of tokenIn to be sold * @return amountOut The amount of tokenOut to be bought */ function getAmountOut( address exchangeProvider, bytes32 exchangeId, address tokenIn, address tokenOut, uint256 amountIn ) external view returns (uint256 amountOut) { require(isExchangeProvider[exchangeProvider], "ExchangeProvider does not exist"); amountOut = IExchangeProvider(exchangeProvider).getAmountOut(exchangeId, tokenIn, tokenOut, amountIn); } /** * @notice Execute a token swap with fixed amountIn. * @param exchangeProvider the address of the exchange provider for the pair. * @param exchangeId The id of the exchange to use. * @param tokenIn The token to be sold. * @param tokenOut The token to be bought. * @param amountIn The amount of tokenIn to be sold. * @param amountOutMin Minimum amountOut to be received - controls slippage. * @return amountOut The amount of tokenOut to be bought. */ function swapIn( address exchangeProvider, bytes32 exchangeId, address tokenIn, address tokenOut, uint256 amountIn, uint256 amountOutMin ) external nonReentrant returns (uint256 amountOut) { require(isExchangeProvider[exchangeProvider], "ExchangeProvider does not exist"); amountOut = IExchangeProvider(exchangeProvider).swapIn(exchangeId, tokenIn, tokenOut, amountIn); require(amountOut >= amountOutMin, "amountOutMin not met"); guardTradingLimits(exchangeId, tokenIn, amountIn, tokenOut, amountOut); transferIn(msg.sender, tokenIn, amountIn); transferOut(msg.sender, tokenOut, amountOut); emit Swap(exchangeProvider, exchangeId, msg.sender, tokenIn, tokenOut, amountIn, amountOut); } /** * @notice Execute a token swap with fixed amountOut. * @param exchangeProvider the address of the exchange provider for the pair. * @param exchangeId The id of the exchange to use. * @param tokenIn The token to be sold. * @param tokenOut The token to be bought. * @param amountOut The amount of tokenOut to be bought. * @param amountInMax Maximum amount of tokenIn that can be traded. * @return amountIn The amount of tokenIn to be sold. */ function swapOut( address exchangeProvider, bytes32 exchangeId, address tokenIn, address tokenOut, uint256 amountOut, uint256 amountInMax ) external nonReentrant returns (uint256 amountIn) { require(isExchangeProvider[exchangeProvider], "ExchangeProvider does not exist"); amountIn = IExchangeProvider(exchangeProvider).swapOut(exchangeId, tokenIn, tokenOut, amountOut); require(amountIn <= amountInMax, "amountInMax exceeded"); guardTradingLimits(exchangeId, tokenIn, amountIn, tokenOut, amountOut); transferIn(msg.sender, tokenIn, amountIn); transferOut(msg.sender, tokenOut, amountOut); emit Swap(exchangeProvider, exchangeId, msg.sender, tokenIn, tokenOut, amountIn, amountOut); } /** * @notice Permissionless way to burn stables from msg.sender directly. * @param token The token getting burned. * @param amount The amount of the token getting burned. * @return True if transaction succeeds. */ function burnStableTokens(address token, uint256 amount) public returns (bool) { require(reserve.isStableAsset(token), "Token must be a reserve stable asset"); IERC20(token).safeTransferFrom(msg.sender, address(this), amount); require(IStableToken(token).burn(amount), "Burning of the stable asset failed"); return true; } /** * @notice Configure trading limits for an (exchangeId, token) touple. * @dev Will revert if the configuration is not valid according to the * TradingLimits library. * Resets existing state according to the TradingLimits library logic. * Can only be called by owner. * @param exchangeId the exchangeId to target. * @param token the token to target. * @param config the new trading limits config. */ function configureTradingLimit( bytes32 exchangeId, address token, TradingLimits.Config memory config ) public onlyOwner { config.validate(); bytes32 limitId = exchangeId ^ bytes32(uint256(uint160(token))); tradingLimitsConfig[limitId] = config; tradingLimitsState[limitId] = tradingLimitsState[limitId].reset(config); emit TradingLimitConfigured(exchangeId, token, config); } /* ==================== Private Functions ==================== */ /** * @notice Transfer a specified Mento asset to the given address. * If the specified asset is a stable asset it will be minted directly to the address. If * the asset is a collateral asset it will be transferred from the reserve to the given address. * @param to The address receiving the asset. * @param token The asset to transfer. * @param amount The amount of `token` to be transferred. */ function transferOut( address payable to, address token, uint256 amount ) internal { if (reserve.isStableAsset(token)) { require(IStableToken(token).mint(to, amount), "Minting of the stable asset failed"); } else if (reserve.isCollateralAsset(token)) { require(reserve.transferExchangeCollateralAsset(token, to, amount), "Transfer of the collateral asset failed"); } else { revert("Token must be stable or collateral assert"); } } /** * @notice Transfer a specified Mento asset into the reserve or the broker. * If the specified asset is a stable asset it will be transfered to the broker * and burned. If the asset is a collateral asset it will be transferred to the reserve. * @param from The address to transfer the asset from. * @param token The asset to transfer. * @param amount The amount of `token` to be transferred. */ function transferIn( address payable from, address token, uint256 amount ) internal { if (reserve.isStableAsset(token)) { IERC20(token).safeTransferFrom(from, address(this), amount); require(IStableToken(token).burn(amount), "Burning of the stable asset failed"); } else if (reserve.isCollateralAsset(token)) { IERC20(token).safeTransferFrom(from, address(reserve), amount); } else { revert("Token must be stable or collateral assert"); } } /** * @notice Verify trading limits for a trade in both directions. * @dev Reverts if the trading limits are met for outflow or inflow. * @param exchangeId the ID of the exchange being used. * @param _tokenIn the address of the token flowing in. * @param amountIn the amount of token flowing in. * @param _tokenOut the address of the token flowing out. * @param amountOut the amount of token flowing out. */ function guardTradingLimits( bytes32 exchangeId, address _tokenIn, uint256 amountIn, address _tokenOut, uint256 amountOut ) internal { bytes32 tokenIn = bytes32(uint256(uint160(_tokenIn))); bytes32 tokenOut = bytes32(uint256(uint160(_tokenOut))); require(amountIn <= uint256(MAX_INT256), "amountIn too large"); require(amountOut <= uint256(MAX_INT256), "amountOut too large"); guardTradingLimit(exchangeId ^ tokenIn, int256(amountIn), _tokenIn); guardTradingLimit(exchangeId ^ tokenOut, -1 * int256(amountOut), _tokenOut); } /** * @notice Updates and verifies a trading limit if it's configured. * @dev Will revert if the trading limit is exceeded by this trade. * @param tradingLimitId the ID of the trading limit associated with the token * @param deltaFlow the deltaflow of this token, negative for outflow, positive for inflow. * @param token the address of the token, used to lookup decimals. */ function guardTradingLimit( bytes32 tradingLimitId, int256 deltaFlow, address token ) internal { TradingLimits.Config memory tradingLimitConfig = tradingLimitsConfig[tradingLimitId]; if (tradingLimitConfig.flags > 0) { TradingLimits.State memory tradingLimitState = tradingLimitsState[tradingLimitId]; tradingLimitState = tradingLimitState.update(tradingLimitConfig, deltaFlow, IERC20Metadata(token).decimals()); tradingLimitState.verify(tradingLimitConfig); tradingLimitsState[tradingLimitId] = tradingLimitState; } } /* ==================== View Functions ==================== */ /** * @notice Get the list of registered exchange providers. * @dev This can be used by UI or clients to discover all pairs. * @return exchangeProviders the addresses of all exchange providers. */ function getExchangeProviders() external view returns (address[] memory) { return exchangeProviders; } }
/lib/mento-core/contracts/common/Initializable.sol
// SPDX-License-Identifier: GPL-3.0-or-later pragma solidity ^0.5.13; contract Initializable { bool public initialized; constructor(bool testingDeployment) public { if (!testingDeployment) { initialized = true; } } modifier initializer() { require(!initialized, "contract already initialized"); initialized = true; _; } }
/lib/mento-core/contracts/common/ReentrancyGuard.sol
// SPDX-License-Identifier: GPL-3.0-or-later pragma solidity ^0.5.13; /** * @title Helps contracts guard against reentrancy attacks. * @author Remco Bloemen <remco@2π.com>, Eenae <[email protected]> * @dev If you mark a function `nonReentrant`, you should also * mark it `external`. */ contract ReentrancyGuard { /// @dev counter to allow mutex lock with only one SSTORE operation uint256 private _guardCounter; constructor() internal { // The counter starts at one to prevent changing it from zero to a non-zero // value, which is a more expensive operation. _guardCounter = 1; } /** * @dev Prevents a contract from calling itself, directly or indirectly. * Calling a `nonReentrant` function from another `nonReentrant` * function is not supported. It is possible to prevent this from happening * by making the `nonReentrant` function external, and make it call a * `private` function that does the actual work. */ modifier nonReentrant() { _guardCounter += 1; uint256 localCounter = _guardCounter; _; require(localCounter == _guardCounter, "reentrant call"); } }
/lib/mento-core/contracts/common/TradingLimits.sol
// SPDX-License-Identifier: GPL-3.0-or-later pragma solidity ^0.5.13; pragma experimental ABIEncoderV2; /** * @title TradingLimits * @author Mento Team * @notice This library provides data structs and utility functions for * defining and verifying trading limits on the netflow of an asset. * There are three limits that can be enabled: * - L0: A timewindow based limit, verifies that: * -1 * limit0 <= netflow0 <= limit0, * for a netflow0 that resets every timespan0 seconds. * - L1: A timewindow based limit, verifies that: * -1 * limit1 <= netflow1 <= limit1, * for a netflow1 that resets every timespan1 second. * - LG: A global (or lifetime) limit that ensures that: * -1 * limitGlobal <= netflowGlobal <= limitGlobal, * for a netflowGlobal that doesn't reset until the * limit is disabled. * @dev All contained functions are pure or view and marked internal to * be inlined on consuming contracts at compile time for gas efficiency. * Both State and Config structs are designed to be packed in one * storage slot each. * In order to pack both the state and config into one slot each, * some assumptions are made: * 1. limit{0,1,Global} and netflow{0,1,Global} are recorded with * ZERO decimals precision to fit in an int48. * Any subunit delta in netflow will be rounded up to one unit. * 2. netflow{0,1,Global} have to fit in int48, thus have to fit in the range: * -140_737_488_355_328 to 140_737_488_355_328, which can cover most * tokens of interest, but will break down for tokens which trade * in large unit values. * 3. timespan{0,1} and lastUpdated{0,1} have to fit in int32 therefore * the timestamps will overflow sometime in the year 2102. * * The library ensures that netflow0 and netflow1 are reset during * the update phase, but does not control how the full State gets * updated if the Config changes, this is left to the library consumer. */ library TradingLimits { uint8 private constant L0 = 1; // 0b001 Limit0 uint8 private constant L1 = 2; // 0b010 Limit1 uint8 private constant LG = 4; // 0b100 LimitGlobal int48 private constant MAX_INT48 = int48(uint48(-1) / 2); struct State { uint32 lastUpdated0; uint32 lastUpdated1; int48 netflow0; int48 netflow1; int48 netflowGlobal; } struct Config { uint32 timestep0; uint32 timestep1; int48 limit0; int48 limit1; int48 limitGlobal; uint8 flags; } /** * @notice Validate a trading limit configuration. * @dev Reverts if the configuration is malformed. * @param self the Config struct to check. */ function validate(Config memory self) internal pure { require(self.flags & L1 == 0 || self.flags & L0 != 0, "L1 without L0 not allowed"); require(self.flags & L0 == 0 || self.timestep0 > 0, "timestep0 can't be zero if active"); require(self.flags & L1 == 0 || self.timestep1 > 0, "timestep1 can't be zero if active"); } /** * @notice Verify a trading limit State with a provided Config. * @dev Reverts if the limits are exceeded. * @param self the trading limit State to check. * @param config the trading limit Config to check against. */ function verify(State memory self, Config memory config) internal pure { if ((config.flags & L0) > 0 && (-1 * config.limit0 > self.netflow0 || self.netflow0 > config.limit0)) { revert("L0 Exceeded"); } if ((config.flags & L1) > 0 && (-1 * config.limit1 > self.netflow1 || self.netflow1 > config.limit1)) { revert("L1 Exceeded"); } if ( (config.flags & LG) > 0 && (-1 * config.limitGlobal > self.netflowGlobal || self.netflowGlobal > config.limitGlobal) ) { revert("LG Exceeded"); } } /** * @notice Reset an existing state with a new config. * It keps netflows of enabled limits and resets when disabled. * It resets all timestamp checkpoints to reset time-window limits * on next swap. * @param self the trading limit state to reset. * @param config the updated config to reset against. * @return the reset state. */ function reset(State memory self, Config memory config) internal pure returns (State memory) { // Ensure the next swap will reset the trading limits windows. self.lastUpdated0 = 0; self.lastUpdated1 = 0; if (config.flags & L0 == 0) { self.netflow0 = 0; } if (config.flags & L1 == 0) { self.netflow1 = 0; } if (config.flags & LG == 0) { self.netflowGlobal = 0; } return self; } /** * @notice Updates a trading limit State in the context of a Config with the deltaFlow provided. * @dev Reverts if the values provided cause overflows. * @param self the trading limit State to update. * @param config the trading limit Config for the provided State. * @param _deltaFlow the delta flow to add to the netflow. * @param decimals the number of decimals the _deltaFlow is denominated in. * @return State the updated state. */ function update( State memory self, Config memory config, int256 _deltaFlow, uint8 decimals ) internal view returns (State memory) { int256 _deltaFlowUnits = _deltaFlow / int256((10**uint256(decimals))); require(_deltaFlowUnits <= MAX_INT48, "dFlow too large"); int48 deltaFlowUnits = _deltaFlowUnits == 0 ? 1 : int48(_deltaFlowUnits); if (config.flags & L0 > 0) { if (block.timestamp > self.lastUpdated0 + config.timestep0) { self.netflow0 = 0; self.lastUpdated0 = uint32(block.timestamp); } self.netflow0 = safeINT48Add(self.netflow0, deltaFlowUnits); if (config.flags & L1 > 0) { if (block.timestamp > self.lastUpdated1 + config.timestep1) { self.netflow1 = 0; self.lastUpdated1 = uint32(block.timestamp); } self.netflow1 = safeINT48Add(self.netflow1, deltaFlowUnits); } } if (config.flags & LG > 0) { self.netflowGlobal = safeINT48Add(self.netflowGlobal, deltaFlowUnits); } return self; } /** * @notice Safe add two int48s. * @dev Reverts if addition causes over/underflow. * @param a number to add. * @param b number to add. * @return int48 result of addition. */ function safeINT48Add(int48 a, int48 b) internal pure returns (int48) { int256 c = int256(a) + int256(b); require(c >= -1 * MAX_INT48 && c <= MAX_INT48, "int48 addition overflow"); return int48(c); } }
/lib/mento-core/contracts/common/interfaces/IERC20Metadata.sol
// SPDX-License-Identifier: GPL-3.0-or-later pragma solidity ^0.5.13; interface IERC20Metadata { /** * @dev Returns the name of the token. */ function name() external view returns (string memory); /** * @dev Returns the symbol of the token. */ function symbol() external view returns (string memory); /** * @dev Returns the decimals places of the token. */ function decimals() external view returns (uint8); /** * @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); }
/lib/mento-core/contracts/interfaces/IBroker.sol
// SPDX-License-Identifier: GPL-3.0-or-later pragma solidity ^0.5.13; pragma experimental ABIEncoderV2; import { TradingLimits } from "../common/TradingLimits.sol"; /* * @title Broker Interface for trader functions * @notice The broker is responsible for executing swaps and keeping track of trading limits. */ interface IBroker { /** * @notice Emitted when a swap occurs. * @param exchangeProvider The exchange provider used. * @param exchangeId The id of the exchange used. * @param trader The user that initiated the swap. * @param tokenIn The address of the token that was sold. * @param tokenOut The address of the token that was bought. * @param amountIn The amount of token sold. * @param amountOut The amount of token bought. */ event Swap( address exchangeProvider, bytes32 indexed exchangeId, address indexed trader, address indexed tokenIn, address tokenOut, uint256 amountIn, uint256 amountOut ); /** * @notice Emitted when a new trading limit is configured. * @param exchangeId the exchangeId to target. * @param token the token to target. * @param config the new trading limits config. */ event TradingLimitConfigured(bytes32 exchangeId, address token, TradingLimits.Config config); /** * @notice Execute a token swap with fixed amountIn. * @param exchangeProvider the address of the exchange provider for the pair. * @param exchangeId The id of the exchange to use. * @param tokenIn The token to be sold. * @param tokenOut The token to be bought. * @param amountIn The amount of tokenIn to be sold. * @param amountOutMin Minimum amountOut to be received - controls slippage. * @return amountOut The amount of tokenOut to be bought. */ function swapIn( address exchangeProvider, bytes32 exchangeId, address tokenIn, address tokenOut, uint256 amountIn, uint256 amountOutMin ) external returns (uint256 amountOut); /** * @notice Execute a token swap with fixed amountOut. * @param exchangeProvider the address of the exchange provider for the pair. * @param exchangeId The id of the exchange to use. * @param tokenIn The token to be sold. * @param tokenOut The token to be bought. * @param amountOut The amount of tokenOut to be bought. * @param amountInMax Maximum amount of tokenIn that can be traded. * @return amountIn The amount of tokenIn to be sold. */ function swapOut( address exchangeProvider, bytes32 exchangeId, address tokenIn, address tokenOut, uint256 amountOut, uint256 amountInMax ) external returns (uint256 amountIn); /** * @notice Calculate amountOut of tokenOut received for a given amountIn of tokenIn. * @param exchangeProvider the address of the exchange provider for the pair. * @param exchangeId The id of the exchange to use. * @param tokenIn The token to be sold. * @param tokenOut The token to be bought. * @param amountIn The amount of tokenIn to be sold. * @return amountOut The amount of tokenOut to be bought. */ function getAmountOut( address exchangeProvider, bytes32 exchangeId, address tokenIn, address tokenOut, uint256 amountIn ) external view returns (uint256 amountOut); /** * @notice Calculate amountIn of tokenIn needed for a given amountOut of tokenOut. * @param exchangeProvider the address of the exchange provider for the pair. * @param exchangeId The id of the exchange to use. * @param tokenIn The token to be sold. * @param tokenOut The token to be bought. * @param amountOut The amount of tokenOut to be bought. * @return amountIn The amount of tokenIn to be sold. */ function getAmountIn( address exchangeProvider, bytes32 exchangeId, address tokenIn, address tokenOut, uint256 amountOut ) external view returns (uint256 amountIn); /** * @notice Get the list of registered exchange providers. * @dev This can be used by UI or clients to discover all pairs. * @return exchangeProviders the addresses of all exchange providers. */ function getExchangeProviders() external view returns (address[] memory exchangeProviders); }
/lib/mento-core/contracts/interfaces/IBrokerAdmin.sol
// SPDX-License-Identifier: GPL-3.0-or-later pragma solidity ^0.5.13; /* * @title Broker Admin Interface * @notice Contains admin functions to configure the broker that * should be only callable by the owner. */ interface IBrokerAdmin { /** * @notice Emitted when an ExchangeProvider is added. * @param exchangeProvider The address of the ExchangeProvider. */ event ExchangeProviderAdded(address indexed exchangeProvider); /** * @notice Emitted when an ExchangeProvider is removed. * @param exchangeProvider The address of the ExchangeProvider. */ event ExchangeProviderRemoved(address indexed exchangeProvider); /** * @notice Emitted when the reserve is updated. * @param newAddress The new address. * @param prevAddress The previous address. */ event ReserveSet(address indexed newAddress, address indexed prevAddress); /** * @notice Remove an ExchangeProvider at a specified index. * @param exchangeProvider The address of the ExchangeProvider to remove. * @param index The index in the exchange providers array. */ function removeExchangeProvider(address exchangeProvider, uint256 index) external; /** * @notice Add an ExchangeProvider. * @param exchangeProvider The address of the ExchangeProvider to add. * @return index The index where the ExchangeProvider was inserted. */ function addExchangeProvider(address exchangeProvider) external returns (uint256 index); /** * @notice Set the Mento reserve address. * @param reserve The Mento reserve address. */ function setReserve(address reserve) external; }
/lib/mento-core/contracts/interfaces/IExchangeProvider.sol
// SPDX-License-Identifier: GPL-3.0-or-later pragma solidity ^0.5.13; pragma experimental ABIEncoderV2; /** * @title ExchangeProvider interface * @notice The IExchangeProvider interface is the interface that the Broker uses * to communicate with different exchange manager implementations like the BiPoolManager */ interface IExchangeProvider { /** * @notice Exchange - a struct that's used only by UIs (frontends/CLIs) * in order to discover what asset swaps are possible within an * exchange provider. * It's up to the specific exchange provider to convert its internal * representation to this universal struct. This conversion should * only happen in view calls used for discovery. * @param exchangeId The ID of the exchange, used to initiate swaps or get quotes. * @param assets An array of addresses of ERC20 tokens that can be swapped. */ struct Exchange { bytes32 exchangeId; address[] assets; } /** * @notice Get all exchanges supported by the ExchangeProvider. * @return exchanges An array of Exchange structs. */ function getExchanges() external view returns (Exchange[] memory exchanges); /** * @notice Execute a token swap with fixed amountIn * @param exchangeId The id of the exchange to use * @param tokenIn The token to be sold * @param tokenOut The token to be bought * @param amountIn The amount of tokenIn to be sold * @return amountOut The amount of tokenOut to be bought */ function swapIn( bytes32 exchangeId, address tokenIn, address tokenOut, uint256 amountIn ) external returns (uint256 amountOut); /** * @notice Execute a token swap with fixed amountOut * @param exchangeId The id of the exchange to use * @param tokenIn The token to be sold * @param tokenOut The token to be bought * @param amountOut The amount of tokenOut to be bought * @return amountIn The amount of tokenIn to be sold */ function swapOut( bytes32 exchangeId, address tokenIn, address tokenOut, uint256 amountOut ) external returns (uint256 amountIn); /** * @notice Calculate amountOut of tokenOut received for a given amountIn of tokenIn * @param exchangeId The id of the exchange to use * @param tokenIn The token to be sold * @param tokenOut The token to be bought * @param amountIn The amount of tokenIn to be sold * @return amountOut The amount of tokenOut to be bought */ function getAmountOut( bytes32 exchangeId, address tokenIn, address tokenOut, uint256 amountIn ) external view returns (uint256 amountOut); /** * @notice Calculate amountIn of tokenIn needed for a given amountOut of tokenOut * @param exchangeId The id of the exchange to use * @param tokenIn The token to be sold * @param tokenOut The token to be bought * @param amountOut The amount of tokenOut to be bought * @return amountIn The amount of tokenIn to be sold */ function getAmountIn( bytes32 exchangeId, address tokenIn, address tokenOut, uint256 amountOut ) external view returns (uint256 amountIn); }
/lib/mento-core/contracts/interfaces/IReserve.sol
// SPDX-License-Identifier: GPL-3.0-or-later pragma solidity ^0.5.13; interface IReserve { function setTobinTaxStalenessThreshold(uint256) external; function addToken(address) external returns (bool); function removeToken(address, uint256) external returns (bool); function transferGold(address payable, uint256) external returns (bool); function transferExchangeGold(address payable, uint256) external returns (bool); function transferCollateralAsset( address collateralAsset, address payable to, uint256 value ) external returns (bool); function getReserveGoldBalance() external view returns (uint256); function getUnfrozenReserveGoldBalance() external view returns (uint256); function getOrComputeTobinTax() external returns (uint256, uint256); function getTokens() external view returns (address[] memory); function getReserveRatio() external view returns (uint256); function addExchangeSpender(address) external; function removeExchangeSpender(address, uint256) external; function addSpender(address) external; function removeSpender(address) external; function isStableAsset(address) external view returns (bool); function isCollateralAsset(address) external view returns (bool); function getDailySpendingRatioForCollateralAsset(address collateralAsset) external view returns (uint256); function isExchangeSpender(address exchange) external view returns (bool); function addCollateralAsset(address asset) external returns (bool); function transferExchangeCollateralAsset( address collateralAsset, address payable to, uint256 value ) external returns (bool); }
/lib/mento-core/contracts/interfaces/IStableToken.sol
// SPDX-License-Identifier: GPL-3.0-or-later pragma solidity ^0.5.13; /** * @title This interface describes the functions specific to Celo Stable Tokens, and in the * absence of interface inheritance is intended as a companion to IERC20.sol and ICeloToken.sol. */ interface IStableToken { function mint(address, uint256) external returns (bool); function burn(uint256) external returns (bool); function setInflationParameters(uint256, uint256) external; function valueToUnits(uint256) external view returns (uint256); function unitsToValue(uint256) external view returns (uint256); function getInflationParameters() external view returns ( uint256, uint256, uint256, uint256 ); function getExchangeRegistryId() external view returns (bytes32); // NOTE: duplicated with IERC20.sol, remove once interface inheritance is supported. function balanceOf(address) external view returns (uint256); }
/lib/mento-core/lib/openzeppelin-contracts/contracts/GSN/Context.sol
pragma solidity ^0.5.0; /* * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with GSN meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ contract Context { // Empty internal constructor, to prevent people from mistakenly deploying // an instance of this contract, which should be used via inheritance. constructor () internal { } // solhint-disable-previous-line no-empty-blocks function _msgSender() internal view returns (address payable) { return msg.sender; } function _msgData() internal view returns (bytes memory) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } }
/lib/mento-core/lib/openzeppelin-contracts/contracts/math/SafeMath.sol
pragma solidity ^0.5.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, 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. * * _Available since v2.4.0._ */ 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. * * _Available since v2.4.0._ */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { // Solidity only automatically asserts when dividing by 0 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. * * _Available since v2.4.0._ */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } }
/lib/mento-core/lib/openzeppelin-contracts/contracts/ownership/Ownable.sol
pragma solidity ^0.5.0; import "../GSN/Context.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor () internal { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } /** * @dev Returns the address of the current owner. */ function owner() public view returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(isOwner(), "Ownable: caller is not the owner"); _; } /** * @dev Returns true if the caller is the current owner. */ function isOwner() public view returns (bool) { return _msgSender() == _owner; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public onlyOwner { _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). */ function _transferOwnership(address newOwner) internal { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } }
/lib/mento-core/lib/openzeppelin-contracts/contracts/token/ERC20/IERC20.sol
pragma solidity ^0.5.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. Does not include * the optional functions; to access them see {ERC20Detailed}. */ 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); }
/lib/mento-core/lib/openzeppelin-contracts/contracts/token/ERC20/SafeERC20.sol
pragma solidity ^0.5.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 ERC20;` 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)); } 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. // A Solidity high level call has three parts: // 1. The target address is checked to verify it contains contract code // 2. The call itself is made, and success asserted // 3. The return value is decoded, which in turn checks the size of the returned data. // solhint-disable-next-line max-line-length require(address(token).isContract(), "SafeERC20: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = address(token).call(data); require(success, "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"); } } }
/lib/mento-core/lib/openzeppelin-contracts/contracts/utils/Address.sol
pragma solidity ^0.5.5; /** * @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) { // According to EIP-1052, 0x0 is the value returned for not-yet created accounts // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned // for accounts without code, i.e. `keccak256('')` bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; // solhint-disable-next-line no-inline-assembly assembly { codehash := extcodehash(account) } return (codehash != accountHash && codehash != 0x0); } /** * @dev Converts an `address` into `address payable`. Note that this is * simply a type cast: the actual underlying value is not changed. * * _Available since v2.4.0._ */ function toPayable(address account) internal pure returns (address payable) { return address(uint160(account)); } /** * @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]. * * _Available since v2.4.0._ */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-call-value (bool success, ) = recipient.call.value(amount)(""); require(success, "Address: unable to send value, recipient may have reverted"); } }
Contract ABI
[{"type":"constructor","stateMutability":"nonpayable","payable":false,"inputs":[{"type":"bool","name":"test","internalType":"bool"}]},{"type":"event","name":"ExchangeProviderAdded","inputs":[{"type":"address","name":"exchangeProvider","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"ExchangeProviderRemoved","inputs":[{"type":"address","name":"exchangeProvider","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"OwnershipTransferred","inputs":[{"type":"address","name":"previousOwner","internalType":"address","indexed":true},{"type":"address","name":"newOwner","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"ReserveSet","inputs":[{"type":"address","name":"newAddress","internalType":"address","indexed":true},{"type":"address","name":"prevAddress","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"Swap","inputs":[{"type":"address","name":"exchangeProvider","internalType":"address","indexed":false},{"type":"bytes32","name":"exchangeId","internalType":"bytes32","indexed":true},{"type":"address","name":"trader","internalType":"address","indexed":true},{"type":"address","name":"tokenIn","internalType":"address","indexed":true},{"type":"address","name":"tokenOut","internalType":"address","indexed":false},{"type":"uint256","name":"amountIn","internalType":"uint256","indexed":false},{"type":"uint256","name":"amountOut","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"TradingLimitConfigured","inputs":[{"type":"bytes32","name":"exchangeId","internalType":"bytes32","indexed":false},{"type":"address","name":"token","internalType":"address","indexed":false},{"type":"tuple","name":"config","internalType":"struct TradingLimits.Config","indexed":false,"components":[{"type":"uint32","name":"timestep0","internalType":"uint32"},{"type":"uint32","name":"timestep1","internalType":"uint32"},{"type":"int48","name":"limit0","internalType":"int48"},{"type":"int48","name":"limit1","internalType":"int48"},{"type":"int48","name":"limitGlobal","internalType":"int48"},{"type":"uint8","name":"flags","internalType":"uint8"}]}],"anonymous":false},{"type":"function","stateMutability":"nonpayable","payable":false,"outputs":[{"type":"uint256","name":"index","internalType":"uint256"}],"name":"addExchangeProvider","inputs":[{"type":"address","name":"exchangeProvider","internalType":"address"}],"constant":false},{"type":"function","stateMutability":"nonpayable","payable":false,"outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"burnStableTokens","inputs":[{"type":"address","name":"token","internalType":"address"},{"type":"uint256","name":"amount","internalType":"uint256"}],"constant":false},{"type":"function","stateMutability":"nonpayable","payable":false,"outputs":[],"name":"configureTradingLimit","inputs":[{"type":"bytes32","name":"exchangeId","internalType":"bytes32"},{"type":"address","name":"token","internalType":"address"},{"type":"tuple","name":"config","internalType":"struct TradingLimits.Config","components":[{"type":"uint32","name":"timestep0","internalType":"uint32"},{"type":"uint32","name":"timestep1","internalType":"uint32"},{"type":"int48","name":"limit0","internalType":"int48"},{"type":"int48","name":"limit1","internalType":"int48"},{"type":"int48","name":"limitGlobal","internalType":"int48"},{"type":"uint8","name":"flags","internalType":"uint8"}]}],"constant":false},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"address","name":"","internalType":"address"}],"name":"exchangeProviders","inputs":[{"type":"uint256","name":"","internalType":"uint256"}],"constant":true},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"uint256","name":"amountIn","internalType":"uint256"}],"name":"getAmountIn","inputs":[{"type":"address","name":"exchangeProvider","internalType":"address"},{"type":"bytes32","name":"exchangeId","internalType":"bytes32"},{"type":"address","name":"tokenIn","internalType":"address"},{"type":"address","name":"tokenOut","internalType":"address"},{"type":"uint256","name":"amountOut","internalType":"uint256"}],"constant":true},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"uint256","name":"amountOut","internalType":"uint256"}],"name":"getAmountOut","inputs":[{"type":"address","name":"exchangeProvider","internalType":"address"},{"type":"bytes32","name":"exchangeId","internalType":"bytes32"},{"type":"address","name":"tokenIn","internalType":"address"},{"type":"address","name":"tokenOut","internalType":"address"},{"type":"uint256","name":"amountIn","internalType":"uint256"}],"constant":true},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"address[]","name":"","internalType":"address[]"}],"name":"getExchangeProviders","inputs":[],"constant":true},{"type":"function","stateMutability":"nonpayable","payable":false,"outputs":[],"name":"initialize","inputs":[{"type":"address[]","name":"_exchangeProviders","internalType":"address[]"},{"type":"address","name":"_reserve","internalType":"address"}],"constant":false},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"initialized","inputs":[],"constant":true},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"isExchangeProvider","inputs":[{"type":"address","name":"","internalType":"address"}],"constant":true},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"isOwner","inputs":[],"constant":true},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"address","name":"","internalType":"address"}],"name":"owner","inputs":[],"constant":true},{"type":"function","stateMutability":"nonpayable","payable":false,"outputs":[],"name":"removeExchangeProvider","inputs":[{"type":"address","name":"exchangeProvider","internalType":"address"},{"type":"uint256","name":"index","internalType":"uint256"}],"constant":false},{"type":"function","stateMutability":"nonpayable","payable":false,"outputs":[],"name":"renounceOwnership","inputs":[],"constant":false},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"address","name":"","internalType":"contract IReserve"}],"name":"reserve","inputs":[],"constant":true},{"type":"function","stateMutability":"nonpayable","payable":false,"outputs":[],"name":"setReserve","inputs":[{"type":"address","name":"_reserve","internalType":"address"}],"constant":false},{"type":"function","stateMutability":"nonpayable","payable":false,"outputs":[{"type":"uint256","name":"amountOut","internalType":"uint256"}],"name":"swapIn","inputs":[{"type":"address","name":"exchangeProvider","internalType":"address"},{"type":"bytes32","name":"exchangeId","internalType":"bytes32"},{"type":"address","name":"tokenIn","internalType":"address"},{"type":"address","name":"tokenOut","internalType":"address"},{"type":"uint256","name":"amountIn","internalType":"uint256"},{"type":"uint256","name":"amountOutMin","internalType":"uint256"}],"constant":false},{"type":"function","stateMutability":"nonpayable","payable":false,"outputs":[{"type":"uint256","name":"amountIn","internalType":"uint256"}],"name":"swapOut","inputs":[{"type":"address","name":"exchangeProvider","internalType":"address"},{"type":"bytes32","name":"exchangeId","internalType":"bytes32"},{"type":"address","name":"tokenIn","internalType":"address"},{"type":"address","name":"tokenOut","internalType":"address"},{"type":"uint256","name":"amountOut","internalType":"uint256"},{"type":"uint256","name":"amountInMax","internalType":"uint256"}],"constant":false},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"uint32","name":"timestep0","internalType":"uint32"},{"type":"uint32","name":"timestep1","internalType":"uint32"},{"type":"int48","name":"limit0","internalType":"int48"},{"type":"int48","name":"limit1","internalType":"int48"},{"type":"int48","name":"limitGlobal","internalType":"int48"},{"type":"uint8","name":"flags","internalType":"uint8"}],"name":"tradingLimitsConfig","inputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"constant":true},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"uint32","name":"lastUpdated0","internalType":"uint32"},{"type":"uint32","name":"lastUpdated1","internalType":"uint32"},{"type":"int48","name":"netflow0","internalType":"int48"},{"type":"int48","name":"netflow1","internalType":"int48"},{"type":"int48","name":"netflowGlobal","internalType":"int48"}],"name":"tradingLimitsState","inputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"constant":true},{"type":"function","stateMutability":"nonpayable","payable":false,"outputs":[],"name":"transferOwnership","inputs":[{"type":"address","name":"newOwner","internalType":"address"}],"constant":false}]
Contract Creation Code
0x60806040523480156200001157600080fd5b50604051620037ef380380620037ef8339810160408190526200003491620000d3565b808062000049576000805460ff191660011790555b5060006200005f6001600160e01b03620000bc16565b60008054610100600160a81b0319166101006001600160a01b038416908102919091178255604051929350917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908290a35050600180556200011b565b3390565b8051620000cd8162000101565b92915050565b600060208284031215620000e657600080fd5b6000620000f48484620000c0565b949350505050565b151590565b6200010c81620000fc565b81146200011857600080fd5b50565b6136c4806200012b6000396000f3fe608060405234801561001057600080fd5b50600436106101775760003560e01c80638f32d59b116100d8578063cd3293de1161008c578063ddbbe85011610066578063ddbbe850146102ee578063f01ecd1714610301578063f2fde38b1461032557610177565b8063cd3293de146102b3578063d163b135146102c8578063d1d786b1146102db57610177565b8063a20f2305116100bd578063a20f23051461027a578063a9b5aab31461028d578063c4454fdc146102a057610177565b80638f32d59b1461025f5780639cecc80a1461026757610177565b8063462d0b2e1161012f57806373ec4cf41161011457806373ec4cf414610212578063821a816c146102255780638da5cb5b1461024a57610177565b8063462d0b2e146101f7578063715018a61461020a57610177565b8063131cab2a11610160578063131cab2a146101ba578063158ef93e146101da5780632cac2568146101e257610177565b806304710d531461017c57806304e4564014610191575b600080fd5b61018f61018a3660046126da565b610338565b005b6101a461019f3660046125de565b6104ef565b6040516101b191906134bd565b60405180910390f35b6101cd6101c83660046126da565b6105cc565b6040516101b1919061326f565b6101cd61075a565b6101ea610763565b6040516101b1919061325e565b61018f610205366004612714565b6107c5565b61018f610863565b6101a46102203660046125c0565b6108ed565b610238610233366004612787565b610a48565b6040516101b19695949392919061350d565b610252610ad3565b6040516101b191906131cf565b6101cd610ae7565b61018f6102753660046125c0565b610b10565b6101a46102883660046125de565b610bcf565b61018f61029b3660046127a5565b610c52565b6102526102ae366004612787565b611008565b6102bb61102f565b6040516101b191906132ce565b6101a46102d6366004612653565b61103e565b6101cd6102e93660046125c0565b6111e3565b6101a46102fc366004612653565b6111f8565b61031461030f366004612787565b611369565b6040516101b19594939291906134cb565b61018f6103333660046125c0565b6113d2565b610340610ae7565b6103655760405162461bcd60e51b815260040161035c906133dd565b60405180910390fd5b816001600160a01b03166002828154811061037c57fe5b6000918252602090912001546001600160a01b0316146103ae5760405162461bcd60e51b815260040161035c9061334d565b600280546103c390600163ffffffff61140216565b815481106103cd57fe5b600091825260209091200154600280546001600160a01b0390921691839081106103f357fe5b9060005260206000200160006101000a8154816001600160a01b0302191690836001600160a01b03160217905550600280548061042c57fe5b6000828152602080822083017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff90810180547fffffffffffffffffffffffff00000000000000000000000000000000000000001690559092019092556001600160a01b0384168083526003909152604080832080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001690555190917f29e92ab2e30f4f74283034c28c451b6faac986b554f1808101eb6418bdba19d491a25050565b6001600160a01b03851660009081526003602052604081205460ff166105275760405162461bcd60e51b815260040161035c906133ad565b6040517ff670dde10000000000000000000000000000000000000000000000000000000081526001600160a01b0387169063f670dde19061057290889088908890889060040161327d565b60206040518083038186803b15801561058a57600080fd5b505afa15801561059e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506105c291908101906127e9565b9695505050505050565b6006546040517f4f8e6e230000000000000000000000000000000000000000000000000000000081526000916001600160a01b031690634f8e6e23906106169086906004016131cf565b60206040518083038186803b15801561062e57600080fd5b505afa158015610642573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506106669190810190612769565b6106825760405162461bcd60e51b815260040161035c9061337d565b61069d6001600160a01b03841633308563ffffffff61144b16565b6040517f42966c680000000000000000000000000000000000000000000000000000000081526001600160a01b038416906342966c68906106e29085906004016134bd565b602060405180830381600087803b1580156106fc57600080fd5b505af1158015610710573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506107349190810190612769565b6107505760405162461bcd60e51b815260040161035c906133fd565b5060015b92915050565b60005460ff1681565b606060028054806020026020016040519081016040528092919081815260200182805480156107bb57602002820191906000526020600020905b81546001600160a01b0316815260019091019060200180831161079d575b5050505050905090565b60005460ff16156107e85760405162461bcd60e51b815260040161035c906132fd565b600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016600117905561081c33611510565b60005b828110156108545761084b84848381811061083657fe5b905060200201602061022091908101906125c0565b5060010161081f565b5061085e81610b10565b505050565b61086b610ae7565b6108875760405162461bcd60e51b815260040161035c906133dd565b600080546040516101009091046001600160a01b0316907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080547fffffffffffffffffffffff0000000000000000000000000000000000000000ff169055565b60006108f7610ae7565b6109135760405162461bcd60e51b815260040161035c906133dd565b6001600160a01b03821660009081526003602052604090205460ff161561094c5760405162461bcd60e51b815260040161035c906132ed565b6001600160a01b0382166109725760405162461bcd60e51b815260040161035c906133cd565b6002805460018082019092557f405787fa12a823e0f2b7631cc41b3ba8828b3321ca811111fa75cd3aa3bb5ace0180547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b03851690811790915560008181526003602052604080822080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016909417909355915190917f2ee2cb0721ec60b86190cae5c48e25064b69b35abad32452a4ec99d232033de291a260025461075490600163ffffffff61140216565b60056020819052600091825260409091205463ffffffff80821692640100000000830490911691680100000000000000008104820b916e0100000000000000000000000000008204810b9174010000000000000000000000000000000000000000810490910b907a010000000000000000000000000000000000000000000000000000900460ff1686565b60005461010090046001600160a01b031690565b6000805461010090046001600160a01b0316610b016115b3565b6001600160a01b031614905090565b610b18610ae7565b610b345760405162461bcd60e51b815260040161035c906133dd565b6001600160a01b038116610b5a5760405162461bcd60e51b815260040161035c9061346d565b6006546040516001600160a01b03918216918316907fb69e1c416d8be92ac92c8e97e77c4626fba5e6ab50161099f659ea3303479e5090600090a3600680547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0392909216919091179055565b6001600160a01b03851660009081526003602052604081205460ff16610c075760405162461bcd60e51b815260040161035c906133ad565b6040517f93c7e3bc0000000000000000000000000000000000000000000000000000000081526001600160a01b038716906393c7e3bc9061057290889088908890889060040161327d565b610c5a610ae7565b610c765760405162461bcd60e51b815260040161035c906133dd565b610c7f816115b7565b6000826001600160a01b031660001b84189050816005600083815260200190815260200160002060008201518160000160006101000a81548163ffffffff021916908363ffffffff16021790555060208201518160000160046101000a81548163ffffffff021916908363ffffffff16021790555060408201518160000160086101000a81548165ffffffffffff021916908360050b65ffffffffffff160217905550606082015181600001600e6101000a81548165ffffffffffff021916908360050b65ffffffffffff16021790555060808201518160000160146101000a81548165ffffffffffff021916908360050b65ffffffffffff16021790555060a082015181600001601a6101000a81548160ff021916908360ff160217905550905050610e7582600460008481526020019081526020016000206040518060a00160405290816000820160009054906101000a900463ffffffff1663ffffffff1663ffffffff1681526020016000820160049054906101000a900463ffffffff1663ffffffff1663ffffffff1681526020016000820160089054906101000a900460050b60050b60050b815260200160008201600e9054906101000a900460050b60050b60050b81526020016000820160149054906101000a900460050b60050b60050b8152505061165d90919063ffffffff16565b6000828152600460209081526040918290208351815492850151858501516060870151608090970151600590810b65ffffffffffff90811674010000000000000000000000000000000000000000027fffffffffffff000000000000ffffffffffffffffffffffffffffffffffffffff99830b82166e010000000000000000000000000000027fffffffffffffffffffffffff000000000000ffffffffffffffffffffffffffff9490930b90911668010000000000000000027fffffffffffffffffffffffffffffffffffff000000000000ffffffffffffffff63ffffffff958616640100000000027fffffffffffffffffffffffffffffffffffffffffffffffff00000000ffffffff969097167fffffffffffffffffffffffffffffffffffffffffffffffffffffffff00000000909916989098179490941694909417959095169190911716929092179390931617909155517f1a082a1efaf1549c18917ddcb1f759680c29371609e24f4b946e93acf4ce5ad290610ffa908690869086906132a5565b60405180910390a150505050565b6002818154811061101557fe5b6000918252602090912001546001600160a01b0316905081565b6006546001600160a01b031681565b600180548101908190556001600160a01b03871660009081526003602052604081205490919060ff166110835760405162461bcd60e51b815260040161035c906133ad565b6040517fd3385d050000000000000000000000000000000000000000000000000000000081526001600160a01b0389169063d3385d05906110ce908a908a908a908a9060040161327d565b602060405180830381600087803b1580156110e857600080fd5b505af11580156110fc573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525061112091908101906127e9565b9150828211156111425760405162461bcd60e51b815260040161035c9061332d565b61114f87878488886116b2565b61115a338784611785565b6111653386866119ce565b856001600160a01b0316336001600160a01b0316887fe7b046415cac9de47940c3087e06db13a0e058ccf53ac5f0edd49ebb4c2c3a6f8b89878a6040516111af9493929190613220565b60405180910390a460015481146111d85760405162461bcd60e51b815260040161035c9061339d565b509695505050505050565b60036020526000908152604090205460ff1681565b600180548101908190556001600160a01b03871660009081526003602052604081205490919060ff1661123d5760405162461bcd60e51b815260040161035c906133ad565b6040517f42bfc99c0000000000000000000000000000000000000000000000000000000081526001600160a01b038916906342bfc99c90611288908a908a908a908a9060040161327d565b602060405180830381600087803b1580156112a257600080fd5b505af11580156112b6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506112da91908101906127e9565b9150828210156112fc5760405162461bcd60e51b815260040161035c9061342d565b61130987878688866116b2565b611314338786611785565b61131f3386846119ce565b856001600160a01b0316336001600160a01b0316887fe7b046415cac9de47940c3087e06db13a0e058ccf53ac5f0edd49ebb4c2c3a6f8b8989886040516111af9493929190613220565b60046020526000908152604090205463ffffffff80821691640100000000810490911690680100000000000000008104600590810b916e0100000000000000000000000000008104820b9174010000000000000000000000000000000000000000909104900b85565b6113da610ae7565b6113f65760405162461bcd60e51b815260040161035c906133dd565b6113ff81611510565b50565b600061144483836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250611c7a565b9392505050565b60405161150a9085907f23b872dd0000000000000000000000000000000000000000000000000000000090611488908790879087906024016131f8565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff0000000000000000000000000000000000000000000000000000000090931692909217909152611ca6565b50505050565b6001600160a01b0381166115365760405162461bcd60e51b815260040161035c9061330d565b600080546040516001600160a01b038085169361010090930416917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b03909216610100027fffffffffffffffffffffff0000000000000000000000000000000000000000ff909216919091179055565b3390565b60a081015160021615806115d1575060a081015160011615155b6115ed5760405162461bcd60e51b815260040161035c9061333d565b60a081015160011615806116075750805163ffffffff1615155b6116235760405162461bcd60e51b815260040161035c906133bd565b60a0810151600216158061164157506000816020015163ffffffff16115b6113ff5760405162461bcd60e51b815260040161035c9061336d565b611665612425565b6000808452602084015260a082015160011661168357600060408401525b60a082015160021661169757600060608401525b60a08201516004166116ab57600060808401525b5090919050565b6001600160a01b038481169083167f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8511156117005760405162461bcd60e51b815260040161035c906133ed565b7f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8311156117405760405162461bcd60e51b815260040161035c9061340d565b61174d8288188688611d8b565b61177c818818847fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0286611d8b565b50505050505050565b6006546040517f4f8e6e230000000000000000000000000000000000000000000000000000000081526001600160a01b0390911690634f8e6e23906117ce9085906004016131cf565b60206040518083038186803b1580156117e657600080fd5b505afa1580156117fa573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525061181e9190810190612769565b156118f65761183e6001600160a01b03831684308463ffffffff61144b16565b6040517f42966c680000000000000000000000000000000000000000000000000000000081526001600160a01b038316906342966c68906118839084906004016134bd565b602060405180830381600087803b15801561189d57600080fd5b505af11580156118b1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506118d59190810190612769565b6118f15760405162461bcd60e51b815260040161035c906133fd565b61085e565b6006546040517fcae182fe0000000000000000000000000000000000000000000000000000000081526001600160a01b039091169063cae182fe9061193f9085906004016131cf565b60206040518083038186803b15801561195757600080fd5b505afa15801561196b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525061198f9190810190612769565b156119b6576006546118f1906001600160a01b03848116918691168463ffffffff61144b16565b60405162461bcd60e51b815260040161035c9061348d565b6006546040517f4f8e6e230000000000000000000000000000000000000000000000000000000081526001600160a01b0390911690634f8e6e2390611a179085906004016131cf565b60206040518083038186803b158015611a2f57600080fd5b505afa158015611a43573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250611a679190810190612769565b15611b21576040517f40c10f190000000000000000000000000000000000000000000000000000000081526001600160a01b038316906340c10f1990611ab390869085906004016131dd565b602060405180830381600087803b158015611acd57600080fd5b505af1158015611ae1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250611b059190810190612769565b6118f15760405162461bcd60e51b815260040161035c9061345d565b6006546040517fcae182fe0000000000000000000000000000000000000000000000000000000081526001600160a01b039091169063cae182fe90611b6a9085906004016131cf565b60206040518083038186803b158015611b8257600080fd5b505afa158015611b96573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250611bba9190810190612769565b156119b6576006546040517f6be383fc0000000000000000000000000000000000000000000000000000000081526001600160a01b0390911690636be383fc90611c0c908590879086906004016131f8565b602060405180830381600087803b158015611c2657600080fd5b505af1158015611c3a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250611c5e9190810190612769565b6118f15760405162461bcd60e51b815260040161035c9061349d565b60008184841115611c9e5760405162461bcd60e51b815260040161035c91906132dc565b505050900390565b611cb8826001600160a01b03166120f5565b611cd45760405162461bcd60e51b815260040161035c906134ad565b60006060836001600160a01b031683604051611cf091906131c3565b6000604051808303816000865af19150503d8060008114611d2d576040519150601f19603f3d011682016040523d82523d6000602084013e611d32565b606091505b509150915081611d545760405162461bcd60e51b815260040161035c9061335d565b80511561150a5780806020019051611d6f9190810190612769565b61150a5760405162461bcd60e51b815260040161035c9061347d565b611d93612453565b50600083815260056020818152604092839020835160c081018552905463ffffffff808216835264010000000082041692820192909252680100000000000000008204830b830b830b938101939093526e0100000000000000000000000000008104820b820b820b6060840152740100000000000000000000000000000000000000008104820b820b90910b60808301527a010000000000000000000000000000000000000000000000000000900460ff1660a082018190521561150a57611e59612425565b50600084815260046020818152604092839020835160a081018552905463ffffffff808216835264010000000082041682840152680100000000000000008104600590810b810b810b838701526e0100000000000000000000000000008204810b810b810b606084015274010000000000000000000000000000000000000000909104810b810b900b608082015283517f313ce56700000000000000000000000000000000000000000000000000000000815293519093611f8a93869389936001600160a01b038a169363313ce56793818101939291829003018186803b158015611f4357600080fd5b505afa158015611f57573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250611f7b9190810190612807565b8492919063ffffffff61213116565b9050611f9c818363ffffffff61225816565b60009485526004602090815260409586902082518154928401519784015160608501516080909501517fffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000000090941663ffffffff928316177fffffffffffffffffffffffffffffffffffffffffffffffff00000000ffffffff166401000000009290991691909102979097177fffffffffffffffffffffffffffffffffffff000000000000ffffffffffffffff1668010000000000000000600598890b65ffffffffffff90811691909102919091177fffffffffffffffffffffffff000000000000ffffffffffffffffffffffffffff166e01000000000000000000000000000094890b821694909402939093177fffffffffffff000000000000ffffffffffffffffffffffffffffffffffffffff16740100000000000000000000000000000000000000009290970b929092160294909417909355505050565b6000813f7fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a47081811480159061212957508115155b949350505050565b612139612425565b60008260ff16600a0a848161214a57fe5b059050657fffffffffff8113156121735760405162461bcd60e51b815260040161035c9061343d565b600081156121815781612184565b60015b60a08701519091506001161561222557855187510163ffffffff164211156121b7576000604088015263ffffffff421687525b6121c58760400151826123c7565b600590810b900b604088015260a08601516002161561222557856020015187602001510163ffffffff1642111561220a576000606088015263ffffffff421660208801525b6122188760600151826123c7565b600590810b900b60608801525b60a08601516004161561224d576122408760800151826123c7565b600590810b900b60808801525b509495945050505050565b60a0810151600116158015906122b45750816040015160050b81604001517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0260050b13806122b45750806040015160050b826040015160050b135b156122d15760405162461bcd60e51b815260040161035c9061341d565b60a08101516002161580159061232d5750816060015160050b81606001517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0260050b138061232d5750806060015160050b826060015160050b135b1561234a5760405162461bcd60e51b815260040161035c9061338d565b60a0810151600416158015906123a65750816080015160050b81608001517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0260050b13806123a65750806080015160050b826080015160050b135b156123c35760405162461bcd60e51b815260040161035c9061344d565b5050565b6000600582810b9084900b017fffffffffffffffffffffffffffffffffffffffffffffffffffff80000000000181128015906124095750657fffffffffff8113155b6114445760405162461bcd60e51b815260040161035c9061331d565b6040805160a08101825260008082526020820181905291810182905260608101829052608081019190915290565b6040805160c081018252600080825260208201819052918101829052606081018290526080810182905260a081019190915290565b803561075481613640565b60008083601f8401126124a557600080fd5b50813567ffffffffffffffff8111156124bd57600080fd5b6020830191508360208202830111156124d557600080fd5b9250929050565b805161075481613654565b80356107548161365d565b803561075481613666565b600060c0828403121561250f57600080fd5b61251960c0613567565b90506000612527848461259f565b82525060206125388484830161259f565b602083015250604061254c848285016124f2565b6040830152506060612560848285016124f2565b6060830152506080612574848285016124f2565b60808301525060a0612588848285016125aa565b60a08301525092915050565b80516107548161365d565b80356107548161366f565b803561075481613678565b805161075481613678565b6000602082840312156125d257600080fd5b60006121298484612488565b600080600080600060a086880312156125f657600080fd5b60006126028888612488565b9550506020612613888289016124e7565b945050604061262488828901612488565b935050606061263588828901612488565b9250506080612646888289016124e7565b9150509295509295909350565b60008060008060008060c0878903121561266c57600080fd5b60006126788989612488565b965050602061268989828a016124e7565b955050604061269a89828a01612488565b94505060606126ab89828a01612488565b93505060806126bc89828a016124e7565b92505060a06126cd89828a016124e7565b9150509295509295509295565b600080604083850312156126ed57600080fd5b60006126f98585612488565b925050602061270a858286016124e7565b9150509250929050565b60008060006040848603121561272957600080fd5b833567ffffffffffffffff81111561274057600080fd5b61274c86828701612493565b9350935050602061275f86828701612488565b9150509250925092565b60006020828403121561277b57600080fd5b600061212984846124dc565b60006020828403121561279957600080fd5b600061212984846124e7565b600080600061010084860312156127bb57600080fd5b60006127c786866124e7565b93505060206127d886828701612488565b925050604061275f868287016124fd565b6000602082840312156127fb57600080fd5b60006121298484612594565b60006020828403121561281957600080fd5b600061212984846125b5565b60006128318383612848565b505060200190565b612842816135da565b82525050565b612842816135a6565b600061285c82613594565b6128668185613598565b93506128718361358e565b8060005b8381101561224d5781516128898882612825565b97506128948361358e565b925050600101612875565b612842816135b1565b612842816135b6565b60006128bc82613594565b6128c681856135a1565b93506128d68185602086016135ec565b9290920192915050565b612842816135e1565b612842816135b9565b60006128fd82613594565b6129078185613598565b93506129178185602086016135ec565b61292081613618565b9093019392505050565b6000612937602b83613598565b7f45786368616e676550726f766964657220616c7265616479206578697374732081527f696e20746865206c697374000000000000000000000000000000000000000000602082015260400192915050565b6000612996601c83613598565b7f636f6e747261637420616c726561647920696e697469616c697a656400000000815260200192915050565b60006129cf602683613598565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206181527f6464726573730000000000000000000000000000000000000000000000000000602082015260400192915050565b6000612a2e601783613598565b7f696e743438206164646974696f6e206f766572666c6f77000000000000000000815260200192915050565b6000612a67601483613598565b7f616d6f756e74496e4d6178206578636565646564000000000000000000000000815260200192915050565b6000612aa0601983613598565b7f4c3120776974686f7574204c30206e6f7420616c6c6f77656400000000000000815260200192915050565b6000612ad9601c83613598565b7f696e64657820646f65736e2774206d617463682070726f766964657200000000815260200192915050565b6000612b12602083613598565b7f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815260200192915050565b6000612b4b602183613598565b7f74696d6573746570312063616e2774206265207a65726f20696620616374697681527f6500000000000000000000000000000000000000000000000000000000000000602082015260400192915050565b6000612baa602483613598565b7f546f6b656e206d7573742062652061207265736572766520737461626c65206181527f7373657400000000000000000000000000000000000000000000000000000000602082015260400192915050565b6000612c09600b83613598565b7f4c31204578636565646564000000000000000000000000000000000000000000815260200192915050565b6000612c42600e83613598565b7f7265656e7472616e742063616c6c000000000000000000000000000000000000815260200192915050565b6000612c7b601f83613598565b7f45786368616e676550726f766964657220646f6573206e6f7420657869737400815260200192915050565b6000612cb4602183613598565b7f74696d6573746570302063616e2774206265207a65726f20696620616374697681527f6500000000000000000000000000000000000000000000000000000000000000602082015260400192915050565b6000612d13602383613598565b7f45786368616e676550726f766964657220616464726573732063616e2774206281527f6520300000000000000000000000000000000000000000000000000000000000602082015260400192915050565b6000612d72602083613598565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572815260200192915050565b6000612dab601283613598565b7f616d6f756e74496e20746f6f206c617267650000000000000000000000000000815260200192915050565b6000612de4602283613598565b7f4275726e696e67206f662074686520737461626c65206173736574206661696c81527f6564000000000000000000000000000000000000000000000000000000000000602082015260400192915050565b6000612e43601383613598565b7f616d6f756e744f757420746f6f206c6172676500000000000000000000000000815260200192915050565b6000612e7c600b83613598565b7f4c30204578636565646564000000000000000000000000000000000000000000815260200192915050565b6000612eb5601483613598565b7f616d6f756e744f75744d696e206e6f74206d6574000000000000000000000000815260200192915050565b6000612eee600f83613598565b7f64466c6f7720746f6f206c617267650000000000000000000000000000000000815260200192915050565b6000612f27600b83613598565b7f4c47204578636565646564000000000000000000000000000000000000000000815260200192915050565b6000612f60602283613598565b7f4d696e74696e67206f662074686520737461626c65206173736574206661696c81527f6564000000000000000000000000000000000000000000000000000000000000602082015260400192915050565b6000612fbf601b83613598565b7f526573657276652061646472657373206d757374206265207365740000000000815260200192915050565b6000612ff8602a83613598565b7f5361666545524332303a204552433230206f7065726174696f6e20646964206e81527f6f74207375636365656400000000000000000000000000000000000000000000602082015260400192915050565b6000613057602983613598565b7f546f6b656e206d75737420626520737461626c65206f7220636f6c6c6174657281527f616c206173736572740000000000000000000000000000000000000000000000602082015260400192915050565b60006130b6602783613598565b7f5472616e73666572206f662074686520636f6c6c61746572616c20617373657481527f206661696c656400000000000000000000000000000000000000000000000000602082015260400192915050565b6000613115601f83613598565b7f5361666545524332303a2063616c6c20746f206e6f6e2d636f6e747261637400815260200192915050565b805160c083019061315284826131b1565b50602082015161316560208501826131b1565b50604082015161317860408501826128e9565b50606082015161318b60608501826128e9565b50608082015161319e60808501826128e9565b5060a082015161150a60a08501826131ba565b612842816135cb565b612842816135d4565b600061144482846128b1565b602081016107548284612848565b604081016131eb8285612839565b61144460208301846128a8565b606081016132068286612848565b6132136020830185612848565b61212960408301846128a8565b6080810161322e8287612848565b61323b6020830186612848565b61324860408301856128a8565b61325560608301846128a8565b95945050505050565b602080825281016114448184612851565b60208101610754828461289f565b6080810161328b82876128a8565b6132986020830186612848565b6132486040830185612848565b61010081016132b482866128a8565b6132c16020830185612848565b6121296040830184613141565b6020810161075482846128e0565b6020808252810161144481846128f2565b602080825281016107548161292a565b6020808252810161075481612989565b60208082528101610754816129c2565b6020808252810161075481612a21565b6020808252810161075481612a5a565b6020808252810161075481612a93565b6020808252810161075481612acc565b6020808252810161075481612b05565b6020808252810161075481612b3e565b6020808252810161075481612b9d565b6020808252810161075481612bfc565b6020808252810161075481612c35565b6020808252810161075481612c6e565b6020808252810161075481612ca7565b6020808252810161075481612d06565b6020808252810161075481612d65565b6020808252810161075481612d9e565b6020808252810161075481612dd7565b6020808252810161075481612e36565b6020808252810161075481612e6f565b6020808252810161075481612ea8565b6020808252810161075481612ee1565b6020808252810161075481612f1a565b6020808252810161075481612f53565b6020808252810161075481612fb2565b6020808252810161075481612feb565b602080825281016107548161304a565b60208082528101610754816130a9565b6020808252810161075481613108565b6020810161075482846128a8565b60a081016134d982886131b1565b6134e660208301876131b1565b6134f360408301866128e9565b61350060608301856128e9565b6105c260808301846128e9565b60c0810161351b82896131b1565b61352860208301886131b1565b61353560408301876128e9565b61354260608301866128e9565b61354f60808301856128e9565b61355c60a08301846131ba565b979650505050505050565b60405181810167ffffffffffffffff8111828210171561358657600080fd5b604052919050565b60200190565b5190565b90815260200190565b919050565b6000610754826135bf565b151590565b90565b60050b90565b6001600160a01b031690565b63ffffffff1690565b60ff1690565b6000610754825b6000610754826135a6565b60005b838110156136075781810151838201526020016135ef565b8381111561150a5750506000910152565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01690565b613649816135a6565b81146113ff57600080fd5b613649816135b1565b613649816135b6565b613649816135b9565b613649816135cb565b613649816135d456fea365627a7a72315820e4e04bd1b62312146c7bcc0e70fec4aa193d5c34d458abcfc0c2127c7b01ff6d6c6578706572696d656e74616cf564736f6c634300051100400000000000000000000000000000000000000000000000000000000000000000
Deployed ByteCode
0x608060405234801561001057600080fd5b50600436106101775760003560e01c80638f32d59b116100d8578063cd3293de1161008c578063ddbbe85011610066578063ddbbe850146102ee578063f01ecd1714610301578063f2fde38b1461032557610177565b8063cd3293de146102b3578063d163b135146102c8578063d1d786b1146102db57610177565b8063a20f2305116100bd578063a20f23051461027a578063a9b5aab31461028d578063c4454fdc146102a057610177565b80638f32d59b1461025f5780639cecc80a1461026757610177565b8063462d0b2e1161012f57806373ec4cf41161011457806373ec4cf414610212578063821a816c146102255780638da5cb5b1461024a57610177565b8063462d0b2e146101f7578063715018a61461020a57610177565b8063131cab2a11610160578063131cab2a146101ba578063158ef93e146101da5780632cac2568146101e257610177565b806304710d531461017c57806304e4564014610191575b600080fd5b61018f61018a3660046126da565b610338565b005b6101a461019f3660046125de565b6104ef565b6040516101b191906134bd565b60405180910390f35b6101cd6101c83660046126da565b6105cc565b6040516101b1919061326f565b6101cd61075a565b6101ea610763565b6040516101b1919061325e565b61018f610205366004612714565b6107c5565b61018f610863565b6101a46102203660046125c0565b6108ed565b610238610233366004612787565b610a48565b6040516101b19695949392919061350d565b610252610ad3565b6040516101b191906131cf565b6101cd610ae7565b61018f6102753660046125c0565b610b10565b6101a46102883660046125de565b610bcf565b61018f61029b3660046127a5565b610c52565b6102526102ae366004612787565b611008565b6102bb61102f565b6040516101b191906132ce565b6101a46102d6366004612653565b61103e565b6101cd6102e93660046125c0565b6111e3565b6101a46102fc366004612653565b6111f8565b61031461030f366004612787565b611369565b6040516101b19594939291906134cb565b61018f6103333660046125c0565b6113d2565b610340610ae7565b6103655760405162461bcd60e51b815260040161035c906133dd565b60405180910390fd5b816001600160a01b03166002828154811061037c57fe5b6000918252602090912001546001600160a01b0316146103ae5760405162461bcd60e51b815260040161035c9061334d565b600280546103c390600163ffffffff61140216565b815481106103cd57fe5b600091825260209091200154600280546001600160a01b0390921691839081106103f357fe5b9060005260206000200160006101000a8154816001600160a01b0302191690836001600160a01b03160217905550600280548061042c57fe5b6000828152602080822083017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff90810180547fffffffffffffffffffffffff00000000000000000000000000000000000000001690559092019092556001600160a01b0384168083526003909152604080832080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001690555190917f29e92ab2e30f4f74283034c28c451b6faac986b554f1808101eb6418bdba19d491a25050565b6001600160a01b03851660009081526003602052604081205460ff166105275760405162461bcd60e51b815260040161035c906133ad565b6040517ff670dde10000000000000000000000000000000000000000000000000000000081526001600160a01b0387169063f670dde19061057290889088908890889060040161327d565b60206040518083038186803b15801561058a57600080fd5b505afa15801561059e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506105c291908101906127e9565b9695505050505050565b6006546040517f4f8e6e230000000000000000000000000000000000000000000000000000000081526000916001600160a01b031690634f8e6e23906106169086906004016131cf565b60206040518083038186803b15801561062e57600080fd5b505afa158015610642573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506106669190810190612769565b6106825760405162461bcd60e51b815260040161035c9061337d565b61069d6001600160a01b03841633308563ffffffff61144b16565b6040517f42966c680000000000000000000000000000000000000000000000000000000081526001600160a01b038416906342966c68906106e29085906004016134bd565b602060405180830381600087803b1580156106fc57600080fd5b505af1158015610710573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506107349190810190612769565b6107505760405162461bcd60e51b815260040161035c906133fd565b5060015b92915050565b60005460ff1681565b606060028054806020026020016040519081016040528092919081815260200182805480156107bb57602002820191906000526020600020905b81546001600160a01b0316815260019091019060200180831161079d575b5050505050905090565b60005460ff16156107e85760405162461bcd60e51b815260040161035c906132fd565b600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016600117905561081c33611510565b60005b828110156108545761084b84848381811061083657fe5b905060200201602061022091908101906125c0565b5060010161081f565b5061085e81610b10565b505050565b61086b610ae7565b6108875760405162461bcd60e51b815260040161035c906133dd565b600080546040516101009091046001600160a01b0316907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080547fffffffffffffffffffffff0000000000000000000000000000000000000000ff169055565b60006108f7610ae7565b6109135760405162461bcd60e51b815260040161035c906133dd565b6001600160a01b03821660009081526003602052604090205460ff161561094c5760405162461bcd60e51b815260040161035c906132ed565b6001600160a01b0382166109725760405162461bcd60e51b815260040161035c906133cd565b6002805460018082019092557f405787fa12a823e0f2b7631cc41b3ba8828b3321ca811111fa75cd3aa3bb5ace0180547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b03851690811790915560008181526003602052604080822080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016909417909355915190917f2ee2cb0721ec60b86190cae5c48e25064b69b35abad32452a4ec99d232033de291a260025461075490600163ffffffff61140216565b60056020819052600091825260409091205463ffffffff80821692640100000000830490911691680100000000000000008104820b916e0100000000000000000000000000008204810b9174010000000000000000000000000000000000000000810490910b907a010000000000000000000000000000000000000000000000000000900460ff1686565b60005461010090046001600160a01b031690565b6000805461010090046001600160a01b0316610b016115b3565b6001600160a01b031614905090565b610b18610ae7565b610b345760405162461bcd60e51b815260040161035c906133dd565b6001600160a01b038116610b5a5760405162461bcd60e51b815260040161035c9061346d565b6006546040516001600160a01b03918216918316907fb69e1c416d8be92ac92c8e97e77c4626fba5e6ab50161099f659ea3303479e5090600090a3600680547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0392909216919091179055565b6001600160a01b03851660009081526003602052604081205460ff16610c075760405162461bcd60e51b815260040161035c906133ad565b6040517f93c7e3bc0000000000000000000000000000000000000000000000000000000081526001600160a01b038716906393c7e3bc9061057290889088908890889060040161327d565b610c5a610ae7565b610c765760405162461bcd60e51b815260040161035c906133dd565b610c7f816115b7565b6000826001600160a01b031660001b84189050816005600083815260200190815260200160002060008201518160000160006101000a81548163ffffffff021916908363ffffffff16021790555060208201518160000160046101000a81548163ffffffff021916908363ffffffff16021790555060408201518160000160086101000a81548165ffffffffffff021916908360050b65ffffffffffff160217905550606082015181600001600e6101000a81548165ffffffffffff021916908360050b65ffffffffffff16021790555060808201518160000160146101000a81548165ffffffffffff021916908360050b65ffffffffffff16021790555060a082015181600001601a6101000a81548160ff021916908360ff160217905550905050610e7582600460008481526020019081526020016000206040518060a00160405290816000820160009054906101000a900463ffffffff1663ffffffff1663ffffffff1681526020016000820160049054906101000a900463ffffffff1663ffffffff1663ffffffff1681526020016000820160089054906101000a900460050b60050b60050b815260200160008201600e9054906101000a900460050b60050b60050b81526020016000820160149054906101000a900460050b60050b60050b8152505061165d90919063ffffffff16565b6000828152600460209081526040918290208351815492850151858501516060870151608090970151600590810b65ffffffffffff90811674010000000000000000000000000000000000000000027fffffffffffff000000000000ffffffffffffffffffffffffffffffffffffffff99830b82166e010000000000000000000000000000027fffffffffffffffffffffffff000000000000ffffffffffffffffffffffffffff9490930b90911668010000000000000000027fffffffffffffffffffffffffffffffffffff000000000000ffffffffffffffff63ffffffff958616640100000000027fffffffffffffffffffffffffffffffffffffffffffffffff00000000ffffffff969097167fffffffffffffffffffffffffffffffffffffffffffffffffffffffff00000000909916989098179490941694909417959095169190911716929092179390931617909155517f1a082a1efaf1549c18917ddcb1f759680c29371609e24f4b946e93acf4ce5ad290610ffa908690869086906132a5565b60405180910390a150505050565b6002818154811061101557fe5b6000918252602090912001546001600160a01b0316905081565b6006546001600160a01b031681565b600180548101908190556001600160a01b03871660009081526003602052604081205490919060ff166110835760405162461bcd60e51b815260040161035c906133ad565b6040517fd3385d050000000000000000000000000000000000000000000000000000000081526001600160a01b0389169063d3385d05906110ce908a908a908a908a9060040161327d565b602060405180830381600087803b1580156110e857600080fd5b505af11580156110fc573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525061112091908101906127e9565b9150828211156111425760405162461bcd60e51b815260040161035c9061332d565b61114f87878488886116b2565b61115a338784611785565b6111653386866119ce565b856001600160a01b0316336001600160a01b0316887fe7b046415cac9de47940c3087e06db13a0e058ccf53ac5f0edd49ebb4c2c3a6f8b89878a6040516111af9493929190613220565b60405180910390a460015481146111d85760405162461bcd60e51b815260040161035c9061339d565b509695505050505050565b60036020526000908152604090205460ff1681565b600180548101908190556001600160a01b03871660009081526003602052604081205490919060ff1661123d5760405162461bcd60e51b815260040161035c906133ad565b6040517f42bfc99c0000000000000000000000000000000000000000000000000000000081526001600160a01b038916906342bfc99c90611288908a908a908a908a9060040161327d565b602060405180830381600087803b1580156112a257600080fd5b505af11580156112b6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506112da91908101906127e9565b9150828210156112fc5760405162461bcd60e51b815260040161035c9061342d565b61130987878688866116b2565b611314338786611785565b61131f3386846119ce565b856001600160a01b0316336001600160a01b0316887fe7b046415cac9de47940c3087e06db13a0e058ccf53ac5f0edd49ebb4c2c3a6f8b8989886040516111af9493929190613220565b60046020526000908152604090205463ffffffff80821691640100000000810490911690680100000000000000008104600590810b916e0100000000000000000000000000008104820b9174010000000000000000000000000000000000000000909104900b85565b6113da610ae7565b6113f65760405162461bcd60e51b815260040161035c906133dd565b6113ff81611510565b50565b600061144483836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250611c7a565b9392505050565b60405161150a9085907f23b872dd0000000000000000000000000000000000000000000000000000000090611488908790879087906024016131f8565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff0000000000000000000000000000000000000000000000000000000090931692909217909152611ca6565b50505050565b6001600160a01b0381166115365760405162461bcd60e51b815260040161035c9061330d565b600080546040516001600160a01b038085169361010090930416917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b03909216610100027fffffffffffffffffffffff0000000000000000000000000000000000000000ff909216919091179055565b3390565b60a081015160021615806115d1575060a081015160011615155b6115ed5760405162461bcd60e51b815260040161035c9061333d565b60a081015160011615806116075750805163ffffffff1615155b6116235760405162461bcd60e51b815260040161035c906133bd565b60a0810151600216158061164157506000816020015163ffffffff16115b6113ff5760405162461bcd60e51b815260040161035c9061336d565b611665612425565b6000808452602084015260a082015160011661168357600060408401525b60a082015160021661169757600060608401525b60a08201516004166116ab57600060808401525b5090919050565b6001600160a01b038481169083167f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8511156117005760405162461bcd60e51b815260040161035c906133ed565b7f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8311156117405760405162461bcd60e51b815260040161035c9061340d565b61174d8288188688611d8b565b61177c818818847fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0286611d8b565b50505050505050565b6006546040517f4f8e6e230000000000000000000000000000000000000000000000000000000081526001600160a01b0390911690634f8e6e23906117ce9085906004016131cf565b60206040518083038186803b1580156117e657600080fd5b505afa1580156117fa573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525061181e9190810190612769565b156118f65761183e6001600160a01b03831684308463ffffffff61144b16565b6040517f42966c680000000000000000000000000000000000000000000000000000000081526001600160a01b038316906342966c68906118839084906004016134bd565b602060405180830381600087803b15801561189d57600080fd5b505af11580156118b1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506118d59190810190612769565b6118f15760405162461bcd60e51b815260040161035c906133fd565b61085e565b6006546040517fcae182fe0000000000000000000000000000000000000000000000000000000081526001600160a01b039091169063cae182fe9061193f9085906004016131cf565b60206040518083038186803b15801561195757600080fd5b505afa15801561196b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525061198f9190810190612769565b156119b6576006546118f1906001600160a01b03848116918691168463ffffffff61144b16565b60405162461bcd60e51b815260040161035c9061348d565b6006546040517f4f8e6e230000000000000000000000000000000000000000000000000000000081526001600160a01b0390911690634f8e6e2390611a179085906004016131cf565b60206040518083038186803b158015611a2f57600080fd5b505afa158015611a43573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250611a679190810190612769565b15611b21576040517f40c10f190000000000000000000000000000000000000000000000000000000081526001600160a01b038316906340c10f1990611ab390869085906004016131dd565b602060405180830381600087803b158015611acd57600080fd5b505af1158015611ae1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250611b059190810190612769565b6118f15760405162461bcd60e51b815260040161035c9061345d565b6006546040517fcae182fe0000000000000000000000000000000000000000000000000000000081526001600160a01b039091169063cae182fe90611b6a9085906004016131cf565b60206040518083038186803b158015611b8257600080fd5b505afa158015611b96573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250611bba9190810190612769565b156119b6576006546040517f6be383fc0000000000000000000000000000000000000000000000000000000081526001600160a01b0390911690636be383fc90611c0c908590879086906004016131f8565b602060405180830381600087803b158015611c2657600080fd5b505af1158015611c3a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250611c5e9190810190612769565b6118f15760405162461bcd60e51b815260040161035c9061349d565b60008184841115611c9e5760405162461bcd60e51b815260040161035c91906132dc565b505050900390565b611cb8826001600160a01b03166120f5565b611cd45760405162461bcd60e51b815260040161035c906134ad565b60006060836001600160a01b031683604051611cf091906131c3565b6000604051808303816000865af19150503d8060008114611d2d576040519150601f19603f3d011682016040523d82523d6000602084013e611d32565b606091505b509150915081611d545760405162461bcd60e51b815260040161035c9061335d565b80511561150a5780806020019051611d6f9190810190612769565b61150a5760405162461bcd60e51b815260040161035c9061347d565b611d93612453565b50600083815260056020818152604092839020835160c081018552905463ffffffff808216835264010000000082041692820192909252680100000000000000008204830b830b830b938101939093526e0100000000000000000000000000008104820b820b820b6060840152740100000000000000000000000000000000000000008104820b820b90910b60808301527a010000000000000000000000000000000000000000000000000000900460ff1660a082018190521561150a57611e59612425565b50600084815260046020818152604092839020835160a081018552905463ffffffff808216835264010000000082041682840152680100000000000000008104600590810b810b810b838701526e0100000000000000000000000000008204810b810b810b606084015274010000000000000000000000000000000000000000909104810b810b900b608082015283517f313ce56700000000000000000000000000000000000000000000000000000000815293519093611f8a93869389936001600160a01b038a169363313ce56793818101939291829003018186803b158015611f4357600080fd5b505afa158015611f57573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250611f7b9190810190612807565b8492919063ffffffff61213116565b9050611f9c818363ffffffff61225816565b60009485526004602090815260409586902082518154928401519784015160608501516080909501517fffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000000090941663ffffffff928316177fffffffffffffffffffffffffffffffffffffffffffffffff00000000ffffffff166401000000009290991691909102979097177fffffffffffffffffffffffffffffffffffff000000000000ffffffffffffffff1668010000000000000000600598890b65ffffffffffff90811691909102919091177fffffffffffffffffffffffff000000000000ffffffffffffffffffffffffffff166e01000000000000000000000000000094890b821694909402939093177fffffffffffff000000000000ffffffffffffffffffffffffffffffffffffffff16740100000000000000000000000000000000000000009290970b929092160294909417909355505050565b6000813f7fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a47081811480159061212957508115155b949350505050565b612139612425565b60008260ff16600a0a848161214a57fe5b059050657fffffffffff8113156121735760405162461bcd60e51b815260040161035c9061343d565b600081156121815781612184565b60015b60a08701519091506001161561222557855187510163ffffffff164211156121b7576000604088015263ffffffff421687525b6121c58760400151826123c7565b600590810b900b604088015260a08601516002161561222557856020015187602001510163ffffffff1642111561220a576000606088015263ffffffff421660208801525b6122188760600151826123c7565b600590810b900b60608801525b60a08601516004161561224d576122408760800151826123c7565b600590810b900b60808801525b509495945050505050565b60a0810151600116158015906122b45750816040015160050b81604001517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0260050b13806122b45750806040015160050b826040015160050b135b156122d15760405162461bcd60e51b815260040161035c9061341d565b60a08101516002161580159061232d5750816060015160050b81606001517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0260050b138061232d5750806060015160050b826060015160050b135b1561234a5760405162461bcd60e51b815260040161035c9061338d565b60a0810151600416158015906123a65750816080015160050b81608001517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0260050b13806123a65750806080015160050b826080015160050b135b156123c35760405162461bcd60e51b815260040161035c9061344d565b5050565b6000600582810b9084900b017fffffffffffffffffffffffffffffffffffffffffffffffffffff80000000000181128015906124095750657fffffffffff8113155b6114445760405162461bcd60e51b815260040161035c9061331d565b6040805160a08101825260008082526020820181905291810182905260608101829052608081019190915290565b6040805160c081018252600080825260208201819052918101829052606081018290526080810182905260a081019190915290565b803561075481613640565b60008083601f8401126124a557600080fd5b50813567ffffffffffffffff8111156124bd57600080fd5b6020830191508360208202830111156124d557600080fd5b9250929050565b805161075481613654565b80356107548161365d565b803561075481613666565b600060c0828403121561250f57600080fd5b61251960c0613567565b90506000612527848461259f565b82525060206125388484830161259f565b602083015250604061254c848285016124f2565b6040830152506060612560848285016124f2565b6060830152506080612574848285016124f2565b60808301525060a0612588848285016125aa565b60a08301525092915050565b80516107548161365d565b80356107548161366f565b803561075481613678565b805161075481613678565b6000602082840312156125d257600080fd5b60006121298484612488565b600080600080600060a086880312156125f657600080fd5b60006126028888612488565b9550506020612613888289016124e7565b945050604061262488828901612488565b935050606061263588828901612488565b9250506080612646888289016124e7565b9150509295509295909350565b60008060008060008060c0878903121561266c57600080fd5b60006126788989612488565b965050602061268989828a016124e7565b955050604061269a89828a01612488565b94505060606126ab89828a01612488565b93505060806126bc89828a016124e7565b92505060a06126cd89828a016124e7565b9150509295509295509295565b600080604083850312156126ed57600080fd5b60006126f98585612488565b925050602061270a858286016124e7565b9150509250929050565b60008060006040848603121561272957600080fd5b833567ffffffffffffffff81111561274057600080fd5b61274c86828701612493565b9350935050602061275f86828701612488565b9150509250925092565b60006020828403121561277b57600080fd5b600061212984846124dc565b60006020828403121561279957600080fd5b600061212984846124e7565b600080600061010084860312156127bb57600080fd5b60006127c786866124e7565b93505060206127d886828701612488565b925050604061275f868287016124fd565b6000602082840312156127fb57600080fd5b60006121298484612594565b60006020828403121561281957600080fd5b600061212984846125b5565b60006128318383612848565b505060200190565b612842816135da565b82525050565b612842816135a6565b600061285c82613594565b6128668185613598565b93506128718361358e565b8060005b8381101561224d5781516128898882612825565b97506128948361358e565b925050600101612875565b612842816135b1565b612842816135b6565b60006128bc82613594565b6128c681856135a1565b93506128d68185602086016135ec565b9290920192915050565b612842816135e1565b612842816135b9565b60006128fd82613594565b6129078185613598565b93506129178185602086016135ec565b61292081613618565b9093019392505050565b6000612937602b83613598565b7f45786368616e676550726f766964657220616c7265616479206578697374732081527f696e20746865206c697374000000000000000000000000000000000000000000602082015260400192915050565b6000612996601c83613598565b7f636f6e747261637420616c726561647920696e697469616c697a656400000000815260200192915050565b60006129cf602683613598565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206181527f6464726573730000000000000000000000000000000000000000000000000000602082015260400192915050565b6000612a2e601783613598565b7f696e743438206164646974696f6e206f766572666c6f77000000000000000000815260200192915050565b6000612a67601483613598565b7f616d6f756e74496e4d6178206578636565646564000000000000000000000000815260200192915050565b6000612aa0601983613598565b7f4c3120776974686f7574204c30206e6f7420616c6c6f77656400000000000000815260200192915050565b6000612ad9601c83613598565b7f696e64657820646f65736e2774206d617463682070726f766964657200000000815260200192915050565b6000612b12602083613598565b7f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815260200192915050565b6000612b4b602183613598565b7f74696d6573746570312063616e2774206265207a65726f20696620616374697681527f6500000000000000000000000000000000000000000000000000000000000000602082015260400192915050565b6000612baa602483613598565b7f546f6b656e206d7573742062652061207265736572766520737461626c65206181527f7373657400000000000000000000000000000000000000000000000000000000602082015260400192915050565b6000612c09600b83613598565b7f4c31204578636565646564000000000000000000000000000000000000000000815260200192915050565b6000612c42600e83613598565b7f7265656e7472616e742063616c6c000000000000000000000000000000000000815260200192915050565b6000612c7b601f83613598565b7f45786368616e676550726f766964657220646f6573206e6f7420657869737400815260200192915050565b6000612cb4602183613598565b7f74696d6573746570302063616e2774206265207a65726f20696620616374697681527f6500000000000000000000000000000000000000000000000000000000000000602082015260400192915050565b6000612d13602383613598565b7f45786368616e676550726f766964657220616464726573732063616e2774206281527f6520300000000000000000000000000000000000000000000000000000000000602082015260400192915050565b6000612d72602083613598565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572815260200192915050565b6000612dab601283613598565b7f616d6f756e74496e20746f6f206c617267650000000000000000000000000000815260200192915050565b6000612de4602283613598565b7f4275726e696e67206f662074686520737461626c65206173736574206661696c81527f6564000000000000000000000000000000000000000000000000000000000000602082015260400192915050565b6000612e43601383613598565b7f616d6f756e744f757420746f6f206c6172676500000000000000000000000000815260200192915050565b6000612e7c600b83613598565b7f4c30204578636565646564000000000000000000000000000000000000000000815260200192915050565b6000612eb5601483613598565b7f616d6f756e744f75744d696e206e6f74206d6574000000000000000000000000815260200192915050565b6000612eee600f83613598565b7f64466c6f7720746f6f206c617267650000000000000000000000000000000000815260200192915050565b6000612f27600b83613598565b7f4c47204578636565646564000000000000000000000000000000000000000000815260200192915050565b6000612f60602283613598565b7f4d696e74696e67206f662074686520737461626c65206173736574206661696c81527f6564000000000000000000000000000000000000000000000000000000000000602082015260400192915050565b6000612fbf601b83613598565b7f526573657276652061646472657373206d757374206265207365740000000000815260200192915050565b6000612ff8602a83613598565b7f5361666545524332303a204552433230206f7065726174696f6e20646964206e81527f6f74207375636365656400000000000000000000000000000000000000000000602082015260400192915050565b6000613057602983613598565b7f546f6b656e206d75737420626520737461626c65206f7220636f6c6c6174657281527f616c206173736572740000000000000000000000000000000000000000000000602082015260400192915050565b60006130b6602783613598565b7f5472616e73666572206f662074686520636f6c6c61746572616c20617373657481527f206661696c656400000000000000000000000000000000000000000000000000602082015260400192915050565b6000613115601f83613598565b7f5361666545524332303a2063616c6c20746f206e6f6e2d636f6e747261637400815260200192915050565b805160c083019061315284826131b1565b50602082015161316560208501826131b1565b50604082015161317860408501826128e9565b50606082015161318b60608501826128e9565b50608082015161319e60808501826128e9565b5060a082015161150a60a08501826131ba565b612842816135cb565b612842816135d4565b600061144482846128b1565b602081016107548284612848565b604081016131eb8285612839565b61144460208301846128a8565b606081016132068286612848565b6132136020830185612848565b61212960408301846128a8565b6080810161322e8287612848565b61323b6020830186612848565b61324860408301856128a8565b61325560608301846128a8565b95945050505050565b602080825281016114448184612851565b60208101610754828461289f565b6080810161328b82876128a8565b6132986020830186612848565b6132486040830185612848565b61010081016132b482866128a8565b6132c16020830185612848565b6121296040830184613141565b6020810161075482846128e0565b6020808252810161144481846128f2565b602080825281016107548161292a565b6020808252810161075481612989565b60208082528101610754816129c2565b6020808252810161075481612a21565b6020808252810161075481612a5a565b6020808252810161075481612a93565b6020808252810161075481612acc565b6020808252810161075481612b05565b6020808252810161075481612b3e565b6020808252810161075481612b9d565b6020808252810161075481612bfc565b6020808252810161075481612c35565b6020808252810161075481612c6e565b6020808252810161075481612ca7565b6020808252810161075481612d06565b6020808252810161075481612d65565b6020808252810161075481612d9e565b6020808252810161075481612dd7565b6020808252810161075481612e36565b6020808252810161075481612e6f565b6020808252810161075481612ea8565b6020808252810161075481612ee1565b6020808252810161075481612f1a565b6020808252810161075481612f53565b6020808252810161075481612fb2565b6020808252810161075481612feb565b602080825281016107548161304a565b60208082528101610754816130a9565b6020808252810161075481613108565b6020810161075482846128a8565b60a081016134d982886131b1565b6134e660208301876131b1565b6134f360408301866128e9565b61350060608301856128e9565b6105c260808301846128e9565b60c0810161351b82896131b1565b61352860208301886131b1565b61353560408301876128e9565b61354260608301866128e9565b61354f60808301856128e9565b61355c60a08301846131ba565b979650505050505050565b60405181810167ffffffffffffffff8111828210171561358657600080fd5b604052919050565b60200190565b5190565b90815260200190565b919050565b6000610754826135bf565b151590565b90565b60050b90565b6001600160a01b031690565b63ffffffff1690565b60ff1690565b6000610754825b6000610754826135a6565b60005b838110156136075781810151838201526020016135ef565b8381111561150a5750506000910152565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01690565b613649816135a6565b81146113ff57600080fd5b613649816135b1565b613649816135b6565b613649816135b9565b613649816135cb565b613649816135d456fea365627a7a72315820e4e04bd1b62312146c7bcc0e70fec4aa193d5c34d458abcfc0c2127c7b01ff6d6c6578706572696d656e74616cf564736f6c63430005110040
External libraries
AddressLinkedList : 0x6200f54d73491d56b8d7a975c9ee18efb4d518df
AddressSortedLinkedListWithMedian : 0xed477a99035d0c1e11369f1d7a4e587893cc002b