Source Code
Overview
ETH Balance
0 ETH
ETH Value
$0.00| Transaction Hash |
|
Block
|
From
|
To
|
|||||
|---|---|---|---|---|---|---|---|---|---|
Latest 25 internal transactions (View All)
Advanced mode:
| Parent Transaction Hash | Block | From | To | |||
|---|---|---|---|---|---|---|
| 107557682 | 923 days ago | 0 ETH | ||||
| 107557682 | 923 days ago | 0 ETH | ||||
| 107557682 | 923 days ago | 0 ETH | ||||
| 107557682 | 923 days ago | 0 ETH | ||||
| 107557682 | 923 days ago | 0 ETH | ||||
| 107557682 | 923 days ago | 0 ETH | ||||
| 107557682 | 923 days ago | 0 ETH | ||||
| 107557682 | 923 days ago | 0 ETH | ||||
| 107557682 | 923 days ago | 0 ETH | ||||
| 107557682 | 923 days ago | 0 ETH | ||||
| 107557682 | 923 days ago | 0 ETH | ||||
| 107557682 | 923 days ago | 0 ETH | ||||
| 107557682 | 923 days ago | 0 ETH | ||||
| 107557682 | 923 days ago | 0 ETH | ||||
| 107557682 | 923 days ago | 0 ETH | ||||
| 107557682 | 923 days ago | 0 ETH | ||||
| 107557682 | 923 days ago | 0 ETH | ||||
| 107557682 | 923 days ago | 0 ETH | ||||
| 107557682 | 923 days ago | 0 ETH | ||||
| 107557682 | 923 days ago | 0 ETH | ||||
| 107557682 | 923 days ago | 0 ETH | ||||
| 107557682 | 923 days ago | 0 ETH | ||||
| 107557682 | 923 days ago | 0 ETH | ||||
| 107557682 | 923 days ago | 0 ETH | ||||
| 107557682 | 923 days ago | 0 ETH |
Cross-Chain Transactions
Loading...
Loading
Contract Name:
SportsAMMUtils
Compiler Version
v0.8.4+commit.c7e474f2
Optimization Enabled:
Yes with 200 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol";
import "@openzeppelin/contracts-4.4.1/token/ERC20/IERC20.sol";
import "../interfaces/ISportPositionalMarket.sol";
import "../interfaces/ISportPositionalMarketManager.sol";
import "../interfaces/IPosition.sol";
import "../interfaces/ITherundownConsumer.sol";
import "../interfaces/ISportsAMM.sol";
import "./LiquidityPool/SportAMMLiquidityPool.sol";
/// @title Sports AMM utils
contract SportsAMMUtils {
uint private constant ONE = 1e18;
uint private constant ZERO_POINT_ONE = 1e17;
uint private constant ONE_PERCENT = 1e16;
uint private constant MAX_APPROVAL = type(uint256).max;
int private constant ONE_INT = 1e18;
int private constant ONE_PERCENT_INT = 1e16;
ISportsAMM public sportsAMM;
constructor(address _sportsAMM) {
sportsAMM = ISportsAMM(_sportsAMM);
}
struct DiscountParams {
uint balancePosition;
uint balanceOtherSide;
uint amount;
uint availableToBuyFromAMM;
uint max_spread;
}
struct NegativeDiscountsParams {
uint amount;
uint balancePosition;
uint balanceOtherSide;
uint _availableToBuyFromAMMOtherSide;
uint _availableToBuyFromAMM;
uint pricePosition;
uint priceOtherPosition;
uint max_spread;
}
struct PriceImpactParams {
address market;
ISportsAMM.Position position;
uint amount;
uint _availableToBuyFromAMM;
uint _availableToBuyFromAMMOtherSide;
SportAMMLiquidityPool liquidityPool;
uint max_spread;
uint minSupportedOdds;
}
function buyPriceImpactImbalancedSkew(
uint amount,
uint balanceOtherSide,
uint balancePosition,
uint balanceOtherSideAfter,
uint balancePositionAfter,
uint availableToBuyFromAMM,
uint max_spread
) public view returns (uint) {
uint maxPossibleSkew = balanceOtherSide + availableToBuyFromAMM - balancePosition;
uint skew = balanceOtherSideAfter - (balancePositionAfter);
uint newImpact = (max_spread * ((skew * ONE) / (maxPossibleSkew))) / ONE;
if (balancePosition > 0) {
uint newPriceForMintedOnes = newImpact / 2;
uint tempMultiplier = (amount - balancePosition) * newPriceForMintedOnes;
return (tempMultiplier * ONE) / (amount) / ONE;
} else {
uint previousSkew = balanceOtherSide;
uint previousImpact = (max_spread * ((previousSkew * ONE) / maxPossibleSkew)) / ONE;
return (newImpact + previousImpact) / 2;
}
}
function calculateDiscount(DiscountParams memory params) public view returns (int) {
uint currentBuyImpactOtherSide = buyPriceImpactImbalancedSkew(
params.amount,
params.balancePosition,
params.balanceOtherSide,
params.balanceOtherSide > ONE
? params.balancePosition
: params.balancePosition + (ONE - params.balanceOtherSide),
params.balanceOtherSide > ONE ? params.balanceOtherSide - ONE : 0,
params.availableToBuyFromAMM,
params.max_spread
);
uint startDiscount = currentBuyImpactOtherSide;
uint tempMultiplier = params.balancePosition - params.amount;
uint finalDiscount = ((startDiscount / 2) * ((tempMultiplier * ONE) / params.balancePosition + ONE)) / ONE;
return -int(finalDiscount);
}
function calculateDiscountFromNegativeToPositive(NegativeDiscountsParams memory params)
public
view
returns (int priceImpact)
{
uint amountToBeMinted = params.amount - params.balancePosition;
uint sum1 = params.balanceOtherSide + params.balancePosition;
uint sum2 = params.balanceOtherSide + amountToBeMinted;
uint red3 = params._availableToBuyFromAMM - params.balancePosition;
uint positiveSkew = buyPriceImpactImbalancedSkew(amountToBeMinted, sum1, 0, sum2, 0, red3, params.max_spread);
uint skew = (params.priceOtherPosition * positiveSkew) / params.pricePosition;
int discount = calculateDiscount(
DiscountParams(
params.balancePosition,
params.balanceOtherSide,
params.balancePosition,
params._availableToBuyFromAMMOtherSide,
params.max_spread
)
);
int discountBalance = int(params.balancePosition) * discount;
int discountMinted = int(amountToBeMinted * skew);
int amountInt = int(params.balancePosition + amountToBeMinted);
priceImpact = (discountBalance + discountMinted) / amountInt;
if (priceImpact > 0) {
int numerator = int(params.pricePosition) * priceImpact;
priceImpact = numerator / int(params.priceOtherPosition);
}
}
function calculateTempQuote(
int skewImpact,
uint baseOdds,
uint safeBoxImpact,
uint amount
) public pure returns (int tempQuote) {
if (skewImpact >= 0) {
int impactPrice = ((ONE_INT - int(baseOdds)) * skewImpact) / ONE_INT;
// add 2% to the price increase to avoid edge cases on the extremes
impactPrice = (impactPrice * (ONE_INT + (ONE_PERCENT_INT * 2))) / ONE_INT;
tempQuote = (int(amount) * (int(baseOdds) + impactPrice)) / ONE_INT;
} else {
tempQuote = ((int(amount)) * ((int(baseOdds) * (ONE_INT + skewImpact)) / ONE_INT)) / ONE_INT;
}
tempQuote = (tempQuote * (ONE_INT + (int(safeBoxImpact)))) / ONE_INT;
}
function calculateAvailableToBuy(
uint capUsed,
uint spentOnThisGame,
uint baseOdds,
uint balance,
uint max_spread
) public view returns (uint availableAmount) {
uint discountedPrice = (baseOdds * (ONE - max_spread / 2)) / ONE;
uint additionalBufferFromSelling = (balance * discountedPrice) / ONE;
if ((capUsed + additionalBufferFromSelling) > spentOnThisGame) {
uint availableUntilCapSUSD = capUsed + additionalBufferFromSelling - spentOnThisGame;
if (availableUntilCapSUSD > capUsed) {
availableUntilCapSUSD = capUsed;
}
uint midImpactPriceIncrease = ((ONE - baseOdds) * (max_spread / 2)) / ONE;
uint divider_price = ONE - (baseOdds + midImpactPriceIncrease);
availableAmount = balance + ((availableUntilCapSUSD * ONE) / divider_price);
}
}
function getCanExercize(address market, address toCheck) public view returns (bool canExercize) {
if (
ISportPositionalMarketManager(sportsAMM.manager()).isKnownMarket(market) &&
!ISportPositionalMarket(market).paused() &&
ISportPositionalMarket(market).resolved()
) {
(IPosition home, IPosition away, IPosition draw) = ISportPositionalMarket(market).getOptions();
if (
(home.getBalanceOf(address(toCheck)) > 0) ||
(away.getBalanceOf(address(toCheck)) > 0) ||
(ISportPositionalMarket(market).optionsCount() > 2 && draw.getBalanceOf(address(toCheck)) > 0)
) {
canExercize = true;
}
}
}
function obtainOdds(address _market, ISportsAMM.Position _position) public view returns (uint oddsToReturn) {
address theRundownConsumer = sportsAMM.theRundownConsumer();
if (ISportPositionalMarket(_market).optionsCount() > uint(_position)) {
uint[] memory odds = new uint[](ISportPositionalMarket(_market).optionsCount());
odds = ITherundownConsumer(theRundownConsumer).getNormalizedOddsForMarket(_market);
uint firstTag = ISportPositionalMarket(_market).tags(0);
if (!sportsAMM.isMarketForSportOnePositional(firstTag) || uint(_position) == 0) {
oddsToReturn = odds[uint(_position)];
}
}
}
function obtainOddsMulti(
address _market,
ISportsAMM.Position _position1,
ISportsAMM.Position _position2
) public view returns (uint oddsToReturn1, uint oddsToReturn2) {
address theRundownConsumer = sportsAMM.theRundownConsumer();
uint positionsCount = ISportPositionalMarket(_market).optionsCount();
uint[] memory odds = new uint[](ISportPositionalMarket(_market).optionsCount());
odds = ITherundownConsumer(theRundownConsumer).getNormalizedOddsForMarket(_market);
if (positionsCount > uint(_position1)) {
oddsToReturn1 = odds[uint(_position1)];
}
if (positionsCount > uint(_position2)) {
oddsToReturn2 = odds[uint(_position2)];
}
}
function getBalanceOtherSideOnThreePositions(
ISportsAMM.Position position,
address addressToCheck,
address market
) public view returns (uint balanceOfTheOtherSide) {
(uint homeBalance, uint awayBalance, uint drawBalance) = getBalanceOfPositionsOnMarket(market, addressToCheck);
if (position == ISportsAMM.Position.Home) {
balanceOfTheOtherSide = awayBalance < drawBalance ? awayBalance : drawBalance;
} else if (position == ISportsAMM.Position.Away) {
balanceOfTheOtherSide = homeBalance < drawBalance ? homeBalance : drawBalance;
} else {
balanceOfTheOtherSide = homeBalance < awayBalance ? homeBalance : awayBalance;
}
}
function getBalanceOfPositionsOnMarket(address market, address addressToCheck)
public
view
returns (
uint homeBalance,
uint awayBalance,
uint drawBalance
)
{
(IPosition home, IPosition away, IPosition draw) = ISportPositionalMarket(market).getOptions();
homeBalance = home.getBalanceOf(address(addressToCheck));
awayBalance = away.getBalanceOf(address(addressToCheck));
if (ISportPositionalMarket(market).optionsCount() == 3) {
drawBalance = draw.getBalanceOf(address(addressToCheck));
}
}
function getBalanceOfPositionsOnMarketByPositions(
address market,
address addressToCheck,
ISportsAMM.Position position1,
ISportsAMM.Position position2
) public view returns (uint firstBalance, uint secondBalance) {
(uint homeBalance, uint awayBalance, uint drawBalance) = getBalanceOfPositionsOnMarket(market, addressToCheck);
firstBalance = position1 == ISportsAMM.Position.Home ? homeBalance : position1 == ISportsAMM.Position.Away
? awayBalance
: drawBalance;
secondBalance = position2 == ISportsAMM.Position.Home ? homeBalance : position2 == ISportsAMM.Position.Away
? awayBalance
: drawBalance;
}
function balanceOfPositionsOnMarket(
address market,
ISportsAMM.Position position,
address addressToCheck
)
public
view
returns (
uint,
uint,
uint
)
{
(IPosition home, IPosition away, ) = ISportPositionalMarket(market).getOptions();
uint balance = position == ISportsAMM.Position.Home
? home.getBalanceOf(addressToCheck)
: away.getBalanceOf(addressToCheck);
uint balanceOtherSideMax = position == ISportsAMM.Position.Home
? away.getBalanceOf(addressToCheck)
: home.getBalanceOf(addressToCheck);
uint balanceOtherSideMin = balanceOtherSideMax;
if (ISportPositionalMarket(market).optionsCount() == 3) {
(uint homeBalance, uint awayBalance, uint drawBalance) = getBalanceOfPositionsOnMarket(market, addressToCheck);
if (position == ISportsAMM.Position.Home) {
balance = homeBalance;
if (awayBalance < drawBalance) {
balanceOtherSideMax = drawBalance;
balanceOtherSideMin = awayBalance;
} else {
balanceOtherSideMax = awayBalance;
balanceOtherSideMin = drawBalance;
}
} else if (position == ISportsAMM.Position.Away) {
balance = awayBalance;
if (homeBalance < drawBalance) {
balanceOtherSideMax = drawBalance;
balanceOtherSideMin = homeBalance;
} else {
balanceOtherSideMax = homeBalance;
balanceOtherSideMin = drawBalance;
}
} else if (position == ISportsAMM.Position.Draw) {
balance = drawBalance;
if (homeBalance < awayBalance) {
balanceOtherSideMax = awayBalance;
balanceOtherSideMin = homeBalance;
} else {
balanceOtherSideMax = homeBalance;
balanceOtherSideMin = awayBalance;
}
}
}
return (balance, balanceOtherSideMax, balanceOtherSideMin);
}
function balanceOfPositionOnMarket(
address market,
ISportsAMM.Position position,
address addressToCheck
) public view returns (uint) {
(IPosition home, IPosition away, IPosition draw) = ISportPositionalMarket(market).getOptions();
uint balance = position == ISportsAMM.Position.Home
? home.getBalanceOf(addressToCheck)
: away.getBalanceOf(addressToCheck);
if (ISportPositionalMarket(market).optionsCount() == 3 && position != ISportsAMM.Position.Home) {
balance = position == ISportsAMM.Position.Away
? away.getBalanceOf(addressToCheck)
: draw.getBalanceOf(addressToCheck);
}
return balance;
}
function getParentMarketPositions(address market)
public
view
returns (
ISportsAMM.Position position1,
ISportsAMM.Position position2,
address parentMarket
)
{
ISportPositionalMarket parentMarketContract = ISportPositionalMarket(market).parentMarket();
(IPosition parentPosition1, IPosition parentPosition2) = ISportPositionalMarket(market).getParentMarketPositions();
(IPosition home, IPosition away, ) = parentMarketContract.getOptions();
position1 = parentPosition1 == home ? ISportsAMM.Position.Home : parentPosition1 == away
? ISportsAMM.Position.Away
: ISportsAMM.Position.Draw;
position2 = parentPosition2 == home ? ISportsAMM.Position.Home : parentPosition2 == away
? ISportsAMM.Position.Away
: ISportsAMM.Position.Draw;
parentMarket = address(parentMarketContract);
}
function getParentMarketPositionAddresses(address market)
public
view
returns (address parentMarketPosition1, address parentMarketPosition2)
{
(IPosition position1, IPosition position2) = ISportPositionalMarket(market).getParentMarketPositions();
parentMarketPosition1 = address(position1);
parentMarketPosition2 = address(position2);
}
function getBaseOddsForDoubleChance(address market, uint minSupportedOdds)
public
view
returns (uint oddsPosition1, uint oddsPosition2)
{
(ISportsAMM.Position position1, ISportsAMM.Position position2, address parentMarket) = getParentMarketPositions(
market
);
oddsPosition1 = obtainOdds(parentMarket, position1);
oddsPosition2 = obtainOdds(parentMarket, position2);
if (oddsPosition1 > 0 && oddsPosition2 > 0) {
oddsPosition1 = oddsPosition1 < minSupportedOdds ? minSupportedOdds : oddsPosition1;
oddsPosition2 = oddsPosition2 < minSupportedOdds ? minSupportedOdds : oddsPosition2;
}
}
function getBaseOddsForDoubleChanceSum(address market, uint minSupportedOdds) public view returns (uint sum) {
(uint oddsPosition1, uint oddsPosition2) = getBaseOddsForDoubleChance(market, minSupportedOdds);
sum = oddsPosition1 + oddsPosition2;
}
function getBuyPriceImpact(PriceImpactParams memory params) public view returns (int priceImpact) {
(uint balancePosition, , uint balanceOtherSide) = balanceOfPositionsOnMarket(
params.market,
params.position,
params.liquidityPool.getMarketPool(params.market)
);
bool isTwoPositional = ISportPositionalMarket(params.market).optionsCount() == 2;
uint balancePositionAfter = balancePosition > params.amount ? balancePosition - params.amount : 0;
uint balanceOtherSideAfter = balancePosition > params.amount
? balanceOtherSide
: balanceOtherSide + (params.amount - balancePosition);
if (params.amount <= balancePosition) {
priceImpact = calculateDiscount(
DiscountParams(
balancePosition,
balanceOtherSide,
params.amount,
params._availableToBuyFromAMMOtherSide,
params.max_spread
)
);
} else {
if (balancePosition > 0) {
uint pricePosition = _obtainOdds(params.market, params.position, params.minSupportedOdds);
uint priceOtherPosition = isTwoPositional
? _obtainOdds(
params.market,
params.position == ISportsAMM.Position.Home ? ISportsAMM.Position.Away : ISportsAMM.Position.Home,
params.minSupportedOdds
)
: ONE - pricePosition;
priceImpact = calculateDiscountFromNegativeToPositive(
NegativeDiscountsParams(
params.amount,
balancePosition,
balanceOtherSide,
params._availableToBuyFromAMMOtherSide,
params._availableToBuyFromAMM,
pricePosition,
priceOtherPosition,
params.max_spread
)
);
} else {
priceImpact = int(
buyPriceImpactImbalancedSkew(
params.amount,
balanceOtherSide,
balancePosition,
balanceOtherSideAfter,
balancePositionAfter,
params._availableToBuyFromAMM,
params.max_spread
)
);
}
}
}
function _obtainOdds(
address _market,
ISportsAMM.Position _position,
uint minSupportedOdds
) internal view returns (uint) {
if (ISportPositionalMarket(_market).isDoubleChance()) {
if (_position == ISportsAMM.Position.Home) {
return getBaseOddsForDoubleChanceSum(_market, minSupportedOdds);
}
}
return obtainOdds(_market, _position);
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/utils/SafeERC20.sol)
pragma solidity ^0.8.0;
import "../IERC20Upgradeable.sol";
import "../../../utils/AddressUpgradeable.sol";
/**
* @title SafeERC20
* @dev Wrappers around ERC20 operations that throw on failure (when the token
* contract returns false). Tokens that return no value (and instead revert or
* throw on failure) are also supported, non-reverting calls are assumed to be
* successful.
* To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
* which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
*/
library SafeERC20Upgradeable {
using AddressUpgradeable for address;
function safeTransfer(
IERC20Upgradeable token,
address to,
uint256 value
) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
}
function safeTransferFrom(
IERC20Upgradeable token,
address from,
address to,
uint256 value
) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
}
/**
* @dev Deprecated. This function has issues similar to the ones found in
* {IERC20-approve}, and its usage is discouraged.
*
* Whenever possible, use {safeIncreaseAllowance} and
* {safeDecreaseAllowance} instead.
*/
function safeApprove(
IERC20Upgradeable token,
address spender,
uint256 value
) internal {
// safeApprove should only be called when setting an initial allowance,
// or when resetting it to zero. To increase and decrease it, use
// 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
require(
(value == 0) || (token.allowance(address(this), spender) == 0),
"SafeERC20: approve from non-zero to non-zero allowance"
);
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
}
function safeIncreaseAllowance(
IERC20Upgradeable token,
address spender,
uint256 value
) internal {
uint256 newAllowance = token.allowance(address(this), spender) + value;
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
}
function safeDecreaseAllowance(
IERC20Upgradeable token,
address spender,
uint256 value
) internal {
unchecked {
uint256 oldAllowance = token.allowance(address(this), spender);
require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");
uint256 newAllowance = oldAllowance - value;
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
}
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*/
function _callOptionalReturn(IERC20Upgradeable token, bytes memory data) private {
// We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
// we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that
// the target address contains contract code and also asserts for success in the low-level call.
bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
if (returndata.length > 0) {
// Return data is optional
require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.0;
/**
* @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 amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `to`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address to, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `from` to `to` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(
address from,
address to,
uint256 amount
) external returns (bool);
}// SPDX-License-Identifier: MIT
pragma solidity >=0.5.16;
import "../interfaces/IPositionalMarketManager.sol";
import "../interfaces/IPosition.sol";
import "../interfaces/IPriceFeed.sol";
interface ISportPositionalMarket {
/* ========== TYPES ========== */
enum Phase {
Trading,
Maturity,
Expiry
}
enum Side {
Cancelled,
Home,
Away,
Draw
}
/* ========== VIEWS / VARIABLES ========== */
function getOptions()
external
view
returns (
IPosition home,
IPosition away,
IPosition draw
);
function times() external view returns (uint maturity, uint destruction);
function initialMint() external view returns (uint);
function getGameDetails() external view returns (bytes32 gameId, string memory gameLabel);
function getGameId() external view returns (bytes32);
function deposited() external view returns (uint);
function optionsCount() external view returns (uint);
function creator() external view returns (address);
function resolved() external view returns (bool);
function cancelled() external view returns (bool);
function paused() external view returns (bool);
function phase() external view returns (Phase);
function canResolve() external view returns (bool);
function result() external view returns (Side);
function isChild() external view returns (bool);
function tags(uint idx) external view returns (uint);
function getParentMarketPositions() external view returns (IPosition position1, IPosition position2);
function getStampedOdds()
external
view
returns (
uint,
uint,
uint
);
function balancesOf(address account)
external
view
returns (
uint home,
uint away,
uint draw
);
function totalSupplies()
external
view
returns (
uint home,
uint away,
uint draw
);
function isDoubleChance() external view returns (bool);
function parentMarket() external view returns (ISportPositionalMarket);
/* ========== MUTATIVE FUNCTIONS ========== */
function setPaused(bool _paused) external;
function updateDates(uint256 _maturity, uint256 _expiry) external;
function mint(uint value) external;
function exerciseOptions() external;
function restoreInvalidOdds(
uint _homeOdds,
uint _awayOdds,
uint _drawOdds
) external;
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "../interfaces/ISportPositionalMarket.sol";
interface ISportPositionalMarketManager {
/* ========== VIEWS / VARIABLES ========== */
function marketCreationEnabled() external view returns (bool);
function totalDeposited() external view returns (uint);
function numActiveMarkets() external view returns (uint);
function activeMarkets(uint index, uint pageSize) external view returns (address[] memory);
function numMaturedMarkets() external view returns (uint);
function maturedMarkets(uint index, uint pageSize) external view returns (address[] memory);
function isActiveMarket(address candidate) external view returns (bool);
function isDoubleChanceMarket(address candidate) external view returns (bool);
function isDoubleChanceSupported() external view returns (bool);
function isKnownMarket(address candidate) external view returns (bool);
function getActiveMarketAddress(uint _index) external view returns (address);
function transformCollateral(uint value) external view returns (uint);
function reverseTransformCollateral(uint value) external view returns (uint);
function isMarketPaused(address _market) external view returns (bool);
function expiryDuration() external view returns (uint);
function isWhitelistedAddress(address _address) external view returns (bool);
/* ========== MUTATIVE FUNCTIONS ========== */
function createMarket(
bytes32 gameId,
string memory gameLabel,
uint maturity,
uint initialMint, // initial sUSD to mint options for,
uint positionCount,
uint[] memory tags,
bool isChild,
address parentMarket
) external returns (ISportPositionalMarket);
function setMarketPaused(address _market, bool _paused) external;
function updateDatesForMarket(address _market, uint256 _newStartTime) external;
function resolveMarket(address market, uint outcome) external;
function expireMarkets(address[] calldata market) external;
function transferSusdTo(
address sender,
address receiver,
uint amount
) external;
}// SPDX-License-Identifier: MIT
pragma solidity >=0.5.16;
import "./IPositionalMarket.sol";
interface IPosition {
/* ========== VIEWS / VARIABLES ========== */
function getBalanceOf(address account) external view returns (uint);
function getTotalSupply() external view returns (uint);
function exerciseWithAmount(address claimant, uint amount) external;
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
interface ITherundownConsumer {
struct GameCreate {
bytes32 gameId;
uint256 startTime;
int24 homeOdds;
int24 awayOdds;
int24 drawOdds;
string homeTeam;
string awayTeam;
}
// view functions
function supportedSport(uint _sportId) external view returns (bool);
function getNormalizedOdds(bytes32 _gameId) external view returns (uint[] memory);
function getNormalizedOddsForMarket(address _market) external view returns (uint[] memory);
function getNormalizedChildOdds(address _market) external view returns (uint[] memory);
function getNormalizedOddsForTwoPosition(bytes32 _gameId) external view returns (uint[] memory);
function getGamesPerDatePerSport(uint _sportId, uint _date) external view returns (bytes32[] memory);
function getGamePropsForOdds(address _market)
external
view
returns (
uint,
uint,
bytes32
);
function gameIdPerMarket(address _market) external view returns (bytes32);
function getGameCreatedById(bytes32 _gameId) external view returns (GameCreate memory);
function isChildMarket(address _market) external view returns (bool);
function gameFulfilledCreated(bytes32 _gameId) external view returns (bool);
// write functions
function fulfillGamesCreated(
bytes32 _requestId,
bytes[] memory _games,
uint _sportsId,
uint _date
) external;
function fulfillGamesResolved(
bytes32 _requestId,
bytes[] memory _games,
uint _sportsId
) external;
function fulfillGamesOdds(bytes32 _requestId, bytes[] memory _games) external;
function setPausedByCanceledStatus(address _market, bool _flag) external;
function setGameIdPerChildMarket(bytes32 _gameId, address _child) external;
function pauseOrUnpauseMarket(address _market, bool _pause) external;
function setChildMarkets(
bytes32 _gameId,
address _main,
address _child,
bool _isSpread,
int16 _spreadHome,
uint24 _totalOver
) external;
function resolveMarketManually(
address _market,
uint _outcome,
uint8 _homeScore,
uint8 _awayScore,
bool _usebackupOdds
) external;
function getOddsForGame(bytes32 _gameId)
external
view
returns (
int24,
int24,
int24
);
function sportsIdPerGame(bytes32 _gameId) external view returns (uint);
function getGameStartTime(bytes32 _gameId) external view returns (uint256);
function marketPerGameId(bytes32 _gameId) external view returns (address);
function marketResolved(address _market) external view returns (bool);
function marketCanceled(address _market) external view returns (bool);
function invalidOdds(address _market) external view returns (bool);
function isPausedByCanceledStatus(address _market) external view returns (bool);
function isSportOnADate(uint _date, uint _sportId) external view returns (bool);
function isSportTwoPositionsSport(uint _sportsId) external view returns (bool);
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
interface ISportsAMM {
/* ========== VIEWS / VARIABLES ========== */
enum Position {
Home,
Away,
Draw
}
struct SellRequirements {
address user;
address market;
Position position;
uint amount;
uint expectedPayout;
uint additionalSlippage;
}
function theRundownConsumer() external view returns (address);
function getMarketDefaultOdds(address _market, bool isSell) external view returns (uint[] memory);
function isMarketInAMMTrading(address _market) external view returns (bool);
function isMarketForSportOnePositional(uint _tag) external view returns (bool);
function availableToBuyFromAMM(address market, Position position) external view returns (uint _available);
function parlayAMM() external view returns (address);
function minSupportedOdds() external view returns (uint);
function maxSupportedOdds() external view returns (uint);
function min_spread() external view returns (uint);
function max_spread() external view returns (uint);
function minimalTimeLeftToMaturity() external view returns (uint);
function getSpentOnGame(address market) external view returns (uint);
function safeBoxImpact() external view returns (uint);
function manager() external view returns (address);
function getLiquidityPool() external view returns (address);
function buyFromAMM(
address market,
Position position,
uint amount,
uint expectedPayout,
uint additionalSlippage
) external;
function buyFromAmmQuote(
address market,
Position position,
uint amount
) external view returns (uint);
function buyFromAmmQuoteForParlayAMM(
address market,
Position position,
uint amount
) external view returns (uint);
function updateParlayVolume(address _account, uint _amount) external;
function buyPriceImpact(
address market,
ISportsAMM.Position position,
uint amount
) external view returns (int impact);
function obtainOdds(address _market, ISportsAMM.Position _position) external view returns (uint oddsToReturn);
function buyFromAmmQuoteWithDifferentCollateral(
address market,
ISportsAMM.Position position,
uint amount,
address collateral
) external view returns (uint collateralQuote, uint sUSDToPay);
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol";
import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol";
import "../../utils/proxy/solidity-0.8.0/ProxyReentrancyGuard.sol";
import "../../utils/proxy/solidity-0.8.0/ProxyOwned.sol";
import "@openzeppelin/contracts-4.4.1/proxy/Clones.sol";
import "../../interfaces/ISportsAMM.sol";
import "../../interfaces/ISportPositionalMarket.sol";
import "../../interfaces/IStakingThales.sol";
import "./SportAMMLiquidityPoolRound.sol";
contract SportAMMLiquidityPool is Initializable, ProxyOwned, PausableUpgradeable, ProxyReentrancyGuard {
/* ========== LIBRARIES ========== */
using SafeERC20Upgradeable for IERC20Upgradeable;
struct InitParams {
address _owner;
ISportsAMM _sportsAmm;
IERC20Upgradeable _sUSD;
uint _roundLength;
uint _maxAllowedDeposit;
uint _minDepositAmount;
uint _maxAllowedUsers;
bool _needsTransformingCollateral;
}
/* ========== CONSTANTS ========== */
uint private constant HUNDRED = 1e20;
uint private constant ONE = 1e18;
/* ========== STATE VARIABLES ========== */
ISportsAMM public sportsAMM;
IERC20Upgradeable public sUSD;
bool public started;
uint public round;
uint public roundLength;
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(uint => address[]) public tradingMarketsPerRound;
mapping(uint => mapping(address => bool)) public isTradingMarketInARound;
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;
IStakingThales public stakingThales;
uint public stakedThalesMultiplier;
address public poolRoundMastercopy;
mapping(address => bool) public whitelistedDeposits;
uint public totalDeposited;
bool public onlyWhitelistedStakersAllowed;
mapping(address => bool) public whitelistedStakers;
bool public needsTransformingCollateral;
mapping(uint => mapping(address => bool)) public marketAlreadyExercisedInRound;
bool public roundClosingPrepared;
uint public usersProcessedInRound;
/* ========== CONSTRUCTOR ========== */
function initialize(InitParams calldata params) external initializer {
setOwner(params._owner);
initNonReentrant();
sportsAMM = ISportsAMM(params._sportsAmm);
sUSD = params._sUSD;
roundLength = params._roundLength;
maxAllowedDeposit = params._maxAllowedDeposit;
minDepositAmount = params._minDepositAmount;
maxAllowedUsers = params._maxAllowedUsers;
needsTransformingCollateral = params._needsTransformingCollateral;
sUSD.approve(address(sportsAMM), type(uint256).max);
}
/// @notice Start pool and begin round #1
function start() external onlyOwner {
require(!started, "Liquidity pool has already started");
require(allocationPerRound[1] > 0, "can not start with 0 deposits");
firstRoundStartTime = block.timestamp;
round = 1;
address roundPool = _getOrCreateRoundPool(1);
SportAMMLiquidityPoolRound(roundPool).updateRoundTimes(firstRoundStartTime, getRoundEndTime(1));
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 {
uint nextRound = round + 1;
address roundPool = _getOrCreateRoundPool(nextRound);
sUSD.safeTransferFrom(msg.sender, roundPool, amount);
if (!whitelistedDeposits[msg.sender]) {
require(!onlyWhitelistedStakersAllowed || whitelistedStakers[msg.sender], "Only whitelisted stakers allowed");
require(address(stakingThales) != address(0), "Staking Thales not set");
require(
(balancesPerRound[round][msg.sender] + amount + balancesPerRound[nextRound][msg.sender]) <=
_transformCollateral((stakingThales.stakedBalanceOf(msg.sender) * stakedThalesMultiplier) / ONE),
"Not enough staked THALES"
);
}
require(msg.sender != defaultLiquidityProvider, "Can't deposit directly as default liquidity provider");
// 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;
if (address(stakingThales) != address(0)) {
stakingThales.updateVolume(msg.sender, amount);
}
emit Deposited(msg.sender, amount, round);
}
/// @notice get sUSD to mint for buy and store market as trading in the round
/// @param market to trade
/// @param amountToMint amount to get for mint
function commitTrade(address market, uint amountToMint)
external
nonReentrant
whenNotPaused
onlyAMM
roundClosingNotPrepared
{
require(started, "Pool has not started");
require(amountToMint > 0, "Can't commit a zero trade");
amountToMint = _transformCollateral(amountToMint);
// add 1e-6 due to rounding issue, will be sent back to AMM at the end
amountToMint = needsTransformingCollateral ? amountToMint + 1 : amountToMint;
uint marketRound = getMarketRound(market);
address liquidityPoolRound = _getOrCreateRoundPool(marketRound);
if (marketRound == round) {
sUSD.safeTransferFrom(liquidityPoolRound, address(sportsAMM), amountToMint);
} else {
uint poolBalance = sUSD.balanceOf(liquidityPoolRound);
if (poolBalance >= amountToMint) {
sUSD.safeTransferFrom(liquidityPoolRound, address(sportsAMM), amountToMint);
} else {
uint differenceToLPAsDefault = amountToMint - poolBalance;
_depositAsDefault(differenceToLPAsDefault, liquidityPoolRound, marketRound);
sUSD.safeTransferFrom(liquidityPoolRound, address(sportsAMM), amountToMint);
}
}
if (!isTradingMarketInARound[marketRound][market]) {
tradingMarketsPerRound[marketRound].push(market);
isTradingMarketInARound[marketRound][market] = true;
}
}
/// @notice get options that are in the LP into the AMM for the buy tx
/// @param market to get options for
/// @param optionsAmount to get options for
/// @param position to get options for
function getOptionsForBuy(
address market,
uint optionsAmount,
ISportsAMM.Position position
) external nonReentrant whenNotPaused onlyAMM roundClosingNotPrepared {
if (optionsAmount > 0) {
require(started, "Pool has not started");
uint marketRound = getMarketRound(market);
address liquidityPoolRound = _getOrCreateRoundPool(marketRound);
(IPosition home, IPosition away, IPosition draw) = ISportPositionalMarket(market).getOptions();
IPosition target = position == ISportsAMM.Position.Home ? home : away;
if (ISportPositionalMarket(market).optionsCount() > 2 && position != ISportsAMM.Position.Home) {
target = position == ISportsAMM.Position.Away ? away : draw;
}
SportAMMLiquidityPoolRound(liquidityPoolRound).moveOptions(
IERC20Upgradeable(address(target)),
optionsAmount,
address(sportsAMM)
);
}
}
/// @notice get options that are in the LP into the AMM for the buy tx
/// @param market to get options for
/// @param optionsAmount to get options for
/// @param position to get options for
function getOptionsForBuyByAddress(
address market,
uint optionsAmount,
address position
) external nonReentrant whenNotPaused onlyAMM roundClosingNotPrepared {
if (optionsAmount > 0) {
require(started, "Pool has not started");
uint marketRound = getMarketRound(market);
address liquidityPoolRound = _getOrCreateRoundPool(marketRound);
SportAMMLiquidityPoolRound(liquidityPoolRound).moveOptions(
IERC20Upgradeable(position),
optionsAmount,
address(sportsAMM)
);
}
}
/// @notice Create a round pool by market maturity date if it doesnt already exist
/// @param market to use
/// @return roundPool the pool for the passed market
function getOrCreateMarketPool(address market)
external
onlyAMM
nonReentrant
whenNotPaused
roundClosingNotPrepared
returns (address roundPool)
{
uint marketRound = getMarketRound(market);
roundPool = _getOrCreateRoundPool(marketRound);
}
/// @notice request withdrawal from the LP
function withdrawalRequest() external nonReentrant whenNotPaused roundClosingNotPrepared {
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");
if (!whitelistedDeposits[msg.sender]) {
require(address(stakingThales) != address(0), "Staking Thales not set");
require(
balancesPerRound[round][msg.sender] <
_transformCollateral(((stakingThales.stakedBalanceOf(msg.sender) * stakedThalesMultiplier) / ONE)),
"Not enough staked THALES"
);
}
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 Prepare round closing
/// excercise options of trading markets and ensure there are no markets left unresolved
function prepareRoundClosing() external nonReentrant whenNotPaused roundClosingNotPrepared {
require(canCloseCurrentRound(), "Can't close current round");
// excercise market options
exerciseMarketsReadyToExercised();
address roundPool = roundPools[round];
// final balance is the final amount of sUSD in the round pool
uint currentBalance = sUSD.balanceOf(roundPool);
// calculate PnL
// if no allocation for current round
if (allocationPerRound[round] == 0) {
profitAndLossPerRound[round] = 1;
} else {
profitAndLossPerRound[round] = (currentBalance * ONE) / allocationPerRound[round];
}
roundClosingPrepared = true;
emit RoundClosingPrepared(round);
}
/// @notice Prepare round closing
/// excercise options of trading markets and ensure there are no markets left unresolved
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, "batchSize 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);
if (address(stakingThales) != address(0)) {
stakingThales.updateVolume(user, balanceAfterCurRound);
}
} else {
balancesPerRound[round + 1][user] = 0;
sUSD.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 profit and loss and process withdrawals
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;
sUSD.safeTransferFrom(roundPool, defaultLiquidityProvider, balanceAfterCurRound);
emit Claimed(defaultLiquidityProvider, balanceAfterCurRound);
}
if (round == 1) {
cumulativeProfitAndLoss[round] = profitAndLossPerRound[round];
} else {
cumulativeProfitAndLoss[round] = (cumulativeProfitAndLoss[round - 1] * profitAndLossPerRound[round]) / ONE;
}
// start next round
round += 1;
//add all carried over sUSD
allocationPerRound[round] += sUSD.balanceOf(roundPool);
totalDeposited = allocationPerRound[round] - balancesPerRound[round][defaultLiquidityProvider];
address roundPoolNewRound = _getOrCreateRoundPool(round);
sUSD.safeTransferFrom(roundPool, roundPoolNewRound, sUSD.balanceOf(roundPool));
usersProcessedInRound = 0;
emit RoundClosed(round - 1, profitAndLossPerRound[round - 1]);
}
/// @notice Iterate all markets in the current round and exercise those ready to be exercised
function exerciseMarketsReadyToExercised() public roundClosingNotPrepared {
SportAMMLiquidityPoolRound poolRound = SportAMMLiquidityPoolRound(roundPools[round]);
ISportPositionalMarket market;
for (uint i = 0; i < tradingMarketsPerRound[round].length; i++) {
address marketAddress = tradingMarketsPerRound[round][i];
if (!marketAlreadyExercisedInRound[round][marketAddress]) {
market = ISportPositionalMarket(marketAddress);
if (market.resolved()) {
poolRound.exerciseMarketReadyToExercised(market);
marketAlreadyExercisedInRound[round][marketAddress] = true;
}
}
}
}
/* ========== VIEWS ========== */
/// @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];
}
/// @notice Return the maximum amount the user can deposit now
/// @param user address to check
/// @return maxDepositForUser the maximum amount the user can deposit in total including already deposited
/// @return availableToDepositForUser the maximum amount the user can deposit now
/// @return stakedThalesForUser how much THALES the user has staked
function getMaxAvailableDepositForUser(address user)
external
view
returns (
uint maxDepositForUser,
uint availableToDepositForUser,
uint stakedThalesForUser
)
{
uint nextRound = round + 1;
stakedThalesForUser = stakingThales.stakedBalanceOf(user);
maxDepositForUser = _transformCollateral((stakedThalesForUser * stakedThalesMultiplier) / ONE);
availableToDepositForUser = maxDepositForUser > (balancesPerRound[round][user] + balancesPerRound[nextRound][user])
? (maxDepositForUser - balancesPerRound[round][user] - balancesPerRound[nextRound][user])
: 0;
}
/// @notice Return how much the user needs to have staked to withdraw
/// @param user address to check
/// @return neededStaked how much the user needs to have staked to withdraw
function getNeededStakedThalesToWithdrawForUser(address user) external view returns (uint neededStaked) {
uint nextRound = round + 1;
neededStaked =
_reverseTransformCollateral((balancesPerRound[round][user] + balancesPerRound[nextRound][user]) * ONE) /
stakedThalesMultiplier;
}
/// @notice get the pool address for the market
/// @param market to check
/// @return roundPool the pool address for the market
function getMarketPool(address market) external view returns (address roundPool) {
roundPool = roundPools[getMarketRound(market)];
}
/// @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;
}
ISportPositionalMarket market;
for (uint i = 0; i < tradingMarketsPerRound[round].length; i++) {
address marketAddress = tradingMarketsPerRound[round][i];
if (!marketAlreadyExercisedInRound[round][marketAddress]) {
market = ISportPositionalMarket(marketAddress);
if (!market.resolved()) {
return false;
}
}
}
return true;
}
/// @notice Iterate all markets in the current round and return true if at least one can be exercised
function hasMarketsReadyToBeExercised() public view returns (bool) {
SportAMMLiquidityPoolRound poolRound = SportAMMLiquidityPoolRound(roundPools[round]);
ISportPositionalMarket market;
for (uint i = 0; i < tradingMarketsPerRound[round].length; i++) {
address marketAddress = tradingMarketsPerRound[round][i];
if (!marketAlreadyExercisedInRound[round][marketAddress]) {
market = ISportPositionalMarket(marketAddress);
if (market.resolved()) {
(uint homeBalance, uint awayBalance, uint drawBalance) = market.balancesOf(address(poolRound));
if (homeBalance > 0 || awayBalance > 0 || drawBalance > 0) {
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 - 1) * 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 * roundLength;
}
/// @notice Return the round to which a market belongs to
/// @param market to get the round for
/// @return _round the round which the market belongs to
function getMarketRound(address market) public view returns (uint _round) {
ISportPositionalMarket marketContract = ISportPositionalMarket(market);
(uint maturity, ) = marketContract.times();
if (maturity > firstRoundStartTime) {
_round = (maturity - firstRoundStartTime) / roundLength + 1;
} else {
_round = 1;
}
}
/// @notice Return the count of users in current round
/// @return _the count of users in current round
function getUsersCountInCurrentRound() external view returns (uint) {
return usersPerRound[round].length;
}
/* ========== INTERNAL FUNCTIONS ========== */
function _transformCollateral(uint value) internal view returns (uint) {
if (needsTransformingCollateral) {
return value / 1e12;
} else {
return value;
}
}
function _reverseTransformCollateral(uint value) internal view returns (uint) {
if (needsTransformingCollateral) {
return value * 1e12;
} else {
return value;
}
}
function _depositAsDefault(
uint amount,
address roundPool,
uint _round
) internal {
require(defaultLiquidityProvider != address(0), "default liquidity provider not set");
sUSD.safeTransferFrom(defaultLiquidityProvider, roundPool, amount);
balancesPerRound[_round][defaultLiquidityProvider] += amount;
allocationPerRound[_round] += amount;
emit Deposited(defaultLiquidityProvider, amount, _round);
}
function _getOrCreateRoundPool(uint _round) internal returns (address roundPool) {
roundPool = roundPools[_round];
if (roundPool == address(0)) {
require(poolRoundMastercopy != address(0), "Round pool mastercopy not set");
SportAMMLiquidityPoolRound newRoundPool = SportAMMLiquidityPoolRound(Clones.clone(poolRoundMastercopy));
newRoundPool.initialize(address(this), sUSD, _round, getRoundEndTime(_round - 1), getRoundEndTime(_round));
roundPool = address(newRoundPool);
roundPools[_round] = roundPool;
emit RoundPoolCreated(_round, roundPool);
}
}
/* ========== SETTERS ========== */
function setPaused(bool _setPausing) external onlyOwner {
_setPausing ? _pause() : _unpause();
}
/// @notice Set onlyWhitelistedStakersAllowed variable
/// @param flagToSet self explanatory
function setOnlyWhitelistedStakersAllowed(bool flagToSet) external onlyOwner {
onlyWhitelistedStakersAllowed = flagToSet;
emit SetOnlyWhitelistedStakersAllowed(flagToSet);
}
/// @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 _stakedThalesMultiplier
/// @param _stakedThalesMultiplier the number of sUSD one can deposit per THALES staked
function setStakedThalesMultiplier(uint _stakedThalesMultiplier) external onlyOwner {
stakedThalesMultiplier = _stakedThalesMultiplier;
emit StakedThalesMultiplierChanged(_stakedThalesMultiplier);
}
/// @notice Set IStakingThales contract
/// @param _stakingThales IStakingThales address
function setStakingThales(IStakingThales _stakingThales) external onlyOwner {
require(address(_stakingThales) != address(0), "Can not set a zero address!");
stakingThales = _stakingThales;
emit StakingThalesChanged(address(_stakingThales));
}
/// @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 ThalesAMM contract
/// @param _sportAMM ThalesAMM address
function setSportAmm(ISportsAMM _sportAMM) external onlyOwner {
require(address(_sportAMM) != address(0), "Can not set a zero address!");
sportsAMM = _sportAMM;
sUSD.approve(address(sportsAMM), type(uint256).max);
emit SportAMMChanged(address(_sportAMM));
}
/// @notice Set defaultLiquidityProvider wallet
/// @param _defaultLiquidityProvider default liquidity provider
function setDefaultLiquidityProvider(address _defaultLiquidityProvider) external onlyOwner {
require(_defaultLiquidityProvider != address(0), "Can not set a zero address!");
defaultLiquidityProvider = _defaultLiquidityProvider;
emit DefaultLiquidityProviderChanged(_defaultLiquidityProvider);
}
/// @notice Set length of rounds
/// @param _roundLength Length of a round in miliseconds
function setRoundLength(uint _roundLength) external onlyOwner {
require(!started, "Can't change round length after start");
roundLength = _roundLength;
emit RoundLengthChanged(_roundLength);
}
/// @notice set addresses which can deposit into the AMM bypassing the staking checks
/// @param _whitelistedAddresses Addresses to set the whitelist flag for
/// @param _flag to set
function setWhitelistedAddresses(address[] calldata _whitelistedAddresses, bool _flag) external onlyOwner {
require(_whitelistedAddresses.length > 0, "Whitelisted addresses cannot be empty");
for (uint256 index = 0; index < _whitelistedAddresses.length; index++) {
// only if current flag is different, if same skip it
if (whitelistedDeposits[_whitelistedAddresses[index]] != _flag) {
whitelistedDeposits[_whitelistedAddresses[index]] = _flag;
emit AddedIntoWhitelist(_whitelistedAddresses[index], _flag);
}
}
}
/// @notice set addresses which can deposit into the AMM when only whitelisted stakers are allowed
/// @param _whitelistedAddresses Addresses to set the whitelist flag for
/// @param _flag to set
function setWhitelistedStakerAddresses(address[] calldata _whitelistedAddresses, bool _flag) external onlyOwner {
require(_whitelistedAddresses.length > 0, "Whitelisted addresses cannot be empty");
for (uint256 index = 0; index < _whitelistedAddresses.length; index++) {
// only if current flag is different, if same skip it
if (whitelistedStakers[_whitelistedAddresses[index]] != _flag) {
whitelistedStakers[_whitelistedAddresses[index]] = _flag;
emit AddedIntoWhitelistStaker(_whitelistedAddresses[index], _flag);
}
}
}
/* ========== MODIFIERS ========== */
modifier canDeposit(uint amount) {
require(!withdrawalRequested[msg.sender], "Withdrawal is requested, cannot deposit");
require(amount >= minDepositAmount, "Amount less than minDepositAmount");
require(totalDeposited + amount <= maxAllowedDeposit, "Deposit amount exceeds AMM LP cap");
_;
}
modifier onlyAMM() {
require(msg.sender == address(sportsAMM), "only the AMM may perform these methods");
_;
}
modifier roundClosingNotPrepared() {
require(!roundClosingPrepared, "Not allowed during roundClosingPrepared");
_;
}
/* ========== EVENTS ========== */
event PoolStarted();
event Deposited(address user, uint amount, uint round);
event WithdrawalRequested(address user);
event RoundClosed(uint round, uint roundPnL);
event Claimed(address user, uint amount);
event RoundPoolCreated(uint _round, address roundPool);
event PoolRoundMastercopyChanged(address newMastercopy);
event StakedThalesMultiplierChanged(uint _stakedThalesMultiplier);
event StakingThalesChanged(address stakingThales);
event MaxAllowedDepositChanged(uint maxAllowedDeposit);
event MinAllowedDepositChanged(uint minAllowedDeposit);
event MaxAllowedUsersChanged(uint MaxAllowedUsersChanged);
event SportAMMChanged(address sportAMM);
event DefaultLiquidityProviderChanged(address newProvider);
event AddedIntoWhitelist(address _whitelistAddress, bool _flag);
event AddedIntoWhitelistStaker(address _whitelistAddress, bool _flag);
event RoundLengthChanged(uint roundLength);
event SetOnlyWhitelistedStakersAllowed(bool flagToSet);
event RoundClosingPrepared(uint round);
event RoundClosingBatchProcessed(uint round, uint batchSize);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/IERC20.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20Upgradeable {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(
address sender,
address recipient,
uint256 amount
) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Address.sol)
pragma solidity ^0.8.0;
/**
* @dev Collection of functions related to the address type
*/
library AddressUpgradeable {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize, which returns 0 for contracts in
// construction, since the code is only stored at the end of the
// constructor execution.
uint256 size;
assembly {
size := extcodesize(account)
}
return size > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value
) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory errorMessage
) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
require(isContract(target), "Address: call to non-contract");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(
address target,
bytes memory data,
string memory errorMessage
) internal view returns (bytes memory) {
require(isContract(target), "Address: static call to non-contract");
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
* revert reason using the provided one.
*
* _Available since v4.3._
*/
function verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) internal pure returns (bytes memory) {
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
}// SPDX-License-Identifier: MIT
pragma solidity >=0.5.16;
import "../interfaces/IPositionalMarket.sol";
interface IPositionalMarketManager {
/* ========== VIEWS / VARIABLES ========== */
function durations() external view returns (uint expiryDuration, uint maxTimeToMaturity);
function capitalRequirement() external view returns (uint);
function marketCreationEnabled() external view returns (bool);
function onlyAMMMintingAndBurning() external view returns (bool);
function transformCollateral(uint value) external view returns (uint);
function reverseTransformCollateral(uint value) external view returns (uint);
function totalDeposited() external view returns (uint);
function numActiveMarkets() external view returns (uint);
function activeMarkets(uint index, uint pageSize) external view returns (address[] memory);
function numMaturedMarkets() external view returns (uint);
function maturedMarkets(uint index, uint pageSize) external view returns (address[] memory);
function isActiveMarket(address candidate) external view returns (bool);
function isKnownMarket(address candidate) external view returns (bool);
function getThalesAMM() external view returns (address);
/* ========== MUTATIVE FUNCTIONS ========== */
function createMarket(
bytes32 oracleKey,
uint strikePrice,
uint maturity,
uint initialMint // initial sUSD to mint options for,
) external returns (IPositionalMarket);
function resolveMarket(address market) external;
function expireMarkets(address[] calldata market) external;
function transferSusdTo(
address sender,
address receiver,
uint amount
) external;
}// SPDX-License-Identifier: MIT
pragma solidity >=0.5.16;
interface IPriceFeed {
// Structs
struct RateAndUpdatedTime {
uint216 rate;
uint40 time;
}
// Mutative functions
function addAggregator(bytes32 currencyKey, address aggregatorAddress) external;
function removeAggregator(bytes32 currencyKey) external;
// Views
function rateForCurrency(bytes32 currencyKey) external view returns (uint);
function rateAndUpdatedTime(bytes32 currencyKey) external view returns (uint rate, uint time);
function getRates() external view returns (uint[] memory);
function getCurrencies() external view returns (bytes32[] memory);
}// SPDX-License-Identifier: MIT
pragma solidity >=0.5.16;
import "../interfaces/IPositionalMarketManager.sol";
import "../interfaces/IPosition.sol";
import "../interfaces/IPriceFeed.sol";
interface IPositionalMarket {
/* ========== TYPES ========== */
enum Phase {
Trading,
Maturity,
Expiry
}
enum Side {
Up,
Down
}
/* ========== VIEWS / VARIABLES ========== */
function getOptions() external view returns (IPosition up, IPosition down);
function times() external view returns (uint maturity, uint destructino);
function getOracleDetails()
external
view
returns (
bytes32 key,
uint strikePrice,
uint finalPrice
);
function fees() external view returns (uint poolFee, uint creatorFee);
function deposited() external view returns (uint);
function creator() external view returns (address);
function resolved() external view returns (bool);
function phase() external view returns (Phase);
function oraclePrice() external view returns (uint);
function oraclePriceAndTimestamp() external view returns (uint price, uint updatedAt);
function canResolve() external view returns (bool);
function result() external view returns (Side);
function balancesOf(address account) external view returns (uint up, uint down);
function totalSupplies() external view returns (uint up, uint down);
function getMaximumBurnable(address account) external view returns (uint amount);
/* ========== MUTATIVE FUNCTIONS ========== */
function mint(uint value) external;
function exerciseOptions() external returns (uint);
function burnOptions(uint amount) external;
function burnOptionsMaximum() external;
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (access/Ownable.sol)
pragma solidity ^0.8.0;
import "../utils/ContextUpgradeable.sol";
import "../proxy/utils/Initializable.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract OwnableUpgradeable is Initializable, ContextUpgradeable {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
function __Ownable_init() internal onlyInitializing {
__Context_init_unchained();
__Ownable_init_unchained();
}
function __Ownable_init_unchained() internal onlyInitializing {
_transferOwnership(_msgSender());
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
_;
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
uint256[49] private __gap;
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (proxy/utils/Initializable.sol)
pragma solidity ^0.8.0;
import "../../utils/AddressUpgradeable.sol";
/**
* @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
* behind a proxy. Since a proxied contract can't have a constructor, it's common to move constructor logic to an
* external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
* function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
*
* TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
* possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.
*
* CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
* that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
*
* [CAUTION]
* ====
* Avoid leaving a contract uninitialized.
*
* An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation
* contract, which may impact the proxy. To initialize the implementation contract, you can either invoke the
* initializer manually, or you can include a constructor to automatically mark it as initialized when it is deployed:
*
* [.hljs-theme-light.nopadding]
* ```
* /// @custom:oz-upgrades-unsafe-allow constructor
* constructor() initializer {}
* ```
* ====
*/
abstract contract Initializable {
/**
* @dev Indicates that the contract has been initialized.
*/
bool private _initialized;
/**
* @dev Indicates that the contract is in the process of being initialized.
*/
bool private _initializing;
/**
* @dev Modifier to protect an initializer function from being invoked twice.
*/
modifier initializer() {
// If the contract is initializing we ignore whether _initialized is set in order to support multiple
// inheritance patterns, but we only do this in the context of a constructor, because in other contexts the
// contract may have been reentered.
require(_initializing ? _isConstructor() : !_initialized, "Initializable: contract is already initialized");
bool isTopLevelCall = !_initializing;
if (isTopLevelCall) {
_initializing = true;
_initialized = true;
}
_;
if (isTopLevelCall) {
_initializing = false;
}
}
/**
* @dev Modifier to protect an initialization function so that it can only be invoked by functions with the
* {initializer} modifier, directly or indirectly.
*/
modifier onlyInitializing() {
require(_initializing, "Initializable: contract is not initializing");
_;
}
function _isConstructor() private view returns (bool) {
return !AddressUpgradeable.isContract(address(this));
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (security/Pausable.sol)
pragma solidity ^0.8.0;
import "../utils/ContextUpgradeable.sol";
import "../proxy/utils/Initializable.sol";
/**
* @dev Contract module which allows children to implement an emergency stop
* mechanism that can be triggered by an authorized account.
*
* This module is used through inheritance. It will make available the
* modifiers `whenNotPaused` and `whenPaused`, which can be applied to
* the functions of your contract. Note that they will not be pausable by
* simply including this module, only once the modifiers are put in place.
*/
abstract contract PausableUpgradeable is Initializable, ContextUpgradeable {
/**
* @dev Emitted when the pause is triggered by `account`.
*/
event Paused(address account);
/**
* @dev Emitted when the pause is lifted by `account`.
*/
event Unpaused(address account);
bool private _paused;
/**
* @dev Initializes the contract in unpaused state.
*/
function __Pausable_init() internal onlyInitializing {
__Context_init_unchained();
__Pausable_init_unchained();
}
function __Pausable_init_unchained() internal onlyInitializing {
_paused = false;
}
/**
* @dev Returns true if the contract is paused, and false otherwise.
*/
function paused() public view virtual returns (bool) {
return _paused;
}
/**
* @dev Modifier to make a function callable only when the contract is not paused.
*
* Requirements:
*
* - The contract must not be paused.
*/
modifier whenNotPaused() {
require(!paused(), "Pausable: paused");
_;
}
/**
* @dev Modifier to make a function callable only when the contract is paused.
*
* Requirements:
*
* - The contract must be paused.
*/
modifier whenPaused() {
require(paused(), "Pausable: not paused");
_;
}
/**
* @dev Triggers stopped state.
*
* Requirements:
*
* - The contract must not be paused.
*/
function _pause() internal virtual whenNotPaused {
_paused = true;
emit Paused(_msgSender());
}
/**
* @dev Returns to normal state.
*
* Requirements:
*
* - The contract must be paused.
*/
function _unpause() internal virtual whenPaused {
_paused = false;
emit Unpaused(_msgSender());
}
uint256[49] private __gap;
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/**
* @dev Contract module that helps prevent reentrant calls to a function.
*
* Inheriting from `ReentrancyGuard` will make the `nonReentrant` modifier
* available, which can be aplied to functions to make sure there are no nested
* (reentrant) calls to them.
*
* Note that because there is a single `nonReentrant` guard, functions marked as
* `nonReentrant` may not call one another. This can be worked around by making
* those functions `private`, and then adding `external` `nonReentrant` entry
* points to them.
*/
contract ProxyReentrancyGuard {
/// @dev counter to allow mutex lock with only one SSTORE operation
uint256 private _guardCounter;
bool private _initialized;
function initNonReentrant() public {
require(!_initialized, "Already initialized");
_initialized = true;
_guardCounter = 1;
}
/**
* @dev Prevents a contract from calling itself, directly or indirectly.
* Calling a `nonReentrant` function from another `nonReentrant`
* function is not supported. It is possible to prevent this from happening
* by making the `nonReentrant` function external, and make it call a
* `private` function that does the actual work.
*/
modifier nonReentrant() {
_guardCounter += 1;
uint256 localCounter = _guardCounter;
_;
require(localCounter == _guardCounter, "ReentrancyGuard: reentrant call");
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
// Clone of syntetix contract without constructor
contract ProxyOwned {
address public owner;
address public nominatedOwner;
bool private _initialized;
bool private _transferredAtInit;
function setOwner(address _owner) public {
require(_owner != address(0), "Owner address cannot be 0");
require(!_initialized, "Already initialized, use nominateNewOwner");
_initialized = true;
owner = _owner;
emit OwnerChanged(address(0), _owner);
}
function nominateNewOwner(address _owner) external onlyOwner {
nominatedOwner = _owner;
emit OwnerNominated(_owner);
}
function acceptOwnership() external {
require(msg.sender == nominatedOwner, "You must be nominated before you can accept ownership");
emit OwnerChanged(owner, nominatedOwner);
owner = nominatedOwner;
nominatedOwner = address(0);
}
function transferOwnershipAtInit(address proxyAddress) external onlyOwner {
require(proxyAddress != address(0), "Invalid address");
require(!_transferredAtInit, "Already transferred");
owner = proxyAddress;
_transferredAtInit = true;
emit OwnerChanged(owner, proxyAddress);
}
modifier onlyOwner {
_onlyOwner();
_;
}
function _onlyOwner() private view {
require(msg.sender == owner, "Only the contract owner may perform this action");
}
event OwnerNominated(address newOwner);
event OwnerChanged(address oldOwner, address newOwner);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (proxy/Clones.sol)
pragma solidity ^0.8.0;
/**
* @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.
*
* _Available since v3.4._
*/
library Clones {
/**
* @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 {
let ptr := mload(0x40)
mstore(ptr, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000)
mstore(add(ptr, 0x14), shl(0x60, implementation))
mstore(add(ptr, 0x28), 0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000)
instance := create(0, ptr, 0x37)
}
require(instance != address(0), "ERC1167: create failed");
}
/**
* @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 {
let ptr := mload(0x40)
mstore(ptr, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000)
mstore(add(ptr, 0x14), shl(0x60, implementation))
mstore(add(ptr, 0x28), 0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000)
instance := create2(0, ptr, 0x37, salt)
}
require(instance != address(0), "ERC1167: create2 failed");
}
/**
* @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(ptr, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000)
mstore(add(ptr, 0x14), shl(0x60, implementation))
mstore(add(ptr, 0x28), 0x5af43d82803e903d91602b57fd5bf3ff00000000000000000000000000000000)
mstore(add(ptr, 0x38), shl(0x60, deployer))
mstore(add(ptr, 0x4c), salt)
mstore(add(ptr, 0x6c), keccak256(ptr, 0x37))
predicted := keccak256(add(ptr, 0x37), 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
pragma solidity >=0.5.16;
interface IStakingThales {
function updateVolume(address account, uint amount) external;
/* ========== VIEWS / VARIABLES ========== */
function totalStakedAmount() external view returns (uint);
function stakedBalanceOf(address account) external view returns (uint);
function currentPeriodRewards() external view returns (uint);
function currentPeriodFees() external view returns (uint);
function getLastPeriodOfClaimedRewards(address account) external view returns (uint);
function getRewardsAvailable(address account) external view returns (uint);
function getRewardFeesAvailable(address account) external view returns (uint);
function getAlreadyClaimedRewards(address account) external view returns (uint);
function getContractRewardFunds() external view returns (uint);
function getContractFeeFunds() external view returns (uint);
function getAMMVolume(address account) external view returns (uint);
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol";
import "../../interfaces/ISportPositionalMarket.sol";
import "./SportAMMLiquidityPool.sol";
contract SportAMMLiquidityPoolRound {
/* ========== LIBRARIES ========== */
using SafeERC20Upgradeable for IERC20Upgradeable;
/* ========== STATE VARIABLES ========== */
SportAMMLiquidityPool public liquidityPool;
IERC20Upgradeable public sUSD;
uint public round;
uint public roundStartTime;
uint public roundEndTime;
/* ========== CONSTRUCTOR ========== */
bool public initialized;
function initialize(
address _liquidityPool,
IERC20Upgradeable _sUSD,
uint _round,
uint _roundStartTime,
uint _roundEndTime
) external {
require(!initialized, "Already initialized");
initialized = true;
liquidityPool = SportAMMLiquidityPool(_liquidityPool);
sUSD = _sUSD;
round = _round;
roundStartTime = _roundStartTime;
roundEndTime = _roundEndTime;
sUSD.approve(_liquidityPool, type(uint256).max);
}
function updateRoundTimes(uint _roundStartTime, uint _roundEndTime) external onlyLiquidityPool {
roundStartTime = _roundStartTime;
roundEndTime = _roundEndTime;
emit RoundTimesUpdated(_roundStartTime, _roundEndTime);
}
function exerciseMarketReadyToExercised(ISportPositionalMarket market) external onlyLiquidityPool {
if (market.resolved()) {
(uint homeBalance, uint awayBalance, uint drawBalance) = market.balancesOf(address(this));
if (homeBalance > 0 || awayBalance > 0 || drawBalance > 0) {
market.exerciseOptions();
}
}
}
function moveOptions(
IERC20Upgradeable option,
uint optionsAmount,
address destination
) external onlyLiquidityPool {
option.safeTransfer(destination, optionsAmount);
}
modifier onlyLiquidityPool() {
require(msg.sender == address(liquidityPool), "only the Pool manager may perform these methods");
_;
}
event RoundTimesUpdated(uint _roundStartTime, uint _roundEndTime);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)
pragma solidity ^0.8.0;
import "../proxy/utils/Initializable.sol";
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract ContextUpgradeable is Initializable {
function __Context_init() internal onlyInitializing {
__Context_init_unchained();
}
function __Context_init_unchained() internal onlyInitializing {
}
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
uint256[50] private __gap;
}{
"optimizer": {
"enabled": true,
"runs": 200
},
"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":"_sportsAMM","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"address","name":"market","type":"address"},{"internalType":"enum ISportsAMM.Position","name":"position","type":"uint8"},{"internalType":"address","name":"addressToCheck","type":"address"}],"name":"balanceOfPositionOnMarket","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"market","type":"address"},{"internalType":"enum ISportsAMM.Position","name":"position","type":"uint8"},{"internalType":"address","name":"addressToCheck","type":"address"}],"name":"balanceOfPositionsOnMarket","outputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"balanceOtherSide","type":"uint256"},{"internalType":"uint256","name":"balancePosition","type":"uint256"},{"internalType":"uint256","name":"balanceOtherSideAfter","type":"uint256"},{"internalType":"uint256","name":"balancePositionAfter","type":"uint256"},{"internalType":"uint256","name":"availableToBuyFromAMM","type":"uint256"},{"internalType":"uint256","name":"max_spread","type":"uint256"}],"name":"buyPriceImpactImbalancedSkew","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"capUsed","type":"uint256"},{"internalType":"uint256","name":"spentOnThisGame","type":"uint256"},{"internalType":"uint256","name":"baseOdds","type":"uint256"},{"internalType":"uint256","name":"balance","type":"uint256"},{"internalType":"uint256","name":"max_spread","type":"uint256"}],"name":"calculateAvailableToBuy","outputs":[{"internalType":"uint256","name":"availableAmount","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"balancePosition","type":"uint256"},{"internalType":"uint256","name":"balanceOtherSide","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"availableToBuyFromAMM","type":"uint256"},{"internalType":"uint256","name":"max_spread","type":"uint256"}],"internalType":"struct SportsAMMUtils.DiscountParams","name":"params","type":"tuple"}],"name":"calculateDiscount","outputs":[{"internalType":"int256","name":"","type":"int256"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"balancePosition","type":"uint256"},{"internalType":"uint256","name":"balanceOtherSide","type":"uint256"},{"internalType":"uint256","name":"_availableToBuyFromAMMOtherSide","type":"uint256"},{"internalType":"uint256","name":"_availableToBuyFromAMM","type":"uint256"},{"internalType":"uint256","name":"pricePosition","type":"uint256"},{"internalType":"uint256","name":"priceOtherPosition","type":"uint256"},{"internalType":"uint256","name":"max_spread","type":"uint256"}],"internalType":"struct SportsAMMUtils.NegativeDiscountsParams","name":"params","type":"tuple"}],"name":"calculateDiscountFromNegativeToPositive","outputs":[{"internalType":"int256","name":"priceImpact","type":"int256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"int256","name":"skewImpact","type":"int256"},{"internalType":"uint256","name":"baseOdds","type":"uint256"},{"internalType":"uint256","name":"safeBoxImpact","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"calculateTempQuote","outputs":[{"internalType":"int256","name":"tempQuote","type":"int256"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"market","type":"address"},{"internalType":"address","name":"addressToCheck","type":"address"}],"name":"getBalanceOfPositionsOnMarket","outputs":[{"internalType":"uint256","name":"homeBalance","type":"uint256"},{"internalType":"uint256","name":"awayBalance","type":"uint256"},{"internalType":"uint256","name":"drawBalance","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"market","type":"address"},{"internalType":"address","name":"addressToCheck","type":"address"},{"internalType":"enum ISportsAMM.Position","name":"position1","type":"uint8"},{"internalType":"enum ISportsAMM.Position","name":"position2","type":"uint8"}],"name":"getBalanceOfPositionsOnMarketByPositions","outputs":[{"internalType":"uint256","name":"firstBalance","type":"uint256"},{"internalType":"uint256","name":"secondBalance","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"enum ISportsAMM.Position","name":"position","type":"uint8"},{"internalType":"address","name":"addressToCheck","type":"address"},{"internalType":"address","name":"market","type":"address"}],"name":"getBalanceOtherSideOnThreePositions","outputs":[{"internalType":"uint256","name":"balanceOfTheOtherSide","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"market","type":"address"},{"internalType":"uint256","name":"minSupportedOdds","type":"uint256"}],"name":"getBaseOddsForDoubleChance","outputs":[{"internalType":"uint256","name":"oddsPosition1","type":"uint256"},{"internalType":"uint256","name":"oddsPosition2","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"market","type":"address"},{"internalType":"uint256","name":"minSupportedOdds","type":"uint256"}],"name":"getBaseOddsForDoubleChanceSum","outputs":[{"internalType":"uint256","name":"sum","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"market","type":"address"},{"internalType":"enum ISportsAMM.Position","name":"position","type":"uint8"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"_availableToBuyFromAMM","type":"uint256"},{"internalType":"uint256","name":"_availableToBuyFromAMMOtherSide","type":"uint256"},{"internalType":"contract SportAMMLiquidityPool","name":"liquidityPool","type":"address"},{"internalType":"uint256","name":"max_spread","type":"uint256"},{"internalType":"uint256","name":"minSupportedOdds","type":"uint256"}],"internalType":"struct SportsAMMUtils.PriceImpactParams","name":"params","type":"tuple"}],"name":"getBuyPriceImpact","outputs":[{"internalType":"int256","name":"priceImpact","type":"int256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"market","type":"address"},{"internalType":"address","name":"toCheck","type":"address"}],"name":"getCanExercize","outputs":[{"internalType":"bool","name":"canExercize","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"market","type":"address"}],"name":"getParentMarketPositionAddresses","outputs":[{"internalType":"address","name":"parentMarketPosition1","type":"address"},{"internalType":"address","name":"parentMarketPosition2","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"market","type":"address"}],"name":"getParentMarketPositions","outputs":[{"internalType":"enum ISportsAMM.Position","name":"position1","type":"uint8"},{"internalType":"enum ISportsAMM.Position","name":"position2","type":"uint8"},{"internalType":"address","name":"parentMarket","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_market","type":"address"},{"internalType":"enum ISportsAMM.Position","name":"_position","type":"uint8"}],"name":"obtainOdds","outputs":[{"internalType":"uint256","name":"oddsToReturn","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_market","type":"address"},{"internalType":"enum ISportsAMM.Position","name":"_position1","type":"uint8"},{"internalType":"enum ISportsAMM.Position","name":"_position2","type":"uint8"}],"name":"obtainOddsMulti","outputs":[{"internalType":"uint256","name":"oddsToReturn1","type":"uint256"},{"internalType":"uint256","name":"oddsToReturn2","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"sportsAMM","outputs":[{"internalType":"contract ISportsAMM","name":"","type":"address"}],"stateMutability":"view","type":"function"}]Contract Creation Code
60806040523480156200001157600080fd5b5060405162002fc438038062002fc483398101604081905262000034916200005a565b600080546001600160a01b0319166001600160a01b03929092169190911790556200008a565b6000602082840312156200006c578081fd5b81516001600160a01b038116811462000083578182fd5b9392505050565b612f2a806200009a6000396000f3fe608060405234801561001057600080fd5b50600436106101215760003560e01c8063a119612d116100ad578063d95bff2511610071578063d95bff25146102ca578063e468265c146102dd578063ea25928a146102f0578063f54ffd0014610303578063f947c6b31461031657600080fd5b8063a119612d14610244578063a4d682dd14610257578063ad2ddaa414610279578063c3812fe21461028c578063c99252881461029f57600080fd5b806350d851a1116100f457806350d851a1146101ba5780636116ad1e146101cd578063755cc89c146101fb57806380143b9b1461020e5780639612e9a31461022157600080fd5b80630381cd09146101265780632888a20d1461014c57806331b8975e1461015f5780634ab96c8314610192575b600080fd5b610139610134366004612b19565b610329565b6040519081526020015b60405180910390f35b61013961015a366004612a3c565b6105e9565b61017261016d3660046126f5565b610700565b604080516001600160a01b03938416815292909116602083015201610143565b6101a56101a036600461287c565b610782565b60408051928352602083019190915201610143565b6101396101c83660046127bc565b6107f3565b6101e06101db3660046127f0565b610bc9565b60408051938452602084019290925290820152606001610143565b6101a5610209366004612765565b61100a565b61013961021c366004612aab565b6110eb565b61023461022f36600461272d565b611258565b6040519015158152602001610143565b61013961025236600461287c565b6116e4565b61026a6102653660046126f5565b61170b565b60405161014393929190612c5e565b610139610287366004612a0b565b61190c565b61013961029a366004612bf1565b611a19565b6000546102b2906001600160a01b031681565b6040516001600160a01b039091168152602001610143565b6101396102d83660046129de565b611b27565b6101396102eb3660046127f0565b611bd5565b6101e06102fe36600461272d565b611f45565b6101a5610311366004612838565b6121bf565b610139610324366004612bb7565b6124f3565b8051602082015160a083015160405163c2edfc7360e01b81526001600160a01b038085166004830152600094859485946103bd949293919291169063c2edfc739060240160206040518083038186803b15801561038557600080fd5b505afa158015610399573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101db9190612711565b9250509150600084600001516001600160a01b0316631a1dbabb6040518163ffffffff1660e01b815260040160206040518083038186803b15801561040157600080fd5b505afa158015610415573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104399190612b9f565b6002149050600085604001518411610452576000610461565b60408601516104619085612e69565b905060008660400151851161048f578487604001516104809190612e69565b61048a9085612d2e565b610491565b835b9050848760400151116104e0576104d96040518060a0016040528087815260200186815260200189604001518152602001896080015181526020018960c001518152506105e9565b95506105df565b84156105c15760006104ff886000015189602001518a60e0015161261e565b905060008461051f5761051a82670de0b6b3a7640000612e69565b610564565b88516105649060008b60200151600281111561054b57634e487b7160e01b600052602160045260246000fd5b1461055757600061055a565b60015b8b60e0015161261e565b90506105b86040518061010001604052808b6040015181526020018981526020018881526020018b6080015181526020018b6060015181526020018481526020018381526020018b60c001518152506110eb565b975050506105df565b6105dc8760400151858784868c606001518d60c00151611a19565b95505b5050505050919050565b604081015181516020830151600092839261067992670de0b6b3a7640000811161063557602087015161062490670de0b6b3a7640000612e69565b87516106309190612d2e565b610638565b86515b670de0b6b3a764000088602001511161065257600061066a565b670de0b6b3a7640000886020015161066a9190612e69565b88606001518960800151611a19565b60408401518451919250829160009161069191612e69565b90506000670de0b6b3a7640000808760000151670de0b6b3a7640000856106b89190612e0b565b6106c29190612d74565b6106cc9190612d2e565b6106d7600286612d74565b6106e19190612e0b565b6106eb9190612d74565b90506106f681612e80565b9695505050505050565b600080600080846001600160a01b031663647b65df6040518163ffffffff1660e01b8152600401604080518083038186803b15801561073e57600080fd5b505afa158015610752573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610776919061296f565b90969095509350505050565b60008060008060006107938761170b565b9250925092506107a381846107f3565b94506107af81836107f3565b93506000851180156107c15750600084115b156107e9578585106107d357846107d5565b855b94508584106107e457836107e6565b855b93505b5050509250929050565b600080546040805163bb96af6560e01b8152905183926001600160a01b03169163bb96af65916004808301926020929190829003018186803b15801561083857600080fd5b505afa15801561084c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108709190612711565b905082600281111561089257634e487b7160e01b600052602160045260246000fd5b846001600160a01b0316631a1dbabb6040518163ffffffff1660e01b815260040160206040518083038186803b1580156108cb57600080fd5b505afa1580156108df573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109039190612b9f565b1115610bc2576000846001600160a01b0316631a1dbabb6040518163ffffffff1660e01b815260040160206040518083038186803b15801561094457600080fd5b505afa158015610958573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061097c9190612b9f565b67ffffffffffffffff8111156109a257634e487b7160e01b600052604160045260246000fd5b6040519080825280602002602001820160405280156109cb578160200160208202803683370190505b5060405163db0d457960e01b81526001600160a01b0387811660048301529192509083169063db0d45799060240160006040518083038186803b158015610a1157600080fd5b505afa158015610a25573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610a4d91908101906128a7565b6040516308208aaf60e21b81526000600482018190529192506001600160a01b038716906320822abc9060240160206040518083038186803b158015610a9257600080fd5b505afa158015610aa6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610aca9190612b9f565b6000546040516346fe88bf60e11b8152600481018390529192506001600160a01b031690638dfd117e9060240160206040518083038186803b158015610b0f57600080fd5b505afa158015610b23573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b47919061294f565b1580610b705750846002811115610b6e57634e487b7160e01b600052602160045260246000fd5b155b15610bbf5781856002811115610b9657634e487b7160e01b600052602160045260246000fd5b81518110610bb457634e487b7160e01b600052603260045260246000fd5b602002602001015193505b50505b5092915050565b6000806000806000876001600160a01b031663cc2ee1966040518163ffffffff1660e01b815260040160606040518083038186803b158015610c0a57600080fd5b505afa158015610c1e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c42919061299d565b509092509050600080886002811115610c6b57634e487b7160e01b600052602160045260246000fd5b14610cee57604051634dcb776760e11b81526001600160a01b038881166004830152831690639b96eece9060240160206040518083038186803b158015610cb157600080fd5b505afa158015610cc5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ce99190612b9f565b610d67565b604051634dcb776760e11b81526001600160a01b038881166004830152841690639b96eece9060240160206040518083038186803b158015610d2f57600080fd5b505afa158015610d43573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d679190612b9f565b9050600080896002811115610d8c57634e487b7160e01b600052602160045260246000fd5b14610e0f57604051634dcb776760e11b81526001600160a01b038981166004830152851690639b96eece9060240160206040518083038186803b158015610dd257600080fd5b505afa158015610de6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e0a9190612b9f565b610e88565b604051634dcb776760e11b81526001600160a01b038981166004830152841690639b96eece9060240160206040518083038186803b158015610e5057600080fd5b505afa158015610e64573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e889190612b9f565b905060008190508a6001600160a01b0316631a1dbabb6040518163ffffffff1660e01b815260040160206040518083038186803b158015610ec857600080fd5b505afa158015610edc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f009190612b9f565b60031415610ff9576000806000610f178e8d611f45565b9194509250905060008d6002811115610f4057634e487b7160e01b600052602160045260246000fd5b1415610f675782955080821015610f5c57809450819350610ff5565b819450809350610ff5565b60018d6002811115610f8957634e487b7160e01b600052602160045260246000fd5b1415610fb05781955080831015610fa557809450829350610ff5565b829450809350610ff5565b60028d6002811115610fd257634e487b7160e01b600052602160045260246000fd5b1415610ff55780955081831015610fee57819450829350610ff5565b8294508193505b5050505b919a90995090975095505050505050565b600080600080600061101c8989611f45565b91945092509050600087600281111561104557634e487b7160e01b600052602160045260246000fd5b1461107d57600187600281111561106c57634e487b7160e01b600052602160045260246000fd5b14611077578061107f565b8161107f565b825b945060008660028111156110a357634e487b7160e01b600052602160045260246000fd5b146110db5760018660028111156110ca57634e487b7160e01b600052602160045260246000fd5b146110d557806110dd565b816110dd565b825b935050505094509492505050565b600080826020015183600001516111029190612e69565b905060008360200151846040015161111a9190612d2e565b9050600082856040015161112e9190612d2e565b90506000856020015186608001516111469190612e69565b9050600061115f85856000866000878d60e00151611a19565b905060008760a00151828960c001516111789190612e0b565b6111829190612d74565b905060006111c96040518060a001604052808b6020015181526020018b6040015181526020018b6020015181526020018b6060015181526020018b60e001518152506105e9565b90506000818a602001516111dd9190612d88565b905060006111eb848a612e0b565b90506000898c602001516111ff9190612d2e565b90508061120c8385612ced565b6112169190612d46565b9a5060008b13156112495760008b8d60a001516112339190612d88565b90508c60c00151816112459190612d46565b9b50505b50505050505050505050919050565b60008060009054906101000a90046001600160a01b03166001600160a01b031663481c6a756040518163ffffffff1660e01b815260040160206040518083038186803b1580156112a757600080fd5b505afa1580156112bb573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112df9190612711565b60405163e62b888960e01b81526001600160a01b038581166004830152919091169063e62b88899060240160206040518083038186803b15801561132257600080fd5b505afa158015611336573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061135a919061294f565b80156113d45750826001600160a01b0316635c975abb6040518163ffffffff1660e01b815260040160206040518083038186803b15801561139a57600080fd5b505afa1580156113ae573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113d2919061294f565b155b801561144c5750826001600160a01b0316633f6fa6556040518163ffffffff1660e01b815260040160206040518083038186803b15801561141457600080fd5b505afa158015611428573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061144c919061294f565b156116de576000806000856001600160a01b031663cc2ee1966040518163ffffffff1660e01b815260040160606040518083038186803b15801561148f57600080fd5b505afa1580156114a3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114c7919061299d565b604051634dcb776760e11b81526001600160a01b0389811660048301529396509194509250600091851690639b96eece9060240160206040518083038186803b15801561151357600080fd5b505afa158015611527573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061154b9190612b9f565b11806115d15750604051634dcb776760e11b81526001600160a01b03868116600483015260009190841690639b96eece9060240160206040518083038186803b15801561159757600080fd5b505afa1580156115ab573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115cf9190612b9f565b115b806116d157506002866001600160a01b0316631a1dbabb6040518163ffffffff1660e01b815260040160206040518083038186803b15801561161257600080fd5b505afa158015611626573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061164a9190612b9f565b1180156116d15750604051634dcb776760e11b81526001600160a01b03868116600483015260009190831690639b96eece9060240160206040518083038186803b15801561169757600080fd5b505afa1580156116ab573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116cf9190612b9f565b115b15610bbf57600193505050505b92915050565b60008060006116f38585610782565b90925090506117028183612d2e565b95945050505050565b600080600080846001600160a01b031663d03ecc646040518163ffffffff1660e01b815260040160206040518083038186803b15801561174a57600080fd5b505afa15801561175e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117829190612711565b9050600080866001600160a01b031663647b65df6040518163ffffffff1660e01b8152600401604080518083038186803b1580156117bf57600080fd5b505afa1580156117d3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117f7919061296f565b91509150600080846001600160a01b031663cc2ee1966040518163ffffffff1660e01b815260040160606040518083038186803b15801561183757600080fd5b505afa15801561184b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061186f919061299d565b5091509150816001600160a01b0316846001600160a01b0316146118b457806001600160a01b0316846001600160a01b0316146118ad5760026118b7565b60016118b7565b60005b9750816001600160a01b0316836001600160a01b0316146118f957806001600160a01b0316836001600160a01b0316146118f25760026118fc565b60016118fc565b60005b9799979850939695505050505050565b60008085126119b3576000670de0b6b3a76400008661192b8783612e2a565b6119359190612d88565b61193f9190612d46565b9050670de0b6b3a764000061195c662386f26fc100006002612d88565b61196e90670de0b6b3a7640000612ced565b6119789083612d88565b6119829190612d46565b9050670de0b6b3a76400006119978287612ced565b6119a19085612d88565b6119ab9190612d46565b9150506119f2565b670de0b6b3a7640000806119c78782612ced565b6119d19087612d88565b6119db9190612d46565b6119e59084612d88565b6119ef9190612d46565b90505b670de0b6b3a7640000611a058482612ced565b611a0f9083612d88565b6117029190612d46565b60008086611a27858a612d2e565b611a319190612e69565b90506000611a3f8688612e69565b90506000670de0b6b3a764000083611a578285612e0b565b611a619190612d74565b611a6b9087612e0b565b611a759190612d74565b90508815611ad9576000611a8a600283612d74565b9050600081611a998c8f612e69565b611aa39190612e0b565b9050670de0b6b3a76400008d611ab98284612e0b565b611ac39190612d74565b611acd9190612d74565b95505050505050611b1c565b896000670de0b6b3a764000085611af08285612e0b565b611afa9190612d74565b611b049089612e0b565b611b0e9190612d74565b90506002611ac38285612d2e565b979650505050505050565b600080600080611b378587611f45565b919450925090506000876002811115611b6057634e487b7160e01b600052602160045260246000fd5b1415611b7c57808210611b735780611b75565b815b9350611bcb565b6001876002811115611b9e57634e487b7160e01b600052602160045260246000fd5b1415611bb957808310611bb15780611b75565b829350611bcb565b818310611bc65781611bc8565b825b93505b5050509392505050565b600080600080866001600160a01b031663cc2ee1966040518163ffffffff1660e01b815260040160606040518083038186803b158015611c1457600080fd5b505afa158015611c28573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c4c919061299d565b91945092509050600080876002811115611c7657634e487b7160e01b600052602160045260246000fd5b14611cf957604051634dcb776760e11b81526001600160a01b038781166004830152841690639b96eece9060240160206040518083038186803b158015611cbc57600080fd5b505afa158015611cd0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611cf49190612b9f565b611d72565b604051634dcb776760e11b81526001600160a01b038781166004830152851690639b96eece9060240160206040518083038186803b158015611d3a57600080fd5b505afa158015611d4e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d729190612b9f565b9050876001600160a01b0316631a1dbabb6040518163ffffffff1660e01b815260040160206040518083038186803b158015611dad57600080fd5b505afa158015611dc1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611de59190612b9f565b6003148015611e1457506000876002811115611e1157634e487b7160e01b600052602160045260246000fd5b14155b15611bc8576001876002811115611e3b57634e487b7160e01b600052602160045260246000fd5b14611ebe57604051634dcb776760e11b81526001600160a01b038781166004830152831690639b96eece9060240160206040518083038186803b158015611e8157600080fd5b505afa158015611e95573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611eb99190612b9f565b611f37565b604051634dcb776760e11b81526001600160a01b038781166004830152841690639b96eece9060240160206040518083038186803b158015611eff57600080fd5b505afa158015611f13573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f379190612b9f565b9450505050505b9392505050565b600080600080600080876001600160a01b031663cc2ee1966040518163ffffffff1660e01b815260040160606040518083038186803b158015611f8757600080fd5b505afa158015611f9b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611fbf919061299d565b604051634dcb776760e11b81526001600160a01b038b81166004830152939650919450925090841690639b96eece9060240160206040518083038186803b15801561200957600080fd5b505afa15801561201d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120419190612b9f565b604051634dcb776760e11b81526001600160a01b03898116600483015291975090831690639b96eece9060240160206040518083038186803b15801561208657600080fd5b505afa15801561209a573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120be9190612b9f565b9450876001600160a01b0316631a1dbabb6040518163ffffffff1660e01b815260040160206040518083038186803b1580156120f957600080fd5b505afa15801561210d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121319190612b9f565b600314156121b557604051634dcb776760e11b81526001600160a01b038881166004830152821690639b96eece9060240160206040518083038186803b15801561217a57600080fd5b505afa15801561218e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121b29190612b9f565b93505b5050509250925092565b60008060008060009054906101000a90046001600160a01b03166001600160a01b031663bb96af656040518163ffffffff1660e01b815260040160206040518083038186803b15801561221157600080fd5b505afa158015612225573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122499190612711565b90506000866001600160a01b0316631a1dbabb6040518163ffffffff1660e01b815260040160206040518083038186803b15801561228657600080fd5b505afa15801561229a573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122be9190612b9f565b90506000876001600160a01b0316631a1dbabb6040518163ffffffff1660e01b815260040160206040518083038186803b1580156122fb57600080fd5b505afa15801561230f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123339190612b9f565b67ffffffffffffffff81111561235957634e487b7160e01b600052604160045260246000fd5b604051908082528060200260200182016040528015612382578160200160208202803683370190505b5060405163db0d457960e01b81526001600160a01b038a811660048301529192509084169063db0d45799060240160006040518083038186803b1580156123c857600080fd5b505afa1580156123dc573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261240491908101906128a7565b905086600281111561242657634e487b7160e01b600052602160045260246000fd5b821115612477578087600281111561244e57634e487b7160e01b600052602160045260246000fd5b8151811061246c57634e487b7160e01b600052603260045260246000fd5b602002602001015194505b85600281111561249757634e487b7160e01b600052602160045260246000fd5b8211156124e857808660028111156124bf57634e487b7160e01b600052602160045260246000fd5b815181106124dd57634e487b7160e01b600052603260045260246000fd5b602002602001015193505b505050935093915050565b600080670de0b6b3a764000061250a600285612d74565b61251c90670de0b6b3a7640000612e69565b6125269087612e0b565b6125309190612d74565b90506000670de0b6b3a76400006125478387612e0b565b6125519190612d74565b90508661255e828a612d2e565b111561261357600087612571838b612d2e565b61257b9190612e69565b9050888111156125885750875b6000670de0b6b3a764000061259e600288612d74565b6125b08a670de0b6b3a7640000612e69565b6125ba9190612e0b565b6125c49190612d74565b905060006125d2828a612d2e565b6125e490670de0b6b3a7640000612e69565b9050806125f9670de0b6b3a764000085612e0b565b6126039190612d74565b61260d9089612d2e565b95505050505b505095945050505050565b6000836001600160a01b031663fa20d6686040518163ffffffff1660e01b815260040160206040518083038186803b15801561265957600080fd5b505afa15801561266d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612691919061294f565b156126cf5760008360028111156126b857634e487b7160e01b600052602160045260246000fd5b14156126cf576126c884836116e4565b9050611f3e565b6126d984846107f3565b949350505050565b8035600381106126f057600080fd5b919050565b600060208284031215612706578081fd5b8135611f3e81612edc565b600060208284031215612722578081fd5b8151611f3e81612edc565b6000806040838503121561273f578081fd5b823561274a81612edc565b9150602083013561275a81612edc565b809150509250929050565b6000806000806080858703121561277a578182fd5b843561278581612edc565b9350602085013561279581612edc565b92506127a3604086016126e1565b91506127b1606086016126e1565b905092959194509250565b600080604083850312156127ce578182fd5b82356127d981612edc565b91506127e7602084016126e1565b90509250929050565b600080600060608486031215612804578283fd5b833561280f81612edc565b925061281d602085016126e1565b9150604084013561282d81612edc565b809150509250925092565b60008060006060848603121561284c578081fd5b833561285781612edc565b9250612865602085016126e1565b9150612873604085016126e1565b90509250925092565b6000806040838503121561288e578182fd5b823561289981612edc565b946020939093013593505050565b600060208083850312156128b9578182fd5b825167ffffffffffffffff808211156128d0578384fd5b818501915085601f8301126128e3578384fd5b8151818111156128f5576128f5612ec6565b8060051b9150612906848301612cbc565b8181528481019084860184860187018a1015612920578788fd5b8795505b83861015612942578051835260019590950194918601918601612924565b5098975050505050505050565b600060208284031215612960578081fd5b81518015158114611f3e578182fd5b60008060408385031215612981578182fd5b825161298c81612edc565b602084015190925061275a81612edc565b6000806000606084860312156129b1578081fd5b83516129bc81612edc565b60208501519093506129cd81612edc565b604085015190925061282d81612edc565b6000806000606084860312156129f2578081fd5b6129fb846126e1565b9250602084013561281d81612edc565b60008060008060808587031215612a20578182fd5b5050823594602084013594506040840135936060013592509050565b600060a08284031215612a4d578081fd5b60405160a0810181811067ffffffffffffffff82111715612a7057612a70612ec6565b806040525082358152602083013560208201526040830135604082015260608301356060820152608083013560808201528091505092915050565b60006101008284031215612abd578081fd5b612ac5612c92565b823581526020830135602082015260408301356040820152606083013560608201526080830135608082015260a083013560a082015260c083013560c082015260e083013560e08201528091505092915050565b60006101008284031215612b2b578081fd5b612b33612c92565b8235612b3e81612edc565b8152612b4c602084016126e1565b602082015260408301356040820152606083013560608201526080830135608082015260a0830135612b7d81612edc565b60a082015260c0838101359082015260e0928301359281019290925250919050565b600060208284031215612bb0578081fd5b5051919050565b600080600080600060a08688031215612bce578283fd5b505083359560208501359550604085013594606081013594506080013592509050565b600080600080600080600060e0888a031215612c0b578485fd5b505085359760208701359750604087013596606081013596506080810135955060a0810135945060c0013592509050565b60038110612c5a57634e487b7160e01b600052602160045260246000fd5b9052565b60608101612c6c8286612c3c565b612c796020830185612c3c565b6001600160a01b03929092166040919091015292915050565b604051610100810167ffffffffffffffff81118282101715612cb657612cb6612ec6565b60405290565b604051601f8201601f1916810167ffffffffffffffff81118282101715612ce557612ce5612ec6565b604052919050565b600080821280156001600160ff1b0384900385131615612d0f57612d0f612e9a565b600160ff1b8390038412811615612d2857612d28612e9a565b50500190565b60008219821115612d4157612d41612e9a565b500190565b600082612d5557612d55612eb0565b600160ff1b821460001984141615612d6f57612d6f612e9a565b500590565b600082612d8357612d83612eb0565b500490565b60006001600160ff1b0381841382841380821686840486111615612dae57612dae612e9a565b600160ff1b84871282811687830589121615612dcc57612dcc612e9a565b858712925087820587128484161615612de757612de7612e9a565b87850587128184161615612dfd57612dfd612e9a565b505050929093029392505050565b6000816000190483118215151615612e2557612e25612e9a565b500290565b60008083128015600160ff1b850184121615612e4857612e48612e9a565b6001600160ff1b0384018313811615612e6357612e63612e9a565b50500390565b600082821015612e7b57612e7b612e9a565b500390565b6000600160ff1b821415612e9657612e96612e9a565b0390565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b0381168114612ef157600080fd5b5056fea26469706673582212201eab0d0bfdbcf66e251b8a99b9a02f874e71f6e2a780e2004748c09edf706ad564736f6c63430008040033000000000000000000000000170a5714112daeff20e798b6e92e25b86ea603c1
Deployed Bytecode
0x608060405234801561001057600080fd5b50600436106101215760003560e01c8063a119612d116100ad578063d95bff2511610071578063d95bff25146102ca578063e468265c146102dd578063ea25928a146102f0578063f54ffd0014610303578063f947c6b31461031657600080fd5b8063a119612d14610244578063a4d682dd14610257578063ad2ddaa414610279578063c3812fe21461028c578063c99252881461029f57600080fd5b806350d851a1116100f457806350d851a1146101ba5780636116ad1e146101cd578063755cc89c146101fb57806380143b9b1461020e5780639612e9a31461022157600080fd5b80630381cd09146101265780632888a20d1461014c57806331b8975e1461015f5780634ab96c8314610192575b600080fd5b610139610134366004612b19565b610329565b6040519081526020015b60405180910390f35b61013961015a366004612a3c565b6105e9565b61017261016d3660046126f5565b610700565b604080516001600160a01b03938416815292909116602083015201610143565b6101a56101a036600461287c565b610782565b60408051928352602083019190915201610143565b6101396101c83660046127bc565b6107f3565b6101e06101db3660046127f0565b610bc9565b60408051938452602084019290925290820152606001610143565b6101a5610209366004612765565b61100a565b61013961021c366004612aab565b6110eb565b61023461022f36600461272d565b611258565b6040519015158152602001610143565b61013961025236600461287c565b6116e4565b61026a6102653660046126f5565b61170b565b60405161014393929190612c5e565b610139610287366004612a0b565b61190c565b61013961029a366004612bf1565b611a19565b6000546102b2906001600160a01b031681565b6040516001600160a01b039091168152602001610143565b6101396102d83660046129de565b611b27565b6101396102eb3660046127f0565b611bd5565b6101e06102fe36600461272d565b611f45565b6101a5610311366004612838565b6121bf565b610139610324366004612bb7565b6124f3565b8051602082015160a083015160405163c2edfc7360e01b81526001600160a01b038085166004830152600094859485946103bd949293919291169063c2edfc739060240160206040518083038186803b15801561038557600080fd5b505afa158015610399573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101db9190612711565b9250509150600084600001516001600160a01b0316631a1dbabb6040518163ffffffff1660e01b815260040160206040518083038186803b15801561040157600080fd5b505afa158015610415573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104399190612b9f565b6002149050600085604001518411610452576000610461565b60408601516104619085612e69565b905060008660400151851161048f578487604001516104809190612e69565b61048a9085612d2e565b610491565b835b9050848760400151116104e0576104d96040518060a0016040528087815260200186815260200189604001518152602001896080015181526020018960c001518152506105e9565b95506105df565b84156105c15760006104ff886000015189602001518a60e0015161261e565b905060008461051f5761051a82670de0b6b3a7640000612e69565b610564565b88516105649060008b60200151600281111561054b57634e487b7160e01b600052602160045260246000fd5b1461055757600061055a565b60015b8b60e0015161261e565b90506105b86040518061010001604052808b6040015181526020018981526020018881526020018b6080015181526020018b6060015181526020018481526020018381526020018b60c001518152506110eb565b975050506105df565b6105dc8760400151858784868c606001518d60c00151611a19565b95505b5050505050919050565b604081015181516020830151600092839261067992670de0b6b3a7640000811161063557602087015161062490670de0b6b3a7640000612e69565b87516106309190612d2e565b610638565b86515b670de0b6b3a764000088602001511161065257600061066a565b670de0b6b3a7640000886020015161066a9190612e69565b88606001518960800151611a19565b60408401518451919250829160009161069191612e69565b90506000670de0b6b3a7640000808760000151670de0b6b3a7640000856106b89190612e0b565b6106c29190612d74565b6106cc9190612d2e565b6106d7600286612d74565b6106e19190612e0b565b6106eb9190612d74565b90506106f681612e80565b9695505050505050565b600080600080846001600160a01b031663647b65df6040518163ffffffff1660e01b8152600401604080518083038186803b15801561073e57600080fd5b505afa158015610752573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610776919061296f565b90969095509350505050565b60008060008060006107938761170b565b9250925092506107a381846107f3565b94506107af81836107f3565b93506000851180156107c15750600084115b156107e9578585106107d357846107d5565b855b94508584106107e457836107e6565b855b93505b5050509250929050565b600080546040805163bb96af6560e01b8152905183926001600160a01b03169163bb96af65916004808301926020929190829003018186803b15801561083857600080fd5b505afa15801561084c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108709190612711565b905082600281111561089257634e487b7160e01b600052602160045260246000fd5b846001600160a01b0316631a1dbabb6040518163ffffffff1660e01b815260040160206040518083038186803b1580156108cb57600080fd5b505afa1580156108df573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109039190612b9f565b1115610bc2576000846001600160a01b0316631a1dbabb6040518163ffffffff1660e01b815260040160206040518083038186803b15801561094457600080fd5b505afa158015610958573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061097c9190612b9f565b67ffffffffffffffff8111156109a257634e487b7160e01b600052604160045260246000fd5b6040519080825280602002602001820160405280156109cb578160200160208202803683370190505b5060405163db0d457960e01b81526001600160a01b0387811660048301529192509083169063db0d45799060240160006040518083038186803b158015610a1157600080fd5b505afa158015610a25573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610a4d91908101906128a7565b6040516308208aaf60e21b81526000600482018190529192506001600160a01b038716906320822abc9060240160206040518083038186803b158015610a9257600080fd5b505afa158015610aa6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610aca9190612b9f565b6000546040516346fe88bf60e11b8152600481018390529192506001600160a01b031690638dfd117e9060240160206040518083038186803b158015610b0f57600080fd5b505afa158015610b23573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b47919061294f565b1580610b705750846002811115610b6e57634e487b7160e01b600052602160045260246000fd5b155b15610bbf5781856002811115610b9657634e487b7160e01b600052602160045260246000fd5b81518110610bb457634e487b7160e01b600052603260045260246000fd5b602002602001015193505b50505b5092915050565b6000806000806000876001600160a01b031663cc2ee1966040518163ffffffff1660e01b815260040160606040518083038186803b158015610c0a57600080fd5b505afa158015610c1e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c42919061299d565b509092509050600080886002811115610c6b57634e487b7160e01b600052602160045260246000fd5b14610cee57604051634dcb776760e11b81526001600160a01b038881166004830152831690639b96eece9060240160206040518083038186803b158015610cb157600080fd5b505afa158015610cc5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ce99190612b9f565b610d67565b604051634dcb776760e11b81526001600160a01b038881166004830152841690639b96eece9060240160206040518083038186803b158015610d2f57600080fd5b505afa158015610d43573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d679190612b9f565b9050600080896002811115610d8c57634e487b7160e01b600052602160045260246000fd5b14610e0f57604051634dcb776760e11b81526001600160a01b038981166004830152851690639b96eece9060240160206040518083038186803b158015610dd257600080fd5b505afa158015610de6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e0a9190612b9f565b610e88565b604051634dcb776760e11b81526001600160a01b038981166004830152841690639b96eece9060240160206040518083038186803b158015610e5057600080fd5b505afa158015610e64573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e889190612b9f565b905060008190508a6001600160a01b0316631a1dbabb6040518163ffffffff1660e01b815260040160206040518083038186803b158015610ec857600080fd5b505afa158015610edc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f009190612b9f565b60031415610ff9576000806000610f178e8d611f45565b9194509250905060008d6002811115610f4057634e487b7160e01b600052602160045260246000fd5b1415610f675782955080821015610f5c57809450819350610ff5565b819450809350610ff5565b60018d6002811115610f8957634e487b7160e01b600052602160045260246000fd5b1415610fb05781955080831015610fa557809450829350610ff5565b829450809350610ff5565b60028d6002811115610fd257634e487b7160e01b600052602160045260246000fd5b1415610ff55780955081831015610fee57819450829350610ff5565b8294508193505b5050505b919a90995090975095505050505050565b600080600080600061101c8989611f45565b91945092509050600087600281111561104557634e487b7160e01b600052602160045260246000fd5b1461107d57600187600281111561106c57634e487b7160e01b600052602160045260246000fd5b14611077578061107f565b8161107f565b825b945060008660028111156110a357634e487b7160e01b600052602160045260246000fd5b146110db5760018660028111156110ca57634e487b7160e01b600052602160045260246000fd5b146110d557806110dd565b816110dd565b825b935050505094509492505050565b600080826020015183600001516111029190612e69565b905060008360200151846040015161111a9190612d2e565b9050600082856040015161112e9190612d2e565b90506000856020015186608001516111469190612e69565b9050600061115f85856000866000878d60e00151611a19565b905060008760a00151828960c001516111789190612e0b565b6111829190612d74565b905060006111c96040518060a001604052808b6020015181526020018b6040015181526020018b6020015181526020018b6060015181526020018b60e001518152506105e9565b90506000818a602001516111dd9190612d88565b905060006111eb848a612e0b565b90506000898c602001516111ff9190612d2e565b90508061120c8385612ced565b6112169190612d46565b9a5060008b13156112495760008b8d60a001516112339190612d88565b90508c60c00151816112459190612d46565b9b50505b50505050505050505050919050565b60008060009054906101000a90046001600160a01b03166001600160a01b031663481c6a756040518163ffffffff1660e01b815260040160206040518083038186803b1580156112a757600080fd5b505afa1580156112bb573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112df9190612711565b60405163e62b888960e01b81526001600160a01b038581166004830152919091169063e62b88899060240160206040518083038186803b15801561132257600080fd5b505afa158015611336573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061135a919061294f565b80156113d45750826001600160a01b0316635c975abb6040518163ffffffff1660e01b815260040160206040518083038186803b15801561139a57600080fd5b505afa1580156113ae573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113d2919061294f565b155b801561144c5750826001600160a01b0316633f6fa6556040518163ffffffff1660e01b815260040160206040518083038186803b15801561141457600080fd5b505afa158015611428573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061144c919061294f565b156116de576000806000856001600160a01b031663cc2ee1966040518163ffffffff1660e01b815260040160606040518083038186803b15801561148f57600080fd5b505afa1580156114a3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114c7919061299d565b604051634dcb776760e11b81526001600160a01b0389811660048301529396509194509250600091851690639b96eece9060240160206040518083038186803b15801561151357600080fd5b505afa158015611527573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061154b9190612b9f565b11806115d15750604051634dcb776760e11b81526001600160a01b03868116600483015260009190841690639b96eece9060240160206040518083038186803b15801561159757600080fd5b505afa1580156115ab573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115cf9190612b9f565b115b806116d157506002866001600160a01b0316631a1dbabb6040518163ffffffff1660e01b815260040160206040518083038186803b15801561161257600080fd5b505afa158015611626573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061164a9190612b9f565b1180156116d15750604051634dcb776760e11b81526001600160a01b03868116600483015260009190831690639b96eece9060240160206040518083038186803b15801561169757600080fd5b505afa1580156116ab573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116cf9190612b9f565b115b15610bbf57600193505050505b92915050565b60008060006116f38585610782565b90925090506117028183612d2e565b95945050505050565b600080600080846001600160a01b031663d03ecc646040518163ffffffff1660e01b815260040160206040518083038186803b15801561174a57600080fd5b505afa15801561175e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117829190612711565b9050600080866001600160a01b031663647b65df6040518163ffffffff1660e01b8152600401604080518083038186803b1580156117bf57600080fd5b505afa1580156117d3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117f7919061296f565b91509150600080846001600160a01b031663cc2ee1966040518163ffffffff1660e01b815260040160606040518083038186803b15801561183757600080fd5b505afa15801561184b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061186f919061299d565b5091509150816001600160a01b0316846001600160a01b0316146118b457806001600160a01b0316846001600160a01b0316146118ad5760026118b7565b60016118b7565b60005b9750816001600160a01b0316836001600160a01b0316146118f957806001600160a01b0316836001600160a01b0316146118f25760026118fc565b60016118fc565b60005b9799979850939695505050505050565b60008085126119b3576000670de0b6b3a76400008661192b8783612e2a565b6119359190612d88565b61193f9190612d46565b9050670de0b6b3a764000061195c662386f26fc100006002612d88565b61196e90670de0b6b3a7640000612ced565b6119789083612d88565b6119829190612d46565b9050670de0b6b3a76400006119978287612ced565b6119a19085612d88565b6119ab9190612d46565b9150506119f2565b670de0b6b3a7640000806119c78782612ced565b6119d19087612d88565b6119db9190612d46565b6119e59084612d88565b6119ef9190612d46565b90505b670de0b6b3a7640000611a058482612ced565b611a0f9083612d88565b6117029190612d46565b60008086611a27858a612d2e565b611a319190612e69565b90506000611a3f8688612e69565b90506000670de0b6b3a764000083611a578285612e0b565b611a619190612d74565b611a6b9087612e0b565b611a759190612d74565b90508815611ad9576000611a8a600283612d74565b9050600081611a998c8f612e69565b611aa39190612e0b565b9050670de0b6b3a76400008d611ab98284612e0b565b611ac39190612d74565b611acd9190612d74565b95505050505050611b1c565b896000670de0b6b3a764000085611af08285612e0b565b611afa9190612d74565b611b049089612e0b565b611b0e9190612d74565b90506002611ac38285612d2e565b979650505050505050565b600080600080611b378587611f45565b919450925090506000876002811115611b6057634e487b7160e01b600052602160045260246000fd5b1415611b7c57808210611b735780611b75565b815b9350611bcb565b6001876002811115611b9e57634e487b7160e01b600052602160045260246000fd5b1415611bb957808310611bb15780611b75565b829350611bcb565b818310611bc65781611bc8565b825b93505b5050509392505050565b600080600080866001600160a01b031663cc2ee1966040518163ffffffff1660e01b815260040160606040518083038186803b158015611c1457600080fd5b505afa158015611c28573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c4c919061299d565b91945092509050600080876002811115611c7657634e487b7160e01b600052602160045260246000fd5b14611cf957604051634dcb776760e11b81526001600160a01b038781166004830152841690639b96eece9060240160206040518083038186803b158015611cbc57600080fd5b505afa158015611cd0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611cf49190612b9f565b611d72565b604051634dcb776760e11b81526001600160a01b038781166004830152851690639b96eece9060240160206040518083038186803b158015611d3a57600080fd5b505afa158015611d4e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d729190612b9f565b9050876001600160a01b0316631a1dbabb6040518163ffffffff1660e01b815260040160206040518083038186803b158015611dad57600080fd5b505afa158015611dc1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611de59190612b9f565b6003148015611e1457506000876002811115611e1157634e487b7160e01b600052602160045260246000fd5b14155b15611bc8576001876002811115611e3b57634e487b7160e01b600052602160045260246000fd5b14611ebe57604051634dcb776760e11b81526001600160a01b038781166004830152831690639b96eece9060240160206040518083038186803b158015611e8157600080fd5b505afa158015611e95573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611eb99190612b9f565b611f37565b604051634dcb776760e11b81526001600160a01b038781166004830152841690639b96eece9060240160206040518083038186803b158015611eff57600080fd5b505afa158015611f13573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f379190612b9f565b9450505050505b9392505050565b600080600080600080876001600160a01b031663cc2ee1966040518163ffffffff1660e01b815260040160606040518083038186803b158015611f8757600080fd5b505afa158015611f9b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611fbf919061299d565b604051634dcb776760e11b81526001600160a01b038b81166004830152939650919450925090841690639b96eece9060240160206040518083038186803b15801561200957600080fd5b505afa15801561201d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120419190612b9f565b604051634dcb776760e11b81526001600160a01b03898116600483015291975090831690639b96eece9060240160206040518083038186803b15801561208657600080fd5b505afa15801561209a573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120be9190612b9f565b9450876001600160a01b0316631a1dbabb6040518163ffffffff1660e01b815260040160206040518083038186803b1580156120f957600080fd5b505afa15801561210d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121319190612b9f565b600314156121b557604051634dcb776760e11b81526001600160a01b038881166004830152821690639b96eece9060240160206040518083038186803b15801561217a57600080fd5b505afa15801561218e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121b29190612b9f565b93505b5050509250925092565b60008060008060009054906101000a90046001600160a01b03166001600160a01b031663bb96af656040518163ffffffff1660e01b815260040160206040518083038186803b15801561221157600080fd5b505afa158015612225573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122499190612711565b90506000866001600160a01b0316631a1dbabb6040518163ffffffff1660e01b815260040160206040518083038186803b15801561228657600080fd5b505afa15801561229a573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122be9190612b9f565b90506000876001600160a01b0316631a1dbabb6040518163ffffffff1660e01b815260040160206040518083038186803b1580156122fb57600080fd5b505afa15801561230f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123339190612b9f565b67ffffffffffffffff81111561235957634e487b7160e01b600052604160045260246000fd5b604051908082528060200260200182016040528015612382578160200160208202803683370190505b5060405163db0d457960e01b81526001600160a01b038a811660048301529192509084169063db0d45799060240160006040518083038186803b1580156123c857600080fd5b505afa1580156123dc573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261240491908101906128a7565b905086600281111561242657634e487b7160e01b600052602160045260246000fd5b821115612477578087600281111561244e57634e487b7160e01b600052602160045260246000fd5b8151811061246c57634e487b7160e01b600052603260045260246000fd5b602002602001015194505b85600281111561249757634e487b7160e01b600052602160045260246000fd5b8211156124e857808660028111156124bf57634e487b7160e01b600052602160045260246000fd5b815181106124dd57634e487b7160e01b600052603260045260246000fd5b602002602001015193505b505050935093915050565b600080670de0b6b3a764000061250a600285612d74565b61251c90670de0b6b3a7640000612e69565b6125269087612e0b565b6125309190612d74565b90506000670de0b6b3a76400006125478387612e0b565b6125519190612d74565b90508661255e828a612d2e565b111561261357600087612571838b612d2e565b61257b9190612e69565b9050888111156125885750875b6000670de0b6b3a764000061259e600288612d74565b6125b08a670de0b6b3a7640000612e69565b6125ba9190612e0b565b6125c49190612d74565b905060006125d2828a612d2e565b6125e490670de0b6b3a7640000612e69565b9050806125f9670de0b6b3a764000085612e0b565b6126039190612d74565b61260d9089612d2e565b95505050505b505095945050505050565b6000836001600160a01b031663fa20d6686040518163ffffffff1660e01b815260040160206040518083038186803b15801561265957600080fd5b505afa15801561266d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612691919061294f565b156126cf5760008360028111156126b857634e487b7160e01b600052602160045260246000fd5b14156126cf576126c884836116e4565b9050611f3e565b6126d984846107f3565b949350505050565b8035600381106126f057600080fd5b919050565b600060208284031215612706578081fd5b8135611f3e81612edc565b600060208284031215612722578081fd5b8151611f3e81612edc565b6000806040838503121561273f578081fd5b823561274a81612edc565b9150602083013561275a81612edc565b809150509250929050565b6000806000806080858703121561277a578182fd5b843561278581612edc565b9350602085013561279581612edc565b92506127a3604086016126e1565b91506127b1606086016126e1565b905092959194509250565b600080604083850312156127ce578182fd5b82356127d981612edc565b91506127e7602084016126e1565b90509250929050565b600080600060608486031215612804578283fd5b833561280f81612edc565b925061281d602085016126e1565b9150604084013561282d81612edc565b809150509250925092565b60008060006060848603121561284c578081fd5b833561285781612edc565b9250612865602085016126e1565b9150612873604085016126e1565b90509250925092565b6000806040838503121561288e578182fd5b823561289981612edc565b946020939093013593505050565b600060208083850312156128b9578182fd5b825167ffffffffffffffff808211156128d0578384fd5b818501915085601f8301126128e3578384fd5b8151818111156128f5576128f5612ec6565b8060051b9150612906848301612cbc565b8181528481019084860184860187018a1015612920578788fd5b8795505b83861015612942578051835260019590950194918601918601612924565b5098975050505050505050565b600060208284031215612960578081fd5b81518015158114611f3e578182fd5b60008060408385031215612981578182fd5b825161298c81612edc565b602084015190925061275a81612edc565b6000806000606084860312156129b1578081fd5b83516129bc81612edc565b60208501519093506129cd81612edc565b604085015190925061282d81612edc565b6000806000606084860312156129f2578081fd5b6129fb846126e1565b9250602084013561281d81612edc565b60008060008060808587031215612a20578182fd5b5050823594602084013594506040840135936060013592509050565b600060a08284031215612a4d578081fd5b60405160a0810181811067ffffffffffffffff82111715612a7057612a70612ec6565b806040525082358152602083013560208201526040830135604082015260608301356060820152608083013560808201528091505092915050565b60006101008284031215612abd578081fd5b612ac5612c92565b823581526020830135602082015260408301356040820152606083013560608201526080830135608082015260a083013560a082015260c083013560c082015260e083013560e08201528091505092915050565b60006101008284031215612b2b578081fd5b612b33612c92565b8235612b3e81612edc565b8152612b4c602084016126e1565b602082015260408301356040820152606083013560608201526080830135608082015260a0830135612b7d81612edc565b60a082015260c0838101359082015260e0928301359281019290925250919050565b600060208284031215612bb0578081fd5b5051919050565b600080600080600060a08688031215612bce578283fd5b505083359560208501359550604085013594606081013594506080013592509050565b600080600080600080600060e0888a031215612c0b578485fd5b505085359760208701359750604087013596606081013596506080810135955060a0810135945060c0013592509050565b60038110612c5a57634e487b7160e01b600052602160045260246000fd5b9052565b60608101612c6c8286612c3c565b612c796020830185612c3c565b6001600160a01b03929092166040919091015292915050565b604051610100810167ffffffffffffffff81118282101715612cb657612cb6612ec6565b60405290565b604051601f8201601f1916810167ffffffffffffffff81118282101715612ce557612ce5612ec6565b604052919050565b600080821280156001600160ff1b0384900385131615612d0f57612d0f612e9a565b600160ff1b8390038412811615612d2857612d28612e9a565b50500190565b60008219821115612d4157612d41612e9a565b500190565b600082612d5557612d55612eb0565b600160ff1b821460001984141615612d6f57612d6f612e9a565b500590565b600082612d8357612d83612eb0565b500490565b60006001600160ff1b0381841382841380821686840486111615612dae57612dae612e9a565b600160ff1b84871282811687830589121615612dcc57612dcc612e9a565b858712925087820587128484161615612de757612de7612e9a565b87850587128184161615612dfd57612dfd612e9a565b505050929093029392505050565b6000816000190483118215151615612e2557612e25612e9a565b500290565b60008083128015600160ff1b850184121615612e4857612e48612e9a565b6001600160ff1b0384018313811615612e6357612e63612e9a565b50500390565b600082821015612e7b57612e7b612e9a565b500390565b6000600160ff1b821415612e9657612e96612e9a565b0390565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b0381168114612ef157600080fd5b5056fea26469706673582212201eab0d0bfdbcf66e251b8a99b9a02f874e71f6e2a780e2004748c09edf706ad564736f6c63430008040033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
000000000000000000000000170a5714112daeff20e798b6e92e25b86ea603c1
-----Decoded View---------------
Arg [0] : _sportsAMM (address): 0x170a5714112daEfF20E798B6e92e25B86Ea603C1
-----Encoded View---------------
1 Constructor Arguments found :
Arg [0] : 000000000000000000000000170a5714112daeff20e798b6e92e25b86ea603c1
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
[ Download: CSV Export ]
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.