Source Code
Overview
ETH Balance
0 ETH
ETH Value
$0.00
Cross-Chain Transactions
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 100 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 "../AMM/Ticket.sol";
import "../../interfaces/ISportsAMMV2Manager.sol";
import "../../interfaces/ISportsAMMV2.sol";
import "../../interfaces/ISportsAMMV2RiskManager.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;
require(params._utilizationRate <= 1e18, "Utilization rate can't exceed 100%");
utilizationRate = params._utilizationRate;
safeBox = params._safeBox;
require(params._safeBoxImpact <= 1e18, "Safe Box impact can't exceed 100%");
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;
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);
// if this is a past round, but not the default one, then we send the funds to the current round
if (ticketRound > 1 && ticketRound < round) {
ticketRound = round;
}
if (_amount > 0) {
address liquidityPoolRound = ticketRound <= 1 ? defaultLiquidityProvider : _getOrCreateRoundPool(ticketRound);
collateral.safeTransferFrom(address(sportsAMM), liquidityPoolRound, _amount);
}
if (isTradingTicketInARound[ticketRound][_ticket]) {
ticketAlreadyExercisedInRound[ticketRound][_ticket] = true;
}
}
/// @notice migrate ticket to next round
/// @param _ticket ticket to migrate
/// @param _newRound new round (0 for next round)
/// @param _ticketIndexInRound index of ticket in round (use 0 to perform automatic lookup through the round array)
function migrateTicketToAnotherRound(
address _ticket,
uint _newRound,
uint _ticketIndexInRound
) external onlyWhitelistedAddresses(msg.sender) roundClosingNotPrepared {
uint ticketRound = getTicketRound(_ticket);
require(ticketRound == round, "TicketNotInCurrentRound");
_migrateTicketToNewRound(_ticket, _newRound == 0 ? round + 1 : _newRound, _ticketIndexInRound);
}
/// @notice migrate batch of tickets to another round
/// @param _tickets batch of tickets to migrate
/// @param _newRound new round (0 for next round)
/// @param _ticketsIndexInRound index of tickets in round (use 0 to perform automatic lookup through the round array)
function migrateBatchOfTicketsToAnotherRound(
address[] memory _tickets,
uint _newRound,
uint[] memory _ticketsIndexInRound
) external onlyWhitelistedAddresses(msg.sender) roundClosingNotPrepared {
_newRound = _newRound == 0 ? round + 1 : _newRound;
if (_ticketsIndexInRound.length == 0) {
for (uint i; i < _tickets.length; i++) {
_migrateTicketToNewRound(_tickets[i], _newRound, 0);
}
} else {
require(_tickets.length == _ticketsIndexInRound.length, "ArraysLengthsMustMatch");
uint tradingTicketsLength = tradingTicketsPerRound[round].length;
for (uint i = 0; i < _tickets.length; i++) {
require(_ticketsIndexInRound[i] > 0, "TicketIndexMustBeGreaterThan0");
// check if the ticket index has not been migrated yet
if (_ticketsIndexInRound[i] < tradingTicketsLength - i) {
_migrateTicketToNewRound(_tickets[i], _newRound, _ticketsIndexInRound[i]);
} else {
// if the ticket index has been migrated, find the new index
// the new index is one of the ticket indexes in the _ticketsIndexInRound array
uint n;
bool found = false;
while (n < _ticketsIndexInRound.length) {
if (tradingTicketsPerRound[round][_ticketsIndexInRound[n]] == _tickets[i]) {
found = true;
break;
}
++n;
}
require(found, "TicketNotFoundInInputArray");
_migrateTicketToNewRound(_tickets[i], _newRound, _ticketsIndexInRound[n]);
}
}
}
}
/// @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 ether;
} 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");
address roundPool = roundPools[round];
uint endCursor = usersProcessedInRound + _batchSize;
if (endCursor > usersPerRound[round].length) {
endCursor = usersPerRound[round].length;
}
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);
} 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 whenNotPaused {
_exerciseTicketsReadyToBeExercised(round);
}
/// @notice iterate all tickets in the default round and exercise those ready to be exercised
function exerciseDefaultRoundTicketsReadyToBeExercised() external whenNotPaused {
_exerciseTicketsReadyToBeExercised(1);
}
/// @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 {
_exerciseTicketsReadyToBeExercisedBatch(_batchSize, round);
}
/// @notice iterate all default round tickets in the current round and exercise those ready to be exercised (batch)
/// @param _batchSize number of tickets to be processed
function exerciseDefaultRoundTicketsReadyToBeExercisedBatch(
uint _batchSize
) external nonReentrant whenNotPaused roundClosingNotPrepared {
_exerciseTicketsReadyToBeExercisedBatch(_batchSize, 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);
}
/// @notice return the price of the pool collateral
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 tickets in the current round and return true if at least one can be exercised
/// @return bool
function hasTicketsReadyToBeExercised() external view returns (bool) {
return _hasTicketsReadyToBeExercised(round);
}
/// @notice iterate all tickets in the default round and return true if at least one can be exercised
/// @return bool
function hasDefaultRoundTicketsReadyToBeExercised() external view returns (bool) {
return _hasTicketsReadyToBeExercised(1);
}
function _hasTicketsReadyToBeExercised(uint _round) internal 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;
uint16 sportId;
for (uint i = 0; i < ticket.numOfMarkets(); i++) {
(, sportId, , maturity, , , , , ) = ticket.markets(i);
bool isFuture = ISportsAMMV2RiskManager(addressManager.getAddress("SportsAMMV2RiskManager")).isSportIdFuture(
sportId
);
if (maturity > firstRoundStartTime && !isFuture) {
if (i == 0) {
ticketRound = (maturity - firstRoundStartTime) / roundLength + 2;
} else {
// if ticket is cross rounds, use the default round
if (((maturity - firstRoundStartTime) / roundLength + 2) != ticketRound) {
ticketRound = 1;
break;
}
}
} else {
ticketRound = 1;
break;
}
}
}
}
/// @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;
}
/// @notice Get the index of a ticket in a specific round's trading tickets array
/// @param _ticket The address of the ticket to find
/// @param _round The round number to search in
/// @param _startIndex The starting index to search from
/// @param _endIndex The ending index to search until
/// @return index The index of the ticket if found, otherwise returns _endIndex
/// @return found Whether the ticket was found
function getTicketIndexInTicketRound(
address _ticket,
uint _round,
uint _startIndex,
uint _endIndex
) external view returns (uint index, bool found) {
uint finalIndex = tradingTicketsPerRound[_round].length > _endIndex
? _endIndex
: tradingTicketsPerRound[_round].length;
for (uint i = _startIndex; i < finalIndex; ++i) {
if (tradingTicketsPerRound[_round][i] == _ticket) {
return (i, true);
}
}
return (_endIndex, false);
}
/* ========== INTERNAL FUNCTIONS ========== */
function _exerciseTicketsReadyToBeExercisedBatch(uint _batchSize, uint _roundNumber) internal {
require(_batchSize > 0, "Batch size has to be greater than 0");
uint count = 0;
for (uint i = 0; i < tradingTicketsPerRound[_roundNumber].length; i++) {
if (count == _batchSize) break;
if (_exerciseTicket(_roundNumber, tradingTicketsPerRound[_roundNumber][i])) {
count += 1;
}
}
}
function _exerciseTicketsReadyToBeExercised(uint _roundNumber) internal {
for (uint i = 0; i < tradingTicketsPerRound[_roundNumber].length; i++) {
_exerciseTicket(_roundNumber, tradingTicketsPerRound[_roundNumber][i]);
}
}
function _exerciseTicket(uint _roundNumber, address ticketAddress) internal returns (bool exercised) {
if (!ticketAlreadyExercisedInRound[_roundNumber][ticketAddress]) {
Ticket ticket = Ticket(ticketAddress);
bool isWinner = ticket.isUserTheWinner();
bool isSystemExercisable = false;
bool isSystem = false;
if (_roundNumber > 1) {
isSystem = ticket.isSystem();
}
// in case round needs to be closed, ensure all system bets are exercised too, as there could be money in those that needs to be returned to LP rounds
if (isSystem && block.timestamp > getRoundEndTime(_roundNumber)) {
isSystemExercisable = true;
}
if (ticket.isTicketExercisable() && (!isWinner || isSystemExercisable)) {
sportsAMM.handleTicketResolving(ticketAddress, ISportsAMMV2.TicketAction.Exercise);
}
if ((isWinner && !isSystem) || ticket.resolved()) {
ticketAlreadyExercisedInRound[_roundNumber][ticketAddress] = true;
exercised = true;
}
}
}
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,
address _forUser,
uint _amount,
bool _isDefaultCollateral
) internal {
if (address(stakingThales) != address(0)) {
uint collateralDecimals = ISportsAMMV2Manager(address(collateral)).decimals();
if (!_isDefaultCollateral) {
_amount = (_amount * getCollateralPrice()) / ONE;
}
stakingThales.updateVolumeAtAmountDecimals(_forUser, _amount, collateralDecimals);
}
}
function _migrateTicketToNewRound(address _ticket, uint _newRound, uint _ticketIndexInRound) internal {
require(_newRound > round || _newRound == 1, "RoundAlreadyClosed");
uint ticketRound = getTicketRound(_ticket);
require(ticketRound == round, "Ticket not in current round");
require(isTradingTicketInARound[ticketRound][_ticket], "TicketNotInCurrentRound");
require(!ticketAlreadyExercisedInRound[ticketRound][_ticket], "TicketAlreadyExercised");
require(!Ticket(_ticket).resolved(), "TicketAlreadyResolved");
// removing from old round
delete isTradingTicketInARound[ticketRound][_ticket];
_removeTicketFromRound(ticketRound, _ticket, _ticketIndexInRound);
// transfer funds from new pool to old pool
address oldLiquidityPoolRound = _getOrCreateRoundPool(ticketRound);
address newLiquidityPoolRound = _getOrCreateRoundPool(_newRound);
uint transferAmountNewToOld = collateral.balanceOf(_ticket) - Ticket(_ticket).buyInAmount();
uint newPoolBalance = collateral.balanceOf(newLiquidityPoolRound);
if (transferAmountNewToOld > newPoolBalance) {
uint differenceToLPAsDefault = transferAmountNewToOld - newPoolBalance;
_depositAsDefault(differenceToLPAsDefault, newLiquidityPoolRound, _newRound);
}
collateral.safeTransferFrom(newLiquidityPoolRound, oldLiquidityPoolRound, transferAmountNewToOld);
// adding ticket to new round
roundPerTicket[_ticket] = _newRound;
isTradingTicketInARound[_newRound][_ticket] = true;
tradingTicketsPerRound[_newRound].push(_ticket);
emit TicketMigratedToNextRound(_ticket, ticketRound, _newRound);
}
function _removeTicketFromRound(uint _round, address _ticket, uint _ticketIndexInRound) internal {
// if _ticketIndexInRound is 0, we need to find the ticket in the round and remove it
// lookup is performed by iterating through the array
bool found;
if (_ticketIndexInRound == 0) {
for (uint i; i < tradingTicketsPerRound[_round].length; ++i) {
if (tradingTicketsPerRound[_round][i] == _ticket) {
found = true;
_ticketIndexInRound = i;
break;
}
}
} else {
found =
_ticketIndexInRound < tradingTicketsPerRound[_round].length &&
tradingTicketsPerRound[_round][_ticketIndexInRound] == _ticket;
}
require(found, "TicketNotFound");
tradingTicketsPerRound[_round][_ticketIndexInRound] = tradingTicketsPerRound[_round][
tradingTicketsPerRound[_round].length - 1
];
tradingTicketsPerRound[_round].pop();
}
/* ========== 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 seconds
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 {
require(_utilizationRate <= 1e18, "Utilization rate can't exceed 100%");
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;
require(safeBoxImpact <= 1e18, "Safe Box impact can't exceed 100%");
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");
_;
}
modifier onlyWhitelistedAddresses(address sender) {
require(
sender == owner || sportsAMM.manager().isWhitelistedAddress(sender, ISportsAMMV2Manager.Role.MARKET_RESOLVING),
"Invalid sender"
);
_;
}
/* ========== 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);
event TicketMigratedToNextRound(address ticket, uint oldRound, uint newRound);
}// 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 decreaseAndTransferStakedThales(address account, uint amount) external;
function increaseAndTransferStakedThales(address account, uint amount) external;
function updateVolumeAtAmountDecimals(
address account,
uint amount,
uint decimals
) external;
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
// internal
import "../../interfaces/ISportsAMMV2Manager.sol";
import "../../interfaces/ISportsAMMV2.sol";
contract Ticket {
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;
uint24 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;
bool _isLive;
uint8 _systemBetDenominator;
bool _isSGP;
}
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;
bool public isLive;
mapping(uint => MarketData) public markets;
uint public finalPayout;
bool public isSystem;
uint8 public systemBetDenominator;
bool public isSGP;
bool public isMarkedAsLost;
/* ========== 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;
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;
isLive = params._isLive;
createdAt = block.timestamp;
systemBetDenominator = params._systemBetDenominator;
isSystem = systemBetDenominator > 0;
isSGP = params._isSGP;
}
/* ========== EXTERNAL READ FUNCTIONS ========== */
/// @notice checks if the user lost the ticket
/// @return isTicketLost true/false
function isTicketLost() public view returns (bool) {
if (isMarkedAsLost) {
return true;
} else {
uint lostMarketsCount = 0;
for (uint i = 0; i < numOfMarkets; i++) {
(bool isMarketResolved, bool isWinningMarketPosition) = sportsAMM
.resultManager()
.isMarketResolvedAndPositionWinning(
markets[i].gameId,
markets[i].typeId,
markets[i].playerId,
markets[i].line,
markets[i].position,
markets[i].combinedPositions
);
if (isMarketResolved && !isWinningMarketPosition) {
if (!isSystem) {
return true;
} else {
lostMarketsCount++;
if (lostMarketsCount > (numOfMarkets - systemBetDenominator)) {
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;
}
/// @notice return the payout for this ticket
/// @return systemBetPayout the payout for this ticket
function getSystemBetPayout() external view returns (uint systemBetPayout) {
systemBetPayout = _getSystemBetPayout();
}
/* ========== EXTERNAL WRITE FUNCTIONS ========== */
/// @notice exercise ticket
function exercise(address _exerciseCollateral) external onlyAMM notPaused returns (uint) {
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) {
if (isSGP) {
isCancelled = true;
break;
}
finalPayout = (finalPayout * markets[i].odd) / ONE;
} else {
isCancelled = false;
}
}
finalPayout = isCancelled ? buyInAmount : (isSystem ? _getSystemBetPayout() : finalPayout);
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 cancel the ticket
function cancel() external onlyAMM notPaused returns (uint) {
finalPayout = buyInAmount;
collateral.safeTransfer(address(ticketOwner), finalPayout);
uint balance = collateral.balanceOf(address(this));
if (balance != 0) {
collateral.safeTransfer(address(sportsAMM), balance);
}
_resolve(true, true);
return finalPayout;
}
/// @notice mark the ticket as lost
function markAsLost() external onlyAMM notPaused returns (uint) {
uint balance = collateral.balanceOf(address(this));
if (balance != 0) {
collateral.safeTransfer(address(sportsAMM), balance);
}
_resolve(false, false);
isMarkedAsLost = true;
return 0;
}
/// @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");
if (paused == _paused) return;
paused = _paused;
emit PauseUpdated(_paused);
}
/* ========== SYSTEM BET UTILS ========== */
function _getSystemBetPayout() internal view returns (uint systemBetPayout) {
if (isSystem) {
uint8[][] memory systemCombinations = sportsAMM.riskManager().generateCombinations(
uint8(numOfMarkets),
systemBetDenominator
);
uint totalCombinations = systemCombinations.length;
uint buyinPerCombination = ((buyInAmount * ONE) / totalCombinations) / ONE;
bool[] memory winningMarkets = new bool[](numOfMarkets);
bool[] memory cancelledMarkets = new bool[](numOfMarkets);
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 0;
}
winningMarkets[i] = sportsAMM.resultManager().isWinningMarketPosition(
markets[i].gameId,
markets[i].typeId,
markets[i].playerId,
markets[i].line,
markets[i].position,
markets[i].combinedPositions
);
cancelledMarkets[i] = sportsAMM.resultManager().isCancelledMarketPosition(
markets[i].gameId,
markets[i].typeId,
markets[i].playerId,
markets[i].line,
markets[i].position,
markets[i].combinedPositions
);
}
// Loop through each stored combination
for (uint i = 0; i < totalCombinations; i++) {
uint8[] memory currentCombination = systemCombinations[i];
uint combinationQuote = ONE;
for (uint j = 0; j < currentCombination.length; j++) {
uint8 marketIndex = currentCombination[j];
if (winningMarkets[marketIndex]) {
if (!cancelledMarkets[marketIndex]) {
combinationQuote = (combinationQuote * markets[marketIndex].odd) / ONE;
}
} else {
combinationQuote = 0;
break;
}
}
if (combinationQuote > 0) {
uint combinationPayout = (buyinPerCombination * ONE) / combinationQuote;
systemBetPayout += combinationPayout;
}
}
uint maxPayout = (buyInAmount * ONE) / totalQuote;
if (systemBetPayout > maxPayout) {
systemBetPayout = maxPayout;
}
}
}
/* ========== MODIFIERS ========== */
modifier onlyAMM() {
require(msg.sender == address(sportsAMM), "Only the AMM may perform these methods");
_;
}
modifier notPaused() {
require(!paused, "Market paused");
_;
}
/* ========== EVENTS ========== */
event Resolved(bool isUserTheWinner, bool cancelled);
event Expired(address beneficiary);
event PauseUpdated(bool paused);
}// 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 "./IProxyBetting.sol";
interface IFreeBetsHolder is IProxyBetting {
function confirmLiveTrade(bytes32 requestId, address _createdTicket, uint _buyInAmount, address _collateral) external;
function confirmSGPTrade(bytes32 requestId, address _createdTicket, uint _buyInAmount, address _collateral) external;
function balancePerUserAndCollateral(address user, address collateral) external view returns (uint);
function freeBetExpiration(address user, address collateral) external view returns (uint);
function freeBetExpirationUpgrade() external view returns (uint);
function freeBetExpirationPeriod() external view returns (uint);
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
interface IProxyBetting {
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 confirmTicketResolved(address _resolvedTicket) 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";
import "../interfaces/IFreeBetsHolder.sol";
import "../interfaces/IStakingThalesBettingProxy.sol";
interface ISportsAMMV2 {
enum TicketAction {
Exercise,
Cancel,
MarkLost
}
struct CombinedPosition {
uint16 typeId;
uint8 position;
int24 line;
}
struct TradeData {
bytes32 gameId;
uint16 sportId;
uint16 typeId;
uint maturity;
uint8 status;
int24 line;
uint24 playerId;
uint[] odds;
bytes32[] merkleProof;
uint8 position;
CombinedPosition[][] combinedPositions;
}
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 handleTicketResolving(address _ticket, ISportsAMMV2.TicketAction action) external;
function riskManager() external view returns (ISportsAMMV2RiskManager);
function freeBetsHolder() external view returns (IFreeBetsHolder);
function stakingThalesBettingProxy() external view returns (IStakingThalesBettingProxy);
function tradeLive(
TradeData[] calldata _tradeData,
uint _buyInAmount,
uint _expectedQuote,
address _recipient,
address _referrer,
address _collateral
) external returns (address _createdTicket);
function trade(
TradeData[] calldata _tradeData,
uint _buyInAmount,
uint _expectedQuote,
uint _additionalSlippage,
address _referrer,
address _collateral,
bool _isEth
) external returns (address _createdTicket);
function tradeSystemBet(
TradeData[] calldata _tradeData,
uint _buyInAmount,
uint _expectedQuote,
uint _additionalSlippage,
address _referrer,
address _collateral,
bool _isEth,
uint8 _systemBetDenominator
) external returns (address _createdTicket);
function tradeSGP(
ISportsAMMV2.TradeData[] calldata _tradeData,
uint _buyInAmount,
uint _approvedQuote,
address _recipient,
address _referrer,
address _collateral
) external returns (address _createdTicket);
function rootPerGame(bytes32 game) external view returns (bytes32);
function getRootsPerGames(bytes32[] calldata _games) external view returns (bytes32[] memory _roots);
function paused() external view returns (bool);
}// 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 sportsAMM() external view returns (address);
function getTicketsPerMarket(
uint _index,
uint _pageSize,
bytes32 _gameId,
uint _typeId,
uint _playerId
) external view returns (address[] memory);
function numOfTicketsPerMarket(bytes32 _gameId, uint _typeId, uint _playerId) external view returns (uint);
function addNewKnownTicket(ISportsAMMV2.TradeData[] memory _tradeData, address ticket, address user) external;
function resolveKnownTicket(address ticket, address ticketOwner) external;
function expireKnownTicket(address ticket, address ticketOwner) external;
function isSystemTicket(address _ticket) external view returns (bool);
function isSGPTicket(address _ticket) external view returns (bool);
}// 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,
uint24 _playerId,
int24 _line,
ISportsAMMV2.CombinedPosition[] memory combinedPositions
) external view returns (bool isResolved);
function getMarketPositionStatus(
bytes32 _gameId,
uint16 _typeId,
uint24 _playerId,
int24 _line,
uint _position,
ISportsAMMV2.CombinedPosition[] memory _combinedPositions
) external view returns (MarketPositionStatus status);
function isWinningMarketPosition(
bytes32 _gameId,
uint16 _typeId,
uint24 _playerId,
int24 _line,
uint _position,
ISportsAMMV2.CombinedPosition[] memory _combinedPositions
) external view returns (bool isWinning);
function isCancelledMarketPosition(
bytes32 _gameId,
uint16 _typeId,
uint24 _playerId,
int24 _line,
uint _position,
ISportsAMMV2.CombinedPosition[] memory _combinedPositions
) external view returns (bool isCancelled);
function getResultsPerMarket(
bytes32 _gameId,
uint16 _typeId,
uint24 _playerId
) external view returns (int24[] memory results);
function resultTypePerMarketType(uint _typeId) external view returns (uint8 marketType);
function isMarketResolvedAndPositionWinning(
bytes32 _gameId,
uint16 _typeId,
uint24 _playerId,
int24 _line,
uint _position,
ISportsAMMV2.CombinedPosition[] memory _combinedPositions
) external view returns (bool isResolved, bool isWinning);
function setResultsPerMarkets(
bytes32[] memory _gameIds,
uint16[] memory _typeIds,
uint24[] memory _playerIds,
int24[][] memory _results
) external;
function isGameCancelled(bytes32 _gameId) external view returns (bool);
function cancelGames(bytes32[] memory _gameIds) external;
function cancelMarkets(
bytes32[] memory _gameIds,
uint16[] memory _typeIds,
uint24[] memory _playerIds,
int24[] memory _lines
) external;
function cancelMarket(bytes32 _gameId, uint16 _typeId, uint24 _playerId, int24 _line) external;
function cancelGame(bytes32 _gameId) 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 maxAllowedSystemCombinations() 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,
uint24 _playerId,
int24 _line,
uint _maturity,
bool _isLive
) external view returns (uint cap);
function checkRisks(
ISportsAMMV2.TradeData[] memory _tradeData,
uint _buyInAmount,
bool _isLive,
uint8 _systemBetDenominator
) external view returns (ISportsAMMV2RiskManager.RiskStatus riskStatus, bool[] memory isMarketOutOfLiquidity);
function checkLimits(
uint _buyInAmount,
uint _totalQuote,
uint _payout,
uint _expectedPayout,
uint _additionalSlippage,
uint _ticketSize
) external view;
function spentOnGame(bytes32 _gameId) external view returns (uint);
function riskPerMarketTypeAndPosition(
bytes32 _gameId,
uint _typeId,
uint _playerId,
uint _position
) external view returns (int);
function checkAndUpdateRisks(
ISportsAMMV2.TradeData[] memory _tradeData,
uint _buyInAmount,
uint _payout,
bool _isLive,
uint8 _systemBetDenominator,
bool _isSGP
) external;
function verifyMerkleTree(ISportsAMMV2.TradeData memory _marketTradeData, bytes32 _rootPerGame) external pure;
function batchVerifyMerkleTree(
ISportsAMMV2.TradeData[] memory _marketTradeData,
bytes32[] memory _rootPerGame
) external pure;
function isSportIdFuture(uint16 _sportsId) external view returns (bool);
function sgpOnSportIdEnabled(uint16 _sportsId) external view returns (bool);
function getMaxSystemBetPayout(
ISportsAMMV2.TradeData[] memory _tradeData,
uint8 _systemBetDenominator,
uint _buyInAmount,
uint _addedPayoutPercentage
) external view returns (uint systemBetPayout, uint systemBetQuote);
function generateCombinations(uint8 n, uint8 k) external pure returns (uint8[][] memory);
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import "./IProxyBetting.sol";
interface IStakingThalesBettingProxy is IProxyBetting {
function preConfirmLiveTrade(bytes32 requestId, uint _buyInAmount) external;
function confirmLiveTrade(bytes32 requestId, address _createdTicket, uint _buyInAmount) external;
function preConfirmSGPTrade(bytes32 requestId, uint _buyInAmount) external;
function confirmSGPTrade(bytes32 requestId, address _createdTicket, uint _buyInAmount) external;
}// 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": 100
},
"evmVersion": "paris",
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"libraries": {}
}Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
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":"ticket","type":"address"},{"indexed":false,"internalType":"uint256","name":"oldRound","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newRound","type":"uint256"}],"name":"TicketMigratedToNextRound","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":"exerciseDefaultRoundTicketsReadyToBeExercised","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_batchSize","type":"uint256"}],"name":"exerciseDefaultRoundTicketsReadyToBeExercisedBatch","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"},{"internalType":"uint256","name":"_round","type":"uint256"},{"internalType":"uint256","name":"_startIndex","type":"uint256"},{"internalType":"uint256","name":"_endIndex","type":"uint256"}],"name":"getTicketIndexInTicketRound","outputs":[{"internalType":"uint256","name":"index","type":"uint256"},{"internalType":"bool","name":"found","type":"bool"}],"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":"hasDefaultRoundTicketsReadyToBeExercised","outputs":[{"internalType":"bool","name":"","type":"bool"}],"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":[{"internalType":"address[]","name":"_tickets","type":"address[]"},{"internalType":"uint256","name":"_newRound","type":"uint256"},{"internalType":"uint256[]","name":"_ticketsIndexInRound","type":"uint256[]"}],"name":"migrateBatchOfTicketsToAnotherRound","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_ticket","type":"address"},{"internalType":"uint256","name":"_newRound","type":"uint256"},{"internalType":"uint256","name":"_ticketIndexInRound","type":"uint256"}],"name":"migrateTicketToAnotherRound","outputs":[],"stateMutability":"nonpayable","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
608060405234801561001057600080fd5b50615d7080620000216000396000f3fe608060405234801561001057600080fd5b50600436106104805760003560e01c80636c321c8a11610257578063d03c027311610146578063ddcc8fe9116100c3578063ebc7977211610087578063ebc7977214610a59578063ee161cce14610a61578063f61fcb8b14610a69578063f7683bbc14610a89578063ff50abdc14610a9157600080fd5b8063ddcc8fe914610a10578063e278fe6f14610a23578063e81e52ee14610a2b578063e8362b7714610a3e578063e95d39ca14610a4657600080fd5b8063d8dfeb451161010a578063d8dfeb45146109b1578063d95ad45c146109c4578063db7e3648146109d7578063db7f92d4146109ea578063ddc6ac23146109fd57600080fd5b8063d03c027314610971578063d27c079714610979578063d69fb66814610982578063d728e9101461098b578063d7efa1291461099e57600080fd5b8063a6644f96116101d4578063bdcc22e911610198578063bdcc22e914610922578063be9a65551461092b578063c3b83f5f14610933578063c992528814610946578063c9f4ff461461095e57600080fd5b8063a6644f96146108b8578063a8df539f146108e6578063b562a1ab146108f3578063b6b55f25146108fc578063b9b1be8b1461090f57600080fd5b80638b649b941161021b5780638b649b94146108615780638b8444121461086a5780638c54c812146108725780638da5cb5b146108925780639bd2e61b146108a557600080fd5b80636c321c8a1461080a57806374094edd1461081357806377332fc51461083357806379ba5097146108465780637a1e0aa81461084e57600080fd5b80634218c4d8116103735780635c7b396e116102f0578063634e0d97116102b4578063634e0d9714610796578063645006ca146107c457806365e0e725146107cd5780636685fdc2146107e0578063681312f5146107f757600080fd5b80635c7b396e146107295780635c975abb146107325780635ddd3e831461073a578063610589e1146107655780636131dc711461076e57600080fd5b80634d549a42116103375780634d549a42146106d557806353a47bb7146106e857806353e8bdb7146106fb578063582ab2f91461070357806358c09cc01461071657600080fd5b80634218c4d81461065e5780634651f0801461066657806348663e951461068f5780634a96fc84146106a25780634ae7937f146106b557600080fd5b80631daae17311610401578063336d30ed116103c5578063336d30ed146105f2578063343e4f9f146106125780633ab76e9f146106255780633b92d7581461063857806340774ff61461064b57600080fd5b80631daae173146105625780631f2698ab14610595578063202ffce8146105a957806327c28442146105bc578063311c56df146105ea57600080fd5b8063146ca53111610448578063146ca531146105175780631627540c1461052057806316c38b3c146105335780631b2a52d8146105465780631baa88561461055957600080fd5b806303d868db1461048557806309b17b3d146104ae57806312b19a13146104c357806313af4035146104e4578063145dee7d146104f7575b600080fd5b610498610493366004615387565b610a9a565b6040516104a591906153a9565b60405180910390f35b6104c16104bc3660046153bd565b610ad2565b005b6104d66104d13660046153d6565b610de6565b6040519081526020016104a5565b6104c16104f2366004615404565b610e14565b6104d66105053660046153d6565b6000908152600f602052604090205490565b6104d660055481565b6104c161052e366004615404565b610f2b565b6104c161054136600461542f565b610f7e565b6104c16105543660046153d6565b610f9e565b6104d660075481565b610585610570366004615404565b600d6020526000908152604090205460ff1681565b60405190151581526020016104a5565b60045461058590600160a01b900460ff1681565b6104c16105b73660046153d6565b6114f2565b6105856105ca36600461544c565b601160209081526000928352604080842090915290825290205460ff1681565b6104c161152f565b6104d66106003660046153d6565b60146020526000908152604090205481565b610498610620366004615387565b61173f565b602154610498906001600160a01b031681565b601954610498906001600160a01b031681565b6104c16106593660046153d6565b61175b565b6104c16117c0565b6104986106743660046153d6565b6008602052600090815260409020546001600160a01b031681565b601f54610498906001600160a01b031681565b6104c16106b03660046153d6565b6117d4565b6104d66106c33660046153d6565b600c6020526000908152604090205481565b6104c16106e3366004615404565b611847565b600154610498906001600160a01b031681565b6104c16118c1565b6104c161071136600461547c565b6118f7565b6104c16107243660046154b1565b611a8b565b6104d6601d5481565b610585611ebd565b6104d661074836600461544c565b600b60209081526000928352604080842090915290825290205481565b6104d660175481565b61078161077c3660046154dd565b611ed2565b604080519283529015156020830152016104a5565b6105856107a436600461544c565b600a60209081526000928352604080842090915290825290205460ff1681565b6104d660165481565b6104c16107db366004615404565b611f83565b6005546000908152600960205260409020546104d6565b6104c16108053660046153d6565b611ffc565b6104d6601e5481565b6104d66108213660046153d6565b60136020526000908152604090205481565b610498610841366004615404565b6120a1565b6104c16120d0565b6104c161085c3660046154b1565b6121a8565b6104d660065481565b6104c1612238565b6104d6610880366004615404565b60126020526000908152604090205481565b600054610498906001600160a01b031681565b6104c16108b33660046153d6565b612513565b6105856108c636600461544c565b601060209081526000928352604080842090915290825290205460ff1681565b601c546105859060ff1681565b6104d660225481565b6104c161090a3660046153d6565b6127ad565b601a54610498906001600160a01b031681565b6104d660185481565b6104c16129b1565b6104c1610941366004615404565b612b4e565b6003546104989061010090046001600160a01b031681565b6104d661096c366004615387565b612c3e565b610585612c7e565b6104d660155481565b6104d660205481565b6104c16109993660046155ee565b612c8f565b6104c16109ac3660046154b1565b6130ad565b600454610498906001600160a01b031681565b6105856109d2366004615404565b6131e0565b6104d66109e5366004615404565b61329f565b6104c16109f83660046153d6565b613556565b6104d6610a0b3660046153d6565b613593565b6104c1610a1e3660046153d6565b6135a4565b6104c16135e1565b6104c1610a39366004615404565b6139f5565b610585613b80565b6104c1610a543660046153d6565b613b8d565b6104c1613bde565b610585613c3c565b6104d6610a77366004615404565b600e6020526000908152604090205481565b6104d6613d78565b6104d6601b5481565b600f6020528160005260406000208181548110610ab657600080fd5b6000918252602090912001546001600160a01b03169150829050565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a008054600160401b810460ff16159067ffffffffffffffff16600081158015610b185750825b905060008267ffffffffffffffff166001148015610b355750303b155b905081158015610b43575080155b15610b615760405163f92ee8a960e01b815260040160405180910390fd5b845467ffffffffffffffff191660011785558315610b8b57845460ff60401b1916600160401b1785555b610b9b6104f26020880188615404565b610ba3613bde565b610bb36040870160208801615404565b600380546001600160a01b039290921661010002610100600160a81b0319909216919091179055610bea6060870160408801615404565b602180546001600160a01b0319166001600160a01b0392909216919091179055610c1a6080870160608801615404565b600480546001600160a01b0319166001600160a01b0392909216919091179055610160860135602255608086013560065560a086013560155560c086013560165560e0860135601755670de0b6b3a76400006101008701351115610c995760405162461bcd60e51b8152600401610c90906156b9565b60405180910390fd5b610100860135601e55610cb461014087016101208801615404565b601f80546001600160a01b0319166001600160a01b0392909216919091179055670de0b6b3a76400006101408701351115610d015760405162461bcd60e51b8152600401610c90906156fb565b61014086013560209081556004546001600160a01b03169063095ea7b390610d2f9060408a01908a01615404565b6000196040518363ffffffff1660e01b8152600401610d4f92919061573c565b6020604051808303816000875af1158015610d6e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d929190615755565b5060016005558315610dde57845460ff60401b19168555604051600181527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15b505050505050565b600654600090610df7600184615788565b610e01919061579b565b600754610e0e91906157b2565b92915050565b6001600160a01b038116610e665760405162461bcd60e51b815260206004820152601960248201527804f776e657220616464726573732063616e6e6f74206265203603c1b6044820152606401610c90565b600154600160a01b900460ff1615610ed25760405162461bcd60e51b815260206004820152602960248201527f416c726561647920696e697469616c697a65642c20757365206e6f6d696e617460448201526832a732bba7bbb732b960b91b6064820152608401610c90565b6001805460ff60a01b1916600160a01b179055600080546001600160a01b0383166001600160a01b0319909116178155604051600080516020615cdb83398151915291610f209184906157c5565b60405180910390a150565b610f33613e6f565b600180546001600160a01b0319166001600160a01b0383161790556040517f906a1c6bd7e3091ea86693dd029a831c19049ce77f1dce2ce0bab1cacbabce2290610f209083906153a9565b610f86613e6f565b80610f9657610f93613ee1565b50565b610f93613f2d565b600160026000828254610fb191906157b2565b9091555050600254610fc1613f74565b601c5460ff16610fe35760405162461bcd60e51b8152600401610c90906157df565b600554600090815260096020526040902054601d54106110455760405162461bcd60e51b815260206004820152601b60248201527f416c6c20757365727320616c72656164792070726f63657373656400000000006044820152606401610c90565b600082116110655760405162461bcd60e51b8152600401610c9090615816565b600554600090815260086020526040812054601d546001600160a01b0390911691906110929085906157b2565b6005546000908152600960205260409020549091508111156110c257506005546000908152600960205260409020545b601d545b8181101561148e5760055460009081526009602052604081208054839081106110f1576110f1615859565b6000918252602080832090910154600554835260138252604080842054600b84528185206001600160a01b0390931680865292909352832054909350670de0b6b3a7640000916111409161579b565b61114a919061586f565b6001600160a01b0383166000908152600d602052604090205490915060ff16158015611186575060055460009081526013602052604090205415155b156112765780600b6000600554600161119f91906157b2565b81526020019081526020016000206000846001600160a01b03166001600160a01b03168152602001908152602001600020546111db91906157b2565b600b600060055460016111ee91906157b2565b81526020019081526020016000206000846001600160a01b03166001600160a01b031681526020019081526020016000208190555060096000600554600161123691906157b2565b8152602080820192909252604001600090812080546001810182559082529190200180546001600160a01b0319166001600160a01b038416179055611468565b6001600160a01b0382166000908152600e6020526040902054156113d1576001600160a01b0382166000908152600e6020526040812054670de0b6b3a7640000906112c1908461579b565b6112cb919061586f565b6004549091506112e6906001600160a01b0316878584613f9a565b600080516020615cfb833981519152838260405161130592919061573c565b60405180910390a16001600160a01b0383166000908152600d60209081526040808320805460ff19169055600e90915281208190556005546009919061134c9060016157b2565b8152602080820192909252604001600090812080546001810182559082529190200180546001600160a01b0319166001600160a01b0385161790556113918183615788565b600b600060055460016113a491906157b2565b8152602080820192909252604090810160009081206001600160a01b038816825290925290205550611468565b6000600b600060055460016113e691906157b2565b8152602080820192909252604090810160009081206001600160a01b0380881683529352209190915560045461141f9116868484613f9a565b6001600160a01b0382166000908152600d602052604090819020805460ff1916905551600080516020615cfb8339815191529061145f908490849061573c565b60405180910390a15b601d546114769060016157b2565b601d555081905061148681615891565b9150506110c6565b5060055460408051918252602082018690527f2e692c8fcabe33ba22535323e79dcb54ef22dccdb8e4ebdd9f2a7ffb1a28856c910160405180910390a1505060025481146114ee5760405162461bcd60e51b8152600401610c90906158aa565b5050565b6114fa613e6f565b60178190556040518181527fe7c2c09f66c8b970b4a99250f4d0844e1496b9d51d4760a17b0134ddd52023e190602001610f20565b60016002600082825461154291906157b2565b9091555050600254600454600160a01b900460ff166115735760405162461bcd60e51b8152600401610c90906158e1565b336000908152600d602052604090205460ff16156115a35760405162461bcd60e51b8152600401610c909061590f565b6005546000908152600b602090815260408083203384529091529020546115dc5760405162461bcd60e51b8152600401610c9090615946565b600b600060055460016115ef91906157b2565b8152602080820192909252604090810160009081203382529092529020541561162a5760405162461bcd60e51b8152600401610c9090615973565b611632613f74565b601c5460ff16156116555760405162461bcd60e51b8152600401610c90906159c9565b6005546000908152600b60209081526040808320338452909152902054601b5411156116b6576005546000908152600b60209081526040808320338452909152812054601b8054919290916116ab908490615788565b909155506116bc9050565b6000601b555b60016018546116cb9190615788565b601855336000818152600d602052604090819020805460ff19166001179055517fe5892ff2a8b08efb903ffbba1f0514c1d3e22eea34dd5b89cf30aabce03dde5a91611716916153a9565b60405180910390a16002548114610f935760405162461bcd60e51b8152600401610c90906158aa565b60096020528160005260406000208181548110610ab657600080fd5b611763613e6f565b670de0b6b3a764000081111561178b5760405162461bcd60e51b8152600401610c90906156b9565b601e8190556040518181527fc117ccf765672707ebe3c1606037488c1e27dc1f42b5266e3d6b496db7d4209e90602001610f20565b6117c8613f74565b6117d26001613ff4565b565b6001600260008282546117e791906157b2565b90915550506002546117f7613f74565b601c5460ff161561181a5760405162461bcd60e51b8152600401610c90906159c9565b61182682600554614060565b60025481146114ee5760405162461bcd60e51b8152600401610c90906158aa565b61184f613e6f565b6001600160a01b0381166118755760405162461bcd60e51b8152600401610c9090615a10565b601a80546001600160a01b0319166001600160a01b0383169081179091556040517fa65a5aa86bb6f8e75752296da3ebda45474c8a302fc640c3b62868793862a03391610f20916153a9565b601c5460ff16156118e45760405162461bcd60e51b8152600401610c90906159c9565b6118ec613f74565b6117d2600554613ff4565b60005433906001600160a01b03168114806119f35750600360019054906101000a90046001600160a01b03166001600160a01b031663481c6a756040518163ffffffff1660e01b8152600401602060405180830381865afa158015611960573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119849190615a47565b6001600160a01b031663e760c3958260026040518363ffffffff1660e01b81526004016119b2929190615a7a565b602060405180830381865afa1580156119cf573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119f39190615755565b611a0f5760405162461bcd60e51b8152600401610c9090615aa7565b601c5460ff1615611a325760405162461bcd60e51b8152600401610c90906159c9565b6000611a3d8561329f565b90506005548114611a605760405162461bcd60e51b8152600401610c9090615acf565b611a84858515611a705785611a7e565b600554611a7e9060016157b2565b856140ec565b5050505050565b600160026000828254611a9e91906157b2565b9091555050600254611aae613f74565b60035461010090046001600160a01b03163314611add5760405162461bcd60e51b8152600401610c9090615b00565b601c5460ff1615611b005760405162461bcd60e51b8152600401610c90906159c9565b600454600160a01b900460ff16611b295760405162461bcd60e51b8152600401610c90906158e1565b60008211611b755760405162461bcd60e51b815260206004820152601960248201527843616e277420636f6d6d69742061207a65726f20747261646560381b6044820152606401610c90565b6000611b808461329f565b6001600160a01b0385166000908152601260205260408120829055909150611ba78261457c565b90506005548203611cfe57600354600454611bd6916001600160a01b0391821691849161010090041687613f9a565b601e546005546000908152600c6020526040902054670de0b6b3a764000091611bfe9161579b565b611c08919061586f565b6005546000908152600c6020526040902054611c249190615788565b600480546040516370a0823160e01b81526001600160a01b03909116916370a0823191611c53918691016153a9565b602060405180830381865afa158015611c70573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c949190615b46565b1015611cf95760405162461bcd60e51b815260206004820152602e60248201527f416d6f756e74206578636565647320617661696c61626c65207574696c697a6160448201526d1d1a5bdb88199bdc881c9bdd5b9960921b6064820152608401610c90565b611e3b565b600554821115611df257600480546040516370a0823160e01b81526000926001600160a01b03909216916370a0823191611d3a918691016153a9565b602060405180830381865afa158015611d57573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d7b9190615b46565b9050848110611dad57600354600454611da8916001600160a01b0391821691859161010090041688613f9a565b611dec565b6000611db98287615788565b9050611dc681848661475a565b600354600454611dea916001600160a01b0391821691869161010090041689613f9a565b505b50611e3b565b81600114611e325760405162461bcd60e51b815260206004820152600d60248201526c125b9d985b1a59081c9bdd5b99609a1b6044820152606401610c90565b611e3b84614838565b506000818152600f602090815260408083208054600180820183559185528385200180546001600160a01b0319166001600160a01b038a1690811790915594845260108352818420948452939091529020805460ff191690911790556002548114611eb85760405162461bcd60e51b8152600401610c90906158aa565b505050565b600080611ec861494a565b5460ff1692915050565b6000838152600f6020526040812054819081908410611eff576000868152600f6020526040902054611f01565b835b9050845b81811015611f70576000878152600f6020526040902080546001600160a01b038a16919083908110611f3957611f39615859565b6000918252602090912001546001600160a01b031603611f6057925060019150611f7a9050565b611f6981615891565b9050611f05565b5083600092509250505b94509492505050565b611f8b613e6f565b6001600160a01b038116611fb15760405162461bcd60e51b8152600401610c9090615a10565b601980546001600160a01b0319166001600160a01b0383161790556040517faaf6f0738515c3cf390f1b3faec649d2dacb169d024089afc43bbe2fe66cd2d890610f209083906153a9565b612004613e6f565b600454600160a01b900460ff161561206c5760405162461bcd60e51b815260206004820152602560248201527f43616e2774206368616e676520726f756e64206c656e677468206166746572206044820152641cdd185c9d60da1b6064820152608401610c90565b60068190556040518181527f1d1fb7111c3779798bd4aefb2daea07ee8257a13c7eaceba89b4b1ccd405050d90602001610f20565b6000600860006120b08461329f565b81526020810191909152604001600020546001600160a01b031692915050565b6001546001600160a01b031633146121485760405162461bcd60e51b815260206004820152603560248201527f596f75206d757374206265206e6f6d696e61746564206265666f726520796f7560448201527402063616e20616363657074206f776e65727368697605c1b6064820152608401610c90565b600054600154604051600080516020615cdb83398151915292612179926001600160a01b03918216929116906157c5565b60405180910390a160018054600080546001600160a01b03199081166001600160a01b03841617909155169055565b6121b0613e6f565b601f80546001600160a01b0319166001600160a01b038416179055602054670de0b6b3a764000010156121f55760405162461bcd60e51b8152600401610c90906156fb565b60208190556040517fa1a8623472ca4e2879372be60dfd1ff0675778e49f7379eedd98ca57cf36b21a9061222c908490849061573c565b60405180910390a15050565b60016002600082825461224b91906157b2565b909155505060025461225b613f74565b601c5460ff161561227e5760405162461bcd60e51b8152600401610c90906159c9565b612286613c3c565b6122ce5760405162461bcd60e51b815260206004820152601960248201527810d85b89dd0818db1bdcd94818dd5c9c995b9d081c9bdd5b99603a1b6044820152606401610c90565b6122d66118c1565b600554600090815260086020526040808220546004805492516370a0823160e01b81526001600160a01b039283169493909216916370a082319161231c918691016153a9565b602060405180830381865afa158015612339573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061235d9190615b46565b6005546000908152600c602052604090205490915081111561242c57602080546005546000908152600c9092526040822054670de0b6b3a764000091906123a49085615788565b6123ae919061579b565b6123b8919061586f565b601f546004549192506123da916001600160a01b039081169186911684613f9a565b6123e48183615788565b91507fb8379d05082aa2dd32963972d72cc2d46257811133341855b63bb2fddda6ca3e60205482604051612422929190918252602082015260400190565b60405180910390a1505b6005546000908152600c60205260408120549003612465576005546000908152601360205260409020670de0b6b3a764000090556124a6565b6005546000908152600c6020526040902054612489670de0b6b3a76400008361579b565b612493919061586f565b6005546000908152601360205260409020555b601c805460ff191660011790556005546040517fa224cce482b24082d1d3128437615f7f5ce87b97453a11114846ea442a100272916124e89190815260200190565b60405180910390a150506002548114610f935760405162461bcd60e51b8152600401610c90906158aa565b60016002600082825461252691906157b2565b9091555050600254600454600160a01b900460ff166125575760405162461bcd60e51b8152600401610c90906158e1565b336000908152600d602052604090205460ff16156125875760405162461bcd60e51b8152600401610c909061590f565b6005546000908152600b602090815260408083203384529091529020546125c05760405162461bcd60e51b8152600401610c9090615946565b600b600060055460016125d391906157b2565b8152602080820192909252604090810160009081203382529092529020541561260e5760405162461bcd60e51b8152600401610c9090615973565b612616613f74565b601c5460ff16156126395760405162461bcd60e51b8152600401610c90906159c9565b61264b662386f26fc10000600a61579b565b821015801561266b5750612667662386f26fc10000605a61579b565b8211155b6126c35760405162461bcd60e51b815260206004820152602360248201527f53686172652068617320746f206265206265747765656e2031302520616e642060448201526239302560e81b6064820152608401610c90565b6005546000908152600b60209081526040808320338452909152812054670de0b6b3a7640000906126f590859061579b565b6126ff919061586f565b905080601b5411156127285780601b600082825461271d9190615788565b9091555061272e9050565b6000601b555b336000818152600d60209081526040808320805460ff19166001179055600e90915290819020859055517fe5892ff2a8b08efb903ffbba1f0514c1d3e22eea34dd5b89cf30aabce03dde5a91612783916153a9565b60405180910390a15060025481146114ee5760405162461bcd60e51b8152600401610c90906158aa565b336000908152600d6020526040902054819060ff161561281f5760405162461bcd60e51b815260206004820152602760248201527f5769746864726177616c206973207265717565737465642c2063616e6e6f742060448201526619195c1bdcda5d60ca1b6064820152608401610c90565b60155481601b5461283091906157b2565b11156128885760405162461bcd60e51b815260206004820152602160248201527f4465706f73697420616d6f756e74206578636565647320414d4d204c502063616044820152600760fc1b6064820152608401610c90565b6005546000908152600b602090815260408083203384529091529020541580156128e05750600b600060055460016128c091906157b2565b815260208082019290925260409081016000908120338252909252902054155b15612941576016548110156129415760405162461bcd60e51b815260206004820152602160248201527f416d6f756e74206c657373207468616e206d696e4465706f736974416d6f756e6044820152601d60fa1b6064820152608401610c90565b60016002600082825461295491906157b2565b9091555050600254612964613f74565b601c5460ff16156129875760405162461bcd60e51b8152600401610c90906159c9565b6129908361496e565b6002548114611eb85760405162461bcd60e51b8152600401610c90906158aa565b6129b9613e6f565b600454600160a01b900460ff1615612a0c5760405162461bcd60e51b81526020600482015260166024820152751314081a185cc8185b1c9958591e481cdd185c9d195960521b6044820152606401610c90565b6002600052600c6020527f5d6016397a73f5e079297ac5a36fef17b4d9c3831618e63ab105738020ddd72054612a845760405162461bcd60e51b815260206004820152601d60248201527f43616e206e6f7420737461727420776974682030206465706f736974730000006044820152606401610c90565b4260075560026005819055600090612a9b9061457c565b9050806001600160a01b0316637d3de7ce600754612ab96002610de6565b6040516001600160e01b031960e085901b16815260048101929092526024820152604401600060405180830381600087803b158015612af757600080fd5b505af1158015612b0b573d6000803e3d6000fd5b50506004805460ff60a01b1916600160a01b17905550506040517f960682678fca98f3ed131eaf165e59544bcd738e948f0b3c64f58fa9e1c65e6090600090a150565b612b56613e6f565b6001600160a01b038116612b9e5760405162461bcd60e51b815260206004820152600f60248201526e496e76616c6964206164647265737360881b6044820152606401610c90565b600154600160a81b900460ff1615612bee5760405162461bcd60e51b8152602060048201526013602482015272105b1c9958591e481d1c985b9cd9995c9c9959606a1b6044820152606401610c90565b600080546001600160a01b0383166001600160a01b031990911681179091556001805460ff60a81b1916600160a81b179055604051600080516020615cdb83398151915291610f209184906157c5565b6000828152601460208181526040808420546013835281852054868652939092528320549091612c6d9161579b565b612c77919061586f565b9392505050565b6000612c8a6001614b74565b905090565b60005433906001600160a01b0316811480612d8b5750600360019054906101000a90046001600160a01b03166001600160a01b031663481c6a756040518163ffffffff1660e01b8152600401602060405180830381865afa158015612cf8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612d1c9190615a47565b6001600160a01b031663e760c3958260026040518363ffffffff1660e01b8152600401612d4a929190615a7a565b602060405180830381865afa158015612d67573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612d8b9190615755565b612da75760405162461bcd60e51b8152600401610c9090615aa7565b601c5460ff1615612dca5760405162461bcd60e51b8152600401610c90906159c9565b8215612dd65782612de4565b600554612de49060016157b2565b92508151600003612e385760005b8451811015612e3257612e20858281518110612e1057612e10615859565b60200260200101518560006140ec565b80612e2a81615891565b915050612df2565b506130a7565b8151845114612e825760405162461bcd60e51b8152602060048201526016602482015275082e4e4c2f2e698cadccee8d0e69aeae6e89ac2e8c6d60531b6044820152606401610c90565b6005546000908152600f6020526040812054905b8551811015610dde576000848281518110612eb357612eb3615859565b602002602001015111612f085760405162461bcd60e51b815260206004820152601d60248201527f5469636b6574496e6465784d7573744265477265617465725468616e300000006044820152606401610c90565b612f128183615788565b848281518110612f2457612f24615859565b60200260200101511015612f7457612f6f868281518110612f4757612f47615859565b602002602001015186868481518110612f6257612f62615859565b60200260200101516140ec565b613095565b6000805b855182101561301557878381518110612f9357612f93615859565b60200260200101516001600160a01b0316600f60006005548152602001908152602001600020878481518110612fcb57612fcb615859565b602002602001015181548110612fe357612fe3615859565b6000918252602090912001546001600160a01b03160361300557506001613015565b61300e82615891565b9150612f78565b806130625760405162461bcd60e51b815260206004820152601a60248201527f5469636b65744e6f74466f756e64496e496e70757441727261790000000000006044820152606401610c90565b61309288848151811061307757613077615859565b602002602001015188888581518110612f6257612f62615859565b50505b8061309f81615891565b915050612e96565b50505050565b6130b5613f74565b601c5460ff16156130d85760405162461bcd60e51b8152600401610c90906159c9565b60035461010090046001600160a01b031633146131075760405162461bcd60e51b8152600401610c9090615b00565b60006131128361329f565b9050600181118015613125575060055481105b1561312f57506005545b8115613183576000600182111561314e576131498261457c565b61315b565b6019546001600160a01b03165b600354600454919250613181916001600160a01b03908116916101009004168386613f9a565b505b60008181526010602090815260408083206001600160a01b038716845290915290205460ff1615611eb85760008181526011602090815260408083206001600160a01b03871684529091529020805460ff19166001179055505050565b6005546000908152600b602090815260408083206001600160a01b038516845290915281205415158061325757506000600b6000600554600161322391906157b2565b81526020019081526020016000206000846001600160a01b03166001600160a01b0316815260200190815260200160002054115b8015610e0e57506001600160a01b0382166000908152600d602052604090205460ff161580610e0e5750506001600160a01b03166000908152600e6020526040902054151590565b6001600160a01b038116600090815260126020526040812054908190036135515781600080805b836001600160a01b03166362e5c8196040518163ffffffff1660e01b8152600401602060405180830381865afa158015613304573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906133289190615b46565b81101561354c5760405163b1283e7760e01b8152600481018290526001600160a01b0385169063b1283e779060240161012060405180830381865afa158015613375573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906133999190615b82565b505060215460405163bf40fac160e01b815260206004820152601660248201527529b837b93a39a0a6a6ab192934b9b5a6b0b730b3b2b960511b6044820152949a5095985060009650506001600160a01b03909416935063bf40fac1925050606401602060405180830381865afa158015613418573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061343c9190615a47565b6040516349ef3bc960e11b815261ffff851660048201526001600160a01b0391909116906393de779290602401602060405180830381865afa158015613486573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906134aa9190615755565b9050600754841180156134bb575080155b1561352f57816000036134f4576006546007546134d89086615788565b6134e2919061586f565b6134ed9060026157b2565b9550613539565b85600654600754866135069190615788565b613510919061586f565b61351b9060026157b2565b1461352a57600195505061354c565b613539565b600195505061354c565b508061354481615891565b9150506132c6565b505050505b919050565b61355e613e6f565b60168190556040518181527f990717cc219e5348c1b88bb0ff530d804f0b6f54f3b03844a2bfbe4eb1e9c5d690602001610f20565b600654600090610df7600284615788565b6135ac613e6f565b60158190556040518181527f8c43aa02599ac8f8bab4724621ceea5e7a06b07bbbfaf3b7bd0386cbe481ea3c90602001610f20565b6001600260008282546135f491906157b2565b9091555050600254613604613f74565b601c5460ff166136265760405162461bcd60e51b8152600401610c90906157df565b600554600090815260096020526040902054601d54146136885760405162461bcd60e51b815260206004820152601b60248201527f4e6f7420616c6c2075736572732070726f6365737365642079657400000000006044820152606401610c90565b601c805460ff19169055600554600090815260086020908152604080832054600b83528184206019546001600160a01b03908116865293529220549116901561377157600554600090815260136020908152604080832054600b83528184206019546001600160a01b03168552909252822054670de0b6b3a76400009161370e9161579b565b613718919061586f565b60195460045491925061373a916001600160a01b039081169185911684613f9a565b601954604051600080516020615cfb83398151915291613767916001600160a01b0390911690849061573c565b60405180910390a1505b60055460020361379e57600554600090815260136020908152604080832054601490925290912055613801565b600554600081815260136020526040812054670de0b6b3a76400009290916014916137cb90600190615788565b8152602001908152602001600020546137e4919061579b565b6137ee919061586f565b6005546000908152601460205260409020555b60056000815461381090615891565b90915550600480546040516370a0823160e01b81526001600160a01b03909116916370a0823191613843918591016153a9565b602060405180830381865afa158015613860573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906138849190615b46565b6005546000908152600c6020526040812080549091906138a59084906157b2565b90915550506005546000818152600b602090815260408083206019546001600160a01b03168452825280832054938352600c9091529020546138e79190615788565b601b556005546000906138f99061457c565b600480546040516370a0823160e01b815292935061398692859285926001600160a01b0316916370a0823191613931918691016153a9565b602060405180830381865afa15801561394e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906139729190615b46565b6004546001600160a01b0316929190613f9a565b6000601d556005547fc67dda8e11f1aa941c7e74466b1859a07a32f46aaf641d29b83be348424d93cd906139bc90600190615788565b6013600060016005546139cf9190615788565b8152602001908152602001600020546040516124e8929190918252602082015260400190565b6139fd613e6f565b6001600160a01b038116613a235760405162461bcd60e51b8152600401610c9090615a10565b60035461010090046001600160a01b031615613ab8576004805460035460405163095ea7b360e01b81526001600160a01b039283169363095ea7b393613a7393610100900416916000910161573c565b6020604051808303816000875af1158015613a92573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613ab69190615755565b505b60038054610100600160a81b0319166101006001600160a01b03848116820292909217928390556004805460405163095ea7b360e01b81529084169463095ea7b394613b0d949091041691600019910161573c565b6020604051808303816000875af1158015613b2c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613b509190615755565b507f576297e5fcc8cd907ee80b240284865eb3d821bdc5232e6ee9e4d78a12531c0981604051610f2091906153a9565b6000612c8a600554614b74565b600160026000828254613ba091906157b2565b9091555050600254613bb0613f74565b601c5460ff1615613bd35760405162461bcd60e51b8152600401610c90906159c9565b611826826001614060565b60035460ff1615613c275760405162461bcd60e51b8152602060048201526013602482015272105b1c9958591e481a5b9a5d1a585b1a5e9959606a1b6044820152606401610c90565b6003805460ff19166001908117909155600255565b600454600090600160a01b900460ff161580613c615750613c5e600554610de6565b42105b15613c6c5750600090565b60008060005b6005546000908152600f6020526040902054811015613d6e576005546000908152600f60205260409020805482908110613cae57613cae615859565b600091825260208083209091015460055483526011825260408084206001600160a01b039092168085529190925291205490925060ff16613d5c57819250826001600160a01b031663b0c56f056040518163ffffffff1660e01b8152600401602060405180830381865afa158015613d2a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613d4e9190615755565b613d5c576000935050505090565b80613d6681615891565b915050613c72565b5060019250505090565b60215460405163bf40fac160e01b8152602060048201526009602482015268141c9a58d95199595960ba1b60448201526000916001600160a01b03169063bf40fac190606401602060405180830381865afa158015613ddb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613dff9190615a47565b6001600160a01b031663ac82f6086022546040518263ffffffff1660e01b8152600401613e2e91815260200190565b602060405180830381865afa158015613e4b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612c8a9190615b46565b6000546001600160a01b031633146117d25760405162461bcd60e51b815260206004820152602f60248201527f4f6e6c792074686520636f6e7472616374206f776e6572206d6179207065726660448201526e37b936903a3434b99030b1ba34b7b760891b6064820152608401610c90565b613ee9614ce6565b6000613ef361494a565b805460ff1916815590507f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b604051610f2091906153a9565b613f35613f74565b6000613f3f61494a565b805460ff1916600117815590507f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258613f203390565b613f7c611ebd565b156117d25760405163d93c066560e01b815260040160405180910390fd5b604080516001600160a01b0385811660248301528416604482015260648082018490528251808303909101815260849091019091526020810180516001600160e01b03166323b872dd60e01b1790526130a7908590614d0b565b60005b6000828152600f60205260409020548110156114ee576000828152600f60205260409020805461404d9184918490811061403357614033615859565b6000918252602090912001546001600160a01b0316614d65565b508061405881615891565b915050613ff7565b600082116140805760405162461bcd60e51b8152600401610c9090615816565b6000805b6000838152600f60205260409020548110156130a7578184146130a7576000838152600f6020526040902080546140c79185918490811061403357614033615859565b156140da576140d76001836157b2565b91505b806140e481615891565b915050614084565b6005548211806140fc5750816001145b61413d5760405162461bcd60e51b8152602060048201526012602482015271149bdd5b99105b1c9958591e50db1bdcd95960721b6044820152606401610c90565b60006141488461329f565b9050600554811461419b5760405162461bcd60e51b815260206004820152601b60248201527f5469636b6574206e6f7420696e2063757272656e7420726f756e6400000000006044820152606401610c90565b60008181526010602090815260408083206001600160a01b038816845290915290205460ff166141dd5760405162461bcd60e51b8152600401610c9090615acf565b60008181526011602090815260408083206001600160a01b038816845290915290205460ff16156142495760405162461bcd60e51b8152602060048201526016602482015275151a58dad95d105b1c9958591e515e195c98da5cd95960521b6044820152606401610c90565b836001600160a01b0316633f6fa6556040518163ffffffff1660e01b8152600401602060405180830381865afa158015614287573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906142ab9190615755565b156142f05760405162461bcd60e51b8152602060048201526015602482015274151a58dad95d105b1c9958591e54995cdbdb1d9959605a1b6044820152606401610c90565b60008181526010602090815260408083206001600160a01b03881684529091529020805460ff19169055614325818584615020565b60006143308261457c565b9050600061433d8561457c565b90506000866001600160a01b031663d165dac26040518163ffffffff1660e01b8152600401602060405180830381865afa15801561437f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906143a39190615b46565b600480546040516370a0823160e01b81526001600160a01b03909116916370a08231916143d2918c91016153a9565b602060405180830381865afa1580156143ef573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906144139190615b46565b61441d9190615788565b600480546040516370a0823160e01b81529293506000926001600160a01b03909116916370a0823191614452918791016153a9565b602060405180830381865afa15801561446f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906144939190615b46565b9050808211156144b85760006144a98284615788565b90506144b681858a61475a565b505b6004546144d0906001600160a01b0316848685613f9a565b6001600160a01b03881660008181526012602090815260408083208b90558a8352601082528083208484528252808320805460ff191660019081179091558b8452600f8352818420805491820181558452919092200180546001600160a01b031916909217909155517fd8edac6470af12f863b07d43de4b58079798e80230a8b7f899a4f55ecdac61809061456a908a9088908b90615c28565b60405180910390a15050505050505050565b6000818152600860205260409020546001600160a01b03168061355157816001036145d6575060198054600083815260086020526040902080546001600160a01b0319166001600160a01b03928316179055905416919050565b601a546001600160a01b031661462e5760405162461bcd60e51b815260206004820152601d60248201527f526f756e6420706f6f6c206d6173746572636f7079206e6f74207365740000006044820152606401610c90565b601a54600090614646906001600160a01b031661521c565b6004549091506001600160a01b038083169163d13f90b491309116866146706104d1600183615788565b61467989610de6565b6040516001600160e01b031960e088901b1681526001600160a01b03958616600482015294909316602485015260448401919091526064830152608482015260a401600060405180830381600087803b1580156146d557600080fd5b505af11580156146e9573d6000803e3d6000fd5b50505060008481526008602090815260409182902080546001600160a01b0319166001600160a01b03861690811790915582518781529182015292935083927f24c1b21b902a85b5039d7d72427d9376657229eea77880ec9e62031dc950f6ba92500160405180910390a150919050565b6019546001600160a01b03166147825760405162461bcd60e51b8152600401610c9090615c49565b6019546004546147a0916001600160a01b0391821691168486613f9a565b6000818152600b602090815260408083206019546001600160a01b03168452909152812080548592906147d49084906157b2565b90915550506000818152600c6020526040812080548592906147f79084906157b2565b9091555050601954604051600080516020615d1b8339815191529161482b916001600160a01b039091169086908590615c28565b60405180910390a1505050565b6019546001600160a01b03166148605760405162461bcd60e51b8152600401610c9090615c49565b60195460035460045461488a926001600160a01b0391821692908216916101009091041684613f9a565b6019546001600160a01b031660009081527f72c6bfb7988af3a1efa6568f02a999bc52252641c659d85961ca3d372b57d5cf6020526040812080548392906148d39084906157b2565b909155505060016000908152600c6020527fd421a5181c571bba3f01190c922c3b2a896fc1d84e86c9f17ac10e67ebef8b5c80548392906149159084906157b2565b9091555050601954604051600080516020615d1b83398151915291610f20916001600160a01b03909116908490600190615c28565b7fcd5ed15c6e187e77e9aee88184c21f4f2182ab5827cb3b7e07fbedcd63f0330090565b6000600554600161497f91906157b2565b9050600061498c8261457c565b6004549091506149a7906001600160a01b0316338386613f9a565b6019546001600160a01b03163303614a0d5760405162461bcd60e51b8152602060048201526024808201527f43616e2774206465706f736974206469726563746c792061732064656661756c604482015263074204c560e41b6064820152608401610c90565b6005546000908152600b60209081526040808320338452909152902054158015614a4e57506000828152600b60209081526040808320338452909152902054155b15614ae75760175460185410614aa65760405162461bcd60e51b815260206004820152601b60248201527f4d617820616d6f756e74206f66207573657273207265616368656400000000006044820152606401610c90565b60008281526009602090815260408220805460018181018355918452919092200180546001600160a01b03191633179055601854614ae3916157b2565b6018555b6000828152600b6020908152604080832033845290915281208054859290614b109084906157b2565b90915550506000828152600c602052604081208054859290614b339084906157b2565b9250508190555082601b6000828254614b4c91906157b2565b9091555050600554604051600080516020615d1b8339815191529161482b9133918791615c28565b60008080805b6000858152600f6020526040902054811015614cdb576000858152600f60205260409020805482908110614bb057614bb0615859565b60009182526020808320909101548783526011825260408084206001600160a01b039092168085529190925291205490925060ff16614cc957819250826001600160a01b031663e74d3c476040518163ffffffff1660e01b8152600401602060405180830381865afa158015614c2a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614c4e9190615755565b8015614cb95750826001600160a01b0316633356a35a6040518163ffffffff1660e01b8152600401602060405180830381865afa158015614c93573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614cb79190615755565b155b15614cc957506001949350505050565b80614cd381615891565b915050614b7a565b506000949350505050565b614cee611ebd565b6117d257604051638dfc202b60e01b815260040160405180910390fd5b6000614d206001600160a01b03841683615289565b90508051600014158015614d45575080806020019051810190614d439190615755565b155b15611eb85782604051635274afe760e01b8152600401610c9091906153a9565b60008281526011602090815260408083206001600160a01b038516845290915281205460ff16610e0e5760008290506000816001600160a01b0316633356a35a6040518163ffffffff1660e01b8152600401602060405180830381865afa158015614dd4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614df89190615755565b90506000806001871115614e6b57836001600160a01b0316634652e3306040518163ffffffff1660e01b8152600401602060405180830381865afa158015614e44573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614e689190615755565b90505b808015614e7f5750614e7c87610de6565b42115b15614e8957600191505b836001600160a01b031663e74d3c476040518163ffffffff1660e01b8152600401602060405180830381865afa158015614ec7573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614eeb9190615755565b8015614efc5750821580614efc5750815b15614f6b57600354604051630f8a940b60e41b81526101009091046001600160a01b03169063f8a940b090614f38908990600090600401615c75565b600060405180830381600087803b158015614f5257600080fd5b505af1158015614f66573d6000803e3d6000fd5b505050505b828015614f76575080155b80614fde5750836001600160a01b0316633f6fa6556040518163ffffffff1660e01b8152600401602060405180830381865afa158015614fba573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614fde9190615755565b156150165760008781526011602090815260408083206001600160a01b038a1684529091529020805460ff1916600190811790915594505b5050505092915050565b6000816000036150ab5760005b6000858152600f60205260409020548110156150a5576000858152600f6020526040902080546001600160a01b03861691908390811061506f5761506f615859565b6000918252602090912001546001600160a01b03160361509557600191508092506150a5565b61509e81615891565b905061502d565b50615109565b6000848152600f60205260409020548210801561510657506000848152600f6020526040902080546001600160a01b0385169190849081106150ef576150ef615859565b6000918252602090912001546001600160a01b0316145b90505b806151475760405162461bcd60e51b815260206004820152600e60248201526d151a58dad95d139bdd119bdd5b9960921b6044820152606401610c90565b6000848152600f60205260409020805461516390600190615788565b8154811061517357615173615859565b6000918252602080832090910154868352600f909152604090912080546001600160a01b0390921691849081106151ac576151ac615859565b600091825260208083209190910180546001600160a01b0319166001600160a01b039490941693909317909255858152600f909152604090208054806151f4576151f4615c95565b600082815260209020810160001990810180546001600160a01b031916905501905550505050565b6000763d602d80600a3d3981f3363d3d373d3d3d363d730000008260601b60e81c176000526e5af43d82803e903d91602b57fd5bf38260781b17602052603760096000f090506001600160a01b038116613551576040516330be1a3d60e21b815260040160405180910390fd5b6060612c778383600084600080856001600160a01b031684866040516152af9190615cab565b60006040518083038185875af1925050503d80600081146152ec576040519150601f19603f3d011682016040523d82523d6000602084013e6152f1565b606091505b509150915061530186838361530b565b9695505050505050565b6060826153205761531b8261535e565b612c77565b815115801561533757506001600160a01b0384163b155b156153575783604051639996b31560e01b8152600401610c9091906153a9565b5080612c77565b80511561536e5780518082602001fd5b604051630a12f52160e11b815260040160405180910390fd5b6000806040838503121561539a57600080fd5b50508035926020909101359150565b6001600160a01b0391909116815260200190565b600061018082840312156153d057600080fd5b50919050565b6000602082840312156153e857600080fd5b5035919050565b6001600160a01b0381168114610f9357600080fd5b60006020828403121561541657600080fd5b8135612c77816153ef565b8015158114610f9357600080fd5b60006020828403121561544157600080fd5b8135612c7781615421565b6000806040838503121561545f57600080fd5b823591506020830135615471816153ef565b809150509250929050565b60008060006060848603121561549157600080fd5b833561549c816153ef565b95602085013595506040909401359392505050565b600080604083850312156154c457600080fd5b82356154cf816153ef565b946020939093013593505050565b600080600080608085870312156154f357600080fd5b84356154fe816153ef565b966020860135965060408601359560600135945092505050565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff8111828210171561555757615557615518565b604052919050565b600067ffffffffffffffff82111561557957615579615518565b5060051b60200190565b600082601f83011261559457600080fd5b813560206155a96155a48361555f565b61552e565b82815260059290921b840181019181810190868411156155c857600080fd5b8286015b848110156155e357803583529183019183016155cc565b509695505050505050565b60008060006060848603121561560357600080fd5b833567ffffffffffffffff8082111561561b57600080fd5b818601915086601f83011261562f57600080fd5b8135602061563f6155a48361555f565b82815260059290921b8401810191818101908a84111561565e57600080fd5b948201945b83861015615685578535615676816153ef565b82529482019490820190615663565b97505087013594505060408601359150808211156156a257600080fd5b506156af86828701615583565b9150509250925092565b60208082526022908201527f5574696c697a6174696f6e20726174652063616e277420657863656564203130604082015261302560f01b606082015260800190565b60208082526021908201527f5361666520426f7820696d706163742063616e277420657863656564203130306040820152602560f81b606082015260800190565b6001600160a01b03929092168252602082015260400190565b60006020828403121561576757600080fd5b8151612c7781615421565b634e487b7160e01b600052601160045260246000fd5b81810381811115610e0e57610e0e615772565b8082028115828204841417610e0e57610e0e615772565b80820180821115610e0e57610e0e615772565b6001600160a01b0392831681529116602082015260400190565b6020808252601a908201527f526f756e6420636c6f73696e67206e6f74207072657061726564000000000000604082015260600190565b60208082526023908201527f42617463682073697a652068617320746f20626520677265617465722074686160408201526206e20360ec1b606082015260800190565b634e487b7160e01b600052603260045260246000fd5b60008261588c57634e487b7160e01b600052601260045260246000fd5b500490565b6000600182016158a3576158a3615772565b5060010190565b6020808252601f908201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604082015260600190565b602080825260149082015273141bdbdb081a185cc81b9bdd081cdd185c9d195960621b604082015260600190565b6020808252601c908201527f5769746864726177616c20616c72656164792072657175657374656400000000604082015260600190565b6020808252601390820152724e6f7468696e6720746f20776974686472617760681b604082015260600190565b60208082526036908201527f43616e277420776974686472617720617320796f7520616c72656164792064656040820152751c1bdcda5d195908199bdc881b995e1d081c9bdd5b9960521b606082015260800190565b60208082526027908201527f4e6f7420616c6c6f77656420647572696e6720726f756e64436c6f73696e67506040820152661c995c185c995960ca1b606082015260800190565b6020808252601b908201527f43616e206e6f74207365742061207a65726f2061646472657373210000000000604082015260600190565b600060208284031215615a5957600080fd5b8151612c77816153ef565b634e487b7160e01b600052602160045260246000fd5b6001600160a01b03831681526040810160048310615a9a57615a9a615a64565b8260208301529392505050565b6020808252600e908201526d24b73b30b634b21039b2b73232b960911b604082015260600190565b602080825260179082015276151a58dad95d139bdd125b90dd5c9c995b9d149bdd5b99604a1b604082015260600190565b60208082526026908201527f4f6e6c792074686520414d4d206d617920706572666f726d207468657365206d6040820152656574686f647360d01b606082015260800190565b600060208284031215615b5857600080fd5b5051919050565b805161ffff8116811461355157600080fd5b805160ff8116811461355157600080fd5b60008060008060008060008060006101208a8c031215615ba157600080fd5b89519850615bb160208b01615b5f565b9750615bbf60408b01615b5f565b965060608a01519550615bd460808b01615b71565b945060a08a01518060020b8114615bea57600080fd5b60c08b015190945062ffffff81168114615c0357600080fd5b9250615c1160e08b01615b71565b91506101008a015190509295985092959850929598565b6001600160a01b039390931683526020830191909152604082015260600190565b602080825260129082015271111959985d5b1d081314081b9bdd081cd95d60721b604082015260600190565b6001600160a01b03831681526040810160038310615a9a57615a9a615a64565b634e487b7160e01b600052603160045260246000fd5b6000825160005b81811015615ccc5760208186018101518583015201615cb2565b50600092019182525091905056feb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159cd8138f8a3f377c5259ca548e70e4c2de94f129f5a11036a15b69513cba2b426a73a19dd210f1a7f902193214c0ee91dd35ee5b4d920cba8d519eca65a7b488caa2646970667358221220a1862ce6b445fa8005c24fa154170b79a833146221b34ef74f948cacfc50095064736f6c63430008140033
Deployed Bytecode
0x608060405234801561001057600080fd5b50600436106104805760003560e01c80636c321c8a11610257578063d03c027311610146578063ddcc8fe9116100c3578063ebc7977211610087578063ebc7977214610a59578063ee161cce14610a61578063f61fcb8b14610a69578063f7683bbc14610a89578063ff50abdc14610a9157600080fd5b8063ddcc8fe914610a10578063e278fe6f14610a23578063e81e52ee14610a2b578063e8362b7714610a3e578063e95d39ca14610a4657600080fd5b8063d8dfeb451161010a578063d8dfeb45146109b1578063d95ad45c146109c4578063db7e3648146109d7578063db7f92d4146109ea578063ddc6ac23146109fd57600080fd5b8063d03c027314610971578063d27c079714610979578063d69fb66814610982578063d728e9101461098b578063d7efa1291461099e57600080fd5b8063a6644f96116101d4578063bdcc22e911610198578063bdcc22e914610922578063be9a65551461092b578063c3b83f5f14610933578063c992528814610946578063c9f4ff461461095e57600080fd5b8063a6644f96146108b8578063a8df539f146108e6578063b562a1ab146108f3578063b6b55f25146108fc578063b9b1be8b1461090f57600080fd5b80638b649b941161021b5780638b649b94146108615780638b8444121461086a5780638c54c812146108725780638da5cb5b146108925780639bd2e61b146108a557600080fd5b80636c321c8a1461080a57806374094edd1461081357806377332fc51461083357806379ba5097146108465780637a1e0aa81461084e57600080fd5b80634218c4d8116103735780635c7b396e116102f0578063634e0d97116102b4578063634e0d9714610796578063645006ca146107c457806365e0e725146107cd5780636685fdc2146107e0578063681312f5146107f757600080fd5b80635c7b396e146107295780635c975abb146107325780635ddd3e831461073a578063610589e1146107655780636131dc711461076e57600080fd5b80634d549a42116103375780634d549a42146106d557806353a47bb7146106e857806353e8bdb7146106fb578063582ab2f91461070357806358c09cc01461071657600080fd5b80634218c4d81461065e5780634651f0801461066657806348663e951461068f5780634a96fc84146106a25780634ae7937f146106b557600080fd5b80631daae17311610401578063336d30ed116103c5578063336d30ed146105f2578063343e4f9f146106125780633ab76e9f146106255780633b92d7581461063857806340774ff61461064b57600080fd5b80631daae173146105625780631f2698ab14610595578063202ffce8146105a957806327c28442146105bc578063311c56df146105ea57600080fd5b8063146ca53111610448578063146ca531146105175780631627540c1461052057806316c38b3c146105335780631b2a52d8146105465780631baa88561461055957600080fd5b806303d868db1461048557806309b17b3d146104ae57806312b19a13146104c357806313af4035146104e4578063145dee7d146104f7575b600080fd5b610498610493366004615387565b610a9a565b6040516104a591906153a9565b60405180910390f35b6104c16104bc3660046153bd565b610ad2565b005b6104d66104d13660046153d6565b610de6565b6040519081526020016104a5565b6104c16104f2366004615404565b610e14565b6104d66105053660046153d6565b6000908152600f602052604090205490565b6104d660055481565b6104c161052e366004615404565b610f2b565b6104c161054136600461542f565b610f7e565b6104c16105543660046153d6565b610f9e565b6104d660075481565b610585610570366004615404565b600d6020526000908152604090205460ff1681565b60405190151581526020016104a5565b60045461058590600160a01b900460ff1681565b6104c16105b73660046153d6565b6114f2565b6105856105ca36600461544c565b601160209081526000928352604080842090915290825290205460ff1681565b6104c161152f565b6104d66106003660046153d6565b60146020526000908152604090205481565b610498610620366004615387565b61173f565b602154610498906001600160a01b031681565b601954610498906001600160a01b031681565b6104c16106593660046153d6565b61175b565b6104c16117c0565b6104986106743660046153d6565b6008602052600090815260409020546001600160a01b031681565b601f54610498906001600160a01b031681565b6104c16106b03660046153d6565b6117d4565b6104d66106c33660046153d6565b600c6020526000908152604090205481565b6104c16106e3366004615404565b611847565b600154610498906001600160a01b031681565b6104c16118c1565b6104c161071136600461547c565b6118f7565b6104c16107243660046154b1565b611a8b565b6104d6601d5481565b610585611ebd565b6104d661074836600461544c565b600b60209081526000928352604080842090915290825290205481565b6104d660175481565b61078161077c3660046154dd565b611ed2565b604080519283529015156020830152016104a5565b6105856107a436600461544c565b600a60209081526000928352604080842090915290825290205460ff1681565b6104d660165481565b6104c16107db366004615404565b611f83565b6005546000908152600960205260409020546104d6565b6104c16108053660046153d6565b611ffc565b6104d6601e5481565b6104d66108213660046153d6565b60136020526000908152604090205481565b610498610841366004615404565b6120a1565b6104c16120d0565b6104c161085c3660046154b1565b6121a8565b6104d660065481565b6104c1612238565b6104d6610880366004615404565b60126020526000908152604090205481565b600054610498906001600160a01b031681565b6104c16108b33660046153d6565b612513565b6105856108c636600461544c565b601060209081526000928352604080842090915290825290205460ff1681565b601c546105859060ff1681565b6104d660225481565b6104c161090a3660046153d6565b6127ad565b601a54610498906001600160a01b031681565b6104d660185481565b6104c16129b1565b6104c1610941366004615404565b612b4e565b6003546104989061010090046001600160a01b031681565b6104d661096c366004615387565b612c3e565b610585612c7e565b6104d660155481565b6104d660205481565b6104c16109993660046155ee565b612c8f565b6104c16109ac3660046154b1565b6130ad565b600454610498906001600160a01b031681565b6105856109d2366004615404565b6131e0565b6104d66109e5366004615404565b61329f565b6104c16109f83660046153d6565b613556565b6104d6610a0b3660046153d6565b613593565b6104c1610a1e3660046153d6565b6135a4565b6104c16135e1565b6104c1610a39366004615404565b6139f5565b610585613b80565b6104c1610a543660046153d6565b613b8d565b6104c1613bde565b610585613c3c565b6104d6610a77366004615404565b600e6020526000908152604090205481565b6104d6613d78565b6104d6601b5481565b600f6020528160005260406000208181548110610ab657600080fd5b6000918252602090912001546001600160a01b03169150829050565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a008054600160401b810460ff16159067ffffffffffffffff16600081158015610b185750825b905060008267ffffffffffffffff166001148015610b355750303b155b905081158015610b43575080155b15610b615760405163f92ee8a960e01b815260040160405180910390fd5b845467ffffffffffffffff191660011785558315610b8b57845460ff60401b1916600160401b1785555b610b9b6104f26020880188615404565b610ba3613bde565b610bb36040870160208801615404565b600380546001600160a01b039290921661010002610100600160a81b0319909216919091179055610bea6060870160408801615404565b602180546001600160a01b0319166001600160a01b0392909216919091179055610c1a6080870160608801615404565b600480546001600160a01b0319166001600160a01b0392909216919091179055610160860135602255608086013560065560a086013560155560c086013560165560e0860135601755670de0b6b3a76400006101008701351115610c995760405162461bcd60e51b8152600401610c90906156b9565b60405180910390fd5b610100860135601e55610cb461014087016101208801615404565b601f80546001600160a01b0319166001600160a01b0392909216919091179055670de0b6b3a76400006101408701351115610d015760405162461bcd60e51b8152600401610c90906156fb565b61014086013560209081556004546001600160a01b03169063095ea7b390610d2f9060408a01908a01615404565b6000196040518363ffffffff1660e01b8152600401610d4f92919061573c565b6020604051808303816000875af1158015610d6e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d929190615755565b5060016005558315610dde57845460ff60401b19168555604051600181527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15b505050505050565b600654600090610df7600184615788565b610e01919061579b565b600754610e0e91906157b2565b92915050565b6001600160a01b038116610e665760405162461bcd60e51b815260206004820152601960248201527804f776e657220616464726573732063616e6e6f74206265203603c1b6044820152606401610c90565b600154600160a01b900460ff1615610ed25760405162461bcd60e51b815260206004820152602960248201527f416c726561647920696e697469616c697a65642c20757365206e6f6d696e617460448201526832a732bba7bbb732b960b91b6064820152608401610c90565b6001805460ff60a01b1916600160a01b179055600080546001600160a01b0383166001600160a01b0319909116178155604051600080516020615cdb83398151915291610f209184906157c5565b60405180910390a150565b610f33613e6f565b600180546001600160a01b0319166001600160a01b0383161790556040517f906a1c6bd7e3091ea86693dd029a831c19049ce77f1dce2ce0bab1cacbabce2290610f209083906153a9565b610f86613e6f565b80610f9657610f93613ee1565b50565b610f93613f2d565b600160026000828254610fb191906157b2565b9091555050600254610fc1613f74565b601c5460ff16610fe35760405162461bcd60e51b8152600401610c90906157df565b600554600090815260096020526040902054601d54106110455760405162461bcd60e51b815260206004820152601b60248201527f416c6c20757365727320616c72656164792070726f63657373656400000000006044820152606401610c90565b600082116110655760405162461bcd60e51b8152600401610c9090615816565b600554600090815260086020526040812054601d546001600160a01b0390911691906110929085906157b2565b6005546000908152600960205260409020549091508111156110c257506005546000908152600960205260409020545b601d545b8181101561148e5760055460009081526009602052604081208054839081106110f1576110f1615859565b6000918252602080832090910154600554835260138252604080842054600b84528185206001600160a01b0390931680865292909352832054909350670de0b6b3a7640000916111409161579b565b61114a919061586f565b6001600160a01b0383166000908152600d602052604090205490915060ff16158015611186575060055460009081526013602052604090205415155b156112765780600b6000600554600161119f91906157b2565b81526020019081526020016000206000846001600160a01b03166001600160a01b03168152602001908152602001600020546111db91906157b2565b600b600060055460016111ee91906157b2565b81526020019081526020016000206000846001600160a01b03166001600160a01b031681526020019081526020016000208190555060096000600554600161123691906157b2565b8152602080820192909252604001600090812080546001810182559082529190200180546001600160a01b0319166001600160a01b038416179055611468565b6001600160a01b0382166000908152600e6020526040902054156113d1576001600160a01b0382166000908152600e6020526040812054670de0b6b3a7640000906112c1908461579b565b6112cb919061586f565b6004549091506112e6906001600160a01b0316878584613f9a565b600080516020615cfb833981519152838260405161130592919061573c565b60405180910390a16001600160a01b0383166000908152600d60209081526040808320805460ff19169055600e90915281208190556005546009919061134c9060016157b2565b8152602080820192909252604001600090812080546001810182559082529190200180546001600160a01b0319166001600160a01b0385161790556113918183615788565b600b600060055460016113a491906157b2565b8152602080820192909252604090810160009081206001600160a01b038816825290925290205550611468565b6000600b600060055460016113e691906157b2565b8152602080820192909252604090810160009081206001600160a01b0380881683529352209190915560045461141f9116868484613f9a565b6001600160a01b0382166000908152600d602052604090819020805460ff1916905551600080516020615cfb8339815191529061145f908490849061573c565b60405180910390a15b601d546114769060016157b2565b601d555081905061148681615891565b9150506110c6565b5060055460408051918252602082018690527f2e692c8fcabe33ba22535323e79dcb54ef22dccdb8e4ebdd9f2a7ffb1a28856c910160405180910390a1505060025481146114ee5760405162461bcd60e51b8152600401610c90906158aa565b5050565b6114fa613e6f565b60178190556040518181527fe7c2c09f66c8b970b4a99250f4d0844e1496b9d51d4760a17b0134ddd52023e190602001610f20565b60016002600082825461154291906157b2565b9091555050600254600454600160a01b900460ff166115735760405162461bcd60e51b8152600401610c90906158e1565b336000908152600d602052604090205460ff16156115a35760405162461bcd60e51b8152600401610c909061590f565b6005546000908152600b602090815260408083203384529091529020546115dc5760405162461bcd60e51b8152600401610c9090615946565b600b600060055460016115ef91906157b2565b8152602080820192909252604090810160009081203382529092529020541561162a5760405162461bcd60e51b8152600401610c9090615973565b611632613f74565b601c5460ff16156116555760405162461bcd60e51b8152600401610c90906159c9565b6005546000908152600b60209081526040808320338452909152902054601b5411156116b6576005546000908152600b60209081526040808320338452909152812054601b8054919290916116ab908490615788565b909155506116bc9050565b6000601b555b60016018546116cb9190615788565b601855336000818152600d602052604090819020805460ff19166001179055517fe5892ff2a8b08efb903ffbba1f0514c1d3e22eea34dd5b89cf30aabce03dde5a91611716916153a9565b60405180910390a16002548114610f935760405162461bcd60e51b8152600401610c90906158aa565b60096020528160005260406000208181548110610ab657600080fd5b611763613e6f565b670de0b6b3a764000081111561178b5760405162461bcd60e51b8152600401610c90906156b9565b601e8190556040518181527fc117ccf765672707ebe3c1606037488c1e27dc1f42b5266e3d6b496db7d4209e90602001610f20565b6117c8613f74565b6117d26001613ff4565b565b6001600260008282546117e791906157b2565b90915550506002546117f7613f74565b601c5460ff161561181a5760405162461bcd60e51b8152600401610c90906159c9565b61182682600554614060565b60025481146114ee5760405162461bcd60e51b8152600401610c90906158aa565b61184f613e6f565b6001600160a01b0381166118755760405162461bcd60e51b8152600401610c9090615a10565b601a80546001600160a01b0319166001600160a01b0383169081179091556040517fa65a5aa86bb6f8e75752296da3ebda45474c8a302fc640c3b62868793862a03391610f20916153a9565b601c5460ff16156118e45760405162461bcd60e51b8152600401610c90906159c9565b6118ec613f74565b6117d2600554613ff4565b60005433906001600160a01b03168114806119f35750600360019054906101000a90046001600160a01b03166001600160a01b031663481c6a756040518163ffffffff1660e01b8152600401602060405180830381865afa158015611960573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119849190615a47565b6001600160a01b031663e760c3958260026040518363ffffffff1660e01b81526004016119b2929190615a7a565b602060405180830381865afa1580156119cf573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119f39190615755565b611a0f5760405162461bcd60e51b8152600401610c9090615aa7565b601c5460ff1615611a325760405162461bcd60e51b8152600401610c90906159c9565b6000611a3d8561329f565b90506005548114611a605760405162461bcd60e51b8152600401610c9090615acf565b611a84858515611a705785611a7e565b600554611a7e9060016157b2565b856140ec565b5050505050565b600160026000828254611a9e91906157b2565b9091555050600254611aae613f74565b60035461010090046001600160a01b03163314611add5760405162461bcd60e51b8152600401610c9090615b00565b601c5460ff1615611b005760405162461bcd60e51b8152600401610c90906159c9565b600454600160a01b900460ff16611b295760405162461bcd60e51b8152600401610c90906158e1565b60008211611b755760405162461bcd60e51b815260206004820152601960248201527843616e277420636f6d6d69742061207a65726f20747261646560381b6044820152606401610c90565b6000611b808461329f565b6001600160a01b0385166000908152601260205260408120829055909150611ba78261457c565b90506005548203611cfe57600354600454611bd6916001600160a01b0391821691849161010090041687613f9a565b601e546005546000908152600c6020526040902054670de0b6b3a764000091611bfe9161579b565b611c08919061586f565b6005546000908152600c6020526040902054611c249190615788565b600480546040516370a0823160e01b81526001600160a01b03909116916370a0823191611c53918691016153a9565b602060405180830381865afa158015611c70573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c949190615b46565b1015611cf95760405162461bcd60e51b815260206004820152602e60248201527f416d6f756e74206578636565647320617661696c61626c65207574696c697a6160448201526d1d1a5bdb88199bdc881c9bdd5b9960921b6064820152608401610c90565b611e3b565b600554821115611df257600480546040516370a0823160e01b81526000926001600160a01b03909216916370a0823191611d3a918691016153a9565b602060405180830381865afa158015611d57573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d7b9190615b46565b9050848110611dad57600354600454611da8916001600160a01b0391821691859161010090041688613f9a565b611dec565b6000611db98287615788565b9050611dc681848661475a565b600354600454611dea916001600160a01b0391821691869161010090041689613f9a565b505b50611e3b565b81600114611e325760405162461bcd60e51b815260206004820152600d60248201526c125b9d985b1a59081c9bdd5b99609a1b6044820152606401610c90565b611e3b84614838565b506000818152600f602090815260408083208054600180820183559185528385200180546001600160a01b0319166001600160a01b038a1690811790915594845260108352818420948452939091529020805460ff191690911790556002548114611eb85760405162461bcd60e51b8152600401610c90906158aa565b505050565b600080611ec861494a565b5460ff1692915050565b6000838152600f6020526040812054819081908410611eff576000868152600f6020526040902054611f01565b835b9050845b81811015611f70576000878152600f6020526040902080546001600160a01b038a16919083908110611f3957611f39615859565b6000918252602090912001546001600160a01b031603611f6057925060019150611f7a9050565b611f6981615891565b9050611f05565b5083600092509250505b94509492505050565b611f8b613e6f565b6001600160a01b038116611fb15760405162461bcd60e51b8152600401610c9090615a10565b601980546001600160a01b0319166001600160a01b0383161790556040517faaf6f0738515c3cf390f1b3faec649d2dacb169d024089afc43bbe2fe66cd2d890610f209083906153a9565b612004613e6f565b600454600160a01b900460ff161561206c5760405162461bcd60e51b815260206004820152602560248201527f43616e2774206368616e676520726f756e64206c656e677468206166746572206044820152641cdd185c9d60da1b6064820152608401610c90565b60068190556040518181527f1d1fb7111c3779798bd4aefb2daea07ee8257a13c7eaceba89b4b1ccd405050d90602001610f20565b6000600860006120b08461329f565b81526020810191909152604001600020546001600160a01b031692915050565b6001546001600160a01b031633146121485760405162461bcd60e51b815260206004820152603560248201527f596f75206d757374206265206e6f6d696e61746564206265666f726520796f7560448201527402063616e20616363657074206f776e65727368697605c1b6064820152608401610c90565b600054600154604051600080516020615cdb83398151915292612179926001600160a01b03918216929116906157c5565b60405180910390a160018054600080546001600160a01b03199081166001600160a01b03841617909155169055565b6121b0613e6f565b601f80546001600160a01b0319166001600160a01b038416179055602054670de0b6b3a764000010156121f55760405162461bcd60e51b8152600401610c90906156fb565b60208190556040517fa1a8623472ca4e2879372be60dfd1ff0675778e49f7379eedd98ca57cf36b21a9061222c908490849061573c565b60405180910390a15050565b60016002600082825461224b91906157b2565b909155505060025461225b613f74565b601c5460ff161561227e5760405162461bcd60e51b8152600401610c90906159c9565b612286613c3c565b6122ce5760405162461bcd60e51b815260206004820152601960248201527810d85b89dd0818db1bdcd94818dd5c9c995b9d081c9bdd5b99603a1b6044820152606401610c90565b6122d66118c1565b600554600090815260086020526040808220546004805492516370a0823160e01b81526001600160a01b039283169493909216916370a082319161231c918691016153a9565b602060405180830381865afa158015612339573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061235d9190615b46565b6005546000908152600c602052604090205490915081111561242c57602080546005546000908152600c9092526040822054670de0b6b3a764000091906123a49085615788565b6123ae919061579b565b6123b8919061586f565b601f546004549192506123da916001600160a01b039081169186911684613f9a565b6123e48183615788565b91507fb8379d05082aa2dd32963972d72cc2d46257811133341855b63bb2fddda6ca3e60205482604051612422929190918252602082015260400190565b60405180910390a1505b6005546000908152600c60205260408120549003612465576005546000908152601360205260409020670de0b6b3a764000090556124a6565b6005546000908152600c6020526040902054612489670de0b6b3a76400008361579b565b612493919061586f565b6005546000908152601360205260409020555b601c805460ff191660011790556005546040517fa224cce482b24082d1d3128437615f7f5ce87b97453a11114846ea442a100272916124e89190815260200190565b60405180910390a150506002548114610f935760405162461bcd60e51b8152600401610c90906158aa565b60016002600082825461252691906157b2565b9091555050600254600454600160a01b900460ff166125575760405162461bcd60e51b8152600401610c90906158e1565b336000908152600d602052604090205460ff16156125875760405162461bcd60e51b8152600401610c909061590f565b6005546000908152600b602090815260408083203384529091529020546125c05760405162461bcd60e51b8152600401610c9090615946565b600b600060055460016125d391906157b2565b8152602080820192909252604090810160009081203382529092529020541561260e5760405162461bcd60e51b8152600401610c9090615973565b612616613f74565b601c5460ff16156126395760405162461bcd60e51b8152600401610c90906159c9565b61264b662386f26fc10000600a61579b565b821015801561266b5750612667662386f26fc10000605a61579b565b8211155b6126c35760405162461bcd60e51b815260206004820152602360248201527f53686172652068617320746f206265206265747765656e2031302520616e642060448201526239302560e81b6064820152608401610c90565b6005546000908152600b60209081526040808320338452909152812054670de0b6b3a7640000906126f590859061579b565b6126ff919061586f565b905080601b5411156127285780601b600082825461271d9190615788565b9091555061272e9050565b6000601b555b336000818152600d60209081526040808320805460ff19166001179055600e90915290819020859055517fe5892ff2a8b08efb903ffbba1f0514c1d3e22eea34dd5b89cf30aabce03dde5a91612783916153a9565b60405180910390a15060025481146114ee5760405162461bcd60e51b8152600401610c90906158aa565b336000908152600d6020526040902054819060ff161561281f5760405162461bcd60e51b815260206004820152602760248201527f5769746864726177616c206973207265717565737465642c2063616e6e6f742060448201526619195c1bdcda5d60ca1b6064820152608401610c90565b60155481601b5461283091906157b2565b11156128885760405162461bcd60e51b815260206004820152602160248201527f4465706f73697420616d6f756e74206578636565647320414d4d204c502063616044820152600760fc1b6064820152608401610c90565b6005546000908152600b602090815260408083203384529091529020541580156128e05750600b600060055460016128c091906157b2565b815260208082019290925260409081016000908120338252909252902054155b15612941576016548110156129415760405162461bcd60e51b815260206004820152602160248201527f416d6f756e74206c657373207468616e206d696e4465706f736974416d6f756e6044820152601d60fa1b6064820152608401610c90565b60016002600082825461295491906157b2565b9091555050600254612964613f74565b601c5460ff16156129875760405162461bcd60e51b8152600401610c90906159c9565b6129908361496e565b6002548114611eb85760405162461bcd60e51b8152600401610c90906158aa565b6129b9613e6f565b600454600160a01b900460ff1615612a0c5760405162461bcd60e51b81526020600482015260166024820152751314081a185cc8185b1c9958591e481cdd185c9d195960521b6044820152606401610c90565b6002600052600c6020527f5d6016397a73f5e079297ac5a36fef17b4d9c3831618e63ab105738020ddd72054612a845760405162461bcd60e51b815260206004820152601d60248201527f43616e206e6f7420737461727420776974682030206465706f736974730000006044820152606401610c90565b4260075560026005819055600090612a9b9061457c565b9050806001600160a01b0316637d3de7ce600754612ab96002610de6565b6040516001600160e01b031960e085901b16815260048101929092526024820152604401600060405180830381600087803b158015612af757600080fd5b505af1158015612b0b573d6000803e3d6000fd5b50506004805460ff60a01b1916600160a01b17905550506040517f960682678fca98f3ed131eaf165e59544bcd738e948f0b3c64f58fa9e1c65e6090600090a150565b612b56613e6f565b6001600160a01b038116612b9e5760405162461bcd60e51b815260206004820152600f60248201526e496e76616c6964206164647265737360881b6044820152606401610c90565b600154600160a81b900460ff1615612bee5760405162461bcd60e51b8152602060048201526013602482015272105b1c9958591e481d1c985b9cd9995c9c9959606a1b6044820152606401610c90565b600080546001600160a01b0383166001600160a01b031990911681179091556001805460ff60a81b1916600160a81b179055604051600080516020615cdb83398151915291610f209184906157c5565b6000828152601460208181526040808420546013835281852054868652939092528320549091612c6d9161579b565b612c77919061586f565b9392505050565b6000612c8a6001614b74565b905090565b60005433906001600160a01b0316811480612d8b5750600360019054906101000a90046001600160a01b03166001600160a01b031663481c6a756040518163ffffffff1660e01b8152600401602060405180830381865afa158015612cf8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612d1c9190615a47565b6001600160a01b031663e760c3958260026040518363ffffffff1660e01b8152600401612d4a929190615a7a565b602060405180830381865afa158015612d67573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612d8b9190615755565b612da75760405162461bcd60e51b8152600401610c9090615aa7565b601c5460ff1615612dca5760405162461bcd60e51b8152600401610c90906159c9565b8215612dd65782612de4565b600554612de49060016157b2565b92508151600003612e385760005b8451811015612e3257612e20858281518110612e1057612e10615859565b60200260200101518560006140ec565b80612e2a81615891565b915050612df2565b506130a7565b8151845114612e825760405162461bcd60e51b8152602060048201526016602482015275082e4e4c2f2e698cadccee8d0e69aeae6e89ac2e8c6d60531b6044820152606401610c90565b6005546000908152600f6020526040812054905b8551811015610dde576000848281518110612eb357612eb3615859565b602002602001015111612f085760405162461bcd60e51b815260206004820152601d60248201527f5469636b6574496e6465784d7573744265477265617465725468616e300000006044820152606401610c90565b612f128183615788565b848281518110612f2457612f24615859565b60200260200101511015612f7457612f6f868281518110612f4757612f47615859565b602002602001015186868481518110612f6257612f62615859565b60200260200101516140ec565b613095565b6000805b855182101561301557878381518110612f9357612f93615859565b60200260200101516001600160a01b0316600f60006005548152602001908152602001600020878481518110612fcb57612fcb615859565b602002602001015181548110612fe357612fe3615859565b6000918252602090912001546001600160a01b03160361300557506001613015565b61300e82615891565b9150612f78565b806130625760405162461bcd60e51b815260206004820152601a60248201527f5469636b65744e6f74466f756e64496e496e70757441727261790000000000006044820152606401610c90565b61309288848151811061307757613077615859565b602002602001015188888581518110612f6257612f62615859565b50505b8061309f81615891565b915050612e96565b50505050565b6130b5613f74565b601c5460ff16156130d85760405162461bcd60e51b8152600401610c90906159c9565b60035461010090046001600160a01b031633146131075760405162461bcd60e51b8152600401610c9090615b00565b60006131128361329f565b9050600181118015613125575060055481105b1561312f57506005545b8115613183576000600182111561314e576131498261457c565b61315b565b6019546001600160a01b03165b600354600454919250613181916001600160a01b03908116916101009004168386613f9a565b505b60008181526010602090815260408083206001600160a01b038716845290915290205460ff1615611eb85760008181526011602090815260408083206001600160a01b03871684529091529020805460ff19166001179055505050565b6005546000908152600b602090815260408083206001600160a01b038516845290915281205415158061325757506000600b6000600554600161322391906157b2565b81526020019081526020016000206000846001600160a01b03166001600160a01b0316815260200190815260200160002054115b8015610e0e57506001600160a01b0382166000908152600d602052604090205460ff161580610e0e5750506001600160a01b03166000908152600e6020526040902054151590565b6001600160a01b038116600090815260126020526040812054908190036135515781600080805b836001600160a01b03166362e5c8196040518163ffffffff1660e01b8152600401602060405180830381865afa158015613304573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906133289190615b46565b81101561354c5760405163b1283e7760e01b8152600481018290526001600160a01b0385169063b1283e779060240161012060405180830381865afa158015613375573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906133999190615b82565b505060215460405163bf40fac160e01b815260206004820152601660248201527529b837b93a39a0a6a6ab192934b9b5a6b0b730b3b2b960511b6044820152949a5095985060009650506001600160a01b03909416935063bf40fac1925050606401602060405180830381865afa158015613418573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061343c9190615a47565b6040516349ef3bc960e11b815261ffff851660048201526001600160a01b0391909116906393de779290602401602060405180830381865afa158015613486573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906134aa9190615755565b9050600754841180156134bb575080155b1561352f57816000036134f4576006546007546134d89086615788565b6134e2919061586f565b6134ed9060026157b2565b9550613539565b85600654600754866135069190615788565b613510919061586f565b61351b9060026157b2565b1461352a57600195505061354c565b613539565b600195505061354c565b508061354481615891565b9150506132c6565b505050505b919050565b61355e613e6f565b60168190556040518181527f990717cc219e5348c1b88bb0ff530d804f0b6f54f3b03844a2bfbe4eb1e9c5d690602001610f20565b600654600090610df7600284615788565b6135ac613e6f565b60158190556040518181527f8c43aa02599ac8f8bab4724621ceea5e7a06b07bbbfaf3b7bd0386cbe481ea3c90602001610f20565b6001600260008282546135f491906157b2565b9091555050600254613604613f74565b601c5460ff166136265760405162461bcd60e51b8152600401610c90906157df565b600554600090815260096020526040902054601d54146136885760405162461bcd60e51b815260206004820152601b60248201527f4e6f7420616c6c2075736572732070726f6365737365642079657400000000006044820152606401610c90565b601c805460ff19169055600554600090815260086020908152604080832054600b83528184206019546001600160a01b03908116865293529220549116901561377157600554600090815260136020908152604080832054600b83528184206019546001600160a01b03168552909252822054670de0b6b3a76400009161370e9161579b565b613718919061586f565b60195460045491925061373a916001600160a01b039081169185911684613f9a565b601954604051600080516020615cfb83398151915291613767916001600160a01b0390911690849061573c565b60405180910390a1505b60055460020361379e57600554600090815260136020908152604080832054601490925290912055613801565b600554600081815260136020526040812054670de0b6b3a76400009290916014916137cb90600190615788565b8152602001908152602001600020546137e4919061579b565b6137ee919061586f565b6005546000908152601460205260409020555b60056000815461381090615891565b90915550600480546040516370a0823160e01b81526001600160a01b03909116916370a0823191613843918591016153a9565b602060405180830381865afa158015613860573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906138849190615b46565b6005546000908152600c6020526040812080549091906138a59084906157b2565b90915550506005546000818152600b602090815260408083206019546001600160a01b03168452825280832054938352600c9091529020546138e79190615788565b601b556005546000906138f99061457c565b600480546040516370a0823160e01b815292935061398692859285926001600160a01b0316916370a0823191613931918691016153a9565b602060405180830381865afa15801561394e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906139729190615b46565b6004546001600160a01b0316929190613f9a565b6000601d556005547fc67dda8e11f1aa941c7e74466b1859a07a32f46aaf641d29b83be348424d93cd906139bc90600190615788565b6013600060016005546139cf9190615788565b8152602001908152602001600020546040516124e8929190918252602082015260400190565b6139fd613e6f565b6001600160a01b038116613a235760405162461bcd60e51b8152600401610c9090615a10565b60035461010090046001600160a01b031615613ab8576004805460035460405163095ea7b360e01b81526001600160a01b039283169363095ea7b393613a7393610100900416916000910161573c565b6020604051808303816000875af1158015613a92573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613ab69190615755565b505b60038054610100600160a81b0319166101006001600160a01b03848116820292909217928390556004805460405163095ea7b360e01b81529084169463095ea7b394613b0d949091041691600019910161573c565b6020604051808303816000875af1158015613b2c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613b509190615755565b507f576297e5fcc8cd907ee80b240284865eb3d821bdc5232e6ee9e4d78a12531c0981604051610f2091906153a9565b6000612c8a600554614b74565b600160026000828254613ba091906157b2565b9091555050600254613bb0613f74565b601c5460ff1615613bd35760405162461bcd60e51b8152600401610c90906159c9565b611826826001614060565b60035460ff1615613c275760405162461bcd60e51b8152602060048201526013602482015272105b1c9958591e481a5b9a5d1a585b1a5e9959606a1b6044820152606401610c90565b6003805460ff19166001908117909155600255565b600454600090600160a01b900460ff161580613c615750613c5e600554610de6565b42105b15613c6c5750600090565b60008060005b6005546000908152600f6020526040902054811015613d6e576005546000908152600f60205260409020805482908110613cae57613cae615859565b600091825260208083209091015460055483526011825260408084206001600160a01b039092168085529190925291205490925060ff16613d5c57819250826001600160a01b031663b0c56f056040518163ffffffff1660e01b8152600401602060405180830381865afa158015613d2a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613d4e9190615755565b613d5c576000935050505090565b80613d6681615891565b915050613c72565b5060019250505090565b60215460405163bf40fac160e01b8152602060048201526009602482015268141c9a58d95199595960ba1b60448201526000916001600160a01b03169063bf40fac190606401602060405180830381865afa158015613ddb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613dff9190615a47565b6001600160a01b031663ac82f6086022546040518263ffffffff1660e01b8152600401613e2e91815260200190565b602060405180830381865afa158015613e4b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612c8a9190615b46565b6000546001600160a01b031633146117d25760405162461bcd60e51b815260206004820152602f60248201527f4f6e6c792074686520636f6e7472616374206f776e6572206d6179207065726660448201526e37b936903a3434b99030b1ba34b7b760891b6064820152608401610c90565b613ee9614ce6565b6000613ef361494a565b805460ff1916815590507f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b604051610f2091906153a9565b613f35613f74565b6000613f3f61494a565b805460ff1916600117815590507f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258613f203390565b613f7c611ebd565b156117d25760405163d93c066560e01b815260040160405180910390fd5b604080516001600160a01b0385811660248301528416604482015260648082018490528251808303909101815260849091019091526020810180516001600160e01b03166323b872dd60e01b1790526130a7908590614d0b565b60005b6000828152600f60205260409020548110156114ee576000828152600f60205260409020805461404d9184918490811061403357614033615859565b6000918252602090912001546001600160a01b0316614d65565b508061405881615891565b915050613ff7565b600082116140805760405162461bcd60e51b8152600401610c9090615816565b6000805b6000838152600f60205260409020548110156130a7578184146130a7576000838152600f6020526040902080546140c79185918490811061403357614033615859565b156140da576140d76001836157b2565b91505b806140e481615891565b915050614084565b6005548211806140fc5750816001145b61413d5760405162461bcd60e51b8152602060048201526012602482015271149bdd5b99105b1c9958591e50db1bdcd95960721b6044820152606401610c90565b60006141488461329f565b9050600554811461419b5760405162461bcd60e51b815260206004820152601b60248201527f5469636b6574206e6f7420696e2063757272656e7420726f756e6400000000006044820152606401610c90565b60008181526010602090815260408083206001600160a01b038816845290915290205460ff166141dd5760405162461bcd60e51b8152600401610c9090615acf565b60008181526011602090815260408083206001600160a01b038816845290915290205460ff16156142495760405162461bcd60e51b8152602060048201526016602482015275151a58dad95d105b1c9958591e515e195c98da5cd95960521b6044820152606401610c90565b836001600160a01b0316633f6fa6556040518163ffffffff1660e01b8152600401602060405180830381865afa158015614287573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906142ab9190615755565b156142f05760405162461bcd60e51b8152602060048201526015602482015274151a58dad95d105b1c9958591e54995cdbdb1d9959605a1b6044820152606401610c90565b60008181526010602090815260408083206001600160a01b03881684529091529020805460ff19169055614325818584615020565b60006143308261457c565b9050600061433d8561457c565b90506000866001600160a01b031663d165dac26040518163ffffffff1660e01b8152600401602060405180830381865afa15801561437f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906143a39190615b46565b600480546040516370a0823160e01b81526001600160a01b03909116916370a08231916143d2918c91016153a9565b602060405180830381865afa1580156143ef573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906144139190615b46565b61441d9190615788565b600480546040516370a0823160e01b81529293506000926001600160a01b03909116916370a0823191614452918791016153a9565b602060405180830381865afa15801561446f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906144939190615b46565b9050808211156144b85760006144a98284615788565b90506144b681858a61475a565b505b6004546144d0906001600160a01b0316848685613f9a565b6001600160a01b03881660008181526012602090815260408083208b90558a8352601082528083208484528252808320805460ff191660019081179091558b8452600f8352818420805491820181558452919092200180546001600160a01b031916909217909155517fd8edac6470af12f863b07d43de4b58079798e80230a8b7f899a4f55ecdac61809061456a908a9088908b90615c28565b60405180910390a15050505050505050565b6000818152600860205260409020546001600160a01b03168061355157816001036145d6575060198054600083815260086020526040902080546001600160a01b0319166001600160a01b03928316179055905416919050565b601a546001600160a01b031661462e5760405162461bcd60e51b815260206004820152601d60248201527f526f756e6420706f6f6c206d6173746572636f7079206e6f74207365740000006044820152606401610c90565b601a54600090614646906001600160a01b031661521c565b6004549091506001600160a01b038083169163d13f90b491309116866146706104d1600183615788565b61467989610de6565b6040516001600160e01b031960e088901b1681526001600160a01b03958616600482015294909316602485015260448401919091526064830152608482015260a401600060405180830381600087803b1580156146d557600080fd5b505af11580156146e9573d6000803e3d6000fd5b50505060008481526008602090815260409182902080546001600160a01b0319166001600160a01b03861690811790915582518781529182015292935083927f24c1b21b902a85b5039d7d72427d9376657229eea77880ec9e62031dc950f6ba92500160405180910390a150919050565b6019546001600160a01b03166147825760405162461bcd60e51b8152600401610c9090615c49565b6019546004546147a0916001600160a01b0391821691168486613f9a565b6000818152600b602090815260408083206019546001600160a01b03168452909152812080548592906147d49084906157b2565b90915550506000818152600c6020526040812080548592906147f79084906157b2565b9091555050601954604051600080516020615d1b8339815191529161482b916001600160a01b039091169086908590615c28565b60405180910390a1505050565b6019546001600160a01b03166148605760405162461bcd60e51b8152600401610c9090615c49565b60195460035460045461488a926001600160a01b0391821692908216916101009091041684613f9a565b6019546001600160a01b031660009081527f72c6bfb7988af3a1efa6568f02a999bc52252641c659d85961ca3d372b57d5cf6020526040812080548392906148d39084906157b2565b909155505060016000908152600c6020527fd421a5181c571bba3f01190c922c3b2a896fc1d84e86c9f17ac10e67ebef8b5c80548392906149159084906157b2565b9091555050601954604051600080516020615d1b83398151915291610f20916001600160a01b03909116908490600190615c28565b7fcd5ed15c6e187e77e9aee88184c21f4f2182ab5827cb3b7e07fbedcd63f0330090565b6000600554600161497f91906157b2565b9050600061498c8261457c565b6004549091506149a7906001600160a01b0316338386613f9a565b6019546001600160a01b03163303614a0d5760405162461bcd60e51b8152602060048201526024808201527f43616e2774206465706f736974206469726563746c792061732064656661756c604482015263074204c560e41b6064820152608401610c90565b6005546000908152600b60209081526040808320338452909152902054158015614a4e57506000828152600b60209081526040808320338452909152902054155b15614ae75760175460185410614aa65760405162461bcd60e51b815260206004820152601b60248201527f4d617820616d6f756e74206f66207573657273207265616368656400000000006044820152606401610c90565b60008281526009602090815260408220805460018181018355918452919092200180546001600160a01b03191633179055601854614ae3916157b2565b6018555b6000828152600b6020908152604080832033845290915281208054859290614b109084906157b2565b90915550506000828152600c602052604081208054859290614b339084906157b2565b9250508190555082601b6000828254614b4c91906157b2565b9091555050600554604051600080516020615d1b8339815191529161482b9133918791615c28565b60008080805b6000858152600f6020526040902054811015614cdb576000858152600f60205260409020805482908110614bb057614bb0615859565b60009182526020808320909101548783526011825260408084206001600160a01b039092168085529190925291205490925060ff16614cc957819250826001600160a01b031663e74d3c476040518163ffffffff1660e01b8152600401602060405180830381865afa158015614c2a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614c4e9190615755565b8015614cb95750826001600160a01b0316633356a35a6040518163ffffffff1660e01b8152600401602060405180830381865afa158015614c93573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614cb79190615755565b155b15614cc957506001949350505050565b80614cd381615891565b915050614b7a565b506000949350505050565b614cee611ebd565b6117d257604051638dfc202b60e01b815260040160405180910390fd5b6000614d206001600160a01b03841683615289565b90508051600014158015614d45575080806020019051810190614d439190615755565b155b15611eb85782604051635274afe760e01b8152600401610c9091906153a9565b60008281526011602090815260408083206001600160a01b038516845290915281205460ff16610e0e5760008290506000816001600160a01b0316633356a35a6040518163ffffffff1660e01b8152600401602060405180830381865afa158015614dd4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614df89190615755565b90506000806001871115614e6b57836001600160a01b0316634652e3306040518163ffffffff1660e01b8152600401602060405180830381865afa158015614e44573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614e689190615755565b90505b808015614e7f5750614e7c87610de6565b42115b15614e8957600191505b836001600160a01b031663e74d3c476040518163ffffffff1660e01b8152600401602060405180830381865afa158015614ec7573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614eeb9190615755565b8015614efc5750821580614efc5750815b15614f6b57600354604051630f8a940b60e41b81526101009091046001600160a01b03169063f8a940b090614f38908990600090600401615c75565b600060405180830381600087803b158015614f5257600080fd5b505af1158015614f66573d6000803e3d6000fd5b505050505b828015614f76575080155b80614fde5750836001600160a01b0316633f6fa6556040518163ffffffff1660e01b8152600401602060405180830381865afa158015614fba573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614fde9190615755565b156150165760008781526011602090815260408083206001600160a01b038a1684529091529020805460ff1916600190811790915594505b5050505092915050565b6000816000036150ab5760005b6000858152600f60205260409020548110156150a5576000858152600f6020526040902080546001600160a01b03861691908390811061506f5761506f615859565b6000918252602090912001546001600160a01b03160361509557600191508092506150a5565b61509e81615891565b905061502d565b50615109565b6000848152600f60205260409020548210801561510657506000848152600f6020526040902080546001600160a01b0385169190849081106150ef576150ef615859565b6000918252602090912001546001600160a01b0316145b90505b806151475760405162461bcd60e51b815260206004820152600e60248201526d151a58dad95d139bdd119bdd5b9960921b6044820152606401610c90565b6000848152600f60205260409020805461516390600190615788565b8154811061517357615173615859565b6000918252602080832090910154868352600f909152604090912080546001600160a01b0390921691849081106151ac576151ac615859565b600091825260208083209190910180546001600160a01b0319166001600160a01b039490941693909317909255858152600f909152604090208054806151f4576151f4615c95565b600082815260209020810160001990810180546001600160a01b031916905501905550505050565b6000763d602d80600a3d3981f3363d3d373d3d3d363d730000008260601b60e81c176000526e5af43d82803e903d91602b57fd5bf38260781b17602052603760096000f090506001600160a01b038116613551576040516330be1a3d60e21b815260040160405180910390fd5b6060612c778383600084600080856001600160a01b031684866040516152af9190615cab565b60006040518083038185875af1925050503d80600081146152ec576040519150601f19603f3d011682016040523d82523d6000602084013e6152f1565b606091505b509150915061530186838361530b565b9695505050505050565b6060826153205761531b8261535e565b612c77565b815115801561533757506001600160a01b0384163b155b156153575783604051639996b31560e01b8152600401610c9091906153a9565b5080612c77565b80511561536e5780518082602001fd5b604051630a12f52160e11b815260040160405180910390fd5b6000806040838503121561539a57600080fd5b50508035926020909101359150565b6001600160a01b0391909116815260200190565b600061018082840312156153d057600080fd5b50919050565b6000602082840312156153e857600080fd5b5035919050565b6001600160a01b0381168114610f9357600080fd5b60006020828403121561541657600080fd5b8135612c77816153ef565b8015158114610f9357600080fd5b60006020828403121561544157600080fd5b8135612c7781615421565b6000806040838503121561545f57600080fd5b823591506020830135615471816153ef565b809150509250929050565b60008060006060848603121561549157600080fd5b833561549c816153ef565b95602085013595506040909401359392505050565b600080604083850312156154c457600080fd5b82356154cf816153ef565b946020939093013593505050565b600080600080608085870312156154f357600080fd5b84356154fe816153ef565b966020860135965060408601359560600135945092505050565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff8111828210171561555757615557615518565b604052919050565b600067ffffffffffffffff82111561557957615579615518565b5060051b60200190565b600082601f83011261559457600080fd5b813560206155a96155a48361555f565b61552e565b82815260059290921b840181019181810190868411156155c857600080fd5b8286015b848110156155e357803583529183019183016155cc565b509695505050505050565b60008060006060848603121561560357600080fd5b833567ffffffffffffffff8082111561561b57600080fd5b818601915086601f83011261562f57600080fd5b8135602061563f6155a48361555f565b82815260059290921b8401810191818101908a84111561565e57600080fd5b948201945b83861015615685578535615676816153ef565b82529482019490820190615663565b97505087013594505060408601359150808211156156a257600080fd5b506156af86828701615583565b9150509250925092565b60208082526022908201527f5574696c697a6174696f6e20726174652063616e277420657863656564203130604082015261302560f01b606082015260800190565b60208082526021908201527f5361666520426f7820696d706163742063616e277420657863656564203130306040820152602560f81b606082015260800190565b6001600160a01b03929092168252602082015260400190565b60006020828403121561576757600080fd5b8151612c7781615421565b634e487b7160e01b600052601160045260246000fd5b81810381811115610e0e57610e0e615772565b8082028115828204841417610e0e57610e0e615772565b80820180821115610e0e57610e0e615772565b6001600160a01b0392831681529116602082015260400190565b6020808252601a908201527f526f756e6420636c6f73696e67206e6f74207072657061726564000000000000604082015260600190565b60208082526023908201527f42617463682073697a652068617320746f20626520677265617465722074686160408201526206e20360ec1b606082015260800190565b634e487b7160e01b600052603260045260246000fd5b60008261588c57634e487b7160e01b600052601260045260246000fd5b500490565b6000600182016158a3576158a3615772565b5060010190565b6020808252601f908201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604082015260600190565b602080825260149082015273141bdbdb081a185cc81b9bdd081cdd185c9d195960621b604082015260600190565b6020808252601c908201527f5769746864726177616c20616c72656164792072657175657374656400000000604082015260600190565b6020808252601390820152724e6f7468696e6720746f20776974686472617760681b604082015260600190565b60208082526036908201527f43616e277420776974686472617720617320796f7520616c72656164792064656040820152751c1bdcda5d195908199bdc881b995e1d081c9bdd5b9960521b606082015260800190565b60208082526027908201527f4e6f7420616c6c6f77656420647572696e6720726f756e64436c6f73696e67506040820152661c995c185c995960ca1b606082015260800190565b6020808252601b908201527f43616e206e6f74207365742061207a65726f2061646472657373210000000000604082015260600190565b600060208284031215615a5957600080fd5b8151612c77816153ef565b634e487b7160e01b600052602160045260246000fd5b6001600160a01b03831681526040810160048310615a9a57615a9a615a64565b8260208301529392505050565b6020808252600e908201526d24b73b30b634b21039b2b73232b960911b604082015260600190565b602080825260179082015276151a58dad95d139bdd125b90dd5c9c995b9d149bdd5b99604a1b604082015260600190565b60208082526026908201527f4f6e6c792074686520414d4d206d617920706572666f726d207468657365206d6040820152656574686f647360d01b606082015260800190565b600060208284031215615b5857600080fd5b5051919050565b805161ffff8116811461355157600080fd5b805160ff8116811461355157600080fd5b60008060008060008060008060006101208a8c031215615ba157600080fd5b89519850615bb160208b01615b5f565b9750615bbf60408b01615b5f565b965060608a01519550615bd460808b01615b71565b945060a08a01518060020b8114615bea57600080fd5b60c08b015190945062ffffff81168114615c0357600080fd5b9250615c1160e08b01615b71565b91506101008a015190509295985092959850929598565b6001600160a01b039390931683526020830191909152604082015260600190565b602080825260129082015271111959985d5b1d081314081b9bdd081cd95d60721b604082015260600190565b6001600160a01b03831681526040810160038310615a9a57615a9a615a64565b634e487b7160e01b600052603160045260246000fd5b6000825160005b81811015615ccc5760208186018101518583015201615cb2565b50600092019182525091905056feb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159cd8138f8a3f377c5259ca548e70e4c2de94f129f5a11036a15b69513cba2b426a73a19dd210f1a7f902193214c0ee91dd35ee5b4d920cba8d519eca65a7b488caa2646970667358221220a1862ce6b445fa8005c24fa154170b79a833146221b34ef74f948cacfc50095064736f6c63430008140033
Loading...
Loading
Loading...
Loading
Loading...
Loading
Net Worth in USD
$0.00
Net Worth in ETH
0
Multichain Portfolio | 34 Chains
| Chain | Token | Portfolio % | Price | Amount | Value |
|---|
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.