Source Code
Overview
ETH Balance
0 ETH
More Info
ContractCreator
Multichain Info
N/A
Loading...
Loading
This contract may be a proxy contract. Click on More Options and select Is this a proxy? to confirm and enable the "Read as Proxy" & "Write as Proxy" tabs.
Contract Name:
SportsAMMV2LiquidityPool
Compiler Version
v0.8.20+commit.a1b79de6
Optimization Enabled:
Yes with 200 runs
Other Settings:
paris EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "@openzeppelin/contracts-upgradeable/utils/PausableUpgradeable.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/proxy/Clones.sol";
import "../../utils/proxy/ProxyReentrancyGuard.sol";
import "../../utils/proxy/ProxyOwned.sol";
import "@thales-dao/contracts/contracts/interfaces/IStakingThales.sol";
import "@thales-dao/contracts/contracts/interfaces/IPriceFeed.sol";
import "@thales-dao/contracts/contracts/interfaces/IAddressManager.sol";
import "./SportsAMMV2LiquidityPoolRound.sol";
import "../Ticket.sol";
import "../../interfaces/ISportsAMMV2Manager.sol";
import "../../interfaces/ISportsAMMV2.sol";
contract SportsAMMV2LiquidityPool is Initializable, ProxyOwned, PausableUpgradeable, ProxyReentrancyGuard {
/* ========== LIBRARIES ========== */
using SafeERC20 for IERC20;
/* ========== STRUCT DEFINITION ========== */
struct InitParams {
address _owner;
address _sportsAMM;
address _addressManager;
IERC20 _collateral;
uint _roundLength;
uint _maxAllowedDeposit;
uint _minDepositAmount;
uint _maxAllowedUsers;
uint _utilizationRate;
address _safeBox;
uint _safeBoxImpact;
bytes32 _collateralKey;
}
/* ========== CONSTANTS ========== */
uint private constant ONE = 1e18;
uint private constant ONE_PERCENT = 1e16;
uint private constant MAX_APPROVAL = type(uint256).max;
/* ========== STATE VARIABLES ========== */
ISportsAMMV2 public sportsAMM;
IERC20 public collateral;
bool public started;
uint public round;
uint public roundLength;
// actually second round, as first one is default for mixed round and never closes
uint public firstRoundStartTime;
mapping(uint => address) public roundPools;
mapping(uint => address[]) public usersPerRound;
mapping(uint => mapping(address => bool)) public userInRound;
mapping(uint => mapping(address => uint)) public balancesPerRound;
mapping(uint => uint) public allocationPerRound;
mapping(address => bool) public withdrawalRequested;
mapping(address => uint) public withdrawalShare;
mapping(uint => address[]) public tradingTicketsPerRound;
mapping(uint => mapping(address => bool)) public isTradingTicketInARound;
mapping(uint => mapping(address => bool)) public ticketAlreadyExercisedInRound;
mapping(address => uint) public roundPerTicket;
mapping(uint => uint) public profitAndLossPerRound;
mapping(uint => uint) public cumulativeProfitAndLoss;
uint public maxAllowedDeposit;
uint public minDepositAmount;
uint public maxAllowedUsers;
uint public usersCurrentlyInPool;
address public defaultLiquidityProvider;
address public poolRoundMastercopy;
uint public totalDeposited;
bool public roundClosingPrepared;
uint public usersProcessedInRound;
uint public utilizationRate;
address public safeBox;
uint public safeBoxImpact;
IAddressManager public addressManager;
bytes32 public collateralKey;
/* ========== CONSTRUCTOR ========== */
function initialize(InitParams calldata params) external initializer {
setOwner(params._owner);
initNonReentrant();
sportsAMM = ISportsAMMV2(params._sportsAMM);
addressManager = IAddressManager(params._addressManager);
collateral = params._collateral;
collateralKey = params._collateralKey;
roundLength = params._roundLength;
maxAllowedDeposit = params._maxAllowedDeposit;
minDepositAmount = params._minDepositAmount;
maxAllowedUsers = params._maxAllowedUsers;
utilizationRate = params._utilizationRate;
safeBox = params._safeBox;
safeBoxImpact = params._safeBoxImpact;
collateral.approve(params._sportsAMM, MAX_APPROVAL);
round = 1;
}
/* ========== EXTERNAL WRITE FUNCTIONS ========== */
/// @notice start pool and begin round #2
function start() external onlyOwner {
require(!started, "LP has already started");
require(allocationPerRound[2] > 0, "Can not start with 0 deposits");
firstRoundStartTime = block.timestamp;
round = 2;
address roundPool = _getOrCreateRoundPool(2);
SportsAMMV2LiquidityPoolRound(roundPool).updateRoundTimes(firstRoundStartTime, getRoundEndTime(2));
started = true;
emit PoolStarted();
}
/// @notice deposit funds from user into pool for the next round
/// @param amount value to be deposited
function deposit(uint amount) external canDeposit(amount) nonReentrant whenNotPaused roundClosingNotPrepared {
_deposit(amount);
}
/// @notice deposit funds from user into pool for the next round
/// @param amount value to be deposited
function _deposit(uint amount) internal {
uint nextRound = round + 1;
address roundPool = _getOrCreateRoundPool(nextRound);
collateral.safeTransferFrom(msg.sender, roundPool, amount);
require(msg.sender != defaultLiquidityProvider, "Can't deposit directly as default LP");
// new user enters the pool
if (balancesPerRound[round][msg.sender] == 0 && balancesPerRound[nextRound][msg.sender] == 0) {
require(usersCurrentlyInPool < maxAllowedUsers, "Max amount of users reached");
usersPerRound[nextRound].push(msg.sender);
usersCurrentlyInPool = usersCurrentlyInPool + 1;
}
balancesPerRound[nextRound][msg.sender] += amount;
allocationPerRound[nextRound] += amount;
totalDeposited += amount;
IStakingThales stakingThales = IStakingThales(addressManager.getAddress("StakingThales"));
updateStakingVolume(stakingThales, amount, address(sportsAMM.defaultCollateral()) == address(collateral));
emit Deposited(msg.sender, amount, round);
}
/// @notice get collateral amount needed for trade and store ticket as trading in the round
/// @param ticket to trade
/// @param amount amount to get
function commitTrade(address ticket, uint amount) external nonReentrant whenNotPaused onlyAMM roundClosingNotPrepared {
require(started, "Pool has not started");
require(amount > 0, "Can't commit a zero trade");
uint ticketRound = getTicketRound(ticket);
roundPerTicket[ticket] = ticketRound;
address liquidityPoolRound = _getOrCreateRoundPool(ticketRound);
if (ticketRound == round) {
collateral.safeTransferFrom(liquidityPoolRound, address(sportsAMM), amount);
require(
collateral.balanceOf(liquidityPoolRound) >=
(allocationPerRound[round] - ((allocationPerRound[round] * utilizationRate) / ONE)),
"Amount exceeds available utilization for round"
);
} else if (ticketRound > round) {
uint poolBalance = collateral.balanceOf(liquidityPoolRound);
if (poolBalance >= amount) {
collateral.safeTransferFrom(liquidityPoolRound, address(sportsAMM), amount);
} else {
uint differenceToLPAsDefault = amount - poolBalance;
_depositAsDefault(differenceToLPAsDefault, liquidityPoolRound, ticketRound);
collateral.safeTransferFrom(liquidityPoolRound, address(sportsAMM), amount);
}
} else {
require(ticketRound == 1, "Invalid round");
_provideAsDefault(amount);
}
tradingTicketsPerRound[ticketRound].push(ticket);
isTradingTicketInARound[ticketRound][ticket] = true;
}
/// @notice transfer collateral amount from AMM to LP (ticket liquidity pool round)
/// @param _ticket to trade
function transferToPool(address _ticket, uint _amount) external whenNotPaused roundClosingNotPrepared onlyAMM {
uint ticketRound = getTicketRound(_ticket);
address liquidityPoolRound = ticketRound <= 1 ? defaultLiquidityProvider : _getOrCreateRoundPool(ticketRound);
collateral.safeTransferFrom(address(sportsAMM), liquidityPoolRound, _amount);
if (isTradingTicketInARound[ticketRound][_ticket]) {
ticketAlreadyExercisedInRound[ticketRound][_ticket] = true;
}
}
/// @notice request withdrawal from the LP
function withdrawalRequest() external nonReentrant canWithdraw whenNotPaused roundClosingNotPrepared {
if (totalDeposited > balancesPerRound[round][msg.sender]) {
totalDeposited -= balancesPerRound[round][msg.sender];
} else {
totalDeposited = 0;
}
usersCurrentlyInPool = usersCurrentlyInPool - 1;
withdrawalRequested[msg.sender] = true;
emit WithdrawalRequested(msg.sender);
}
/// @notice request partial withdrawal from the LP
/// @param _share the percentage the user is wihdrawing from his total deposit
function partialWithdrawalRequest(uint _share) external nonReentrant canWithdraw whenNotPaused roundClosingNotPrepared {
require(_share >= ONE_PERCENT * 10 && _share <= ONE_PERCENT * 90, "Share has to be between 10% and 90%");
uint toWithdraw = (balancesPerRound[round][msg.sender] * _share) / ONE;
if (totalDeposited > toWithdraw) {
totalDeposited -= toWithdraw;
} else {
totalDeposited = 0;
}
withdrawalRequested[msg.sender] = true;
withdrawalShare[msg.sender] = _share;
emit WithdrawalRequested(msg.sender);
}
/// @notice prepare round closing - excercise tickets and ensure there are no tickets left unresolved, handle SB profit and calculate PnL
function prepareRoundClosing() external nonReentrant whenNotPaused roundClosingNotPrepared {
require(canCloseCurrentRound(), "Can't close current round");
// excercise tickets
exerciseTicketsReadyToBeExercised();
address roundPool = roundPools[round];
// final balance is the final amount of collateral in the round pool
uint currentBalance = collateral.balanceOf(roundPool);
// send profit reserved for SafeBox if positive round
if (currentBalance > allocationPerRound[round]) {
uint safeBoxAmount = ((currentBalance - allocationPerRound[round]) * safeBoxImpact) / ONE;
collateral.safeTransferFrom(roundPool, safeBox, safeBoxAmount);
currentBalance = currentBalance - safeBoxAmount;
emit SafeBoxSharePaid(safeBoxImpact, safeBoxAmount);
}
// calculate PnL
// if no allocation for current round
if (allocationPerRound[round] == 0) {
profitAndLossPerRound[round] = 1;
} else {
profitAndLossPerRound[round] = (currentBalance * ONE) / allocationPerRound[round];
}
roundClosingPrepared = true;
emit RoundClosingPrepared(round);
}
/// @notice process round closing batch - update balances and handle withdrawals
/// @param _batchSize size of batch
function processRoundClosingBatch(uint _batchSize) external nonReentrant whenNotPaused {
require(roundClosingPrepared, "Round closing not prepared");
require(usersProcessedInRound < usersPerRound[round].length, "All users already processed");
require(_batchSize > 0, "Batch size has to be greater than 0");
IStakingThales stakingThales = IStakingThales(addressManager.getAddress("StakingThales"));
address roundPool = roundPools[round];
uint endCursor = usersProcessedInRound + _batchSize;
if (endCursor > usersPerRound[round].length) {
endCursor = usersPerRound[round].length;
}
bool isDefaultCollateral = address(sportsAMM.defaultCollateral()) == address(collateral);
for (uint i = usersProcessedInRound; i < endCursor; i++) {
address user = usersPerRound[round][i];
uint balanceAfterCurRound = (balancesPerRound[round][user] * profitAndLossPerRound[round]) / ONE;
if (!withdrawalRequested[user] && (profitAndLossPerRound[round] > 0)) {
balancesPerRound[round + 1][user] = balancesPerRound[round + 1][user] + balanceAfterCurRound;
usersPerRound[round + 1].push(user);
updateStakingVolume(stakingThales, balanceAfterCurRound, isDefaultCollateral);
} else {
if (withdrawalShare[user] > 0) {
uint amountToClaim = (balanceAfterCurRound * withdrawalShare[user]) / ONE;
collateral.safeTransferFrom(roundPool, user, amountToClaim);
emit Claimed(user, amountToClaim);
withdrawalRequested[user] = false;
withdrawalShare[user] = 0;
usersPerRound[round + 1].push(user);
balancesPerRound[round + 1][user] = balanceAfterCurRound - amountToClaim;
} else {
balancesPerRound[round + 1][user] = 0;
collateral.safeTransferFrom(roundPool, user, balanceAfterCurRound);
withdrawalRequested[user] = false;
emit Claimed(user, balanceAfterCurRound);
}
}
usersProcessedInRound = usersProcessedInRound + 1;
}
emit RoundClosingBatchProcessed(round, _batchSize);
}
/// @notice close current round and begin next round - calculate cumulative PnL
function closeRound() external nonReentrant whenNotPaused {
require(roundClosingPrepared, "Round closing not prepared");
require(usersProcessedInRound == usersPerRound[round].length, "Not all users processed yet");
// set for next round to false
roundClosingPrepared = false;
address roundPool = roundPools[round];
// always claim for defaultLiquidityProvider
if (balancesPerRound[round][defaultLiquidityProvider] > 0) {
uint balanceAfterCurRound = (balancesPerRound[round][defaultLiquidityProvider] * profitAndLossPerRound[round]) /
ONE;
collateral.safeTransferFrom(roundPool, defaultLiquidityProvider, balanceAfterCurRound);
emit Claimed(defaultLiquidityProvider, balanceAfterCurRound);
}
if (round == 2) {
cumulativeProfitAndLoss[round] = profitAndLossPerRound[round];
} else {
cumulativeProfitAndLoss[round] = (cumulativeProfitAndLoss[round - 1] * profitAndLossPerRound[round]) / ONE;
}
// start next round
++round;
//add all carried over collateral
allocationPerRound[round] += collateral.balanceOf(roundPool);
totalDeposited = allocationPerRound[round] - balancesPerRound[round][defaultLiquidityProvider];
address roundPoolNewRound = _getOrCreateRoundPool(round);
collateral.safeTransferFrom(roundPool, roundPoolNewRound, collateral.balanceOf(roundPool));
usersProcessedInRound = 0;
emit RoundClosed(round - 1, profitAndLossPerRound[round - 1]);
}
/// @notice iterate all tickets in the current round and exercise those ready to be exercised
function exerciseTicketsReadyToBeExercised() public roundClosingNotPrepared {
Ticket ticket;
address ticketAddress;
for (uint i = 0; i < tradingTicketsPerRound[round].length; i++) {
ticketAddress = tradingTicketsPerRound[round][i];
if (!ticketAlreadyExercisedInRound[round][ticketAddress]) {
ticket = Ticket(ticketAddress);
if (ticket.isTicketExercisable() && !ticket.isUserTheWinner()) {
sportsAMM.exerciseTicket(ticketAddress);
}
if (ticket.isUserTheWinner() || ticket.resolved()) {
ticketAlreadyExercisedInRound[round][ticketAddress] = true;
}
}
}
}
/// @notice iterate all tickets in the current round and exercise those ready to be exercised (batch)
/// @param _batchSize number of tickets to be processed
function exerciseTicketsReadyToBeExercisedBatch(
uint _batchSize
) external nonReentrant whenNotPaused roundClosingNotPrepared {
require(_batchSize > 0, "Batch size has to be greater than 0");
uint count = 0;
Ticket ticket;
for (uint i = 0; i < tradingTicketsPerRound[round].length; i++) {
if (count == _batchSize) break;
address ticketAddress = tradingTicketsPerRound[round][i];
if (!ticketAlreadyExercisedInRound[round][ticketAddress]) {
ticket = Ticket(ticketAddress);
if (ticket.isTicketExercisable() && !ticket.isUserTheWinner()) {
sportsAMM.exerciseTicket(ticketAddress);
}
if (ticket.isUserTheWinner() || ticket.resolved()) {
ticketAlreadyExercisedInRound[round][ticketAddress] = true;
count += 1;
}
}
}
}
/* ========== EXTERNAL READ FUNCTIONS ========== */
/// @notice whether the user is currently LPing
/// @param _user to check
/// @return isUserInLP whether the user is currently LPing
function isUserLPing(address _user) external view returns (bool isUserInLP) {
isUserInLP =
(balancesPerRound[round][_user] > 0 || balancesPerRound[round + 1][_user] > 0) &&
(!withdrawalRequested[_user] || withdrawalShare[_user] > 0);
}
function getCollateralPrice() public view returns (uint) {
return IPriceFeed(addressManager.getAddress("PriceFeed")).rateForCurrency(collateralKey);
}
/// @notice get the pool address for the ticket
/// @param _ticket to check
/// @return roundPool the pool address for the ticket
function getTicketPool(address _ticket) external view returns (address roundPool) {
roundPool = roundPools[getTicketRound(_ticket)];
}
/// @notice checks if all conditions are met to close the round
/// @return bool
function canCloseCurrentRound() public view returns (bool) {
if (!started || block.timestamp < getRoundEndTime(round)) {
return false;
}
Ticket ticket;
address ticketAddress;
for (uint i = 0; i < tradingTicketsPerRound[round].length; i++) {
ticketAddress = tradingTicketsPerRound[round][i];
if (!ticketAlreadyExercisedInRound[round][ticketAddress]) {
ticket = Ticket(ticketAddress);
if (!ticket.areAllMarketsResolved()) {
return false;
}
}
}
return true;
}
/// @notice iterate all ticket in the current round and return true if at least one can be exercised
/// @return bool
function hasTicketsReadyToBeExercised() public view returns (bool) {
Ticket ticket;
address ticketAddress;
for (uint i = 0; i < tradingTicketsPerRound[round].length; i++) {
ticketAddress = tradingTicketsPerRound[round][i];
if (!ticketAlreadyExercisedInRound[round][ticketAddress]) {
ticket = Ticket(ticketAddress);
if (ticket.isTicketExercisable() && !ticket.isUserTheWinner()) {
return true;
}
}
}
return false;
}
/// @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];
}
/// @notice return the start time of the passed round
/// @param _round number
/// @return uint the start time of the given round
function getRoundStartTime(uint _round) public view returns (uint) {
return firstRoundStartTime + (_round - 2) * roundLength;
}
/// @notice return the end time of the passed round
/// @param _round number
/// @return uint the end time of the given round
function getRoundEndTime(uint _round) public view returns (uint) {
return firstRoundStartTime + (_round - 1) * roundLength;
}
/// @notice return the round to which a ticket belongs to
/// @param _ticket to get the round for
/// @return ticketRound the min round which the ticket belongs to
function getTicketRound(address _ticket) public view returns (uint ticketRound) {
ticketRound = roundPerTicket[_ticket];
if (ticketRound == 0) {
Ticket ticket = Ticket(_ticket);
uint maturity;
for (uint i = 0; i < ticket.numOfMarkets(); i++) {
(, , , maturity, , , , , ) = ticket.markets(i);
if (maturity > firstRoundStartTime) {
if (i == 0) {
ticketRound = (maturity - firstRoundStartTime) / roundLength + 2;
} else {
if (((maturity - firstRoundStartTime) / roundLength + 2) != ticketRound) {
ticketRound = 1;
break;
}
}
} else {
ticketRound = 1;
}
}
}
}
/// @notice return the count of users in current round
/// @return uint the count of users in current round
function getUsersCountInCurrentRound() external view returns (uint) {
return usersPerRound[round].length;
}
/// @notice return the number of tickets in current rount
/// @return numOfTickets the number of tickets in urrent rount
function getNumberOfTradingTicketsPerRound(uint _round) external view returns (uint numOfTickets) {
numOfTickets = tradingTicketsPerRound[_round].length;
}
/* ========== INTERNAL FUNCTIONS ========== */
function _depositAsDefault(uint _amount, address _roundPool, uint _round) internal {
require(defaultLiquidityProvider != address(0), "Default LP not set");
collateral.safeTransferFrom(defaultLiquidityProvider, _roundPool, _amount);
balancesPerRound[_round][defaultLiquidityProvider] += _amount;
allocationPerRound[_round] += _amount;
emit Deposited(defaultLiquidityProvider, _amount, _round);
}
function _provideAsDefault(uint _amount) internal {
require(defaultLiquidityProvider != address(0), "Default LP not set");
collateral.safeTransferFrom(defaultLiquidityProvider, address(sportsAMM), _amount);
balancesPerRound[1][defaultLiquidityProvider] += _amount;
allocationPerRound[1] += _amount;
emit Deposited(defaultLiquidityProvider, _amount, 1);
}
function _getOrCreateRoundPool(uint _round) internal returns (address roundPool) {
roundPool = roundPools[_round];
if (roundPool == address(0)) {
if (_round == 1) {
roundPools[_round] = defaultLiquidityProvider;
roundPool = defaultLiquidityProvider;
} else {
require(poolRoundMastercopy != address(0), "Round pool mastercopy not set");
SportsAMMV2LiquidityPoolRound newRoundPool = SportsAMMV2LiquidityPoolRound(
Clones.clone(poolRoundMastercopy)
);
newRoundPool.initialize(
address(this),
collateral,
_round,
getRoundEndTime(_round - 1),
getRoundEndTime(_round)
);
roundPool = address(newRoundPool);
roundPools[_round] = roundPool;
emit RoundPoolCreated(_round, roundPool);
}
}
}
function updateStakingVolume(IStakingThales stakingThales, uint _amount, bool _isDefaultCollateral) internal {
if (address(stakingThales) != address(0)) {
uint collateralDecimals = ISportsAMMV2Manager(address(collateral)).decimals();
if (!_isDefaultCollateral) {
_amount = (_amount * getCollateralPrice()) / ONE;
}
stakingThales.updateVolumeAtAmountDecimals(msg.sender, _amount, collateralDecimals);
}
}
/* ========== SETTERS ========== */
/// @notice Pause/unpause LP
/// @param _setPausing true/false
function setPaused(bool _setPausing) external onlyOwner {
_setPausing ? _pause() : _unpause();
}
/// @notice Set _poolRoundMastercopy
/// @param _poolRoundMastercopy to clone round pools from
function setPoolRoundMastercopy(address _poolRoundMastercopy) external onlyOwner {
require(_poolRoundMastercopy != address(0), "Can not set a zero address!");
poolRoundMastercopy = _poolRoundMastercopy;
emit PoolRoundMastercopyChanged(poolRoundMastercopy);
}
/// @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 SportsAMM contract
/// @param _sportsAMM SportsAMM address
function setSportsAMM(ISportsAMMV2 _sportsAMM) external onlyOwner {
require(address(_sportsAMM) != address(0), "Can not set a zero address!");
if (address(sportsAMM) != address(0)) {
collateral.approve(address(sportsAMM), 0);
}
sportsAMM = _sportsAMM;
collateral.approve(address(sportsAMM), MAX_APPROVAL);
emit SportAMMChanged(address(_sportsAMM));
}
/// @notice Set defaultLiquidityProvider wallet
/// @param _defaultLiquidityProvider default liquidity provider
function setDefaultLiquidityProvider(address _defaultLiquidityProvider) external onlyOwner {
require(_defaultLiquidityProvider != address(0), "Can not set a zero address!");
defaultLiquidityProvider = _defaultLiquidityProvider;
emit DefaultLiquidityProviderChanged(_defaultLiquidityProvider);
}
/// @notice Set length of rounds
/// @param _roundLength Length of a round in miliseconds
function setRoundLength(uint _roundLength) external onlyOwner {
require(!started, "Can't change round length after start");
roundLength = _roundLength;
emit RoundLengthChanged(_roundLength);
}
/// @notice set utilization rate parameter
/// @param _utilizationRate value as percentage
function setUtilizationRate(uint _utilizationRate) external onlyOwner {
utilizationRate = _utilizationRate;
emit UtilizationRateChanged(_utilizationRate);
}
/// @notice set SafeBox params
/// @param _safeBox where to send a profit reserved for protocol from each round
/// @param _safeBoxImpact how much is the SafeBox percentage
function setSafeBoxParams(address _safeBox, uint _safeBoxImpact) external onlyOwner {
safeBox = _safeBox;
safeBoxImpact = _safeBoxImpact;
emit SetSafeBoxParams(_safeBox, _safeBoxImpact);
}
/* ========== MODIFIERS ========== */
modifier canDeposit(uint amount) {
require(!withdrawalRequested[msg.sender], "Withdrawal is requested, cannot deposit");
require(totalDeposited + amount <= maxAllowedDeposit, "Deposit amount exceeds AMM LP cap");
if (balancesPerRound[round][msg.sender] == 0 && balancesPerRound[round + 1][msg.sender] == 0) {
require(amount >= minDepositAmount, "Amount less than minDepositAmount");
}
_;
}
modifier canWithdraw() {
require(started, "Pool 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");
_;
}
modifier onlyAMM() {
require(msg.sender == address(sportsAMM), "Only the AMM may perform these methods");
_;
}
modifier roundClosingNotPrepared() {
require(!roundClosingPrepared, "Not allowed during roundClosingPrepared");
_;
}
/* ========== EVENTS ========== */
event PoolStarted();
event RoundPoolCreated(uint round, address roundPool);
event Deposited(address user, uint amount, uint round);
event WithdrawalRequested(address user);
event SafeBoxSharePaid(uint safeBoxShare, uint safeBoxAmount);
event RoundClosingPrepared(uint round);
event Claimed(address user, uint amount);
event RoundClosingBatchProcessed(uint round, uint batchSize);
event RoundClosed(uint round, uint roundPnL);
event PoolRoundMastercopyChanged(address newMastercopy);
event SportAMMChanged(address sportAMM);
event DefaultLiquidityProviderChanged(address newProvider);
event RoundLengthChanged(uint roundLength);
event MaxAllowedDepositChanged(uint maxAllowedDeposit);
event MinAllowedDepositChanged(uint minAllowedDeposit);
event MaxAllowedUsersChanged(uint maxAllowedUsersChanged);
event UtilizationRateChanged(uint utilizationRate);
event SetSafeBoxParams(address safeBox, uint safeBoxImpact);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (proxy/utils/Initializable.sol)
pragma solidity ^0.8.20;
/**
* @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 proxied contracts do not make use of 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.
*
* The initialization functions use a version number. Once a version number is used, it is consumed and cannot be
* reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in
* case an upgrade adds a module that needs to be initialized.
*
* For example:
*
* [.hljs-theme-light.nopadding]
* ```solidity
* contract MyToken is ERC20Upgradeable {
* function initialize() initializer public {
* __ERC20_init("MyToken", "MTK");
* }
* }
*
* contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {
* function initializeV2() reinitializer(2) public {
* __ERC20Permit_init("MyToken");
* }
* }
* ```
*
* 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 prevent the implementation contract from being used, you should invoke
* the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:
*
* [.hljs-theme-light.nopadding]
* ```
* /// @custom:oz-upgrades-unsafe-allow constructor
* constructor() {
* _disableInitializers();
* }
* ```
* ====
*/
abstract contract Initializable {
/**
* @dev Storage of the initializable contract.
*
* It's implemented on a custom ERC-7201 namespace to reduce the risk of storage collisions
* when using with upgradeable contracts.
*
* @custom:storage-location erc7201:openzeppelin.storage.Initializable
*/
struct InitializableStorage {
/**
* @dev Indicates that the contract has been initialized.
*/
uint64 _initialized;
/**
* @dev Indicates that the contract is in the process of being initialized.
*/
bool _initializing;
}
// keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.Initializable")) - 1)) & ~bytes32(uint256(0xff))
bytes32 private constant INITIALIZABLE_STORAGE = 0xf0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00;
/**
* @dev The contract is already initialized.
*/
error InvalidInitialization();
/**
* @dev The contract is not initializing.
*/
error NotInitializing();
/**
* @dev Triggered when the contract has been initialized or reinitialized.
*/
event Initialized(uint64 version);
/**
* @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,
* `onlyInitializing` functions can be used to initialize parent contracts.
*
* Similar to `reinitializer(1)`, except that in the context of a constructor an `initializer` may be invoked any
* number of times. This behavior in the constructor can be useful during testing and is not expected to be used in
* production.
*
* Emits an {Initialized} event.
*/
modifier initializer() {
// solhint-disable-next-line var-name-mixedcase
InitializableStorage storage $ = _getInitializableStorage();
// Cache values to avoid duplicated sloads
bool isTopLevelCall = !$._initializing;
uint64 initialized = $._initialized;
// Allowed calls:
// - initialSetup: the contract is not in the initializing state and no previous version was
// initialized
// - construction: the contract is initialized at version 1 (no reininitialization) and the
// current contract is just being deployed
bool initialSetup = initialized == 0 && isTopLevelCall;
bool construction = initialized == 1 && address(this).code.length == 0;
if (!initialSetup && !construction) {
revert InvalidInitialization();
}
$._initialized = 1;
if (isTopLevelCall) {
$._initializing = true;
}
_;
if (isTopLevelCall) {
$._initializing = false;
emit Initialized(1);
}
}
/**
* @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the
* contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be
* used to initialize parent contracts.
*
* A reinitializer may be used after the original initialization step. This is essential to configure modules that
* are added through upgrades and that require initialization.
*
* When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`
* cannot be nested. If one is invoked in the context of another, execution will revert.
*
* Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in
* a contract, executing them in the right order is up to the developer or operator.
*
* WARNING: Setting the version to 2**64 - 1 will prevent any future reinitialization.
*
* Emits an {Initialized} event.
*/
modifier reinitializer(uint64 version) {
// solhint-disable-next-line var-name-mixedcase
InitializableStorage storage $ = _getInitializableStorage();
if ($._initializing || $._initialized >= version) {
revert InvalidInitialization();
}
$._initialized = version;
$._initializing = true;
_;
$._initializing = false;
emit Initialized(version);
}
/**
* @dev Modifier to protect an initialization function so that it can only be invoked by functions with the
* {initializer} and {reinitializer} modifiers, directly or indirectly.
*/
modifier onlyInitializing() {
_checkInitializing();
_;
}
/**
* @dev Reverts if the contract is not in an initializing state. See {onlyInitializing}.
*/
function _checkInitializing() internal view virtual {
if (!_isInitializing()) {
revert NotInitializing();
}
}
/**
* @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.
* Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized
* to any version. It is recommended to use this to lock implementation contracts that are designed to be called
* through proxies.
*
* Emits an {Initialized} event the first time it is successfully executed.
*/
function _disableInitializers() internal virtual {
// solhint-disable-next-line var-name-mixedcase
InitializableStorage storage $ = _getInitializableStorage();
if ($._initializing) {
revert InvalidInitialization();
}
if ($._initialized != type(uint64).max) {
$._initialized = type(uint64).max;
emit Initialized(type(uint64).max);
}
}
/**
* @dev Returns the highest version that has been initialized. See {reinitializer}.
*/
function _getInitializedVersion() internal view returns (uint64) {
return _getInitializableStorage()._initialized;
}
/**
* @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.
*/
function _isInitializing() internal view returns (bool) {
return _getInitializableStorage()._initializing;
}
/**
* @dev Returns a pointer to the storage namespace.
*/
// solhint-disable-next-line var-name-mixedcase
function _getInitializableStorage() private pure returns (InitializableStorage storage $) {
assembly {
$.slot := INITIALIZABLE_STORAGE
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/Context.sol)
pragma solidity ^0.8.20;
import {Initializable} from "../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 {
}
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;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/Pausable.sol)
pragma solidity ^0.8.20;
import {ContextUpgradeable} from "../utils/ContextUpgradeable.sol";
import {Initializable} from "../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 {
/// @custom:storage-location erc7201:openzeppelin.storage.Pausable
struct PausableStorage {
bool _paused;
}
// keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.Pausable")) - 1)) & ~bytes32(uint256(0xff))
bytes32 private constant PausableStorageLocation = 0xcd5ed15c6e187e77e9aee88184c21f4f2182ab5827cb3b7e07fbedcd63f03300;
function _getPausableStorage() private pure returns (PausableStorage storage $) {
assembly {
$.slot := PausableStorageLocation
}
}
/**
* @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);
/**
* @dev The operation failed because the contract is paused.
*/
error EnforcedPause();
/**
* @dev The operation failed because the contract is not paused.
*/
error ExpectedPause();
/**
* @dev Initializes the contract in unpaused state.
*/
function __Pausable_init() internal onlyInitializing {
__Pausable_init_unchained();
}
function __Pausable_init_unchained() internal onlyInitializing {
PausableStorage storage $ = _getPausableStorage();
$._paused = false;
}
/**
* @dev Modifier to make a function callable only when the contract is not paused.
*
* Requirements:
*
* - The contract must not be paused.
*/
modifier whenNotPaused() {
_requireNotPaused();
_;
}
/**
* @dev Modifier to make a function callable only when the contract is paused.
*
* Requirements:
*
* - The contract must be paused.
*/
modifier whenPaused() {
_requirePaused();
_;
}
/**
* @dev Returns true if the contract is paused, and false otherwise.
*/
function paused() public view virtual returns (bool) {
PausableStorage storage $ = _getPausableStorage();
return $._paused;
}
/**
* @dev Throws if the contract is paused.
*/
function _requireNotPaused() internal view virtual {
if (paused()) {
revert EnforcedPause();
}
}
/**
* @dev Throws if the contract is not paused.
*/
function _requirePaused() internal view virtual {
if (!paused()) {
revert ExpectedPause();
}
}
/**
* @dev Triggers stopped state.
*
* Requirements:
*
* - The contract must not be paused.
*/
function _pause() internal virtual whenNotPaused {
PausableStorage storage $ = _getPausableStorage();
$._paused = true;
emit Paused(_msgSender());
}
/**
* @dev Returns to normal state.
*
* Requirements:
*
* - The contract must be paused.
*/
function _unpause() internal virtual whenPaused {
PausableStorage storage $ = _getPausableStorage();
$._paused = false;
emit Unpaused(_msgSender());
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (proxy/Clones.sol)
pragma solidity ^0.8.20;
/**
* @dev https://eips.ethereum.org/EIPS/eip-1167[EIP 1167] is a standard for
* deploying minimal proxy contracts, also known as "clones".
*
* > To simply and cheaply clone contract functionality in an immutable way, this standard specifies
* > a minimal bytecode implementation that delegates all calls to a known, fixed address.
*
* The library includes functions to deploy a proxy using either `create` (traditional deployment) or `create2`
* (salted deterministic deployment). It also includes functions to predict the addresses of clones deployed using the
* deterministic method.
*/
library Clones {
/**
* @dev A clone instance deployment failed.
*/
error ERC1167FailedCreateClone();
/**
* @dev Deploys and returns the address of a clone that mimics the behaviour of `implementation`.
*
* This function uses the create opcode, which should never revert.
*/
function clone(address implementation) internal returns (address instance) {
/// @solidity memory-safe-assembly
assembly {
// Cleans the upper 96 bits of the `implementation` word, then packs the first 3 bytes
// of the `implementation` address with the bytecode before the address.
mstore(0x00, or(shr(0xe8, shl(0x60, implementation)), 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000))
// Packs the remaining 17 bytes of `implementation` with the bytecode after the address.
mstore(0x20, or(shl(0x78, implementation), 0x5af43d82803e903d91602b57fd5bf3))
instance := create(0, 0x09, 0x37)
}
if (instance == address(0)) {
revert ERC1167FailedCreateClone();
}
}
/**
* @dev Deploys and returns the address of a clone that mimics the behaviour of `implementation`.
*
* This function uses the create2 opcode and a `salt` to deterministically deploy
* the clone. Using the same `implementation` and `salt` multiple time will revert, since
* the clones cannot be deployed twice at the same address.
*/
function cloneDeterministic(address implementation, bytes32 salt) internal returns (address instance) {
/// @solidity memory-safe-assembly
assembly {
// Cleans the upper 96 bits of the `implementation` word, then packs the first 3 bytes
// of the `implementation` address with the bytecode before the address.
mstore(0x00, or(shr(0xe8, shl(0x60, implementation)), 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000))
// Packs the remaining 17 bytes of `implementation` with the bytecode after the address.
mstore(0x20, or(shl(0x78, implementation), 0x5af43d82803e903d91602b57fd5bf3))
instance := create2(0, 0x09, 0x37, salt)
}
if (instance == address(0)) {
revert ERC1167FailedCreateClone();
}
}
/**
* @dev Computes the address of a clone deployed using {Clones-cloneDeterministic}.
*/
function predictDeterministicAddress(
address implementation,
bytes32 salt,
address deployer
) internal pure returns (address predicted) {
/// @solidity memory-safe-assembly
assembly {
let ptr := mload(0x40)
mstore(add(ptr, 0x38), deployer)
mstore(add(ptr, 0x24), 0x5af43d82803e903d91602b57fd5bf3ff)
mstore(add(ptr, 0x14), implementation)
mstore(ptr, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73)
mstore(add(ptr, 0x58), salt)
mstore(add(ptr, 0x78), keccak256(add(ptr, 0x0c), 0x37))
predicted := keccak256(add(ptr, 0x43), 0x55)
}
}
/**
* @dev Computes the address of a clone deployed using {Clones-cloneDeterministic}.
*/
function predictDeterministicAddress(
address implementation,
bytes32 salt
) internal view returns (address predicted) {
return predictDeterministicAddress(implementation, salt, address(this));
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/IERC20Permit.sol)
pragma solidity ^0.8.20;
/**
* @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
* https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
*
* Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
* presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't
* need to send a transaction, and thus is not required to hold Ether at all.
*
* ==== Security Considerations
*
* There are two important considerations concerning the use of `permit`. The first is that a valid permit signature
* expresses an allowance, and it should not be assumed to convey additional meaning. In particular, it should not be
* considered as an intention to spend the allowance in any specific way. The second is that because permits have
* built-in replay protection and can be submitted by anyone, they can be frontrun. A protocol that uses permits should
* take this into consideration and allow a `permit` call to fail. Combining these two aspects, a pattern that may be
* generally recommended is:
*
* ```solidity
* function doThingWithPermit(..., uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public {
* try token.permit(msg.sender, address(this), value, deadline, v, r, s) {} catch {}
* doThing(..., value);
* }
*
* function doThing(..., uint256 value) public {
* token.safeTransferFrom(msg.sender, address(this), value);
* ...
* }
* ```
*
* Observe that: 1) `msg.sender` is used as the owner, leaving no ambiguity as to the signer intent, and 2) the use of
* `try/catch` allows the permit to fail and makes the code tolerant to frontrunning. (See also
* {SafeERC20-safeTransferFrom}).
*
* Additionally, note that smart contract wallets (such as Argent or Safe) are not able to produce permit signatures, so
* contracts should have entry points that don't rely on permit.
*/
interface IERC20Permit {
/**
* @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,
* given ``owner``'s signed approval.
*
* IMPORTANT: The same issues {IERC20-approve} has related to transaction
* ordering also apply here.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `deadline` must be a timestamp in the future.
* - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`
* over the EIP712-formatted function arguments.
* - the signature must use ``owner``'s current nonce (see {nonces}).
*
* For more information on the signature format, see the
* https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP
* section].
*
* CAUTION: See Security Considerations above.
*/
function permit(
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) external;
/**
* @dev Returns the current nonce for `owner`. This value must be
* included whenever a signature is generated for {permit}.
*
* Every successful call to {permit} increases ``owner``'s nonce by one. This
* prevents a signature from being used multiple times.
*/
function nonces(address owner) external view returns (uint256);
/**
* @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.
*/
// solhint-disable-next-line func-name-mixedcase
function DOMAIN_SEPARATOR() external view returns (bytes32);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.20;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @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);
/**
* @dev Returns the value of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the value of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves a `value` amount of tokens from the caller's account to `to`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address to, uint256 value) 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 a `value` amount of tokens 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 value) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from `from` to `to` using the
* allowance mechanism. `value` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address from, address to, uint256 value) external returns (bool);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/utils/SafeERC20.sol)
pragma solidity ^0.8.20;
import {IERC20} from "../IERC20.sol";
import {IERC20Permit} from "../extensions/IERC20Permit.sol";
import {Address} from "../../../utils/Address.sol";
/**
* @title SafeERC20
* @dev Wrappers around ERC20 operations that throw on failure (when the token
* contract returns false). Tokens that return no value (and instead revert or
* throw on failure) are also supported, non-reverting calls are assumed to be
* successful.
* To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
* which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
*/
library SafeERC20 {
using Address for address;
/**
* @dev An operation with an ERC20 token failed.
*/
error SafeERC20FailedOperation(address token);
/**
* @dev Indicates a failed `decreaseAllowance` request.
*/
error SafeERC20FailedDecreaseAllowance(address spender, uint256 currentAllowance, uint256 requestedDecrease);
/**
* @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*/
function safeTransfer(IERC20 token, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeCall(token.transfer, (to, value)));
}
/**
* @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the
* calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.
*/
function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeCall(token.transferFrom, (from, to, value)));
}
/**
* @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*/
function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
uint256 oldAllowance = token.allowance(address(this), spender);
forceApprove(token, spender, oldAllowance + value);
}
/**
* @dev Decrease the calling contract's allowance toward `spender` by `requestedDecrease`. If `token` returns no
* value, non-reverting calls are assumed to be successful.
*/
function safeDecreaseAllowance(IERC20 token, address spender, uint256 requestedDecrease) internal {
unchecked {
uint256 currentAllowance = token.allowance(address(this), spender);
if (currentAllowance < requestedDecrease) {
revert SafeERC20FailedDecreaseAllowance(spender, currentAllowance, requestedDecrease);
}
forceApprove(token, spender, currentAllowance - requestedDecrease);
}
}
/**
* @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval
* to be set to zero before setting it to a non-zero value, such as USDT.
*/
function forceApprove(IERC20 token, address spender, uint256 value) internal {
bytes memory approvalCall = abi.encodeCall(token.approve, (spender, value));
if (!_callOptionalReturnBool(token, approvalCall)) {
_callOptionalReturn(token, abi.encodeCall(token.approve, (spender, 0)));
_callOptionalReturn(token, approvalCall);
}
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*/
function _callOptionalReturn(IERC20 token, bytes memory data) private {
// We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
// we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that
// the target address contains contract code and also asserts for success in the low-level call.
bytes memory returndata = address(token).functionCall(data);
if (returndata.length != 0 && !abi.decode(returndata, (bool))) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @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).
*
* This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead.
*/
function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {
// 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 cannot use {Address-functionCall} here since this should return false
// and not revert is the subcall reverts.
(bool success, bytes memory returndata) = address(token).call(data);
return success && (returndata.length == 0 || abi.decode(returndata, (bool))) && address(token).code.length > 0;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/Address.sol)
pragma solidity ^0.8.20;
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev The ETH balance of the account is not enough to perform the operation.
*/
error AddressInsufficientBalance(address account);
/**
* @dev There's no code at `target` (it is not a contract).
*/
error AddressEmptyCode(address target);
/**
* @dev A call to an address target failed. The target may have reverted.
*/
error FailedInnerCall();
/**
* @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://consensys.net/diligence/blog/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.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
if (address(this).balance < amount) {
revert AddressInsufficientBalance(address(this));
}
(bool success, ) = recipient.call{value: amount}("");
if (!success) {
revert FailedInnerCall();
}
}
/**
* @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 or custom error, it is bubbled
* up by this function (like regular Solidity function calls). However, if
* the call reverted with no returned reason, this function reverts with a
* {FailedInnerCall} error.
*
* 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.
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0);
}
/**
* @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`.
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
if (address(this).balance < value) {
revert AddressInsufficientBalance(address(this));
}
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResultFromTarget(target, success, returndata);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResultFromTarget(target, success, returndata);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResultFromTarget(target, success, returndata);
}
/**
* @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target
* was not a contract or bubbling up the revert reason (falling back to {FailedInnerCall}) in case of an
* unsuccessful call.
*/
function verifyCallResultFromTarget(
address target,
bool success,
bytes memory returndata
) internal view returns (bytes memory) {
if (!success) {
_revert(returndata);
} else {
// only check if target is a contract if the call was successful and the return data is empty
// otherwise we already know that it was a contract
if (returndata.length == 0 && target.code.length == 0) {
revert AddressEmptyCode(target);
}
return returndata;
}
}
/**
* @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the
* revert reason or with a default {FailedInnerCall} error.
*/
function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) {
if (!success) {
_revert(returndata);
} else {
return returndata;
}
}
/**
* @dev Reverts with returndata if present. Otherwise reverts with {FailedInnerCall}.
*/
function _revert(bytes memory returndata) private pure {
// 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
/// @solidity memory-safe-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert FailedInnerCall();
}
}
}// SPDX-License-Identifier: MIT
pragma solidity >=0.5.16;
interface IAddressManager {
struct Addresses {
address safeBox;
address referrals;
address stakingThales;
address multiCollateralOnOffRamp;
address pyth;
address speedMarketsAMM;
}
function safeBox() external view returns (address);
function referrals() external view returns (address);
function stakingThales() external view returns (address);
function multiCollateralOnOffRamp() external view returns (address);
function pyth() external view returns (address);
function speedMarketsAMM() external view returns (address);
function getAddresses() external view returns (Addresses memory);
function getAddresses(string[] calldata _contractNames) external view returns (address[] memory contracts);
function getAddress(string memory _contractName) external view returns (address contract_);
function checkIfContractExists(string memory _contractName) external view returns (bool contractExists);
}// 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;
interface IStakingThales {
function updateVolume(address account, uint amount) external;
function updateStakingRewards(
uint _currentPeriodRewards,
uint _extraRewards,
uint _revShare
) 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);
function getAMMVolume(address account) external view returns (uint);
function updateVolumeAtAmountDecimals(
address account,
uint amount,
uint decimals
) external;
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "../interfaces/ISportsAMMV2Manager.sol";
import "../interfaces/ISportsAMMV2ResultManager.sol";
import "../interfaces/ISportsAMMV2RiskManager.sol";
import "../interfaces/ISportsAMMV2Manager.sol";
interface ISportsAMMV2 {
struct CombinedPosition {
uint16 typeId;
uint8 position;
int24 line;
}
struct TradeData {
bytes32 gameId;
uint16 sportId;
uint16 typeId;
uint maturity;
uint8 status;
int24 line;
uint16 playerId;
uint[] odds;
bytes32[] merkleProof;
uint8 position;
CombinedPosition[][] combinedPositions;
}
struct TradeParams {
uint _buyInAmount;
uint _expectedPayout;
uint _additionalSlippage;
address _differentRecipient;
address _collateral;
address _collateralPool;
uint _collateralPriceInUSD;
}
function defaultCollateral() external view returns (IERC20);
function manager() external view returns (ISportsAMMV2Manager);
function resultManager() external view returns (ISportsAMMV2ResultManager);
function safeBoxFee() external view returns (uint);
function exerciseTicket(address _ticket) external;
function riskManager() external view returns (ISportsAMMV2RiskManager);
function tradeLive(
TradeData[] calldata _tradeData,
address _requester,
uint _buyInAmount,
uint _expectedPayout,
address _differentRecipient,
address _referrer,
address _collateral
) external returns (address _createdTicket);
function trade(
TradeData[] calldata _tradeData,
uint _buyInAmount,
uint _expectedPayout,
uint _additionalSlippage,
address _differentRecipient,
address _referrer,
address _collateral,
bool _isEth
) external returns (address _createdTicket);
function rootPerGame(bytes32 game) external view returns (bytes32);
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import "./ISportsAMMV2.sol";
interface ISportsAMMV2Manager {
enum Role {
ROOT_SETTING,
RISK_MANAGING,
MARKET_RESOLVING,
TICKET_PAUSER
}
function isWhitelistedAddress(address _address, Role role) external view returns (bool);
function decimals() external view returns (uint);
function feeToken() external view returns (address);
function isActiveTicket(address _ticket) external view returns (bool);
function getActiveTickets(uint _index, uint _pageSize) external view returns (address[] memory);
function numOfActiveTickets() external view returns (uint);
function getActiveTicketsPerUser(uint _index, uint _pageSize, address _user) external view returns (address[] memory);
function numOfActiveTicketsPerUser(address _user) external view returns (uint);
function getResolvedTicketsPerUser(uint _index, uint _pageSize, address _user) external view returns (address[] memory);
function numOfResolvedTicketsPerUser(address _user) external view returns (uint);
function getTicketsPerGame(uint _index, uint _pageSize, bytes32 _gameId) external view returns (address[] memory);
function numOfTicketsPerGame(bytes32 _gameId) external view returns (uint);
function isKnownTicket(address _ticket) external view returns (bool);
function addNewKnownTicket(ISportsAMMV2.TradeData[] memory _tradeData, address ticket, address user) external;
function resolveKnownTicket(address ticket, address ticketOwner) external;
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "./ISportsAMMV2.sol";
interface ISportsAMMV2ResultManager {
enum MarketPositionStatus {
Open,
Cancelled,
Winning,
Losing
}
function isMarketResolved(
bytes32 _gameId,
uint16 _typeId,
uint16 _playerId,
int24 _line,
ISportsAMMV2.CombinedPosition[] memory combinedPositions
) external view returns (bool isResolved);
function getMarketPositionStatus(
bytes32 _gameId,
uint16 _typeId,
uint16 _playerId,
int24 _line,
uint _position,
ISportsAMMV2.CombinedPosition[] memory _combinedPositions
) external view returns (MarketPositionStatus status);
function isWinningMarketPosition(
bytes32 _gameId,
uint16 _typeId,
uint16 _playerId,
int24 _line,
uint _position,
ISportsAMMV2.CombinedPosition[] memory _combinedPositions
) external view returns (bool isWinning);
function isCancelledMarketPosition(
bytes32 _gameId,
uint16 _typeId,
uint16 _playerId,
int24 _line,
uint _position,
ISportsAMMV2.CombinedPosition[] memory _combinedPositions
) external view returns (bool isCancelled);
function getResultsPerMarket(
bytes32 _gameId,
uint16 _typeId,
uint16 _playerId
) external view returns (int24[] memory results);
function setResultsPerMarkets(
bytes32[] memory _gameIds,
uint16[] memory _typeIds,
uint16[] memory _playerIds,
int24[][] memory _results
) external;
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import "./ISportsAMMV2.sol";
interface ISportsAMMV2RiskManager {
struct TypeCap {
uint typeId;
uint cap;
}
struct CapData {
uint capPerSport;
uint capPerChild;
TypeCap[] capPerType;
}
struct DynamicLiquidityData {
uint cutoffTimePerSport;
uint cutoffDividerPerSport;
}
struct RiskData {
uint sportId;
CapData capData;
uint riskMultiplierPerSport;
DynamicLiquidityData dynamicLiquidityData;
}
enum RiskStatus {
NoRisk,
OutOfLiquidity,
InvalidCombination
}
function minBuyInAmount() external view returns (uint);
function maxTicketSize() external view returns (uint);
function maxSupportedAmount() external view returns (uint);
function maxSupportedOdds() external view returns (uint);
function expiryDuration() external view returns (uint);
function liveTradingPerSportAndTypeEnabled(uint _sportId, uint _typeId) external view returns (bool _enabled);
function calculateCapToBeUsed(
bytes32 _gameId,
uint16 _sportId,
uint16 _typeId,
uint16 _playerId,
int24 _line,
uint _maturity
) external view returns (uint cap);
function checkRisks(
ISportsAMMV2.TradeData[] memory _tradeData,
uint _buyInAmount
) external view returns (ISportsAMMV2RiskManager.RiskStatus riskStatus, bool[] memory isMarketOutOfLiquidity);
function checkLimits(
uint _buyInAmount,
uint _totalQuote,
uint _payout,
uint _expectedPayout,
uint _additionalSlippage
) external view;
function checkAndUpdateRisks(ISportsAMMV2.TradeData[] memory _tradeData, uint _buyInAmount) external;
function verifyMerkleTree(ISportsAMMV2.TradeData memory _marketTradeData, bytes32 _rootPerGame) external pure;
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
contract SportsAMMV2LiquidityPoolRound {
/* ========== LIBRARIES ========== */
using SafeERC20 for IERC20;
/* ========== STATE VARIABLES ========== */
// the adddress of the LP contract
address public liquidityPool;
// the adddress of collateral that LP accepts
IERC20 public collateral;
// the round number
uint public round;
// the round start time
uint public roundStartTime;
// the round end time
uint public roundEndTime;
// initialized flag
bool public initialized;
/* ========== CONSTRUCTOR ========== */
/// @notice initialize the storage in the contract with the parameters
/// @param _liquidityPool the adddress of the LP contract
/// @param _collateral the adddress of collateral that LP accepts
/// @param _round the round number
/// @param _roundStartTime the round start time
/// @param _roundEndTime the round end time
function initialize(
address _liquidityPool,
IERC20 _collateral,
uint _round,
uint _roundStartTime,
uint _roundEndTime
) external {
require(!initialized, "Already initialized");
initialized = true;
liquidityPool = _liquidityPool;
collateral = _collateral;
round = _round;
roundStartTime = _roundStartTime;
roundEndTime = _roundEndTime;
collateral.approve(_liquidityPool, type(uint256).max);
}
/// @notice update round times
/// @param _roundStartTime the round start time
/// @param _roundEndTime the round end time
function updateRoundTimes(uint _roundStartTime, uint _roundEndTime) external onlyLiquidityPool {
roundStartTime = _roundStartTime;
roundEndTime = _roundEndTime;
emit RoundTimesUpdated(_roundStartTime, _roundEndTime);
}
modifier onlyLiquidityPool() {
require(msg.sender == liquidityPool, "Only LP may perform this method");
_;
}
event RoundTimesUpdated(uint roundStartTime, uint roundEndTime);
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
// internal
import "../utils/OwnedWithInit.sol";
import "../interfaces/ISportsAMMV2.sol";
contract Ticket is OwnedWithInit {
using SafeERC20 for IERC20;
uint private constant ONE = 1e18;
enum Phase {
Trading,
Maturity,
Expiry
}
struct MarketData {
bytes32 gameId;
uint16 sportId;
uint16 typeId;
uint maturity;
uint8 status;
int24 line;
uint16 playerId;
uint8 position;
uint odd;
ISportsAMMV2.CombinedPosition[] combinedPositions;
}
struct TicketInit {
MarketData[] _markets;
uint _buyInAmount;
uint _fees;
uint _totalQuote;
address _sportsAMM;
address _ticketOwner;
IERC20 _collateral;
uint _expiry;
}
ISportsAMMV2 public sportsAMM;
address public ticketOwner;
IERC20 public collateral;
uint public buyInAmount;
uint public fees;
uint public totalQuote;
uint public numOfMarkets;
uint public expiry;
uint public createdAt;
bool public resolved;
bool public paused;
bool public initialized;
bool public cancelled;
mapping(uint => MarketData) public markets;
uint public finalPayout;
/* ========== CONSTRUCTOR ========== */
/// @notice initialize the ticket contract
/// @param params all parameters for Init
function initialize(TicketInit calldata params) external {
require(!initialized, "Ticket already initialized");
initialized = true;
initOwner(msg.sender);
sportsAMM = ISportsAMMV2(params._sportsAMM);
numOfMarkets = params._markets.length;
for (uint i = 0; i < numOfMarkets; i++) {
markets[i] = params._markets[i];
}
buyInAmount = params._buyInAmount;
fees = params._fees;
totalQuote = params._totalQuote;
ticketOwner = params._ticketOwner;
collateral = params._collateral;
expiry = params._expiry;
createdAt = block.timestamp;
}
/* ========== EXTERNAL READ FUNCTIONS ========== */
/// @notice checks if the user lost the ticket
/// @return isTicketLost true/false
function isTicketLost() public view returns (bool) {
for (uint i = 0; i < numOfMarkets; i++) {
bool isMarketResolved = sportsAMM.resultManager().isMarketResolved(
markets[i].gameId,
markets[i].typeId,
markets[i].playerId,
markets[i].line,
markets[i].combinedPositions
);
bool isWinningMarketPosition = sportsAMM.resultManager().isWinningMarketPosition(
markets[i].gameId,
markets[i].typeId,
markets[i].playerId,
markets[i].line,
markets[i].position,
markets[i].combinedPositions
);
if (isMarketResolved && !isWinningMarketPosition) {
return true;
}
}
return false;
}
/// @notice checks are all markets of the ticket resolved
/// @return areAllMarketsResolved true/false
function areAllMarketsResolved() public view returns (bool) {
for (uint i = 0; i < numOfMarkets; i++) {
if (
!sportsAMM.resultManager().isMarketResolved(
markets[i].gameId,
markets[i].typeId,
markets[i].playerId,
markets[i].line,
markets[i].combinedPositions
)
) {
return false;
}
}
return true;
}
/// @notice checks if the user won the ticket
/// @return hasUserWon true/false
function isUserTheWinner() external view returns (bool hasUserWon) {
hasUserWon = _isUserTheWinner();
}
/// @notice checks if the ticket ready to be exercised
/// @return isExercisable true/false
function isTicketExercisable() public view returns (bool isExercisable) {
isExercisable = !resolved && (areAllMarketsResolved() || isTicketLost());
}
/// @notice gets current phase of the ticket
/// @return phase ticket phase
function phase() public view returns (Phase) {
return
isTicketExercisable() || resolved ? ((expiry < block.timestamp) ? Phase.Expiry : Phase.Maturity) : Phase.Trading;
}
/// @notice gets combined positions of the game
/// @return combinedPositions game combined positions
function getCombinedPositions(
uint _marketIndex
) public view returns (ISportsAMMV2.CombinedPosition[] memory combinedPositions) {
return markets[_marketIndex].combinedPositions;
}
/* ========== EXTERNAL WRITE FUNCTIONS ========== */
/// @notice exercise ticket
function exercise(address _exerciseCollateral) external onlyAMM returns (uint) {
require(!paused, "Market paused");
bool isExercisable = isTicketExercisable();
require(isExercisable, "Ticket not exercisable yet");
uint payoutWithFees = collateral.balanceOf(address(this));
uint payout = payoutWithFees - fees;
bool isCancelled = false;
if (_isUserTheWinner()) {
finalPayout = payout;
isCancelled = true;
for (uint i = 0; i < numOfMarkets; i++) {
bool isCancelledMarketPosition = sportsAMM.resultManager().isCancelledMarketPosition(
markets[i].gameId,
markets[i].typeId,
markets[i].playerId,
markets[i].line,
markets[i].position,
markets[i].combinedPositions
);
if (isCancelledMarketPosition) {
finalPayout = (finalPayout * markets[i].odd) / ONE;
} else {
isCancelled = false;
}
}
if (isCancelled) {
finalPayout = buyInAmount;
}
collateral.safeTransfer(
_exerciseCollateral == address(0) || _exerciseCollateral == address(collateral)
? address(ticketOwner)
: address(sportsAMM),
finalPayout
);
}
// if user is lost or if the user payout was less than anticipated due to cancelled games, send the remainder to AMM
uint balance = collateral.balanceOf(address(this));
if (balance != 0) {
collateral.safeTransfer(address(sportsAMM), balance);
}
_resolve(!isTicketLost(), isCancelled);
return finalPayout;
}
/// @notice expire ticket
function expire(address _beneficiary) external onlyAMM {
require(phase() == Phase.Expiry, "Ticket not in expiry phase");
require(!resolved, "Can't expire resolved ticket");
emit Expired(_beneficiary);
_selfDestruct(_beneficiary);
}
/// @notice withdraw collateral from the ticket
function withdrawCollateral(address recipient) external onlyAMM {
collateral.safeTransfer(recipient, collateral.balanceOf(address(this)));
}
/* ========== INTERNAL FUNCTIONS ========== */
function _resolve(bool _hasUserWon, bool _cancelled) internal {
resolved = true;
cancelled = _cancelled;
emit Resolved(_hasUserWon, _cancelled);
}
function _selfDestruct(address beneficiary) internal {
uint balance = collateral.balanceOf(address(this));
if (balance != 0) {
collateral.safeTransfer(beneficiary, balance);
}
}
function _isUserTheWinner() internal view returns (bool hasUserWon) {
if (areAllMarketsResolved()) {
hasUserWon = !isTicketLost();
}
}
/* ========== SETTERS ========== */
function setPaused(bool _paused) external {
require(msg.sender == address(sportsAMM.manager()), "Invalid sender");
require(paused != _paused, "State not changed");
paused = _paused;
emit PauseUpdated(_paused);
}
/* ========== MODIFIERS ========== */
modifier onlyAMM() {
require(msg.sender == address(sportsAMM), "Only the AMM may perform these methods");
_;
}
/* ========== EVENTS ========== */
event Resolved(bool isUserTheWinner, bool cancelled);
event Expired(address beneficiary);
event PauseUpdated(bool paused);
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
contract OwnedWithInit {
address public owner;
address public nominatedOwner;
constructor() {}
function initOwner(address _owner) internal {
require(owner == address(0), "Init can only be called when owner is 0");
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);
}
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.20;
// 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.20;
/**
* @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");
}
}{
"optimizer": {
"enabled": true,
"runs": 200
},
"evmVersion": "paris",
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"libraries": {}
}Contract ABI
API[{"inputs":[{"internalType":"address","name":"target","type":"address"}],"name":"AddressEmptyCode","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"AddressInsufficientBalance","type":"error"},{"inputs":[],"name":"ERC1167FailedCreateClone","type":"error"},{"inputs":[],"name":"EnforcedPause","type":"error"},{"inputs":[],"name":"ExpectedPause","type":"error"},{"inputs":[],"name":"FailedInnerCall","type":"error"},{"inputs":[],"name":"InvalidInitialization","type":"error"},{"inputs":[],"name":"NotInitializing","type":"error"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"SafeERC20FailedOperation","type":"error"},{"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":"newProvider","type":"address"}],"name":"DefaultLiquidityProviderChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"round","type":"uint256"}],"name":"Deposited","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint64","name":"version","type":"uint64"}],"name":"Initialized","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":"address","name":"newMastercopy","type":"address"}],"name":"PoolRoundMastercopyChanged","type":"event"},{"anonymous":false,"inputs":[],"name":"PoolStarted","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":"round","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"batchSize","type":"uint256"}],"name":"RoundClosingBatchProcessed","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"round","type":"uint256"}],"name":"RoundClosingPrepared","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":"round","type":"uint256"},{"indexed":false,"internalType":"address","name":"roundPool","type":"address"}],"name":"RoundPoolCreated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"safeBoxShare","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"safeBoxAmount","type":"uint256"}],"name":"SafeBoxSharePaid","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"safeBox","type":"address"},{"indexed":false,"internalType":"uint256","name":"safeBoxImpact","type":"uint256"}],"name":"SetSafeBoxParams","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"sportAMM","type":"address"}],"name":"SportAMMChanged","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":[{"indexed":false,"internalType":"address","name":"user","type":"address"}],"name":"WithdrawalRequested","type":"event"},{"inputs":[],"name":"acceptOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"addressManager","outputs":[{"internalType":"contract IAddressManager","name":"","type":"address"}],"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":"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":[],"name":"closeRound","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"collateral","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"collateralKey","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"ticket","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"commitTrade","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":[],"name":"defaultLiquidityProvider","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"deposit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"exerciseTicketsReadyToBeExercised","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_batchSize","type":"uint256"}],"name":"exerciseTicketsReadyToBeExercisedBatch","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"firstRoundStartTime","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getCollateralPrice","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_round","type":"uint256"}],"name":"getNumberOfTradingTicketsPerRound","outputs":[{"internalType":"uint256","name":"numOfTickets","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_round","type":"uint256"}],"name":"getRoundEndTime","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_round","type":"uint256"}],"name":"getRoundStartTime","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_ticket","type":"address"}],"name":"getTicketPool","outputs":[{"internalType":"address","name":"roundPool","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_ticket","type":"address"}],"name":"getTicketRound","outputs":[{"internalType":"uint256","name":"ticketRound","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getUsersCountInCurrentRound","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"hasTicketsReadyToBeExercised","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"initNonReentrant","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"address","name":"_sportsAMM","type":"address"},{"internalType":"address","name":"_addressManager","type":"address"},{"internalType":"contract IERC20","name":"_collateral","type":"address"},{"internalType":"uint256","name":"_roundLength","type":"uint256"},{"internalType":"uint256","name":"_maxAllowedDeposit","type":"uint256"},{"internalType":"uint256","name":"_minDepositAmount","type":"uint256"},{"internalType":"uint256","name":"_maxAllowedUsers","type":"uint256"},{"internalType":"uint256","name":"_utilizationRate","type":"uint256"},{"internalType":"address","name":"_safeBox","type":"address"},{"internalType":"uint256","name":"_safeBoxImpact","type":"uint256"},{"internalType":"bytes32","name":"_collateralKey","type":"bytes32"}],"internalType":"struct SportsAMMV2LiquidityPool.InitParams","name":"params","type":"tuple"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"address","name":"","type":"address"}],"name":"isTradingTicketInARound","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"}],"name":"isUserLPing","outputs":[{"internalType":"bool","name":"isUserInLP","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":[{"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":[{"internalType":"uint256","name":"_share","type":"uint256"}],"name":"partialWithdrawalRequest","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"poolRoundMastercopy","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"prepareRoundClosing","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_batchSize","type":"uint256"}],"name":"processRoundClosingBatch","outputs":[],"stateMutability":"nonpayable","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":"roundClosingPrepared","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"roundLength","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"roundPerTicket","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"roundPools","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"safeBox","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"safeBoxImpact","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_defaultLiquidityProvider","type":"address"}],"name":"setDefaultLiquidityProvider","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":"address","name":"_owner","type":"address"}],"name":"setOwner","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"_setPausing","type":"bool"}],"name":"setPaused","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_poolRoundMastercopy","type":"address"}],"name":"setPoolRoundMastercopy","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_roundLength","type":"uint256"}],"name":"setRoundLength","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_safeBox","type":"address"},{"internalType":"uint256","name":"_safeBoxImpact","type":"uint256"}],"name":"setSafeBoxParams","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract ISportsAMMV2","name":"_sportsAMM","type":"address"}],"name":"setSportsAMM","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_utilizationRate","type":"uint256"}],"name":"setUtilizationRate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"sportsAMM","outputs":[{"internalType":"contract ISportsAMMV2","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"start","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"started","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"address","name":"","type":"address"}],"name":"ticketAlreadyExercisedInRound","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalDeposited","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"tradingTicketsPerRound","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":"address","name":"_ticket","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"transferToPool","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":"usersCurrentlyInPool","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":"usersProcessedInRound","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"utilizationRate","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"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"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"withdrawalShare","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"}]Contract Creation Code
608060405234801561001057600080fd5b5061504f806100206000396000f3fe608060405234801561001057600080fd5b506004361061043e5760003560e01c80636c321c8a11610236578063c99252881161013b578063ddc6ac23116100c3578063ebc7977211610087578063ebc79772146109bd578063ee161cce146109c5578063f61fcb8b146109cd578063f7683bbc146109ed578063ff50abdc146109f557600080fd5b8063ddc6ac2314610974578063ddcc8fe914610987578063e278fe6f1461099a578063e81e52ee146109a2578063e8362b77146109b557600080fd5b8063d7efa1291161010a578063d7efa12914610915578063d8dfeb4514610928578063d95ad45c1461093b578063db7e36481461094e578063db7f92d41461096157600080fd5b8063c9925288146108d8578063c9f4ff46146108f0578063d27c079714610903578063d69fb6681461090c57600080fd5b80639bd2e61b116101be578063b6b55f251161018d578063b6b55f251461088e578063b9b1be8b146108a1578063bdcc22e9146108b4578063be9a6555146108bd578063c3b83f5f146108c557600080fd5b80639bd2e61b14610837578063a6644f961461084a578063a8df539f14610878578063b562a1ab1461088557600080fd5b80637a1e0aa8116102055780637a1e0aa8146107e05780638b649b94146107f35780638b844412146107fc5780638c54c812146108045780638da5cb5b1461082457600080fd5b80636c321c8a1461079c57806374094edd146107a557806377332fc5146107c557806379ba5097146107d857600080fd5b80633b92d7581161034757806358c09cc0116102cf578063634e0d9711610293578063634e0d9714610728578063645006ca1461075657806365e0e7251461075f5780636685fdc214610772578063681312f51461078957600080fd5b806358c09cc0146106c05780635c7b396e146106d35780635c975abb146106dc5780635ddd3e83146106f4578063610589e11461071f57600080fd5b80634a96fc84116103165780634a96fc841461065f5780634ae7937f146106725780634d549a421461069257806353a47bb7146106a557806353e8bdb7146106b857600080fd5b80633b92d758146105fd57806340774ff6146106105780634651f0801461062357806348663e951461064c57600080fd5b80631baa8856116103ca57806327c284421161039957806327c2844214610581578063311c56df146105af578063336d30ed146105b7578063343e4f9f146105d75780633ab76e9f146105ea57600080fd5b80631baa88561461051e5780631daae173146105275780631f2698ab1461055a578063202ffce81461056e57600080fd5b8063145dee7d11610411578063145dee7d146104bc578063146ca531146104dc5780631627540c146104e557806316c38b3c146104f85780631b2a52d81461050b57600080fd5b806303d868db1461044357806309b17b3d1461047357806312b19a131461048857806313af4035146104a9575b600080fd5b610456610451366004614b25565b6109fe565b6040516001600160a01b0390911681526020015b60405180910390f35b610486610481366004614b47565b610a36565b005b61049b610496366004614b60565b610cec565b60405190815260200161046a565b6104866104b7366004614b8e565b610d1a565b61049b6104ca366004614b60565b6000908152600f602052604090205490565b61049b60055481565b6104866104f3366004614b8e565b610e50565b610486610506366004614bb9565b610ea6565b610486610519366004614b60565b610ec6565b61049b60075481565b61054a610535366004614b8e565b600d6020526000908152604090205460ff1681565b604051901515815260200161046a565b60045461054a90600160a01b900460ff1681565b61048661057c366004614b60565b61159a565b61054a61058f366004614bd6565b601160209081526000928352604080842090915290825290205460ff1681565b6104866115d7565b61049b6105c5366004614b60565b60146020526000908152604090205481565b6104566105e5366004614b25565b61183b565b602154610456906001600160a01b031681565b601954610456906001600160a01b031681565b61048661061e366004614b60565b611857565b610456610631366004614b60565b6008602052600090815260409020546001600160a01b031681565b601f54610456906001600160a01b031681565b61048661066d366004614b60565b611894565b61049b610680366004614b60565b600c6020526000908152604090205481565b6104866106a0366004614b8e565b611bfe565b600154610456906001600160a01b031681565b610486611c7a565b6104866106ce366004614c06565b611f6c565b61049b601d5481565b600080516020614ffa8339815191525460ff1661054a565b61049b610702366004614bd6565b600b60209081526000928352604080842090915290825290205481565b61049b60175481565b61054a610736366004614bd6565b600a60209081526000928352604080842090915290825290205460ff1681565b61049b60165481565b61048661076d366004614b8e565b61239e565b60055460009081526009602052604090205461049b565b610486610797366004614b60565b61241a565b61049b601e5481565b61049b6107b3366004614b60565b60136020526000908152604090205481565b6104566107d3366004614b8e565b6124bf565b6104866124ee565b6104866107ee366004614c06565b6125d8565b61049b60065481565b61048661263f565b61049b610812366004614b8e565b60126020526000908152604090205481565b600054610456906001600160a01b031681565b610486610845366004614b60565b612916565b61054a610858366004614bd6565b601060209081526000928352604080842090915290825290205460ff1681565b601c5461054a9060ff1681565b61049b60225481565b61048661089c366004614b60565b612c01565b601a54610456906001600160a01b031681565b61049b60185481565b610486612e05565b6104866108d3366004614b8e565b612fa2565b6003546104569061010090046001600160a01b031681565b61049b6108fe366004614b25565b6130ab565b61049b60155481565b61049b60205481565b610486610923366004614c06565b6130eb565b600454610456906001600160a01b031681565b61054a610949366004614b8e565b6131fd565b61049b61095c366004614b8e565b6132bc565b61048661096f366004614b60565b61345a565b61049b610982366004614b60565b613497565b610486610995366004614b60565b6134a8565b6104866134e5565b6104866109b0366004614b8e565b61393b565b61054a613ad4565b610486613c4c565b61054a613caa565b61049b6109db366004614b8e565b600e6020526000908152604090205481565b61049b613de6565b61049b601b5481565b600f6020528160005260406000208181548110610a1a57600080fd5b6000918252602090912001546001600160a01b03169150829050565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a008054600160401b810460ff16159067ffffffffffffffff16600081158015610a7c5750825b905060008267ffffffffffffffff166001148015610a995750303b155b905081158015610aa7575080155b15610ac55760405163f92ee8a960e01b815260040160405180910390fd5b845467ffffffffffffffff191660011785558315610aef57845460ff60401b1916600160401b1785555b610aff6104b76020880188614b8e565b610b07613c4c565b610b176040870160208801614b8e565b600380546001600160a01b039290921661010002610100600160a81b0319909216919091179055610b4e6060870160408801614b8e565b602180546001600160a01b0319166001600160a01b0392909216919091179055610b7e6080870160608801614b8e565b600480546001600160a01b0319166001600160a01b0392909216919091179055610160860135602255608086013560065560a086013560155560c086013560165560e0860135601755610100860135601e55610be261014087016101208801614b8e565b601f80546001600160a01b0319166001600160a01b0392831617905561014087013560209081556004549091169063095ea7b390610c269060408a01908a01614b8e565b6040516001600160e01b031960e084901b1681526001600160a01b03909116600482015260001960248201526044016020604051808303816000875af1158015610c74573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c989190614c32565b5060016005558315610ce457845460ff60401b19168555604051600181527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15b505050505050565b600654600090610cfd600184614c65565b610d079190614c78565b600754610d149190614c8f565b92915050565b6001600160a01b038116610d755760405162461bcd60e51b815260206004820152601960248201527f4f776e657220616464726573732063616e6e6f7420626520300000000000000060448201526064015b60405180910390fd5b600154600160a01b900460ff1615610de15760405162461bcd60e51b815260206004820152602960248201527f416c726561647920696e697469616c697a65642c20757365206e6f6d696e617460448201526832a732bba7bbb732b960b91b6064820152608401610d6c565b6001805460ff60a01b1916600160a01b179055600080546001600160a01b0383166001600160a01b0319909116811782556040805192835260208301919091527fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c91015b60405180910390a150565b610e58613ee2565b600180546001600160a01b0319166001600160a01b0383169081179091556040519081527f906a1c6bd7e3091ea86693dd029a831c19049ce77f1dce2ce0bab1cacbabce2290602001610e45565b610eae613ee2565b80610ebe57610ebb613f56565b50565b610ebb613fb0565b600160026000828254610ed99190614c8f565b9091555050600254610ee9613ff9565b601c5460ff16610f3b5760405162461bcd60e51b815260206004820152601a60248201527f526f756e6420636c6f73696e67206e6f742070726570617265640000000000006044820152606401610d6c565b600554600090815260096020526040902054601d5410610f9d5760405162461bcd60e51b815260206004820152601b60248201527f416c6c20757365727320616c72656164792070726f63657373656400000000006044820152606401610d6c565b60008211610fbd5760405162461bcd60e51b8152600401610d6c90614ca2565b60215460405163bf40fac160e01b815260206004820152600d60248201526c5374616b696e675468616c657360981b60448201526000916001600160a01b03169063bf40fac190606401602060405180830381865afa158015611024573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110489190614ce5565b600554600090815260086020526040812054601d549293506001600160a01b031691611075908690614c8f565b6005546000908152600960205260409020549091508111156110a557506005546000908152600960205260409020545b6004805460035460408051632bac3c5960e21b815290516000946001600160a01b03948516946101009094049093169263aeb0f164928082019260209290918290030181865afa1580156110fd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111219190614ce5565b6001600160a01b03161490506000601d5490505b8281101561153457600554600090815260096020526040812080548390811061116057611160614d02565b6000918252602080832090910154600554835260138252604080842054600b84528185206001600160a01b0390931680865292909352832054909350670de0b6b3a7640000916111af91614c78565b6111b99190614d18565b6001600160a01b0383166000908152600d602052604090205490915060ff161580156111f5575060055460009081526013602052604090205415155b156112f05780600b6000600554600161120e9190614c8f565b81526020019081526020016000206000846001600160a01b03166001600160a01b031681526020019081526020016000205461124a9190614c8f565b600b6000600554600161125d9190614c8f565b81526020019081526020016000206000846001600160a01b03166001600160a01b03168152602001908152602001600020819055506009600060055460016112a59190614c8f565b8152602080820192909252604001600090812080546001810182559082529190200180546001600160a01b0319166001600160a01b0384161790556112eb87828661402a565b61150e565b6001600160a01b0382166000908152600e602052604090205415611466576001600160a01b0382166000908152600e6020526040812054670de0b6b3a76400009061133b9084614c78565b6113459190614d18565b600454909150611360906001600160a01b0316888584614149565b604080516001600160a01b0385168152602081018390527fd8138f8a3f377c5259ca548e70e4c2de94f129f5a11036a15b69513cba2b426a910160405180910390a16001600160a01b0383166000908152600d60209081526040808320805460ff19169055600e9091528120819055600554600991906113e1906001614c8f565b8152602080820192909252604001600090812080546001810182559082529190200180546001600160a01b0319166001600160a01b0385161790556114268183614c65565b600b600060055460016114399190614c8f565b8152602080820192909252604090810160009081206001600160a01b03881682529092529020555061150e565b6000600b6000600554600161147b9190614c8f565b8152602080820192909252604090810160009081206001600160a01b038088168352935220919091556004546114b49116878484614149565b6001600160a01b0382166000818152600d6020908152604091829020805460ff19169055815192835282018390527fd8138f8a3f377c5259ca548e70e4c2de94f129f5a11036a15b69513cba2b426a910160405180910390a15b601d5461151c906001614c8f565b601d555081905061152c81614d3a565b915050611135565b5060055460408051918252602082018890527f2e692c8fcabe33ba22535323e79dcb54ef22dccdb8e4ebdd9f2a7ffb1a28856c910160405180910390a15050505060025481146115965760405162461bcd60e51b8152600401610d6c90614d53565b5050565b6115a2613ee2565b60178190556040518181527fe7c2c09f66c8b970b4a99250f4d0844e1496b9d51d4760a17b0134ddd52023e190602001610e45565b6001600260008282546115ea9190614c8f565b9091555050600254600454600160a01b900460ff1661161b5760405162461bcd60e51b8152600401610d6c90614d8a565b336000908152600d602052604090205460ff161561167b5760405162461bcd60e51b815260206004820152601c60248201527f5769746864726177616c20616c726561647920726571756573746564000000006044820152606401610d6c565b6005546000908152600b602090815260408083203384529091529020546116da5760405162461bcd60e51b81526020600482015260136024820152724e6f7468696e6720746f20776974686472617760681b6044820152606401610d6c565b600b600060055460016116ed9190614c8f565b815260208082019290925260409081016000908120338252909252902054156117285760405162461bcd60e51b8152600401610d6c90614db8565b611730613ff9565b601c5460ff16156117535760405162461bcd60e51b8152600401610d6c90614e0e565b6005546000908152600b60209081526040808320338452909152902054601b5411156117b4576005546000908152600b60209081526040808320338452909152812054601b8054919290916117a9908490614c65565b909155506117ba9050565b6000601b555b60016018546117c99190614c65565b601855336000818152600d6020908152604091829020805460ff1916600117905590519182527fe5892ff2a8b08efb903ffbba1f0514c1d3e22eea34dd5b89cf30aabce03dde5a910160405180910390a16002548114610ebb5760405162461bcd60e51b8152600401610d6c90614d53565b60096020528160005260406000208181548110610a1a57600080fd5b61185f613ee2565b601e8190556040518181527fc117ccf765672707ebe3c1606037488c1e27dc1f42b5266e3d6b496db7d4209e90602001610e45565b6001600260008282546118a79190614c8f565b90915550506002546118b7613ff9565b601c5460ff16156118da5760405162461bcd60e51b8152600401610d6c90614e0e565b600082116118fa5760405162461bcd60e51b8152600401610d6c90614ca2565b600080805b6005546000908152600f6020526040902054811015611bda57828514611bda576005546000908152600f6020526040812080548390811061194257611942614d02565b600091825260208083209091015460055483526011825260408084206001600160a01b039092168085529190925291205490915060ff16611bc757809250826001600160a01b031663e74d3c476040518163ffffffff1660e01b8152600401602060405180830381865afa1580156119be573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119e29190614c32565b8015611a4d5750826001600160a01b0316633356a35a6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611a27573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a4b9190614c32565b155b15611ab85760035460405163066aa16f60e21b81526001600160a01b038381166004830152610100909204909116906319aa85bc90602401600060405180830381600087803b158015611a9f57600080fd5b505af1158015611ab3573d6000803e3d6000fd5b505050505b826001600160a01b0316633356a35a6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611af6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b1a9190614c32565b80611b825750826001600160a01b0316633f6fa6556040518163ffffffff1660e01b8152600401602060405180830381865afa158015611b5e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b829190614c32565b15611bc75760055460009081526011602090815260408083206001600160a01b03851684529091529020805460ff19166001908117909155611bc49085614c8f565b93505b5080611bd281614d3a565b9150506118ff565b50505060025481146115965760405162461bcd60e51b8152600401610d6c90614d53565b611c06613ee2565b6001600160a01b038116611c2c5760405162461bcd60e51b8152600401610d6c90614e55565b601a80546001600160a01b0319166001600160a01b0383169081179091556040519081527fa65a5aa86bb6f8e75752296da3ebda45474c8a302fc640c3b62868793862a03390602001610e45565b601c5460ff1615611c9d5760405162461bcd60e51b8152600401610d6c90614e0e565b60008060005b6005546000908152600f6020526040902054811015611f67576005546000908152600f60205260409020805482908110611cdf57611cdf614d02565b600091825260208083209091015460055483526011825260408084206001600160a01b039092168085529190925291205490925060ff16611f5557819250826001600160a01b031663e74d3c476040518163ffffffff1660e01b8152600401602060405180830381865afa158015611d5b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d7f9190614c32565b8015611dea5750826001600160a01b0316633356a35a6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611dc4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611de89190614c32565b155b15611e555760035460405163066aa16f60e21b81526001600160a01b038481166004830152610100909204909116906319aa85bc90602401600060405180830381600087803b158015611e3c57600080fd5b505af1158015611e50573d6000803e3d6000fd5b505050505b826001600160a01b0316633356a35a6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611e93573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611eb79190614c32565b80611f1f5750826001600160a01b0316633f6fa6556040518163ffffffff1660e01b8152600401602060405180830381865afa158015611efb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f1f9190614c32565b15611f555760055460009081526011602090815260408083206001600160a01b03861684529091529020805460ff191660011790555b80611f5f81614d3a565b915050611ca3565b505050565b600160026000828254611f7f9190614c8f565b9091555050600254611f8f613ff9565b60035461010090046001600160a01b03163314611fbe5760405162461bcd60e51b8152600401610d6c90614e8c565b601c5460ff1615611fe15760405162461bcd60e51b8152600401610d6c90614e0e565b600454600160a01b900460ff1661200a5760405162461bcd60e51b8152600401610d6c90614d8a565b6000821161205a5760405162461bcd60e51b815260206004820152601960248201527f43616e277420636f6d6d69742061207a65726f207472616465000000000000006044820152606401610d6c565b6000612065846132bc565b6001600160a01b038516600090815260126020526040812082905590915061208c826141a3565b905060055482036121e3576003546004546120bb916001600160a01b0391821691849161010090041687614149565b601e546005546000908152600c6020526040902054670de0b6b3a7640000916120e391614c78565b6120ed9190614d18565b6005546000908152600c60205260409020546121099190614c65565b600480546040516370a0823160e01b81526001600160a01b03858116938201939093529116906370a0823190602401602060405180830381865afa158015612155573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121799190614ed2565b10156121de5760405162461bcd60e51b815260206004820152602e60248201527f416d6f756e74206578636565647320617661696c61626c65207574696c697a6160448201526d1d1a5bdb88199bdc881c9bdd5b9960921b6064820152608401610d6c565b612321565b6005548211156122d857600480546040516370a0823160e01b81526001600160a01b0384811693820193909352600092909116906370a0823190602401602060405180830381865afa15801561223d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122619190614ed2565b90508481106122935760035460045461228e916001600160a01b0391821691859161010090041688614149565b6122d2565b600061229f8287614c65565b90506122ac818486614381565b6003546004546122d0916001600160a01b0391821691869161010090041689614149565b505b50612321565b816001146123185760405162461bcd60e51b815260206004820152600d60248201526c125b9d985b1a59081c9bdd5b99609a1b6044820152606401610d6c565b61232184614496565b506000818152600f602090815260408083208054600180820183559185528385200180546001600160a01b0319166001600160a01b038a1690811790915594845260108352818420948452939091529020805460ff191690911790556002548114611f675760405162461bcd60e51b8152600401610d6c90614d53565b6123a6613ee2565b6001600160a01b0381166123cc5760405162461bcd60e51b8152600401610d6c90614e55565b601980546001600160a01b0319166001600160a01b0383169081179091556040519081527faaf6f0738515c3cf390f1b3faec649d2dacb169d024089afc43bbe2fe66cd2d890602001610e45565b612422613ee2565b600454600160a01b900460ff161561248a5760405162461bcd60e51b815260206004820152602560248201527f43616e2774206368616e676520726f756e64206c656e677468206166746572206044820152641cdd185c9d60da1b6064820152608401610d6c565b60068190556040518181527f1d1fb7111c3779798bd4aefb2daea07ee8257a13c7eaceba89b4b1ccd405050d90602001610e45565b6000600860006124ce846132bc565b81526020810191909152604001600020546001600160a01b031692915050565b6001546001600160a01b031633146125665760405162461bcd60e51b815260206004820152603560248201527f596f75206d757374206265206e6f6d696e61746564206265666f726520796f7560448201527402063616e20616363657074206f776e65727368697605c1b6064820152608401610d6c565b600054600154604080516001600160a01b0393841681529290911660208301527fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c910160405180910390a160018054600080546001600160a01b03199081166001600160a01b03841617909155169055565b6125e0613ee2565b601f80546001600160a01b0319166001600160a01b0384169081179091556020828155604080519283529082018390527fa1a8623472ca4e2879372be60dfd1ff0675778e49f7379eedd98ca57cf36b21a910160405180910390a15050565b6001600260008282546126529190614c8f565b9091555050600254612662613ff9565b601c5460ff16156126855760405162461bcd60e51b8152600401610d6c90614e0e565b61268d613caa565b6126d95760405162461bcd60e51b815260206004820152601960248201527f43616e277420636c6f73652063757272656e7420726f756e64000000000000006044820152606401610d6c565b6126e1611c7a565b600554600090815260086020526040808220546004805492516370a0823160e01b81526001600160a01b0392831691810182905290939291909116906370a0823190602401602060405180830381865afa158015612743573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127679190614ed2565b6005546000908152600c602052604090205490915081111561283657602080546005546000908152600c9092526040822054670de0b6b3a764000091906127ae9085614c65565b6127b89190614c78565b6127c29190614d18565b601f546004549192506127e4916001600160a01b039081169186911684614149565b6127ee8183614c65565b91507fb8379d05082aa2dd32963972d72cc2d46257811133341855b63bb2fddda6ca3e6020548260405161282c929190918252602082015260400190565b60405180910390a1505b6005546000908152600c60205260408120549003612868576005546000908152601360205260409020600190556128a9565b6005546000908152600c602052604090205461288c670de0b6b3a764000083614c78565b6128969190614d18565b6005546000908152601360205260409020555b601c805460ff191660011790556005546040517fa224cce482b24082d1d3128437615f7f5ce87b97453a11114846ea442a100272916128eb9190815260200190565b60405180910390a150506002548114610ebb5760405162461bcd60e51b8152600401610d6c90614d53565b6001600260008282546129299190614c8f565b9091555050600254600454600160a01b900460ff1661295a5760405162461bcd60e51b8152600401610d6c90614d8a565b336000908152600d602052604090205460ff16156129ba5760405162461bcd60e51b815260206004820152601c60248201527f5769746864726177616c20616c726561647920726571756573746564000000006044820152606401610d6c565b6005546000908152600b60209081526040808320338452909152902054612a195760405162461bcd60e51b81526020600482015260136024820152724e6f7468696e6720746f20776974686472617760681b6044820152606401610d6c565b600b60006005546001612a2c9190614c8f565b81526020808201929092526040908101600090812033825290925290205415612a675760405162461bcd60e51b8152600401610d6c90614db8565b612a6f613ff9565b601c5460ff1615612a925760405162461bcd60e51b8152600401610d6c90614e0e565b612aa4662386f26fc10000600a614c78565b8210158015612ac45750612ac0662386f26fc10000605a614c78565b8211155b612b1c5760405162461bcd60e51b815260206004820152602360248201527f53686172652068617320746f206265206265747765656e2031302520616e642060448201526239302560e81b6064820152608401610d6c565b6005546000908152600b60209081526040808320338452909152812054670de0b6b3a764000090612b4e908590614c78565b612b589190614d18565b905080601b541115612b815780601b6000828254612b769190614c65565b90915550612b879050565b6000601b555b336000818152600d60209081526040808320805460ff19166001179055600e82529182902086905590519182527fe5892ff2a8b08efb903ffbba1f0514c1d3e22eea34dd5b89cf30aabce03dde5a910160405180910390a15060025481146115965760405162461bcd60e51b8152600401610d6c90614d53565b336000908152600d6020526040902054819060ff1615612c735760405162461bcd60e51b815260206004820152602760248201527f5769746864726177616c206973207265717565737465642c2063616e6e6f742060448201526619195c1bdcda5d60ca1b6064820152608401610d6c565b60155481601b54612c849190614c8f565b1115612cdc5760405162461bcd60e51b815260206004820152602160248201527f4465706f73697420616d6f756e74206578636565647320414d4d204c502063616044820152600760fc1b6064820152608401610d6c565b6005546000908152600b60209081526040808320338452909152902054158015612d345750600b60006005546001612d149190614c8f565b815260208082019290925260409081016000908120338252909252902054155b15612d9557601654811015612d955760405162461bcd60e51b815260206004820152602160248201527f416d6f756e74206c657373207468616e206d696e4465706f736974416d6f756e6044820152601d60fa1b6064820152608401610d6c565b600160026000828254612da89190614c8f565b9091555050600254612db8613ff9565b601c5460ff1615612ddb5760405162461bcd60e51b8152600401610d6c90614e0e565b612de4836145df565b6002548114611f675760405162461bcd60e51b8152600401610d6c90614d53565b612e0d613ee2565b600454600160a01b900460ff1615612e605760405162461bcd60e51b81526020600482015260166024820152751314081a185cc8185b1c9958591e481cdd185c9d195960521b6044820152606401610d6c565b6002600052600c6020527f5d6016397a73f5e079297ac5a36fef17b4d9c3831618e63ab105738020ddd72054612ed85760405162461bcd60e51b815260206004820152601d60248201527f43616e206e6f7420737461727420776974682030206465706f736974730000006044820152606401610d6c565b4260075560026005819055600090612eef906141a3565b9050806001600160a01b0316637d3de7ce600754612f0d6002610cec565b6040516001600160e01b031960e085901b16815260048101929092526024820152604401600060405180830381600087803b158015612f4b57600080fd5b505af1158015612f5f573d6000803e3d6000fd5b50506004805460ff60a01b1916600160a01b17905550506040517f960682678fca98f3ed131eaf165e59544bcd738e948f0b3c64f58fa9e1c65e6090600090a150565b612faa613ee2565b6001600160a01b038116612ff25760405162461bcd60e51b815260206004820152600f60248201526e496e76616c6964206164647265737360881b6044820152606401610d6c565b600154600160a81b900460ff16156130425760405162461bcd60e51b8152602060048201526013602482015272105b1c9958591e481d1c985b9cd9995c9c9959606a1b6044820152606401610d6c565b600080546001600160a01b0383166001600160a01b031990911681179091556001805460ff60a81b1916600160a81b1790556040805182815260208101929092527fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c9101610e45565b60008281526014602081815260408084205460138352818520548686529390925283205490916130da91614c78565b6130e49190614d18565b9392505050565b6130f3613ff9565b601c5460ff16156131165760405162461bcd60e51b8152600401610d6c90614e0e565b60035461010090046001600160a01b031633146131455760405162461bcd60e51b8152600401610d6c90614e8c565b6000613150836132bc565b90506000600182111561316b57613166826141a3565b613178565b6019546001600160a01b03165b60035460045491925061319e916001600160a01b03908116916101009004168386614149565b60008281526010602090815260408083206001600160a01b038816845290915290205460ff16156131f75760008281526011602090815260408083206001600160a01b03881684529091529020805460ff191660011790555b50505050565b6005546000908152600b602090815260408083206001600160a01b038516845290915281205415158061327457506000600b600060055460016132409190614c8f565b81526020019081526020016000206000846001600160a01b03166001600160a01b0316815260200190815260200160002054115b8015610d1457506001600160a01b0382166000908152600d602052604090205460ff161580610d145750506001600160a01b03166000908152600e6020526040902054151590565b6001600160a01b0381166000908152601260205260408120549081900361345557816000805b826001600160a01b03166362e5c8196040518163ffffffff1660e01b8152600401602060405180830381865afa158015613320573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906133449190614ed2565b8110156134515760405163b1283e7760e01b8152600481018290526001600160a01b0384169063b1283e779060240161012060405180830381865afa158015613391573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906133b59190614f0e565b5050600754939850505050851115925061343a9150505780600003613400576006546007546133e49084614c65565b6133ee9190614d18565b6133f9906002614c8f565b935061343f565b83600654600754846134129190614c65565b61341c9190614d18565b613427906002614c8f565b146134355760019350613451565b61343f565b600193505b8061344981614d3a565b9150506132e2565b5050505b919050565b613462613ee2565b60168190556040518181527f990717cc219e5348c1b88bb0ff530d804f0b6f54f3b03844a2bfbe4eb1e9c5d690602001610e45565b600654600090610cfd600284614c65565b6134b0613ee2565b60158190556040518181527f8c43aa02599ac8f8bab4724621ceea5e7a06b07bbbfaf3b7bd0386cbe481ea3c90602001610e45565b6001600260008282546134f89190614c8f565b9091555050600254613508613ff9565b601c5460ff1661355a5760405162461bcd60e51b815260206004820152601a60248201527f526f756e6420636c6f73696e67206e6f742070726570617265640000000000006044820152606401610d6c565b600554600090815260096020526040902054601d54146135bc5760405162461bcd60e51b815260206004820152601b60248201527f4e6f7420616c6c2075736572732070726f6365737365642079657400000000006044820152606401610d6c565b601c805460ff19169055600554600090815260086020908152604080832054600b83528184206019546001600160a01b0390811686529352922054911690156136b657600554600090815260136020908152604080832054600b83528184206019546001600160a01b03168552909252822054670de0b6b3a76400009161364291614c78565b61364c9190614d18565b60195460045491925061366e916001600160a01b039081169185911684614149565b601954604080516001600160a01b039092168252602082018390527fd8138f8a3f377c5259ca548e70e4c2de94f129f5a11036a15b69513cba2b426a910160405180910390a1505b6005546002036136e357600554600090815260136020908152604080832054601490925290912055613746565b600554600081815260136020526040812054670de0b6b3a764000092909160149161371090600190614c65565b8152602001908152602001600020546137299190614c78565b6137339190614d18565b6005546000908152601460205260409020555b60056000815461375590614d3a565b90915550600480546040516370a0823160e01b81526001600160a01b03848116938201939093529116906370a0823190602401602060405180830381865afa1580156137a5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906137c99190614ed2565b6005546000908152600c6020526040812080549091906137ea908490614c8f565b90915550506005546000818152600b602090815260408083206019546001600160a01b03168452825280832054938352600c90915290205461382c9190614c65565b601b5560055460009061383e906141a3565b600480546040516370a0823160e01b81526001600160a01b03808716938201939093529293506138cc928592859216906370a0823190602401602060405180830381865afa158015613894573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906138b89190614ed2565b6004546001600160a01b0316929190614149565b6000601d556005547fc67dda8e11f1aa941c7e74466b1859a07a32f46aaf641d29b83be348424d93cd9061390290600190614c65565b6013600060016005546139159190614c65565b8152602001908152602001600020546040516128eb929190918252602082015260400190565b613943613ee2565b6001600160a01b0381166139695760405162461bcd60e51b8152600401610d6c90614e55565b60035461010090046001600160a01b031615613a01576004805460035460405163095ea7b360e01b81526001600160a01b0361010090920482169381019390935260006024840152169063095ea7b3906044016020604051808303816000875af11580156139db573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906139ff9190614c32565b505b60038054610100600160a81b0319166101006001600160a01b03848116820292909217928390556004805460405163095ea7b360e01b815292909404831690820152600019602482015291169063095ea7b3906044016020604051808303816000875af1158015613a76573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613a9a9190614c32565b506040516001600160a01b03821681527f576297e5fcc8cd907ee80b240284865eb3d821bdc5232e6ee9e4d78a12531c0990602001610e45565b60008080805b6005546000908152600f6020526040902054811015613c42576005546000908152600f60205260409020805482908110613b1657613b16614d02565b600091825260208083209091015460055483526011825260408084206001600160a01b039092168085529190925291205490925060ff16613c3057819250826001600160a01b031663e74d3c476040518163ffffffff1660e01b8152600401602060405180830381865afa158015613b92573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613bb69190614c32565b8015613c215750826001600160a01b0316633356a35a6040518163ffffffff1660e01b8152600401602060405180830381865afa158015613bfb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613c1f9190614c32565b155b15613c30576001935050505090565b80613c3a81614d3a565b915050613ada565b5060009250505090565b60035460ff1615613c955760405162461bcd60e51b8152602060048201526013602482015272105b1c9958591e481a5b9a5d1a585b1a5e9959606a1b6044820152606401610d6c565b6003805460ff19166001908117909155600255565b600454600090600160a01b900460ff161580613ccf5750613ccc600554610cec565b42105b15613cda5750600090565b60008060005b6005546000908152600f6020526040902054811015613ddc576005546000908152600f60205260409020805482908110613d1c57613d1c614d02565b600091825260208083209091015460055483526011825260408084206001600160a01b039092168085529190925291205490925060ff16613dca57819250826001600160a01b031663b0c56f056040518163ffffffff1660e01b8152600401602060405180830381865afa158015613d98573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613dbc9190614c32565b613dca576000935050505090565b80613dd481614d3a565b915050613ce0565b5060019250505090565b60215460405163bf40fac160e01b8152602060048201526009602482015268141c9a58d95199595960ba1b60448201526000916001600160a01b03169063bf40fac190606401602060405180830381865afa158015613e49573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613e6d9190614ce5565b6001600160a01b031663ac82f6086022546040518263ffffffff1660e01b8152600401613e9c91815260200190565b602060405180830381865afa158015613eb9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613edd9190614ed2565b905090565b6000546001600160a01b03163314613f545760405162461bcd60e51b815260206004820152602f60248201527f4f6e6c792074686520636f6e7472616374206f776e6572206d6179207065726660448201526e37b936903a3434b99030b1ba34b7b760891b6064820152608401610d6c565b565b613f5e61491e565b600080516020614ffa833981519152805460ff191681557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b039091168152602001610e45565b613fb8613ff9565b600080516020614ffa833981519152805460ff191660011781557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a25833613f98565b600080516020614ffa8339815191525460ff1615613f545760405163d93c066560e01b815260040160405180910390fd5b6001600160a01b03831615611f67576000600460009054906101000a90046001600160a01b03166001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa15801561408e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906140b29190614ed2565b9050816140e157670de0b6b3a76400006140ca613de6565b6140d49085614c78565b6140de9190614d18565b92505b60405163a2dd835f60e01b81526001600160a01b0385169063a2dd835f9061411190339087908690600401614fa9565b600060405180830381600087803b15801561412b57600080fd5b505af115801561413f573d6000803e3d6000fd5b5050505050505050565b604080516001600160a01b0385811660248301528416604482015260648082018490528251808303909101815260849091019091526020810180516001600160e01b03166323b872dd60e01b1790526131f790859061494e565b6000818152600860205260409020546001600160a01b03168061345557816001036141fd575060198054600083815260086020526040902080546001600160a01b0319166001600160a01b03928316179055905416919050565b601a546001600160a01b03166142555760405162461bcd60e51b815260206004820152601d60248201527f526f756e6420706f6f6c206d6173746572636f7079206e6f74207365740000006044820152606401610d6c565b601a5460009061426d906001600160a01b03166149b1565b6004549091506001600160a01b038083169163d13f90b49130911686614297610496600183614c65565b6142a089610cec565b6040516001600160e01b031960e088901b1681526001600160a01b03958616600482015294909316602485015260448401919091526064830152608482015260a401600060405180830381600087803b1580156142fc57600080fd5b505af1158015614310573d6000803e3d6000fd5b50505060008481526008602090815260409182902080546001600160a01b0319166001600160a01b03861690811790915582518781529182015292935083927f24c1b21b902a85b5039d7d72427d9376657229eea77880ec9e62031dc950f6ba92500160405180910390a150919050565b6019546001600160a01b03166143ce5760405162461bcd60e51b8152602060048201526012602482015271111959985d5b1d081314081b9bdd081cd95d60721b6044820152606401610d6c565b6019546004546143ec916001600160a01b0391821691168486614149565b6000818152600b602090815260408083206019546001600160a01b0316845290915281208054859290614420908490614c8f565b90915550506000818152600c602052604081208054859290614443908490614c8f565b90915550506019546040517f73a19dd210f1a7f902193214c0ee91dd35ee5b4d920cba8d519eca65a7b488ca91614489916001600160a01b039091169086908590614fa9565b60405180910390a1505050565b6019546001600160a01b03166144e35760405162461bcd60e51b8152602060048201526012602482015271111959985d5b1d081314081b9bdd081cd95d60721b6044820152606401610d6c565b60195460035460045461450d926001600160a01b0391821692908216916101009091041684614149565b6019546001600160a01b031660009081527f72c6bfb7988af3a1efa6568f02a999bc52252641c659d85961ca3d372b57d5cf602052604081208054839290614556908490614c8f565b909155505060016000908152600c6020527fd421a5181c571bba3f01190c922c3b2a896fc1d84e86c9f17ac10e67ebef8b5c8054839290614598908490614c8f565b90915550506019546040517f73a19dd210f1a7f902193214c0ee91dd35ee5b4d920cba8d519eca65a7b488ca91610e45916001600160a01b03909116908490600190614fa9565b600060055460016145f09190614c8f565b905060006145fd826141a3565b600454909150614618906001600160a01b0316338386614149565b6019546001600160a01b0316330361467e5760405162461bcd60e51b8152602060048201526024808201527f43616e2774206465706f736974206469726563746c792061732064656661756c604482015263074204c560e41b6064820152608401610d6c565b6005546000908152600b602090815260408083203384529091529020541580156146bf57506000828152600b60209081526040808320338452909152902054155b1561475857601754601854106147175760405162461bcd60e51b815260206004820152601b60248201527f4d617820616d6f756e74206f66207573657273207265616368656400000000006044820152606401610d6c565b60008281526009602090815260408220805460018181018355918452919092200180546001600160a01b0319163317905560185461475491614c8f565b6018555b6000828152600b6020908152604080832033845290915281208054859290614781908490614c8f565b90915550506000828152600c6020526040812080548592906147a4908490614c8f565b9250508190555082601b60008282546147bd9190614c8f565b909155505060215460405163bf40fac160e01b815260206004820152600d60248201526c5374616b696e675468616c657360981b60448201526000916001600160a01b03169063bf40fac190606401602060405180830381865afa158015614829573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061484d9190614ce5565b6004805460035460408051632bac3c5960e21b815290519495506148db9486948a946001600160a01b03908116946101009004169263aeb0f16492818301926020928290030181865afa1580156148a8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906148cc9190614ce5565b6001600160a01b03161461402a565b7f73a19dd210f1a7f902193214c0ee91dd35ee5b4d920cba8d519eca65a7b488ca338560055460405161491093929190614fa9565b60405180910390a150505050565b600080516020614ffa8339815191525460ff16613f5457604051638dfc202b60e01b815260040160405180910390fd5b60006149636001600160a01b03841683614a1e565b905080516000141580156149885750808060200190518101906149869190614c32565b155b15611f6757604051635274afe760e01b81526001600160a01b0384166004820152602401610d6c565b6000763d602d80600a3d3981f3363d3d373d3d3d363d730000008260601b60e81c176000526e5af43d82803e903d91602b57fd5bf38260781b17602052603760096000f090506001600160a01b038116613455576040516330be1a3d60e21b815260040160405180910390fd5b60606130e48383600084600080856001600160a01b03168486604051614a449190614fca565b60006040518083038185875af1925050503d8060008114614a81576040519150601f19603f3d011682016040523d82523d6000602084013e614a86565b606091505b5091509150614a96868383614aa0565b9695505050505050565b606082614ab557614ab082614afc565b6130e4565b8151158015614acc57506001600160a01b0384163b155b15614af557604051639996b31560e01b81526001600160a01b0385166004820152602401610d6c565b50806130e4565b805115614b0c5780518082602001fd5b604051630a12f52160e11b815260040160405180910390fd5b60008060408385031215614b3857600080fd5b50508035926020909101359150565b60006101808284031215614b5a57600080fd5b50919050565b600060208284031215614b7257600080fd5b5035919050565b6001600160a01b0381168114610ebb57600080fd5b600060208284031215614ba057600080fd5b81356130e481614b79565b8015158114610ebb57600080fd5b600060208284031215614bcb57600080fd5b81356130e481614bab565b60008060408385031215614be957600080fd5b823591506020830135614bfb81614b79565b809150509250929050565b60008060408385031215614c1957600080fd5b8235614c2481614b79565b946020939093013593505050565b600060208284031215614c4457600080fd5b81516130e481614bab565b634e487b7160e01b600052601160045260246000fd5b81810381811115610d1457610d14614c4f565b8082028115828204841417610d1457610d14614c4f565b80820180821115610d1457610d14614c4f565b60208082526023908201527f42617463682073697a652068617320746f20626520677265617465722074686160408201526206e20360ec1b606082015260800190565b600060208284031215614cf757600080fd5b81516130e481614b79565b634e487b7160e01b600052603260045260246000fd5b600082614d3557634e487b7160e01b600052601260045260246000fd5b500490565b600060018201614d4c57614d4c614c4f565b5060010190565b6020808252601f908201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604082015260600190565b602080825260149082015273141bdbdb081a185cc81b9bdd081cdd185c9d195960621b604082015260600190565b60208082526036908201527f43616e277420776974686472617720617320796f7520616c72656164792064656040820152751c1bdcda5d195908199bdc881b995e1d081c9bdd5b9960521b606082015260800190565b60208082526027908201527f4e6f7420616c6c6f77656420647572696e6720726f756e64436c6f73696e67506040820152661c995c185c995960ca1b606082015260800190565b6020808252601b908201527f43616e206e6f74207365742061207a65726f2061646472657373210000000000604082015260600190565b60208082526026908201527f4f6e6c792074686520414d4d206d617920706572666f726d207468657365206d6040820152656574686f647360d01b606082015260800190565b600060208284031215614ee457600080fd5b5051919050565b805161ffff8116811461345557600080fd5b805160ff8116811461345557600080fd5b60008060008060008060008060006101208a8c031215614f2d57600080fd5b89519850614f3d60208b01614eeb565b9750614f4b60408b01614eeb565b965060608a01519550614f6060808b01614efd565b945060a08a01518060020b8114614f7657600080fd5b9350614f8460c08b01614eeb565b9250614f9260e08b01614efd565b91506101008a015190509295985092959850929598565b6001600160a01b039390931683526020830191909152604082015260600190565b6000825160005b81811015614feb5760208186018101518583015201614fd1565b50600092019182525091905056fecd5ed15c6e187e77e9aee88184c21f4f2182ab5827cb3b7e07fbedcd63f03300a2646970667358221220c2e3ea8567cd831da8b7e00eef882baa85b37ab55c360eec6a5ca19331ebbe6a64736f6c63430008140033
Deployed Bytecode
0x608060405234801561001057600080fd5b506004361061043e5760003560e01c80636c321c8a11610236578063c99252881161013b578063ddc6ac23116100c3578063ebc7977211610087578063ebc79772146109bd578063ee161cce146109c5578063f61fcb8b146109cd578063f7683bbc146109ed578063ff50abdc146109f557600080fd5b8063ddc6ac2314610974578063ddcc8fe914610987578063e278fe6f1461099a578063e81e52ee146109a2578063e8362b77146109b557600080fd5b8063d7efa1291161010a578063d7efa12914610915578063d8dfeb4514610928578063d95ad45c1461093b578063db7e36481461094e578063db7f92d41461096157600080fd5b8063c9925288146108d8578063c9f4ff46146108f0578063d27c079714610903578063d69fb6681461090c57600080fd5b80639bd2e61b116101be578063b6b55f251161018d578063b6b55f251461088e578063b9b1be8b146108a1578063bdcc22e9146108b4578063be9a6555146108bd578063c3b83f5f146108c557600080fd5b80639bd2e61b14610837578063a6644f961461084a578063a8df539f14610878578063b562a1ab1461088557600080fd5b80637a1e0aa8116102055780637a1e0aa8146107e05780638b649b94146107f35780638b844412146107fc5780638c54c812146108045780638da5cb5b1461082457600080fd5b80636c321c8a1461079c57806374094edd146107a557806377332fc5146107c557806379ba5097146107d857600080fd5b80633b92d7581161034757806358c09cc0116102cf578063634e0d9711610293578063634e0d9714610728578063645006ca1461075657806365e0e7251461075f5780636685fdc214610772578063681312f51461078957600080fd5b806358c09cc0146106c05780635c7b396e146106d35780635c975abb146106dc5780635ddd3e83146106f4578063610589e11461071f57600080fd5b80634a96fc84116103165780634a96fc841461065f5780634ae7937f146106725780634d549a421461069257806353a47bb7146106a557806353e8bdb7146106b857600080fd5b80633b92d758146105fd57806340774ff6146106105780634651f0801461062357806348663e951461064c57600080fd5b80631baa8856116103ca57806327c284421161039957806327c2844214610581578063311c56df146105af578063336d30ed146105b7578063343e4f9f146105d75780633ab76e9f146105ea57600080fd5b80631baa88561461051e5780631daae173146105275780631f2698ab1461055a578063202ffce81461056e57600080fd5b8063145dee7d11610411578063145dee7d146104bc578063146ca531146104dc5780631627540c146104e557806316c38b3c146104f85780631b2a52d81461050b57600080fd5b806303d868db1461044357806309b17b3d1461047357806312b19a131461048857806313af4035146104a9575b600080fd5b610456610451366004614b25565b6109fe565b6040516001600160a01b0390911681526020015b60405180910390f35b610486610481366004614b47565b610a36565b005b61049b610496366004614b60565b610cec565b60405190815260200161046a565b6104866104b7366004614b8e565b610d1a565b61049b6104ca366004614b60565b6000908152600f602052604090205490565b61049b60055481565b6104866104f3366004614b8e565b610e50565b610486610506366004614bb9565b610ea6565b610486610519366004614b60565b610ec6565b61049b60075481565b61054a610535366004614b8e565b600d6020526000908152604090205460ff1681565b604051901515815260200161046a565b60045461054a90600160a01b900460ff1681565b61048661057c366004614b60565b61159a565b61054a61058f366004614bd6565b601160209081526000928352604080842090915290825290205460ff1681565b6104866115d7565b61049b6105c5366004614b60565b60146020526000908152604090205481565b6104566105e5366004614b25565b61183b565b602154610456906001600160a01b031681565b601954610456906001600160a01b031681565b61048661061e366004614b60565b611857565b610456610631366004614b60565b6008602052600090815260409020546001600160a01b031681565b601f54610456906001600160a01b031681565b61048661066d366004614b60565b611894565b61049b610680366004614b60565b600c6020526000908152604090205481565b6104866106a0366004614b8e565b611bfe565b600154610456906001600160a01b031681565b610486611c7a565b6104866106ce366004614c06565b611f6c565b61049b601d5481565b600080516020614ffa8339815191525460ff1661054a565b61049b610702366004614bd6565b600b60209081526000928352604080842090915290825290205481565b61049b60175481565b61054a610736366004614bd6565b600a60209081526000928352604080842090915290825290205460ff1681565b61049b60165481565b61048661076d366004614b8e565b61239e565b60055460009081526009602052604090205461049b565b610486610797366004614b60565b61241a565b61049b601e5481565b61049b6107b3366004614b60565b60136020526000908152604090205481565b6104566107d3366004614b8e565b6124bf565b6104866124ee565b6104866107ee366004614c06565b6125d8565b61049b60065481565b61048661263f565b61049b610812366004614b8e565b60126020526000908152604090205481565b600054610456906001600160a01b031681565b610486610845366004614b60565b612916565b61054a610858366004614bd6565b601060209081526000928352604080842090915290825290205460ff1681565b601c5461054a9060ff1681565b61049b60225481565b61048661089c366004614b60565b612c01565b601a54610456906001600160a01b031681565b61049b60185481565b610486612e05565b6104866108d3366004614b8e565b612fa2565b6003546104569061010090046001600160a01b031681565b61049b6108fe366004614b25565b6130ab565b61049b60155481565b61049b60205481565b610486610923366004614c06565b6130eb565b600454610456906001600160a01b031681565b61054a610949366004614b8e565b6131fd565b61049b61095c366004614b8e565b6132bc565b61048661096f366004614b60565b61345a565b61049b610982366004614b60565b613497565b610486610995366004614b60565b6134a8565b6104866134e5565b6104866109b0366004614b8e565b61393b565b61054a613ad4565b610486613c4c565b61054a613caa565b61049b6109db366004614b8e565b600e6020526000908152604090205481565b61049b613de6565b61049b601b5481565b600f6020528160005260406000208181548110610a1a57600080fd5b6000918252602090912001546001600160a01b03169150829050565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a008054600160401b810460ff16159067ffffffffffffffff16600081158015610a7c5750825b905060008267ffffffffffffffff166001148015610a995750303b155b905081158015610aa7575080155b15610ac55760405163f92ee8a960e01b815260040160405180910390fd5b845467ffffffffffffffff191660011785558315610aef57845460ff60401b1916600160401b1785555b610aff6104b76020880188614b8e565b610b07613c4c565b610b176040870160208801614b8e565b600380546001600160a01b039290921661010002610100600160a81b0319909216919091179055610b4e6060870160408801614b8e565b602180546001600160a01b0319166001600160a01b0392909216919091179055610b7e6080870160608801614b8e565b600480546001600160a01b0319166001600160a01b0392909216919091179055610160860135602255608086013560065560a086013560155560c086013560165560e0860135601755610100860135601e55610be261014087016101208801614b8e565b601f80546001600160a01b0319166001600160a01b0392831617905561014087013560209081556004549091169063095ea7b390610c269060408a01908a01614b8e565b6040516001600160e01b031960e084901b1681526001600160a01b03909116600482015260001960248201526044016020604051808303816000875af1158015610c74573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c989190614c32565b5060016005558315610ce457845460ff60401b19168555604051600181527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15b505050505050565b600654600090610cfd600184614c65565b610d079190614c78565b600754610d149190614c8f565b92915050565b6001600160a01b038116610d755760405162461bcd60e51b815260206004820152601960248201527f4f776e657220616464726573732063616e6e6f7420626520300000000000000060448201526064015b60405180910390fd5b600154600160a01b900460ff1615610de15760405162461bcd60e51b815260206004820152602960248201527f416c726561647920696e697469616c697a65642c20757365206e6f6d696e617460448201526832a732bba7bbb732b960b91b6064820152608401610d6c565b6001805460ff60a01b1916600160a01b179055600080546001600160a01b0383166001600160a01b0319909116811782556040805192835260208301919091527fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c91015b60405180910390a150565b610e58613ee2565b600180546001600160a01b0319166001600160a01b0383169081179091556040519081527f906a1c6bd7e3091ea86693dd029a831c19049ce77f1dce2ce0bab1cacbabce2290602001610e45565b610eae613ee2565b80610ebe57610ebb613f56565b50565b610ebb613fb0565b600160026000828254610ed99190614c8f565b9091555050600254610ee9613ff9565b601c5460ff16610f3b5760405162461bcd60e51b815260206004820152601a60248201527f526f756e6420636c6f73696e67206e6f742070726570617265640000000000006044820152606401610d6c565b600554600090815260096020526040902054601d5410610f9d5760405162461bcd60e51b815260206004820152601b60248201527f416c6c20757365727320616c72656164792070726f63657373656400000000006044820152606401610d6c565b60008211610fbd5760405162461bcd60e51b8152600401610d6c90614ca2565b60215460405163bf40fac160e01b815260206004820152600d60248201526c5374616b696e675468616c657360981b60448201526000916001600160a01b03169063bf40fac190606401602060405180830381865afa158015611024573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110489190614ce5565b600554600090815260086020526040812054601d549293506001600160a01b031691611075908690614c8f565b6005546000908152600960205260409020549091508111156110a557506005546000908152600960205260409020545b6004805460035460408051632bac3c5960e21b815290516000946001600160a01b03948516946101009094049093169263aeb0f164928082019260209290918290030181865afa1580156110fd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111219190614ce5565b6001600160a01b03161490506000601d5490505b8281101561153457600554600090815260096020526040812080548390811061116057611160614d02565b6000918252602080832090910154600554835260138252604080842054600b84528185206001600160a01b0390931680865292909352832054909350670de0b6b3a7640000916111af91614c78565b6111b99190614d18565b6001600160a01b0383166000908152600d602052604090205490915060ff161580156111f5575060055460009081526013602052604090205415155b156112f05780600b6000600554600161120e9190614c8f565b81526020019081526020016000206000846001600160a01b03166001600160a01b031681526020019081526020016000205461124a9190614c8f565b600b6000600554600161125d9190614c8f565b81526020019081526020016000206000846001600160a01b03166001600160a01b03168152602001908152602001600020819055506009600060055460016112a59190614c8f565b8152602080820192909252604001600090812080546001810182559082529190200180546001600160a01b0319166001600160a01b0384161790556112eb87828661402a565b61150e565b6001600160a01b0382166000908152600e602052604090205415611466576001600160a01b0382166000908152600e6020526040812054670de0b6b3a76400009061133b9084614c78565b6113459190614d18565b600454909150611360906001600160a01b0316888584614149565b604080516001600160a01b0385168152602081018390527fd8138f8a3f377c5259ca548e70e4c2de94f129f5a11036a15b69513cba2b426a910160405180910390a16001600160a01b0383166000908152600d60209081526040808320805460ff19169055600e9091528120819055600554600991906113e1906001614c8f565b8152602080820192909252604001600090812080546001810182559082529190200180546001600160a01b0319166001600160a01b0385161790556114268183614c65565b600b600060055460016114399190614c8f565b8152602080820192909252604090810160009081206001600160a01b03881682529092529020555061150e565b6000600b6000600554600161147b9190614c8f565b8152602080820192909252604090810160009081206001600160a01b038088168352935220919091556004546114b49116878484614149565b6001600160a01b0382166000818152600d6020908152604091829020805460ff19169055815192835282018390527fd8138f8a3f377c5259ca548e70e4c2de94f129f5a11036a15b69513cba2b426a910160405180910390a15b601d5461151c906001614c8f565b601d555081905061152c81614d3a565b915050611135565b5060055460408051918252602082018890527f2e692c8fcabe33ba22535323e79dcb54ef22dccdb8e4ebdd9f2a7ffb1a28856c910160405180910390a15050505060025481146115965760405162461bcd60e51b8152600401610d6c90614d53565b5050565b6115a2613ee2565b60178190556040518181527fe7c2c09f66c8b970b4a99250f4d0844e1496b9d51d4760a17b0134ddd52023e190602001610e45565b6001600260008282546115ea9190614c8f565b9091555050600254600454600160a01b900460ff1661161b5760405162461bcd60e51b8152600401610d6c90614d8a565b336000908152600d602052604090205460ff161561167b5760405162461bcd60e51b815260206004820152601c60248201527f5769746864726177616c20616c726561647920726571756573746564000000006044820152606401610d6c565b6005546000908152600b602090815260408083203384529091529020546116da5760405162461bcd60e51b81526020600482015260136024820152724e6f7468696e6720746f20776974686472617760681b6044820152606401610d6c565b600b600060055460016116ed9190614c8f565b815260208082019290925260409081016000908120338252909252902054156117285760405162461bcd60e51b8152600401610d6c90614db8565b611730613ff9565b601c5460ff16156117535760405162461bcd60e51b8152600401610d6c90614e0e565b6005546000908152600b60209081526040808320338452909152902054601b5411156117b4576005546000908152600b60209081526040808320338452909152812054601b8054919290916117a9908490614c65565b909155506117ba9050565b6000601b555b60016018546117c99190614c65565b601855336000818152600d6020908152604091829020805460ff1916600117905590519182527fe5892ff2a8b08efb903ffbba1f0514c1d3e22eea34dd5b89cf30aabce03dde5a910160405180910390a16002548114610ebb5760405162461bcd60e51b8152600401610d6c90614d53565b60096020528160005260406000208181548110610a1a57600080fd5b61185f613ee2565b601e8190556040518181527fc117ccf765672707ebe3c1606037488c1e27dc1f42b5266e3d6b496db7d4209e90602001610e45565b6001600260008282546118a79190614c8f565b90915550506002546118b7613ff9565b601c5460ff16156118da5760405162461bcd60e51b8152600401610d6c90614e0e565b600082116118fa5760405162461bcd60e51b8152600401610d6c90614ca2565b600080805b6005546000908152600f6020526040902054811015611bda57828514611bda576005546000908152600f6020526040812080548390811061194257611942614d02565b600091825260208083209091015460055483526011825260408084206001600160a01b039092168085529190925291205490915060ff16611bc757809250826001600160a01b031663e74d3c476040518163ffffffff1660e01b8152600401602060405180830381865afa1580156119be573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119e29190614c32565b8015611a4d5750826001600160a01b0316633356a35a6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611a27573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a4b9190614c32565b155b15611ab85760035460405163066aa16f60e21b81526001600160a01b038381166004830152610100909204909116906319aa85bc90602401600060405180830381600087803b158015611a9f57600080fd5b505af1158015611ab3573d6000803e3d6000fd5b505050505b826001600160a01b0316633356a35a6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611af6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b1a9190614c32565b80611b825750826001600160a01b0316633f6fa6556040518163ffffffff1660e01b8152600401602060405180830381865afa158015611b5e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b829190614c32565b15611bc75760055460009081526011602090815260408083206001600160a01b03851684529091529020805460ff19166001908117909155611bc49085614c8f565b93505b5080611bd281614d3a565b9150506118ff565b50505060025481146115965760405162461bcd60e51b8152600401610d6c90614d53565b611c06613ee2565b6001600160a01b038116611c2c5760405162461bcd60e51b8152600401610d6c90614e55565b601a80546001600160a01b0319166001600160a01b0383169081179091556040519081527fa65a5aa86bb6f8e75752296da3ebda45474c8a302fc640c3b62868793862a03390602001610e45565b601c5460ff1615611c9d5760405162461bcd60e51b8152600401610d6c90614e0e565b60008060005b6005546000908152600f6020526040902054811015611f67576005546000908152600f60205260409020805482908110611cdf57611cdf614d02565b600091825260208083209091015460055483526011825260408084206001600160a01b039092168085529190925291205490925060ff16611f5557819250826001600160a01b031663e74d3c476040518163ffffffff1660e01b8152600401602060405180830381865afa158015611d5b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d7f9190614c32565b8015611dea5750826001600160a01b0316633356a35a6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611dc4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611de89190614c32565b155b15611e555760035460405163066aa16f60e21b81526001600160a01b038481166004830152610100909204909116906319aa85bc90602401600060405180830381600087803b158015611e3c57600080fd5b505af1158015611e50573d6000803e3d6000fd5b505050505b826001600160a01b0316633356a35a6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611e93573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611eb79190614c32565b80611f1f5750826001600160a01b0316633f6fa6556040518163ffffffff1660e01b8152600401602060405180830381865afa158015611efb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f1f9190614c32565b15611f555760055460009081526011602090815260408083206001600160a01b03861684529091529020805460ff191660011790555b80611f5f81614d3a565b915050611ca3565b505050565b600160026000828254611f7f9190614c8f565b9091555050600254611f8f613ff9565b60035461010090046001600160a01b03163314611fbe5760405162461bcd60e51b8152600401610d6c90614e8c565b601c5460ff1615611fe15760405162461bcd60e51b8152600401610d6c90614e0e565b600454600160a01b900460ff1661200a5760405162461bcd60e51b8152600401610d6c90614d8a565b6000821161205a5760405162461bcd60e51b815260206004820152601960248201527f43616e277420636f6d6d69742061207a65726f207472616465000000000000006044820152606401610d6c565b6000612065846132bc565b6001600160a01b038516600090815260126020526040812082905590915061208c826141a3565b905060055482036121e3576003546004546120bb916001600160a01b0391821691849161010090041687614149565b601e546005546000908152600c6020526040902054670de0b6b3a7640000916120e391614c78565b6120ed9190614d18565b6005546000908152600c60205260409020546121099190614c65565b600480546040516370a0823160e01b81526001600160a01b03858116938201939093529116906370a0823190602401602060405180830381865afa158015612155573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121799190614ed2565b10156121de5760405162461bcd60e51b815260206004820152602e60248201527f416d6f756e74206578636565647320617661696c61626c65207574696c697a6160448201526d1d1a5bdb88199bdc881c9bdd5b9960921b6064820152608401610d6c565b612321565b6005548211156122d857600480546040516370a0823160e01b81526001600160a01b0384811693820193909352600092909116906370a0823190602401602060405180830381865afa15801561223d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122619190614ed2565b90508481106122935760035460045461228e916001600160a01b0391821691859161010090041688614149565b6122d2565b600061229f8287614c65565b90506122ac818486614381565b6003546004546122d0916001600160a01b0391821691869161010090041689614149565b505b50612321565b816001146123185760405162461bcd60e51b815260206004820152600d60248201526c125b9d985b1a59081c9bdd5b99609a1b6044820152606401610d6c565b61232184614496565b506000818152600f602090815260408083208054600180820183559185528385200180546001600160a01b0319166001600160a01b038a1690811790915594845260108352818420948452939091529020805460ff191690911790556002548114611f675760405162461bcd60e51b8152600401610d6c90614d53565b6123a6613ee2565b6001600160a01b0381166123cc5760405162461bcd60e51b8152600401610d6c90614e55565b601980546001600160a01b0319166001600160a01b0383169081179091556040519081527faaf6f0738515c3cf390f1b3faec649d2dacb169d024089afc43bbe2fe66cd2d890602001610e45565b612422613ee2565b600454600160a01b900460ff161561248a5760405162461bcd60e51b815260206004820152602560248201527f43616e2774206368616e676520726f756e64206c656e677468206166746572206044820152641cdd185c9d60da1b6064820152608401610d6c565b60068190556040518181527f1d1fb7111c3779798bd4aefb2daea07ee8257a13c7eaceba89b4b1ccd405050d90602001610e45565b6000600860006124ce846132bc565b81526020810191909152604001600020546001600160a01b031692915050565b6001546001600160a01b031633146125665760405162461bcd60e51b815260206004820152603560248201527f596f75206d757374206265206e6f6d696e61746564206265666f726520796f7560448201527402063616e20616363657074206f776e65727368697605c1b6064820152608401610d6c565b600054600154604080516001600160a01b0393841681529290911660208301527fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c910160405180910390a160018054600080546001600160a01b03199081166001600160a01b03841617909155169055565b6125e0613ee2565b601f80546001600160a01b0319166001600160a01b0384169081179091556020828155604080519283529082018390527fa1a8623472ca4e2879372be60dfd1ff0675778e49f7379eedd98ca57cf36b21a910160405180910390a15050565b6001600260008282546126529190614c8f565b9091555050600254612662613ff9565b601c5460ff16156126855760405162461bcd60e51b8152600401610d6c90614e0e565b61268d613caa565b6126d95760405162461bcd60e51b815260206004820152601960248201527f43616e277420636c6f73652063757272656e7420726f756e64000000000000006044820152606401610d6c565b6126e1611c7a565b600554600090815260086020526040808220546004805492516370a0823160e01b81526001600160a01b0392831691810182905290939291909116906370a0823190602401602060405180830381865afa158015612743573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127679190614ed2565b6005546000908152600c602052604090205490915081111561283657602080546005546000908152600c9092526040822054670de0b6b3a764000091906127ae9085614c65565b6127b89190614c78565b6127c29190614d18565b601f546004549192506127e4916001600160a01b039081169186911684614149565b6127ee8183614c65565b91507fb8379d05082aa2dd32963972d72cc2d46257811133341855b63bb2fddda6ca3e6020548260405161282c929190918252602082015260400190565b60405180910390a1505b6005546000908152600c60205260408120549003612868576005546000908152601360205260409020600190556128a9565b6005546000908152600c602052604090205461288c670de0b6b3a764000083614c78565b6128969190614d18565b6005546000908152601360205260409020555b601c805460ff191660011790556005546040517fa224cce482b24082d1d3128437615f7f5ce87b97453a11114846ea442a100272916128eb9190815260200190565b60405180910390a150506002548114610ebb5760405162461bcd60e51b8152600401610d6c90614d53565b6001600260008282546129299190614c8f565b9091555050600254600454600160a01b900460ff1661295a5760405162461bcd60e51b8152600401610d6c90614d8a565b336000908152600d602052604090205460ff16156129ba5760405162461bcd60e51b815260206004820152601c60248201527f5769746864726177616c20616c726561647920726571756573746564000000006044820152606401610d6c565b6005546000908152600b60209081526040808320338452909152902054612a195760405162461bcd60e51b81526020600482015260136024820152724e6f7468696e6720746f20776974686472617760681b6044820152606401610d6c565b600b60006005546001612a2c9190614c8f565b81526020808201929092526040908101600090812033825290925290205415612a675760405162461bcd60e51b8152600401610d6c90614db8565b612a6f613ff9565b601c5460ff1615612a925760405162461bcd60e51b8152600401610d6c90614e0e565b612aa4662386f26fc10000600a614c78565b8210158015612ac45750612ac0662386f26fc10000605a614c78565b8211155b612b1c5760405162461bcd60e51b815260206004820152602360248201527f53686172652068617320746f206265206265747765656e2031302520616e642060448201526239302560e81b6064820152608401610d6c565b6005546000908152600b60209081526040808320338452909152812054670de0b6b3a764000090612b4e908590614c78565b612b589190614d18565b905080601b541115612b815780601b6000828254612b769190614c65565b90915550612b879050565b6000601b555b336000818152600d60209081526040808320805460ff19166001179055600e82529182902086905590519182527fe5892ff2a8b08efb903ffbba1f0514c1d3e22eea34dd5b89cf30aabce03dde5a910160405180910390a15060025481146115965760405162461bcd60e51b8152600401610d6c90614d53565b336000908152600d6020526040902054819060ff1615612c735760405162461bcd60e51b815260206004820152602760248201527f5769746864726177616c206973207265717565737465642c2063616e6e6f742060448201526619195c1bdcda5d60ca1b6064820152608401610d6c565b60155481601b54612c849190614c8f565b1115612cdc5760405162461bcd60e51b815260206004820152602160248201527f4465706f73697420616d6f756e74206578636565647320414d4d204c502063616044820152600760fc1b6064820152608401610d6c565b6005546000908152600b60209081526040808320338452909152902054158015612d345750600b60006005546001612d149190614c8f565b815260208082019290925260409081016000908120338252909252902054155b15612d9557601654811015612d955760405162461bcd60e51b815260206004820152602160248201527f416d6f756e74206c657373207468616e206d696e4465706f736974416d6f756e6044820152601d60fa1b6064820152608401610d6c565b600160026000828254612da89190614c8f565b9091555050600254612db8613ff9565b601c5460ff1615612ddb5760405162461bcd60e51b8152600401610d6c90614e0e565b612de4836145df565b6002548114611f675760405162461bcd60e51b8152600401610d6c90614d53565b612e0d613ee2565b600454600160a01b900460ff1615612e605760405162461bcd60e51b81526020600482015260166024820152751314081a185cc8185b1c9958591e481cdd185c9d195960521b6044820152606401610d6c565b6002600052600c6020527f5d6016397a73f5e079297ac5a36fef17b4d9c3831618e63ab105738020ddd72054612ed85760405162461bcd60e51b815260206004820152601d60248201527f43616e206e6f7420737461727420776974682030206465706f736974730000006044820152606401610d6c565b4260075560026005819055600090612eef906141a3565b9050806001600160a01b0316637d3de7ce600754612f0d6002610cec565b6040516001600160e01b031960e085901b16815260048101929092526024820152604401600060405180830381600087803b158015612f4b57600080fd5b505af1158015612f5f573d6000803e3d6000fd5b50506004805460ff60a01b1916600160a01b17905550506040517f960682678fca98f3ed131eaf165e59544bcd738e948f0b3c64f58fa9e1c65e6090600090a150565b612faa613ee2565b6001600160a01b038116612ff25760405162461bcd60e51b815260206004820152600f60248201526e496e76616c6964206164647265737360881b6044820152606401610d6c565b600154600160a81b900460ff16156130425760405162461bcd60e51b8152602060048201526013602482015272105b1c9958591e481d1c985b9cd9995c9c9959606a1b6044820152606401610d6c565b600080546001600160a01b0383166001600160a01b031990911681179091556001805460ff60a81b1916600160a81b1790556040805182815260208101929092527fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c9101610e45565b60008281526014602081815260408084205460138352818520548686529390925283205490916130da91614c78565b6130e49190614d18565b9392505050565b6130f3613ff9565b601c5460ff16156131165760405162461bcd60e51b8152600401610d6c90614e0e565b60035461010090046001600160a01b031633146131455760405162461bcd60e51b8152600401610d6c90614e8c565b6000613150836132bc565b90506000600182111561316b57613166826141a3565b613178565b6019546001600160a01b03165b60035460045491925061319e916001600160a01b03908116916101009004168386614149565b60008281526010602090815260408083206001600160a01b038816845290915290205460ff16156131f75760008281526011602090815260408083206001600160a01b03881684529091529020805460ff191660011790555b50505050565b6005546000908152600b602090815260408083206001600160a01b038516845290915281205415158061327457506000600b600060055460016132409190614c8f565b81526020019081526020016000206000846001600160a01b03166001600160a01b0316815260200190815260200160002054115b8015610d1457506001600160a01b0382166000908152600d602052604090205460ff161580610d145750506001600160a01b03166000908152600e6020526040902054151590565b6001600160a01b0381166000908152601260205260408120549081900361345557816000805b826001600160a01b03166362e5c8196040518163ffffffff1660e01b8152600401602060405180830381865afa158015613320573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906133449190614ed2565b8110156134515760405163b1283e7760e01b8152600481018290526001600160a01b0384169063b1283e779060240161012060405180830381865afa158015613391573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906133b59190614f0e565b5050600754939850505050851115925061343a9150505780600003613400576006546007546133e49084614c65565b6133ee9190614d18565b6133f9906002614c8f565b935061343f565b83600654600754846134129190614c65565b61341c9190614d18565b613427906002614c8f565b146134355760019350613451565b61343f565b600193505b8061344981614d3a565b9150506132e2565b5050505b919050565b613462613ee2565b60168190556040518181527f990717cc219e5348c1b88bb0ff530d804f0b6f54f3b03844a2bfbe4eb1e9c5d690602001610e45565b600654600090610cfd600284614c65565b6134b0613ee2565b60158190556040518181527f8c43aa02599ac8f8bab4724621ceea5e7a06b07bbbfaf3b7bd0386cbe481ea3c90602001610e45565b6001600260008282546134f89190614c8f565b9091555050600254613508613ff9565b601c5460ff1661355a5760405162461bcd60e51b815260206004820152601a60248201527f526f756e6420636c6f73696e67206e6f742070726570617265640000000000006044820152606401610d6c565b600554600090815260096020526040902054601d54146135bc5760405162461bcd60e51b815260206004820152601b60248201527f4e6f7420616c6c2075736572732070726f6365737365642079657400000000006044820152606401610d6c565b601c805460ff19169055600554600090815260086020908152604080832054600b83528184206019546001600160a01b0390811686529352922054911690156136b657600554600090815260136020908152604080832054600b83528184206019546001600160a01b03168552909252822054670de0b6b3a76400009161364291614c78565b61364c9190614d18565b60195460045491925061366e916001600160a01b039081169185911684614149565b601954604080516001600160a01b039092168252602082018390527fd8138f8a3f377c5259ca548e70e4c2de94f129f5a11036a15b69513cba2b426a910160405180910390a1505b6005546002036136e357600554600090815260136020908152604080832054601490925290912055613746565b600554600081815260136020526040812054670de0b6b3a764000092909160149161371090600190614c65565b8152602001908152602001600020546137299190614c78565b6137339190614d18565b6005546000908152601460205260409020555b60056000815461375590614d3a565b90915550600480546040516370a0823160e01b81526001600160a01b03848116938201939093529116906370a0823190602401602060405180830381865afa1580156137a5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906137c99190614ed2565b6005546000908152600c6020526040812080549091906137ea908490614c8f565b90915550506005546000818152600b602090815260408083206019546001600160a01b03168452825280832054938352600c90915290205461382c9190614c65565b601b5560055460009061383e906141a3565b600480546040516370a0823160e01b81526001600160a01b03808716938201939093529293506138cc928592859216906370a0823190602401602060405180830381865afa158015613894573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906138b89190614ed2565b6004546001600160a01b0316929190614149565b6000601d556005547fc67dda8e11f1aa941c7e74466b1859a07a32f46aaf641d29b83be348424d93cd9061390290600190614c65565b6013600060016005546139159190614c65565b8152602001908152602001600020546040516128eb929190918252602082015260400190565b613943613ee2565b6001600160a01b0381166139695760405162461bcd60e51b8152600401610d6c90614e55565b60035461010090046001600160a01b031615613a01576004805460035460405163095ea7b360e01b81526001600160a01b0361010090920482169381019390935260006024840152169063095ea7b3906044016020604051808303816000875af11580156139db573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906139ff9190614c32565b505b60038054610100600160a81b0319166101006001600160a01b03848116820292909217928390556004805460405163095ea7b360e01b815292909404831690820152600019602482015291169063095ea7b3906044016020604051808303816000875af1158015613a76573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613a9a9190614c32565b506040516001600160a01b03821681527f576297e5fcc8cd907ee80b240284865eb3d821bdc5232e6ee9e4d78a12531c0990602001610e45565b60008080805b6005546000908152600f6020526040902054811015613c42576005546000908152600f60205260409020805482908110613b1657613b16614d02565b600091825260208083209091015460055483526011825260408084206001600160a01b039092168085529190925291205490925060ff16613c3057819250826001600160a01b031663e74d3c476040518163ffffffff1660e01b8152600401602060405180830381865afa158015613b92573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613bb69190614c32565b8015613c215750826001600160a01b0316633356a35a6040518163ffffffff1660e01b8152600401602060405180830381865afa158015613bfb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613c1f9190614c32565b155b15613c30576001935050505090565b80613c3a81614d3a565b915050613ada565b5060009250505090565b60035460ff1615613c955760405162461bcd60e51b8152602060048201526013602482015272105b1c9958591e481a5b9a5d1a585b1a5e9959606a1b6044820152606401610d6c565b6003805460ff19166001908117909155600255565b600454600090600160a01b900460ff161580613ccf5750613ccc600554610cec565b42105b15613cda5750600090565b60008060005b6005546000908152600f6020526040902054811015613ddc576005546000908152600f60205260409020805482908110613d1c57613d1c614d02565b600091825260208083209091015460055483526011825260408084206001600160a01b039092168085529190925291205490925060ff16613dca57819250826001600160a01b031663b0c56f056040518163ffffffff1660e01b8152600401602060405180830381865afa158015613d98573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613dbc9190614c32565b613dca576000935050505090565b80613dd481614d3a565b915050613ce0565b5060019250505090565b60215460405163bf40fac160e01b8152602060048201526009602482015268141c9a58d95199595960ba1b60448201526000916001600160a01b03169063bf40fac190606401602060405180830381865afa158015613e49573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613e6d9190614ce5565b6001600160a01b031663ac82f6086022546040518263ffffffff1660e01b8152600401613e9c91815260200190565b602060405180830381865afa158015613eb9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613edd9190614ed2565b905090565b6000546001600160a01b03163314613f545760405162461bcd60e51b815260206004820152602f60248201527f4f6e6c792074686520636f6e7472616374206f776e6572206d6179207065726660448201526e37b936903a3434b99030b1ba34b7b760891b6064820152608401610d6c565b565b613f5e61491e565b600080516020614ffa833981519152805460ff191681557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b039091168152602001610e45565b613fb8613ff9565b600080516020614ffa833981519152805460ff191660011781557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a25833613f98565b600080516020614ffa8339815191525460ff1615613f545760405163d93c066560e01b815260040160405180910390fd5b6001600160a01b03831615611f67576000600460009054906101000a90046001600160a01b03166001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa15801561408e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906140b29190614ed2565b9050816140e157670de0b6b3a76400006140ca613de6565b6140d49085614c78565b6140de9190614d18565b92505b60405163a2dd835f60e01b81526001600160a01b0385169063a2dd835f9061411190339087908690600401614fa9565b600060405180830381600087803b15801561412b57600080fd5b505af115801561413f573d6000803e3d6000fd5b5050505050505050565b604080516001600160a01b0385811660248301528416604482015260648082018490528251808303909101815260849091019091526020810180516001600160e01b03166323b872dd60e01b1790526131f790859061494e565b6000818152600860205260409020546001600160a01b03168061345557816001036141fd575060198054600083815260086020526040902080546001600160a01b0319166001600160a01b03928316179055905416919050565b601a546001600160a01b03166142555760405162461bcd60e51b815260206004820152601d60248201527f526f756e6420706f6f6c206d6173746572636f7079206e6f74207365740000006044820152606401610d6c565b601a5460009061426d906001600160a01b03166149b1565b6004549091506001600160a01b038083169163d13f90b49130911686614297610496600183614c65565b6142a089610cec565b6040516001600160e01b031960e088901b1681526001600160a01b03958616600482015294909316602485015260448401919091526064830152608482015260a401600060405180830381600087803b1580156142fc57600080fd5b505af1158015614310573d6000803e3d6000fd5b50505060008481526008602090815260409182902080546001600160a01b0319166001600160a01b03861690811790915582518781529182015292935083927f24c1b21b902a85b5039d7d72427d9376657229eea77880ec9e62031dc950f6ba92500160405180910390a150919050565b6019546001600160a01b03166143ce5760405162461bcd60e51b8152602060048201526012602482015271111959985d5b1d081314081b9bdd081cd95d60721b6044820152606401610d6c565b6019546004546143ec916001600160a01b0391821691168486614149565b6000818152600b602090815260408083206019546001600160a01b0316845290915281208054859290614420908490614c8f565b90915550506000818152600c602052604081208054859290614443908490614c8f565b90915550506019546040517f73a19dd210f1a7f902193214c0ee91dd35ee5b4d920cba8d519eca65a7b488ca91614489916001600160a01b039091169086908590614fa9565b60405180910390a1505050565b6019546001600160a01b03166144e35760405162461bcd60e51b8152602060048201526012602482015271111959985d5b1d081314081b9bdd081cd95d60721b6044820152606401610d6c565b60195460035460045461450d926001600160a01b0391821692908216916101009091041684614149565b6019546001600160a01b031660009081527f72c6bfb7988af3a1efa6568f02a999bc52252641c659d85961ca3d372b57d5cf602052604081208054839290614556908490614c8f565b909155505060016000908152600c6020527fd421a5181c571bba3f01190c922c3b2a896fc1d84e86c9f17ac10e67ebef8b5c8054839290614598908490614c8f565b90915550506019546040517f73a19dd210f1a7f902193214c0ee91dd35ee5b4d920cba8d519eca65a7b488ca91610e45916001600160a01b03909116908490600190614fa9565b600060055460016145f09190614c8f565b905060006145fd826141a3565b600454909150614618906001600160a01b0316338386614149565b6019546001600160a01b0316330361467e5760405162461bcd60e51b8152602060048201526024808201527f43616e2774206465706f736974206469726563746c792061732064656661756c604482015263074204c560e41b6064820152608401610d6c565b6005546000908152600b602090815260408083203384529091529020541580156146bf57506000828152600b60209081526040808320338452909152902054155b1561475857601754601854106147175760405162461bcd60e51b815260206004820152601b60248201527f4d617820616d6f756e74206f66207573657273207265616368656400000000006044820152606401610d6c565b60008281526009602090815260408220805460018181018355918452919092200180546001600160a01b0319163317905560185461475491614c8f565b6018555b6000828152600b6020908152604080832033845290915281208054859290614781908490614c8f565b90915550506000828152600c6020526040812080548592906147a4908490614c8f565b9250508190555082601b60008282546147bd9190614c8f565b909155505060215460405163bf40fac160e01b815260206004820152600d60248201526c5374616b696e675468616c657360981b60448201526000916001600160a01b03169063bf40fac190606401602060405180830381865afa158015614829573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061484d9190614ce5565b6004805460035460408051632bac3c5960e21b815290519495506148db9486948a946001600160a01b03908116946101009004169263aeb0f16492818301926020928290030181865afa1580156148a8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906148cc9190614ce5565b6001600160a01b03161461402a565b7f73a19dd210f1a7f902193214c0ee91dd35ee5b4d920cba8d519eca65a7b488ca338560055460405161491093929190614fa9565b60405180910390a150505050565b600080516020614ffa8339815191525460ff16613f5457604051638dfc202b60e01b815260040160405180910390fd5b60006149636001600160a01b03841683614a1e565b905080516000141580156149885750808060200190518101906149869190614c32565b155b15611f6757604051635274afe760e01b81526001600160a01b0384166004820152602401610d6c565b6000763d602d80600a3d3981f3363d3d373d3d3d363d730000008260601b60e81c176000526e5af43d82803e903d91602b57fd5bf38260781b17602052603760096000f090506001600160a01b038116613455576040516330be1a3d60e21b815260040160405180910390fd5b60606130e48383600084600080856001600160a01b03168486604051614a449190614fca565b60006040518083038185875af1925050503d8060008114614a81576040519150601f19603f3d011682016040523d82523d6000602084013e614a86565b606091505b5091509150614a96868383614aa0565b9695505050505050565b606082614ab557614ab082614afc565b6130e4565b8151158015614acc57506001600160a01b0384163b155b15614af557604051639996b31560e01b81526001600160a01b0385166004820152602401610d6c565b50806130e4565b805115614b0c5780518082602001fd5b604051630a12f52160e11b815260040160405180910390fd5b60008060408385031215614b3857600080fd5b50508035926020909101359150565b60006101808284031215614b5a57600080fd5b50919050565b600060208284031215614b7257600080fd5b5035919050565b6001600160a01b0381168114610ebb57600080fd5b600060208284031215614ba057600080fd5b81356130e481614b79565b8015158114610ebb57600080fd5b600060208284031215614bcb57600080fd5b81356130e481614bab565b60008060408385031215614be957600080fd5b823591506020830135614bfb81614b79565b809150509250929050565b60008060408385031215614c1957600080fd5b8235614c2481614b79565b946020939093013593505050565b600060208284031215614c4457600080fd5b81516130e481614bab565b634e487b7160e01b600052601160045260246000fd5b81810381811115610d1457610d14614c4f565b8082028115828204841417610d1457610d14614c4f565b80820180821115610d1457610d14614c4f565b60208082526023908201527f42617463682073697a652068617320746f20626520677265617465722074686160408201526206e20360ec1b606082015260800190565b600060208284031215614cf757600080fd5b81516130e481614b79565b634e487b7160e01b600052603260045260246000fd5b600082614d3557634e487b7160e01b600052601260045260246000fd5b500490565b600060018201614d4c57614d4c614c4f565b5060010190565b6020808252601f908201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604082015260600190565b602080825260149082015273141bdbdb081a185cc81b9bdd081cdd185c9d195960621b604082015260600190565b60208082526036908201527f43616e277420776974686472617720617320796f7520616c72656164792064656040820152751c1bdcda5d195908199bdc881b995e1d081c9bdd5b9960521b606082015260800190565b60208082526027908201527f4e6f7420616c6c6f77656420647572696e6720726f756e64436c6f73696e67506040820152661c995c185c995960ca1b606082015260800190565b6020808252601b908201527f43616e206e6f74207365742061207a65726f2061646472657373210000000000604082015260600190565b60208082526026908201527f4f6e6c792074686520414d4d206d617920706572666f726d207468657365206d6040820152656574686f647360d01b606082015260800190565b600060208284031215614ee457600080fd5b5051919050565b805161ffff8116811461345557600080fd5b805160ff8116811461345557600080fd5b60008060008060008060008060006101208a8c031215614f2d57600080fd5b89519850614f3d60208b01614eeb565b9750614f4b60408b01614eeb565b965060608a01519550614f6060808b01614efd565b945060a08a01518060020b8114614f7657600080fd5b9350614f8460c08b01614eeb565b9250614f9260e08b01614efd565b91506101008a015190509295985092959850929598565b6001600160a01b039390931683526020830191909152604082015260600190565b6000825160005b81811015614feb5760208186018101518583015201614fd1565b50600092019182525091905056fecd5ed15c6e187e77e9aee88184c21f4f2182ab5827cb3b7e07fbedcd63f03300a2646970667358221220c2e3ea8567cd831da8b7e00eef882baa85b37ab55c360eec6a5ca19331ebbe6a64736f6c63430008140033
Loading...
Loading
Loading...
Loading
Loading...
Loading
Loading...
Loading
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.