Contract Overview
Balance:
0 ETH
My Name Tag:
Not Available
Txn Hash | Method |
Block
|
From
|
To
|
Value | ||||
---|---|---|---|---|---|---|---|---|---|
0x0849029d6e92a7f2956b65fe2f33a221ff971b6aaa46b0925e101c8629cb9e35 | 0x60806040 | 2439427 | 327 days 14 hrs ago | 0x9841484a4a6c0b61c4eea71376d76453fd05ec9c | IN | Create: SportVault | 0 ETH | 0.008085727576 |
[ Download CSV Export ]
Latest 9 internal transactions
[ Download CSV Export ]
Contract Name:
SportVault
Compiler Version
v0.8.4+commit.c7e474f2
Optimization Enabled:
Yes with 200 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol"; import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; import "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol"; import "../utils/proxy/solidity-0.8.0/ProxyReentrancyGuard.sol"; import "../utils/proxy/solidity-0.8.0/ProxyOwned.sol"; import "../interfaces/ISportsAMM.sol"; import "../interfaces/ISportPositionalMarket.sol"; import "../interfaces/IStakingThales.sol"; contract SportVault is Initializable, ProxyOwned, PausableUpgradeable, ProxyReentrancyGuard { /* ========== LIBRARIES ========== */ using SafeERC20Upgradeable for IERC20Upgradeable; struct DepositReceipt { uint round; uint amount; } struct InitParams { address _owner; ISportsAMM _sportsAmm; IERC20Upgradeable _sUSD; uint _roundLength; uint _priceLowerLimit; uint _priceUpperLimit; int _skewImpactLimit; uint _allocationLimitsPerMarketPerRound; uint _maxAllowedDeposit; uint _utilizationRate; uint _minDepositAmount; uint _maxAllowedUsers; uint _minTradeAmount; } /* ========== CONSTANTS ========== */ uint private constant HUNDRED = 1e20; uint private constant ONE = 1e18; /* ========== STATE VARIABLES ========== */ ISportsAMM public sportsAMM; IERC20Upgradeable public sUSD; bool public vaultStarted; uint public round; uint public roundLength; mapping(uint => uint) public roundStartTime; mapping(uint => address[]) public usersPerRound; mapping(uint => mapping(address => bool)) public userInRound; mapping(uint => mapping(address => uint)) public balancesPerRound; mapping(address => bool) public withdrawalRequested; mapping(address => DepositReceipt) public depositReceipts; mapping(uint => uint) public allocationPerRound; mapping(uint => address[]) public tradingMarketsPerRound; mapping(uint => mapping(address => ISportsAMM.Position)) public tradingMarketPositionPerRound; mapping(uint => mapping(address => bool)) public isTradingMarketInARound; mapping(uint => uint) public profitAndLossPerRound; mapping(uint => uint) public cumulativeProfitAndLoss; uint public maxAllowedDeposit; uint public utilizationRate; mapping(uint => uint) public capPerRound; uint public minDepositAmount; uint public maxAllowedUsers; uint public usersCurrentlyInVault; uint public allocationLimitsPerMarketPerRound; mapping(uint => mapping(address => uint)) public allocationSpentPerRound; uint public priceLowerLimit; uint public priceUpperLimit; int public skewImpactLimit; uint public minTradeAmount; /// @return The address of the Staking contract IStakingThales public stakingThales; /* ========== CONSTRUCTOR ========== */ function __BaseSportVault_init( address _owner, ISportsAMM _sportAmm, IERC20Upgradeable _sUSD, uint _roundLength, uint _maxAllowedDeposit, uint _utilizationRate, uint _minDepositAmount, uint _maxAllowedUsers ) internal onlyInitializing { setOwner(_owner); initNonReentrant(); sportsAMM = ISportsAMM(_sportAmm); sUSD = _sUSD; roundLength = _roundLength; maxAllowedDeposit = _maxAllowedDeposit; utilizationRate = _utilizationRate; minDepositAmount = _minDepositAmount; maxAllowedUsers = _maxAllowedUsers; sUSD.approve(address(sportsAMM), type(uint256).max); } function initialize(InitParams calldata params) external initializer { __BaseSportVault_init( params._owner, params._sportsAmm, params._sUSD, params._roundLength, params._maxAllowedDeposit, params._utilizationRate, params._minDepositAmount, params._maxAllowedUsers ); priceLowerLimit = params._priceLowerLimit; priceUpperLimit = params._priceUpperLimit; skewImpactLimit = params._skewImpactLimit; allocationLimitsPerMarketPerRound = params._allocationLimitsPerMarketPerRound; minTradeAmount = params._minTradeAmount; } /// @notice Start vault and begin round #1 function startVault() external onlyOwner { require(!vaultStarted, "Vault has already started"); round = 1; roundStartTime[round] = block.timestamp; vaultStarted = true; capPerRound[2] = capPerRound[1]; emit VaultStarted(); } /// @notice Close current round and begin next round, /// excercise options of trading markets and calculate profit and loss function closeRound() external nonReentrant whenNotPaused { require(canCloseCurrentRound(), "Can't close current round"); // excercise market options _exerciseMarketsReadyToExercised(); // balance in next round does not affect PnL in a current round uint currentVaultBalance = sUSD.balanceOf(address(this)) - allocationPerRound[round + 1]; // calculate PnL // if no allocation for current round if (allocationPerRound[round] == 0) { profitAndLossPerRound[round] = 1; } else { profitAndLossPerRound[round] = (currentVaultBalance * ONE) / allocationPerRound[round]; } for (uint i = 0; i < usersPerRound[round].length; i++) { address user = usersPerRound[round][i]; uint balanceAfterCurRound = (balancesPerRound[round][user] * profitAndLossPerRound[round]) / ONE; if (userInRound[round][user]) { if (!withdrawalRequested[user]) { balancesPerRound[round + 1][user] = balancesPerRound[round + 1][user] + balanceAfterCurRound; userInRound[round + 1][user] = true; usersPerRound[round + 1].push(user); } else { balancesPerRound[round + 1][user] = 0; sUSD.safeTransfer(user, balanceAfterCurRound); withdrawalRequested[user] = false; userInRound[round + 1][user] = false; emit Claimed(user, balanceAfterCurRound); } } } if (round == 1) { cumulativeProfitAndLoss[round] = profitAndLossPerRound[round]; } else { cumulativeProfitAndLoss[round] = (cumulativeProfitAndLoss[round - 1] * profitAndLossPerRound[round]) / ONE; } // start next round round += 1; roundStartTime[round] = block.timestamp; // allocation for next round doesn't include withdrawal queue share from previous round allocationPerRound[round] = sUSD.balanceOf(address(this)); capPerRound[round + 1] = allocationPerRound[round]; emit RoundClosed(round - 1, profitAndLossPerRound[round - 1]); } /// @notice Deposit funds from user into vault for the next round /// @param amount Value to be deposited function deposit(uint amount) external canDeposit(amount) { sUSD.safeTransferFrom(msg.sender, address(this), amount); uint nextRound = round + 1; // new user enters the vault if (balancesPerRound[round][msg.sender] == 0 && balancesPerRound[nextRound][msg.sender] == 0) { require(usersCurrentlyInVault < maxAllowedUsers, "Max amount of users reached"); usersPerRound[nextRound].push(msg.sender); userInRound[nextRound][msg.sender] = true; usersCurrentlyInVault = usersCurrentlyInVault + 1; } balancesPerRound[nextRound][msg.sender] += amount; // update deposit state of a user depositReceipts[msg.sender] = DepositReceipt(nextRound, balancesPerRound[nextRound][msg.sender]); allocationPerRound[nextRound] += amount; capPerRound[nextRound] += amount; emit Deposited(msg.sender, amount); } function withdrawalRequest() external { require(vaultStarted, "Vault has not started"); require(!withdrawalRequested[msg.sender], "Withdrawal already requested"); require(balancesPerRound[round][msg.sender] > 0, "Nothing to withdraw"); require(balancesPerRound[round + 1][msg.sender] == 0, "Can't withdraw as you already deposited for next round"); uint nextRound = round + 1; if (capPerRound[nextRound] > balancesPerRound[round][msg.sender]) { capPerRound[nextRound] -= balancesPerRound[round][msg.sender]; } usersCurrentlyInVault = usersCurrentlyInVault - 1; withdrawalRequested[msg.sender] = true; emit WithdrawalRequested(msg.sender); } /// @notice Buy market options from Thales AMM /// @param market address of a market /// @param amount number of options to be bought /// @param position to buy options for function trade( address market, uint amount, ISportsAMM.Position position ) external nonReentrant whenNotPaused { require(vaultStarted, "Vault has not started"); require(amount >= minTradeAmount, "Amount less than minimum"); ISportPositionalMarket marketContract = ISportPositionalMarket(market); (uint maturity, ) = marketContract.times(); require(maturity < (roundStartTime[round] + roundLength), "Market time not valid"); uint pricePosition = sportsAMM.buyFromAmmQuote(address(market), position, ONE); require(pricePosition > 0, "Price not more than 0"); int pricePositionImpact = sportsAMM.buyPriceImpact(address(market), position, amount); require(pricePosition >= priceLowerLimit && pricePosition <= priceUpperLimit, "Market price not valid"); require(pricePositionImpact < skewImpactLimit, "Skew impact too high"); _buyFromAmm(market, position, amount); if (!isTradingMarketInARound[round][market]) { tradingMarketsPerRound[round].push(market); isTradingMarketInARound[round][market] = true; } } /// @notice Set length of rounds /// @param _roundLength Length of a round in miliseconds function setRoundLength(uint _roundLength) external onlyOwner { roundLength = _roundLength; emit RoundLengthChanged(_roundLength); } /// @notice Set ThalesAMM contract /// @param _sportAMM ThalesAMM address function setSportAmm(ISportsAMM _sportAMM) external onlyOwner { sportsAMM = _sportAMM; sUSD.approve(address(sportsAMM), type(uint256).max); emit SportAMMChanged(address(_sportAMM)); } /// @notice Set IStakingThales contract /// @param _stakingThales IStakingThales address function setStakingThales(IStakingThales _stakingThales) external onlyOwner { stakingThales = _stakingThales; emit StakingThalesChanged(address(_stakingThales)); } /// @notice Set utilization rate parameter /// @param _utilizationRate Value in percents function setUtilizationRate(uint _utilizationRate) external onlyOwner { utilizationRate = _utilizationRate; emit UtilizationRateChanged(_utilizationRate); } /// @notice Set max allowed deposit /// @param _maxAllowedDeposit Deposit value function setMaxAllowedDeposit(uint _maxAllowedDeposit) external onlyOwner { maxAllowedDeposit = _maxAllowedDeposit; emit MaxAllowedDepositChanged(_maxAllowedDeposit); } /// @notice Set min allowed deposit /// @param _minDepositAmount Deposit value function setMinAllowedDeposit(uint _minDepositAmount) external onlyOwner { minDepositAmount = _minDepositAmount; emit MinAllowedDepositChanged(_minDepositAmount); } /// @notice Set _maxAllowedUsers /// @param _maxAllowedUsers Deposit value function setMaxAllowedUsers(uint _maxAllowedUsers) external onlyOwner { maxAllowedUsers = _maxAllowedUsers; emit MaxAllowedUsersChanged(_maxAllowedUsers); } /// @notice Set allocation limits for assets to be spent in one round /// @param _allocationLimitsPerMarketPerRound allocation per market in percent function setAllocationLimits(uint _allocationLimitsPerMarketPerRound) external onlyOwner { require(_allocationLimitsPerMarketPerRound < HUNDRED, "Invalid allocation limit values"); allocationLimitsPerMarketPerRound = _allocationLimitsPerMarketPerRound; emit SetAllocationLimits(allocationLimitsPerMarketPerRound); } /// @notice Set price limit for options to be bought from AMM /// @param _priceLowerLimit lower limit /// @param _priceUpperLimit upper limit function setPriceLimits(uint _priceLowerLimit, uint _priceUpperLimit) external onlyOwner { require(_priceLowerLimit < _priceUpperLimit, "Invalid price limit values"); priceLowerLimit = _priceLowerLimit; priceUpperLimit = _priceUpperLimit; emit SetPriceLimits(_priceLowerLimit, _priceUpperLimit); } /// @notice Set skew impact limit for AMM /// @param _skewImpactLimit limit in percents function setSkewImpactLimit(int _skewImpactLimit) external onlyOwner { skewImpactLimit = _skewImpactLimit; emit SetSkewImpactLimit(_skewImpactLimit); } /// @notice Set _minTradeAmount /// @param _minTradeAmount limit in percents function setMinTradeAmount(uint _minTradeAmount) external onlyOwner { minTradeAmount = _minTradeAmount; emit SetMinTradeAmount(_minTradeAmount); } /* ========== INTERNAL FUNCTIONS ========== */ function _exerciseMarketsReadyToExercised() internal { ISportPositionalMarket market; for (uint i = 0; i < tradingMarketsPerRound[round].length; i++) { market = ISportPositionalMarket(tradingMarketsPerRound[round][i]); if (!market.paused() && market.resolved()) { (uint homeBalance, uint awayBalance, uint drawBalance) = market.balancesOf(address(this)); if (homeBalance > 0 || awayBalance > 0 || drawBalance > 0) { market.exerciseOptions(); } } } } /// @notice Buy options from AMM /// @param market address of a market /// @param position position to be bought /// @param amount amount of positions to be bought function _buyFromAmm( address market, ISportsAMM.Position position, uint amount ) internal { if (isTradingMarketInARound[round][market]) { require( tradingMarketPositionPerRound[round][market] == position, "Cannot trade different options on the same market" ); } uint quote = sportsAMM.buyFromAmmQuote(market, position, amount); uint allocationAsset = (tradingAllocation() * allocationLimitsPerMarketPerRound) / HUNDRED; require( (quote + allocationSpentPerRound[round][market]) < allocationAsset, "Amount exceeds available allocation for asset" ); uint balanceBeforeTrade = sUSD.balanceOf(address(this)); sportsAMM.buyFromAMM(market, position, amount, quote, 0); uint balanceAfterTrade = sUSD.balanceOf(address(this)); allocationSpentPerRound[round][market] += quote; tradingMarketPositionPerRound[round][market] = position; emit TradeExecuted(market, position, amount, quote); } /// @notice Return trading allocation in current round based on utilization rate param /// @return uint function tradingAllocation() public view returns (uint) { return (allocationPerRound[round] * utilizationRate) / ONE; } /* ========== VIEWS ========== */ /// @notice Checks if all conditions are met to close the round /// @return bool function canCloseCurrentRound() public view returns (bool) { if (!vaultStarted || block.timestamp < (roundStartTime[round] + roundLength)) { return false; } for (uint i = 0; i < tradingMarketsPerRound[round].length; i++) { ISportPositionalMarket market = ISportPositionalMarket(tradingMarketsPerRound[round][i]); if ((!market.resolved()) || market.paused()) { return false; } } return true; } /// @notice Get available amount to spend on an asset in a round /// @param market to fetch available allocation for /// @return uint function getAvailableAllocationForMarket(address market) external view returns (uint) { uint allocationMarket = (tradingAllocation() * allocationLimitsPerMarketPerRound) / HUNDRED; return allocationMarket - allocationSpentPerRound[round][market]; } /// @notice Return user balance in a round /// @param _round Round number /// @param user Address of the user /// @return uint function getBalancesPerRound(uint _round, address user) external view returns (uint) { return balancesPerRound[_round][user]; } /// @notice Return available to deposit /// @return uint function getAvailableToDeposit() external view returns (uint) { return maxAllowedDeposit - capPerRound[round + 1]; } /// @notice end of current round /// @return uint function getCurrentRoundEnd() external view returns (uint) { return roundStartTime[round] + roundLength; } /// @notice Return multiplied PnLs between rounds /// @param roundA Round number from /// @param roundB Round number to /// @return uint function cumulativePnLBetweenRounds(uint roundA, uint roundB) public view returns (uint) { return (cumulativeProfitAndLoss[roundB] * profitAndLossPerRound[roundA]) / cumulativeProfitAndLoss[roundA]; } /* ========== MODIFIERS ========== */ modifier canDeposit(uint amount) { require(!withdrawalRequested[msg.sender], "Withdrawal is requested, cannot deposit"); require(amount >= minDepositAmount, "Invalid amount"); require(capPerRound[round + 1] + amount <= maxAllowedDeposit, "Deposit amount exceeds vault cap"); _; } /* ========== EVENTS ========== */ event VaultStarted(); event RoundClosed(uint round, uint roundPnL); event RoundLengthChanged(uint roundLength); event SportAMMChanged(address thalesAmm); event StakingThalesChanged(address stakingThales); event SetSUSD(address sUSD); event Deposited(address user, uint amount); event Claimed(address user, uint amount); event WithdrawalRequested(address user); event UtilizationRateChanged(uint utilizationRate); event MaxAllowedDepositChanged(uint maxAllowedDeposit); event MinAllowedDepositChanged(uint minAllowedDeposit); event MaxAllowedUsersChanged(uint MaxAllowedUsersChanged); event SetAllocationLimits(uint allocationLimitsPerMarketPerRound); event SetPriceLimits(uint priceLowerLimit, uint priceUpperLimit); event SetSkewImpactLimit(int skewImpact); event SetMinTradeAmount(uint SetMinTradeAmount); event TradeExecuted(address market, ISportsAMM.Position position, uint amount, uint quote); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC20/utils/SafeERC20.sol) pragma solidity ^0.8.0; import "../IERC20Upgradeable.sol"; import "../../../utils/AddressUpgradeable.sol"; /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20Upgradeable { using AddressUpgradeable for address; function safeTransfer( IERC20Upgradeable token, address to, uint256 value ) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom( IERC20Upgradeable token, address from, address to, uint256 value ) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } /** * @dev Deprecated. This function has issues similar to the ones found in * {IERC20-approve}, and its usage is discouraged. * * Whenever possible, use {safeIncreaseAllowance} and * {safeDecreaseAllowance} instead. */ function safeApprove( IERC20Upgradeable 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' 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( IERC20Upgradeable token, address spender, uint256 value ) internal { uint256 newAllowance = token.allowance(address(this), spender) + value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function safeDecreaseAllowance( IERC20Upgradeable token, address spender, uint256 value ) internal { unchecked { uint256 oldAllowance = token.allowance(address(this), spender); require(oldAllowance >= value, "SafeERC20: decreased allowance below zero"); uint256 newAllowance = oldAllowance - value; _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(IERC20Upgradeable token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (access/Ownable.sol) pragma solidity ^0.8.0; import "../utils/ContextUpgradeable.sol"; import "../proxy/utils/Initializable.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. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * 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. */ abstract contract OwnableUpgradeable is Initializable, ContextUpgradeable { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ function __Ownable_init() internal onlyInitializing { __Context_init_unchained(); __Ownable_init_unchained(); } function __Ownable_init_unchained() internal onlyInitializing { _transferOwnership(_msgSender()); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the 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 virtual onlyOwner { _transferOwnership(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 virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } uint256[49] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (proxy/utils/Initializable.sol) pragma solidity ^0.8.0; import "../../utils/AddressUpgradeable.sol"; /** * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed * behind a proxy. Since a proxied contract can't have a constructor, it's common to move constructor logic to an * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect. * * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}. * * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity. * * [CAUTION] * ==== * Avoid leaving a contract uninitialized. * * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation * contract, which may impact the proxy. To initialize the implementation contract, you can either invoke the * initializer manually, or you can include a constructor to automatically mark it as initialized when it is deployed: * * [.hljs-theme-light.nopadding] * ``` * /// @custom:oz-upgrades-unsafe-allow constructor * constructor() initializer {} * ``` * ==== */ abstract contract Initializable { /** * @dev Indicates that the contract has been initialized. */ bool private _initialized; /** * @dev Indicates that the contract is in the process of being initialized. */ bool private _initializing; /** * @dev Modifier to protect an initializer function from being invoked twice. */ modifier initializer() { // If the contract is initializing we ignore whether _initialized is set in order to support multiple // inheritance patterns, but we only do this in the context of a constructor, because in other contexts the // contract may have been reentered. require(_initializing ? _isConstructor() : !_initialized, "Initializable: contract is already initialized"); bool isTopLevelCall = !_initializing; if (isTopLevelCall) { _initializing = true; _initialized = true; } _; if (isTopLevelCall) { _initializing = false; } } /** * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the * {initializer} modifier, directly or indirectly. */ modifier onlyInitializing() { require(_initializing, "Initializable: contract is not initializing"); _; } function _isConstructor() private view returns (bool) { return !AddressUpgradeable.isContract(address(this)); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (security/Pausable.sol) pragma solidity ^0.8.0; import "../utils/ContextUpgradeable.sol"; import "../proxy/utils/Initializable.sol"; /** * @dev Contract module which allows children to implement an emergency stop * mechanism that can be triggered by an authorized account. * * This module is used through inheritance. It will make available the * modifiers `whenNotPaused` and `whenPaused`, which can be applied to * the functions of your contract. Note that they will not be pausable by * simply including this module, only once the modifiers are put in place. */ abstract contract PausableUpgradeable is Initializable, ContextUpgradeable { /** * @dev Emitted when the pause is triggered by `account`. */ event Paused(address account); /** * @dev Emitted when the pause is lifted by `account`. */ event Unpaused(address account); bool private _paused; /** * @dev Initializes the contract in unpaused state. */ function __Pausable_init() internal onlyInitializing { __Context_init_unchained(); __Pausable_init_unchained(); } function __Pausable_init_unchained() internal onlyInitializing { _paused = false; } /** * @dev Returns true if the contract is paused, and false otherwise. */ function paused() public view virtual returns (bool) { return _paused; } /** * @dev Modifier to make a function callable only when the contract is not paused. * * Requirements: * * - The contract must not be paused. */ modifier whenNotPaused() { require(!paused(), "Pausable: paused"); _; } /** * @dev Modifier to make a function callable only when the contract is paused. * * Requirements: * * - The contract must be paused. */ modifier whenPaused() { require(paused(), "Pausable: not paused"); _; } /** * @dev Triggers stopped state. * * Requirements: * * - The contract must not be paused. */ function _pause() internal virtual whenNotPaused { _paused = true; emit Paused(_msgSender()); } /** * @dev Returns to normal state. * * Requirements: * * - The contract must be paused. */ function _unpause() internal virtual whenPaused { _paused = false; emit Unpaused(_msgSender()); } uint256[49] private __gap; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Contract module that helps prevent reentrant calls to a function. * * Inheriting from `ReentrancyGuard` will make the `nonReentrant` modifier * available, which can be aplied to functions to make sure there are no nested * (reentrant) calls to them. * * Note that because there is a single `nonReentrant` guard, functions marked as * `nonReentrant` may not call one another. This can be worked around by making * those functions `private`, and then adding `external` `nonReentrant` entry * points to them. */ contract ProxyReentrancyGuard { /// @dev counter to allow mutex lock with only one SSTORE operation uint256 private _guardCounter; bool private _initialized; function initNonReentrant() public { require(!_initialized, "Already initialized"); _initialized = true; _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, "ReentrancyGuard: reentrant call"); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; // Clone of syntetix contract without constructor contract ProxyOwned { address public owner; address public nominatedOwner; bool private _initialized; bool private _transferredAtInit; function setOwner(address _owner) public { require(_owner != address(0), "Owner address cannot be 0"); require(!_initialized, "Already initialized, use nominateNewOwner"); _initialized = true; owner = _owner; emit OwnerChanged(address(0), _owner); } function nominateNewOwner(address _owner) external onlyOwner { nominatedOwner = _owner; emit OwnerNominated(_owner); } function acceptOwnership() external { require(msg.sender == nominatedOwner, "You must be nominated before you can accept ownership"); emit OwnerChanged(owner, nominatedOwner); owner = nominatedOwner; nominatedOwner = address(0); } function transferOwnershipAtInit(address proxyAddress) external onlyOwner { require(proxyAddress != address(0), "Invalid address"); require(!_transferredAtInit, "Already transferred"); owner = proxyAddress; _transferredAtInit = true; emit OwnerChanged(owner, proxyAddress); } modifier onlyOwner { _onlyOwner(); _; } function _onlyOwner() private view { require(msg.sender == owner, "Only the contract owner may perform this action"); } event OwnerNominated(address newOwner); event OwnerChanged(address oldOwner, address newOwner); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; interface ISportsAMM { /* ========== VIEWS / VARIABLES ========== */ enum Position { Home, Away, Draw } function getMarketDefaultOdds(address _market, bool isSell) external view returns (uint[] memory); function buyFromAMM( address market, Position position, uint amount, uint expectedPayout, uint additionalSlippage ) external; function buyFromAmmQuote( address market, Position position, uint amount ) external view returns (uint); function buyPriceImpact( address market, ISportsAMM.Position position, uint amount ) external view returns (int impact); }
// SPDX-License-Identifier: MIT pragma solidity >=0.5.16; import "../interfaces/IPositionalMarketManager.sol"; import "../interfaces/IPosition.sol"; import "../interfaces/IPriceFeed.sol"; interface ISportPositionalMarket { /* ========== TYPES ========== */ enum Phase { Trading, Maturity, Expiry } enum Side { Cancelled, Home, Away, Draw } /* ========== VIEWS / VARIABLES ========== */ function getOptions() external view returns ( IPosition home, IPosition away, IPosition draw ); function times() external view returns (uint maturity, uint destruction); function getGameDetails() external view returns (bytes32 gameId, string memory gameLabel); function getGameId() external view returns (bytes32); function deposited() external view returns (uint); function optionsCount() external view returns (uint); function creator() external view returns (address); function resolved() external view returns (bool); function cancelled() external view returns (bool); function paused() external view returns (bool); function phase() external view returns (Phase); function canResolve() external view returns (bool); function result() external view returns (Side); function tags(uint idx) external view returns (uint); function getStampedOdds() external view returns ( uint, uint, uint ); function balancesOf(address account) external view returns ( uint home, uint away, uint draw ); function totalSupplies() external view returns ( uint home, uint away, uint draw ); function getMaximumBurnable(address account) external view returns (uint amount); /* ========== MUTATIVE FUNCTIONS ========== */ function setPaused(bool _paused) external; function updateDates(uint256 _maturity, uint256 _expiry) external; function mint(uint value) external; function exerciseOptions() external; function restoreInvalidOdds( uint _homeOdds, uint _awayOdds, uint _drawOdds ) external; function burnOptions(uint amount) external; function burnOptionsMaximum() external; }
// SPDX-License-Identifier: MIT pragma solidity >=0.5.16; interface IStakingThales { function updateVolume(address account, uint amount) external; /* ========== VIEWS / VARIABLES ========== */ function totalStakedAmount() external view returns (uint); function stakedBalanceOf(address account) external view returns (uint); function currentPeriodRewards() external view returns (uint); function currentPeriodFees() external view returns (uint); function getLastPeriodOfClaimedRewards(address account) external view returns (uint); function getRewardsAvailable(address account) external view returns (uint); function getRewardFeesAvailable(address account) external view returns (uint); function getAlreadyClaimedRewards(address account) external view returns (uint); function getContractRewardFunds() external view returns (uint); function getContractFeeFunds() external view returns (uint); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC20/IERC20.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20Upgradeable { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom( address sender, address recipient, uint256 amount ) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Address.sol) pragma solidity ^0.8.0; /** * @dev Collection of functions related to the address type */ library AddressUpgradeable { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) pragma solidity ^0.8.0; import "../proxy/utils/Initializable.sol"; /** * @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 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. */ abstract contract ContextUpgradeable is Initializable { function __Context_init() internal onlyInitializing { __Context_init_unchained(); } function __Context_init_unchained() internal onlyInitializing { } function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } uint256[50] private __gap; }
// SPDX-License-Identifier: MIT pragma solidity >=0.5.16; import "../interfaces/IPositionalMarket.sol"; interface IPositionalMarketManager { /* ========== VIEWS / VARIABLES ========== */ function durations() external view returns (uint expiryDuration, uint maxTimeToMaturity); function capitalRequirement() external view returns (uint); function marketCreationEnabled() external view returns (bool); function onlyAMMMintingAndBurning() external view returns (bool); function transformCollateral(uint value) external view returns (uint); function reverseTransformCollateral(uint value) external view returns (uint); function totalDeposited() external view returns (uint); function numActiveMarkets() external view returns (uint); function activeMarkets(uint index, uint pageSize) external view returns (address[] memory); function numMaturedMarkets() external view returns (uint); function maturedMarkets(uint index, uint pageSize) external view returns (address[] memory); function isActiveMarket(address candidate) external view returns (bool); function isKnownMarket(address candidate) external view returns (bool); function getThalesAMM() external view returns (address); /* ========== MUTATIVE FUNCTIONS ========== */ function createMarket( bytes32 oracleKey, uint strikePrice, uint maturity, uint initialMint // initial sUSD to mint options for, ) external returns (IPositionalMarket); function resolveMarket(address market) external; function expireMarkets(address[] calldata market) external; function transferSusdTo( address sender, address receiver, uint amount ) external; }
// SPDX-License-Identifier: MIT pragma solidity >=0.5.16; import "./IPositionalMarket.sol"; interface IPosition { /* ========== VIEWS / VARIABLES ========== */ function getBalanceOf(address account) external view returns (uint); function getTotalSupply() external view returns (uint); }
// SPDX-License-Identifier: MIT pragma solidity >=0.5.16; interface IPriceFeed { // Structs struct RateAndUpdatedTime { uint216 rate; uint40 time; } // Mutative functions function addAggregator(bytes32 currencyKey, address aggregatorAddress) external; function removeAggregator(bytes32 currencyKey) external; // Views function rateForCurrency(bytes32 currencyKey) external view returns (uint); function rateAndUpdatedTime(bytes32 currencyKey) external view returns (uint rate, uint time); function getRates() external view returns (uint[] memory); function getCurrencies() external view returns (bytes32[] memory); }
// SPDX-License-Identifier: MIT pragma solidity >=0.5.16; import "../interfaces/IPositionalMarketManager.sol"; import "../interfaces/IPosition.sol"; import "../interfaces/IPriceFeed.sol"; interface IPositionalMarket { /* ========== TYPES ========== */ enum Phase { Trading, Maturity, Expiry } enum Side { Up, Down } /* ========== VIEWS / VARIABLES ========== */ function getOptions() external view returns (IPosition up, IPosition down); function times() external view returns (uint maturity, uint destructino); function getOracleDetails() external view returns ( bytes32 key, uint strikePrice, uint finalPrice ); function fees() external view returns (uint poolFee, uint creatorFee); function deposited() external view returns (uint); function creator() external view returns (address); function resolved() external view returns (bool); function phase() external view returns (Phase); function oraclePrice() external view returns (uint); function oraclePriceAndTimestamp() external view returns (uint price, uint updatedAt); function canResolve() external view returns (bool); function result() external view returns (Side); function balancesOf(address account) external view returns (uint up, uint down); function totalSupplies() external view returns (uint up, uint down); function getMaximumBurnable(address account) external view returns (uint amount); /* ========== MUTATIVE FUNCTIONS ========== */ function mint(uint value) external; function exerciseOptions() external returns (uint); function burnOptions(uint amount) external; function burnOptionsMaximum() external; }
{ "optimizer": { "enabled": true, "runs": 200 }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "libraries": {} }
[{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Claimed","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Deposited","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"maxAllowedDeposit","type":"uint256"}],"name":"MaxAllowedDepositChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"MaxAllowedUsersChanged","type":"uint256"}],"name":"MaxAllowedUsersChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"minAllowedDeposit","type":"uint256"}],"name":"MinAllowedDepositChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"oldOwner","type":"address"},{"indexed":false,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnerChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnerNominated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"round","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"roundPnL","type":"uint256"}],"name":"RoundClosed","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"roundLength","type":"uint256"}],"name":"RoundLengthChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"allocationLimitsPerMarketPerRound","type":"uint256"}],"name":"SetAllocationLimits","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"SetMinTradeAmount","type":"uint256"}],"name":"SetMinTradeAmount","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"priceLowerLimit","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"priceUpperLimit","type":"uint256"}],"name":"SetPriceLimits","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"sUSD","type":"address"}],"name":"SetSUSD","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"int256","name":"skewImpact","type":"int256"}],"name":"SetSkewImpactLimit","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"thalesAmm","type":"address"}],"name":"SportAMMChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"stakingThales","type":"address"}],"name":"StakingThalesChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"market","type":"address"},{"indexed":false,"internalType":"enum ISportsAMM.Position","name":"position","type":"uint8"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"quote","type":"uint256"}],"name":"TradeExecuted","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"utilizationRate","type":"uint256"}],"name":"UtilizationRateChanged","type":"event"},{"anonymous":false,"inputs":[],"name":"VaultStarted","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"user","type":"address"}],"name":"WithdrawalRequested","type":"event"},{"inputs":[],"name":"acceptOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"allocationLimitsPerMarketPerRound","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"allocationPerRound","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"address","name":"","type":"address"}],"name":"allocationSpentPerRound","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"address","name":"","type":"address"}],"name":"balancesPerRound","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"canCloseCurrentRound","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"capPerRound","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"closeRound","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"roundA","type":"uint256"},{"internalType":"uint256","name":"roundB","type":"uint256"}],"name":"cumulativePnLBetweenRounds","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"cumulativeProfitAndLoss","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"deposit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"depositReceipts","outputs":[{"internalType":"uint256","name":"round","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"market","type":"address"}],"name":"getAvailableAllocationForMarket","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getAvailableToDeposit","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_round","type":"uint256"},{"internalType":"address","name":"user","type":"address"}],"name":"getBalancesPerRound","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getCurrentRoundEnd","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"initNonReentrant","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"contract ISportsAMM","name":"_sportsAmm","type":"address"},{"internalType":"contract IERC20Upgradeable","name":"_sUSD","type":"address"},{"internalType":"uint256","name":"_roundLength","type":"uint256"},{"internalType":"uint256","name":"_priceLowerLimit","type":"uint256"},{"internalType":"uint256","name":"_priceUpperLimit","type":"uint256"},{"internalType":"int256","name":"_skewImpactLimit","type":"int256"},{"internalType":"uint256","name":"_allocationLimitsPerMarketPerRound","type":"uint256"},{"internalType":"uint256","name":"_maxAllowedDeposit","type":"uint256"},{"internalType":"uint256","name":"_utilizationRate","type":"uint256"},{"internalType":"uint256","name":"_minDepositAmount","type":"uint256"},{"internalType":"uint256","name":"_maxAllowedUsers","type":"uint256"},{"internalType":"uint256","name":"_minTradeAmount","type":"uint256"}],"internalType":"struct SportVault.InitParams","name":"params","type":"tuple"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"address","name":"","type":"address"}],"name":"isTradingMarketInARound","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxAllowedDeposit","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxAllowedUsers","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"minDepositAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"minTradeAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_owner","type":"address"}],"name":"nominateNewOwner","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"nominatedOwner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"priceLowerLimit","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"priceUpperLimit","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"profitAndLossPerRound","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"round","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"roundLength","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"roundStartTime","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"sUSD","outputs":[{"internalType":"contract IERC20Upgradeable","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_allocationLimitsPerMarketPerRound","type":"uint256"}],"name":"setAllocationLimits","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_maxAllowedDeposit","type":"uint256"}],"name":"setMaxAllowedDeposit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_maxAllowedUsers","type":"uint256"}],"name":"setMaxAllowedUsers","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_minDepositAmount","type":"uint256"}],"name":"setMinAllowedDeposit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_minTradeAmount","type":"uint256"}],"name":"setMinTradeAmount","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_owner","type":"address"}],"name":"setOwner","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_priceLowerLimit","type":"uint256"},{"internalType":"uint256","name":"_priceUpperLimit","type":"uint256"}],"name":"setPriceLimits","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_roundLength","type":"uint256"}],"name":"setRoundLength","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"int256","name":"_skewImpactLimit","type":"int256"}],"name":"setSkewImpactLimit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract ISportsAMM","name":"_sportAMM","type":"address"}],"name":"setSportAmm","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IStakingThales","name":"_stakingThales","type":"address"}],"name":"setStakingThales","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_utilizationRate","type":"uint256"}],"name":"setUtilizationRate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"skewImpactLimit","outputs":[{"internalType":"int256","name":"","type":"int256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"sportsAMM","outputs":[{"internalType":"contract ISportsAMM","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"stakingThales","outputs":[{"internalType":"contract IStakingThales","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"startVault","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"market","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"enum ISportsAMM.Position","name":"position","type":"uint8"}],"name":"trade","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"tradingAllocation","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"address","name":"","type":"address"}],"name":"tradingMarketPositionPerRound","outputs":[{"internalType":"enum ISportsAMM.Position","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"tradingMarketsPerRound","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"proxyAddress","type":"address"}],"name":"transferOwnershipAtInit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"address","name":"","type":"address"}],"name":"userInRound","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"usersCurrentlyInVault","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"usersPerRound","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"utilizationRate","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"vaultStarted","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"withdrawalRequest","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"withdrawalRequested","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"}]
Contract Creation Code
608060405234801561001057600080fd5b506137de806100206000396000f3fe608060405234801561001057600080fd5b50600436106103ba5760003560e01c806371bb4b47116101f4578063c3b83f5f1161011a578063ddcc8fe9116100ad578063e76a02791161007c578063e76a027914610891578063ebc79772146108a4578063ee161cce146108ac578063fd8a8cc6146108b457600080fd5b8063ddcc8fe91461085a578063e278fe6f1461086d578063e45b2e8814610875578063e75c93d91461088857600080fd5b8063d27c0797116100e9578063d27c07971461082d578063db7f92d414610836578063dd636bc714610849578063dda9046f1461085157600080fd5b8063c3b83f5f146107db578063c9925288146107ee578063c9f4ff4614610806578063cee73a761461081957600080fd5b80639324cac711610192578063a9050d4d11610161578063a9050d4d14610796578063b6b55f251461079f578063be805e3c146107b2578063c137a60f146107bb57600080fd5b80639324cac71461070a578063942f53571461071d57806395ba9a7014610758578063a250badb1461078357600080fd5b80637f852582116101ce5780637f852582146106c257806387117630146106d55780638b649b94146106e85780638da5cb5b146106f157600080fd5b806371bb4b471461069257806374094edd1461069a57806379ba5097146106ba57600080fd5b8063384e631c116102e45780635ddd3e83116102775780636719b2ee116102465780636719b2ee1461060c578063681312f5146106485780636c321c8a1461065b57806371143ab91461066457600080fd5b80635ddd3e83146105a1578063610589e1146105cc578063634e0d97146105d5578063645006ca1461060357600080fd5b806353a47bb7116102b357806353a47bb714610568578063569917911461057b5780635c975abb1461058e5780635d1c236d1461059957600080fd5b8063384e631c1461051957806340774ff61461052c578063456ff7881461053f5780634ae7937f1461054857600080fd5b8063202ffce81161035c578063322ce77a1161032b578063322ce77a146104ca578063336d30ed146104d3578063343e4f9f146104f3578063370faeb01461050657600080fd5b8063202ffce81461047c57806325a663951461048f5780632ef04761146104af578063311c56df146104c257600080fd5b8063146ca53111610398578063146ca531146104255780631627540c1461042e5780631daae173146104415780631e9224601461047457600080fd5b806306d1fb3c146103bf578063082f9fd4146103e557806313af403514610410575b600080fd5b6103d26103cd366004613516565b6108c7565b6040519081526020015b60405180910390f35b6103f86103f3366004613545565b6108f1565b6040516001600160a01b0390911681526020016103dc565b61042361041e36600461344e565b610929565b005b6103d260695481565b61042361043c36600461344e565b610a69565b61046461044f36600461344e565b606f6020526000908152604090205460ff1681565b60405190151581526020016103dc565b6103d2610abf565b61042361048a3660046134ce565b610af9565b6103d261049d3660046134ce565b60796020526000908152604090205481565b6104236104bd3660046134ce565b610b36565b610423610b73565b6103d2607c5481565b6103d26104e13660046134ce565b60766020526000908152604090205481565b6103f8610501366004613545565b610dfe565b610423610514366004613545565b610e1a565b6104236105273660046134fe565b610eb8565b61042361053a3660046134ce565b610fed565b6103d260815481565b6103d26105563660046134ce565b60716020526000908152604090205481565b6001546103f8906001600160a01b031681565b61042361058936600461346a565b61102a565b60345460ff16610464565b61042361150a565b6103d26105af366004613516565b606e60209081526000928352604080842090915290825290205481565b6103d2607b5481565b6104646105e3366004613516565b606d60209081526000928352604080842090915290825290205460ff1681565b6103d2607a5481565b61063361061a36600461344e565b6070602052600090815260409020805460019091015482565b604080519283526020830191909152016103dc565b6104236106563660046134ce565b611623565b6103d260785481565b610464610672366004613516565b607460209081526000928352604080842090915290825290205460ff1681565b6103d2611660565b6103d26106a83660046134ce565b60756020526000908152604090205481565b610423611680565b6104236106d036600461344e565b61177d565b6104236106e33660046134ce565b6117d3565b6103d2606a5481565b6000546103f8906201000090046001600160a01b031681565b6068546103f8906001600160a01b031681565b61074b61072b366004613516565b607360209081526000928352604080842090915290825290205460ff1681565b6040516103dc9190613687565b6103d2610766366004613516565b607e60209081526000928352604080842090915290825290205481565b6103d261079136600461344e565b611868565b6103d2607d5481565b6104236107ad3660046134ce565b6118ce565b6103d260805481565b6103d26107c93660046134ce565b606b6020526000908152604090205481565b6104236107e936600461344e565b611c1a565b6067546103f89061010090046001600160a01b031681565b6103d2610814366004613545565b611d33565b60685461046490600160a01b900460ff1681565b6103d260775481565b6104236108443660046134ce565b611d6c565b6103d2611da9565b6103d260825481565b6104236108683660046134ce565b611dda565b610423611e17565b61042361088336600461344e565b612567565b6103d2607f5481565b61042361089f3660046134ce565b612651565b61042361268e565b6104646126ec565b6083546103f8906001600160a01b031681565b6000828152606e602090815260408083206001600160a01b03851684529091529020545b92915050565b6072602052816000526040600020818154811061090d57600080fd5b6000918252602090912001546001600160a01b03169150829050565b6001600160a01b0381166109845760405162461bcd60e51b815260206004820152601960248201527f4f776e657220616464726573732063616e6e6f7420626520300000000000000060448201526064015b60405180910390fd5b600154600160a01b900460ff16156109f05760405162461bcd60e51b815260206004820152602960248201527f416c726561647920696e697469616c697a65642c20757365206e6f6d696e617460448201526832a732bba7bbb732b960b91b606482015260840161097b565b6001805460ff60a01b1916600160a01b179055600080546001600160a01b03831662010000810262010000600160b01b03199092169190911782556040805192835260208301919091527fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c91015b60405180910390a150565b610a716128a2565b600180546001600160a01b0319166001600160a01b0383169081179091556040519081527f906a1c6bd7e3091ea86693dd029a831c19049ce77f1dce2ce0bab1cacbabce2290602001610a5e565b6078546069546000908152607160205260408120549091670de0b6b3a764000091610aea9190613700565b610af491906136e0565b905090565b610b016128a2565b607b8190556040518181527fe7c2c09f66c8b970b4a99250f4d0844e1496b9d51d4760a17b0134ddd52023e190602001610a5e565b610b3e6128a2565b60818190556040518181527f137f353e194da87258fd6c2b78eb1cfb9f2ce996f3466729d2464eccb7ce612990602001610a5e565b606854600160a01b900460ff16610bc45760405162461bcd60e51b815260206004820152601560248201527415985d5b1d081a185cc81b9bdd081cdd185c9d1959605a1b604482015260640161097b565b336000908152606f602052604090205460ff1615610c245760405162461bcd60e51b815260206004820152601c60248201527f5769746864726177616c20616c72656164792072657175657374656400000000604482015260640161097b565b6069546000908152606e60209081526040808320338452909152902054610c835760405162461bcd60e51b81526020600482015260136024820152724e6f7468696e6720746f20776974686472617760681b604482015260640161097b565b606e60006069546001610c9691906136c8565b81526020808201929092526040908101600090812033825290925290205415610d205760405162461bcd60e51b815260206004820152603660248201527f43616e277420776974686472617720617320796f7520616c72656164792064656044820152751c1bdcda5d195908199bdc881b995e1d081c9bdd5b9960521b606482015260840161097b565b60006069546001610d3191906136c8565b6069546000908152606e602090815260408083203384528252808320548484526079909252909120549192501015610da1576069546000908152606e6020908152604080832033845282528083205484845260799092528220805491929091610d9b90849061371f565b90915550505b6001607c54610db0919061371f565b607c55336000818152606f6020908152604091829020805460ff1916600117905590519182527fe5892ff2a8b08efb903ffbba1f0514c1d3e22eea34dd5b89cf30aabce03dde5a9101610a5e565b606c602052816000526040600020818154811061090d57600080fd5b610e226128a2565b808210610e715760405162461bcd60e51b815260206004820152601a60248201527f496e76616c6964207072696365206c696d69742076616c756573000000000000604482015260640161097b565b607f829055608081905560408051838152602081018390527f34b23d671026520e294c1060acc36120677e8c9bd073a8f6577a6f241785b1a6910160405180910390a15050565b600054610100900460ff16610ed35760005460ff1615610ed7565b303b155b610f3a5760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b606482015260840161097b565b600054610100900460ff16158015610f5c576000805461ffff19166101011790555b610fae610f6c602084018461344e565b610f7c604085016020860161344e565b610f8c606086016040870161344e565b856060013586610100013587610120013588610140013589610160013561291c565b608080830135607f5560a0830135905560c082013560815560e0820135607d556101808201356082558015610fe9576000805461ff00191690555b5050565b610ff56128a2565b60788190556040518181527fc117ccf765672707ebe3c1606037488c1e27dc1f42b5266e3d6b496db7d4209e90602001610a5e565b60016066600082825461103d91906136c8565b909155505060665460345460ff161561108b5760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b604482015260640161097b565b606854600160a01b900460ff166110dc5760405162461bcd60e51b815260206004820152601560248201527415985d5b1d081a185cc81b9bdd081cdd185c9d1959605a1b604482015260640161097b565b60825483101561112e5760405162461bcd60e51b815260206004820152601860248201527f416d6f756e74206c657373207468616e206d696e696d756d0000000000000000604482015260640161097b565b60008490506000816001600160a01b0316639e3b34bf6040518163ffffffff1660e01b8152600401604080518083038186803b15801561116d57600080fd5b505afa158015611181573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111a59190613566565b50606a546069546000908152606b60205260409020549192506111c7916136c8565b811061120d5760405162461bcd60e51b815260206004820152601560248201527413585c9ad95d081d1a5b59481b9bdd081d985b1a59605a1b604482015260640161097b565b60675460405163270e13ef60e01b815260009161010090046001600160a01b03169063270e13ef9061124f908a908990670de0b6b3a7640000906004016135f4565b60206040518083038186803b15801561126757600080fd5b505afa15801561127b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061129f91906134e6565b9050600081116112e95760405162461bcd60e51b815260206004820152601560248201527405072696365206e6f74206d6f7265207468616e203605c1b604482015260640161097b565b606754604051632fd1b02d60e21b815260009161010090046001600160a01b03169063bf46c0b490611323908b908a908c906004016135f4565b60206040518083038186803b15801561133b57600080fd5b505afa15801561134f573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061137391906134e6565b9050607f54821015801561138957506080548211155b6113ce5760405162461bcd60e51b815260206004820152601660248201527513585c9ad95d081c1c9a58d9481b9bdd081d985b1a5960521b604482015260640161097b565b60815481126114165760405162461bcd60e51b81526020600482015260146024820152730a6d6caee40d2dae0c2c6e840e8dede40d0d2ced60631b604482015260640161097b565b611421888789612a76565b60695460009081526074602090815260408083206001600160a01b038c16845290915290205460ff166114af576069805460009081526072602090815260408083208054600180820183559185528385200180546001600160a01b0319166001600160a01b038f169081179091559454845260748352818420948452939091529020805460ff191690911790555b5050505060665481146115045760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015260640161097b565b50505050565b6115126128a2565b606854600160a01b900460ff161561156c5760405162461bcd60e51b815260206004820152601960248201527f5661756c742068617320616c7265616479207374617274656400000000000000604482015260640161097b565b6001606955427fa775687211c2b3346a0f5a2a0e7590e6c1838453e3785e6dd2a8efd6265ddf15556068805460ff60a01b1916600160a01b17905560796020527fdf6d6ad01a16c6118cfd605fcb55ad218b43517981ef4cc6d63a492cf34990d954600260009081527f7d4d2b02426547888e9185e69135196c4ed1edbc114060100a6ef94f8b5f60df919091556040517f59760ad83ef06d1a0bc439d8b39a42a870493f0cd3bc3d53bbd3e7c6991f494f9190a1565b61162b6128a2565b606a8190556040518181527f1d1fb7111c3779798bd4aefb2daea07ee8257a13c7eaceba89b4b1ccd405050d90602001610a5e565b606a546069546000908152606b60205260408120549091610af4916136c8565b6001546001600160a01b031633146116f85760405162461bcd60e51b815260206004820152603560248201527f596f75206d757374206265206e6f6d696e61746564206265666f726520796f7560448201527402063616e20616363657074206f776e65727368697605c1b606482015260840161097b565b60005460015460408051620100009093046001600160a01b03908116845290911660208301527fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c910160405180910390a1600180546000805462010000600160b01b0319166001600160a01b03831662010000021790556001600160a01b0319169055565b6117856128a2565b608380546001600160a01b0319166001600160a01b0383169081179091556040519081527f3c7faa500efbd341aedbf1ee7ebd52ea36d226dda76bc01dd39b43d46f55b8d390602001610a5e565b6117db6128a2565b68056bc75e2d6310000081106118335760405162461bcd60e51b815260206004820152601f60248201527f496e76616c696420616c6c6f636174696f6e206c696d69742076616c75657300604482015260640161097b565b607d8190556040518181527f9fb019ef2cdd86e0c7772694b935b2fd45131410802474ef0a8bf0afff94a40390602001610a5e565b60008068056bc75e2d63100000607d54611880610abf565b61188a9190613700565b61189491906136e0565b6069546000908152607e602090815260408083206001600160a01b03881684529091529020549091506118c7908261371f565b9392505050565b336000908152606f6020526040902054819060ff16156119405760405162461bcd60e51b815260206004820152602760248201527f5769746864726177616c206973207265717565737465642c2063616e6e6f742060448201526619195c1bdcda5d60ca1b606482015260840161097b565b607a548110156119835760405162461bcd60e51b815260206004820152600e60248201526d125b9d985b1a5908185b5bdd5b9d60921b604482015260640161097b565b6077548160796000606954600161199a91906136c8565b8152602001908152602001600020546119b391906136c8565b1115611a015760405162461bcd60e51b815260206004820181905260248201527f4465706f73697420616d6f756e742065786365656473207661756c7420636170604482015260640161097b565b606854611a19906001600160a01b0316333085612f07565b60006069546001611a2a91906136c8565b6069546000908152606e60209081526040808320338452909152902054909150158015611a6e57506000818152606e60209081526040808320338452909152902054155b15611b2757607b54607c5410611ac65760405162461bcd60e51b815260206004820152601b60248201527f4d617820616d6f756e74206f6620757365727320726561636865640000000000604482015260640161097b565b6000818152606c602090815260408083208054600181810183559185528385200180546001600160a01b03191633908117909155858552606d8452828520908552909252909120805460ff191682179055607c54611b23916136c8565b607c555b6000818152606e6020908152604080832033845290915281208054859290611b509084906136c8565b90915550506040805180820182528281526000838152606e6020908152838220338084529082528483205482850190815290835260708252848320935184555160019093019290925583815260719091529081208054859290611bb49084906136c8565b909155505060008181526079602052604081208054859290611bd79084906136c8565b909155505060408051338152602081018590527f2da466a7b24304f47e87fa2e1e5a81b9831ce54fec19055ce277ca2f39ba42c4910160405180910390a1505050565b611c226128a2565b6001600160a01b038116611c6a5760405162461bcd60e51b815260206004820152600f60248201526e496e76616c6964206164647265737360881b604482015260640161097b565b600154600160a81b900460ff1615611cba5760405162461bcd60e51b8152602060048201526013602482015272105b1c9958591e481d1c985b9cd9995c9c9959606a1b604482015260640161097b565b600080546001600160a01b038381166201000081810262010000600160b01b031990941693909317938490556001805460ff60a81b1916600160a81b1790556040805193909404909116825260208201527fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c9101610a5e565b6000828152607660208181526040808420546075835281852054868652939092528320549091611d6291613700565b6118c791906136e0565b611d746128a2565b607a8190556040518181527f990717cc219e5348c1b88bb0ff530d804f0b6f54f3b03844a2bfbe4eb1e9c5d690602001610a5e565b6000607960006069546001611dbe91906136c8565b815260200190815260200160002054607754610af4919061371f565b611de26128a2565b60778190556040518181527f8c43aa02599ac8f8bab4724621ceea5e7a06b07bbbfaf3b7bd0386cbe481ea3c90602001610a5e565b600160666000828254611e2a91906136c8565b909155505060665460345460ff1615611e785760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b604482015260640161097b565b611e806126ec565b611ecc5760405162461bcd60e51b815260206004820152601960248201527f43616e277420636c6f73652063757272656e7420726f756e6400000000000000604482015260640161097b565b611ed4612f72565b6000607160006069546001611ee991906136c8565b8152602081019190915260409081016000205460685491516370a0823160e01b815230600482015290916001600160a01b0316906370a082319060240160206040518083038186803b158015611f3e57600080fd5b505afa158015611f52573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f7691906134e6565b611f80919061371f565b606954600090815260716020526040902054909150611fb357606954600090815260756020526040902060019055611ff4565b606954600090815260716020526040902054611fd7670de0b6b3a764000083613700565b611fe191906136e0565b6069546000908152607560205260409020555b60005b6069546000908152606c6020526040902054811015612325576069546000908152606c6020526040812080548390811061204157634e487b7160e01b600052603260045260246000fd5b6000918252602080832090910154606954835260758252604080842054606e84528185206001600160a01b0390931680865292909352832054909350670de0b6b3a76400009161209091613700565b61209a91906136e0565b6069546000908152606d602090815260408083206001600160a01b038716845290915290205490915060ff1615612310576001600160a01b0382166000908152606f602052604090205460ff166122205780606e600060695460016120ff91906136c8565b81526020019081526020016000206000846001600160a01b03166001600160a01b031681526020019081526020016000205461213b91906136c8565b606e6000606954600161214e91906136c8565b81526020019081526020016000206000846001600160a01b03166001600160a01b03168152602001908152602001600020819055506001606d6000606954600161219891906136c8565b8152602080820192909252604090810160009081206001600160a01b03871682529092528120805460ff191692151592909217909155606954606c91906121e09060016136c8565b8152602080820192909252604001600090812080546001810182559082529190200180546001600160a01b0319166001600160a01b038416179055612310565b6000606e6000606954600161223591906136c8565b8152602080820192909252604090810160009081206001600160a01b0380881683529352209190915560685461226d911683836131cf565b6001600160a01b0382166000908152606f60205260408120805460ff19169055606954606d9082906122a09060016136c8565b8152602080820192909252604090810160009081206001600160a01b03871680835290845290829020805460ff19169415159490941790935580519283529082018390527fd8138f8a3f377c5259ca548e70e4c2de94f129f5a11036a15b69513cba2b426a910160405180910390a15b5050808061231d90613762565b915050611ff7565b5060695460011415612354576069546000908152607560209081526040808320546076909252909120556123b7565b606954600081815260756020526040812054670de0b6b3a76400009290916076916123819060019061371f565b81526020019081526020016000205461239a9190613700565b6123a491906136e0565b6069546000908152607660205260409020555b6001606960008282546123ca91906136c8565b90915550506069546000908152606b60205260409081902042905560685490516370a0823160e01b81523060048201526001600160a01b03909116906370a082319060240160206040518083038186803b15801561242757600080fd5b505afa15801561243b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061245f91906134e6565b6069805460009081526071602052604080822093909355905480825291812054916079919061248f9060016136c8565b8152602001908152602001600020819055507fc67dda8e11f1aa941c7e74466b1859a07a32f46aaf641d29b83be348424d93cd60016069546124d1919061371f565b6075600060016069546124e4919061371f565b81526020019081526020016000205460405161250a929190918252602082015260400190565b60405180910390a15060665481146125645760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015260640161097b565b50565b61256f6128a2565b60678054610100600160a81b0319166101006001600160a01b038481168202929092179283905560685460405163095ea7b360e01b81529190930482166004820152600019602482015291169063095ea7b390604401602060405180830381600087803b1580156125df57600080fd5b505af11580156125f3573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061261791906134ae565b506040516001600160a01b03821681527f576297e5fcc8cd907ee80b240284865eb3d821bdc5232e6ee9e4d78a12531c0990602001610a5e565b6126596128a2565b60828190556040518181527f26ea09cdab135064e784e44516fc5b3d619360d241ae64bff47153b2e5ee610e90602001610a5e565b60675460ff16156126d75760405162461bcd60e51b8152602060048201526013602482015272105b1c9958591e481a5b9a5d1a585b1a5e9959606a1b604482015260640161097b565b6067805460ff19166001908117909155606655565b606854600090600160a01b900460ff1615806127255750606a546069546000908152606b602052604090205461272291906136c8565b42105b156127305750600090565b60005b60695460009081526072602052604090205481101561289a57606954600090815260726020526040812080548390811061277d57634e487b7160e01b600052603260045260246000fd5b6000918252602091829020015460408051633f6fa65560e01b815290516001600160a01b0390921693508392633f6fa65592600480840193829003018186803b1580156127c957600080fd5b505afa1580156127dd573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061280191906134ae565b15806128795750806001600160a01b0316635c975abb6040518163ffffffff1660e01b815260040160206040518083038186803b15801561284157600080fd5b505afa158015612855573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061287991906134ae565b156128875760009250505090565b508061289281613762565b915050612733565b506001905090565b6000546201000090046001600160a01b0316331461291a5760405162461bcd60e51b815260206004820152602f60248201527f4f6e6c792074686520636f6e7472616374206f776e6572206d6179207065726660448201526e37b936903a3434b99030b1ba34b7b760891b606482015260840161097b565b565b600054610100900460ff166129875760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b606482015260840161097b565b61299088610929565b61299861268e565b60678054610100600160a81b0319166101006001600160a01b038a811682029290921792839055606880546001600160a01b0319168a8416908117909155606a89905560778890556078879055607a869055607b85905560405163095ea7b360e01b8152919093049091166004820152600019602482015263095ea7b390604401602060405180830381600087803b158015612a3357600080fd5b505af1158015612a47573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a6b91906134ae565b505050505050505050565b60695460009081526074602090815260408083206001600160a01b038716845290915290205460ff1615612b7357816002811115612ac457634e487b7160e01b600052602160045260246000fd5b60695460009081526073602090815260408083206001600160a01b038816845290915290205460ff166002811115612b0c57634e487b7160e01b600052602160045260246000fd5b14612b735760405162461bcd60e51b815260206004820152603160248201527f43616e6e6f7420747261646520646966666572656e74206f7074696f6e73206f6044820152701b881d1a19481cd85b59481b585c9ad95d607a1b606482015260840161097b565b60675460405163270e13ef60e01b815260009161010090046001600160a01b03169063270e13ef90612bad908790879087906004016135f4565b60206040518083038186803b158015612bc557600080fd5b505afa158015612bd9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612bfd91906134e6565b9050600068056bc75e2d63100000607d54612c16610abf565b612c209190613700565b612c2a91906136e0565b6069546000908152607e602090815260408083206001600160a01b038a1684529091529020549091508190612c5f90846136c8565b10612cc25760405162461bcd60e51b815260206004820152602d60248201527f416d6f756e74206578636565647320617661696c61626c6520616c6c6f63617460448201526c1a5bdb88199bdc88185cdcd95d609a1b606482015260840161097b565b6068546040516370a0823160e01b81523060048201526000916001600160a01b0316906370a082319060240160206040518083038186803b158015612d0657600080fd5b505afa158015612d1a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612d3e91906134e6565b60675460405163221d7ae160e21b815291925061010090046001600160a01b031690638875eb8490612d7d90899089908990899060009060040161364e565b600060405180830381600087803b158015612d9757600080fd5b505af1158015612dab573d6000803e3d6000fd5b50506068546040516370a0823160e01b8152306004820152600093506001600160a01b0390911691506370a082319060240160206040518083038186803b158015612df557600080fd5b505afa158015612e09573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612e2d91906134e6565b6069546000908152607e602090815260408083206001600160a01b038c168452909152812080549293508692909190612e679084906136c8565b909155505060695460009081526073602090815260408083206001600160a01b038b1684529091529020805487919060ff19166001836002811115612ebc57634e487b7160e01b600052602160045260246000fd5b02179055507fd1fc86fd7e2808fb6a4d745c0f26983bd36784721df1e29a27a28ce3fcdc741687878787604051612ef6949392919061361f565b60405180910390a150505050505050565b6040516001600160a01b03808516602483015283166044820152606481018290526115049085906323b872dd60e01b906084015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152613204565b6000805b606954600090815260726020526040902054811015610fe9576069546000908152607260205260409020805482908110612fc057634e487b7160e01b600052603260045260246000fd5b6000918252602091829020015460408051635c975abb60e01b815290516001600160a01b0390921694508492635c975abb92600480840193829003018186803b15801561300c57600080fd5b505afa158015613020573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061304491906134ae565b1580156130bd5750816001600160a01b0316633f6fa6556040518163ffffffff1660e01b815260040160206040518083038186803b15801561308557600080fd5b505afa158015613099573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906130bd91906134ae565b156131bd57604051636392a51f60e01b8152306004820152600090819081906001600160a01b03861690636392a51f9060240160606040518083038186803b15801561310857600080fd5b505afa15801561311c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906131409190613589565b92509250925060008311806131555750600082115b806131605750600081115b156131b957846001600160a01b031663851492586040518163ffffffff1660e01b8152600401600060405180830381600087803b1580156131a057600080fd5b505af11580156131b4573d6000803e3d6000fd5b505050505b5050505b806131c781613762565b915050612f76565b6040516001600160a01b0383166024820152604481018290526131ff90849063a9059cbb60e01b90606401612f3b565b505050565b6000613259826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166132d69092919063ffffffff16565b8051909150156131ff578080602001905181019061327791906134ae565b6131ff5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b606482015260840161097b565b60606132e584846000856132ed565b949350505050565b60608247101561334e5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b606482015260840161097b565b843b61339c5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015260640161097b565b600080866001600160a01b031685876040516133b891906135d8565b60006040518083038185875af1925050503d80600081146133f5576040519150601f19603f3d011682016040523d82523d6000602084013e6133fa565b606091505b509150915061340a828286613415565b979650505050505050565b606083156134245750816118c7565b8251156134345782518084602001fd5b8160405162461bcd60e51b815260040161097b9190613695565b60006020828403121561345f578081fd5b81356118c781613793565b60008060006060848603121561347e578182fd5b833561348981613793565b9250602084013591506040840135600381106134a3578182fd5b809150509250925092565b6000602082840312156134bf578081fd5b815180151581146118c7578182fd5b6000602082840312156134df578081fd5b5035919050565b6000602082840312156134f7578081fd5b5051919050565b60006101a08284031215613510578081fd5b50919050565b60008060408385031215613528578182fd5b82359150602083013561353a81613793565b809150509250929050565b60008060408385031215613557578182fd5b50508035926020909101359150565b60008060408385031215613578578182fd5b505080516020909101519092909150565b60008060006060848603121561359d578283fd5b8351925060208401519150604084015190509250925092565b600381106135d457634e487b7160e01b600052602160045260246000fd5b9052565b600082516135ea818460208701613736565b9190910192915050565b6001600160a01b03841681526060810161361160208301856135b6565b826040830152949350505050565b6001600160a01b03851681526080810161363c60208301866135b6565b60408201939093526060015292915050565b6001600160a01b038616815260a0810161366b60208301876135b6565b8460408301528360608301528260808301529695505050505050565b602081016108eb82846135b6565b60208152600082518060208401526136b4816040850160208701613736565b601f01601f19169190910160400192915050565b600082198211156136db576136db61377d565b500190565b6000826136fb57634e487b7160e01b81526012600452602481fd5b500490565b600081600019048311821515161561371a5761371a61377d565b500290565b6000828210156137315761373161377d565b500390565b60005b83811015613751578181015183820152602001613739565b838111156115045750506000910152565b60006000198214156137765761377661377d565b5060010190565b634e487b7160e01b600052601160045260246000fd5b6001600160a01b038116811461256457600080fdfea2646970667358221220224de9a5a2b43d9dbb3f985d3c437b9c570634d70eb54d4018e30e23b1fb3c2b64736f6c63430008040033