Source Code
Overview
POL Balance
POL Value
$0.00Cross-Chain Transactions
Loading...
Loading
This contract may be a proxy contract. Click on More Options and select Is this a proxy? to confirm and enable the "Read as Proxy" & "Write as Proxy" tabs.
Contract Name:
SpeedMarketsAMM
Compiler Version
v0.8.16+commit.07a7930e
Optimization Enabled:
Yes with 100 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
// external
import "@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol";
import "@openzeppelin/contracts-upgradeable/utils/math/MathUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "@openzeppelin/contracts-upgradeable/utils/math/SafeMathUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol";
import "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol";
import "@openzeppelin/contracts-4.4.1/proxy/Clones.sol";
import "@pythnetwork/pyth-sdk-solidity/IPyth.sol";
// internal
import "../utils/proxy/solidity-0.8.0/ProxyReentrancyGuard.sol";
import "../utils/proxy/solidity-0.8.0/ProxyOwned.sol";
import "../utils/proxy/solidity-0.8.0/ProxyPausable.sol";
import "../utils/libraries/AddressSetLib.sol";
import "../interfaces/IStakingThales.sol";
import "../interfaces/IMultiCollateralOnOffRamp.sol";
import "../interfaces/IReferrals.sol";
import "../interfaces/IAddressManager.sol";
import "../interfaces/ISpeedMarketsAMM.sol";
import "./SpeedMarket.sol";
import "../interfaces/ISpeedMarketsAMMUtils.sol";
/// @title An AMM for Overtime Speed Markets
contract SpeedMarketsAMM is Initializable, ProxyOwned, ProxyPausable, ProxyReentrancyGuard {
using SafeERC20Upgradeable for IERC20Upgradeable;
using AddressSetLib for AddressSetLib.AddressSet;
AddressSetLib.AddressSet internal _activeMarkets;
AddressSetLib.AddressSet internal _maturedMarkets;
uint private constant ONE = 1e18;
uint private constant MAX_APPROVAL = type(uint256).max;
/// ========== Custom Errors ==========
error MulticollateralOnrampDisabled();
error NotEnoughReceivedViaOnramp();
error SkewSlippageExceeded();
error RiskPerDirectionExceeded();
error RiskPerAssetExceeded();
error AssetNotSupported();
error InvalidBuyinAmount();
error InvalidStrikeTime();
error TimeTooFarIntoFuture();
error CanNotResolve();
error InvalidPrice();
error CanOnlyBeCalledFromResolverOrOwner();
error OnlyCreatorAllowed();
error BonusTooHigh();
error OnlyMarketOwner();
error EtherTransferFailed();
error MismatchedLengths();
error CollateralNotSupported();
error InvalidOffRampCollateral();
error InvalidWhitelistAddress();
IERC20Upgradeable public sUSD;
address public speedMarketMastercopy;
uint public safeBoxImpact;
uint public lpFee;
address private safeBox; // unused, moved to AddressManager
mapping(bytes32 => bool) public supportedAsset;
uint public minimalTimeToMaturity;
uint public maximalTimeToMaturity;
uint public minBuyinAmount;
uint public maxBuyinAmount;
mapping(bytes32 => uint) public maxRiskPerAsset;
mapping(bytes32 => uint) public currentRiskPerAsset;
mapping(bytes32 => bytes32) public assetToPythId;
IPyth private pyth; // unused, moved to AddressManager
uint64 public maximumPriceDelay;
IStakingThales private stakingThales; // unused, moved to AddressManager
mapping(address => AddressSetLib.AddressSet) internal _activeMarketsPerUser;
mapping(address => AddressSetLib.AddressSet) internal _maturedMarketsPerUser;
mapping(address => bool) public whitelistedAddresses;
IMultiCollateralOnOffRamp private multiCollateralOnOffRamp; // unused, moved to AddressManager
bool public multicollateralEnabled;
mapping(bytes32 => mapping(SpeedMarket.Direction => uint)) public maxRiskPerAssetAndDirection;
mapping(bytes32 => mapping(SpeedMarket.Direction => uint)) public currentRiskPerAssetAndDirection;
uint64 public maximumPriceDelayForResolving;
mapping(address => bool) public marketHasCreatedAtAttribute;
address private referrals; // unused, moved to AddressManager
uint[] public timeThresholdsForFees;
uint[] public lpFees;
ISpeedMarketsAMMUtils public speedMarketsAMMUtils;
mapping(address => bool) public marketHasFeeAttribute;
/// @return The address of the address manager contract
IAddressManager public addressManager;
uint public maxSkewImpact;
uint public skewSlippage;
mapping(address => bool) public supportedNativeCollateral;
/// @notice Bonus percentage per collateral token (e.g., 0.02e18 for 2%)
mapping(address => uint) public bonusPerCollateral;
mapping(bytes32 => bytes32) public assetToChainlinkId;
/// @param user user wallet address
/// @param asset market asset
/// @param strikeTime strike time, if zero delta time is used
/// @param delta delta time, used if strike time is zero
/// @param strikePrice oracle price
/// @param strikePricePublishTime oracle publish time for strike price
/// @param direction direction (UP/DOWN)
/// @param collateral collateral address, for default collateral use zero address
/// @param collateralAmount collateral amount, for non default includes fees
/// @param referrer referrer address
/// @param skewImpact skew impact, used to check skew slippage
struct CreateMarketParams {
address user;
bytes32 asset;
uint64 strikeTime;
uint64 delta;
int64 strikePrice;
uint64 strikePricePublishTime;
ISpeedMarketsAMM.OracleSource oracleSource;
SpeedMarket.Direction direction;
address collateral;
uint collateralAmount;
address referrer;
uint skewImpact;
}
struct InternalCreateParams {
CreateMarketParams createMarketParams;
bool transferCollateral;
uint64 strikeTime;
uint buyinAmount;
uint buyinAmountInUSD;
address defaultCollateral;
}
receive() external payable {}
function initialize(address _owner, IERC20Upgradeable _sUSD) external initializer {
setOwner(_owner);
initNonReentrant();
sUSD = _sUSD;
supportedNativeCollateral[address(_sUSD)] = true;
}
/// @notice create new market for a given delta/strike time
/// @param _params parameters for creating market
function createNewMarket(CreateMarketParams calldata _params)
external
nonReentrant
notPaused
onlyCreator
returns (address marketAddress)
{
IAddressManager.Addresses memory contractsAddresses = addressManager.getAddresses();
// Calculate strike time: use provided strikeTime or current timestamp + delta
uint64 strikeTime = _params.strikeTime == 0 ? uint64(block.timestamp + _params.delta) : _params.strikeTime;
// Determine collateral configuration
(
bool isNativeCollateral,
address defaultCollateral,
uint buyinAmount,
uint buyinAmountInUSD
) = _determineCollateralConfig(_params, strikeTime, contractsAddresses);
// Create internal parameters struct
InternalCreateParams memory internalParams = InternalCreateParams({
createMarketParams: _params,
strikeTime: strikeTime,
buyinAmount: buyinAmount,
transferCollateral: isNativeCollateral,
defaultCollateral: defaultCollateral,
buyinAmountInUSD: buyinAmountInUSD
});
marketAddress = _createNewMarket(internalParams, contractsAddresses);
}
/// @notice Determines collateral configuration and calculates buyin amount
/// @param _params Market creation parameters
/// @param strikeTime Calculated strike time
/// @param contractsAddresses Contract addresses from address manager
/// @return isNativeCollateral Whether the collateral is natively supported
/// @return defaultCollateral The default collateral address to use
/// @return buyinAmount The calculated buyin amount
function _determineCollateralConfig(
CreateMarketParams calldata _params,
uint64 strikeTime,
IAddressManager.Addresses memory contractsAddresses
)
internal
returns (
bool isNativeCollateral,
address defaultCollateral,
uint buyinAmount,
uint buyinAmountInUSD
)
{
isNativeCollateral = supportedNativeCollateral[_params.collateral] || _params.collateral == address(0);
if (supportedNativeCollateral[_params.collateral] && _params.collateral != address(0)) {
defaultCollateral = _params.collateral;
} else {
defaultCollateral = address(sUSD);
}
// Calculate buyin amount based on collateral type
if (isNativeCollateral) {
buyinAmount = buyinAmountInUSD = _params.collateralAmount;
if (defaultCollateral != address(sUSD)) {
buyinAmountInUSD = speedMarketsAMMUtils.transformCollateralToUSD(
defaultCollateral,
address(sUSD),
_params.collateralAmount
);
}
} else {
// For external collaterals, convert through onramp
buyinAmount = buyinAmountInUSD = _getBuyinWithConversion(
_params.user,
_params.collateral,
_params.collateralAmount,
strikeTime,
contractsAddresses
);
}
}
/// @notice Gets the buyin amount with conversion
/// @param user The user address
/// @param collateral The collateral address
/// @param collateralAmount The collateral amount
/// @param strikeTime The strike time
/// @param contractsAddresses Contract addresses from address manager
/// @return buyinAmount The calculated buyin amount
function _getBuyinWithConversion(
address user,
address collateral,
uint collateralAmount,
uint64 strikeTime,
IAddressManager.Addresses memory contractsAddresses
) internal returns (uint buyinAmount) {
if (!multicollateralEnabled) revert MulticollateralOnrampDisabled();
uint amountBefore = sUSD.balanceOf(address(this));
IMultiCollateralOnOffRamp iMultiCollateralOnOffRamp = IMultiCollateralOnOffRamp(
contractsAddresses.multiCollateralOnOffRamp
);
IERC20Upgradeable(collateral).safeTransferFrom(user, address(this), collateralAmount);
IERC20Upgradeable(collateral).approve(address(iMultiCollateralOnOffRamp), collateralAmount);
uint convertedAmount = iMultiCollateralOnOffRamp.onramp(collateral, collateralAmount);
uint lpFeeForDeltaTime = speedMarketsAMMUtils.getFeeByTimeThreshold(
uint64(strikeTime - block.timestamp),
timeThresholdsForFees,
lpFees,
lpFee
);
buyinAmount = (convertedAmount * ONE) / (ONE + safeBoxImpact + lpFeeForDeltaTime);
uint amountDiff = sUSD.balanceOf(address(this)) - amountBefore;
if (amountDiff < buyinAmount) revert NotEnoughReceivedViaOnramp();
}
/// @notice Gets the skew by asset and direction
/// @param _asset The asset
/// @param _direction The direction
/// @return skew The skew
function _getSkewByAssetAndDirection(bytes32 _asset, SpeedMarket.Direction _direction) internal view returns (uint) {
return
(((currentRiskPerAssetAndDirection[_asset][_direction] * ONE) /
maxRiskPerAssetAndDirection[_asset][_direction]) * maxSkewImpact) / ONE;
}
/// @notice Handles the risk and gets the fee
/// @param asset The asset
/// @param direction The direction
/// @param buyinAmountInUSD The buyin amount in USD
/// @param strikeTime The strike time
/// @param skewImpact The skew impact
function _handleRiskAndGetFee(
bytes32 asset,
SpeedMarket.Direction direction,
uint buyinAmountInUSD,
uint64 strikeTime,
uint skewImpact,
uint payoutBonus
) internal returns (uint lpFeeWithSkew, uint payoutInUSD) {
uint skew = _getSkewByAssetAndDirection(asset, direction);
if (skew > skewImpact + skewSlippage) revert SkewSlippageExceeded();
SpeedMarket.Direction oppositeDirection = direction == SpeedMarket.Direction.Up
? SpeedMarket.Direction.Down
: SpeedMarket.Direction.Up;
// calculate discount as half of skew for opposite direction
uint discount = skew == 0 ? _getSkewByAssetAndDirection(asset, oppositeDirection) / 2 : 0;
// decrease risk for opposite direction if there is, otherwise increase risk for current direction
if (currentRiskPerAssetAndDirection[asset][oppositeDirection] > buyinAmountInUSD) {
currentRiskPerAssetAndDirection[asset][oppositeDirection] -= buyinAmountInUSD;
} else {
currentRiskPerAssetAndDirection[asset][direction] +=
buyinAmountInUSD -
currentRiskPerAssetAndDirection[asset][oppositeDirection];
currentRiskPerAssetAndDirection[asset][oppositeDirection] = 0;
if (currentRiskPerAssetAndDirection[asset][direction] > maxRiskPerAssetAndDirection[asset][direction]) {
revert RiskPerDirectionExceeded();
}
}
// (LP fee by delta time) + (skew impact based on risk per direction and asset) - (discount as half of opposite skew)
lpFeeWithSkew =
speedMarketsAMMUtils.getFeeByTimeThreshold(
uint64(strikeTime - block.timestamp),
timeThresholdsForFees,
lpFees,
lpFee
) +
skew -
discount;
// payout with bonus
payoutInUSD = buyinAmountInUSD * 2 + (buyinAmountInUSD * 2 * payoutBonus) / ONE;
// update risk per asset with the bonus applied
currentRiskPerAsset[asset] += (payoutInUSD - (buyinAmountInUSD * (ONE + lpFeeWithSkew)) / ONE);
if (currentRiskPerAsset[asset] > maxRiskPerAsset[asset]) {
revert RiskPerAssetExceeded();
}
}
/// @notice Handles the referrer and safe box
/// @param user The user address
/// @param referrer The referrer address
/// @param buyinAmount The buyin amount
/// @param collateral The collateral address
/// @param contractsAddresses Contract addresses from address manager
function _handleReferrerAndSafeBox(
address user,
address referrer,
uint buyinAmount,
IERC20Upgradeable collateral,
IAddressManager.Addresses memory contractsAddresses
) internal returns (uint referrerShare) {
IReferrals iReferrals = IReferrals(contractsAddresses.referrals);
if (address(iReferrals) != address(0)) {
address newOrExistingReferrer;
if (referrer != address(0)) {
iReferrals.setReferrer(referrer, user);
newOrExistingReferrer = referrer;
} else {
newOrExistingReferrer = iReferrals.referrals(user);
}
if (newOrExistingReferrer != address(0)) {
uint referrerFeeByTier = iReferrals.getReferrerFee(newOrExistingReferrer);
if (referrerFeeByTier > 0) {
referrerShare = (buyinAmount * referrerFeeByTier) / ONE;
collateral.safeTransfer(newOrExistingReferrer, referrerShare);
emit ReferrerPaid(newOrExistingReferrer, user, referrerShare, buyinAmount);
}
}
}
collateral.safeTransfer(contractsAddresses.safeBox, (buyinAmount * safeBoxImpact) / ONE - referrerShare);
}
/// @notice Creates a new market
/// @param params Internal market creation parameters
/// @param contractsAddresses Contract addresses from address manager
function _createNewMarket(InternalCreateParams memory params, IAddressManager.Addresses memory contractsAddresses)
internal
returns (address)
{
if (!supportedAsset[params.createMarketParams.asset]) revert AssetNotSupported();
if (params.buyinAmountInUSD < minBuyinAmount || params.buyinAmountInUSD > maxBuyinAmount) {
revert InvalidBuyinAmount();
}
if (params.strikeTime < block.timestamp + minimalTimeToMaturity) {
revert InvalidStrikeTime();
}
if (params.strikeTime > block.timestamp + maximalTimeToMaturity) {
revert TimeTooFarIntoFuture();
}
(uint lpFeeWithSkew, uint payoutInUSD) = _handleRiskAndGetFee(
params.createMarketParams.asset,
params.createMarketParams.direction,
params.buyinAmountInUSD,
params.strikeTime,
params.createMarketParams.skewImpact,
params.transferCollateral ? bonusPerCollateral[params.defaultCollateral] : 0
);
if (params.transferCollateral) {
uint totalAmountToTransfer = (params.buyinAmount * (ONE + safeBoxImpact + lpFeeWithSkew)) / ONE;
IERC20Upgradeable(params.defaultCollateral).safeTransferFrom(
params.createMarketParams.user,
address(this),
totalAmountToTransfer
);
}
SpeedMarket srm = SpeedMarket(Clones.clone(speedMarketMastercopy));
uint payout = payoutInUSD;
bool defaultCollateralIsNotUSD = params.transferCollateral && params.defaultCollateral != address(sUSD);
if (defaultCollateralIsNotUSD) {
payout = params.buyinAmount * 2 + (params.buyinAmount * 2 * bonusPerCollateral[params.defaultCollateral]) / ONE;
}
srm.initialize(
SpeedMarket.InitParams(
address(this),
params.createMarketParams.user,
params.createMarketParams.asset,
params.strikeTime,
params.createMarketParams.strikePrice,
params.createMarketParams.strikePricePublishTime,
params.createMarketParams.oracleSource,
params.createMarketParams.direction,
params.defaultCollateral,
params.buyinAmount,
safeBoxImpact,
lpFeeWithSkew,
payout
)
);
if (defaultCollateralIsNotUSD) {
IERC20Upgradeable(params.defaultCollateral).safeTransfer(address(srm), payout);
} else {
sUSD.safeTransfer(address(srm), payout);
}
_handleReferrerAndSafeBox(
params.createMarketParams.user,
params.createMarketParams.referrer,
params.buyinAmount,
IERC20Upgradeable(params.defaultCollateral),
contractsAddresses
);
_activeMarkets.add(address(srm));
_activeMarketsPerUser[params.createMarketParams.user].add(address(srm));
marketHasCreatedAtAttribute[address(srm)] = true;
marketHasFeeAttribute[address(srm)] = true;
emit MarketCreated(
address(srm),
params.createMarketParams.user,
params.createMarketParams.asset,
params.strikeTime,
params.createMarketParams.strikePrice,
params.createMarketParams.direction,
params.buyinAmount
);
emit MarketCreatedWithFees(
address(srm),
params.createMarketParams.user,
params.createMarketParams.asset,
params.strikeTime,
params.createMarketParams.strikePrice,
params.createMarketParams.direction,
params.buyinAmountInUSD,
safeBoxImpact,
lpFeeWithSkew
);
return address(srm);
}
/// @notice owner can resolve market for a given market address with finalPrice
function resolveMarketWithPrice(address _market, int64 _finalPrice) external {
if (msg.sender != addressManager.getAddress("SpeedMarketsAMMResolver") && msg.sender != owner)
revert CanOnlyBeCalledFromResolverOrOwner();
if (!canResolveMarket(_market)) revert CanNotResolve();
_resolveMarketWithPrice(_market, _finalPrice);
}
function _resolveMarketWithPrice(address market, int64 _finalPrice) internal {
SpeedMarket sm = SpeedMarket(market);
sm.resolve(_finalPrice);
_activeMarkets.remove(market);
_maturedMarkets.add(market);
address user = sm.user();
if (_activeMarketsPerUser[user].contains(market)) {
_activeMarketsPerUser[user].remove(market);
}
_maturedMarketsPerUser[user].add(market);
bytes32 asset = SpeedMarket(market).asset();
address collateral = SpeedMarket(market).collateral();
uint buyinAmountInUSD = collateral == address(sUSD) || collateral == address(0)
? SpeedMarket(market).buyinAmount()
: speedMarketsAMMUtils.transformCollateralToUSD(collateral, address(sUSD), SpeedMarket(market).buyinAmount());
SpeedMarket.Direction direction = SpeedMarket(market).direction();
if (currentRiskPerAssetAndDirection[asset][direction] > buyinAmountInUSD) {
currentRiskPerAssetAndDirection[asset][direction] -= buyinAmountInUSD;
} else {
currentRiskPerAssetAndDirection[asset][direction] = 0;
}
if (!sm.isUserWinner()) {
if (currentRiskPerAsset[asset] > 2 * buyinAmountInUSD) {
currentRiskPerAsset[asset] -= (2 * buyinAmountInUSD);
} else {
currentRiskPerAsset[asset] = 0;
}
}
emit MarketResolved(market, sm.result(), sm.isUserWinner());
}
function offrampHelper(address user, uint amount) external {
if (msg.sender != addressManager.getAddress("SpeedMarketsAMMResolver")) revert CanOnlyBeCalledFromResolverOrOwner();
sUSD.safeTransferFrom(user, msg.sender, amount);
}
/// @notice Transfer amount to destination address
function transferAmount(
address _collateral,
address _destination,
uint _amount
) external onlyOwner {
IERC20Upgradeable(_collateral).safeTransfer(_destination, _amount);
emit AmountTransfered(_collateral, _destination, _amount);
}
//////////// getters /////////////////
/// @notice activeMarkets returns list of active markets
/// @param index index of the page
/// @param pageSize number of addresses per page
/// @return address[] active market list
function activeMarkets(uint index, uint pageSize) external view returns (address[] memory) {
return _activeMarkets.getPage(index, pageSize);
}
/// @notice maturedMarkets returns list of matured markets
/// @param index index of the page
/// @param pageSize number of addresses per page
/// @return address[] matured market list
function maturedMarkets(uint index, uint pageSize) external view returns (address[] memory) {
return _maturedMarkets.getPage(index, pageSize);
}
/// @notice activeMarkets returns list of active markets per user
function activeMarketsPerUser(
uint index,
uint pageSize,
address user
) external view returns (address[] memory) {
return _activeMarketsPerUser[user].getPage(index, pageSize);
}
/// @notice maturedMarkets returns list of matured markets per user
function maturedMarketsPerUser(
uint index,
uint pageSize,
address user
) external view returns (address[] memory) {
return _maturedMarketsPerUser[user].getPage(index, pageSize);
}
/// @notice whether a market can be resolved
function canResolveMarket(address market) public view returns (bool) {
return
_activeMarkets.contains(market) &&
(SpeedMarket(market).strikeTime() < block.timestamp) &&
!SpeedMarket(market).resolved();
}
/// @notice get lengths of all arrays
function getLengths(address user) external view returns (uint[5] memory) {
return [
_activeMarkets.elements.length,
_maturedMarkets.elements.length,
_activeMarketsPerUser[user].elements.length,
_maturedMarketsPerUser[user].elements.length,
lpFees.length
];
}
/// @notice get params for chained market
function getParams(bytes32 asset) external view returns (ISpeedMarketsAMM.Params memory) {
ISpeedMarketsAMM.Params memory params;
params.supportedAsset = supportedAsset[asset];
params.safeBoxImpact = safeBoxImpact;
params.maximumPriceDelay = maximumPriceDelay;
return params;
}
//////////////////setters/////////////////
/// @notice Set addresses used in AMM
/// @param _mastercopy to use to create markets
/// @param _speedMarketsAMMUtils address of speed markets AMM utils
/// @param _addressManager address manager contract
function setAMMAddresses(
address _mastercopy,
ISpeedMarketsAMMUtils _speedMarketsAMMUtils,
address _addressManager
) external onlyOwner {
speedMarketMastercopy = _mastercopy;
speedMarketsAMMUtils = _speedMarketsAMMUtils;
addressManager = IAddressManager(_addressManager);
emit AMMAddressesChanged(_mastercopy, _speedMarketsAMMUtils, _addressManager);
}
/// @notice Set parameters for limits
function setLimitParams(
uint _minBuyinAmount,
uint _maxBuyinAmount,
uint _minimalTimeToMaturity,
uint _maximalTimeToMaturity,
uint64 _maximumPriceDelay,
uint64 _maximumPriceDelayForResolving
) external onlyOwner {
minBuyinAmount = _minBuyinAmount;
maxBuyinAmount = _maxBuyinAmount;
minimalTimeToMaturity = _minimalTimeToMaturity;
maximalTimeToMaturity = _maximalTimeToMaturity;
maximumPriceDelay = _maximumPriceDelay;
maximumPriceDelayForResolving = _maximumPriceDelayForResolving;
emit LimitParamsChanged(
_minBuyinAmount,
_maxBuyinAmount,
_minimalTimeToMaturity,
_maximalTimeToMaturity,
_maximumPriceDelay,
_maximumPriceDelayForResolving
);
}
/// @notice maximum risk per asset and per asset and direction
function setMaxRisks(
bytes32 asset,
uint _maxRiskPerAsset,
uint _maxRiskPerAssetAndDirection
) external onlyOwner {
maxRiskPerAsset[asset] = _maxRiskPerAsset;
currentRiskPerAsset[asset] = 0;
maxRiskPerAssetAndDirection[asset][SpeedMarket.Direction.Up] = _maxRiskPerAssetAndDirection;
maxRiskPerAssetAndDirection[asset][SpeedMarket.Direction.Down] = _maxRiskPerAssetAndDirection;
emit SetMaxRisks(asset, _maxRiskPerAsset, _maxRiskPerAssetAndDirection);
}
/// @notice set SafeBox, max skew impact and skew slippage
/// @param _safeBoxImpact safebox impact
/// @param _maxSkewImpact skew impact
/// @param _skewSlippage skew slippage
function setSafeBoxAndMaxSkewImpact(
uint _safeBoxImpact,
uint _maxSkewImpact,
uint _skewSlippage
) external onlyOwner {
safeBoxImpact = _safeBoxImpact;
maxSkewImpact = _maxSkewImpact;
skewSlippage = _skewSlippage;
emit SafeBoxAndMaxSkewImpactChanged(_safeBoxImpact, _maxSkewImpact, _skewSlippage);
}
/// @notice set LP fee params
/// @param _timeThresholds array of time thresholds (minutes) for different fees in ascending order
/// @param _lpFees array of fees applied to each time frame defined in _timeThresholds
/// @param _lpFee default LP fee when there are no dynamic fees
function setLPFeeParams(
uint[] calldata _timeThresholds,
uint[] calldata _lpFees,
uint _lpFee
) external onlyOwner {
if (_timeThresholds.length != _lpFees.length) revert MismatchedLengths();
delete timeThresholdsForFees;
delete lpFees;
for (uint i; i < _timeThresholds.length; ++i) {
timeThresholdsForFees.push(_timeThresholds[i]);
lpFees.push(_lpFees[i]);
}
lpFee = _lpFee;
emit SetLPFeeParams(_timeThresholds, _lpFees, _lpFee);
}
/// @notice set whether an asset is supported
function setSupportedAsset(bytes32 asset, bool _supported) external onlyOwner {
supportedAsset[asset] = _supported;
emit SetSupportedAsset(asset, _supported);
}
/// @notice map asset to PythID/ChainlinkID, e.g. "ETH" as bytes 32 to an equivalent ID from pyth/chainlink docs
function setAssetToPriceOracleID(
bytes32 asset,
bytes32 pythId,
bytes32 chainlinkId
) external onlyOwner {
assetToPythId[asset] = pythId;
assetToChainlinkId[asset] = chainlinkId;
emit SetAssetToPriceOracleID(asset, pythId, chainlinkId);
}
/// @notice set sUSD address (default collateral)
function setSusdAddress(address _sUSD) external onlyOwner {
sUSD = IERC20Upgradeable(_sUSD);
emit SusdAddressChanged(_sUSD);
}
/// @notice set multi-collateral enabled
function setMultiCollateralOnOffRampEnabled(bool _enabled) external onlyOwner {
address multiCollateralAddress = addressManager.multiCollateralOnOffRamp();
if (multiCollateralAddress != address(0)) {
sUSD.approve(multiCollateralAddress, _enabled ? MAX_APPROVAL : 0);
}
multicollateralEnabled = _enabled;
emit MultiCollateralOnOffRampEnabled(_enabled);
}
/// @notice Set bonus percentage for a collateral
/// @param _collateral collateral address
/// @param _bonus bonus percentage (e.g., 0.02e18 for 2%)
function setSupportedNativeCollateralAndBonus(
address _collateral,
bool _supported,
uint _bonus,
bytes32 _collateralKey
) external onlyOwner {
// 10% bonus as max
if (_bonus > 1e17) revert BonusTooHigh();
bonusPerCollateral[_collateral] = _bonus;
supportedNativeCollateral[_collateral] = _supported;
speedMarketsAMMUtils.setCollateralKey(_collateral, _collateralKey);
emit CollateralBonusSet(_collateral, _bonus);
}
/// @notice adding/removing whitelist address depending on a flag
/// @param _whitelistAddress address that needed to be whitelisted or removed from WL
/// @param _flag adding or removing from whitelist (true: add, false: remove)
function addToWhitelist(address _whitelistAddress, bool _flag) external onlyOwner {
if (_whitelistAddress == address(0)) revert InvalidWhitelistAddress();
whitelistedAddresses[_whitelistAddress] = _flag;
emit AddedIntoWhitelist(_whitelistAddress, _flag);
}
//////////////////modifiers/////////////////
modifier onlyCreator() {
address speedMarketsCreator = addressManager.getAddress("SpeedMarketsAMMCreator");
if (msg.sender != speedMarketsCreator) revert OnlyCreatorAllowed();
_;
}
//////////////////events/////////////////
event MarketCreated(
address _market,
address _user,
bytes32 _asset,
uint _strikeTime,
int64 _strikePrice,
SpeedMarket.Direction _direction,
uint _buyinAmount
);
event MarketCreatedWithFees(
address _market,
address _user,
bytes32 _asset,
uint _strikeTime,
int64 _strikePrice,
SpeedMarket.Direction _direction,
uint _buyinAmount,
uint _safeBoxImpact,
uint _lpFee
);
event MarketResolved(address _market, SpeedMarket.Direction _result, bool _userIsWinner);
event AMMAddressesChanged(address _mastercopy, ISpeedMarketsAMMUtils _speedMarketsAMMUtils, address _addressManager);
event LimitParamsChanged(
uint _minBuyinAmount,
uint _maxBuyinAmount,
uint _minimalTimeToMaturity,
uint _maximalTimeToMaturity,
uint _maximumPriceDelay,
uint _maximumPriceDelayForResolving
);
event SetMaxRisks(bytes32 asset, uint _maxRiskPerAsset, uint _maxRiskPerAssetAndDirection);
event SafeBoxAndMaxSkewImpactChanged(uint _safeBoxImpact, uint _maxSkewImpact, uint _skewSlippage);
event SetLPFeeParams(uint[] _timeThresholds, uint[] _lpFees, uint _lpFee);
event SetSupportedAsset(bytes32 asset, bool _supported);
event SetAssetToPriceOracleID(bytes32 asset, bytes32 pythId, bytes32 chainlinkId);
event SusdAddressChanged(address _sUSD);
event MultiCollateralOnOffRampEnabled(bool _enabled);
event ReferrerPaid(address refferer, address trader, uint amount, uint volume);
event AmountTransfered(address _collateral, address _destination, uint _amount);
event CollateralBonusSet(address indexed collateral, uint bonus);
event AddedIntoWhitelist(address _whitelistAddress, bool _flag);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/utils/SafeERC20.sol)
pragma solidity ^0.8.0;
import "../IERC20Upgradeable.sol";
import "../../../utils/AddressUpgradeable.sol";
/**
* @title SafeERC20
* @dev Wrappers around ERC20 operations that throw on failure (when the token
* contract returns false). Tokens that return no value (and instead revert or
* throw on failure) are also supported, non-reverting calls are assumed to be
* successful.
* To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
* which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
*/
library SafeERC20Upgradeable {
using AddressUpgradeable for address;
function safeTransfer(
IERC20Upgradeable token,
address to,
uint256 value
) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
}
function safeTransferFrom(
IERC20Upgradeable token,
address from,
address to,
uint256 value
) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
}
/**
* @dev Deprecated. This function has issues similar to the ones found in
* {IERC20-approve}, and its usage is discouraged.
*
* Whenever possible, use {safeIncreaseAllowance} and
* {safeDecreaseAllowance} instead.
*/
function safeApprove(
IERC20Upgradeable token,
address spender,
uint256 value
) internal {
// safeApprove should only be called when setting an initial allowance,
// or when resetting it to zero. To increase and decrease it, use
// 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
require(
(value == 0) || (token.allowance(address(this), spender) == 0),
"SafeERC20: approve from non-zero to non-zero allowance"
);
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
}
function safeIncreaseAllowance(
IERC20Upgradeable token,
address spender,
uint256 value
) internal {
uint256 newAllowance = token.allowance(address(this), spender) + value;
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
}
function safeDecreaseAllowance(
IERC20Upgradeable token,
address spender,
uint256 value
) internal {
unchecked {
uint256 oldAllowance = token.allowance(address(this), spender);
require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");
uint256 newAllowance = oldAllowance - value;
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
}
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*/
function _callOptionalReturn(IERC20Upgradeable token, bytes memory data) private {
// We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
// we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that
// the target address contains contract code and also asserts for success in the low-level call.
bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
if (returndata.length > 0) {
// Return data is optional
require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/math/Math.sol)
pragma solidity ^0.8.0;
/**
* @dev Standard math utilities missing in the Solidity language.
*/
library MathUpgradeable {
/**
* @dev Returns the largest of two numbers.
*/
function max(uint256 a, uint256 b) internal pure returns (uint256) {
return a >= b ? a : b;
}
/**
* @dev Returns the smallest of two numbers.
*/
function min(uint256 a, uint256 b) internal pure returns (uint256) {
return a < b ? a : b;
}
/**
* @dev Returns the average of two numbers. The result is rounded towards
* zero.
*/
function average(uint256 a, uint256 b) internal pure returns (uint256) {
// (a + b) / 2 can overflow.
return (a & b) + (a ^ b) / 2;
}
/**
* @dev Returns the ceiling of the division of two numbers.
*
* This differs from standard division with `/` in that it rounds up instead
* of rounding down.
*/
function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
// (a + b - 1) / b can overflow on addition, so we distribute.
return a / b + (a % b == 0 ? 0 : 1);
}
}// 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 (utils/math/SafeMath.sol)
pragma solidity ^0.8.0;
// CAUTION
// This version of SafeMath should only be used with Solidity 0.8 or later,
// because it relies on the compiler's built in overflow checks.
/**
* @dev Wrappers over Solidity's arithmetic operations.
*
* NOTE: `SafeMath` is generally not needed starting with Solidity 0.8, since the compiler
* now has built in overflow checking.
*/
library SafeMathUpgradeable {
/**
* @dev Returns the addition of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
uint256 c = a + b;
if (c < a) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the substraction of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b > a) return (false, 0);
return (true, a - b);
}
}
/**
* @dev Returns the multiplication of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) return (true, 0);
uint256 c = a * b;
if (c / a != b) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the division of two unsigned integers, with a division by zero flag.
*
* _Available since v3.4._
*/
function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a / b);
}
}
/**
* @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
*
* _Available since v3.4._
*/
function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a % b);
}
}
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
return a + b;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return a - b;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
*
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
return a * b;
}
/**
* @dev Returns the integer division of two unsigned integers, reverting on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator.
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return a / b;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* reverting when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return a % b;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {trySub}.
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
unchecked {
require(b <= a, errorMessage);
return a - b;
}
}
/**
* @dev Returns the integer division of two unsigned integers, reverting with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
unchecked {
require(b > 0, errorMessage);
return a / b;
}
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* reverting with custom message when dividing by zero.
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {tryMod}.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
unchecked {
require(b > 0, errorMessage);
return a % b;
}
}
}// 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 (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
// 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: Apache-2.0
pragma solidity ^0.8.0;
import "./PythStructs.sol";
import "./IPythEvents.sol";
/// @title Consume prices from the Pyth Network (https://pyth.network/).
/// @dev Please refer to the guidance at https://docs.pyth.network/consumers/best-practices for how to consume prices safely.
/// @author Pyth Data Association
interface IPyth is IPythEvents {
/// @notice Returns the period (in seconds) that a price feed is considered valid since its publish time
function getValidTimePeriod() external view returns (uint validTimePeriod);
/// @notice Returns the price and confidence interval.
/// @dev Reverts if the price has not been updated within the last `getValidTimePeriod()` seconds.
/// @param id The Pyth Price Feed ID of which to fetch the price and confidence interval.
/// @return price - please read the documentation of PythStructs.Price to understand how to use this safely.
function getPrice(
bytes32 id
) external view returns (PythStructs.Price memory price);
/// @notice Returns the exponentially-weighted moving average price and confidence interval.
/// @dev Reverts if the EMA price is not available.
/// @param id The Pyth Price Feed ID of which to fetch the EMA price and confidence interval.
/// @return price - please read the documentation of PythStructs.Price to understand how to use this safely.
function getEmaPrice(
bytes32 id
) external view returns (PythStructs.Price memory price);
/// @notice Returns the price of a price feed without any sanity checks.
/// @dev This function returns the most recent price update in this contract without any recency checks.
/// This function is unsafe as the returned price update may be arbitrarily far in the past.
///
/// Users of this function should check the `publishTime` in the price to ensure that the returned price is
/// sufficiently recent for their application. If you are considering using this function, it may be
/// safer / easier to use either `getPrice` or `getPriceNoOlderThan`.
/// @return price - please read the documentation of PythStructs.Price to understand how to use this safely.
function getPriceUnsafe(
bytes32 id
) external view returns (PythStructs.Price memory price);
/// @notice Returns the price that is no older than `age` seconds of the current time.
/// @dev This function is a sanity-checked version of `getPriceUnsafe` which is useful in
/// applications that require a sufficiently-recent price. Reverts if the price wasn't updated sufficiently
/// recently.
/// @return price - please read the documentation of PythStructs.Price to understand how to use this safely.
function getPriceNoOlderThan(
bytes32 id,
uint age
) external view returns (PythStructs.Price memory price);
/// @notice Returns the exponentially-weighted moving average price of a price feed without any sanity checks.
/// @dev This function returns the same price as `getEmaPrice` in the case where the price is available.
/// However, if the price is not recent this function returns the latest available price.
///
/// The returned price can be from arbitrarily far in the past; this function makes no guarantees that
/// the returned price is recent or useful for any particular application.
///
/// Users of this function should check the `publishTime` in the price to ensure that the returned price is
/// sufficiently recent for their application. If you are considering using this function, it may be
/// safer / easier to use either `getEmaPrice` or `getEmaPriceNoOlderThan`.
/// @return price - please read the documentation of PythStructs.Price to understand how to use this safely.
function getEmaPriceUnsafe(
bytes32 id
) external view returns (PythStructs.Price memory price);
/// @notice Returns the exponentially-weighted moving average price that is no older than `age` seconds
/// of the current time.
/// @dev This function is a sanity-checked version of `getEmaPriceUnsafe` which is useful in
/// applications that require a sufficiently-recent price. Reverts if the price wasn't updated sufficiently
/// recently.
/// @return price - please read the documentation of PythStructs.Price to understand how to use this safely.
function getEmaPriceNoOlderThan(
bytes32 id,
uint age
) external view returns (PythStructs.Price memory price);
/// @notice Update price feeds with given update messages.
/// This method requires the caller to pay a fee in wei; the required fee can be computed by calling
/// `getUpdateFee` with the length of the `updateData` array.
/// Prices will be updated if they are more recent than the current stored prices.
/// The call will succeed even if the update is not the most recent.
/// @dev Reverts if the transferred fee is not sufficient or the updateData is invalid.
/// @param updateData Array of price update data.
function updatePriceFeeds(bytes[] calldata updateData) external payable;
/// @notice Wrapper around updatePriceFeeds that rejects fast if a price update is not necessary. A price update is
/// necessary if the current on-chain publishTime is older than the given publishTime. It relies solely on the
/// given `publishTimes` for the price feeds and does not read the actual price update publish time within `updateData`.
///
/// This method requires the caller to pay a fee in wei; the required fee can be computed by calling
/// `getUpdateFee` with the length of the `updateData` array.
///
/// `priceIds` and `publishTimes` are two arrays with the same size that correspond to senders known publishTime
/// of each priceId when calling this method. If all of price feeds within `priceIds` have updated and have
/// a newer or equal publish time than the given publish time, it will reject the transaction to save gas.
/// Otherwise, it calls updatePriceFeeds method to update the prices.
///
/// @dev Reverts if update is not needed or the transferred fee is not sufficient or the updateData is invalid.
/// @param updateData Array of price update data.
/// @param priceIds Array of price ids.
/// @param publishTimes Array of publishTimes. `publishTimes[i]` corresponds to known `publishTime` of `priceIds[i]`
function updatePriceFeedsIfNecessary(
bytes[] calldata updateData,
bytes32[] calldata priceIds,
uint64[] calldata publishTimes
) external payable;
/// @notice Returns the required fee to update an array of price updates.
/// @param updateData Array of price update data.
/// @return feeAmount The required fee in Wei.
function getUpdateFee(
bytes[] calldata updateData
) external view returns (uint feeAmount);
/// @notice Parse `updateData` and return price feeds of the given `priceIds` if they are all published
/// within `minPublishTime` and `maxPublishTime`.
///
/// You can use this method if you want to use a Pyth price at a fixed time and not the most recent price;
/// otherwise, please consider using `updatePriceFeeds`. This method does not store the price updates on-chain.
///
/// This method requires the caller to pay a fee in wei; the required fee can be computed by calling
/// `getUpdateFee` with the length of the `updateData` array.
///
///
/// @dev Reverts if the transferred fee is not sufficient or the updateData is invalid or there is
/// no update for any of the given `priceIds` within the given time range.
/// @param updateData Array of price update data.
/// @param priceIds Array of price ids.
/// @param minPublishTime minimum acceptable publishTime for the given `priceIds`.
/// @param maxPublishTime maximum acceptable publishTime for the given `priceIds`.
/// @return priceFeeds Array of the price feeds corresponding to the given `priceIds` (with the same order).
function parsePriceFeedUpdates(
bytes[] calldata updateData,
bytes32[] calldata priceIds,
uint64 minPublishTime,
uint64 maxPublishTime
) external payable returns (PythStructs.PriceFeed[] memory priceFeeds);
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/**
* @dev Contract module that helps prevent reentrant calls to a function.
*
* Inheriting from `ReentrancyGuard` will make the `nonReentrant` modifier
* available, which can be aplied to functions to make sure there are no nested
* (reentrant) calls to them.
*
* Note that because there is a single `nonReentrant` guard, functions marked as
* `nonReentrant` may not call one another. This can be worked around by making
* those functions `private`, and then adding `external` `nonReentrant` entry
* points to them.
*/
contract ProxyReentrancyGuard {
/// @dev counter to allow mutex lock with only one SSTORE operation
uint256 private _guardCounter;
bool private _initialized;
function initNonReentrant() public {
require(!_initialized, "Already initialized");
_initialized = true;
_guardCounter = 1;
}
/**
* @dev Prevents a contract from calling itself, directly or indirectly.
* Calling a `nonReentrant` function from another `nonReentrant`
* function is not supported. It is possible to prevent this from happening
* by making the `nonReentrant` function external, and make it call a
* `private` function that does the actual work.
*/
modifier nonReentrant() {
_guardCounter += 1;
uint256 localCounter = _guardCounter;
_;
require(localCounter == _guardCounter, "ReentrancyGuard: reentrant call");
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
// Clone of syntetix contract without constructor
contract ProxyOwned {
address public owner;
address public nominatedOwner;
bool private _initialized;
bool private _transferredAtInit;
function setOwner(address _owner) public {
require(_owner != address(0), "Owner address cannot be 0");
require(!_initialized, "Already initialized, use nominateNewOwner");
_initialized = true;
owner = _owner;
emit OwnerChanged(address(0), _owner);
}
function nominateNewOwner(address _owner) external onlyOwner {
nominatedOwner = _owner;
emit OwnerNominated(_owner);
}
function acceptOwnership() external {
require(msg.sender == nominatedOwner, "You must be nominated before you can accept ownership");
emit OwnerChanged(owner, nominatedOwner);
owner = nominatedOwner;
nominatedOwner = address(0);
}
function transferOwnershipAtInit(address proxyAddress) external onlyOwner {
require(proxyAddress != address(0), "Invalid address");
require(!_transferredAtInit, "Already transferred");
owner = proxyAddress;
_transferredAtInit = true;
emit OwnerChanged(owner, proxyAddress);
}
modifier onlyOwner {
_onlyOwner();
_;
}
function _onlyOwner() private view {
require(msg.sender == owner, "Only the contract owner may perform this action");
}
event OwnerNominated(address newOwner);
event OwnerChanged(address oldOwner, address newOwner);
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
// Inheritance
import "./ProxyOwned.sol";
// Clone of syntetix contract without constructor
contract ProxyPausable is ProxyOwned {
uint public lastPauseTime;
bool public paused;
/**
* @notice Change the paused state of the contract
* @dev Only the contract owner may call this.
*/
function setPaused(bool _paused) external onlyOwner {
// Ensure we're actually changing the state before we do anything
if (_paused == paused) {
return;
}
// Set our paused state.
paused = _paused;
// If applicable, set the last pause time.
if (paused) {
lastPauseTime = block.timestamp;
}
// Let everyone know that our pause state has changed.
emit PauseChanged(paused);
}
event PauseChanged(bool isPaused);
modifier notPaused {
require(!paused, "This action cannot be performed while the contract is paused");
_;
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
library AddressSetLib {
struct AddressSet {
address[] elements;
mapping(address => uint) indices;
}
function contains(AddressSet storage set, address candidate) internal view returns (bool) {
if (set.elements.length == 0) {
return false;
}
uint index = set.indices[candidate];
return index != 0 || set.elements[0] == candidate;
}
function getPage(
AddressSet storage set,
uint index,
uint pageSize
) internal view returns (address[] memory) {
// NOTE: This implementation should be converted to slice operators if the compiler is updated to v0.6.0+
uint endIndex = index + pageSize; // The check below that endIndex <= index handles overflow.
// If the page extends past the end of the list, truncate it.
if (endIndex > set.elements.length) {
endIndex = set.elements.length;
}
if (endIndex <= index) {
return new address[](0);
}
uint n = endIndex - index; // We already checked for negative overflow.
address[] memory page = new address[](n);
for (uint i; i < n; i++) {
page[i] = set.elements[i + index];
}
return page;
}
function add(AddressSet storage set, address element) internal {
// Adding to a set is an idempotent operation.
if (!contains(set, element)) {
set.indices[element] = set.elements.length;
set.elements.push(element);
}
}
function remove(AddressSet storage set, address element) internal {
require(contains(set, element), "Element not in set.");
// Replace the removed element with the last element of the list.
uint index = set.indices[element];
uint lastIndex = set.elements.length - 1; // We required that element is in the list, so it is not empty.
if (index != lastIndex) {
// No need to shift the last element if it is the one we want to delete.
address shiftedElement = set.elements[lastIndex];
set.elements[index] = shiftedElement;
set.indices[shiftedElement] = index;
}
set.elements.pop();
delete set.indices[element];
}
}// SPDX-License-Identifier: MIT
pragma solidity >=0.5.16;
interface IStakingThales {
function updateVolume(address account, uint amount) external;
function updateStakingRewards(
uint _currentPeriodRewards,
uint _extraRewards,
uint _revShare
) external;
/* ========== VIEWS / VARIABLES ========== */
function totalStakedAmount() external view returns (uint);
function stakedBalanceOf(address account) external view returns (uint);
function currentPeriodRewards() external view returns (uint);
function currentPeriodFees() external view returns (uint);
function getLastPeriodOfClaimedRewards(address account) external view returns (uint);
function getRewardsAvailable(address account) external view returns (uint);
function getRewardFeesAvailable(address account) external view returns (uint);
function getAlreadyClaimedRewards(address account) external view returns (uint);
function getContractRewardFunds() external view returns (uint);
function getContractFeeFunds() external view returns (uint);
function getAMMVolume(address account) external view returns (uint);
function decreaseAndTransferStakedThales(address account, uint amount) external;
function increaseAndTransferStakedThales(address account, uint amount) external;
function updateVolumeAtAmountDecimals(
address account,
uint amount,
uint decimals
) external;
}// SPDX-License-Identifier: MIT
pragma solidity >=0.5.16;
interface IMultiCollateralOnOffRamp {
function onramp(address collateral, uint collateralAmount) external returns (uint);
function onrampWithEth(uint amount) external payable returns (uint);
function getMinimumReceived(address collateral, uint amount) external view returns (uint);
function getMinimumNeeded(address collateral, uint amount) external view returns (uint);
function WETH9() external view returns (address);
function offrampIntoEth(uint amount) external returns (uint);
function offramp(address collateral, uint amount) external returns (uint);
function offrampFromIntoEth(address collateralFrom, uint amount) external returns (uint);
function offrampFrom(
address collateralFrom,
address collateralTo,
uint amount
) external returns (uint);
function priceFeed() external view returns (address);
}// SPDX-License-Identifier: MIT
pragma solidity >=0.5.16;
interface IReferrals {
function referrals(address) external view returns (address);
function getReferrerFee(address) external view returns (uint);
function sportReferrals(address) external view returns (address);
function setReferrer(address, address) external;
}// SPDX-License-Identifier: MIT
pragma solidity >=0.5.16;
interface IAddressManager {
struct Addresses {
address safeBox;
address referrals;
address stakingThales;
address multiCollateralOnOffRamp;
address pyth;
address speedMarketsAMM;
}
function safeBox() external view returns (address);
function referrals() external view returns (address);
function stakingThales() external view returns (address);
function multiCollateralOnOffRamp() external view returns (address);
function pyth() external view returns (address);
function speedMarketsAMM() external view returns (address);
function getAddresses() external view returns (Addresses memory);
function getAddresses(string[] calldata _contractNames) external view returns (address[] memory contracts);
function getAddress(string memory _contractName) external view returns (address contract_);
function checkIfContractExists(string memory _contractName) external view returns (bool contractExists);
}// SPDX-License-Identifier: MIT
pragma solidity >=0.5.16;
import "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol";
import "@pythnetwork/pyth-sdk-solidity/PythStructs.sol";
import "../SpeedMarkets/SpeedMarket.sol";
import "../SpeedMarkets/SpeedMarketsAMM.sol";
import "./ISpeedMarketsAMMUtils.sol";
interface ISpeedMarketsAMM {
enum OracleSource {
Pyth,
Chainlink
}
struct Params {
bool supportedAsset;
uint safeBoxImpact;
uint64 maximumPriceDelay;
}
function sUSD() external view returns (IERC20Upgradeable);
function addressManager() external view returns (address);
function createNewMarket(SpeedMarketsAMM.CreateMarketParams calldata _params) external returns (address marketAddress);
function resolveMarketWithPrice(address _market, int64 _finalPrice) external;
function canResolveMarket(address market) external view returns (bool);
function multicollateralEnabled() external view returns (bool);
function offrampHelper(address user, uint amount) external;
function supportedAsset(bytes32 _asset) external view returns (bool);
function assetToPythId(bytes32 _asset) external view returns (bytes32);
function assetToChainlinkId(bytes32 _asset) external view returns (bytes32);
function minBuyinAmount() external view returns (uint);
function maxBuyinAmount() external view returns (uint);
function minimalTimeToMaturity() external view returns (uint);
function maximalTimeToMaturity() external view returns (uint);
function maximumPriceDelay() external view returns (uint64);
function maximumPriceDelayForResolving() external view returns (uint64);
function timeThresholdsForFees(uint _index) external view returns (uint);
function lpFees(uint _index) external view returns (uint);
function lpFee() external view returns (uint);
function maxSkewImpact() external view returns (uint);
function safeBoxImpact() external view returns (uint);
function marketHasCreatedAtAttribute(address _market) external view returns (bool);
function marketHasFeeAttribute(address _market) external view returns (bool);
function maxRiskPerAsset(bytes32 _asset) external view returns (uint);
function currentRiskPerAsset(bytes32 _asset) external view returns (uint);
function maxRiskPerAssetAndDirection(bytes32 _asset, SpeedMarket.Direction _direction) external view returns (uint);
function currentRiskPerAssetAndDirection(bytes32 _asset, SpeedMarket.Direction _direction) external view returns (uint);
function whitelistedAddresses(address _wallet) external view returns (bool);
function getLengths(address _user) external view returns (uint[5] memory);
function getParams(bytes32 _asset) external view returns (Params memory);
function supportedNativeCollateral(address _collateral) external view returns (bool);
function bonusPerCollateral(address _collateral) external view returns (uint);
function speedMarketsAMMUtils() external view returns (ISpeedMarketsAMMUtils);
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol";
import "../interfaces/ISpeedMarketsAMM.sol";
contract SpeedMarket {
using SafeERC20Upgradeable for IERC20Upgradeable;
struct InitParams {
address _speedMarketsAMM;
address _user;
bytes32 _asset;
uint64 _strikeTime;
int64 _strikePrice;
uint64 _strikePricePublishTime;
ISpeedMarketsAMM.OracleSource _oracleSource;
Direction _direction;
address _collateral;
uint _buyinAmount;
uint _safeBoxImpact;
uint _lpFee;
uint _payout;
}
enum Direction {
Up,
Down
}
address public user;
bytes32 public asset;
uint64 public strikeTime;
int64 public strikePrice;
uint64 public strikePricePublishTime;
ISpeedMarketsAMM.OracleSource public oracleSource;
Direction public direction;
uint public buyinAmount;
uint public payout;
address public collateral;
bool public resolved;
int64 public finalPrice;
Direction public result;
ISpeedMarketsAMM public speedMarketsAMM;
uint public safeBoxImpact;
uint public lpFee;
uint256 public createdAt;
/* ========== CONSTRUCTOR ========== */
bool public initialized = false;
function initialize(InitParams calldata params) external {
require(!initialized, "Speed market already initialized");
initialized = true;
speedMarketsAMM = ISpeedMarketsAMM(params._speedMarketsAMM);
user = params._user;
asset = params._asset;
strikeTime = params._strikeTime;
strikePrice = params._strikePrice;
strikePricePublishTime = params._strikePricePublishTime;
oracleSource = params._oracleSource;
direction = params._direction;
buyinAmount = params._buyinAmount;
safeBoxImpact = params._safeBoxImpact;
lpFee = params._lpFee;
collateral = params._collateral;
payout = params._payout;
IERC20Upgradeable(params._collateral).approve(params._speedMarketsAMM, type(uint256).max);
createdAt = block.timestamp;
}
function resolve(int64 _finalPrice) external onlyAMM {
require(!resolved, "already resolved");
require(block.timestamp > strikeTime, "not ready to be resolved");
resolved = true;
finalPrice = _finalPrice;
if (finalPrice < strikePrice) {
result = Direction.Down;
} else if (finalPrice > strikePrice) {
result = Direction.Up;
} else {
result = direction == Direction.Up ? Direction.Down : Direction.Up;
}
uint payoutToTransfer = IERC20Upgradeable(collateral).balanceOf(address(this));
if (direction == result) {
if (payoutToTransfer > payout) {
IERC20Upgradeable(collateral).safeTransfer(address(speedMarketsAMM), payoutToTransfer - payout);
payoutToTransfer = payout;
}
IERC20Upgradeable(collateral).safeTransfer(user, payoutToTransfer);
} else {
IERC20Upgradeable(collateral).safeTransfer(address(speedMarketsAMM), payoutToTransfer);
}
emit Resolved(finalPrice, result, direction == result);
}
function isUserWinner() external view returns (bool) {
return resolved && (direction == result);
}
modifier onlyAMM() {
require(msg.sender == address(speedMarketsAMM), "only the AMM may perform these methods");
_;
}
event Resolved(int64 finalPrice, Direction result, bool userIsWinner);
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/// @title An AMM utils for Thales speed markets
interface ISpeedMarketsAMMUtils {
function getFeeByTimeThreshold(
uint64 _deltaTimeSec,
uint[] calldata _timeThresholds,
uint[] calldata _fees,
uint _defaultFee
) external pure returns (uint fee);
function collateralKey(address _collateral) external view returns (bytes32);
function setCollateralKey(address _collateral, bytes32 _key) external;
function transformCollateralToUSD(
address _collateral,
address defaultCollateral,
uint _amount
) external view returns (uint);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Address.sol)
pragma solidity ^0.8.0;
/**
* @dev Collection of functions related to the address type
*/
library AddressUpgradeable {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize, which returns 0 for contracts in
// construction, since the code is only stored at the end of the
// constructor execution.
uint256 size;
assembly {
size := extcodesize(account)
}
return size > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value
) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory errorMessage
) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
require(isContract(target), "Address: call to non-contract");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(
address target,
bytes memory data,
string memory errorMessage
) internal view returns (bytes memory) {
require(isContract(target), "Address: static call to non-contract");
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
* revert reason using the provided one.
*
* _Available since v4.3._
*/
function verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) internal pure returns (bytes memory) {
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)
pragma solidity ^0.8.0;
import "../proxy/utils/Initializable.sol";
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract ContextUpgradeable is Initializable {
function __Context_init() internal onlyInitializing {
__Context_init_unchained();
}
function __Context_init_unchained() internal onlyInitializing {
}
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
uint256[50] private __gap;
}// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.0;
contract PythStructs {
// A price with a degree of uncertainty, represented as a price +- a confidence interval.
//
// The confidence interval roughly corresponds to the standard error of a normal distribution.
// Both the price and confidence are stored in a fixed-point numeric representation,
// `x * (10^expo)`, where `expo` is the exponent.
//
// Please refer to the documentation at https://docs.pyth.network/consumers/best-practices for how
// to how this price safely.
struct Price {
// Price
int64 price;
// Confidence interval around the price
uint64 conf;
// Price exponent
int32 expo;
// Unix timestamp describing when the price was published
uint publishTime;
}
// PriceFeed represents a current aggregate price from pyth publisher feeds.
struct PriceFeed {
// The price ID.
bytes32 id;
// Latest available price
Price price;
// Latest available exponentially-weighted moving average price
Price emaPrice;
}
}// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.0;
/// @title IPythEvents contains the events that Pyth contract emits.
/// @dev This interface can be used for listening to the updates for off-chain and testing purposes.
interface IPythEvents {
/// @dev Emitted when the price feed with `id` has received a fresh update.
/// @param id The Pyth Price Feed ID.
/// @param publishTime Publish time of the given price update.
/// @param price Price of the given price update.
/// @param conf Confidence interval of the given price update.
event PriceFeedUpdate(
bytes32 indexed id,
uint64 publishTime,
int64 price,
uint64 conf
);
/// @dev Emitted when a batch price update is processed successfully.
/// @param chainId ID of the source chain that the batch price update comes from.
/// @param sequenceNumber Sequence number of the batch price update.
event BatchPriceFeedUpdate(uint16 chainId, uint64 sequenceNumber);
}{
"optimizer": {
"enabled": true,
"runs": 100
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
}
}Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"inputs":[],"name":"AssetNotSupported","type":"error"},{"inputs":[],"name":"BonusTooHigh","type":"error"},{"inputs":[],"name":"CanNotResolve","type":"error"},{"inputs":[],"name":"CanOnlyBeCalledFromResolverOrOwner","type":"error"},{"inputs":[],"name":"CollateralNotSupported","type":"error"},{"inputs":[],"name":"EtherTransferFailed","type":"error"},{"inputs":[],"name":"InvalidBuyinAmount","type":"error"},{"inputs":[],"name":"InvalidOffRampCollateral","type":"error"},{"inputs":[],"name":"InvalidPrice","type":"error"},{"inputs":[],"name":"InvalidStrikeTime","type":"error"},{"inputs":[],"name":"InvalidWhitelistAddress","type":"error"},{"inputs":[],"name":"MismatchedLengths","type":"error"},{"inputs":[],"name":"MulticollateralOnrampDisabled","type":"error"},{"inputs":[],"name":"NotEnoughReceivedViaOnramp","type":"error"},{"inputs":[],"name":"OnlyCreatorAllowed","type":"error"},{"inputs":[],"name":"OnlyMarketOwner","type":"error"},{"inputs":[],"name":"RiskPerAssetExceeded","type":"error"},{"inputs":[],"name":"RiskPerDirectionExceeded","type":"error"},{"inputs":[],"name":"SkewSlippageExceeded","type":"error"},{"inputs":[],"name":"TimeTooFarIntoFuture","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_mastercopy","type":"address"},{"indexed":false,"internalType":"contract ISpeedMarketsAMMUtils","name":"_speedMarketsAMMUtils","type":"address"},{"indexed":false,"internalType":"address","name":"_addressManager","type":"address"}],"name":"AMMAddressesChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_whitelistAddress","type":"address"},{"indexed":false,"internalType":"bool","name":"_flag","type":"bool"}],"name":"AddedIntoWhitelist","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_collateral","type":"address"},{"indexed":false,"internalType":"address","name":"_destination","type":"address"},{"indexed":false,"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"AmountTransfered","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"collateral","type":"address"},{"indexed":false,"internalType":"uint256","name":"bonus","type":"uint256"}],"name":"CollateralBonusSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"_minBuyinAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_maxBuyinAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_minimalTimeToMaturity","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_maximalTimeToMaturity","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_maximumPriceDelay","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_maximumPriceDelayForResolving","type":"uint256"}],"name":"LimitParamsChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_market","type":"address"},{"indexed":false,"internalType":"address","name":"_user","type":"address"},{"indexed":false,"internalType":"bytes32","name":"_asset","type":"bytes32"},{"indexed":false,"internalType":"uint256","name":"_strikeTime","type":"uint256"},{"indexed":false,"internalType":"int64","name":"_strikePrice","type":"int64"},{"indexed":false,"internalType":"enum SpeedMarket.Direction","name":"_direction","type":"uint8"},{"indexed":false,"internalType":"uint256","name":"_buyinAmount","type":"uint256"}],"name":"MarketCreated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_market","type":"address"},{"indexed":false,"internalType":"address","name":"_user","type":"address"},{"indexed":false,"internalType":"bytes32","name":"_asset","type":"bytes32"},{"indexed":false,"internalType":"uint256","name":"_strikeTime","type":"uint256"},{"indexed":false,"internalType":"int64","name":"_strikePrice","type":"int64"},{"indexed":false,"internalType":"enum SpeedMarket.Direction","name":"_direction","type":"uint8"},{"indexed":false,"internalType":"uint256","name":"_buyinAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_safeBoxImpact","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_lpFee","type":"uint256"}],"name":"MarketCreatedWithFees","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_market","type":"address"},{"indexed":false,"internalType":"enum SpeedMarket.Direction","name":"_result","type":"uint8"},{"indexed":false,"internalType":"bool","name":"_userIsWinner","type":"bool"}],"name":"MarketResolved","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bool","name":"_enabled","type":"bool"}],"name":"MultiCollateralOnOffRampEnabled","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"oldOwner","type":"address"},{"indexed":false,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnerChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnerNominated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bool","name":"isPaused","type":"bool"}],"name":"PauseChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"refferer","type":"address"},{"indexed":false,"internalType":"address","name":"trader","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"volume","type":"uint256"}],"name":"ReferrerPaid","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"_safeBoxImpact","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_maxSkewImpact","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_skewSlippage","type":"uint256"}],"name":"SafeBoxAndMaxSkewImpactChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"asset","type":"bytes32"},{"indexed":false,"internalType":"bytes32","name":"pythId","type":"bytes32"},{"indexed":false,"internalType":"bytes32","name":"chainlinkId","type":"bytes32"}],"name":"SetAssetToPriceOracleID","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256[]","name":"_timeThresholds","type":"uint256[]"},{"indexed":false,"internalType":"uint256[]","name":"_lpFees","type":"uint256[]"},{"indexed":false,"internalType":"uint256","name":"_lpFee","type":"uint256"}],"name":"SetLPFeeParams","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"asset","type":"bytes32"},{"indexed":false,"internalType":"uint256","name":"_maxRiskPerAsset","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_maxRiskPerAssetAndDirection","type":"uint256"}],"name":"SetMaxRisks","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"asset","type":"bytes32"},{"indexed":false,"internalType":"bool","name":"_supported","type":"bool"}],"name":"SetSupportedAsset","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_sUSD","type":"address"}],"name":"SusdAddressChanged","type":"event"},{"inputs":[],"name":"acceptOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"index","type":"uint256"},{"internalType":"uint256","name":"pageSize","type":"uint256"}],"name":"activeMarkets","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"index","type":"uint256"},{"internalType":"uint256","name":"pageSize","type":"uint256"},{"internalType":"address","name":"user","type":"address"}],"name":"activeMarketsPerUser","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_whitelistAddress","type":"address"},{"internalType":"bool","name":"_flag","type":"bool"}],"name":"addToWhitelist","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"addressManager","outputs":[{"internalType":"contract IAddressManager","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"assetToChainlinkId","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"assetToPythId","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"bonusPerCollateral","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"market","type":"address"}],"name":"canResolveMarket","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"user","type":"address"},{"internalType":"bytes32","name":"asset","type":"bytes32"},{"internalType":"uint64","name":"strikeTime","type":"uint64"},{"internalType":"uint64","name":"delta","type":"uint64"},{"internalType":"int64","name":"strikePrice","type":"int64"},{"internalType":"uint64","name":"strikePricePublishTime","type":"uint64"},{"internalType":"enum ISpeedMarketsAMM.OracleSource","name":"oracleSource","type":"uint8"},{"internalType":"enum SpeedMarket.Direction","name":"direction","type":"uint8"},{"internalType":"address","name":"collateral","type":"address"},{"internalType":"uint256","name":"collateralAmount","type":"uint256"},{"internalType":"address","name":"referrer","type":"address"},{"internalType":"uint256","name":"skewImpact","type":"uint256"}],"internalType":"struct SpeedMarketsAMM.CreateMarketParams","name":"_params","type":"tuple"}],"name":"createNewMarket","outputs":[{"internalType":"address","name":"marketAddress","type":"address"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"currentRiskPerAsset","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"},{"internalType":"enum SpeedMarket.Direction","name":"","type":"uint8"}],"name":"currentRiskPerAssetAndDirection","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"}],"name":"getLengths","outputs":[{"internalType":"uint256[5]","name":"","type":"uint256[5]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"asset","type":"bytes32"}],"name":"getParams","outputs":[{"components":[{"internalType":"bool","name":"supportedAsset","type":"bool"},{"internalType":"uint256","name":"safeBoxImpact","type":"uint256"},{"internalType":"uint64","name":"maximumPriceDelay","type":"uint64"}],"internalType":"struct ISpeedMarketsAMM.Params","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"initNonReentrant","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"contract IERC20Upgradeable","name":"_sUSD","type":"address"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"lastPauseTime","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lpFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"lpFees","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"marketHasCreatedAtAttribute","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"marketHasFeeAttribute","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"index","type":"uint256"},{"internalType":"uint256","name":"pageSize","type":"uint256"}],"name":"maturedMarkets","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"index","type":"uint256"},{"internalType":"uint256","name":"pageSize","type":"uint256"},{"internalType":"address","name":"user","type":"address"}],"name":"maturedMarketsPerUser","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxBuyinAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"maxRiskPerAsset","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"},{"internalType":"enum SpeedMarket.Direction","name":"","type":"uint8"}],"name":"maxRiskPerAssetAndDirection","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxSkewImpact","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maximalTimeToMaturity","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maximumPriceDelay","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maximumPriceDelayForResolving","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"minBuyinAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"minimalTimeToMaturity","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"multicollateralEnabled","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_owner","type":"address"}],"name":"nominateNewOwner","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"nominatedOwner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"offrampHelper","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_market","type":"address"},{"internalType":"int64","name":"_finalPrice","type":"int64"}],"name":"resolveMarketWithPrice","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"sUSD","outputs":[{"internalType":"contract IERC20Upgradeable","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"safeBoxImpact","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_mastercopy","type":"address"},{"internalType":"contract ISpeedMarketsAMMUtils","name":"_speedMarketsAMMUtils","type":"address"},{"internalType":"address","name":"_addressManager","type":"address"}],"name":"setAMMAddresses","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"asset","type":"bytes32"},{"internalType":"bytes32","name":"pythId","type":"bytes32"},{"internalType":"bytes32","name":"chainlinkId","type":"bytes32"}],"name":"setAssetToPriceOracleID","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"_timeThresholds","type":"uint256[]"},{"internalType":"uint256[]","name":"_lpFees","type":"uint256[]"},{"internalType":"uint256","name":"_lpFee","type":"uint256"}],"name":"setLPFeeParams","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_minBuyinAmount","type":"uint256"},{"internalType":"uint256","name":"_maxBuyinAmount","type":"uint256"},{"internalType":"uint256","name":"_minimalTimeToMaturity","type":"uint256"},{"internalType":"uint256","name":"_maximalTimeToMaturity","type":"uint256"},{"internalType":"uint64","name":"_maximumPriceDelay","type":"uint64"},{"internalType":"uint64","name":"_maximumPriceDelayForResolving","type":"uint64"}],"name":"setLimitParams","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"asset","type":"bytes32"},{"internalType":"uint256","name":"_maxRiskPerAsset","type":"uint256"},{"internalType":"uint256","name":"_maxRiskPerAssetAndDirection","type":"uint256"}],"name":"setMaxRisks","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"_enabled","type":"bool"}],"name":"setMultiCollateralOnOffRampEnabled","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_owner","type":"address"}],"name":"setOwner","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"_paused","type":"bool"}],"name":"setPaused","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_safeBoxImpact","type":"uint256"},{"internalType":"uint256","name":"_maxSkewImpact","type":"uint256"},{"internalType":"uint256","name":"_skewSlippage","type":"uint256"}],"name":"setSafeBoxAndMaxSkewImpact","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"asset","type":"bytes32"},{"internalType":"bool","name":"_supported","type":"bool"}],"name":"setSupportedAsset","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_collateral","type":"address"},{"internalType":"bool","name":"_supported","type":"bool"},{"internalType":"uint256","name":"_bonus","type":"uint256"},{"internalType":"bytes32","name":"_collateralKey","type":"bytes32"}],"name":"setSupportedNativeCollateralAndBonus","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_sUSD","type":"address"}],"name":"setSusdAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"skewSlippage","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"speedMarketMastercopy","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"speedMarketsAMMUtils","outputs":[{"internalType":"contract ISpeedMarketsAMMUtils","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"supportedAsset","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"supportedNativeCollateral","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"timeThresholdsForFees","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_collateral","type":"address"},{"internalType":"address","name":"_destination","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"transferAmount","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"proxyAddress","type":"address"}],"name":"transferOwnershipAtInit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"whitelistedAddresses","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"stateMutability":"payable","type":"receive"}]Contract Creation Code
608060405234801561001057600080fd5b50614be4806100206000396000f3fe6080604052600436106103315760003560e01c8063704ce43e116101a7578063bc93233f116100ed578063e396ed2611610090578063e396ed2614610b2f578063e60a4d2514610b5f578063e73efc9b14610b8c578063e76fbb0214610bac578063e915586614610bcc578063ebc7977214610be2578063ef469ba214610bf7578063fd6e9b9714610c1757600080fd5b8063bc93233f14610a07578063bd47a9b814610a27578063c3b83f5f14610a54578063c453180214610a74578063ce87e2ee14610aa1578063cf898ca914610ac1578063d69fb66814610ae1578063e11f951d14610af757600080fd5b8063980af6a711610155578063980af6a7146108d7578063999045a0146108f757806399c18e7e146109175780639fc4270314610938578063a201b30714610958578063a2f6532114610997578063b0308e07146109c7578063b711d407146109e757600080fd5b8063704ce43e1461081057806379ba5097146108265780637de926d11461083b57806389c6318d1461085b5780638da5cb5b1461087b57806391b4ded9146108a15780639324cac7146108b757600080fd5b80633ab76e9f116102775780635403f80f1161021a5780635403f80f146107205780635631bf8a1461073657806357dfa0ff146107565780635c975abb1461077657806368b9f66b146107905780636bfffb12146107b05780636ce6c3ca146107d05780636dcf6def146107f057600080fd5b80633ab76e9f146106035780633b46bfc9146106305780633c1ae421146106505780633e7ad1de1461067d578063485cc9551461069357806348dde564146106b35780634eb7c43b146106e057806353a47bb71461070057600080fd5b806312039b6d116102df57806312039b6d1461047c57806312aa3833146104a957806313af4035146104bf57806314527f3a146104df5780631627540c146104ff57806316c38b3c1461051f578063289cc19f1461053f5780632b03da3c1461055557600080fd5b806301bea6361461033d57806301f4747114610381578063023fb259146103a357806302da6244146103d057806305bfdfd4146103f057806306c933d81461043657806307b53bb41461046657600080fd5b3661033857005b600080fd5b34801561034957600080fd5b5061036c610358366004613f6d565b602080526000908152604090205460ff1681565b60405190151581526020015b60405180910390f35b34801561038d57600080fd5b506103a161039c366004613f8a565b610c47565b005b3480156103af57600080fd5b506103c36103be366004613f6d565b610ca3565b6040516103789190613fcb565b3480156103dc57600080fd5b506103a16103eb366004613ffc565b610cfe565b3480156103fc57600080fd5b5061042861040b366004614040565b601e60209081526000928352604080842090915290825290205481565b604051908152602001610378565b34801561044257600080fd5b5061036c610451366004613f6d565b601b6020526000908152604090205460ff1681565b34801561047257600080fd5b5061042860135481565b34801561048857600080fd5b5061049c610497366004614070565b610d60565b60405161037891906140a9565b3480156104b557600080fd5b5061042860125481565b3480156104cb57600080fd5b506103a16104da366004613f6d565b610d90565b3480156104eb57600080fd5b5061036c6104fa366004613f6d565b610eb3565b34801561050b57600080fd5b506103a161051a366004613f6d565b610fa6565b34801561052b57600080fd5b506103a161053a366004614104565b610ff9565b34801561054b57600080fd5b5061042860285481565b34801561056157600080fd5b506105d6610570366004614121565b60408051606080820183526000808352602080840182905292840181905283519182018452808252818301818152828501828152958252600f909352929092205460ff1615158252600c549052601754600160a01b90046001600160401b031690915290565b6040805182511515815260208084015190820152918101516001600160401b031690820152606001610378565b34801561060f57600080fd5b50602654610623906001600160a01b031681565b604051610378919061413a565b34801561063c57600080fd5b506103a161064b36600461416e565b61106b565b34801561065c57600080fd5b5061042861066b366004613f6d565b602a6020526000908152604090205481565b34801561068957600080fd5b5061042860105481565b34801561069f57600080fd5b506103a16106ae3660046141cc565b611127565b3480156106bf57600080fd5b506104286106ce366004614121565b602b6020526000908152604090205481565b3480156106ec57600080fd5b506104286106fb366004614121565b61122a565b34801561070c57600080fd5b50600154610623906001600160a01b031681565b34801561072c57600080fd5b5061042860115481565b34801561074257600080fd5b50610428610751366004614121565b61124b565b34801561076257600080fd5b50602454610623906001600160a01b031681565b34801561078257600080fd5b5060035461036c9060ff1681565b34801561079c57600080fd5b506103a16107ab366004614104565b61125b565b3480156107bc57600080fd5b506103a16107cb3660046141fa565b6113bf565b3480156107dc57600080fd5b506106236107eb36600461423a565b611443565b3480156107fc57600080fd5b506103a161080b36600461424d565b61173b565b34801561081c57600080fd5b50610428600d5481565b34801561083257600080fd5b506103a16117f7565b34801561084757600080fd5b506103a1610856366004614279565b6118e2565b34801561086757600080fd5b5061049c61087636600461429e565b61193c565b34801561088757600080fd5b50600054610623906201000090046001600160a01b031681565b3480156108ad57600080fd5b5061042860025481565b3480156108c357600080fd5b50600a54610623906001600160a01b031681565b3480156108e357600080fd5b506103a16108f23660046142c0565b61194a565b34801561090357600080fd5b506103a1610912366004613f6d565b611a52565b34801561092357600080fd5b50601c5461036c90600160a01b900460ff1681565b34801561094457600080fd5b5061049c610953366004614070565b611aa5565b34801561096457600080fd5b5060175461097f90600160a01b90046001600160401b031681565b6040516001600160401b039091168152602001610378565b3480156109a357600080fd5b5061036c6109b2366004613f6d565b60296020526000908152604090205460ff1681565b3480156109d357600080fd5b506103a16109e2366004614318565b611acb565b3480156109f357600080fd5b506103a1610a02366004614398565b611bba565b348015610a1357600080fd5b506103a1610a2236600461440b565b611cce565b348015610a3357600080fd5b50610428610a42366004614121565b60166020526000908152604090205481565b348015610a6057600080fd5b506103a1610a6f366004613f6d565b611d59565b348015610a8057600080fd5b50610428610a8f366004614121565b60146020526000908152604090205481565b348015610aad57600080fd5b50600b54610623906001600160a01b031681565b348015610acd57600080fd5b50601f5461097f906001600160401b031681565b348015610aed57600080fd5b50610428600c5481565b348015610b0357600080fd5b50610428610b12366004614040565b601d60209081526000928352604080842090915290825290205481565b348015610b3b57600080fd5b5061036c610b4a366004614121565b600f6020526000908152604090205460ff1681565b348015610b6b57600080fd5b50610428610b7a366004614121565b60156020526000908152604090205481565b348015610b9857600080fd5b5061049c610ba736600461429e565b611e5c565b348015610bb857600080fd5b506103a1610bc7366004613ffc565b611e6a565b348015610bd857600080fd5b5061042860275481565b348015610bee57600080fd5b506103a1611ebf565b348015610c0357600080fd5b506103a1610c12366004613ffc565b611f1d565b348015610c2357600080fd5b5061036c610c32366004613f6d565b60256020526000908152604090205460ff1681565b610c4f611f9b565b610c636001600160a01b0384168383612015565b7f3dfef6507ded35b9ec518bb3532736bd85a598bdcb440fdd2289ce92a771e797838383604051610c9693929190614439565b60405180910390a1505050565b610cab613efd565b506040805160a08101825260065481526008546020808301919091526001600160a01b039093166000818152601985528381205483850152908152601a9093529120546060820152602354608082015290565b610d06611f9b565b6000838152601660209081526040808320859055602b82529182902083905581518581529081018490529081018290527fa5d0eb0e57599c22b55099481fc764a3e5bec63ea97f8c409c31f0883678a00f90606001610c96565b6001600160a01b0381166000908152601960205260409020606090610d8690858561206b565b90505b9392505050565b6001600160a01b038116610de75760405162461bcd60e51b815260206004820152601960248201527804f776e657220616464726573732063616e6e6f74206265203603c1b60448201526064015b60405180910390fd5b600154600160a01b900460ff1615610e535760405162461bcd60e51b815260206004820152602960248201527f416c726561647920696e697469616c697a65642c20757365206e6f6d696e617460448201526832a732bba7bbb732b960b91b6064820152608401610dde565b6001805460ff60a01b1916600160a01b179055600080546001600160a01b038316620100000262010000600160b01b0319909116178155604051600080516020614b8f83398151915291610ea891849061445d565b60405180910390a150565b6000610ec0600683612185565b8015610f35575042826001600160a01b03166351d8044f6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610f06573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f2a9190614477565b6001600160401b0316105b8015610fa05750816001600160a01b0316633f6fa6556040518163ffffffff1660e01b8152600401602060405180830381865afa158015610f7a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f9e9190614494565b155b92915050565b610fae611f9b565b600180546001600160a01b0319166001600160a01b0383161790556040517f906a1c6bd7e3091ea86693dd029a831c19049ce77f1dce2ce0bab1cacbabce2290610ea890839061413a565b611001611f9b565b60035460ff16151581151514611068576003805460ff191682151590811790915560ff161561102f57426002555b60035460405160ff909116151581527f8fb6c181ee25a520cf3dd6565006ef91229fcfe5a989566c2a3b8c115570cec590602001610ea8565b50565b611073611f9b565b60128690556013859055601084905560118390556017805467ffffffffffffffff60a01b1916600160a01b6001600160401b0385811691820292909217909255601f805467ffffffffffffffff19169184169182179055604080518981526020810189905290810187905260608101869052608081019290925260a08201527fcb4727945d0c9bf77ea3b48c6c630e5b0e5016c1fe67c9508feafe8fc265cdba9060c00160405180910390a1505050505050565b600054610100900460ff166111425760005460ff1615611146565b303b155b6111a95760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401610dde565b600054610100900460ff161580156111cb576000805461ffff19166101011790555b6111d483610d90565b6111dc611ebf565b600a80546001600160a01b0319166001600160a01b0384169081179091556000908152602960205260409020805460ff191660011790558015611225576000805461ff00191690555b505050565b6023818154811061123a57600080fd5b600091825260209091200154905081565b6022818154811061123a57600080fd5b611263611f9b565b60265460408051639a618c0f60e01b815290516000926001600160a01b031691639a618c0f9160048083019260209291908290030181865afa1580156112ad573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112d191906144b1565b90506001600160a01b0381161561136657600a546001600160a01b031663095ea7b38284611300576000611304565b6000195b6040518363ffffffff1660e01b81526004016113219291906144ce565b6020604051808303816000875af1158015611340573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113649190614494565b505b601c8054831515600160a01b0260ff60a01b199091161790556040517fb76eab56cfa3088dda43a9a4b3ea4bb7685b8007428d4a65248fdaa763d339f8906113b390841515815260200190565b60405180910390a15050565b6113c7611f9b565b600b80546001600160a01b038581166001600160a01b0319928316811790935560248054868316908416811790915560268054928616929093168217909255604080519384526020840192909252908201527fbf934b81354c7e34eda71aa08a74419a5682a0737282cc3f448b353a1893c41f90606001610c96565b600060016004600082825461145891906144fd565b909155505060045460035460ff16156114d95760405162461bcd60e51b815260206004820152603c60248201527f5468697320616374696f6e2063616e6e6f7420626520706572666f726d65642060448201527f7768696c652074686520636f6e747261637420697320706175736564000000006064820152608401610dde565b60265460405163bf40fac160e01b815260206004820152601660248201527529b832b2b226b0b935b2ba39a0a6a6a1b932b0ba37b960511b60448201526000916001600160a01b03169063bf40fac190606401602060405180830381865afa158015611549573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061156d91906144b1565b9050336001600160a01b038216146115985760405163027cbd1b60e61b815260040160405180910390fd5b602654604080516351cfd60960e11b815290516000926001600160a01b03169163a39fac129160048083019260c09291908290030181865afa1580156115e2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611606919061455d565b9050600061161a6060870160408801614615565b6001600160401b03161561163d576116386060870160408801614615565b611660565b61164d6080870160608801614615565b611660906001600160401b0316426144fd565b90506000806000806116738a86886121fb565b935093509350935060006040518060c001604052808c8036038101906116999190614632565b81526020018615158152602001876001600160401b03168152602001848152602001838152602001856001600160a01b031681525090506116da81886123cb565b9950505050505050505060045481146117355760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610dde565b50919050565b60265460405163bf40fac160e01b81526001600160a01b039091169063bf40fac1906117699060040161470b565b602060405180830381865afa158015611786573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117aa91906144b1565b6001600160a01b0316336001600160a01b0316146117db57604051635bc2da4960e01b815260040160405180910390fd5b600a546117f3906001600160a01b031683338461290d565b5050565b6001546001600160a01b0316331461186f5760405162461bcd60e51b815260206004820152603560248201527f596f75206d757374206265206e6f6d696e61746564206265666f726520796f7560448201527402063616e20616363657074206f776e65727368697605c1b6064820152608401610dde565b600054600154604051600080516020614b8f833981519152926118a6926001600160a01b036201000090920482169291169061445d565b60405180910390a1600180546000805462010000600160b01b0319166001600160a01b03831662010000021790556001600160a01b0319169055565b6118ea611f9b565b6000828152600f6020908152604091829020805460ff19168415159081179091558251858152918201527f6af8d0ea20290a2d8dcbb43a77926d5993cd89bac2c6a72cd7813c4eacc2124b91016113b3565b6060610d896008848461206b565b611952611f9b565b67016345785d8a000082111561197b57604051630f49511f60e21b815260040160405180910390fd5b6001600160a01b038481166000908152602a60209081526040808320869055602990915290819020805460ff19168615151790556024549051637f36de5360e11b815291169063fe6dbca6906119d790879085906004016144ce565b600060405180830381600087803b1580156119f157600080fd5b505af1158015611a05573d6000803e3d6000fd5b50505050836001600160a01b03167f17e58c675f250b8ef0675335e238a5dd06ca310d6241de740796696bf61026d983604051611a4491815260200190565b60405180910390a250505050565b611a5a611f9b565b600a80546001600160a01b0319166001600160a01b0383161790556040517fba10f1023c43b7797db2ff58a62990dbbb24aa29adb28dae7424301e38d99ed990610ea890839061413a565b6001600160a01b0381166000908152601a60205260409020606090610d8690858561206b565b60265460405163bf40fac160e01b81526001600160a01b039091169063bf40fac190611af99060040161470b565b602060405180830381865afa158015611b16573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b3a91906144b1565b6001600160a01b0316336001600160a01b031614158015611b6c57506000546201000090046001600160a01b03163314155b15611b8a57604051635bc2da4960e01b815260040160405180910390fd5b611b9382610eb3565b611bb0576040516309f4985b60e21b815260040160405180910390fd5b6117f38282612934565b611bc2611f9b565b838214611be2576040516373f8993760e11b815260040160405180910390fd5b611bee60226000613f1b565b611bfa60236000613f1b565b60005b84811015611c81576022868683818110611c1957611c1961473c565b835460018101855560009485526020948590209190940292909201359190920155506023848483818110611c4f57611c4f61473c565b83546001810185556000948552602094859020919094029290920135919092015550611c7a81614752565b9050611bfd565b50600d8190556040517f97b8e3f33b113d945b11628418dc7b155d05943a8a517a937a9d88f4eda67a6b90611cbf908790879087908790879061479d565b60405180910390a15050505050565b611cd6611f9b565b6001600160a01b038216611cfd57604051634d553d1960e01b815260040160405180910390fd5b6001600160a01b0382166000818152601b6020908152604091829020805460ff19168515159081179091558251938452908301527f58d7a3ccc34541e162fcfc87b84be7b78c34d1e1e7f15de6e4dd67d0fe70aecd91016113b3565b611d61611f9b565b6001600160a01b038116611da95760405162461bcd60e51b815260206004820152600f60248201526e496e76616c6964206164647265737360881b6044820152606401610dde565b600154600160a81b900460ff1615611df95760405162461bcd60e51b8152602060048201526013602482015272105b1c9958591e481d1c985b9cd9995c9c9959606a1b6044820152606401610dde565b600080546001600160a01b038084166201000090810262010000600160b01b031990931692909217928390556001805460ff60a81b1916600160a81b179055604051600080516020614b8f83398151915293610ea893900490911690849061445d565b6060610d896006848461206b565b611e72611f9b565b600c8390556027829055602881905560408051848152602081018490529081018290527faa4fb0e426c89ca5b40184bc99ab0d12c722021c90689decd8f7b901d3f82b3490606001610c96565b60055460ff1615611f085760405162461bcd60e51b8152602060048201526013602482015272105b1c9958591e481a5b9a5d1a585b1a5e9959606a1b6044820152606401610dde565b6005805460ff19166001908117909155600455565b611f25611f9b565b600083815260146020908152604080832085905560158252808320839055601d82528083208380528252808320849055600183529182902083905581518581529081018490529081018290527facbec488a49aaa9d1b3799159ede0349850bc1a73c0e90913ff03dd4354a34a890606001610c96565b6000546201000090046001600160a01b031633146120135760405162461bcd60e51b815260206004820152602f60248201527f4f6e6c792074686520636f6e7472616374206f776e6572206d6179207065726660448201526e37b936903a3434b99030b1ba34b7b760891b6064820152608401610dde565b565b6112258363a9059cbb60e01b84846040516024016120349291906144ce565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152612fe4565b6060600061207983856144fd565b8554909150811115612089575083545b8381116120a6575050604080516000815260208101909152610d89565b60006120b285836147ed565b90506000816001600160401b038111156120ce576120ce614510565b6040519080825280602002602001820160405280156120f7578160200160208202803683370190505b50905060005b8281101561217a578761211088836144fd565b815481106121205761212061473c565b9060005260206000200160009054906101000a90046001600160a01b03168282815181106121505761215061473c565b6001600160a01b03909216602092830291909101909101528061217281614752565b9150506120fd565b509695505050505050565b8154600090810361219857506000610fa0565b6001600160a01b0382166000908152600184016020526040902054801515806121f35750826001600160a01b0316846000016000815481106121dc576121dc61473c565b6000918252602090912001546001600160a01b0316145b949350505050565b60008080806029816122156101208a016101008b01613f6d565b6001600160a01b0316815260208101919091526040016000205460ff16806122575750600061224c61012089016101008a01613f6d565b6001600160a01b0316145b93506029600061226f6101208a016101008b01613f6d565b6001600160a01b0316815260208101919091526040016000205460ff1680156122b3575060006122a761012089016101008a01613f6d565b6001600160a01b031614155b156122d1576122ca61012088016101008901613f6d565b92506122e0565b600a546001600160a01b031692505b831561238d575050600a546101208601359081906001600160a01b0384811691161461238857602454600a5460405163325f3df760e11b81526001600160a01b03928316926364be7bee92612344928892909116906101208d013590600401614439565b602060405180830381865afa158015612361573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123859190614800565b90505b6123c2565b6123bc61239d6020890189613f6d565b6123af6101208a016101008b01613f6d565b89610120013589896130b6565b90508091505b93509350935093565b81516020908101516000908152600f909152604081205460ff166124025760405163981a2a2b60e01b815260040160405180910390fd5b6012548360800151108061241b57506013548360800151115b1561243957604051633575fcab60e01b815260040160405180910390fd5b60105461244690426144fd565b83604001516001600160401b0316101561247357604051632efadfdd60e11b815260040160405180910390fd5b60115461248090426144fd565b83604001516001600160401b031611156124ad57604051635c644df360e11b815260040160405180910390fd5b60008061250b856000015160200151866000015160e0015187608001518860400151896000015161016001518a602001516124e95760006133da565b60a08b01516001600160a01b03166000908152602a60205260409020546133da565b91509150846020015115612580576000670de0b6b3a764000083600c54670de0b6b3a764000061253b91906144fd565b61254591906144fd565b87606001516125549190614819565b61255e9190614838565b86515160a088015191925061257e916001600160a01b031690308461290d565b505b600b54600090612598906001600160a01b031661381d565b905060008290506000876020015180156125c55750600a5460a08901516001600160a01b03908116911614155b905080156126365760a08801516001600160a01b03166000908152602a60205260409020546060890151670de0b6b3a76400009190612605906002614819565b61260f9190614819565b6126199190614838565b6060890151612629906002614819565b61263391906144fd565b91505b826001600160a01b0316639d1e0f08604051806101a00160405280306001600160a01b031681526020018b60000151600001516001600160a01b031681526020018b600001516020015181526020018b604001516001600160401b031681526020018b600001516080015160070b81526020018b6000015160a001516001600160401b031681526020018b6000015160c0015160018111156126da576126da6147d7565b81526020018b6000015160e0015160018111156126f9576126f96147d7565b81526020018b60a001516001600160a01b031681526020018b606001518152602001600c548152602001888152602001858152506040518263ffffffff1660e01b81526004016127499190614885565b600060405180830381600087803b15801561276357600080fd5b505af1158015612777573d6000803e3d6000fd5b50505050801561279f5760a088015161279a906001600160a01b03168484612015565b6127b6565b600a546127b6906001600160a01b03168484612015565b875180516101409091015160608a015160a08b01516127d8939291908b6138ba565b506127e4600684613b1a565b8751516001600160a01b031660009081526019602052604090206128089084613b1a565b6001600160a01b0383166000908152602080805260408083208054600160ff199182168117909255602584529382902080549094161790925589518051918101518b840151608083015160e09093015160608e015195517f4fb5dd0be05638074eabb1b37a9bdf9ab8cbad8d83c7bce9298aca16de5b79c396612895968b96909594939092909190614974565b60405180910390a18751805160208201516040808c015160808086015160e090960151908e0151600c5493517f51f385a862a654703b4b7a2e647518a58930354129b8364d5dbe945752df3646976128f9978c979096909594919391928f906149ca565b60405180910390a150909695505050505050565b61292e846323b872dd60e01b85858560405160240161203493929190614439565b50505050565b604051631f67c49160e01b8152600782900b600482015282906001600160a01b03821690631f67c49190602401600060405180830381600087803b15801561297b57600080fd5b505af115801561298f573d6000803e3d6000fd5b505050506129a7836006613b6c90919063ffffffff16565b6129b2600884613b1a565b6000816001600160a01b0316634f8632ba6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156129f2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a1691906144b1565b6001600160a01b0381166000908152601960205260409020909150612a3b9085612185565b15612a62576001600160a01b0381166000908152601960205260409020612a629085613b6c565b6001600160a01b0381166000908152601a60205260409020612a849085613b1a565b6000846001600160a01b03166338d52e0f6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612ac4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612ae89190614800565b90506000856001600160a01b031663d8dfeb456040518163ffffffff1660e01b8152600401602060405180830381865afa158015612b2a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612b4e91906144b1565b600a549091506000906001600160a01b0380841691161480612b7757506001600160a01b038216155b612c6057602454600a5460408051630fe645d960e11b815290516001600160a01b03938416936364be7bee93879390821692918d1691631fcc8bb2916004808201926020929091908290030181865afa158015612bd8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612bfc9190614800565b6040518463ffffffff1660e01b8152600401612c1a93929190614439565b602060405180830381865afa158015612c37573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612c5b9190614800565b612cc2565b866001600160a01b0316631fcc8bb26040518163ffffffff1660e01b8152600401602060405180830381865afa158015612c9e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612cc29190614800565b90506000876001600160a01b031663645539ed6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612d04573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612d289190614a33565b6000858152601e60205260408120919250839190836001811115612d4e57612d4e6147d7565b6001811115612d5f57612d5f6147d7565b8152602001908152602001600020541115612dcf576000848152601e602052604081208391836001811115612d9657612d966147d7565b6001811115612da757612da76147d7565b81526020019081526020016000206000828254612dc491906147ed565b90915550612e139050565b6000848152601e6020526040812081836001811115612df057612df06147d7565b6001811115612e0157612e016147d7565b81526020810191909152604001600020555b856001600160a01b0316633a2c1e556040518163ffffffff1660e01b8152600401602060405180830381865afa158015612e51573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612e759190614494565b612edd57612e84826002614819565b6000858152601560205260409020541115612ecd57612ea4826002614819565b60008581526015602052604081208054909190612ec29084906147ed565b90915550612edd9050565b6000848152601560205260408120555b7f738ac9ca76b7fd50246d5acdc827b2852e656ed2c287d6538e57b046f0ecf64b88876001600160a01b031663653721476040518163ffffffff1660e01b8152600401602060405180830381865afa158015612f3d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612f619190614a33565b886001600160a01b0316633a2c1e556040518163ffffffff1660e01b8152600401602060405180830381865afa158015612f9f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612fc39190614494565b604051612fd293929190614a50565b60405180910390a15050505050505050565b6000613039826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316613cc59092919063ffffffff16565b80519091501561122557808060200190518101906130579190614494565b6112255760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610dde565b601c54600090600160a01b900460ff166130e35760405163355da01160e11b815260040160405180910390fd5b600a546040516370a0823160e01b81526000916001600160a01b0316906370a082319061311490309060040161413a565b602060405180830381865afa158015613131573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906131559190614800565b60608401519091506131726001600160a01b03881689308961290d565b60405163095ea7b360e01b81526001600160a01b0388169063095ea7b3906131a09084908a906004016144ce565b6020604051808303816000875af11580156131bf573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906131e39190614494565b506040516322ceb11360e21b81526000906001600160a01b03831690638b3ac44c90613215908b908b906004016144ce565b6020604051808303816000875af1158015613234573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906132589190614800565b6024549091506000906001600160a01b031663336ef50d613282426001600160401b038b166147ed565b60226023600d546040518563ffffffff1660e01b81526004016132a89493929190614abf565b602060405180830381865afa1580156132c5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906132e99190614800565b905080600c54670de0b6b3a764000061330291906144fd565b61330c91906144fd565b61331e670de0b6b3a764000084614819565b6133289190614838565b600a546040516370a0823160e01b815291965060009186916001600160a01b0316906370a082319061335e90309060040161413a565b602060405180830381865afa15801561337b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061339f9190614800565b6133a991906147ed565b9050858110156133cc57604051633c923d8b60e21b815260040160405180910390fd5b505050505095945050505050565b60008060006133e98989613cd4565b9050602854856133f991906144fd565b811115613419576040516306c57a0b60e11b815260040160405180910390fd5b60008089600181111561342e5761342e6147d7565b1461343a57600061343d565b60015b90506000821561344e576000613464565b600261345a8c84613cd4565b6134649190614838565b60008c8152601e602052604081209192508a919084600181111561348a5761348a6147d7565b600181111561349b5761349b6147d7565b815260200190815260200160002054111561350b5760008b8152601e602052604081208a918460018111156134d2576134d26147d7565b60018111156134e3576134e36147d7565b8152602001908152602001600020600082825461350091906147ed565b9091555061369c9050565b60008b8152601e602052604081209083600181111561352c5761352c6147d7565b600181111561353d5761353d6147d7565b8152602001908152602001600020548961355791906147ed565b60008c8152601e60205260408120908c6001811115613578576135786147d7565b6001811115613589576135896147d7565b815260200190815260200160002060008282546135a691906144fd565b909155505060008b8152601e60205260408120818460018111156135cc576135cc6147d7565b60018111156135dd576135dd6147d7565b815260200190815260200160002081905550601d60008c815260200190815260200160002060008b6001811115613616576136166147d7565b6001811115613627576136276147d7565b815260200190815260200160002054601e60008d815260200190815260200160002060008c600181111561365d5761365d6147d7565b600181111561366e5761366e6147d7565b815260200190815260200160002054111561369c576040516338f8bc2360e01b815260040160405180910390fd5b602454819084906001600160a01b031663336ef50d6136c4426001600160401b038e166147ed565b60226023600d546040518563ffffffff1660e01b81526004016136ea9493929190614abf565b602060405180830381865afa158015613707573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061372b9190614800565b61373591906144fd565b61373f91906147ed565b9450670de0b6b3a7640000866137568b6002614819565b6137609190614819565b61376a9190614838565b6137758a6002614819565b61377f91906144fd565b9350670de0b6b3a764000061379486826144fd565b61379e908b614819565b6137a89190614838565b6137b290856147ed565b60008c815260156020526040812080549091906137d09084906144fd565b909155505060008b815260146020908152604080832054601590925290912054111561380f57604051635562fb0760e11b815260040160405180910390fd5b505050965096945050505050565b6000604051733d602d80600a3d3981f3363d3d373d3d3d363d7360601b81528260601b60148201526e5af43d82803e903d91602b57fd5bf360881b60288201526037816000f09150506001600160a01b0381166138b55760405162461bcd60e51b8152602060048201526016602482015275115490cc4c4d8dce8818dc99585d194819985a5b195960521b6044820152606401610dde565b919050565b60208101516000906001600160a01b03811615613acb5760006001600160a01b0387161561394a5760405163bbddaca360e01b81526001600160a01b0383169063bbddaca390613910908a908c9060040161445d565b600060405180830381600087803b15801561392a57600080fd5b505af115801561393e573d6000803e3d6000fd5b505050508690506139ba565b604051639ca423b360e01b81526001600160a01b03831690639ca423b390613976908b9060040161413a565b602060405180830381865afa158015613993573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906139b791906144b1565b90505b6001600160a01b03811615613ac95760405163c7d1f5f160e01b81526000906001600160a01b0384169063c7d1f5f1906139f890859060040161413a565b602060405180830381865afa158015613a15573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613a399190614800565b90508015613ac757670de0b6b3a7640000613a548289614819565b613a5e9190614838565b9350613a746001600160a01b0387168386612015565b604080516001600160a01b0380851682528b166020820152908101859052606081018890527f8fa68a6a8e2fc9ff758a6e64afba8bc2f66fb082999a2c5225c8c49633faded49060800160405180910390a15b505b505b613b10836000015183670de0b6b3a7640000600c5489613aeb9190614819565b613af59190614838565b613aff91906147ed565b6001600160a01b0387169190612015565b5095945050505050565b613b248282612185565b6117f35781546001600160a01b038216600081815260018086016020908152604083208590559084018655858252902090910180546001600160a01b03191690911790555050565b613b768282612185565b613bb85760405162461bcd60e51b815260206004820152601360248201527222b632b6b2b73a103737ba1034b71039b2ba1760691b6044820152606401610dde565b6001600160a01b0381166000908152600180840160205260408220548454909291613be2916147ed565b9050808214613c6e576000846000018281548110613c0257613c0261473c565b60009182526020909120015485546001600160a01b0390911691508190869085908110613c3157613c3161473c565b600091825260208083209190910180546001600160a01b0319166001600160a01b0394851617905592909116815260018601909152604090208290555b8354849080613c7f57613c7f614b05565b60008281526020808220830160001990810180546001600160a01b03191690559092019092556001600160a01b0394909416815260019490940190925250506040812055565b6060610d868484600085613d9c565b6027546000838152601d602052604081209091670de0b6b3a76400009183856001811115613d0457613d046147d7565b6001811115613d1557613d156147d7565b815260200190815260200160002054670de0b6b3a7640000601e60008881526020019081526020016000206000876001811115613d5457613d546147d7565b6001811115613d6557613d656147d7565b815260200190815260200160002054613d7e9190614819565b613d889190614838565b613d929190614819565b610d899190614838565b606082471015613dfd5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401610dde565b843b613e4b5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610dde565b600080866001600160a01b03168587604051613e679190614b3f565b60006040518083038185875af1925050503d8060008114613ea4576040519150601f19603f3d011682016040523d82523d6000602084013e613ea9565b606091505b5091509150613eb9828286613ec4565b979650505050505050565b60608315613ed3575081610d89565b825115613ee35782518084602001fd5b8160405162461bcd60e51b8152600401610dde9190614b5b565b6040518060a001604052806005906020820280368337509192915050565b508054600082559060005260206000209081019061106891905b80821115613f495760008155600101613f35565b5090565b6001600160a01b038116811461106857600080fd5b80356138b581613f4d565b600060208284031215613f7f57600080fd5b8135610d8981613f4d565b600080600060608486031215613f9f57600080fd5b8335613faa81613f4d565b92506020840135613fba81613f4d565b929592945050506040919091013590565b60a08101818360005b6005811015613ff3578151835260209283019290910190600101613fd4565b50505092915050565b60008060006060848603121561401157600080fd5b505081359360208301359350604090920135919050565b6002811061106857600080fd5b80356138b581614028565b6000806040838503121561405357600080fd5b82359150602083013561406581614028565b809150509250929050565b60008060006060848603121561408557600080fd5b8335925060208401359150604084013561409e81613f4d565b809150509250925092565b6020808252825182820181905260009190848201906040850190845b818110156140ea5783516001600160a01b0316835292840192918401916001016140c5565b50909695505050505050565b801515811461106857600080fd5b60006020828403121561411657600080fd5b8135610d89816140f6565b60006020828403121561413357600080fd5b5035919050565b6001600160a01b0391909116815260200190565b6001600160401b038116811461106857600080fd5b80356138b58161414e565b60008060008060008060c0878903121561418757600080fd5b8635955060208701359450604087013593506060870135925060808701356141ae8161414e565b915060a08701356141be8161414e565b809150509295509295509295565b600080604083850312156141df57600080fd5b82356141ea81613f4d565b9150602083013561406581613f4d565b60008060006060848603121561420f57600080fd5b833561421a81613f4d565b9250602084013561422a81613f4d565b9150604084013561409e81613f4d565b6000610180828403121561173557600080fd5b6000806040838503121561426057600080fd5b823561426b81613f4d565b946020939093013593505050565b6000806040838503121561428c57600080fd5b823591506020830135614065816140f6565b600080604083850312156142b157600080fd5b50508035926020909101359150565b600080600080608085870312156142d657600080fd5b84356142e181613f4d565b935060208501356142f1816140f6565b93969395505050506040820135916060013590565b8035600781900b81146138b557600080fd5b6000806040838503121561432b57600080fd5b823561433681613f4d565b915061434460208401614306565b90509250929050565b60008083601f84011261435f57600080fd5b5081356001600160401b0381111561437657600080fd5b6020830191508360208260051b850101111561439157600080fd5b9250929050565b6000806000806000606086880312156143b057600080fd5b85356001600160401b03808211156143c757600080fd5b6143d389838a0161434d565b909750955060208801359150808211156143ec57600080fd5b506143f98882890161434d565b96999598509660400135949350505050565b6000806040838503121561441e57600080fd5b823561442981613f4d565b91506020830135614065816140f6565b6001600160a01b039384168152919092166020820152604081019190915260600190565b6001600160a01b0392831681529116602082015260400190565b60006020828403121561448957600080fd5b8151610d898161414e565b6000602082840312156144a657600080fd5b8151610d89816140f6565b6000602082840312156144c357600080fd5b8151610d8981613f4d565b6001600160a01b03929092168252602082015260400190565b634e487b7160e01b600052601160045260246000fd5b80820180821115610fa057610fa06144e7565b634e487b7160e01b600052604160045260246000fd5b60405161018081016001600160401b038111828210171561455757634e487b7160e01b600052604160045260246000fd5b60405290565b600060c0828403121561456f57600080fd5b60405160c081018181106001600160401b038211171561459f57634e487b7160e01b600052604160045260246000fd5b60405282516145ad81613f4d565b815260208301516145bd81613f4d565b602082015260408301516145d081613f4d565b604082015260608301516145e381613f4d565b606082015260808301516145f681613f4d565b608082015260a083015161460981613f4d565b60a08201529392505050565b60006020828403121561462757600080fd5b8135610d898161414e565b6000610180828403121561464557600080fd5b61464d614526565b61465683613f62565b81526020830135602082015261466e60408401614163565b604082015261467f60608401614163565b606082015261469060808401614306565b60808201526146a160a08401614163565b60a08201526146b260c08401614035565b60c08201526146c360e08401614035565b60e08201526101006146d6818501613f62565b9082015261012083810135908201526101406146f3818501613f62565b90820152610160928301359281019290925250919050565b60208082526017908201527629b832b2b226b0b935b2ba39a0a6a6a932b9b7b63b32b960491b604082015260600190565b634e487b7160e01b600052603260045260246000fd5b600060018201614764576147646144e7565b5060010190565b81835260006001600160fb1b0383111561478457600080fd5b8260051b80836020870137939093016020019392505050565b6060815260006147b160608301878961476b565b82810360208401526147c481868861476b565b9150508260408301529695505050505050565b634e487b7160e01b600052602160045260246000fd5b81810381811115610fa057610fa06144e7565b60006020828403121561481257600080fd5b5051919050565b6000816000190483118215151615614833576148336144e7565b500290565b60008261485557634e487b7160e01b600052601260045260246000fd5b500490565b6002811061106857634e487b7160e01b600052602160045260246000fd5b6148818161485a565b9052565b81516001600160a01b031681526101a0810160208301516148b160208401826001600160a01b03169052565b506040830151604083015260608301516148d660608401826001600160401b03169052565b5060808301516148eb608084018260070b9052565b5060a083015161490660a08401826001600160401b03169052565b5060c083015161491960c0840182614878565b5060e083015161492c60e0840182614878565b50610100838101516001600160a01b03169083015261012080840151908301526101408084015190830152610160808401519083015261018092830151929091019190915290565b6001600160a01b03888116825287166020820152604081018690526001600160401b0385166060820152600784900b608082015260e081016149b58461485a565b60a082019390935260c0015295945050505050565b6001600160a01b038a8116825289166020820152604081018890526001600160401b0387166060820152600786900b60808201526101208101614a0c8661485a565b8560a08301528460c08301528360e0830152826101008301529a9950505050505050505050565b600060208284031215614a4557600080fd5b8151610d8981614028565b6001600160a01b038416815260608101614a698461485a565b8360208301528215156040830152949350505050565b6000815480845260208085019450836000528060002060005b83811015614ab457815487529582019560019182019101614a98565b509495945050505050565b6001600160401b0385168152608060208201526000614ae16080830186614a7f565b8281036040840152614af38186614a7f565b91505082606083015295945050505050565b634e487b7160e01b600052603160045260246000fd5b60005b83811015614b36578181015183820152602001614b1e565b50506000910152565b60008251614b51818460208701614b1b565b9190910192915050565b6020815260008251806020840152614b7a816040850160208701614b1b565b601f01601f1916919091016040019291505056feb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159ca2646970667358221220a0a559e2db0ef8addceaac9eb939d276774809e9c5205faa4db69252a4dc193264736f6c63430008100033
Deployed Bytecode
0x6080604052600436106103315760003560e01c8063704ce43e116101a7578063bc93233f116100ed578063e396ed2611610090578063e396ed2614610b2f578063e60a4d2514610b5f578063e73efc9b14610b8c578063e76fbb0214610bac578063e915586614610bcc578063ebc7977214610be2578063ef469ba214610bf7578063fd6e9b9714610c1757600080fd5b8063bc93233f14610a07578063bd47a9b814610a27578063c3b83f5f14610a54578063c453180214610a74578063ce87e2ee14610aa1578063cf898ca914610ac1578063d69fb66814610ae1578063e11f951d14610af757600080fd5b8063980af6a711610155578063980af6a7146108d7578063999045a0146108f757806399c18e7e146109175780639fc4270314610938578063a201b30714610958578063a2f6532114610997578063b0308e07146109c7578063b711d407146109e757600080fd5b8063704ce43e1461081057806379ba5097146108265780637de926d11461083b57806389c6318d1461085b5780638da5cb5b1461087b57806391b4ded9146108a15780639324cac7146108b757600080fd5b80633ab76e9f116102775780635403f80f1161021a5780635403f80f146107205780635631bf8a1461073657806357dfa0ff146107565780635c975abb1461077657806368b9f66b146107905780636bfffb12146107b05780636ce6c3ca146107d05780636dcf6def146107f057600080fd5b80633ab76e9f146106035780633b46bfc9146106305780633c1ae421146106505780633e7ad1de1461067d578063485cc9551461069357806348dde564146106b35780634eb7c43b146106e057806353a47bb71461070057600080fd5b806312039b6d116102df57806312039b6d1461047c57806312aa3833146104a957806313af4035146104bf57806314527f3a146104df5780631627540c146104ff57806316c38b3c1461051f578063289cc19f1461053f5780632b03da3c1461055557600080fd5b806301bea6361461033d57806301f4747114610381578063023fb259146103a357806302da6244146103d057806305bfdfd4146103f057806306c933d81461043657806307b53bb41461046657600080fd5b3661033857005b600080fd5b34801561034957600080fd5b5061036c610358366004613f6d565b602080526000908152604090205460ff1681565b60405190151581526020015b60405180910390f35b34801561038d57600080fd5b506103a161039c366004613f8a565b610c47565b005b3480156103af57600080fd5b506103c36103be366004613f6d565b610ca3565b6040516103789190613fcb565b3480156103dc57600080fd5b506103a16103eb366004613ffc565b610cfe565b3480156103fc57600080fd5b5061042861040b366004614040565b601e60209081526000928352604080842090915290825290205481565b604051908152602001610378565b34801561044257600080fd5b5061036c610451366004613f6d565b601b6020526000908152604090205460ff1681565b34801561047257600080fd5b5061042860135481565b34801561048857600080fd5b5061049c610497366004614070565b610d60565b60405161037891906140a9565b3480156104b557600080fd5b5061042860125481565b3480156104cb57600080fd5b506103a16104da366004613f6d565b610d90565b3480156104eb57600080fd5b5061036c6104fa366004613f6d565b610eb3565b34801561050b57600080fd5b506103a161051a366004613f6d565b610fa6565b34801561052b57600080fd5b506103a161053a366004614104565b610ff9565b34801561054b57600080fd5b5061042860285481565b34801561056157600080fd5b506105d6610570366004614121565b60408051606080820183526000808352602080840182905292840181905283519182018452808252818301818152828501828152958252600f909352929092205460ff1615158252600c549052601754600160a01b90046001600160401b031690915290565b6040805182511515815260208084015190820152918101516001600160401b031690820152606001610378565b34801561060f57600080fd5b50602654610623906001600160a01b031681565b604051610378919061413a565b34801561063c57600080fd5b506103a161064b36600461416e565b61106b565b34801561065c57600080fd5b5061042861066b366004613f6d565b602a6020526000908152604090205481565b34801561068957600080fd5b5061042860105481565b34801561069f57600080fd5b506103a16106ae3660046141cc565b611127565b3480156106bf57600080fd5b506104286106ce366004614121565b602b6020526000908152604090205481565b3480156106ec57600080fd5b506104286106fb366004614121565b61122a565b34801561070c57600080fd5b50600154610623906001600160a01b031681565b34801561072c57600080fd5b5061042860115481565b34801561074257600080fd5b50610428610751366004614121565b61124b565b34801561076257600080fd5b50602454610623906001600160a01b031681565b34801561078257600080fd5b5060035461036c9060ff1681565b34801561079c57600080fd5b506103a16107ab366004614104565b61125b565b3480156107bc57600080fd5b506103a16107cb3660046141fa565b6113bf565b3480156107dc57600080fd5b506106236107eb36600461423a565b611443565b3480156107fc57600080fd5b506103a161080b36600461424d565b61173b565b34801561081c57600080fd5b50610428600d5481565b34801561083257600080fd5b506103a16117f7565b34801561084757600080fd5b506103a1610856366004614279565b6118e2565b34801561086757600080fd5b5061049c61087636600461429e565b61193c565b34801561088757600080fd5b50600054610623906201000090046001600160a01b031681565b3480156108ad57600080fd5b5061042860025481565b3480156108c357600080fd5b50600a54610623906001600160a01b031681565b3480156108e357600080fd5b506103a16108f23660046142c0565b61194a565b34801561090357600080fd5b506103a1610912366004613f6d565b611a52565b34801561092357600080fd5b50601c5461036c90600160a01b900460ff1681565b34801561094457600080fd5b5061049c610953366004614070565b611aa5565b34801561096457600080fd5b5060175461097f90600160a01b90046001600160401b031681565b6040516001600160401b039091168152602001610378565b3480156109a357600080fd5b5061036c6109b2366004613f6d565b60296020526000908152604090205460ff1681565b3480156109d357600080fd5b506103a16109e2366004614318565b611acb565b3480156109f357600080fd5b506103a1610a02366004614398565b611bba565b348015610a1357600080fd5b506103a1610a2236600461440b565b611cce565b348015610a3357600080fd5b50610428610a42366004614121565b60166020526000908152604090205481565b348015610a6057600080fd5b506103a1610a6f366004613f6d565b611d59565b348015610a8057600080fd5b50610428610a8f366004614121565b60146020526000908152604090205481565b348015610aad57600080fd5b50600b54610623906001600160a01b031681565b348015610acd57600080fd5b50601f5461097f906001600160401b031681565b348015610aed57600080fd5b50610428600c5481565b348015610b0357600080fd5b50610428610b12366004614040565b601d60209081526000928352604080842090915290825290205481565b348015610b3b57600080fd5b5061036c610b4a366004614121565b600f6020526000908152604090205460ff1681565b348015610b6b57600080fd5b50610428610b7a366004614121565b60156020526000908152604090205481565b348015610b9857600080fd5b5061049c610ba736600461429e565b611e5c565b348015610bb857600080fd5b506103a1610bc7366004613ffc565b611e6a565b348015610bd857600080fd5b5061042860275481565b348015610bee57600080fd5b506103a1611ebf565b348015610c0357600080fd5b506103a1610c12366004613ffc565b611f1d565b348015610c2357600080fd5b5061036c610c32366004613f6d565b60256020526000908152604090205460ff1681565b610c4f611f9b565b610c636001600160a01b0384168383612015565b7f3dfef6507ded35b9ec518bb3532736bd85a598bdcb440fdd2289ce92a771e797838383604051610c9693929190614439565b60405180910390a1505050565b610cab613efd565b506040805160a08101825260065481526008546020808301919091526001600160a01b039093166000818152601985528381205483850152908152601a9093529120546060820152602354608082015290565b610d06611f9b565b6000838152601660209081526040808320859055602b82529182902083905581518581529081018490529081018290527fa5d0eb0e57599c22b55099481fc764a3e5bec63ea97f8c409c31f0883678a00f90606001610c96565b6001600160a01b0381166000908152601960205260409020606090610d8690858561206b565b90505b9392505050565b6001600160a01b038116610de75760405162461bcd60e51b815260206004820152601960248201527804f776e657220616464726573732063616e6e6f74206265203603c1b60448201526064015b60405180910390fd5b600154600160a01b900460ff1615610e535760405162461bcd60e51b815260206004820152602960248201527f416c726561647920696e697469616c697a65642c20757365206e6f6d696e617460448201526832a732bba7bbb732b960b91b6064820152608401610dde565b6001805460ff60a01b1916600160a01b179055600080546001600160a01b038316620100000262010000600160b01b0319909116178155604051600080516020614b8f83398151915291610ea891849061445d565b60405180910390a150565b6000610ec0600683612185565b8015610f35575042826001600160a01b03166351d8044f6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610f06573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f2a9190614477565b6001600160401b0316105b8015610fa05750816001600160a01b0316633f6fa6556040518163ffffffff1660e01b8152600401602060405180830381865afa158015610f7a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f9e9190614494565b155b92915050565b610fae611f9b565b600180546001600160a01b0319166001600160a01b0383161790556040517f906a1c6bd7e3091ea86693dd029a831c19049ce77f1dce2ce0bab1cacbabce2290610ea890839061413a565b611001611f9b565b60035460ff16151581151514611068576003805460ff191682151590811790915560ff161561102f57426002555b60035460405160ff909116151581527f8fb6c181ee25a520cf3dd6565006ef91229fcfe5a989566c2a3b8c115570cec590602001610ea8565b50565b611073611f9b565b60128690556013859055601084905560118390556017805467ffffffffffffffff60a01b1916600160a01b6001600160401b0385811691820292909217909255601f805467ffffffffffffffff19169184169182179055604080518981526020810189905290810187905260608101869052608081019290925260a08201527fcb4727945d0c9bf77ea3b48c6c630e5b0e5016c1fe67c9508feafe8fc265cdba9060c00160405180910390a1505050505050565b600054610100900460ff166111425760005460ff1615611146565b303b155b6111a95760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401610dde565b600054610100900460ff161580156111cb576000805461ffff19166101011790555b6111d483610d90565b6111dc611ebf565b600a80546001600160a01b0319166001600160a01b0384169081179091556000908152602960205260409020805460ff191660011790558015611225576000805461ff00191690555b505050565b6023818154811061123a57600080fd5b600091825260209091200154905081565b6022818154811061123a57600080fd5b611263611f9b565b60265460408051639a618c0f60e01b815290516000926001600160a01b031691639a618c0f9160048083019260209291908290030181865afa1580156112ad573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112d191906144b1565b90506001600160a01b0381161561136657600a546001600160a01b031663095ea7b38284611300576000611304565b6000195b6040518363ffffffff1660e01b81526004016113219291906144ce565b6020604051808303816000875af1158015611340573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113649190614494565b505b601c8054831515600160a01b0260ff60a01b199091161790556040517fb76eab56cfa3088dda43a9a4b3ea4bb7685b8007428d4a65248fdaa763d339f8906113b390841515815260200190565b60405180910390a15050565b6113c7611f9b565b600b80546001600160a01b038581166001600160a01b0319928316811790935560248054868316908416811790915560268054928616929093168217909255604080519384526020840192909252908201527fbf934b81354c7e34eda71aa08a74419a5682a0737282cc3f448b353a1893c41f90606001610c96565b600060016004600082825461145891906144fd565b909155505060045460035460ff16156114d95760405162461bcd60e51b815260206004820152603c60248201527f5468697320616374696f6e2063616e6e6f7420626520706572666f726d65642060448201527f7768696c652074686520636f6e747261637420697320706175736564000000006064820152608401610dde565b60265460405163bf40fac160e01b815260206004820152601660248201527529b832b2b226b0b935b2ba39a0a6a6a1b932b0ba37b960511b60448201526000916001600160a01b03169063bf40fac190606401602060405180830381865afa158015611549573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061156d91906144b1565b9050336001600160a01b038216146115985760405163027cbd1b60e61b815260040160405180910390fd5b602654604080516351cfd60960e11b815290516000926001600160a01b03169163a39fac129160048083019260c09291908290030181865afa1580156115e2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611606919061455d565b9050600061161a6060870160408801614615565b6001600160401b03161561163d576116386060870160408801614615565b611660565b61164d6080870160608801614615565b611660906001600160401b0316426144fd565b90506000806000806116738a86886121fb565b935093509350935060006040518060c001604052808c8036038101906116999190614632565b81526020018615158152602001876001600160401b03168152602001848152602001838152602001856001600160a01b031681525090506116da81886123cb565b9950505050505050505060045481146117355760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610dde565b50919050565b60265460405163bf40fac160e01b81526001600160a01b039091169063bf40fac1906117699060040161470b565b602060405180830381865afa158015611786573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117aa91906144b1565b6001600160a01b0316336001600160a01b0316146117db57604051635bc2da4960e01b815260040160405180910390fd5b600a546117f3906001600160a01b031683338461290d565b5050565b6001546001600160a01b0316331461186f5760405162461bcd60e51b815260206004820152603560248201527f596f75206d757374206265206e6f6d696e61746564206265666f726520796f7560448201527402063616e20616363657074206f776e65727368697605c1b6064820152608401610dde565b600054600154604051600080516020614b8f833981519152926118a6926001600160a01b036201000090920482169291169061445d565b60405180910390a1600180546000805462010000600160b01b0319166001600160a01b03831662010000021790556001600160a01b0319169055565b6118ea611f9b565b6000828152600f6020908152604091829020805460ff19168415159081179091558251858152918201527f6af8d0ea20290a2d8dcbb43a77926d5993cd89bac2c6a72cd7813c4eacc2124b91016113b3565b6060610d896008848461206b565b611952611f9b565b67016345785d8a000082111561197b57604051630f49511f60e21b815260040160405180910390fd5b6001600160a01b038481166000908152602a60209081526040808320869055602990915290819020805460ff19168615151790556024549051637f36de5360e11b815291169063fe6dbca6906119d790879085906004016144ce565b600060405180830381600087803b1580156119f157600080fd5b505af1158015611a05573d6000803e3d6000fd5b50505050836001600160a01b03167f17e58c675f250b8ef0675335e238a5dd06ca310d6241de740796696bf61026d983604051611a4491815260200190565b60405180910390a250505050565b611a5a611f9b565b600a80546001600160a01b0319166001600160a01b0383161790556040517fba10f1023c43b7797db2ff58a62990dbbb24aa29adb28dae7424301e38d99ed990610ea890839061413a565b6001600160a01b0381166000908152601a60205260409020606090610d8690858561206b565b60265460405163bf40fac160e01b81526001600160a01b039091169063bf40fac190611af99060040161470b565b602060405180830381865afa158015611b16573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b3a91906144b1565b6001600160a01b0316336001600160a01b031614158015611b6c57506000546201000090046001600160a01b03163314155b15611b8a57604051635bc2da4960e01b815260040160405180910390fd5b611b9382610eb3565b611bb0576040516309f4985b60e21b815260040160405180910390fd5b6117f38282612934565b611bc2611f9b565b838214611be2576040516373f8993760e11b815260040160405180910390fd5b611bee60226000613f1b565b611bfa60236000613f1b565b60005b84811015611c81576022868683818110611c1957611c1961473c565b835460018101855560009485526020948590209190940292909201359190920155506023848483818110611c4f57611c4f61473c565b83546001810185556000948552602094859020919094029290920135919092015550611c7a81614752565b9050611bfd565b50600d8190556040517f97b8e3f33b113d945b11628418dc7b155d05943a8a517a937a9d88f4eda67a6b90611cbf908790879087908790879061479d565b60405180910390a15050505050565b611cd6611f9b565b6001600160a01b038216611cfd57604051634d553d1960e01b815260040160405180910390fd5b6001600160a01b0382166000818152601b6020908152604091829020805460ff19168515159081179091558251938452908301527f58d7a3ccc34541e162fcfc87b84be7b78c34d1e1e7f15de6e4dd67d0fe70aecd91016113b3565b611d61611f9b565b6001600160a01b038116611da95760405162461bcd60e51b815260206004820152600f60248201526e496e76616c6964206164647265737360881b6044820152606401610dde565b600154600160a81b900460ff1615611df95760405162461bcd60e51b8152602060048201526013602482015272105b1c9958591e481d1c985b9cd9995c9c9959606a1b6044820152606401610dde565b600080546001600160a01b038084166201000090810262010000600160b01b031990931692909217928390556001805460ff60a81b1916600160a81b179055604051600080516020614b8f83398151915293610ea893900490911690849061445d565b6060610d896006848461206b565b611e72611f9b565b600c8390556027829055602881905560408051848152602081018490529081018290527faa4fb0e426c89ca5b40184bc99ab0d12c722021c90689decd8f7b901d3f82b3490606001610c96565b60055460ff1615611f085760405162461bcd60e51b8152602060048201526013602482015272105b1c9958591e481a5b9a5d1a585b1a5e9959606a1b6044820152606401610dde565b6005805460ff19166001908117909155600455565b611f25611f9b565b600083815260146020908152604080832085905560158252808320839055601d82528083208380528252808320849055600183529182902083905581518581529081018490529081018290527facbec488a49aaa9d1b3799159ede0349850bc1a73c0e90913ff03dd4354a34a890606001610c96565b6000546201000090046001600160a01b031633146120135760405162461bcd60e51b815260206004820152602f60248201527f4f6e6c792074686520636f6e7472616374206f776e6572206d6179207065726660448201526e37b936903a3434b99030b1ba34b7b760891b6064820152608401610dde565b565b6112258363a9059cbb60e01b84846040516024016120349291906144ce565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152612fe4565b6060600061207983856144fd565b8554909150811115612089575083545b8381116120a6575050604080516000815260208101909152610d89565b60006120b285836147ed565b90506000816001600160401b038111156120ce576120ce614510565b6040519080825280602002602001820160405280156120f7578160200160208202803683370190505b50905060005b8281101561217a578761211088836144fd565b815481106121205761212061473c565b9060005260206000200160009054906101000a90046001600160a01b03168282815181106121505761215061473c565b6001600160a01b03909216602092830291909101909101528061217281614752565b9150506120fd565b509695505050505050565b8154600090810361219857506000610fa0565b6001600160a01b0382166000908152600184016020526040902054801515806121f35750826001600160a01b0316846000016000815481106121dc576121dc61473c565b6000918252602090912001546001600160a01b0316145b949350505050565b60008080806029816122156101208a016101008b01613f6d565b6001600160a01b0316815260208101919091526040016000205460ff16806122575750600061224c61012089016101008a01613f6d565b6001600160a01b0316145b93506029600061226f6101208a016101008b01613f6d565b6001600160a01b0316815260208101919091526040016000205460ff1680156122b3575060006122a761012089016101008a01613f6d565b6001600160a01b031614155b156122d1576122ca61012088016101008901613f6d565b92506122e0565b600a546001600160a01b031692505b831561238d575050600a546101208601359081906001600160a01b0384811691161461238857602454600a5460405163325f3df760e11b81526001600160a01b03928316926364be7bee92612344928892909116906101208d013590600401614439565b602060405180830381865afa158015612361573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123859190614800565b90505b6123c2565b6123bc61239d6020890189613f6d565b6123af6101208a016101008b01613f6d565b89610120013589896130b6565b90508091505b93509350935093565b81516020908101516000908152600f909152604081205460ff166124025760405163981a2a2b60e01b815260040160405180910390fd5b6012548360800151108061241b57506013548360800151115b1561243957604051633575fcab60e01b815260040160405180910390fd5b60105461244690426144fd565b83604001516001600160401b0316101561247357604051632efadfdd60e11b815260040160405180910390fd5b60115461248090426144fd565b83604001516001600160401b031611156124ad57604051635c644df360e11b815260040160405180910390fd5b60008061250b856000015160200151866000015160e0015187608001518860400151896000015161016001518a602001516124e95760006133da565b60a08b01516001600160a01b03166000908152602a60205260409020546133da565b91509150846020015115612580576000670de0b6b3a764000083600c54670de0b6b3a764000061253b91906144fd565b61254591906144fd565b87606001516125549190614819565b61255e9190614838565b86515160a088015191925061257e916001600160a01b031690308461290d565b505b600b54600090612598906001600160a01b031661381d565b905060008290506000876020015180156125c55750600a5460a08901516001600160a01b03908116911614155b905080156126365760a08801516001600160a01b03166000908152602a60205260409020546060890151670de0b6b3a76400009190612605906002614819565b61260f9190614819565b6126199190614838565b6060890151612629906002614819565b61263391906144fd565b91505b826001600160a01b0316639d1e0f08604051806101a00160405280306001600160a01b031681526020018b60000151600001516001600160a01b031681526020018b600001516020015181526020018b604001516001600160401b031681526020018b600001516080015160070b81526020018b6000015160a001516001600160401b031681526020018b6000015160c0015160018111156126da576126da6147d7565b81526020018b6000015160e0015160018111156126f9576126f96147d7565b81526020018b60a001516001600160a01b031681526020018b606001518152602001600c548152602001888152602001858152506040518263ffffffff1660e01b81526004016127499190614885565b600060405180830381600087803b15801561276357600080fd5b505af1158015612777573d6000803e3d6000fd5b50505050801561279f5760a088015161279a906001600160a01b03168484612015565b6127b6565b600a546127b6906001600160a01b03168484612015565b875180516101409091015160608a015160a08b01516127d8939291908b6138ba565b506127e4600684613b1a565b8751516001600160a01b031660009081526019602052604090206128089084613b1a565b6001600160a01b0383166000908152602080805260408083208054600160ff199182168117909255602584529382902080549094161790925589518051918101518b840151608083015160e09093015160608e015195517f4fb5dd0be05638074eabb1b37a9bdf9ab8cbad8d83c7bce9298aca16de5b79c396612895968b96909594939092909190614974565b60405180910390a18751805160208201516040808c015160808086015160e090960151908e0151600c5493517f51f385a862a654703b4b7a2e647518a58930354129b8364d5dbe945752df3646976128f9978c979096909594919391928f906149ca565b60405180910390a150909695505050505050565b61292e846323b872dd60e01b85858560405160240161203493929190614439565b50505050565b604051631f67c49160e01b8152600782900b600482015282906001600160a01b03821690631f67c49190602401600060405180830381600087803b15801561297b57600080fd5b505af115801561298f573d6000803e3d6000fd5b505050506129a7836006613b6c90919063ffffffff16565b6129b2600884613b1a565b6000816001600160a01b0316634f8632ba6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156129f2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a1691906144b1565b6001600160a01b0381166000908152601960205260409020909150612a3b9085612185565b15612a62576001600160a01b0381166000908152601960205260409020612a629085613b6c565b6001600160a01b0381166000908152601a60205260409020612a849085613b1a565b6000846001600160a01b03166338d52e0f6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612ac4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612ae89190614800565b90506000856001600160a01b031663d8dfeb456040518163ffffffff1660e01b8152600401602060405180830381865afa158015612b2a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612b4e91906144b1565b600a549091506000906001600160a01b0380841691161480612b7757506001600160a01b038216155b612c6057602454600a5460408051630fe645d960e11b815290516001600160a01b03938416936364be7bee93879390821692918d1691631fcc8bb2916004808201926020929091908290030181865afa158015612bd8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612bfc9190614800565b6040518463ffffffff1660e01b8152600401612c1a93929190614439565b602060405180830381865afa158015612c37573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612c5b9190614800565b612cc2565b866001600160a01b0316631fcc8bb26040518163ffffffff1660e01b8152600401602060405180830381865afa158015612c9e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612cc29190614800565b90506000876001600160a01b031663645539ed6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612d04573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612d289190614a33565b6000858152601e60205260408120919250839190836001811115612d4e57612d4e6147d7565b6001811115612d5f57612d5f6147d7565b8152602001908152602001600020541115612dcf576000848152601e602052604081208391836001811115612d9657612d966147d7565b6001811115612da757612da76147d7565b81526020019081526020016000206000828254612dc491906147ed565b90915550612e139050565b6000848152601e6020526040812081836001811115612df057612df06147d7565b6001811115612e0157612e016147d7565b81526020810191909152604001600020555b856001600160a01b0316633a2c1e556040518163ffffffff1660e01b8152600401602060405180830381865afa158015612e51573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612e759190614494565b612edd57612e84826002614819565b6000858152601560205260409020541115612ecd57612ea4826002614819565b60008581526015602052604081208054909190612ec29084906147ed565b90915550612edd9050565b6000848152601560205260408120555b7f738ac9ca76b7fd50246d5acdc827b2852e656ed2c287d6538e57b046f0ecf64b88876001600160a01b031663653721476040518163ffffffff1660e01b8152600401602060405180830381865afa158015612f3d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612f619190614a33565b886001600160a01b0316633a2c1e556040518163ffffffff1660e01b8152600401602060405180830381865afa158015612f9f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612fc39190614494565b604051612fd293929190614a50565b60405180910390a15050505050505050565b6000613039826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316613cc59092919063ffffffff16565b80519091501561122557808060200190518101906130579190614494565b6112255760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610dde565b601c54600090600160a01b900460ff166130e35760405163355da01160e11b815260040160405180910390fd5b600a546040516370a0823160e01b81526000916001600160a01b0316906370a082319061311490309060040161413a565b602060405180830381865afa158015613131573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906131559190614800565b60608401519091506131726001600160a01b03881689308961290d565b60405163095ea7b360e01b81526001600160a01b0388169063095ea7b3906131a09084908a906004016144ce565b6020604051808303816000875af11580156131bf573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906131e39190614494565b506040516322ceb11360e21b81526000906001600160a01b03831690638b3ac44c90613215908b908b906004016144ce565b6020604051808303816000875af1158015613234573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906132589190614800565b6024549091506000906001600160a01b031663336ef50d613282426001600160401b038b166147ed565b60226023600d546040518563ffffffff1660e01b81526004016132a89493929190614abf565b602060405180830381865afa1580156132c5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906132e99190614800565b905080600c54670de0b6b3a764000061330291906144fd565b61330c91906144fd565b61331e670de0b6b3a764000084614819565b6133289190614838565b600a546040516370a0823160e01b815291965060009186916001600160a01b0316906370a082319061335e90309060040161413a565b602060405180830381865afa15801561337b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061339f9190614800565b6133a991906147ed565b9050858110156133cc57604051633c923d8b60e21b815260040160405180910390fd5b505050505095945050505050565b60008060006133e98989613cd4565b9050602854856133f991906144fd565b811115613419576040516306c57a0b60e11b815260040160405180910390fd5b60008089600181111561342e5761342e6147d7565b1461343a57600061343d565b60015b90506000821561344e576000613464565b600261345a8c84613cd4565b6134649190614838565b60008c8152601e602052604081209192508a919084600181111561348a5761348a6147d7565b600181111561349b5761349b6147d7565b815260200190815260200160002054111561350b5760008b8152601e602052604081208a918460018111156134d2576134d26147d7565b60018111156134e3576134e36147d7565b8152602001908152602001600020600082825461350091906147ed565b9091555061369c9050565b60008b8152601e602052604081209083600181111561352c5761352c6147d7565b600181111561353d5761353d6147d7565b8152602001908152602001600020548961355791906147ed565b60008c8152601e60205260408120908c6001811115613578576135786147d7565b6001811115613589576135896147d7565b815260200190815260200160002060008282546135a691906144fd565b909155505060008b8152601e60205260408120818460018111156135cc576135cc6147d7565b60018111156135dd576135dd6147d7565b815260200190815260200160002081905550601d60008c815260200190815260200160002060008b6001811115613616576136166147d7565b6001811115613627576136276147d7565b815260200190815260200160002054601e60008d815260200190815260200160002060008c600181111561365d5761365d6147d7565b600181111561366e5761366e6147d7565b815260200190815260200160002054111561369c576040516338f8bc2360e01b815260040160405180910390fd5b602454819084906001600160a01b031663336ef50d6136c4426001600160401b038e166147ed565b60226023600d546040518563ffffffff1660e01b81526004016136ea9493929190614abf565b602060405180830381865afa158015613707573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061372b9190614800565b61373591906144fd565b61373f91906147ed565b9450670de0b6b3a7640000866137568b6002614819565b6137609190614819565b61376a9190614838565b6137758a6002614819565b61377f91906144fd565b9350670de0b6b3a764000061379486826144fd565b61379e908b614819565b6137a89190614838565b6137b290856147ed565b60008c815260156020526040812080549091906137d09084906144fd565b909155505060008b815260146020908152604080832054601590925290912054111561380f57604051635562fb0760e11b815260040160405180910390fd5b505050965096945050505050565b6000604051733d602d80600a3d3981f3363d3d373d3d3d363d7360601b81528260601b60148201526e5af43d82803e903d91602b57fd5bf360881b60288201526037816000f09150506001600160a01b0381166138b55760405162461bcd60e51b8152602060048201526016602482015275115490cc4c4d8dce8818dc99585d194819985a5b195960521b6044820152606401610dde565b919050565b60208101516000906001600160a01b03811615613acb5760006001600160a01b0387161561394a5760405163bbddaca360e01b81526001600160a01b0383169063bbddaca390613910908a908c9060040161445d565b600060405180830381600087803b15801561392a57600080fd5b505af115801561393e573d6000803e3d6000fd5b505050508690506139ba565b604051639ca423b360e01b81526001600160a01b03831690639ca423b390613976908b9060040161413a565b602060405180830381865afa158015613993573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906139b791906144b1565b90505b6001600160a01b03811615613ac95760405163c7d1f5f160e01b81526000906001600160a01b0384169063c7d1f5f1906139f890859060040161413a565b602060405180830381865afa158015613a15573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613a399190614800565b90508015613ac757670de0b6b3a7640000613a548289614819565b613a5e9190614838565b9350613a746001600160a01b0387168386612015565b604080516001600160a01b0380851682528b166020820152908101859052606081018890527f8fa68a6a8e2fc9ff758a6e64afba8bc2f66fb082999a2c5225c8c49633faded49060800160405180910390a15b505b505b613b10836000015183670de0b6b3a7640000600c5489613aeb9190614819565b613af59190614838565b613aff91906147ed565b6001600160a01b0387169190612015565b5095945050505050565b613b248282612185565b6117f35781546001600160a01b038216600081815260018086016020908152604083208590559084018655858252902090910180546001600160a01b03191690911790555050565b613b768282612185565b613bb85760405162461bcd60e51b815260206004820152601360248201527222b632b6b2b73a103737ba1034b71039b2ba1760691b6044820152606401610dde565b6001600160a01b0381166000908152600180840160205260408220548454909291613be2916147ed565b9050808214613c6e576000846000018281548110613c0257613c0261473c565b60009182526020909120015485546001600160a01b0390911691508190869085908110613c3157613c3161473c565b600091825260208083209190910180546001600160a01b0319166001600160a01b0394851617905592909116815260018601909152604090208290555b8354849080613c7f57613c7f614b05565b60008281526020808220830160001990810180546001600160a01b03191690559092019092556001600160a01b0394909416815260019490940190925250506040812055565b6060610d868484600085613d9c565b6027546000838152601d602052604081209091670de0b6b3a76400009183856001811115613d0457613d046147d7565b6001811115613d1557613d156147d7565b815260200190815260200160002054670de0b6b3a7640000601e60008881526020019081526020016000206000876001811115613d5457613d546147d7565b6001811115613d6557613d656147d7565b815260200190815260200160002054613d7e9190614819565b613d889190614838565b613d929190614819565b610d899190614838565b606082471015613dfd5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401610dde565b843b613e4b5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610dde565b600080866001600160a01b03168587604051613e679190614b3f565b60006040518083038185875af1925050503d8060008114613ea4576040519150601f19603f3d011682016040523d82523d6000602084013e613ea9565b606091505b5091509150613eb9828286613ec4565b979650505050505050565b60608315613ed3575081610d89565b825115613ee35782518084602001fd5b8160405162461bcd60e51b8152600401610dde9190614b5b565b6040518060a001604052806005906020820280368337509192915050565b508054600082559060005260206000209081019061106891905b80821115613f495760008155600101613f35565b5090565b6001600160a01b038116811461106857600080fd5b80356138b581613f4d565b600060208284031215613f7f57600080fd5b8135610d8981613f4d565b600080600060608486031215613f9f57600080fd5b8335613faa81613f4d565b92506020840135613fba81613f4d565b929592945050506040919091013590565b60a08101818360005b6005811015613ff3578151835260209283019290910190600101613fd4565b50505092915050565b60008060006060848603121561401157600080fd5b505081359360208301359350604090920135919050565b6002811061106857600080fd5b80356138b581614028565b6000806040838503121561405357600080fd5b82359150602083013561406581614028565b809150509250929050565b60008060006060848603121561408557600080fd5b8335925060208401359150604084013561409e81613f4d565b809150509250925092565b6020808252825182820181905260009190848201906040850190845b818110156140ea5783516001600160a01b0316835292840192918401916001016140c5565b50909695505050505050565b801515811461106857600080fd5b60006020828403121561411657600080fd5b8135610d89816140f6565b60006020828403121561413357600080fd5b5035919050565b6001600160a01b0391909116815260200190565b6001600160401b038116811461106857600080fd5b80356138b58161414e565b60008060008060008060c0878903121561418757600080fd5b8635955060208701359450604087013593506060870135925060808701356141ae8161414e565b915060a08701356141be8161414e565b809150509295509295509295565b600080604083850312156141df57600080fd5b82356141ea81613f4d565b9150602083013561406581613f4d565b60008060006060848603121561420f57600080fd5b833561421a81613f4d565b9250602084013561422a81613f4d565b9150604084013561409e81613f4d565b6000610180828403121561173557600080fd5b6000806040838503121561426057600080fd5b823561426b81613f4d565b946020939093013593505050565b6000806040838503121561428c57600080fd5b823591506020830135614065816140f6565b600080604083850312156142b157600080fd5b50508035926020909101359150565b600080600080608085870312156142d657600080fd5b84356142e181613f4d565b935060208501356142f1816140f6565b93969395505050506040820135916060013590565b8035600781900b81146138b557600080fd5b6000806040838503121561432b57600080fd5b823561433681613f4d565b915061434460208401614306565b90509250929050565b60008083601f84011261435f57600080fd5b5081356001600160401b0381111561437657600080fd5b6020830191508360208260051b850101111561439157600080fd5b9250929050565b6000806000806000606086880312156143b057600080fd5b85356001600160401b03808211156143c757600080fd5b6143d389838a0161434d565b909750955060208801359150808211156143ec57600080fd5b506143f98882890161434d565b96999598509660400135949350505050565b6000806040838503121561441e57600080fd5b823561442981613f4d565b91506020830135614065816140f6565b6001600160a01b039384168152919092166020820152604081019190915260600190565b6001600160a01b0392831681529116602082015260400190565b60006020828403121561448957600080fd5b8151610d898161414e565b6000602082840312156144a657600080fd5b8151610d89816140f6565b6000602082840312156144c357600080fd5b8151610d8981613f4d565b6001600160a01b03929092168252602082015260400190565b634e487b7160e01b600052601160045260246000fd5b80820180821115610fa057610fa06144e7565b634e487b7160e01b600052604160045260246000fd5b60405161018081016001600160401b038111828210171561455757634e487b7160e01b600052604160045260246000fd5b60405290565b600060c0828403121561456f57600080fd5b60405160c081018181106001600160401b038211171561459f57634e487b7160e01b600052604160045260246000fd5b60405282516145ad81613f4d565b815260208301516145bd81613f4d565b602082015260408301516145d081613f4d565b604082015260608301516145e381613f4d565b606082015260808301516145f681613f4d565b608082015260a083015161460981613f4d565b60a08201529392505050565b60006020828403121561462757600080fd5b8135610d898161414e565b6000610180828403121561464557600080fd5b61464d614526565b61465683613f62565b81526020830135602082015261466e60408401614163565b604082015261467f60608401614163565b606082015261469060808401614306565b60808201526146a160a08401614163565b60a08201526146b260c08401614035565b60c08201526146c360e08401614035565b60e08201526101006146d6818501613f62565b9082015261012083810135908201526101406146f3818501613f62565b90820152610160928301359281019290925250919050565b60208082526017908201527629b832b2b226b0b935b2ba39a0a6a6a932b9b7b63b32b960491b604082015260600190565b634e487b7160e01b600052603260045260246000fd5b600060018201614764576147646144e7565b5060010190565b81835260006001600160fb1b0383111561478457600080fd5b8260051b80836020870137939093016020019392505050565b6060815260006147b160608301878961476b565b82810360208401526147c481868861476b565b9150508260408301529695505050505050565b634e487b7160e01b600052602160045260246000fd5b81810381811115610fa057610fa06144e7565b60006020828403121561481257600080fd5b5051919050565b6000816000190483118215151615614833576148336144e7565b500290565b60008261485557634e487b7160e01b600052601260045260246000fd5b500490565b6002811061106857634e487b7160e01b600052602160045260246000fd5b6148818161485a565b9052565b81516001600160a01b031681526101a0810160208301516148b160208401826001600160a01b03169052565b506040830151604083015260608301516148d660608401826001600160401b03169052565b5060808301516148eb608084018260070b9052565b5060a083015161490660a08401826001600160401b03169052565b5060c083015161491960c0840182614878565b5060e083015161492c60e0840182614878565b50610100838101516001600160a01b03169083015261012080840151908301526101408084015190830152610160808401519083015261018092830151929091019190915290565b6001600160a01b03888116825287166020820152604081018690526001600160401b0385166060820152600784900b608082015260e081016149b58461485a565b60a082019390935260c0015295945050505050565b6001600160a01b038a8116825289166020820152604081018890526001600160401b0387166060820152600786900b60808201526101208101614a0c8661485a565b8560a08301528460c08301528360e0830152826101008301529a9950505050505050505050565b600060208284031215614a4557600080fd5b8151610d8981614028565b6001600160a01b038416815260608101614a698461485a565b8360208301528215156040830152949350505050565b6000815480845260208085019450836000528060002060005b83811015614ab457815487529582019560019182019101614a98565b509495945050505050565b6001600160401b0385168152608060208201526000614ae16080830186614a7f565b8281036040840152614af38186614a7f565b91505082606083015295945050505050565b634e487b7160e01b600052603160045260246000fd5b60005b83811015614b36578181015183820152602001614b1e565b50506000910152565b60008251614b51818460208701614b1b565b9190910192915050565b6020815260008251806020840152614b7a816040850160208701614b1b565b601f01601f1916919091016040019291505056feb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159ca2646970667358221220a0a559e2db0ef8addceaac9eb939d276774809e9c5205faa4db69252a4dc193264736f6c63430008100033
Loading...
Loading
Loading...
Loading
Loading...
Loading
Net Worth in USD
$0.00
Net Worth in POL
Multichain Portfolio | 34 Chains
| Chain | Token | Portfolio % | Price | Amount | Value |
|---|
Loading...
Loading
Loading...
Loading
Loading...
Loading
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.