Source Code
Overview
BNB Balance
BNB Value
$0.00Latest 16 from a total of 16 transactions
| Transaction Hash |
|
Block
|
From
|
To
|
|||||
|---|---|---|---|---|---|---|---|---|---|
| Unpause | 87865041 | 24 days ago | IN | 0 BNB | 0.00000213 | ||||
| Claim Liquidity | 87865011 | 24 days ago | IN | 0 BNB | 0.00000512 | ||||
| Claim Winnings | 87864980 | 24 days ago | IN | 0 BNB | 0.00000513 | ||||
| Claim Liquidity | 87864790 | 24 days ago | IN | 0 BNB | 0.00000419 | ||||
| Accept Ownership | 87864757 | 24 days ago | IN | 0 BNB | 0.00000264 | ||||
| Claim Fees | 87864577 | 24 days ago | IN | 0 BNB | 0.00000613 | ||||
| Claim Liquidity | 87864384 | 24 days ago | IN | 0 BNB | 0.00000326 | ||||
| Claim Winnings | 87864253 | 24 days ago | IN | 0 BNB | 0.0000028 | ||||
| Claim Liquidity | 87864152 | 24 days ago | IN | 0 BNB | 0.00000419 | ||||
| Accept Ownership | 87863831 | 24 days ago | IN | 0 BNB | 0.00000192 | ||||
| Accept Ownership | 87863785 | 24 days ago | IN | 0 BNB | 0.00000216 | ||||
| Accept Ownership | 87863391 | 24 days ago | IN | 0 BNB | 0.00000237 | ||||
| Accept Ownership | 84119720 | 43 days ago | IN | 0 BNB | 0.0000012 | ||||
| Claim Liquidity | 84118608 | 43 days ago | IN | 0 BNB | 0.00000233 | ||||
| Claim Winnings | 84118516 | 43 days ago | IN | 0 BNB | 0.00000233 | ||||
| Accept Ownership | 84118438 | 43 days ago | IN | 0 BNB | 0.0000012 |
Cross-Chain Transactions
Loading...
Loading
This contract may be a proxy contract. Click on More Options and select Is this a proxy? to confirm and enable the "Read as Proxy" & "Write as Proxy" tabs.
Contract Name:
PredictionMarketV3_4
Compiler Version
v0.8.26+commit.8a97fa7a
Optimization Enabled:
Yes with 1 runs
Other Settings:
paris EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.26;
// openzeppelin upgradeable imports
import "@openzeppelin/contracts-upgradeable/utils/ReentrancyGuardUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/access/Ownable2StepUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol";
// openzeppelin non-upgradeable imports (for interfaces)
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
// local imports
import "./IFantasyERC20.sol";
import "./IRealityETH_ERC20.sol";
import "./IPredictionMarketV3Manager.sol";
import "./IWETH.sol";
library CeilDiv {
// calculates ceil(x/y)
function ceildiv(uint256 x, uint256 y) internal pure returns (uint256) {
if (x > 0) return ((x - 1) / y) + 1;
return 0;
}
}
/// @title Market Contract Factory
contract PredictionMarketV3_4 is Initializable, ReentrancyGuardUpgradeable, Ownable2StepUpgradeable, UUPSUpgradeable {
using SafeERC20 for IERC20;
using CeilDiv for uint256;
// ------ Events ------
event MarketCreated(
address indexed user,
uint256 indexed marketId,
uint256 outcomes,
string question,
string image,
IERC20 token
);
event MarketActionTx(
address indexed user,
MarketAction indexed action,
uint256 indexed marketId,
uint256 outcomeId,
uint256 shares,
uint256 value,
uint256 timestamp
);
event Referral(
address indexed user,
uint256 indexed marketId,
string code,
MarketAction action,
uint256 outcomeId,
uint256 value,
uint256 timestamp
);
event MarketOutcomeShares(uint256 indexed marketId, uint256 timestamp, uint256[] outcomeShares, uint256 liquidity);
event MarketOutcomePrice(uint256 indexed marketId, uint256 indexed outcomeId, uint256 value, uint256 timestamp);
event MarketLiquidity(
uint256 indexed marketId,
uint256 value, // total liquidity
uint256 price, // value of one liquidity share; max: 1 (even odds situation)
uint256 timestamp
);
event MarketResolved(
address indexed user,
uint256 indexed marketId,
uint256 outcomeId,
uint256 timestamp,
bool admin
);
event MarketPaused(address indexed user, uint256 indexed marketId, bool paused, uint256 timestamp);
event MarketCloseDateEdited(
address indexed user,
uint256 indexed marketId,
uint256 closesAtTimestamp,
uint256 timestamp
);
event AllowedManagerSet(address indexed manager, bool allowed);
event Paused(bool paused, address indexed user);
event Withdrawal(address indexed user, address indexed token, uint256 amount, uint256 timestamp);
// ------ Events End ------
uint256 private constant MAX_UINT_256 = type(uint256).max;
uint256 private constant ONE = 10**18;
uint256 public constant MAX_OUTCOMES = 2**5;
uint256 public constant MAX_FEE = 5 * 10**16; // 5%
uint256 public constant MINIMUM_REALITIO_TIMEOUT = 3600; // 1 hour
enum MarketState {
open,
closed,
resolved
}
enum MarketAction {
buy,
sell,
addLiquidity,
removeLiquidity,
claimWinnings,
claimLiquidity,
claimFees,
claimVoided
}
struct Market {
// market details
uint256 closesAtTimestamp;
uint256 balance; // total stake
uint256 liquidity; // stake held
uint256 sharesAvailable; // shares held (all outcomes)
mapping(address user => uint256 shares) liquidityShares;
mapping(address user => bool claimed) liquidityClaims; // wether user has claimed liquidity earnings
MarketState state; // resolution variables
MarketResolution resolution; // fees
MarketFees fees;
// market outcomes
uint256 outcomeCount;
mapping(uint256 outcomeId => MarketOutcome outcome) outcomes;
IERC20 token; // ERC20 token market will use for trading
IPredictionMarketV3Manager manager; // manager contract
address creator; // market creator
bool paused; // market paused, no trading allowed
}
struct Fees {
uint256 fee; // fee % taken from every transaction
uint256 treasuryFee; // fee % taken from every transaction to a treasury address
uint256 distributorFee; // fee % taken from every transaction to a distributor address
}
struct MarketFees {
uint256 feeAccumulator; // internal var used to ensure pro-rate fee distribution
mapping(address user => uint256 claimed) claimed;
address treasury; // address to send treasury fees to
address distributor; // fee % taken from every transaction to a treasury address
Fees buyFees; // fees for buy transactions
Fees sellFees; // fees for sell transactions
}
struct MarketResolution {
IRealityETH_ERC20 realitio;
uint256 outcomeId;
bytes32 questionId; // realitio questionId
// realitio
uint256 realitioTimeout;
}
struct MarketOutcome {
uint256 marketId;
uint256 id;
Shares shares;
}
struct Shares {
uint256 total; // number of shares
uint256 available; // available shares
mapping(address user => uint256 shares) holders;
mapping(address user => bool winningsClaimed) claims; // wether user has claimed winnings
mapping(address user => bool voidedClaimed) voidedClaims; // wether user has claimed voided market shares
}
struct CreateMarketDescription {
uint256 value;
uint32 closesAt;
uint256 outcomes;
IERC20 token;
uint256[] distribution;
string question;
string image;
address arbitrator;
Fees buyFees;
Fees sellFees;
address treasury;
address distributor;
uint32 realitioTimeout;
IPredictionMarketV3Manager manager;
}
uint256[] marketIds;
mapping(uint256 marketId => Market market) markets;
uint256 public marketIndex;
mapping(address manager => bool allowed) allowedManagers;
// weth configs
IWETH public WETH;
bool public paused;
// ------ Modifiers ------
modifier isMarket(uint256 marketId) {
require(marketId < marketIndex, "!m");
_;
}
modifier timeTransitions(uint256 marketId) {
if (block.timestamp >= markets[marketId].closesAtTimestamp && markets[marketId].state == MarketState.open) {
_nextState(marketId);
}
_;
}
modifier atState(uint256 marketId, MarketState state) {
require(markets[marketId].state == state, "!ms");
_;
}
modifier notAtState(uint256 marketId, MarketState state) {
require(markets[marketId].state != state, "!ms");
_;
}
modifier whenNotPaused() {
require(!paused, "!p");
_;
}
modifier whenPaused() {
require(paused, "!p");
_;
}
modifier marketNotPaused(uint256 marketId) {
require(!paused, "p");
require(!markets[marketId].paused, "mp");
_;
}
modifier marketPaused(uint256 marketId) {
require(markets[marketId].paused, "!mp");
_;
}
modifier transitionNext(uint256 marketId) {
_;
_nextState(marketId);
}
modifier transitionLast(uint256 marketId) {
_;
_lastState(marketId);
}
modifier isWETHMarket(uint256 marketId) {
require(address(WETH) != address(0), "w0");
require(address(markets[marketId].token) == address(WETH), "!w");
_;
}
// ------ Modifiers End ------
/// @custom:oz-upgrades-unsafe-allow constructor
constructor() {
_disableInitializers();
}
/// @dev Initialize the contract - replaces constructor for upgradeable contracts
function initialize(IWETH _WETH, address initialOwner) public initializer {
__ReentrancyGuard_init();
__Ownable_init(initialOwner);
__UUPSUpgradeable_init();
WETH = _WETH;
}
receive() external payable {
assert(msg.sender == address(WETH)); // only accept ETH via fallback from the WETH contract
}
// ------ Core Functions ------
/// @dev for internal use only, validates the market fees and throws if they are not valid
function _validateFees(Fees memory fees) private pure {
require(fees.fee <= MAX_FEE, "f>5");
require(fees.treasuryFee <= MAX_FEE, "tf>5");
require(fees.distributorFee <= MAX_FEE, "df>5");
}
/// @dev Creates a market, initializes the outcome shares pool and submits a question in Realitio
function _createMarket(CreateMarketDescription memory desc) private returns (uint256 marketId) {
marketId = marketIndex;
marketIds.push(marketId);
Market storage market = markets[marketId];
IRealityETH_ERC20 realitio = IRealityETH_ERC20(desc.manager.getERC20RealitioAddress(desc.token));
require(desc.value > 0, "v0");
require(desc.closesAt > block.timestamp, "c<n");
require(desc.arbitrator != address(0), "a0");
require(desc.outcomes >= 2 && desc.outcomes <= MAX_OUTCOMES, "!oc");
require(address(realitio) != address(0), "r0");
require(desc.realitioTimeout >= MINIMUM_REALITIO_TIMEOUT, "rt<1h");
require(allowedManagers[address(desc.manager)], "!am");
require(desc.manager.isAllowedToCreateMarket(desc.token, msg.sender), "m!=a");
market.token = desc.token;
market.closesAtTimestamp = desc.closesAt;
market.state = MarketState.open;
// setting up fees
_validateFees(desc.buyFees);
market.fees.buyFees = desc.buyFees;
_validateFees(desc.sellFees);
market.fees.sellFees = desc.sellFees;
market.fees.treasury = desc.treasury;
market.fees.distributor = desc.distributor;
// setting intial value to an integer that does not map to any outcomeId
market.resolution.outcomeId = MAX_UINT_256;
market.outcomeCount = desc.outcomes;
// creating question in realitio
market.resolution.questionId = realitio.askQuestionERC20(
2,
desc.question,
desc.arbitrator,
desc.realitioTimeout,
desc.closesAt,
0,
0
);
market.resolution.realitio = realitio;
market.resolution.realitioTimeout = desc.realitioTimeout;
market.manager = desc.manager;
market.creator = msg.sender;
_addLiquidity(marketId, desc.value, desc.distribution);
// emiting initial price events
_emitMarketActionEvents(marketId);
emit MarketCreated(msg.sender, marketId, desc.outcomes, desc.question, desc.image, desc.token);
// incrementing market array index
marketIndex += 1;
}
function createMarket(CreateMarketDescription calldata desc) external nonReentrant returns (uint256 marketId) {
marketId = _createMarket(
CreateMarketDescription({
value: desc.value,
closesAt: desc.closesAt,
outcomes: desc.outcomes,
token: desc.token,
distribution: desc.distribution,
question: desc.question,
image: desc.image,
arbitrator: desc.arbitrator,
buyFees: desc.buyFees,
sellFees: desc.sellFees,
treasury: desc.treasury,
distributor: desc.distributor,
realitioTimeout: desc.realitioTimeout,
manager: desc.manager
})
);
// transferring funds
desc.token.safeTransferFrom(msg.sender, address(this), desc.value);
}
function mintAndCreateMarket(CreateMarketDescription calldata desc) external nonReentrant returns (uint256 marketId) {
// mint the amount of tokens to the user
IFantasyERC20(address(desc.token)).mint(address(this), desc.value);
return _createMarket(desc);
}
/// @dev Calculates the number of shares bought with "amount" balance
function calcBuyAmount(
uint256 amount,
uint256 marketId,
uint256 outcomeId
) public view returns (uint256) {
Market storage market = markets[marketId];
require(outcomeId < market.outcomeCount, "!o");
uint256[] memory outcomesShares = getMarketOutcomesShares(marketId);
uint256 fee = getMarketFee(marketId);
uint256 amountMinusFees = amount - ((amount * fee) / ONE);
uint256 buyTokenPoolBalance = outcomesShares[outcomeId];
uint256 endingOutcomeBalance = buyTokenPoolBalance * ONE;
for (uint256 i; i < market.outcomeCount; ++i) {
if (i != outcomeId) {
uint256 outcomeShares = outcomesShares[i];
endingOutcomeBalance = (endingOutcomeBalance * outcomeShares).ceildiv(outcomeShares + amountMinusFees);
}
}
require(endingOutcomeBalance > 0, "b0");
return buyTokenPoolBalance + amountMinusFees - (endingOutcomeBalance.ceildiv(ONE));
}
/// @dev Calculates the number of shares needed to be sold in order to receive "amount" in balance
function calcSellAmount(
uint256 amount,
uint256 marketId,
uint256 outcomeId
) public view returns (uint256) {
Market storage market = markets[marketId];
require(outcomeId < market.outcomeCount, "!o");
uint256[] memory outcomesShares = getMarketOutcomesShares(marketId);
uint256 fee = getMarketSellFee(marketId);
uint256 amountPlusFees = (amount * ONE) / (ONE - fee);
uint256 sellTokenPoolBalance = outcomesShares[outcomeId];
uint256 endingOutcomeBalance = sellTokenPoolBalance * ONE;
for (uint256 i; i < market.outcomeCount; ++i) {
if (i != outcomeId) {
uint256 outcomeShares = outcomesShares[i];
require(outcomeShares > amountPlusFees, "!sa");
endingOutcomeBalance = (endingOutcomeBalance * outcomeShares).ceildiv(outcomeShares - amountPlusFees);
}
}
require(endingOutcomeBalance > 0, "b0");
return amountPlusFees + endingOutcomeBalance.ceildiv(ONE) - sellTokenPoolBalance;
}
/// @dev Buy shares of a market outcome - returns gross amount of transaction (amount + fee)
function _buy(
uint256 marketId,
uint256 outcomeId,
uint256 minOutcomeSharesToBuy,
uint256 value
) private timeTransitions(marketId) atState(marketId, MarketState.open) marketNotPaused(marketId) returns (uint256) {
Market storage market = markets[marketId];
uint256 shares = calcBuyAmount(value, marketId, outcomeId);
require(shares >= minOutcomeSharesToBuy, "s<m");
require(shares > 0, "s0");
// subtracting fee from transaction value
uint256 feeAmount = (value * market.fees.buyFees.fee) / ONE;
market.fees.feeAccumulator += feeAmount;
uint256 valueMinusFees = value - feeAmount;
uint256 treasuryFeeAmount = (value * market.fees.buyFees.treasuryFee) / ONE;
uint256 distributorFeeAmount = (value * market.fees.buyFees.distributorFee) / ONE;
valueMinusFees -= treasuryFeeAmount + distributorFeeAmount;
MarketOutcome storage outcome = market.outcomes[outcomeId];
// Funding market shares with received funds
_addSharesToMarket(marketId, valueMinusFees);
require(outcome.shares.available >= shares, "s<sp");
_transferOutcomeSharesfromPool(msg.sender, marketId, outcomeId, shares);
// value emmited in event includes fee (gross amount)
emit MarketActionTx(msg.sender, MarketAction.buy, marketId, outcomeId, shares, value, block.timestamp);
_emitMarketActionEvents(marketId);
// transfering treasury/distributor fees
if (treasuryFeeAmount > 0) {
market.token.safeTransfer(market.fees.treasury, treasuryFeeAmount);
}
if (distributorFeeAmount > 0) {
market.token.safeTransfer(market.fees.distributor, distributorFeeAmount);
}
return value;
}
/// @dev Buy shares of a market outcome
function buy(
uint256 marketId,
uint256 outcomeId,
uint256 minOutcomeSharesToBuy,
uint256 value
) external nonReentrant {
Market storage market = markets[marketId];
market.token.safeTransferFrom(msg.sender, address(this), value);
_buy(marketId, outcomeId, minOutcomeSharesToBuy, value);
}
function buyWithETH(
uint256 marketId,
uint256 outcomeId,
uint256 minOutcomeSharesToBuy
) external payable isWETHMarket(marketId) nonReentrant {
uint256 value = msg.value;
// wrapping and depositing funds
IWETH(WETH).deposit{value: value}();
_buy(marketId, outcomeId, minOutcomeSharesToBuy, value);
}
function referralBuy(
uint256 marketId,
uint256 outcomeId,
uint256 minOutcomeSharesToBuy,
uint256 value,
string memory code
) public nonReentrant {
Market storage market = markets[marketId];
market.token.safeTransferFrom(msg.sender, address(this), value);
_buy(marketId, outcomeId, minOutcomeSharesToBuy, value);
emit Referral(msg.sender, marketId, code, MarketAction.buy, outcomeId, value, block.timestamp);
}
/// @dev Sell shares of a market outcome - returns gross amount of transaction (amount + fee)
function _sell(
uint256 marketId,
uint256 outcomeId,
uint256 value,
uint256 maxOutcomeSharesToSell
) private timeTransitions(marketId) atState(marketId, MarketState.open) marketNotPaused(marketId) returns (uint256) {
Market storage market = markets[marketId];
MarketOutcome storage outcome = market.outcomes[outcomeId];
uint256 shares = calcSellAmount(value, marketId, outcomeId);
require(shares <= maxOutcomeSharesToSell, "s>m");
require(shares > 0, "s0");
require(outcome.shares.holders[msg.sender] >= shares, "s>h");
_transferOutcomeSharesToPool(msg.sender, marketId, outcomeId, shares);
// adding fees to transaction value
uint256 fee = getMarketSellFee(marketId);
uint256 oneMinusFee = ONE - fee;
{
uint256 feeAmount = (value * market.fees.sellFees.fee) / oneMinusFee;
market.fees.feeAccumulator += feeAmount;
}
uint256 valuePlusFees = value + (value * fee) / oneMinusFee;
require(market.balance >= valuePlusFees, "b<v");
// Rebalancing market shares
_removeSharesFromMarket(marketId, valuePlusFees);
// value emmited in event includes fee (gross amount)
emit MarketActionTx(msg.sender, MarketAction.sell, marketId, outcomeId, shares, valuePlusFees, block.timestamp);
_emitMarketActionEvents(marketId);
{
uint256 treasuryFeeAmount = (value * market.fees.sellFees.treasuryFee) / oneMinusFee;
uint256 distributorFeeAmount = (value * market.fees.sellFees.distributorFee) / oneMinusFee;
// transfering treasury/distributor fees
if (treasuryFeeAmount > 0) {
market.token.safeTransfer(market.fees.treasury, treasuryFeeAmount);
}
if (distributorFeeAmount > 0) {
market.token.safeTransfer(market.fees.distributor, distributorFeeAmount);
}
}
return valuePlusFees;
}
function sell(
uint256 marketId,
uint256 outcomeId,
uint256 value,
uint256 maxOutcomeSharesToSell
) external nonReentrant {
_sell(marketId, outcomeId, value, maxOutcomeSharesToSell);
// Transferring funds to user
Market storage market = markets[marketId];
market.token.safeTransfer(msg.sender, value);
}
function sellToETH(
uint256 marketId,
uint256 outcomeId,
uint256 value,
uint256 maxOutcomeSharesToSell
) external isWETHMarket(marketId) nonReentrant {
_sell(marketId, outcomeId, value, maxOutcomeSharesToSell);
IWETH(WETH).withdraw(value);
(bool sent, ) = payable(msg.sender).call{value: value}("");
require(sent, "!s");
}
function referralSell(
uint256 marketId,
uint256 outcomeId,
uint256 value,
uint256 maxOutcomeSharesToSell,
string memory code
) external nonReentrant {
uint256 valuePlusFees = _sell(marketId, outcomeId, value, maxOutcomeSharesToSell);
// Transferring funds to user
Market storage market = markets[marketId];
market.token.safeTransfer(msg.sender, value);
emit Referral(msg.sender, marketId, code, MarketAction.sell, outcomeId, valuePlusFees, block.timestamp);
}
/// @dev Adds liquidity to a market - external
function _addLiquidity(
uint256 marketId,
uint256 value,
uint256[] memory distribution
) private timeTransitions(marketId) atState(marketId, MarketState.open) marketNotPaused(marketId) returns (uint256) {
Market storage market = markets[marketId];
require(value > 0, "v0");
uint256 liquidityAmount;
uint256[] memory outcomesShares = getMarketOutcomesShares(marketId);
uint256[] memory sendBackAmounts = new uint256[](market.outcomeCount);
uint256 baseShares = 0;
if (market.liquidity > 0) {
require(distribution.length == 0, "!d");
// part of the liquidity is exchanged for outcome shares if market is not balanced
for (uint256 i; i < market.outcomeCount; ++i) {
uint256 outcomeShares = outcomesShares[i];
if (baseShares < outcomeShares) baseShares = outcomeShares;
}
for (uint256 i; i < market.outcomeCount; ++i) {
uint256 remaining = (value * outcomesShares[i]) / baseShares;
sendBackAmounts[i] = value - remaining;
}
liquidityAmount = (value * market.liquidity) / baseShares;
// re-balancing fees pool
_rebalanceFeesPool(marketId, liquidityAmount, MarketAction.addLiquidity);
} else {
uint256 distributionLength = distribution.length;
// funding market with no liquidity
if (distributionLength > 0) {
require(distributionLength == market.outcomeCount, "d!=oc");
uint256 maxHint = 0;
for (uint256 i; i < distributionLength; ++i) {
uint256 hint = distribution[i];
if (maxHint < hint) maxHint = hint;
}
for (uint256 i; i < distributionLength; ++i) {
uint256 remaining = (value * distribution[i]) / maxHint;
require(remaining > 0, "!d");
sendBackAmounts[i] = value - remaining;
}
}
// funding market with total liquidity amount
liquidityAmount = value;
}
// funding market
market.liquidity = market.liquidity + liquidityAmount;
market.liquidityShares[msg.sender] = market.liquidityShares[msg.sender] + liquidityAmount;
_addSharesToMarket(marketId, value);
{
// transform sendBackAmounts to array of amounts added
for (uint256 i; i < market.outcomeCount; ++i) {
if (sendBackAmounts[i] > 0) {
_transferOutcomeSharesfromPool(msg.sender, marketId, i, sendBackAmounts[i]);
}
}
// emitting events, using outcome 0 for price reference
uint256 referencePrice = getMarketOutcomePrice(marketId, 0);
for (uint256 i; i < market.outcomeCount; ++i) {
if (sendBackAmounts[i] > 0) {
// outcome price = outcome shares / reference outcome shares * reference outcome price
uint256 outcomePrice = (referencePrice * market.outcomes[0].shares.available) /
market.outcomes[i].shares.available;
emit MarketActionTx(
msg.sender,
MarketAction.buy,
marketId,
i,
sendBackAmounts[i],
(sendBackAmounts[i] * outcomePrice) / ONE, // price * shares
block.timestamp
);
}
}
}
uint256 liquidityPrice = getMarketLiquidityPrice(marketId);
uint256 liquidityValue = (liquidityPrice * liquidityAmount) / ONE;
emit MarketActionTx(
msg.sender,
MarketAction.addLiquidity,
marketId,
0,
liquidityAmount,
liquidityValue,
block.timestamp
);
emit MarketLiquidity(marketId, market.liquidity, liquidityPrice, block.timestamp);
return liquidityAmount;
}
function addLiquidity(uint256 marketId, uint256 value, uint256 minSharesIn) external nonReentrant {
uint256[] memory distribution = new uint256[](0);
uint256 liquidityAmount = _addLiquidity(marketId, value, distribution);
require(liquidityAmount >= minSharesIn, "s<l");
Market storage market = markets[marketId];
market.token.safeTransferFrom(msg.sender, address(this), value);
}
/// @dev Removes liquidity to a market - external
function _removeLiquidity(uint256 marketId, uint256 shares)
private
timeTransitions(marketId)
atState(marketId, MarketState.open)
marketNotPaused(marketId)
returns (uint256)
{
Market storage market = markets[marketId];
// removing 100% of the liquidity is not allowed
require(shares < market.liquidity, "s>l");
require(market.liquidityShares[msg.sender] >= shares, "s>h");
// re-balancing fees pool
_rebalanceFeesPool(marketId, shares, MarketAction.removeLiquidity);
uint256[] memory outcomesShares = getMarketOutcomesShares(marketId);
uint256[] memory sendAmounts = new uint256[](market.outcomeCount);
uint256 baseShares = MAX_UINT_256;
// part of the liquidity is exchanged for outcome shares if market is not balanced
for (uint256 i; i < market.outcomeCount; ++i) {
uint256 outcomeShares = outcomesShares[i];
if (baseShares > outcomeShares) baseShares = outcomeShares;
}
uint256 liquidityAmount = (shares * baseShares) / market.liquidity;
for (uint256 i; i < market.outcomeCount; ++i) {
sendAmounts[i] = (outcomesShares[i] * shares) / market.liquidity;
sendAmounts[i] = sendAmounts[i] - liquidityAmount;
}
// removing liquidity from market
_removeSharesFromMarket(marketId, liquidityAmount);
market.liquidity = market.liquidity - shares;
// removing liquidity tokens from market creator
market.liquidityShares[msg.sender] = market.liquidityShares[msg.sender] - shares;
for (uint256 i; i < market.outcomeCount; ++i) {
if (sendAmounts[i] > 0) {
_transferOutcomeSharesfromPool(msg.sender, marketId, i, sendAmounts[i]);
}
}
// emitting events, using outcome 0 for price reference
uint256 referencePrice = getMarketOutcomePrice(marketId, 0);
for (uint256 i; i < market.outcomeCount; ++i) {
if (sendAmounts[i] > 0) {
// outcome price = outcome shares / reference outcome shares * reference outcome price
uint256 outcomePrice = (referencePrice * market.outcomes[0].shares.available) /
market.outcomes[i].shares.available;
emit MarketActionTx(
msg.sender,
MarketAction.buy,
marketId,
i,
sendAmounts[i],
(sendAmounts[i] * outcomePrice) / ONE, // price * shares
block.timestamp
);
}
}
emit MarketActionTx(
msg.sender,
MarketAction.removeLiquidity,
marketId,
0,
shares,
liquidityAmount,
block.timestamp
);
emit MarketLiquidity(marketId, market.liquidity, getMarketLiquidityPrice(marketId), block.timestamp);
return liquidityAmount;
}
function removeLiquidity(uint256 marketId, uint256 shares, uint256 minValueOut) external nonReentrant {
uint256 value = _removeLiquidity(marketId, shares);
require(value >= minValueOut, "v<l");
// transferring user funds from liquidity removed
Market storage market = markets[marketId];
market.token.safeTransfer(msg.sender, value);
}
/// @dev Fetches winning outcome from Realitio and resolves the market
function resolveMarketOutcome(uint256 marketId)
external
timeTransitions(marketId)
atState(marketId, MarketState.closed)
transitionNext(marketId)
returns (uint256 outcomeId)
{
Market storage market = markets[marketId];
// will fail if question is not finalized
outcomeId = uint256(market.resolution.realitio.resultFor(market.resolution.questionId));
market.resolution.outcomeId = outcomeId;
emit MarketResolved(msg.sender, marketId, outcomeId, block.timestamp, false);
_emitMarketActionEvents(marketId);
}
/// @dev overrides market resolution, instead of using realitio
function adminResolveMarketOutcome(uint256 marketId, uint256 outcomeId)
external
notAtState(marketId, MarketState.resolved)
transitionLast(marketId)
returns (uint256)
{
Market storage market = markets[marketId];
require(market.manager.isAllowedToEditMarket(market.token, msg.sender), "not allowed to resolve market");
market.resolution.outcomeId = outcomeId;
emit MarketResolved(msg.sender, marketId, outcomeId, block.timestamp, true);
_emitMarketActionEvents(marketId);
return market.resolution.outcomeId;
}
/// @dev pauses a market, no trading allowed
function adminPauseMarket(uint256 marketId) external isMarket(marketId) marketNotPaused(marketId) nonReentrant {
Market storage market = markets[marketId];
require(market.manager.isAllowedToEditMarket(market.token, msg.sender), "not allowed to pause market");
market.paused = true;
emit MarketPaused(msg.sender, marketId, true, block.timestamp);
}
/// @dev unpauses a market, trading allowed
function adminUnpauseMarket(uint256 marketId) external isMarket(marketId) marketPaused(marketId) nonReentrant {
Market storage market = markets[marketId];
require(market.manager.isAllowedToEditMarket(market.token, msg.sender), "not allowed to unpause market");
market.paused = false;
emit MarketPaused(msg.sender, marketId, false, block.timestamp);
}
/// @dev overrides market close date
function adminSetMarketCloseDate(uint256 marketId, uint256 closesAt)
external
isMarket(marketId)
notAtState(marketId, MarketState.resolved)
{
Market storage market = markets[marketId];
require(market.manager.isAllowedToEditMarket(market.token, msg.sender), "not allowed to set close date");
require(closesAt > block.timestamp, "resolution before current date");
market.closesAtTimestamp = closesAt;
emit MarketCloseDateEdited(msg.sender, marketId, closesAt, block.timestamp);
}
/// @dev Allows holders of resolved outcome shares to claim earnings.
function _claimWinnings(uint256 marketId)
private
atState(marketId, MarketState.resolved)
marketNotPaused(marketId)
returns (uint256 value)
{
Market storage market = markets[marketId];
MarketOutcome storage resolvedOutcome = market.outcomes[market.resolution.outcomeId];
require(!isMarketVoided(marketId), "mv");
require(resolvedOutcome.shares.holders[msg.sender] > 0, "!h");
require(!resolvedOutcome.shares.claims[msg.sender], "!c");
// 1 share => price = 1
value = resolvedOutcome.shares.holders[msg.sender];
// assuring market has enough funds
require(market.balance >= value, "b<v");
market.balance = market.balance - value;
resolvedOutcome.shares.claims[msg.sender] = true;
emit MarketActionTx(
msg.sender,
MarketAction.claimWinnings,
marketId,
market.resolution.outcomeId,
resolvedOutcome.shares.holders[msg.sender],
value,
block.timestamp
);
}
function claimWinnings(uint256 marketId) external nonReentrant {
uint256 value = _claimWinnings(marketId);
// transferring user funds from winnings claimed
Market storage market = markets[marketId];
market.token.safeTransfer(msg.sender, value);
}
/// @dev Allows holders of voided outcome shares to claim balance back.
function _claimVoidedOutcomeShares(uint256 marketId, uint256 outcomeId)
private
atState(marketId, MarketState.resolved)
marketNotPaused(marketId)
returns (uint256 value)
{
Market storage market = markets[marketId];
MarketOutcome storage outcome = market.outcomes[outcomeId];
require(isMarketVoided(marketId), "!mv");
require(outcome.shares.holders[msg.sender] > 0, "!h");
require(!outcome.shares.voidedClaims[msg.sender], "!c");
// voided market - shares are valued at last market price
uint256 price = getMarketOutcomePrice(marketId, outcomeId);
value = (price * outcome.shares.holders[msg.sender]) / ONE;
// assuring market has enough funds
require(market.balance >= value, "b<v");
market.balance = market.balance - value;
outcome.shares.voidedClaims[msg.sender] = true;
emit MarketActionTx(
msg.sender,
MarketAction.claimVoided,
marketId,
outcomeId,
outcome.shares.holders[msg.sender],
value,
block.timestamp
);
return value;
}
function claimVoidedOutcomeShares(uint256 marketId, uint256 outcomeId) external nonReentrant {
uint256 value = _claimVoidedOutcomeShares(marketId, outcomeId);
// transferring user funds from voided outcome shares claimed
Market storage market = markets[marketId];
market.token.safeTransfer(msg.sender, value);
}
/// @dev Allows liquidity providers to claim earnings from liquidity providing.
function _claimLiquidity(uint256 marketId)
private
atState(marketId, MarketState.resolved)
marketNotPaused(marketId)
returns (uint256 value)
{
Market storage market = markets[marketId];
require(market.liquidityShares[msg.sender] > 0, "!h");
require(!market.liquidityClaims[msg.sender], "!c");
// value = total resolved outcome pool shares * pool share (%)
uint256 liquidityPrice = getMarketLiquidityPrice(marketId);
value = (liquidityPrice * market.liquidityShares[msg.sender]) / ONE;
// assuring market has enough funds
require(market.balance >= value, "b<v");
market.balance = market.balance - value;
market.liquidityClaims[msg.sender] = true;
emit MarketActionTx(
msg.sender,
MarketAction.claimLiquidity,
marketId,
0,
market.liquidityShares[msg.sender],
value,
block.timestamp
);
}
function claimLiquidity(uint256 marketId) external nonReentrant {
uint256 value = _claimLiquidity(marketId);
// transferring user funds from liquidity claimed
Market storage market = markets[marketId];
market.token.safeTransfer(msg.sender, value);
// claiming any pending fees
uint256 feesValue = _claimFees(marketId);
if (feesValue > 0) {
market.token.safeTransfer(msg.sender, feesValue);
}
}
/// @dev Allows liquidity providers to claim their fees share from fees pool
function _claimFees(uint256 marketId) private marketNotPaused(marketId) returns (uint256 value) {
Market storage market = markets[marketId];
value = getUserClaimableFees(marketId, msg.sender);
if (value > 0) {
market.fees.claimed[msg.sender] = market.fees.claimed[msg.sender] + value;
}
emit MarketActionTx(
msg.sender,
MarketAction.claimFees,
marketId,
0,
market.liquidityShares[msg.sender],
value,
block.timestamp
);
}
function claimFees(uint256 marketId) public nonReentrant {
uint256 value = _claimFees(marketId);
// transferring user funds from fees claimed
Market storage market = markets[marketId];
market.token.safeTransfer(msg.sender, value);
}
/// @dev Rebalances the fees pool. Needed in every AddLiquidity / RemoveLiquidity call
function _rebalanceFeesPool(
uint256 marketId,
uint256 liquidityShares,
MarketAction action
) private {
Market storage market = markets[marketId];
uint256 feeAccumulator = (liquidityShares * market.fees.feeAccumulator) / market.liquidity;
if (action == MarketAction.addLiquidity) {
market.fees.feeAccumulator += feeAccumulator;
market.fees.claimed[msg.sender] += feeAccumulator;
} else {
market.fees.feeAccumulator -= feeAccumulator;
market.fees.claimed[msg.sender] = market.fees.claimed[msg.sender] - feeAccumulator;
}
}
/// @dev Transitions market to next state
function _nextState(uint256 marketId) private {
Market storage market = markets[marketId];
market.state = MarketState(uint256(market.state) + 1);
}
/// @dev Transitions market to last state
function _lastState(uint256 marketId) private {
Market storage market = markets[marketId];
market.state = MarketState.resolved;
}
/// @dev Emits a outcome price event for every outcome
function _emitMarketActionEvents(uint256 marketId) private {
Market storage market = markets[marketId];
uint256[] memory outcomeShares = new uint256[](market.outcomeCount);
for (uint256 i; i < market.outcomeCount; ++i) {
outcomeShares[i] = market.outcomes[i].shares.available;
}
emit MarketOutcomeShares(marketId, block.timestamp, outcomeShares, market.liquidity);
}
/// @dev Adds outcome shares to shares pool
function _addSharesToMarket(uint256 marketId, uint256 shares) private {
Market storage market = markets[marketId];
for (uint256 i; i < market.outcomeCount; ++i) {
MarketOutcome storage outcome = market.outcomes[i];
outcome.shares.available = outcome.shares.available + shares;
outcome.shares.total = outcome.shares.total + shares;
// only adding to market total shares, the available remains
market.sharesAvailable = market.sharesAvailable + shares;
}
market.balance = market.balance + shares;
}
/// @dev Removes outcome shares from shares pool
function _removeSharesFromMarket(uint256 marketId, uint256 shares) private {
Market storage market = markets[marketId];
for (uint256 i; i < market.outcomeCount; ++i) {
MarketOutcome storage outcome = market.outcomes[i];
outcome.shares.available = outcome.shares.available - shares;
outcome.shares.total = outcome.shares.total - shares;
// only subtracting from market total shares, the available remains
market.sharesAvailable = market.sharesAvailable - shares;
}
market.balance = market.balance - shares;
}
/// @dev Transfer outcome shares from pool to user balance
function _transferOutcomeSharesfromPool(
address user,
uint256 marketId,
uint256 outcomeId,
uint256 shares
) private {
Market storage market = markets[marketId];
MarketOutcome storage outcome = market.outcomes[outcomeId];
// transfering shares from shares pool to user
outcome.shares.holders[user] = outcome.shares.holders[user] + shares;
outcome.shares.available = outcome.shares.available - shares;
market.sharesAvailable = market.sharesAvailable - shares;
}
/// @dev Transfer outcome shares from user balance back to pool
function _transferOutcomeSharesToPool(
address user,
uint256 marketId,
uint256 outcomeId,
uint256 shares
) private {
Market storage market = markets[marketId];
MarketOutcome storage outcome = market.outcomes[outcomeId];
// adding shares back to pool
outcome.shares.holders[user] = outcome.shares.holders[user] - shares;
outcome.shares.available = outcome.shares.available + shares;
market.sharesAvailable = market.sharesAvailable + shares;
}
// ------ Core Functions End ------
// ------ Getters ------
function getUserMarketShares(uint256 marketId, address user)
external
view
returns (uint256 liquidity, uint256[] memory outcomes)
{
Market storage market = markets[marketId];
uint256[] memory outcomeShares = new uint256[](market.outcomeCount);
for (uint256 i; i < market.outcomeCount; ++i) {
outcomeShares[i] = market.outcomes[i].shares.holders[user];
}
return (market.liquidityShares[user], outcomeShares);
}
function getUserClaimStatus(uint256 marketId, address user)
external
view
returns (
bool winningsToClaim,
bool winningsClaimed,
bool liquidityToClaim,
bool liquidityClaimed,
uint256 claimableFees
)
{
Market storage market = markets[marketId];
// market still not resolved
if (market.state != MarketState.resolved) {
return (false, false, false, false, getUserClaimableFees(marketId, user));
}
MarketOutcome storage outcome = market.outcomes[market.resolution.outcomeId];
return (
outcome.shares.holders[user] > 0,
outcome.shares.claims[user],
market.liquidityShares[user] > 0,
market.liquidityClaims[user],
getUserClaimableFees(marketId, user)
);
}
function getUserLiquidityPoolShare(uint256 marketId, address user) external view returns (uint256) {
Market storage market = markets[marketId];
return (market.liquidityShares[user] * ONE) / market.liquidity;
}
function getUserClaimableFees(uint256 marketId, address user) public view returns (uint256) {
Market storage market = markets[marketId];
uint256 rawAmount = (market.fees.feeAccumulator * market.liquidityShares[user]) / market.liquidity;
// No fees left to claim
if (market.fees.claimed[user] > rawAmount) return 0;
return rawAmount - market.fees.claimed[user];
}
function getMarkets() external view returns (uint256[] memory) {
return marketIds;
}
function getMarketData(uint256 marketId)
external
view
returns (
MarketState state,
uint256 closesAt,
uint256 liquidity,
uint256 balance,
uint256 sharesAvailable,
int256 resolvedOutcomeId
)
{
Market storage market = markets[marketId];
return (
getMarketState(marketId),
market.closesAtTimestamp,
market.liquidity,
market.balance,
market.sharesAvailable,
getMarketResolvedOutcome(marketId)
);
}
function getMarketAltData(uint256 marketId)
external
view
returns (
uint256 buyFee,
bytes32 questionId,
uint256 questionIdUint,
IERC20 token,
uint256 buyTreasuryFee,
address treasury,
IRealityETH_ERC20 realitio,
uint256 realitioTimeout,
IPredictionMarketV3Manager manager
)
{
Market storage market = markets[marketId];
return (
market.fees.buyFees.fee,
market.resolution.questionId,
uint256(market.resolution.questionId),
market.token,
market.fees.buyFees.treasuryFee,
market.fees.treasury,
market.resolution.realitio,
market.resolution.realitioTimeout,
market.manager
);
}
function getMarketState(uint256 marketId) public view returns (MarketState) {
Market storage market = markets[marketId];
// closed should override open state if market is open and past close time
if (market.state == MarketState.open && block.timestamp >= market.closesAtTimestamp) {
return MarketState.closed;
}
return market.state;
}
function getMarketCreator(uint256 marketId) external view returns (address) {
Market storage market = markets[marketId];
return market.creator;
}
function getMarketQuestion(uint256 marketId) external view returns (bytes32) {
Market storage market = markets[marketId];
return (market.resolution.questionId);
}
function getMarketPrices(uint256 marketId) external view returns (uint256 liquidity, uint256[] memory outcomes) {
Market storage market = markets[marketId];
uint256[] memory prices = new uint256[](market.outcomeCount);
for (uint256 i; i < market.outcomeCount; ++i) {
prices[i] = getMarketOutcomePrice(marketId, i);
}
return (getMarketLiquidityPrice(marketId), prices);
}
function getMarketShares(uint256 marketId) external view returns (uint256 liquidity, uint256[] memory outcomes) {
Market storage market = markets[marketId];
uint256[] memory outcomeShares = new uint256[](market.outcomeCount);
for (uint256 i; i < market.outcomeCount; ++i) {
outcomeShares[i] = market.outcomes[i].shares.available;
}
return (market.liquidity, outcomeShares);
}
function getMarketLiquidityPrice(uint256 marketId) public view returns (uint256) {
Market storage market = markets[marketId];
if (market.state == MarketState.resolved && !isMarketVoided(marketId)) {
// resolved market, outcome prices are either 0 or 1
// final liquidity price = outcome shares / liquidity shares
return (market.outcomes[market.resolution.outcomeId].shares.available * ONE) / market.liquidity;
}
// liquidity price = # outcomes / (liquidity * sum (1 / every outcome shares)
uint256 marketSharesSum = 0;
for (uint256 i; i < market.outcomeCount; ++i) {
MarketOutcome storage outcome = market.outcomes[i];
marketSharesSum = marketSharesSum + (ONE * ONE) / outcome.shares.available;
}
return (market.outcomeCount * ONE * ONE * ONE) / market.liquidity / marketSharesSum;
}
function getMarketResolvedOutcome(uint256 marketId) public view returns (int256) {
Market storage market = markets[marketId];
// returning -3 if market still not resolved
if (market.state != MarketState.resolved) {
// -1 is used by reality.eth by convention to indicate an invalid market
// -2 is used by reality.eth by convention to indicate a market answered too soon
return -3;
}
return int256(market.resolution.outcomeId);
}
function isMarketVoided(uint256 marketId) public view returns (bool) {
Market storage market = markets[marketId];
// market still not resolved, still in valid state
if (market.state != MarketState.resolved) {
return false;
}
// resolved market id does not match any of the market ids
return market.resolution.outcomeId >= market.outcomeCount;
}
function getMarketBuyFee(uint256 marketId) public view returns (uint256) {
Market storage market = markets[marketId];
return market.fees.buyFees.fee + market.fees.buyFees.treasuryFee + market.fees.buyFees.distributorFee;
}
function getMarketSellFee(uint256 marketId) public view returns (uint256) {
Market storage market = markets[marketId];
return market.fees.sellFees.fee + market.fees.sellFees.treasuryFee + market.fees.sellFees.distributorFee;
}
// alias of getMarketBuyFee, used for compatibility
function getMarketFee(uint256 marketId) public view returns (uint256) {
return getMarketBuyFee(marketId);
}
function getMarketFees(uint256 marketId)
external
view
returns (
Fees memory buyFees,
Fees memory sellFees,
address treasury,
address distributor
)
{
Market storage market = markets[marketId];
return (market.fees.buyFees, market.fees.sellFees, market.fees.treasury, market.fees.distributor);
}
// ------ Outcome Getters ------
function getMarketOutcomeIds(uint256 marketId) external view returns (uint256[] memory outcomeIds) {
Market storage market = markets[marketId];
outcomeIds = new uint256[](market.outcomeCount);
for (uint256 i; i < market.outcomeCount; ++i) {
outcomeIds[i] = i;
}
}
function getMarketOutcomePrice(uint256 marketId, uint256 outcomeId) public view returns (uint256) {
Market storage market = markets[marketId];
if (market.state == MarketState.resolved && !isMarketVoided(marketId)) {
// resolved market, price is either 0 or 1
return outcomeId == market.resolution.outcomeId ? ONE : 0;
}
// outcome price = 1 / (1 + sum(outcome shares / every outcome shares))
uint256 div = ONE;
for (uint256 i; i < market.outcomeCount; ++i) {
if (i == outcomeId) continue;
div = div + (market.outcomes[outcomeId].shares.available * ONE) / market.outcomes[i].shares.available;
}
return (ONE * ONE) / div;
}
function getMarketOutcomeData(uint256 marketId, uint256 outcomeId)
external
view
returns (
uint256 price,
uint256 availableShares,
uint256 totalShares
)
{
Market storage market = markets[marketId];
MarketOutcome storage outcome = market.outcomes[outcomeId];
return (getMarketOutcomePrice(marketId, outcomeId), outcome.shares.available, outcome.shares.total);
}
function getMarketOutcomesShares(uint256 marketId) public view returns (uint256[] memory shares) {
Market storage market = markets[marketId];
shares = new uint256[](market.outcomeCount);
for (uint256 i; i < market.outcomeCount; ++i) {
shares[i] = market.outcomes[i].shares.available;
}
}
function getMarketPaused(uint256 marketId) external view returns (bool) {
Market storage market = markets[marketId];
return market.paused;
}
// ------ Ownable Setters ------
function setAllowedManager(address manager, bool allowed) external onlyOwner {
allowedManagers[manager] = allowed;
emit AllowedManagerSet(manager, allowed);
}
function withdraw(address token, uint256 amount) external onlyOwner {
IERC20(token).safeTransfer(msg.sender, amount);
emit Withdrawal(msg.sender, token, amount, block.timestamp);
}
function pause() external onlyOwner whenNotPaused {
paused = true;
emit Paused(true, msg.sender);
}
function unpause() external onlyOwner whenPaused {
paused = false;
emit Paused(false, msg.sender);
}
// ------ Upgrade Authorization ------
/// @dev Function that should revert when `msg.sender` is not authorized to upgrade the contract
function _authorizeUpgrade(address newImplementation) internal override onlyOwner {}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/ReentrancyGuard.sol)
pragma solidity ^0.8.20;
import {Initializable} from "../proxy/utils/Initializable.sol";
/**
* @dev Contract module that helps prevent reentrant calls to a function.
*
* Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
* available, which can be applied 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.
*
* TIP: If EIP-1153 (transient storage) is available on the chain you're deploying at,
* consider using {ReentrancyGuardTransient} instead.
*
* TIP: If you would like to learn more about reentrancy and alternative ways
* to protect against it, check out our blog post
* https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
*/
abstract contract ReentrancyGuardUpgradeable is Initializable {
// Booleans are more expensive than uint256 or any type that takes up a full
// word because each write operation emits an extra SLOAD to first read the
// slot's contents, replace the bits taken up by the boolean, and then write
// back. This is the compiler's defense against contract upgrades and
// pointer aliasing, and it cannot be disabled.
// The values being non-zero value makes deployment a bit more expensive,
// but in exchange the refund on every call to nonReentrant will be lower in
// amount. Since refunds are capped to a percentage of the total
// transaction's gas, it is best to keep them low in cases like this one, to
// increase the likelihood of the full refund coming into effect.
uint256 private constant NOT_ENTERED = 1;
uint256 private constant ENTERED = 2;
/// @custom:storage-location erc7201:openzeppelin.storage.ReentrancyGuard
struct ReentrancyGuardStorage {
uint256 _status;
}
// keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.ReentrancyGuard")) - 1)) & ~bytes32(uint256(0xff))
bytes32 private constant ReentrancyGuardStorageLocation = 0x9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f00;
function _getReentrancyGuardStorage() private pure returns (ReentrancyGuardStorage storage $) {
assembly {
$.slot := ReentrancyGuardStorageLocation
}
}
/**
* @dev Unauthorized reentrant call.
*/
error ReentrancyGuardReentrantCall();
function __ReentrancyGuard_init() internal onlyInitializing {
__ReentrancyGuard_init_unchained();
}
function __ReentrancyGuard_init_unchained() internal onlyInitializing {
ReentrancyGuardStorage storage $ = _getReentrancyGuardStorage();
$._status = NOT_ENTERED;
}
/**
* @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 making it call a
* `private` function that does the actual work.
*/
modifier nonReentrant() {
_nonReentrantBefore();
_;
_nonReentrantAfter();
}
function _nonReentrantBefore() private {
ReentrancyGuardStorage storage $ = _getReentrancyGuardStorage();
// On the first call to nonReentrant, _status will be NOT_ENTERED
if ($._status == ENTERED) {
revert ReentrancyGuardReentrantCall();
}
// Any calls to nonReentrant after this point will fail
$._status = ENTERED;
}
function _nonReentrantAfter() private {
ReentrancyGuardStorage storage $ = _getReentrancyGuardStorage();
// By storing the original value once again, a refund is triggered (see
// https://eips.ethereum.org/EIPS/eip-2200)
$._status = NOT_ENTERED;
}
/**
* @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a
* `nonReentrant` function in the call stack.
*/
function _reentrancyGuardEntered() internal view returns (bool) {
ReentrancyGuardStorage storage $ = _getReentrancyGuardStorage();
return $._status == ENTERED;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (access/Ownable2Step.sol)
pragma solidity ^0.8.20;
import {OwnableUpgradeable} from "./OwnableUpgradeable.sol";
import {Initializable} from "../proxy/utils/Initializable.sol";
/**
* @dev Contract module which provides access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* This extension of the {Ownable} contract includes a two-step mechanism to transfer
* ownership, where the new owner must call {acceptOwnership} in order to replace the
* old one. This can help prevent common mistakes, such as transfers of ownership to
* incorrect accounts, or to contracts that are unable to interact with the
* permission system.
*
* The initial owner is specified at deployment time in the constructor for `Ownable`. This
* can later be changed with {transferOwnership} and {acceptOwnership}.
*
* This module is used through inheritance. It will make available all functions
* from parent (Ownable).
*/
abstract contract Ownable2StepUpgradeable is Initializable, OwnableUpgradeable {
/// @custom:storage-location erc7201:openzeppelin.storage.Ownable2Step
struct Ownable2StepStorage {
address _pendingOwner;
}
// keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.Ownable2Step")) - 1)) & ~bytes32(uint256(0xff))
bytes32 private constant Ownable2StepStorageLocation = 0x237e158222e3e6968b72b9db0d8043aacf074ad9f650f0d1606b4d82ee432c00;
function _getOwnable2StepStorage() private pure returns (Ownable2StepStorage storage $) {
assembly {
$.slot := Ownable2StepStorageLocation
}
}
event OwnershipTransferStarted(address indexed previousOwner, address indexed newOwner);
function __Ownable2Step_init() internal onlyInitializing {
}
function __Ownable2Step_init_unchained() internal onlyInitializing {
}
/**
* @dev Returns the address of the pending owner.
*/
function pendingOwner() public view virtual returns (address) {
Ownable2StepStorage storage $ = _getOwnable2StepStorage();
return $._pendingOwner;
}
/**
* @dev Starts the ownership transfer of the contract to a new account. Replaces the pending transfer if there is one.
* Can only be called by the current owner.
*
* Setting `newOwner` to the zero address is allowed; this can be used to cancel an initiated ownership transfer.
*/
function transferOwnership(address newOwner) public virtual override onlyOwner {
Ownable2StepStorage storage $ = _getOwnable2StepStorage();
$._pendingOwner = newOwner;
emit OwnershipTransferStarted(owner(), newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`) and deletes any pending owner.
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual override {
Ownable2StepStorage storage $ = _getOwnable2StepStorage();
delete $._pendingOwner;
super._transferOwnership(newOwner);
}
/**
* @dev The new owner accepts the ownership transfer.
*/
function acceptOwnership() public virtual {
address sender = _msgSender();
if (pendingOwner() != sender) {
revert OwnableUnauthorizedAccount(sender);
}
_transferOwnership(sender);
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.3.0) (proxy/utils/Initializable.sol)
pragma solidity ^0.8.20;
/**
* @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
* behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an
* external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
* function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
*
* The initialization functions use a version number. Once a version number is used, it is consumed and cannot be
* reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in
* case an upgrade adds a module that needs to be initialized.
*
* For example:
*
* [.hljs-theme-light.nopadding]
* ```solidity
* contract MyToken is ERC20Upgradeable {
* function initialize() initializer public {
* __ERC20_init("MyToken", "MTK");
* }
* }
*
* contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {
* function initializeV2() reinitializer(2) public {
* __ERC20Permit_init("MyToken");
* }
* }
* ```
*
* TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
* possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.
*
* CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
* that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
*
* [CAUTION]
* ====
* Avoid leaving a contract uninitialized.
*
* An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation
* contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke
* the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:
*
* [.hljs-theme-light.nopadding]
* ```
* /// @custom:oz-upgrades-unsafe-allow constructor
* constructor() {
* _disableInitializers();
* }
* ```
* ====
*/
abstract contract Initializable {
/**
* @dev Storage of the initializable contract.
*
* It's implemented on a custom ERC-7201 namespace to reduce the risk of storage collisions
* when using with upgradeable contracts.
*
* @custom:storage-location erc7201:openzeppelin.storage.Initializable
*/
struct InitializableStorage {
/**
* @dev Indicates that the contract has been initialized.
*/
uint64 _initialized;
/**
* @dev Indicates that the contract is in the process of being initialized.
*/
bool _initializing;
}
// keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.Initializable")) - 1)) & ~bytes32(uint256(0xff))
bytes32 private constant INITIALIZABLE_STORAGE = 0xf0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00;
/**
* @dev The contract is already initialized.
*/
error InvalidInitialization();
/**
* @dev The contract is not initializing.
*/
error NotInitializing();
/**
* @dev Triggered when the contract has been initialized or reinitialized.
*/
event Initialized(uint64 version);
/**
* @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,
* `onlyInitializing` functions can be used to initialize parent contracts.
*
* Similar to `reinitializer(1)`, except that in the context of a constructor an `initializer` may be invoked any
* number of times. This behavior in the constructor can be useful during testing and is not expected to be used in
* production.
*
* Emits an {Initialized} event.
*/
modifier initializer() {
// solhint-disable-next-line var-name-mixedcase
InitializableStorage storage $ = _getInitializableStorage();
// Cache values to avoid duplicated sloads
bool isTopLevelCall = !$._initializing;
uint64 initialized = $._initialized;
// Allowed calls:
// - initialSetup: the contract is not in the initializing state and no previous version was
// initialized
// - construction: the contract is initialized at version 1 (no reinitialization) and the
// current contract is just being deployed
bool initialSetup = initialized == 0 && isTopLevelCall;
bool construction = initialized == 1 && address(this).code.length == 0;
if (!initialSetup && !construction) {
revert InvalidInitialization();
}
$._initialized = 1;
if (isTopLevelCall) {
$._initializing = true;
}
_;
if (isTopLevelCall) {
$._initializing = false;
emit Initialized(1);
}
}
/**
* @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the
* contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be
* used to initialize parent contracts.
*
* A reinitializer may be used after the original initialization step. This is essential to configure modules that
* are added through upgrades and that require initialization.
*
* When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`
* cannot be nested. If one is invoked in the context of another, execution will revert.
*
* Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in
* a contract, executing them in the right order is up to the developer or operator.
*
* WARNING: Setting the version to 2**64 - 1 will prevent any future reinitialization.
*
* Emits an {Initialized} event.
*/
modifier reinitializer(uint64 version) {
// solhint-disable-next-line var-name-mixedcase
InitializableStorage storage $ = _getInitializableStorage();
if ($._initializing || $._initialized >= version) {
revert InvalidInitialization();
}
$._initialized = version;
$._initializing = true;
_;
$._initializing = false;
emit Initialized(version);
}
/**
* @dev Modifier to protect an initialization function so that it can only be invoked by functions with the
* {initializer} and {reinitializer} modifiers, directly or indirectly.
*/
modifier onlyInitializing() {
_checkInitializing();
_;
}
/**
* @dev Reverts if the contract is not in an initializing state. See {onlyInitializing}.
*/
function _checkInitializing() internal view virtual {
if (!_isInitializing()) {
revert NotInitializing();
}
}
/**
* @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.
* Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized
* to any version. It is recommended to use this to lock implementation contracts that are designed to be called
* through proxies.
*
* Emits an {Initialized} event the first time it is successfully executed.
*/
function _disableInitializers() internal virtual {
// solhint-disable-next-line var-name-mixedcase
InitializableStorage storage $ = _getInitializableStorage();
if ($._initializing) {
revert InvalidInitialization();
}
if ($._initialized != type(uint64).max) {
$._initialized = type(uint64).max;
emit Initialized(type(uint64).max);
}
}
/**
* @dev Returns the highest version that has been initialized. See {reinitializer}.
*/
function _getInitializedVersion() internal view returns (uint64) {
return _getInitializableStorage()._initialized;
}
/**
* @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.
*/
function _isInitializing() internal view returns (bool) {
return _getInitializableStorage()._initializing;
}
/**
* @dev Pointer to storage slot. Allows integrators to override it with a custom storage location.
*
* NOTE: Consider following the ERC-7201 formula to derive storage locations.
*/
function _initializableStorageSlot() internal pure virtual returns (bytes32) {
return INITIALIZABLE_STORAGE;
}
/**
* @dev Returns a pointer to the storage namespace.
*/
// solhint-disable-next-line var-name-mixedcase
function _getInitializableStorage() private pure returns (InitializableStorage storage $) {
bytes32 slot = _initializableStorageSlot();
assembly {
$.slot := slot
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.3.0) (proxy/utils/UUPSUpgradeable.sol)
pragma solidity ^0.8.22;
import {IERC1822Proxiable} from "@openzeppelin/contracts/interfaces/draft-IERC1822.sol";
import {ERC1967Utils} from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Utils.sol";
import {Initializable} from "./Initializable.sol";
/**
* @dev An upgradeability mechanism designed for UUPS proxies. The functions included here can perform an upgrade of an
* {ERC1967Proxy}, when this contract is set as the implementation behind such a proxy.
*
* A security mechanism ensures that an upgrade does not turn off upgradeability accidentally, although this risk is
* reinstated if the upgrade retains upgradeability but removes the security mechanism, e.g. by replacing
* `UUPSUpgradeable` with a custom implementation of upgrades.
*
* The {_authorizeUpgrade} function must be overridden to include access restriction to the upgrade mechanism.
*/
abstract contract UUPSUpgradeable is Initializable, IERC1822Proxiable {
/// @custom:oz-upgrades-unsafe-allow state-variable-immutable
address private immutable __self = address(this);
/**
* @dev The version of the upgrade interface of the contract. If this getter is missing, both `upgradeTo(address)`
* and `upgradeToAndCall(address,bytes)` are present, and `upgradeTo` must be used if no function should be called,
* while `upgradeToAndCall` will invoke the `receive` function if the second argument is the empty byte string.
* If the getter returns `"5.0.0"`, only `upgradeToAndCall(address,bytes)` is present, and the second argument must
* be the empty byte string if no function should be called, making it impossible to invoke the `receive` function
* during an upgrade.
*/
string public constant UPGRADE_INTERFACE_VERSION = "5.0.0";
/**
* @dev The call is from an unauthorized context.
*/
error UUPSUnauthorizedCallContext();
/**
* @dev The storage `slot` is unsupported as a UUID.
*/
error UUPSUnsupportedProxiableUUID(bytes32 slot);
/**
* @dev Check that the execution is being performed through a delegatecall call and that the execution context is
* a proxy contract with an implementation (as defined in ERC-1967) pointing to self. This should only be the case
* for UUPS and transparent proxies that are using the current contract as their implementation. Execution of a
* function through ERC-1167 minimal proxies (clones) would not normally pass this test, but is not guaranteed to
* fail.
*/
modifier onlyProxy() {
_checkProxy();
_;
}
/**
* @dev Check that the execution is not being performed through a delegate call. This allows a function to be
* callable on the implementing contract but not through proxies.
*/
modifier notDelegated() {
_checkNotDelegated();
_;
}
function __UUPSUpgradeable_init() internal onlyInitializing {
}
function __UUPSUpgradeable_init_unchained() internal onlyInitializing {
}
/**
* @dev Implementation of the ERC-1822 {proxiableUUID} function. This returns the storage slot used by the
* implementation. It is used to validate the implementation's compatibility when performing an upgrade.
*
* IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks
* bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this
* function revert if invoked through a proxy. This is guaranteed by the `notDelegated` modifier.
*/
function proxiableUUID() external view virtual notDelegated returns (bytes32) {
return ERC1967Utils.IMPLEMENTATION_SLOT;
}
/**
* @dev Upgrade the implementation of the proxy to `newImplementation`, and subsequently execute the function call
* encoded in `data`.
*
* Calls {_authorizeUpgrade}.
*
* Emits an {Upgraded} event.
*
* @custom:oz-upgrades-unsafe-allow-reachable delegatecall
*/
function upgradeToAndCall(address newImplementation, bytes memory data) public payable virtual onlyProxy {
_authorizeUpgrade(newImplementation);
_upgradeToAndCallUUPS(newImplementation, data);
}
/**
* @dev Reverts if the execution is not performed via delegatecall or the execution
* context is not of a proxy with an ERC-1967 compliant implementation pointing to self.
*/
function _checkProxy() internal view virtual {
if (
address(this) == __self || // Must be called through delegatecall
ERC1967Utils.getImplementation() != __self // Must be called through an active proxy
) {
revert UUPSUnauthorizedCallContext();
}
}
/**
* @dev Reverts if the execution is performed via delegatecall.
* See {notDelegated}.
*/
function _checkNotDelegated() internal view virtual {
if (address(this) != __self) {
// Must not be called through delegatecall
revert UUPSUnauthorizedCallContext();
}
}
/**
* @dev Function that should revert when `msg.sender` is not authorized to upgrade the contract. Called by
* {upgradeToAndCall}.
*
* Normally, this function will use an xref:access.adoc[access control] modifier such as {Ownable-onlyOwner}.
*
* ```solidity
* function _authorizeUpgrade(address) internal onlyOwner {}
* ```
*/
function _authorizeUpgrade(address newImplementation) internal virtual;
/**
* @dev Performs an implementation upgrade with a security check for UUPS proxies, and additional setup call.
*
* As a security check, {proxiableUUID} is invoked in the new implementation, and the return value
* is expected to be the implementation slot in ERC-1967.
*
* Emits an {IERC1967-Upgraded} event.
*/
function _upgradeToAndCallUUPS(address newImplementation, bytes memory data) private {
try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) {
if (slot != ERC1967Utils.IMPLEMENTATION_SLOT) {
revert UUPSUnsupportedProxiableUUID(slot);
}
ERC1967Utils.upgradeToAndCall(newImplementation, data);
} catch {
// The implementation is not UUPS
revert ERC1967Utils.ERC1967InvalidImplementation(newImplementation);
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (token/ERC20/IERC20.sol)
pragma solidity >=0.4.16;
/**
* @dev Interface of the ERC-20 standard as defined in the ERC.
*/
interface IERC20 {
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
/**
* @dev Returns the value of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the value of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves a `value` amount of tokens from the caller's account to `to`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address to, uint256 value) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets a `value` amount of tokens as the allowance of `spender` over the
* caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 value) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from `from` to `to` using the
* allowance mechanism. `value` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address from, address to, uint256 value) external returns (bool);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.3.0) (token/ERC20/utils/SafeERC20.sol)
pragma solidity ^0.8.20;
import {IERC20} from "../IERC20.sol";
import {IERC1363} from "../../../interfaces/IERC1363.sol";
/**
* @title SafeERC20
* @dev Wrappers around ERC-20 operations that throw on failure (when the token
* contract returns false). Tokens that return no value (and instead revert or
* throw on failure) are also supported, non-reverting calls are assumed to be
* successful.
* To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
* which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
*/
library SafeERC20 {
/**
* @dev An operation with an ERC-20 token failed.
*/
error SafeERC20FailedOperation(address token);
/**
* @dev Indicates a failed `decreaseAllowance` request.
*/
error SafeERC20FailedDecreaseAllowance(address spender, uint256 currentAllowance, uint256 requestedDecrease);
/**
* @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*/
function safeTransfer(IERC20 token, address to, uint256 value) internal {
if (!_safeTransfer(token, to, value, true)) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the
* calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.
*/
function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
if (!_safeTransferFrom(token, from, to, value, true)) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @dev Variant of {safeTransfer} that returns a bool instead of reverting if the operation is not successful.
*/
function trySafeTransfer(IERC20 token, address to, uint256 value) internal returns (bool) {
return _safeTransfer(token, to, value, false);
}
/**
* @dev Variant of {safeTransferFrom} that returns a bool instead of reverting if the operation is not successful.
*/
function trySafeTransferFrom(IERC20 token, address from, address to, uint256 value) internal returns (bool) {
return _safeTransferFrom(token, from, to, value, false);
}
/**
* @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*
* IMPORTANT: If the token implements ERC-7674 (ERC-20 with temporary allowance), and if the "client"
* smart contract uses ERC-7674 to set temporary allowances, then the "client" smart contract should avoid using
* this function. Performing a {safeIncreaseAllowance} or {safeDecreaseAllowance} operation on a token contract
* that has a non-zero temporary allowance (for that particular owner-spender) will result in unexpected behavior.
*/
function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
uint256 oldAllowance = token.allowance(address(this), spender);
forceApprove(token, spender, oldAllowance + value);
}
/**
* @dev Decrease the calling contract's allowance toward `spender` by `requestedDecrease`. If `token` returns no
* value, non-reverting calls are assumed to be successful.
*
* IMPORTANT: If the token implements ERC-7674 (ERC-20 with temporary allowance), and if the "client"
* smart contract uses ERC-7674 to set temporary allowances, then the "client" smart contract should avoid using
* this function. Performing a {safeIncreaseAllowance} or {safeDecreaseAllowance} operation on a token contract
* that has a non-zero temporary allowance (for that particular owner-spender) will result in unexpected behavior.
*/
function safeDecreaseAllowance(IERC20 token, address spender, uint256 requestedDecrease) internal {
unchecked {
uint256 currentAllowance = token.allowance(address(this), spender);
if (currentAllowance < requestedDecrease) {
revert SafeERC20FailedDecreaseAllowance(spender, currentAllowance, requestedDecrease);
}
forceApprove(token, spender, currentAllowance - requestedDecrease);
}
}
/**
* @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval
* to be set to zero before setting it to a non-zero value, such as USDT.
*
* NOTE: If the token implements ERC-7674, this function will not modify any temporary allowance. This function
* only sets the "standard" allowance. Any temporary allowance will remain active, in addition to the value being
* set here.
*/
function forceApprove(IERC20 token, address spender, uint256 value) internal {
if (!_safeApprove(token, spender, value, false)) {
if (!_safeApprove(token, spender, 0, true)) revert SafeERC20FailedOperation(address(token));
if (!_safeApprove(token, spender, value, true)) revert SafeERC20FailedOperation(address(token));
}
}
/**
* @dev Performs an {ERC1363} transferAndCall, with a fallback to the simple {ERC20} transfer if the target has no
* code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when
* targeting contracts.
*
* Reverts if the returned value is other than `true`.
*/
function transferAndCallRelaxed(IERC1363 token, address to, uint256 value, bytes memory data) internal {
if (to.code.length == 0) {
safeTransfer(token, to, value);
} else if (!token.transferAndCall(to, value, data)) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @dev Performs an {ERC1363} transferFromAndCall, with a fallback to the simple {ERC20} transferFrom if the target
* has no code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when
* targeting contracts.
*
* Reverts if the returned value is other than `true`.
*/
function transferFromAndCallRelaxed(
IERC1363 token,
address from,
address to,
uint256 value,
bytes memory data
) internal {
if (to.code.length == 0) {
safeTransferFrom(token, from, to, value);
} else if (!token.transferFromAndCall(from, to, value, data)) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @dev Performs an {ERC1363} approveAndCall, with a fallback to the simple {ERC20} approve if the target has no
* code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when
* targeting contracts.
*
* NOTE: When the recipient address (`to`) has no code (i.e. is an EOA), this function behaves as {forceApprove}.
* Opposedly, when the recipient address (`to`) has code, this function only attempts to call {ERC1363-approveAndCall}
* once without retrying, and relies on the returned value to be true.
*
* Reverts if the returned value is other than `true`.
*/
function approveAndCallRelaxed(IERC1363 token, address to, uint256 value, bytes memory data) internal {
if (to.code.length == 0) {
forceApprove(token, to, value);
} else if (!token.approveAndCall(to, value, data)) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @dev Imitates a Solidity `token.transfer(to, value)` call, 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 to The recipient of the tokens
* @param value The amount of token to transfer
* @param bubble Behavior switch if the transfer call reverts: bubble the revert reason or return a false boolean.
*/
function _safeTransfer(IERC20 token, address to, uint256 value, bool bubble) private returns (bool success) {
bytes4 selector = IERC20.transfer.selector;
assembly ("memory-safe") {
let fmp := mload(0x40)
mstore(0x00, selector)
mstore(0x04, and(to, shr(96, not(0))))
mstore(0x24, value)
success := call(gas(), token, 0, 0, 0x44, 0, 0x20)
// if call success and return is true, all is good.
// otherwise (not success or return is not true), we need to perform further checks
if iszero(and(success, eq(mload(0x00), 1))) {
// if the call was a failure and bubble is enabled, bubble the error
if and(iszero(success), bubble) {
returndatacopy(fmp, 0, returndatasize())
revert(fmp, returndatasize())
}
// if the return value is not true, then the call is only successful if:
// - the token address has code
// - the returndata is empty
success := and(success, and(iszero(returndatasize()), gt(extcodesize(token), 0)))
}
mstore(0x40, fmp)
}
}
/**
* @dev Imitates a Solidity `token.transferFrom(from, to, value)` call, 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 from The sender of the tokens
* @param to The recipient of the tokens
* @param value The amount of token to transfer
* @param bubble Behavior switch if the transfer call reverts: bubble the revert reason or return a false boolean.
*/
function _safeTransferFrom(
IERC20 token,
address from,
address to,
uint256 value,
bool bubble
) private returns (bool success) {
bytes4 selector = IERC20.transferFrom.selector;
assembly ("memory-safe") {
let fmp := mload(0x40)
mstore(0x00, selector)
mstore(0x04, and(from, shr(96, not(0))))
mstore(0x24, and(to, shr(96, not(0))))
mstore(0x44, value)
success := call(gas(), token, 0, 0, 0x64, 0, 0x20)
// if call success and return is true, all is good.
// otherwise (not success or return is not true), we need to perform further checks
if iszero(and(success, eq(mload(0x00), 1))) {
// if the call was a failure and bubble is enabled, bubble the error
if and(iszero(success), bubble) {
returndatacopy(fmp, 0, returndatasize())
revert(fmp, returndatasize())
}
// if the return value is not true, then the call is only successful if:
// - the token address has code
// - the returndata is empty
success := and(success, and(iszero(returndatasize()), gt(extcodesize(token), 0)))
}
mstore(0x40, fmp)
mstore(0x60, 0)
}
}
/**
* @dev Imitates a Solidity `token.approve(spender, value)` call, 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 spender The spender of the tokens
* @param value The amount of token to transfer
* @param bubble Behavior switch if the transfer call reverts: bubble the revert reason or return a false boolean.
*/
function _safeApprove(IERC20 token, address spender, uint256 value, bool bubble) private returns (bool success) {
bytes4 selector = IERC20.approve.selector;
assembly ("memory-safe") {
let fmp := mload(0x40)
mstore(0x00, selector)
mstore(0x04, and(spender, shr(96, not(0))))
mstore(0x24, value)
success := call(gas(), token, 0, 0, 0x44, 0, 0x20)
// if call success and return is true, all is good.
// otherwise (not success or return is not true), we need to perform further checks
if iszero(and(success, eq(mload(0x00), 1))) {
// if the call was a failure and bubble is enabled, bubble the error
if and(iszero(success), bubble) {
returndatacopy(fmp, 0, returndatasize())
revert(fmp, returndatasize())
}
// if the return value is not true, then the call is only successful if:
// - the token address has code
// - the returndata is empty
success := and(success, and(iszero(returndatasize()), gt(extcodesize(token), 0)))
}
mstore(0x40, fmp)
}
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.26;
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
interface IFantasyERC20 is IERC20 {
function mint(address account, uint256 amount) external;
function burn(address account, uint256 amount) external;
function claimTokens() external;
function claimAndApproveTokens() external;
function hasUserClaimedTokens(address user) external view returns (bool);
function pause() external;
function unpause() external;
}// SPDX-License-Identifier: GPL-3.0-only
// Based on https://github.com/RealityETH/reality-eth-monorepo/blob/main/packages/contracts/development/contracts/IRealityETH_ERC20.sol
pragma solidity ^0.8.26;
interface IRealityETH_ERC20 {
event LogAnswerReveal (bytes32 indexed question_id, address indexed user, bytes32 indexed answer_hash, bytes32 answer, uint256 nonce, uint256 bond);
event LogCancelArbitration (bytes32 indexed question_id);
event LogClaim (bytes32 indexed question_id, address indexed user, uint256 amount);
event LogFinalize (bytes32 indexed question_id, bytes32 indexed answer);
event LogFundAnswerBounty (bytes32 indexed question_id, uint256 bounty_added, uint256 bounty, address indexed user);
event LogMinimumBond (bytes32 indexed question_id, uint256 min_bond);
event LogNewAnswer (bytes32 answer, bytes32 indexed question_id, bytes32 history_hash, address indexed user, uint256 bond, uint256 ts, bool is_commitment);
event LogNewQuestion (bytes32 indexed question_id, address indexed user, uint256 template_id, string question, bytes32 indexed content_hash, address arbitrator, uint32 timeout, uint32 opening_ts, uint256 nonce, uint256 created);
event LogNewTemplate (uint256 indexed template_id, address indexed user, string question_text);
event LogNotifyOfArbitrationRequest (bytes32 indexed question_id, address indexed user);
event LogReopenQuestion (bytes32 indexed question_id, bytes32 indexed reopened_question_id);
event LogSetQuestionFee (address arbitrator, uint256 amount);
function askQuestion (uint256 template_id, string calldata question, address arbitrator, uint32 timeout, uint32 opening_ts, uint256 nonce) external returns (bytes32);
function askQuestionERC20 (uint256 template_id, string calldata question, address arbitrator, uint32 timeout, uint32 opening_ts, uint256 nonce, uint256 tokens) external returns (bytes32);
function askQuestionWithMinBondERC20 (uint256 template_id, string calldata question, address arbitrator, uint32 timeout, uint32 opening_ts, uint256 nonce, uint256 min_bond, uint256 tokens) external returns (bytes32);
function assignWinnerAndSubmitAnswerByArbitrator (bytes32 question_id, bytes32 answer, address payee_if_wrong, bytes32 last_history_hash, bytes32 last_answer_or_commitment_id, address last_answerer) external;
function cancelArbitration (bytes32 question_id) external;
function claimMultipleAndWithdrawBalance (bytes32[] calldata question_ids, uint256[] calldata lengths, bytes32[] calldata hist_hashes, address[] calldata addrs, uint256[] calldata bonds, bytes32[] calldata answers) external;
function claimWinnings (bytes32 question_id, bytes32[] calldata history_hashes, address[] calldata addrs, uint256[] calldata bonds, bytes32[] calldata answers) external;
function createTemplate (string calldata content) external returns (uint256);
function createTemplateAndAskQuestion (string calldata content, string calldata question, address arbitrator, uint32 timeout, uint32 opening_ts, uint256 nonce) external returns (bytes32);
function fundAnswerBountyERC20 (bytes32 question_id, uint256 tokens) external;
function notifyOfArbitrationRequest (bytes32 question_id, address requester, uint256 max_previous) external;
function reopenQuestionERC20 (uint256 template_id, string calldata question, address arbitrator, uint32 timeout, uint32 opening_ts, uint256 nonce, uint256 min_bond, bytes32 reopens_question_id, uint256 tokens) external returns (bytes32);
function setQuestionFee (uint256 fee) external;
function setToken (address _token) external;
function submitAnswerByArbitrator (bytes32 question_id, bytes32 answer, address answerer) external;
function submitAnswerCommitmentERC20 (bytes32 question_id, bytes32 answer_hash, uint256 max_previous, address _answerer, uint256 tokens) external;
function submitAnswerERC20 (bytes32 question_id, bytes32 answer, uint256 max_previous, uint256 tokens) external;
function submitAnswerForERC20 (bytes32 question_id, bytes32 answer, uint256 max_previous, address answerer, uint256 tokens) external;
function submitAnswerReveal (bytes32 question_id, bytes32 answer, uint256 nonce, uint256 bond) external;
function arbitrator_question_fees (address) external view returns (uint256);
function commitments (bytes32) external view returns (uint32 reveal_ts, bool is_revealed, bytes32 revealed_answer);
function getArbitrator (bytes32 question_id) external view returns (address);
function getBestAnswer (bytes32 question_id) external view returns (bytes32);
function getBond (bytes32 question_id) external view returns (uint256);
function getBounty (bytes32 question_id) external view returns (uint256);
function getContentHash (bytes32 question_id) external view returns (bytes32);
function getFinalAnswer (bytes32 question_id) external view returns (bytes32);
function getFinalAnswerIfMatches (bytes32 question_id, bytes32 content_hash, address arbitrator, uint32 min_timeout, uint256 min_bond) external view returns (bytes32);
function getFinalizeTS (bytes32 question_id) external view returns (uint32);
function getHistoryHash (bytes32 question_id) external view returns (bytes32);
function getMinBond (bytes32 question_id) external view returns (uint256);
function getOpeningTS (bytes32 question_id) external view returns (uint32);
function getTimeout (bytes32 question_id) external view returns (uint32);
function isFinalized (bytes32 question_id) external view returns (bool);
function isPendingArbitration (bytes32 question_id) external view returns (bool);
function isSettledTooSoon (bytes32 question_id) external view returns (bool);
function question_claims (bytes32) external view returns (address payee, uint256 last_bond, uint256 queued_funds);
function questions (bytes32) external view returns (bytes32 content_hash, address arbitrator, uint32 opening_ts, uint32 timeout, uint32 finalize_ts, bool is_pending_arbitration, uint256 bounty, bytes32 best_answer, bytes32 history_hash, uint256 bond, uint256 min_bond);
function reopened_questions (bytes32) external view returns (bytes32);
function reopener_questions (bytes32) external view returns (bool);
function resultFor (bytes32 question_id) external view returns (bytes32);
function resultForOnceSettled (bytes32 question_id) external view returns (bytes32);
function template_hashes (uint256) external view returns (bytes32);
function templates (uint256) external view returns (uint256);
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.26;
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
interface IPredictionMarketV3Manager {
function isAllowedToCreateMarket(IERC20 token, address user) external view returns (bool);
function isAllowedToResolveMarket(IERC20 token, address user) external view returns (bool);
function isAllowedToEditMarket(IERC20 token, address user) external view returns (bool);
function isIERC20TokenSocial(IERC20 token) external view returns (bool);
function getERC20RealitioAddress(IERC20 token) external view returns (address);
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.26;
interface IWETH {
function deposit() external payable;
function transfer(address to, uint256 value) external returns (bool);
function withdraw(uint256) external;
function approve(address guy, uint256 wad) external returns (bool);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)
pragma solidity ^0.8.20;
import {ContextUpgradeable} from "../utils/ContextUpgradeable.sol";
import {Initializable} from "../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.
*
* The initial owner is set to the address provided by the deployer. 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 {
/// @custom:storage-location erc7201:openzeppelin.storage.Ownable
struct OwnableStorage {
address _owner;
}
// keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.Ownable")) - 1)) & ~bytes32(uint256(0xff))
bytes32 private constant OwnableStorageLocation = 0x9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c199300;
function _getOwnableStorage() private pure returns (OwnableStorage storage $) {
assembly {
$.slot := OwnableStorageLocation
}
}
/**
* @dev The caller account is not authorized to perform an operation.
*/
error OwnableUnauthorizedAccount(address account);
/**
* @dev The owner is not a valid owner account. (eg. `address(0)`)
*/
error OwnableInvalidOwner(address owner);
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the address provided by the deployer as the initial owner.
*/
function __Ownable_init(address initialOwner) internal onlyInitializing {
__Ownable_init_unchained(initialOwner);
}
function __Ownable_init_unchained(address initialOwner) internal onlyInitializing {
if (initialOwner == address(0)) {
revert OwnableInvalidOwner(address(0));
}
_transferOwnership(initialOwner);
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
_checkOwner();
_;
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
OwnableStorage storage $ = _getOwnableStorage();
return $._owner;
}
/**
* @dev Throws if the sender is not the owner.
*/
function _checkOwner() internal view virtual {
if (owner() != _msgSender()) {
revert OwnableUnauthorizedAccount(_msgSender());
}
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby disabling 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 {
if (newOwner == address(0)) {
revert OwnableInvalidOwner(address(0));
}
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual {
OwnableStorage storage $ = _getOwnableStorage();
address oldOwner = $._owner;
$._owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (interfaces/draft-IERC1822.sol)
pragma solidity >=0.4.16;
/**
* @dev ERC-1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified
* proxy whose upgrades are fully controlled by the current implementation.
*/
interface IERC1822Proxiable {
/**
* @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation
* address.
*
* IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks
* bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this
* function revert if invoked through a proxy.
*/
function proxiableUUID() external view returns (bytes32);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.2.0) (proxy/ERC1967/ERC1967Utils.sol)
pragma solidity ^0.8.21;
import {IBeacon} from "../beacon/IBeacon.sol";
import {IERC1967} from "../../interfaces/IERC1967.sol";
import {Address} from "../../utils/Address.sol";
import {StorageSlot} from "../../utils/StorageSlot.sol";
/**
* @dev This library provides getters and event emitting update functions for
* https://eips.ethereum.org/EIPS/eip-1967[ERC-1967] slots.
*/
library ERC1967Utils {
/**
* @dev Storage slot with the address of the current implementation.
* This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1.
*/
// solhint-disable-next-line private-vars-leading-underscore
bytes32 internal constant IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
/**
* @dev The `implementation` of the proxy is invalid.
*/
error ERC1967InvalidImplementation(address implementation);
/**
* @dev The `admin` of the proxy is invalid.
*/
error ERC1967InvalidAdmin(address admin);
/**
* @dev The `beacon` of the proxy is invalid.
*/
error ERC1967InvalidBeacon(address beacon);
/**
* @dev An upgrade function sees `msg.value > 0` that may be lost.
*/
error ERC1967NonPayable();
/**
* @dev Returns the current implementation address.
*/
function getImplementation() internal view returns (address) {
return StorageSlot.getAddressSlot(IMPLEMENTATION_SLOT).value;
}
/**
* @dev Stores a new address in the ERC-1967 implementation slot.
*/
function _setImplementation(address newImplementation) private {
if (newImplementation.code.length == 0) {
revert ERC1967InvalidImplementation(newImplementation);
}
StorageSlot.getAddressSlot(IMPLEMENTATION_SLOT).value = newImplementation;
}
/**
* @dev Performs implementation upgrade with additional setup call if data is nonempty.
* This function is payable only if the setup call is performed, otherwise `msg.value` is rejected
* to avoid stuck value in the contract.
*
* Emits an {IERC1967-Upgraded} event.
*/
function upgradeToAndCall(address newImplementation, bytes memory data) internal {
_setImplementation(newImplementation);
emit IERC1967.Upgraded(newImplementation);
if (data.length > 0) {
Address.functionDelegateCall(newImplementation, data);
} else {
_checkNonPayable();
}
}
/**
* @dev Storage slot with the admin of the contract.
* This is the keccak-256 hash of "eip1967.proxy.admin" subtracted by 1.
*/
// solhint-disable-next-line private-vars-leading-underscore
bytes32 internal constant ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;
/**
* @dev Returns the current admin.
*
* TIP: To get this value clients can read directly from the storage slot shown below (specified by ERC-1967) using
* the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.
* `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`
*/
function getAdmin() internal view returns (address) {
return StorageSlot.getAddressSlot(ADMIN_SLOT).value;
}
/**
* @dev Stores a new address in the ERC-1967 admin slot.
*/
function _setAdmin(address newAdmin) private {
if (newAdmin == address(0)) {
revert ERC1967InvalidAdmin(address(0));
}
StorageSlot.getAddressSlot(ADMIN_SLOT).value = newAdmin;
}
/**
* @dev Changes the admin of the proxy.
*
* Emits an {IERC1967-AdminChanged} event.
*/
function changeAdmin(address newAdmin) internal {
emit IERC1967.AdminChanged(getAdmin(), newAdmin);
_setAdmin(newAdmin);
}
/**
* @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.
* This is the keccak-256 hash of "eip1967.proxy.beacon" subtracted by 1.
*/
// solhint-disable-next-line private-vars-leading-underscore
bytes32 internal constant BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;
/**
* @dev Returns the current beacon.
*/
function getBeacon() internal view returns (address) {
return StorageSlot.getAddressSlot(BEACON_SLOT).value;
}
/**
* @dev Stores a new beacon in the ERC-1967 beacon slot.
*/
function _setBeacon(address newBeacon) private {
if (newBeacon.code.length == 0) {
revert ERC1967InvalidBeacon(newBeacon);
}
StorageSlot.getAddressSlot(BEACON_SLOT).value = newBeacon;
address beaconImplementation = IBeacon(newBeacon).implementation();
if (beaconImplementation.code.length == 0) {
revert ERC1967InvalidImplementation(beaconImplementation);
}
}
/**
* @dev Change the beacon and trigger a setup call if data is nonempty.
* This function is payable only if the setup call is performed, otherwise `msg.value` is rejected
* to avoid stuck value in the contract.
*
* Emits an {IERC1967-BeaconUpgraded} event.
*
* CAUTION: Invoking this function has no effect on an instance of {BeaconProxy} since v5, since
* it uses an immutable beacon without looking at the value of the ERC-1967 beacon slot for
* efficiency.
*/
function upgradeBeaconToAndCall(address newBeacon, bytes memory data) internal {
_setBeacon(newBeacon);
emit IERC1967.BeaconUpgraded(newBeacon);
if (data.length > 0) {
Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);
} else {
_checkNonPayable();
}
}
/**
* @dev Reverts if `msg.value` is not zero. It can be used to avoid `msg.value` stuck in the contract
* if an upgrade doesn't perform an initialization call.
*/
function _checkNonPayable() private {
if (msg.value > 0) {
revert ERC1967NonPayable();
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (interfaces/IERC1363.sol)
pragma solidity >=0.6.2;
import {IERC20} from "./IERC20.sol";
import {IERC165} from "./IERC165.sol";
/**
* @title IERC1363
* @dev Interface of the ERC-1363 standard as defined in the https://eips.ethereum.org/EIPS/eip-1363[ERC-1363].
*
* Defines an extension interface for ERC-20 tokens that supports executing code on a recipient contract
* after `transfer` or `transferFrom`, or code on a spender contract after `approve`, in a single transaction.
*/
interface IERC1363 is IERC20, IERC165 {
/*
* Note: the ERC-165 identifier for this interface is 0xb0202a11.
* 0xb0202a11 ===
* bytes4(keccak256('transferAndCall(address,uint256)')) ^
* bytes4(keccak256('transferAndCall(address,uint256,bytes)')) ^
* bytes4(keccak256('transferFromAndCall(address,address,uint256)')) ^
* bytes4(keccak256('transferFromAndCall(address,address,uint256,bytes)')) ^
* bytes4(keccak256('approveAndCall(address,uint256)')) ^
* bytes4(keccak256('approveAndCall(address,uint256,bytes)'))
*/
/**
* @dev Moves a `value` amount of tokens from the caller's account to `to`
* and then calls {IERC1363Receiver-onTransferReceived} on `to`.
* @param to The address which you want to transfer to.
* @param value The amount of tokens to be transferred.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function transferAndCall(address to, uint256 value) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from the caller's account to `to`
* and then calls {IERC1363Receiver-onTransferReceived} on `to`.
* @param to The address which you want to transfer to.
* @param value The amount of tokens to be transferred.
* @param data Additional data with no specified format, sent in call to `to`.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function transferAndCall(address to, uint256 value, bytes calldata data) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from `from` to `to` using the allowance mechanism
* and then calls {IERC1363Receiver-onTransferReceived} on `to`.
* @param from The address which you want to send tokens from.
* @param to The address which you want to transfer to.
* @param value The amount of tokens to be transferred.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function transferFromAndCall(address from, address to, uint256 value) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from `from` to `to` using the allowance mechanism
* and then calls {IERC1363Receiver-onTransferReceived} on `to`.
* @param from The address which you want to send tokens from.
* @param to The address which you want to transfer to.
* @param value The amount of tokens to be transferred.
* @param data Additional data with no specified format, sent in call to `to`.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function transferFromAndCall(address from, address to, uint256 value, bytes calldata data) external returns (bool);
/**
* @dev Sets a `value` amount of tokens as the allowance of `spender` over the
* caller's tokens and then calls {IERC1363Spender-onApprovalReceived} on `spender`.
* @param spender The address which will spend the funds.
* @param value The amount of tokens to be spent.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function approveAndCall(address spender, uint256 value) external returns (bool);
/**
* @dev Sets a `value` amount of tokens as the allowance of `spender` over the
* caller's tokens and then calls {IERC1363Spender-onApprovalReceived} on `spender`.
* @param spender The address which will spend the funds.
* @param value The amount of tokens to be spent.
* @param data Additional data with no specified format, sent in call to `spender`.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function approveAndCall(address spender, uint256 value, bytes calldata data) external returns (bool);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)
pragma solidity ^0.8.20;
import {Initializable} from "../proxy/utils/Initializable.sol";
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract ContextUpgradeable is Initializable {
function __Context_init() internal onlyInitializing {
}
function __Context_init_unchained() internal onlyInitializing {
}
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
function _contextSuffixLength() internal view virtual returns (uint256) {
return 0;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (proxy/beacon/IBeacon.sol)
pragma solidity >=0.4.16;
/**
* @dev This is the interface that {BeaconProxy} expects of its beacon.
*/
interface IBeacon {
/**
* @dev Must return an address that can be used as a delegate call target.
*
* {UpgradeableBeacon} will check that this address is a contract.
*/
function implementation() external view returns (address);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC1967.sol)
pragma solidity >=0.4.11;
/**
* @dev ERC-1967: Proxy Storage Slots. This interface contains the events defined in the ERC.
*/
interface IERC1967 {
/**
* @dev Emitted when the implementation is upgraded.
*/
event Upgraded(address indexed implementation);
/**
* @dev Emitted when the admin account has changed.
*/
event AdminChanged(address previousAdmin, address newAdmin);
/**
* @dev Emitted when the beacon is changed.
*/
event BeaconUpgraded(address indexed beacon);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.2.0) (utils/Address.sol)
pragma solidity ^0.8.20;
import {Errors} from "./Errors.sol";
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev There's no code at `target` (it is not a contract).
*/
error AddressEmptyCode(address target);
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
if (address(this).balance < amount) {
revert Errors.InsufficientBalance(address(this).balance, amount);
}
(bool success, bytes memory returndata) = recipient.call{value: amount}("");
if (!success) {
_revert(returndata);
}
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason or custom error, it is bubbled
* up by this function (like regular Solidity function calls). However, if
* the call reverted with no returned reason, this function reverts with a
* {Errors.FailedCall} error.
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
if (address(this).balance < value) {
revert Errors.InsufficientBalance(address(this).balance, value);
}
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResultFromTarget(target, success, returndata);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResultFromTarget(target, success, returndata);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResultFromTarget(target, success, returndata);
}
/**
* @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target
* was not a contract or bubbling up the revert reason (falling back to {Errors.FailedCall}) in case
* of an unsuccessful call.
*/
function verifyCallResultFromTarget(
address target,
bool success,
bytes memory returndata
) internal view returns (bytes memory) {
if (!success) {
_revert(returndata);
} else {
// only check if target is a contract if the call was successful and the return data is empty
// otherwise we already know that it was a contract
if (returndata.length == 0 && target.code.length == 0) {
revert AddressEmptyCode(target);
}
return returndata;
}
}
/**
* @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the
* revert reason or with a default {Errors.FailedCall} error.
*/
function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) {
if (!success) {
_revert(returndata);
} else {
return returndata;
}
}
/**
* @dev Reverts with returndata if present. Otherwise reverts with {Errors.FailedCall}.
*/
function _revert(bytes memory returndata) private pure {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
assembly ("memory-safe") {
revert(add(returndata, 0x20), mload(returndata))
}
} else {
revert Errors.FailedCall();
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/StorageSlot.sol)
// This file was procedurally generated from scripts/generate/templates/StorageSlot.js.
pragma solidity ^0.8.20;
/**
* @dev Library for reading and writing primitive types to specific storage slots.
*
* Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.
* This library helps with reading and writing to such slots without the need for inline assembly.
*
* The functions in this library return Slot structs that contain a `value` member that can be used to read or write.
*
* Example usage to set ERC-1967 implementation slot:
* ```solidity
* contract ERC1967 {
* // Define the slot. Alternatively, use the SlotDerivation library to derive the slot.
* bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
*
* function _getImplementation() internal view returns (address) {
* return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;
* }
*
* function _setImplementation(address newImplementation) internal {
* require(newImplementation.code.length > 0);
* StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
* }
* }
* ```
*
* TIP: Consider using this library along with {SlotDerivation}.
*/
library StorageSlot {
struct AddressSlot {
address value;
}
struct BooleanSlot {
bool value;
}
struct Bytes32Slot {
bytes32 value;
}
struct Uint256Slot {
uint256 value;
}
struct Int256Slot {
int256 value;
}
struct StringSlot {
string value;
}
struct BytesSlot {
bytes value;
}
/**
* @dev Returns an `AddressSlot` with member `value` located at `slot`.
*/
function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {
assembly ("memory-safe") {
r.slot := slot
}
}
/**
* @dev Returns a `BooleanSlot` with member `value` located at `slot`.
*/
function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {
assembly ("memory-safe") {
r.slot := slot
}
}
/**
* @dev Returns a `Bytes32Slot` with member `value` located at `slot`.
*/
function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {
assembly ("memory-safe") {
r.slot := slot
}
}
/**
* @dev Returns a `Uint256Slot` with member `value` located at `slot`.
*/
function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {
assembly ("memory-safe") {
r.slot := slot
}
}
/**
* @dev Returns a `Int256Slot` with member `value` located at `slot`.
*/
function getInt256Slot(bytes32 slot) internal pure returns (Int256Slot storage r) {
assembly ("memory-safe") {
r.slot := slot
}
}
/**
* @dev Returns a `StringSlot` with member `value` located at `slot`.
*/
function getStringSlot(bytes32 slot) internal pure returns (StringSlot storage r) {
assembly ("memory-safe") {
r.slot := slot
}
}
/**
* @dev Returns an `StringSlot` representation of the string storage pointer `store`.
*/
function getStringSlot(string storage store) internal pure returns (StringSlot storage r) {
assembly ("memory-safe") {
r.slot := store.slot
}
}
/**
* @dev Returns a `BytesSlot` with member `value` located at `slot`.
*/
function getBytesSlot(bytes32 slot) internal pure returns (BytesSlot storage r) {
assembly ("memory-safe") {
r.slot := slot
}
}
/**
* @dev Returns an `BytesSlot` representation of the bytes storage pointer `store`.
*/
function getBytesSlot(bytes storage store) internal pure returns (BytesSlot storage r) {
assembly ("memory-safe") {
r.slot := store.slot
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC20.sol)
pragma solidity >=0.4.16;
import {IERC20} from "../token/ERC20/IERC20.sol";// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC165.sol)
pragma solidity >=0.4.16;
import {IERC165} from "../utils/introspection/IERC165.sol";// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/Errors.sol)
pragma solidity ^0.8.20;
/**
* @dev Collection of common custom errors used in multiple contracts
*
* IMPORTANT: Backwards compatibility is not guaranteed in future versions of the library.
* It is recommended to avoid relying on the error API for critical functionality.
*
* _Available since v5.1._
*/
library Errors {
/**
* @dev The ETH balance of the account is not enough to perform the operation.
*/
error InsufficientBalance(uint256 balance, uint256 needed);
/**
* @dev A call to an address target failed. The target may have reverted.
*/
error FailedCall();
/**
* @dev The deployment failed.
*/
error FailedDeployment();
/**
* @dev A necessary precompile is missing.
*/
error MissingPrecompile(address);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/introspection/IERC165.sol)
pragma solidity >=0.4.16;
/**
* @dev Interface of the ERC-165 standard, as defined in the
* https://eips.ethereum.org/EIPS/eip-165[ERC].
*
* Implementers can declare support of contract interfaces, which can then be
* queried by others ({ERC165Checker}).
*
* For an implementation, see {ERC165}.
*/
interface IERC165 {
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[ERC section]
* to learn more about how these ids are created.
*
* This function call must use less than 30 000 gas.
*/
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}{
"remappings": [
"ds-test/=lib/forge-std/lib/ds-test/src/",
"forge-std/=lib/forge-std/src/",
"@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/",
"@openzeppelin/contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/",
"@reality.eth/contracts/=lib/reality-eth-monorepo/packages/contracts/",
"erc4626-tests/=lib/openzeppelin-contracts-upgradeable/lib/erc4626-tests/",
"halmos-cheatcodes/=lib/openzeppelin-contracts-upgradeable/lib/halmos-cheatcodes/src/",
"hardhat/=node_modules/hardhat/",
"openzeppelin-contracts-upgradeable.git/=lib/openzeppelin-contracts-upgradeable.git/",
"openzeppelin-contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/",
"openzeppelin-contracts.git/=lib/openzeppelin-contracts.git/",
"openzeppelin-contracts/=lib/openzeppelin-contracts/",
"reality-eth-monorepo/=lib/reality-eth-monorepo/"
],
"optimizer": {
"enabled": true,
"runs": 1
},
"metadata": {
"useLiteralContent": false,
"bytecodeHash": "ipfs",
"appendCBOR": true
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"evmVersion": "paris",
"viaIR": true
}Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"address","name":"target","type":"address"}],"name":"AddressEmptyCode","type":"error"},{"inputs":[{"internalType":"address","name":"implementation","type":"address"}],"name":"ERC1967InvalidImplementation","type":"error"},{"inputs":[],"name":"ERC1967NonPayable","type":"error"},{"inputs":[],"name":"FailedCall","type":"error"},{"inputs":[],"name":"InvalidInitialization","type":"error"},{"inputs":[],"name":"NotInitializing","type":"error"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"OwnableInvalidOwner","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"OwnableUnauthorizedAccount","type":"error"},{"inputs":[],"name":"ReentrancyGuardReentrantCall","type":"error"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"SafeERC20FailedOperation","type":"error"},{"inputs":[],"name":"UUPSUnauthorizedCallContext","type":"error"},{"inputs":[{"internalType":"bytes32","name":"slot","type":"bytes32"}],"name":"UUPSUnsupportedProxiableUUID","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"manager","type":"address"},{"indexed":false,"internalType":"bool","name":"allowed","type":"bool"}],"name":"AllowedManagerSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint64","name":"version","type":"uint64"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"enum PredictionMarketV3_4.MarketAction","name":"action","type":"uint8"},{"indexed":true,"internalType":"uint256","name":"marketId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"outcomeId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"shares","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"}],"name":"MarketActionTx","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"uint256","name":"marketId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"closesAtTimestamp","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"}],"name":"MarketCloseDateEdited","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"uint256","name":"marketId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"outcomes","type":"uint256"},{"indexed":false,"internalType":"string","name":"question","type":"string"},{"indexed":false,"internalType":"string","name":"image","type":"string"},{"indexed":false,"internalType":"contract IERC20","name":"token","type":"address"}],"name":"MarketCreated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"marketId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"price","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"}],"name":"MarketLiquidity","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"marketId","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"outcomeId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"}],"name":"MarketOutcomePrice","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"marketId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"},{"indexed":false,"internalType":"uint256[]","name":"outcomeShares","type":"uint256[]"},{"indexed":false,"internalType":"uint256","name":"liquidity","type":"uint256"}],"name":"MarketOutcomeShares","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"uint256","name":"marketId","type":"uint256"},{"indexed":false,"internalType":"bool","name":"paused","type":"bool"},{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"}],"name":"MarketPaused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"uint256","name":"marketId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"outcomeId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"},{"indexed":false,"internalType":"bool","name":"admin","type":"bool"}],"name":"MarketResolved","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferStarted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bool","name":"paused","type":"bool"},{"indexed":true,"internalType":"address","name":"user","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"uint256","name":"marketId","type":"uint256"},{"indexed":false,"internalType":"string","name":"code","type":"string"},{"indexed":false,"internalType":"enum PredictionMarketV3_4.MarketAction","name":"action","type":"uint8"},{"indexed":false,"internalType":"uint256","name":"outcomeId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"}],"name":"Referral","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"implementation","type":"address"}],"name":"Upgraded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"}],"name":"Withdrawal","type":"event"},{"inputs":[],"name":"MAX_FEE","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MAX_OUTCOMES","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MINIMUM_REALITIO_TIMEOUT","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"UPGRADE_INTERFACE_VERSION","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"WETH","outputs":[{"internalType":"contract IWETH","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"acceptOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"marketId","type":"uint256"},{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"uint256","name":"minSharesIn","type":"uint256"}],"name":"addLiquidity","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"marketId","type":"uint256"}],"name":"adminPauseMarket","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"marketId","type":"uint256"},{"internalType":"uint256","name":"outcomeId","type":"uint256"}],"name":"adminResolveMarketOutcome","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"marketId","type":"uint256"},{"internalType":"uint256","name":"closesAt","type":"uint256"}],"name":"adminSetMarketCloseDate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"marketId","type":"uint256"}],"name":"adminUnpauseMarket","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"marketId","type":"uint256"},{"internalType":"uint256","name":"outcomeId","type":"uint256"},{"internalType":"uint256","name":"minOutcomeSharesToBuy","type":"uint256"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"buy","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"marketId","type":"uint256"},{"internalType":"uint256","name":"outcomeId","type":"uint256"},{"internalType":"uint256","name":"minOutcomeSharesToBuy","type":"uint256"}],"name":"buyWithETH","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"marketId","type":"uint256"},{"internalType":"uint256","name":"outcomeId","type":"uint256"}],"name":"calcBuyAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"marketId","type":"uint256"},{"internalType":"uint256","name":"outcomeId","type":"uint256"}],"name":"calcSellAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"marketId","type":"uint256"}],"name":"claimFees","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"marketId","type":"uint256"}],"name":"claimLiquidity","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"marketId","type":"uint256"},{"internalType":"uint256","name":"outcomeId","type":"uint256"}],"name":"claimVoidedOutcomeShares","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"marketId","type":"uint256"}],"name":"claimWinnings","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"uint32","name":"closesAt","type":"uint32"},{"internalType":"uint256","name":"outcomes","type":"uint256"},{"internalType":"contract IERC20","name":"token","type":"address"},{"internalType":"uint256[]","name":"distribution","type":"uint256[]"},{"internalType":"string","name":"question","type":"string"},{"internalType":"string","name":"image","type":"string"},{"internalType":"address","name":"arbitrator","type":"address"},{"components":[{"internalType":"uint256","name":"fee","type":"uint256"},{"internalType":"uint256","name":"treasuryFee","type":"uint256"},{"internalType":"uint256","name":"distributorFee","type":"uint256"}],"internalType":"struct PredictionMarketV3_4.Fees","name":"buyFees","type":"tuple"},{"components":[{"internalType":"uint256","name":"fee","type":"uint256"},{"internalType":"uint256","name":"treasuryFee","type":"uint256"},{"internalType":"uint256","name":"distributorFee","type":"uint256"}],"internalType":"struct PredictionMarketV3_4.Fees","name":"sellFees","type":"tuple"},{"internalType":"address","name":"treasury","type":"address"},{"internalType":"address","name":"distributor","type":"address"},{"internalType":"uint32","name":"realitioTimeout","type":"uint32"},{"internalType":"contract IPredictionMarketV3Manager","name":"manager","type":"address"}],"internalType":"struct PredictionMarketV3_4.CreateMarketDescription","name":"desc","type":"tuple"}],"name":"createMarket","outputs":[{"internalType":"uint256","name":"marketId","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"marketId","type":"uint256"}],"name":"getMarketAltData","outputs":[{"internalType":"uint256","name":"buyFee","type":"uint256"},{"internalType":"bytes32","name":"questionId","type":"bytes32"},{"internalType":"uint256","name":"questionIdUint","type":"uint256"},{"internalType":"contract IERC20","name":"token","type":"address"},{"internalType":"uint256","name":"buyTreasuryFee","type":"uint256"},{"internalType":"address","name":"treasury","type":"address"},{"internalType":"contract IRealityETH_ERC20","name":"realitio","type":"address"},{"internalType":"uint256","name":"realitioTimeout","type":"uint256"},{"internalType":"contract IPredictionMarketV3Manager","name":"manager","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"marketId","type":"uint256"}],"name":"getMarketBuyFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"marketId","type":"uint256"}],"name":"getMarketCreator","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"marketId","type":"uint256"}],"name":"getMarketData","outputs":[{"internalType":"enum PredictionMarketV3_4.MarketState","name":"state","type":"uint8"},{"internalType":"uint256","name":"closesAt","type":"uint256"},{"internalType":"uint256","name":"liquidity","type":"uint256"},{"internalType":"uint256","name":"balance","type":"uint256"},{"internalType":"uint256","name":"sharesAvailable","type":"uint256"},{"internalType":"int256","name":"resolvedOutcomeId","type":"int256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"marketId","type":"uint256"}],"name":"getMarketFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"marketId","type":"uint256"}],"name":"getMarketFees","outputs":[{"components":[{"internalType":"uint256","name":"fee","type":"uint256"},{"internalType":"uint256","name":"treasuryFee","type":"uint256"},{"internalType":"uint256","name":"distributorFee","type":"uint256"}],"internalType":"struct PredictionMarketV3_4.Fees","name":"buyFees","type":"tuple"},{"components":[{"internalType":"uint256","name":"fee","type":"uint256"},{"internalType":"uint256","name":"treasuryFee","type":"uint256"},{"internalType":"uint256","name":"distributorFee","type":"uint256"}],"internalType":"struct PredictionMarketV3_4.Fees","name":"sellFees","type":"tuple"},{"internalType":"address","name":"treasury","type":"address"},{"internalType":"address","name":"distributor","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"marketId","type":"uint256"}],"name":"getMarketLiquidityPrice","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"marketId","type":"uint256"},{"internalType":"uint256","name":"outcomeId","type":"uint256"}],"name":"getMarketOutcomeData","outputs":[{"internalType":"uint256","name":"price","type":"uint256"},{"internalType":"uint256","name":"availableShares","type":"uint256"},{"internalType":"uint256","name":"totalShares","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"marketId","type":"uint256"}],"name":"getMarketOutcomeIds","outputs":[{"internalType":"uint256[]","name":"outcomeIds","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"marketId","type":"uint256"},{"internalType":"uint256","name":"outcomeId","type":"uint256"}],"name":"getMarketOutcomePrice","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"marketId","type":"uint256"}],"name":"getMarketOutcomesShares","outputs":[{"internalType":"uint256[]","name":"shares","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"marketId","type":"uint256"}],"name":"getMarketPaused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"marketId","type":"uint256"}],"name":"getMarketPrices","outputs":[{"internalType":"uint256","name":"liquidity","type":"uint256"},{"internalType":"uint256[]","name":"outcomes","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"marketId","type":"uint256"}],"name":"getMarketQuestion","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"marketId","type":"uint256"}],"name":"getMarketResolvedOutcome","outputs":[{"internalType":"int256","name":"","type":"int256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"marketId","type":"uint256"}],"name":"getMarketSellFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"marketId","type":"uint256"}],"name":"getMarketShares","outputs":[{"internalType":"uint256","name":"liquidity","type":"uint256"},{"internalType":"uint256[]","name":"outcomes","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"marketId","type":"uint256"}],"name":"getMarketState","outputs":[{"internalType":"enum PredictionMarketV3_4.MarketState","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getMarkets","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"marketId","type":"uint256"},{"internalType":"address","name":"user","type":"address"}],"name":"getUserClaimStatus","outputs":[{"internalType":"bool","name":"winningsToClaim","type":"bool"},{"internalType":"bool","name":"winningsClaimed","type":"bool"},{"internalType":"bool","name":"liquidityToClaim","type":"bool"},{"internalType":"bool","name":"liquidityClaimed","type":"bool"},{"internalType":"uint256","name":"claimableFees","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"marketId","type":"uint256"},{"internalType":"address","name":"user","type":"address"}],"name":"getUserClaimableFees","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"marketId","type":"uint256"},{"internalType":"address","name":"user","type":"address"}],"name":"getUserLiquidityPoolShare","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"marketId","type":"uint256"},{"internalType":"address","name":"user","type":"address"}],"name":"getUserMarketShares","outputs":[{"internalType":"uint256","name":"liquidity","type":"uint256"},{"internalType":"uint256[]","name":"outcomes","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract IWETH","name":"_WETH","type":"address"},{"internalType":"address","name":"initialOwner","type":"address"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"marketId","type":"uint256"}],"name":"isMarketVoided","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"marketIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"uint32","name":"closesAt","type":"uint32"},{"internalType":"uint256","name":"outcomes","type":"uint256"},{"internalType":"contract IERC20","name":"token","type":"address"},{"internalType":"uint256[]","name":"distribution","type":"uint256[]"},{"internalType":"string","name":"question","type":"string"},{"internalType":"string","name":"image","type":"string"},{"internalType":"address","name":"arbitrator","type":"address"},{"components":[{"internalType":"uint256","name":"fee","type":"uint256"},{"internalType":"uint256","name":"treasuryFee","type":"uint256"},{"internalType":"uint256","name":"distributorFee","type":"uint256"}],"internalType":"struct PredictionMarketV3_4.Fees","name":"buyFees","type":"tuple"},{"components":[{"internalType":"uint256","name":"fee","type":"uint256"},{"internalType":"uint256","name":"treasuryFee","type":"uint256"},{"internalType":"uint256","name":"distributorFee","type":"uint256"}],"internalType":"struct PredictionMarketV3_4.Fees","name":"sellFees","type":"tuple"},{"internalType":"address","name":"treasury","type":"address"},{"internalType":"address","name":"distributor","type":"address"},{"internalType":"uint32","name":"realitioTimeout","type":"uint32"},{"internalType":"contract IPredictionMarketV3Manager","name":"manager","type":"address"}],"internalType":"struct PredictionMarketV3_4.CreateMarketDescription","name":"desc","type":"tuple"}],"name":"mintAndCreateMarket","outputs":[{"internalType":"uint256","name":"marketId","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pendingOwner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"proxiableUUID","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"marketId","type":"uint256"},{"internalType":"uint256","name":"outcomeId","type":"uint256"},{"internalType":"uint256","name":"minOutcomeSharesToBuy","type":"uint256"},{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"string","name":"code","type":"string"}],"name":"referralBuy","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"marketId","type":"uint256"},{"internalType":"uint256","name":"outcomeId","type":"uint256"},{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"uint256","name":"maxOutcomeSharesToSell","type":"uint256"},{"internalType":"string","name":"code","type":"string"}],"name":"referralSell","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"marketId","type":"uint256"},{"internalType":"uint256","name":"shares","type":"uint256"},{"internalType":"uint256","name":"minValueOut","type":"uint256"}],"name":"removeLiquidity","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"marketId","type":"uint256"}],"name":"resolveMarketOutcome","outputs":[{"internalType":"uint256","name":"outcomeId","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"marketId","type":"uint256"},{"internalType":"uint256","name":"outcomeId","type":"uint256"},{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"uint256","name":"maxOutcomeSharesToSell","type":"uint256"}],"name":"sell","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"marketId","type":"uint256"},{"internalType":"uint256","name":"outcomeId","type":"uint256"},{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"uint256","name":"maxOutcomeSharesToSell","type":"uint256"}],"name":"sellToETH","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"manager","type":"address"},{"internalType":"bool","name":"allowed","type":"bool"}],"name":"setAllowedManager","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"unpause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newImplementation","type":"address"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"upgradeToAndCall","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"},{"stateMutability":"payable","type":"receive"}]Contract Creation Code
60a080604052346100ea57306080527ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a005460ff8160401c166100d9576002600160401b03196001600160401b03821601610073575b60405161583e90816100f0823960805181818161219b01526122400152f35b6001600160401b0319166001600160401b039081177ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a005581527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d290602090a13880610054565b63f92ee8a960e01b60005260046000fd5b600080fdfe60806040526004361015610043575b361561001957600080fd5b6004546001600160a01b0316330361002d57005b634e487b7160e01b600052600160045260246000fd5b6000803560e01c806305a7e5b714612f9d5780631281311d14612f525780631d7920aa14612eb857806327694c2014612e3957806328747a8014612cee5780632a41839014612ccf5780632c2aa24e14612c805780632de0f31614612bf657806331877a3814612b9557806332900f761461199b5780633620875e14612b4e57806336ad8a7a14612b185780633f4ba83a14612ac4578063422f104314612659578063429c9dff1461263f5780634397c4ce14612612578063441cf65e146125e9578063485cc955146124265780634d4f2283146123f15780634f1ef286146121f057806352d1902d1461218857806356d7364a1461201e5780635c975abb14611ff85780635e648eff14611e3457806364c3bfa814611cba578063677bd9ff14611b21578063715018a614611ab2578063757f013514611a0b57806379ba5097146119ba5780637ef1c3c71461199b5780638056ae791461182d5780638456cb59146117d1578063857620e11461137057806385b91d8e1461130257806388b1f1c3146112d45780638c7adc15146112b65780638cd415521461129c5780638da5cb5b14611266578063aa22a02e146111e0578063ac68a74814611197578063ad3cb1cc1461114e578063ad5c464814611125578063b02ed3db14611067578063b31eb89514610fc7578063bb98617314610fa7578063bc063e1a14610f85578063bf45572114610f66578063bfacba3d14610ef4578063c346a9d014610eda578063c8f70d0114610ebb578063cf4d92af14610e9e578063d450deca14610d87578063daaa14a314610ce2578063dc73d16414610cc7578063e30c397814610c91578063ec2c901614610c27578063ec93f0f514610a40578063ef83950a1461082e578063efce4313146107df578063f17d9a081461061f578063f2fde38b14610597578063f3fef3a314610527578063f8544cf9146103405763fdff80851461030f575061000e565b3461033d57604036600319011261033d57602061033561032d613098565b600435613e85565b604051908152f35b80fd5b503461033d5761034f36613286565b90610358613f0d565b81359061036760208401613e42565b90606084019361037685613d9f565b906080810135601e1982360301811215610523578101803591906001600160401b03831161051f57602001908260051b3603821361051f576103bb60a0820182613e53565b906103c960c0840184613e53565b90916103d760e08601613d9f565b936103e56101c08701613d9f565b966103f36101e08801613d9f565b986104016102008901613e42565b9a6102208901359c8d60018060a01b0316809e0361033d57508e906040519e8f9261042b846130f5565b835263ffffffff16602083015260408a810135908301526001600160a01b031660609091015261045d91369190613dc4565b60808c0152369061046d92613180565b60a08a0152369061047d92613180565b60c08801526001600160a01b031660e087015261049e366101008301613e10565b6101008701526104b390369061016001613e10565b6101208601526001600160a01b039081166101408601521661016084015263ffffffff166101808301526101a08201526104ec9061495d565b916104f690613d9f565b90303361050293613f49565b600160008051602061578983398151915255604051908152602090f35b8480fd5b8380fd5b503461033d57604036600319011261033d57610541613082565b6024359061054d61428b565b6001600160a01b03169061056281338461468b565b6040519081524260208201527fc2b4a290c20fb28939d29f102514fbffd2b73c059ffba8b78250c94161d5fcc660403392a380f35b503461033d57602036600319011261033d576105b1613082565b6105b961428b565b6000805160206157e983398151915280546001600160a01b0319166001600160a01b039283169081179091556000805160206156e9833981519152549091167f38d16b8cac22d99fc7c124b9cd0de2d3fa1faef420bfe791d8c362d765e227008380a380f35b503461033d5761062e3661320c565b61063b60025483106136fe565b818352600160205260ff60066040852001541660038110156107cb576002610664911415613343565b8183526001602090815260408085206018810154601782015492516359938d0d60e11b81529193919283916001600160a01b0390811691839182916106af91339116600484016137a8565b03915afa9081156107c0578591610791575b501561074c5742821115610707578190556040519081524260208201527fac5024ecf1999919faf1b53c3551ee68ef67d27d28c7d043c5d340b495450b5460403392a380f35b60405162461bcd60e51b815260206004820152601e60248201527f7265736f6c7574696f6e206265666f72652063757272656e74206461746500006044820152606490fd5b60405162461bcd60e51b815260206004820152601d60248201527f6e6f7420616c6c6f77656420746f2073657420636c6f736520646174650000006044820152606490fd5b6107b3915060203d6020116107b9575b6107ab8183613142565b810190613790565b386106c1565b503d6107a1565b6040513d87823e3d90fd5b634e487b7160e01b84526021600452602484fd5b503461033d5761081160406107f33661320c565b91909384815260016020526016828220018382526020522092613900565b61082a60026003840154930154604051938493846132ba565b0390f35b503461033d5761083d36613286565b90610846613f0d565b60608201916001600160a01b0361085c84613d9f565b1692813593803b15610523578380916044604051809481936340c10f1960e01b83523060048401528a60248401525af18015610a3557908491610a20575b505061024082360312610a1c57604051936108b4856130f5565b84526108c260208301613db3565b602085015260408281013590850152356001600160a01b0381168103610a1c57606084015260808101356001600160401b038111610a1c57810136601f82011215610a1c57610918903690602081359101613dc4565b608084015260a08101356001600160401b038111610a1c5761093d90369083016131b7565b60a084015260c08101356001600160401b038111610a1c579061096661022092369083016131b7565b60c085015261097760e082016130ae565b60e085015261098a366101008301613e10565b61010085015261099e366101608301613e10565b6101208501526109b16101c082016130ae565b6101408501526109c46101e082016130ae565b6101608501526109d76102008201613db3565b6101808501520135906001600160a01b038216820361033d576020610a0284846101a082015261495d565b600160008051602061578983398151915255604051908152f35b8280fd5b81610a2a91613142565b610a1c57823861089a565b6040513d86823e3d90fd5b503461033d57610a4f3661320c565b90610a58613f0d565b808352600160205260ff60066040852001541660038110156107cb576002610a809114613343565b610a9260ff60045460a01c161561372f565b8083526001602052610ab160ff601960408620015460a01c161561375f565b80835260016020526040832090828452601682016020526040842092610ad6826136c4565b15610bfc57600782918560066004610be798019160018060a01b03331660005282602052610b0a60406000205415156147c8565b0160018060a01b03331660005280602052610b2d60ff60406000205416156147f9565b6001670de0b6b3a7640000610b60610b458689613900565b838060a01b0333166000528560205260406000205490613549565b049701610b7a888254610b7582821015614659565b613595565b905533600081815260209283526040808220805460ff19166001179055939092529082902054915190926000805160206156c9833981519152928291610bc59142918b91908561426f565b0390a483526001602052604083206017015433906001600160a01b031661468b565b60016000805160206157898339815191525580f35b60405162461bcd60e51b815260206004820152600360248201526210b6bb60e91b6044820152606490fd5b503461033d578060031936011261033d5760405180916020815492838152019181805260208220915b818110610c7b5761082a85610c6781870382613142565b604051918291602083526020830190613011565b8254845260209093019260019283019201610c50565b503461033d578060031936011261033d576000805160206157e9833981519152546040516001600160a01b039091168152602090f35b503461033d578060031936011261033d576020604051818152f35b503461033d57610d3f610d1c6000805160206157c9833981519152610d06366131d2565b939691929590610d14613f0d565b8387896143a4565b8688526001602052604088206017015490929033906001600160a01b031661468b565b610d546040519260a0845260a0840190613245565b9360016020840152604083015260608201524260808201528033930390a360016000805160206157898339815191525580f35b503461033d5780610de3610d9a3661305f565b91819493610dd660018060a01b0360045416610db78115156139fa565b828952600160205260408920601701546001600160a01b031614613a2b565b610dde613f0d565b6143a4565b506004546001600160a01b0316803b15610e9a57828091602460405180948193632e1a7d4d60e01b83528760048401525af1908115610e8f578391610e77575b50808092335af1610e32613d6f565b5015610e4d5760016000805160206157898339815191525580f35b60405162461bcd60e51b8152602060048201526002602482015261217360f01b6044820152606490fd5b81610e8191613142565b610e8c578138610e23565b50fd5b6040513d85823e3d90fd5b5050fd5b503461033d578060031936011261033d576020604051610e108152f35b503461033d57602036600319011261033d576020610335600435613c22565b503461033d576020610335610eee366130db565b91613ae3565b503461033d57602036600319011261033d5760c090604060043591828152600160205220610f21826137c2565b918154916002810154610f3d6003600184015493015493613ab0565b93610f4b6040518097613222565b602086015260408501526060840152608083015260a0820152f35b503461033d57602036600319011261033d576020610335600435613ab0565b503461033d578060031936011261033d57602060405166b1a2bc2ec500008152f35b503461033d57602036600319011261033d5761082a610c67600435613a5c565b503461033d57604036600319011261033d57610fe1613098565b6004358252600160205260408220601581015491610ffe836132e7565b926001600160a01b039091169060168301855b8281106110395785600486866000520160205260406000205461082a60405192839283613045565b8060019188528260205260406004818a200160009087825260205220546110608289613319565b5201611011565b50611071366130db565b600454919392916110af906001600160a01b03166110908115156139fa565b838552600160205260408520601701546001600160a01b031614613a2b565b6110b7613f0d565b6004546001600160a01b0316803b15610523578360049160405192838092630d0e30db60e41b825234905af18015610a3557611111575b506110fb92933492613fe0565b5060016000805160206157898339815191525580f35b9261111f816110fb95613142565b926110ee565b503461033d578060031936011261033d576004546040516001600160a01b039091168152602090f35b503461033d578060031936011261033d575061082a604051611171604082613142565b60058152640352e302e360dc1b6020820152604051918291602083526020830190613245565b503461033d57602036600319011261033d57610be76004356111b7613f0d565b6111c08161482a565b9083526001602052604083206017015433906001600160a01b031661468b565b503461033d57604036600319011261033d576111fa613098565b60043582526001602052604082209060018060a01b0316825260048101602052604082205491670de0b6b3a7640000830292808404670de0b6b3a764000014901517156112525760206103358460028501549061358b565b634e487b7160e01b81526011600452602490fd5b503461033d578060031936011261033d576000805160206156e9833981519152546040516001600160a01b039091168152602090f35b503461033d5760206103356112b03661320c565b90613900565b503461033d578060031936011261033d576020600254604051908152f35b503461033d57602036600319011261033d5760206112f36004356137c2565b6113006040518092613222565bf35b503461033d57602036600319011261033d5760043580825260016020526015604083200154611330816132e7565b925b818110611352578361134384613c22565b61082a60405192839283613045565b8061135f60019285613900565b6113698287613319565b5201611332565b503461033d5761137f366130db565b9091611389613f0d565b80845260016020526040842054421015806117ae575b6117a0575b808452600160205260ff600660408620015416600381101561178c576113ca9015613343565b6113dc60ff60045460a01c161561372f565b80845260016020526113fb60ff601960408720015460a01c161561375f565b808452600160205260408420926002840192835482101561176157338652600485016020819052604087205490949061143690841115614627565b83875260016020526040872061148c600c600b8301928354936114748c61146b611460888c613549565b60028601549061358b565b96879150613595565b9055338b5201602081905260408a2054909290613595565b33895260209190915260408820556114a384613a5c565b92601587018054966114b4886132e7565b976000198b5b82811061173c57506114cc9085613549565b6114d88654809261358b565b97888d5b8c888683106116f1575050509150506114f6915088615464565b611501838554613595565b8455338a52602081905260408a205461151b908490613595565b338b5260209190915260408a2055885b815481101561156857806115416001928a613319565b5161154d575b0161152b565b61156361155a828b613319565b51828a336153ee565b611547565b509085929189978961157986613804565b8a9354935b84811061163e5750505050509082600360008051602061572983398151915293604051908a825260208201528760408201524260608201526000805160206156c983398151915260803392a4546115d483613c22565b6115e56040519283924291846132ba565b0390a281106116135790825260016020526040822060170154610be7919033906001600160a01b031661468b565b60405162461bcd60e51b81526020600482015260036024820152621d8f1b60ea1b6044820152606490fd5b839495969750611652816001939495613319565b51611666575b01908996959493929161157e565b8a8c866000805160206156c98339815191526116e9670de0b6b3a76400006116d66116bb60168c01878052806020526116a6600360408a2001548d613549565b908a895260205260036040892001549061358b565b6116d0896116c98189613319565b5197613319565b51613549565b0492604051918291339542918a8561426f565b0390a4611658565b8261172d6001956117128961170d611733966116d0878d613319565b61358b565b61171c8487613319565b526117278386613319565b51613595565b92613319565b520189906114dc565b611746818a613319565b51808311611758575b506001016114ba565b9150600161174f565b60405162461bcd60e51b81526020600482015260036024820152621ccf9b60ea1b6044820152606490fd5b634e487b7160e01b85526021600452602485fd5b6117a9816142c1565b6113a4565b50808452600160205260ff600660408620015416600381101561178c571561139f565b503461033d578060031936011261033d576117ea61428b565b6004546117fd60ff8260a01c16156134e7565b60ff60a01b1916600160a01b176004556040516001815233906000805160206156a983398151915290602090a280f35b503461033d5761183c3661320c565b9091828152600160205260ff6006604083200154166003811015611987576002611867911415613343565b8281526001602090815260408083206018810154601782015492516359938d0d60e11b8152919693919283916001600160a01b0390811691839182916118b391339116600484016137a8565b03915afa908115610e8f578391611968575b50156119235782600860209501558060405184815242868201526001604082015260008051602061568983398151915260603392a361190381614301565b815260018352604090819020600601805460ff1916600217905551908152f35b60405162461bcd60e51b815260206004820152601d60248201527f6e6f7420616c6c6f77656420746f207265736f6c7665206d61726b65740000006044820152606490fd5b611981915060203d6020116107b9576107ab8183613142565b386118c5565b634e487b7160e01b82526021600452602482fd5b503461033d57602036600319011261033d5760206103356004356134c2565b503461033d578060031936011261033d576000805160206157e983398151915254336001600160a01b03909116036119f8576119f533614901565b80f35b63118cdaa760e01b815233600452602490fd5b503461033d57611a6a6000805160206157c9833981519152611a2c366131d2565b92949395908092611a3b613f0d565b87895260016020526040892060170154611a63908390309033906001600160a01b0316613f49565b8688613fe0565b50611a806040519260a0845260a0840190613245565b93866020840152604083015260608201524260808201528033930390a360016000805160206157898339815191525580f35b503461033d578060031936011261033d57611acb61428b565b6000805160206157e983398151915280546001600160a01b03199081169091556000805160206156e98339815191528054918216905581906001600160a01b03166000805160206157498339815191528280a380f35b503461033d57602036600319011261033d57600435611b3e613f0d565b808252600160205260ff6006604084200154166003811015611ca6576002611b669114613343565b611b7860ff60045460a01c161561372f565b8082526001602052611b9760ff601960408520015460a01c161561375f565b8082526001602052604082206008810191825484526016820160205260408420611bc0826136c4565b611c7c57338552600481810160208190526040872054610be7968594909160059190611bed9015156147c8565b338a520160208190526040892054611c089060ff16156147f9565b338952602083905260408920546001979097018054611c2f908990610b7582821015614659565b905533808a5260209182526040808b20805460ff191660011790559254818b529390915281892054915190926000805160206156c9833981519152928291610bc59142918b91908561426f565b60405162461bcd60e51b815260206004820152600260248201526136bb60f11b6044820152606490fd5b634e487b7160e01b83526021600452602483fd5b503461033d57602036600319011261033d57600435611cdc60025482106136fe565b808252600160205260ff601960408420015460a01c1615611e0957611cff613f0d565b8082526001602090815260408084206018810154601782015492516359938d0d60e11b81529193919283916001600160a01b039081169183918291611d4a91339116600484016137a8565b03915afa908115610a35578491611dea575b5015611da557601901805460ff60a01b1916905560408051838152426020820152339160008051602061576983398151915291a360016000805160206157898339815191525580f35b60405162461bcd60e51b815260206004820152601d60248201527f6e6f7420616c6c6f77656420746f20756e7061757365206d61726b65740000006044820152606490fd5b611e03915060203d6020116107b9576107ab8183613142565b38611d5c565b60405162461bcd60e51b81526020600482015260036024820152620216d760ec1b6044820152606490fd5b503461033d57602036600319011261033d57600435611e51613f0d565b808252600160205260ff6006604084200154166003811015611ca6576002611e799114613343565b611e8b60ff60045460a01c161561372f565b8082526001602052611eaa60ff601960408520015460a01c161561375f565b8082526001602052611fbe60408320916004830160018060a01b033316855280602052611edc604086205415156147c8565b3385526005840160208190526040862054611efa9060ff16156147f9565b6001670de0b6b3a7640000611f2a611f1186613c22565b838060a01b0333168a528560205260408a205490613549565b049501611f3f868254610b7582821015614659565b90553380875260209182526040808820805460ff191660011790558188529282528287205483518881529283015291810185905242606082015282916005916000805160206156c983398151915290608090a480845260016020526040842060170180549093611fb99133906001600160a01b031661468b565b61482a565b80611fda575b8260016000805160206157898339815191525580f35b9054611ff1919033906001600160a01b031661468b565b3880611fc4565b503461033d578060031936011261033d57602060ff60045460a01c166040519015158152f35b503461033d57602036600319011261033d5760043561204060025482106136fe565b61205260ff60045460a01c161561372f565b808252600160205261207160ff601960408520015460a01c161561375f565b612079613f0d565b8082526001602090815260408084206018810154601782015492516359938d0d60e11b81529193919283916001600160a01b0390811691839182916120c491339116600484016137a8565b03915afa908115610a35578491612169575b501561212657601901805460ff60a01b1916600160a01b1790556040805160018152426020820152339160008051602061576983398151915291a360016000805160206157898339815191525580f35b60405162461bcd60e51b815260206004820152601b60248201527a1b9bdd08185b1b1bddd959081d1bc81c185d5cd9481b585c9ad95d602a1b6044820152606490fd5b612182915060203d6020116107b9576107ab8183613142565b386120d6565b503461033d578060031936011261033d577f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031630036121e15760206040516000805160206157098339815191528152f35b63703e46dd60e11b8152600490fd5b50604036600319011261033d57612205613082565b906024356001600160401b0381116123ed57366023820112156123ed57612236903690602481600401359101613180565b6001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000163081149081156123ca575b506123bb5761227861428b565b6040516352d1902d60e01b8152926001600160a01b0381169190602085600481865afa80958596612387575b506122bd57634c9c8ce360e01b84526004839052602484fd5b90918460008051602061570983398151915281036123755750813b156123635760008051602061570983398151915280546001600160a01b031916821790557fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b8480a28151839015612349578083602061234595519101845af461233f613d6f565b91615627565b5080f35b505050346123545780f35b63b398979f60e01b8152600490fd5b634c9c8ce360e01b8452600452602483fd5b632a87526960e21b8552600452602484fd5b9095506020813d6020116123b3575b816123a360209383613142565b8101031261051f575194386122a4565b3d9150612396565b63703e46dd60e11b8252600482fd5b600080516020615709833981519152546001600160a01b0316141590503861226b565b5080fd5b503461033d57602036600319011261033d5760ff6019604060209360043581526001855220015460a01c166040519015158152f35b503461033d57604036600319011261033d576004356001600160a01b038116908190036123ed57612455613098565b6000805160206157a983398151915254604081901c60ff16159291906001600160401b038116801590816125e1575b60011490816125d7575b1590816125ce575b506125bf576001600160401b031981166001176000805160206157a98339815191525583612596575b506124c8615543565b6124d0615543565b6001600080516020615789833981519152556124ea615543565b6124f2615543565b6001600160a01b038116156125825761250a90614901565b612512615543565b600480546001600160a01b03191691909117905561252d5780f35b60ff60401b196000805160206157a983398151915254166000805160206157a9833981519152557fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d2602060405160018152a180f35b631e4fbdf760e01b84526004849052602484fd5b6001600160481b0319166001600160401b01176000805160206157a983398151915255386124bf565b63f92ee8a960e01b8552600485fd5b90501538612496565b303b15915061248e565b859150612484565b503461033d57602036600319011261033d5760206126086004356136c4565b6040519015158152f35b503461033d57602036600319011261033d5760096040602092600435815260018452200154604051908152f35b503461033d576020610335612653366130db565b916135d3565b503461033d57612668366130db565b91612671613f0d565b602093604051926126828685613142565b8184528136813782825260018652604082205442101580612aa2575b612a94575b8282526001865260ff6006604084200154166003811015611ca6576126c89015613343565b6126da60ff60045460a01c161561372f565b828252600186526126f860ff601960408520015460a01c161561375f565b82825260018652604082209461270f8215156146ed565b61271884613a5c565b60158701908154612728816132e7565b60028a0180549199909388939183156129c95761274690511561471e565b885b8281106129a45750885b828110612973575050509061170d61276a9287613549565b9161277583886154ec565b612780838354613375565b825533865260048901808b52604087205461279c908590613375565b338852908b5260408720556127b18588615362565b855b81548110156127f057806127c96001928b613319565b516127d5575b016127b3565b6127eb6127e2828c613319565b51828b336153ee565b6127cf565b50909193968693959861280285613804565b908a9354935b8b8d8683106128e257505050505050506000805160206157298339815191529061283183613c22565b908360028a8c88670de0b6b3a764000061284b8289613549565b049160405193845283015260408201524260608201526000805160206156c983398151915260803392a454906128886040519283924291846132ba565b0390a2106128b7578252600190925260408120601701549091610be791309033906001600160a01b0316613f49565b60405162461bcd60e51b81526004810185905260036024820152621ccf1b60ea1b6044820152606490fd5b9085858582999a9b946128f9876001999a9b613319565b51612912575b5050505050500190889594939291612808565b6116d66116bb670de0b6b3a7640000926000805160206156c98339815191529561295160166129649701918a8052828452600360408c20015490613549565b918b8a525260036040892001549061358b565b0390a4898c868f8688916128ff565b808c61299d8261172d8d6129978b61170d61299060019a8c613319565b5184613549565b90613595565b5201612752565b6129ae8183613319565b518086106129c0575b50600101612748565b945060016129b7565b9250509150805191826129e1575b5050508391612775565b8203612a67578690875b838110612a42575086885b8b858210612a06575050506129d7565b612a398261172d612a288861170d600198612a21868c613319565b5190613549565b612a3381151561471e565b8d613595565b520187906129f6565b612a4c8183613319565b51808410612a5e575b506001016129eb565b92506001612a55565b60405162461bcd60e51b8152600481018c9052600560248201526464213d6f6360d81b6044820152606490fd5b612a9d836142c1565b6126a3565b508282526001865260ff6006604084200154166003811015611ca6571561269e565b503461033d578060031936011261033d57612add61428b565b600454612aef60ff8260a01c166134e7565b60ff60a01b191660045560405181815233906000805160206156a983398151915290602090a280f35b503461033d57602036600319011261033d576020906004358152600182526019604060018060a01b039220015416604051908152f35b503461033d57610be7612b75612b633661305f565b90809492612b6f613f0d565b846143a4565b5083526001602052604083206017015433906001600160a01b031661468b565b503461033d57602036600319011261033d57600435815260016020526015604082200154612bc2816132e7565b915b818110612be1576040516020808252819061082a90820186613011565b8080612bef60019386613319565b5201612bc4565b503461033d57602036600319011261033d57604061010091612c1661347b565b50612c1f61347b565b506004358152600160205220600d810154600e8201546001600160a01b039081169116612c74612c5d6012612c56600f870161349a565b950161349a565b612c6a60405180966130c2565b60608501906130c2565b60c083015260e0820152f35b503461033d57604036600319011261033d5760a0612ca7612c9f613098565b6004356133c6565b9260409291925194151585521515602085015215156040840152151560608301526080820152f35b503461033d57602036600319011261033d576020610335600435613398565b503461033d57602036600319011261033d576004358082526001602052604082205442101580612e16575b612e08575b808252600160205260ff6006604084200154166003811015611ca6576001612d469114613343565b8082526001602052604082209060018060a01b03600783015416916020600982015460246040518096819363684e62bf60e11b835260048301525afa928315610a35578493612dd2575b509080602094846008610335950155604051908582524287830152604082015260008051602061568983398151915260603392a3612dcd81614301565b6142c1565b909192506020813d602011612e00575b81612def60209383613142565b810103126105235751919081612d90565b3d9150612de2565b612e11816142c1565b612d1e565b50808252600160205260ff6006604084200154166003811015611ca65715612d19565b503461033d57604036600319011261033d57612e53613082565b60243590811515809203610a1c5760207f27e8ce8763c0cbe1d9c8cc9c7ba821966e6c23ec9c1bbe62347d4f621f47378291612e8d61428b565b6001600160a01b0316808552600382526040808620805460ff191660ff87161790555193845292a280f35b503461033d57602036600319011261033d57600435815260016020908152604091829020600f810154600982015460178301546010840154600d8501546007860154600a8701546018909701548951968752978601859052978501939093526001600160a01b039182166060850152608084015290811660a083015293841660c082015260e0810191909152911661010082015261012090f35b503461033d576110fb612f643661305f565b92612f70929192613f0d565b80865260016020526040862060170154612f98908590309033906001600160a01b0316613f49565b613fe0565b503461033d57602036600319011261033d5760043581526001602052604081206015810154612fcb816132e7565b9260168301815b838110612fee5785600286015461082a60405192839283613045565b80600191845282602052600360408520015461300a8289613319565b5201612fd2565b906020808351928381520192019060005b81811061302f5750505090565b8251845260209384019390920191600101613022565b60409061305c939281528160208201520190613011565b90565b608090600319011261307d5760043590602435906044359060643590565b600080fd5b600435906001600160a01b038216820361307d57565b602435906001600160a01b038216820361307d57565b35906001600160a01b038216820361307d57565b6040809180518452602081015160208501520151910152565b606090600319011261307d57600435906024359060443590565b6101c081019081106001600160401b0382111761311157604052565b634e487b7160e01b600052604160045260246000fd5b606081019081106001600160401b0382111761311157604052565b601f909101601f19168101906001600160401b0382119082101761311157604052565b6001600160401b03811161311157601f01601f191660200190565b92919261318c82613165565b9161319a6040519384613142565b82948184528183011161307d578281602093846000960137010152565b9080601f8301121561307d5781602061305c93359101613180565b60a060031982011261307d5760043591602435916044359160643591608435906001600160401b03821161307d5761305c916004016131b7565b604090600319011261307d576004359060243590565b90600382101561322f5752565b634e487b7160e01b600052602160045260246000fd5b919082519283825260005b848110613271575050826000602080949584010152601f8019910116010190565b80602080928401015182828601015201613250565b602060031982011261307d57600435906001600160401b03821161307d5761024090829003600319011261307d5760040190565b6040919493926060820195825260208201520152565b6001600160401b0381116131115760051b60200190565b906132f1826132d0565b6132fe6040519182613142565b828152809261330f601f19916132d0565b0190602036910137565b805182101561332d5760209160051b010190565b634e487b7160e01b600052603260045260246000fd5b1561334a57565b60405162461bcd60e51b8152602060048201526003602482015262216d7360e81b6044820152606490fd5b9190820180921161338257565b634e487b7160e01b600052601160045260246000fd5b600052600160205261305c604060002060146133bd6012830154601384015490613375565b91015490613375565b91909180600052600160205260406000209160ff600684015416600381101561322f57600203613460576008830154600090815260168401602090815260408083206001600160a01b0388168452600480820184528285205460059283018552838620549189018552838620549290980190935292205460ff9182169692151595911693901515929161345891613e85565b919493929190565b929061346c9250613e85565b60009160009160009160009190565b6040519061348882613127565b60006040838281528260208201520152565b906040516134a781613127565b60406002829480548452600181015460208501520154910152565b600052600160205261305c604060002060116133bd600f830154601084015490613375565b156134ee57565b60405162461bcd60e51b8152602060048201526002602482015261021760f41b6044820152606490fd5b1561351f57565b60405162461bcd60e51b8152602060048201526002602482015261216f60f01b6044820152606490fd5b8181029291811591840414171561338257565b8015613575576a0c097ce7bc90715b34b9f160241b0490565b634e487b7160e01b600052601260045260246000fd5b8115613575570490565b9190820391821161338257565b156135a957565b60405162461bcd60e51b8152602060048201526002602482015261062360f41b6044820152606490fd5b929190806000526001602052613622601560406000200154946135f7868510613518565b670de0b6b3a764000061361b61361561360f86613a5c565b956134c2565b83613549565b0490613595565b9361362d8383613319565b5191670de0b6b3a76400008302838104670de0b6b3a76400001484151715613382579360005b838110613680575050505061367a61305c9394612997926136758515156135a2565b613375565b9161474f565b818103613690575b600101613653565b946136bc6001916136b68a6136b06136a88b89613319565b518094613549565b92613375565b90614798565b959050613688565b6000526001602052604060002060ff600682015416600381101561322f576002036136f85760156008820154910154111590565b50600090565b1561370557565b60405162461bcd60e51b8152602060048201526002602482015261216d60f01b6044820152606490fd5b1561373657565b60405162461bcd60e51b81526020600482015260016024820152600760fc1b6044820152606490fd5b1561376657565b60405162461bcd60e51b815260206004820152600260248201526106d760f41b6044820152606490fd5b9081602091031261307d5751801515810361307d5790565b6001600160a01b0391821681529116602082015260400190565b6000526001602052604060002060ff60068201541690600382101561322f57811590816137f8575b506137f25790565b50600190565b905054421015386137ea565b9081600052600160205260406000209160ff600684015416600381101561322f5760021490816138ef575b506138d157670de0b6b3a76400006000601660158501549401935b80821061385e57505061305c91925061355c565b909182156138c8576000805284602052600360406000200154670de0b6b3a7640000810290808204670de0b6b3a76400001490151715613382576001916138b96138bf9286600052886020526003604060002001549061358b565b90613375565b925b019061384a565b916001906138c1565b9060080154156000146138ea57670de0b6b3a764000090565b600090565b6138f991506136c4565b153861382f565b919082600052600160205260406000209260ff600685015416600381101561322f5760021490816139e9575b506139cf5791670de0b6b3a764000090600090601660158201549101945b81831061395f5750505061305c91925061355c565b9091928184146139c6578160005285602052600360406000200154670de0b6b3a7640000810290808204670de0b6b3a76400001490151715613382576001916138b96139bc9287600052896020526003604060002001549061358b565b935b01919061394a565b926001906139be565b909160080154146000146138ea57670de0b6b3a764000090565b6139f391506136c4565b153861392c565b15613a0157565b60405162461bcd60e51b8152602060048201526002602482015261077360f41b6044820152606490fd5b15613a3257565b60405162461bcd60e51b8152602060048201526002602482015261217760f01b6044820152606490fd5b60005260016020526040600020906015820154613a78816132e7565b9260160160005b828110613a8b57505050565b8060019160005282602052600360406000200154613aa98288613319565b5201613a7f565b6000526001602052604060002060ff600682015416600381101561322f57600203613adc576008015490565b5060021990565b909182600052600160205260156040600020015491613b03838310613518565b613b15613b0f85613a5c565b94613398565b670de0b6b3a7640000820291808304670de0b6b3a7640000149015171561338257670de0b6b3a764000003670de0b6b3a7640000811161338257613b589161358b565b91613b638285613319565b5193670de0b6b3a76400008502858104670de0b6b3a76400001486151715613382579260005b838110613bb0575050505061305c92916138b982613bab610b759415156135a2565b61474f565b818103613bc0575b600101613b89565b93613bcb8584613319565b519086821115613bf757816136b688613be9600195613bef95613549565b92613595565b949050613bb8565b60405162461bcd60e51b815260206004820152600360248201526221736160e81b6044820152606490fd5b80600052600160205260406000209060ff600683015416600381101561322f576002149081613d5e575b50613d175760008091601581015492601682015b848210613cee575050670de0b6b3a7640000830292808404670de0b6b3a76400001481151715613382576a0c097ce7bc90715b34b9f160241b810293808504670de0b6b3a76400001490151715613382576f29c30f1029939b146664242d97d9f64960361b0292808404670de0b6b3a764000014901517156133825761305c92600261170d9201549061358b565b9092613d0f60019185600052836020526138b960036040600020015461355c565b930190613c60565b600881015460005260168101602052600360406000200154670de0b6b3a7640000810290808204670de0b6b3a7640000149015171561338257600261305c9201549061358b565b613d6891506136c4565b1538613c4c565b3d15613d9a573d90613d8082613165565b91613d8e6040519384613142565b82523d6000602084013e565b606090565b356001600160a01b038116810361307d5790565b359063ffffffff8216820361307d57565b929190613dd0816132d0565b93613dde6040519586613142565b602085838152019160051b810192831161307d57905b828210613e0057505050565b8135815260209182019101613df4565b919082606091031261307d57604051613e2881613127565b604080829480358452602081013560208501520135910152565b3563ffffffff8116810361307d5790565b903590601e198136030182121561307d57018035906001600160401b03821161307d5760200191813603831361307d57565b60005260016020526040600020600c613ec9613ebe600b84015460018060a01b0386166000526004850160205260406000205490613549565b60028401549061358b565b910160018060a01b038316600052806020528160406000205411613f055761305c9260018060a01b031660005260205260406000205490613595565b505050600090565b60026000805160206157898339815191525414613f3857600260008051602061578983398151915255565b633ee5aeb560e01b60005260046000fd5b6040516323b872dd60e01b60009081526001600160a01b039384166004529290931660245260449390935260209060648180865af190600160005114821615613fbe575b604052600060605215613f9d5750565b635274afe760e01b60009081526001600160a01b0391909116600452602490fd5b906001811516613fd657823b15153d15161690613f8d565b503d6000823e3d90fd5b909181600052600160205260406000205442101580614219575b61420b575b81600052600160205260ff60066040600020015416600381101561322f576140279015613343565b61403960ff60045460a01c161561372f565b81600052600160205261405a60ff60196040600020015460a01c161561375f565b8160005260016020526040600020926140748184876135d3565b9182106141e05761408682151561423e565b6140b9600b8501670de0b6b3a76400006140a4600f88015489613549565b04906140b1828254613375565b905586613595565b92670de0b6b3a76400006140d1601087015488613549565b04928060036140fc670de0b6b3a76400006140f060118b01548c613549565b04976129978989613375565b856000526016890160205261411660406000209186615362565b0154106141b5576000816000805160206156c983398151915261415486614143879661415c9988336153ee565b6040519182918d339642928561426f565b0390a4614301565b8061418e575b508061416d57505090565b6017820154600e9092015461305c926001600160a01b03918216911661468b565b6017830154600d8401546141af92916001600160a01b03918216911661468b565b38614162565b606460405162461bcd60e51b81526020600482015260046024820152630733c73760e41b6044820152fd5b60405162461bcd60e51b8152602060048201526003602482015262733c6d60e81b6044820152606490fd5b614214826142c1565b613fff565b5081600052600160205260ff60066040600020015416600381101561322f5715613ffa565b1561424557565b60405162461bcd60e51b8152602060048201526002602482015261073360f41b6044820152606490fd5b9094939260609260808301968352602083015260408201520152565b6000805160206156e9833981519152546001600160a01b031633036142ac57565b63118cdaa760e01b6000523360045260246000fd5b6000526001602052600660406000200160ff815416600381101561322f576001810180911161338257600381101561322f5760ff80198354169116179055565b806000526001602052604060002060158101549061431e826132e7565b916016820160005b82811061437f575050507fb1bbae7680415a1349ae813ba7d737ca09df07db1f6ce058b3e0812ec15e8886916002614374920154604051928392428452606060208501526060840190613011565b9060408301520390a2565b806001916000528260205260036040600020015461439d8288613319565b5201614326565b91909282600052600160205260406000205442101580614602575b6145f4575b82600052600160205260ff60066040600020015416600381101561322f576143ec9015613343565b6143fe60ff60045460a01c161561372f565b82600052600160205261441f60ff60196040600020015460a01c161561375f565b82600052600160205260406000209284600052601684016020526040600020614449868386613ae3565b9283116145c95760049061445e84151561423e565b3360009081529101602052604090205461447a90831115614627565b8060005260016020526003604060002086600052601681016020528160406000206004810160018060a01b033316600052806020526144be87604060002054613595565b9060018060a01b033316600052602052604060002055016144e0858254613375565b9055016144ee838254613375565b90556144f981613398565b80670de0b6b3a76400000391670de0b6b3a76400008311613382578060016145b8956000805160206156c98339815191526145696145638861170d614597998e61455b8f8561170d614554926012600b870196015490613549565b8254613375565b90558d613549565b8a613375565b9a6145798c858d01541015614659565b6145838c86615464565b8b614154604051928392339642928561426f565b61170d6145ac8261170d601388015487613549565b93601486015490613549565b908061418e57508061416d57505090565b60405162461bcd60e51b8152602060048201526003602482015262733e6d60e81b6044820152606490fd5b6145fd836142c1565b6143c4565b5082600052600160205260ff60066040600020015416600381101561322f57156143bf565b1561462e57565b60405162461bcd60e51b81526020600482015260036024820152620e67cd60eb1b6044820152606490fd5b1561466057565b60405162461bcd60e51b8152602060048201526003602482015262311e3b60e91b6044820152606490fd5b60405163a9059cbb60e01b60009081526001600160a01b03909316600452602493909352919060209060448180865af1906001600051148216156146d5575b60405215613f9d5750565b906001811516613fd657823b15153d151616906146ca565b156146f457565b60405162461bcd60e51b8152602060048201526002602482015261076360f41b6044820152606490fd5b1561472557565b60405162461bcd60e51b8152602060048201526002602482015261085960f21b6044820152606490fd5b906000918061475b5750565b60001981019081116147845782670de0b6b3a76400009293505004600181018091116133825790565b634e487b7160e01b83526011600452602483fd5b90816147a5575050600090565b6000198201918211613382576147ba9161358b565b600181018091116133825790565b156147cf57565b60405162461bcd60e51b8152602060048201526002602482015261042d60f31b6044820152606490fd5b1561480057565b60405162461bcd60e51b8152602060048201526002602482015261216360f01b6044820152606490fd5b61483c60ff60045460a01c161561372f565b80600052600160205261485d60ff60196040600020015460a01c161561375f565b80600052600160205260406000209060046148783383613e85565b92836148c7575b60018060a01b033316600052016020526006604060002054604051906000825260208201528360408201524260608201526000805160206156c983398151915260803392a490565b600c810160018060a01b033316600052806020526148ea85604060002054613375565b33600090815260209290925260409091205561487f565b6000805160206157e983398151915280546001600160a01b03199081169091556000805160206156e983398151915280549182166001600160a01b039384169081179091559116600080516020615749833981519152600080a3565b9060025491600054600160401b81101561311157600181018060005581101561332d577f290decd9548b62a8d60345a988386fc84ba6bc95484008f6362f93160ef3e563018390556000838152600160209081526040918290206101a08401805160608601805195516323a4808b60e21b81526001600160a01b03968716600482015293979096909590949293929183916024918391165afa9081156151bc57600091615320575b5060018060a01b0316614a1a835115156146ed565b602083019563ffffffff8751164210156152f55760e0840180519093906001600160a01b0316156152cb5760408501978851600281101590816152bf575b501561529457831561526a57610180860190610e1063ffffffff8351161061523d5782516001600160a01b031660009081526003602052604090205460ff161561521257825189516040516325c7205960e01b81529160209183916001600160a01b039081169183918291614ad391339116600484016137a8565b03915afa9081156151bc576000916151f3575b50156151c85788516017850180546001600160a01b0319166001600160a01b0392909216919091179055805163ffffffff16845560068401805460ff191690556101008701805160409190614b3a90615571565b518051600f870155602081015160108701550151601185015560406101208801614b648151615571565b518051601287015560208082015160138801559101516014860155610140880151600d860180546001600160a01b03199081166001600160a01b03938416179091556101608a0151600e8801805490921690831617905560001960088701558b51601587015560a08901805198518551945160405163d4876b9f60e01b81526002600482015260e06024820152929a92958694859493169263ffffffff928316929190911690614c189060e4860190613245565b92604485015260648401526084830152600060a4830152600060c483015203816000895af19081156151bc57600091615187575b5060098401556007830180546001600160a01b03199081166001600160a01b0396871617909155905163ffffffff16600a8401559051601883018054831691909416179092556019018054909116331790558151608083015160008881526001602052604090205490969195919042101580615162575b615154575b87600052600160205260ff60066040600020015416600381101561322f57614cf09015613343565b614d0260ff60045460a01c161561372f565b876000526001602052614d2360ff60196040600020015460a01c161561375f565b876000526001602052604060002096614d3d8715156146ed565b6000614d488a613a5c565b978960158101928354614d5a816132e7565b9b6002839401968754938415156000146150855750908f97969594939291614d8390511561471e565b60005b82811061504e575060008e5b8382106150135750505050614db2839261170d614db993614e0196613549565b80966154ec565b614dc4858554613375565b845560048c0160018060a01b03331660005280602052614de986604060002054613375565b3360009081526020929092526040909120558c615362565b60005b8154811015614e4957808a8d82614e1d60019584613319565b51614e2c575b50505001614e04565b614e3981614e4194613319565b5191336153ee565b8a8d82614e23565b5090919293949596988a98614e5d8a613804565b9160009354935b848110614f7057505050505060c0614f5193886000805160206157298339815191527f57c2e8e67a3a13bc1991cd4ba3ed6733e269f1de098668140234d41dcb145ee4989795614f4395836002614eba82613c22565b93670de0b6b3a7640000614ece8287613549565b046040519160008352602083015260408201524260608201526000805160206156c983398151915260803392a45490614f0e6040519283924291846132ba565b0390a2614f1a89614301565b5194519601519160018060a01b0390511695604051948552608060208601526080850190613245565b908382036040850152613245565b9260608201528033930390a36002546001810180911161338257600255565b82939495969798999a9b50614f888160019394613319565b51614fa0575b01908c9a999897969594939291614e64565b8d6000614fd76016860182805280602052614fc260036040852001548a613549565b9085845260205260036040842001549061358b565b6000805160206156c983398151915261500b670de0b6b3a76400006116d6614fff888c613319565b51946116d0898d613319565b0390a4614f8e565b869798995061503d8261172d6150378961170d88999a9b9c612a218660019b613319565b8b613595565b5201908f979695949392918e614d92565b9091929394959697506150618183613319565b5180861061507c575b50600101908f97969594939291614d86565b9450600161506a565b93509193505080959493955192836150a5575b50505050614e0183614db9565b8303615127578582805b8581106150fc57505b8d8582106150c7575050615098565b6150f38261172d6150e28861170d600198612a21868c613319565b6150ed81151561471e565b8c613595565b520186906150b8565b9091506151098184613319565b5180851061511e575b506001019087916150af565b93506001615112565b60405162461bcd60e51b815260206004820152600560248201526464213d6f6360d81b6044820152606490fd5b61515d886142c1565b614cc8565b5087600052600160205260ff60066040600020015416600381101561322f5715614cc3565b9190506020823d6020116151b4575b816151a360209383613142565b8101031261307d5790516019614c4c565b3d9150615196565b6040513d6000823e3d90fd5b606460405162461bcd60e51b81526020600482015260046024820152636d213d6160e01b6044820152fd5b61520c915060203d6020116107b9576107ab8183613142565b38614ae6565b60405162461bcd60e51b815260206004820152600360248201526221616d60e81b6044820152606490fd5b60405162461bcd60e51b81526020600482015260056024820152640e4e87862d60db1b6044820152606490fd5b60405162461bcd60e51b8152602060048201526002602482015261072360f41b6044820152606490fd5b60405162461bcd60e51b8152602060048201526003602482015262216f6360e81b6044820152606490fd5b60209150111538614a58565b60405162461bcd60e51b8152602060048201526002602482015261061360f41b6044820152606490fd5b60405162461bcd60e51b8152602060048201526003602482015262319e3760e91b6044820152606490fd5b6020813d60201161535a575b8161533960209383613142565b810103126123ed5751906001600160a01b038216820361033d575038614a05565b3d915061532c565b919091600052600160205260406000206000906015810192601682019160038101935b85548110156153d3578060019160005284602052604060002060036002820191016153b18a8254613375565b90556153be898254613375565b90556153cb888754613375565b865501615385565b50909493506153ea92506001915001918254613375565b9055565b9160036153ea9381936000526001602052604060002092600052601683016020526040600020906004820160018060a01b0382166000528060205261543888604060002054613375565b9160018060a01b031660005260205260406000205501615459858254613595565b905501918254613595565b919091600052600160205260406000206000906015810192601682019160038101935b85548110156154d5578060019160005284602052604060002060036002820191016154b38a8254613595565b90556154c0898254613595565b90556154cd888754613595565b865501615487565b50909493506153ea92506001915001918254613595565b6000526001602052600c604060002061551961550e600b830194855490613549565b60028301549061358b565b92615525848254613375565b9055336000908152910160205260409020805490916153ea91613375565b60ff6000805160206157a98339815191525460401c161561556057565b631afcd79f60e31b60005260046000fd5b66b1a2bc2ec500008151116155fc5766b1a2bc2ec500006020820151116155d157604066b1a2bc2ec50000910151116155a657565b606460405162461bcd60e51b815260206004820152600460248201526364663e3560e01b6044820152fd5b606460405162461bcd60e51b815260206004820152600460248201526374663e3560e01b6044820152fd5b60405162461bcd60e51b8152602060048201526003602482015262663e3560e81b6044820152606490fd5b9061564d575080511561563c57602081519101fd5b63d6bda27560e01b60005260046000fd5b8151158061567f575b61565e575090565b639996b31560e01b60009081526001600160a01b0391909116600452602490fd5b50803b1561565656fe32c8457b93ca1561f798921516a9997de723415a87991bf1187b70434dc5cdeabe7c303f209cd18ec0555e186104232ac132a445e860bb535d9d28b9f76ad1fa9dcabe311735ed0d65f0c22c5425d1f17331f94c9d0767f59e58473cf95ada619016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c199300360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc1eca98f266e5348ae38d5d057a4d8e451e76672f69ac6ba4b0e3b31ea9c7eb2b8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e02365271d929532d684e6178b913d905d884cfec52891f3d66a6b042aaf0522959b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f00f0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00c993f9a8447446a00c879dadbeefa69111000411f1a1a9f67cf75a12ec08a3ec237e158222e3e6968b72b9db0d8043aacf074ad9f650f0d1606b4d82ee432c00a2646970667358221220a1e566c38918d7c738e9b048e72a39e5d29c01ea9f2e461b400248e54211527b64736f6c634300081a0033
Deployed Bytecode
0x60806040526004361015610043575b361561001957600080fd5b6004546001600160a01b0316330361002d57005b634e487b7160e01b600052600160045260246000fd5b6000803560e01c806305a7e5b714612f9d5780631281311d14612f525780631d7920aa14612eb857806327694c2014612e3957806328747a8014612cee5780632a41839014612ccf5780632c2aa24e14612c805780632de0f31614612bf657806331877a3814612b9557806332900f761461199b5780633620875e14612b4e57806336ad8a7a14612b185780633f4ba83a14612ac4578063422f104314612659578063429c9dff1461263f5780634397c4ce14612612578063441cf65e146125e9578063485cc955146124265780634d4f2283146123f15780634f1ef286146121f057806352d1902d1461218857806356d7364a1461201e5780635c975abb14611ff85780635e648eff14611e3457806364c3bfa814611cba578063677bd9ff14611b21578063715018a614611ab2578063757f013514611a0b57806379ba5097146119ba5780637ef1c3c71461199b5780638056ae791461182d5780638456cb59146117d1578063857620e11461137057806385b91d8e1461130257806388b1f1c3146112d45780638c7adc15146112b65780638cd415521461129c5780638da5cb5b14611266578063aa22a02e146111e0578063ac68a74814611197578063ad3cb1cc1461114e578063ad5c464814611125578063b02ed3db14611067578063b31eb89514610fc7578063bb98617314610fa7578063bc063e1a14610f85578063bf45572114610f66578063bfacba3d14610ef4578063c346a9d014610eda578063c8f70d0114610ebb578063cf4d92af14610e9e578063d450deca14610d87578063daaa14a314610ce2578063dc73d16414610cc7578063e30c397814610c91578063ec2c901614610c27578063ec93f0f514610a40578063ef83950a1461082e578063efce4313146107df578063f17d9a081461061f578063f2fde38b14610597578063f3fef3a314610527578063f8544cf9146103405763fdff80851461030f575061000e565b3461033d57604036600319011261033d57602061033561032d613098565b600435613e85565b604051908152f35b80fd5b503461033d5761034f36613286565b90610358613f0d565b81359061036760208401613e42565b90606084019361037685613d9f565b906080810135601e1982360301811215610523578101803591906001600160401b03831161051f57602001908260051b3603821361051f576103bb60a0820182613e53565b906103c960c0840184613e53565b90916103d760e08601613d9f565b936103e56101c08701613d9f565b966103f36101e08801613d9f565b986104016102008901613e42565b9a6102208901359c8d60018060a01b0316809e0361033d57508e906040519e8f9261042b846130f5565b835263ffffffff16602083015260408a810135908301526001600160a01b031660609091015261045d91369190613dc4565b60808c0152369061046d92613180565b60a08a0152369061047d92613180565b60c08801526001600160a01b031660e087015261049e366101008301613e10565b6101008701526104b390369061016001613e10565b6101208601526001600160a01b039081166101408601521661016084015263ffffffff166101808301526101a08201526104ec9061495d565b916104f690613d9f565b90303361050293613f49565b600160008051602061578983398151915255604051908152602090f35b8480fd5b8380fd5b503461033d57604036600319011261033d57610541613082565b6024359061054d61428b565b6001600160a01b03169061056281338461468b565b6040519081524260208201527fc2b4a290c20fb28939d29f102514fbffd2b73c059ffba8b78250c94161d5fcc660403392a380f35b503461033d57602036600319011261033d576105b1613082565b6105b961428b565b6000805160206157e983398151915280546001600160a01b0319166001600160a01b039283169081179091556000805160206156e9833981519152549091167f38d16b8cac22d99fc7c124b9cd0de2d3fa1faef420bfe791d8c362d765e227008380a380f35b503461033d5761062e3661320c565b61063b60025483106136fe565b818352600160205260ff60066040852001541660038110156107cb576002610664911415613343565b8183526001602090815260408085206018810154601782015492516359938d0d60e11b81529193919283916001600160a01b0390811691839182916106af91339116600484016137a8565b03915afa9081156107c0578591610791575b501561074c5742821115610707578190556040519081524260208201527fac5024ecf1999919faf1b53c3551ee68ef67d27d28c7d043c5d340b495450b5460403392a380f35b60405162461bcd60e51b815260206004820152601e60248201527f7265736f6c7574696f6e206265666f72652063757272656e74206461746500006044820152606490fd5b60405162461bcd60e51b815260206004820152601d60248201527f6e6f7420616c6c6f77656420746f2073657420636c6f736520646174650000006044820152606490fd5b6107b3915060203d6020116107b9575b6107ab8183613142565b810190613790565b386106c1565b503d6107a1565b6040513d87823e3d90fd5b634e487b7160e01b84526021600452602484fd5b503461033d5761081160406107f33661320c565b91909384815260016020526016828220018382526020522092613900565b61082a60026003840154930154604051938493846132ba565b0390f35b503461033d5761083d36613286565b90610846613f0d565b60608201916001600160a01b0361085c84613d9f565b1692813593803b15610523578380916044604051809481936340c10f1960e01b83523060048401528a60248401525af18015610a3557908491610a20575b505061024082360312610a1c57604051936108b4856130f5565b84526108c260208301613db3565b602085015260408281013590850152356001600160a01b0381168103610a1c57606084015260808101356001600160401b038111610a1c57810136601f82011215610a1c57610918903690602081359101613dc4565b608084015260a08101356001600160401b038111610a1c5761093d90369083016131b7565b60a084015260c08101356001600160401b038111610a1c579061096661022092369083016131b7565b60c085015261097760e082016130ae565b60e085015261098a366101008301613e10565b61010085015261099e366101608301613e10565b6101208501526109b16101c082016130ae565b6101408501526109c46101e082016130ae565b6101608501526109d76102008201613db3565b6101808501520135906001600160a01b038216820361033d576020610a0284846101a082015261495d565b600160008051602061578983398151915255604051908152f35b8280fd5b81610a2a91613142565b610a1c57823861089a565b6040513d86823e3d90fd5b503461033d57610a4f3661320c565b90610a58613f0d565b808352600160205260ff60066040852001541660038110156107cb576002610a809114613343565b610a9260ff60045460a01c161561372f565b8083526001602052610ab160ff601960408620015460a01c161561375f565b80835260016020526040832090828452601682016020526040842092610ad6826136c4565b15610bfc57600782918560066004610be798019160018060a01b03331660005282602052610b0a60406000205415156147c8565b0160018060a01b03331660005280602052610b2d60ff60406000205416156147f9565b6001670de0b6b3a7640000610b60610b458689613900565b838060a01b0333166000528560205260406000205490613549565b049701610b7a888254610b7582821015614659565b613595565b905533600081815260209283526040808220805460ff19166001179055939092529082902054915190926000805160206156c9833981519152928291610bc59142918b91908561426f565b0390a483526001602052604083206017015433906001600160a01b031661468b565b60016000805160206157898339815191525580f35b60405162461bcd60e51b815260206004820152600360248201526210b6bb60e91b6044820152606490fd5b503461033d578060031936011261033d5760405180916020815492838152019181805260208220915b818110610c7b5761082a85610c6781870382613142565b604051918291602083526020830190613011565b8254845260209093019260019283019201610c50565b503461033d578060031936011261033d576000805160206157e9833981519152546040516001600160a01b039091168152602090f35b503461033d578060031936011261033d576020604051818152f35b503461033d57610d3f610d1c6000805160206157c9833981519152610d06366131d2565b939691929590610d14613f0d565b8387896143a4565b8688526001602052604088206017015490929033906001600160a01b031661468b565b610d546040519260a0845260a0840190613245565b9360016020840152604083015260608201524260808201528033930390a360016000805160206157898339815191525580f35b503461033d5780610de3610d9a3661305f565b91819493610dd660018060a01b0360045416610db78115156139fa565b828952600160205260408920601701546001600160a01b031614613a2b565b610dde613f0d565b6143a4565b506004546001600160a01b0316803b15610e9a57828091602460405180948193632e1a7d4d60e01b83528760048401525af1908115610e8f578391610e77575b50808092335af1610e32613d6f565b5015610e4d5760016000805160206157898339815191525580f35b60405162461bcd60e51b8152602060048201526002602482015261217360f01b6044820152606490fd5b81610e8191613142565b610e8c578138610e23565b50fd5b6040513d85823e3d90fd5b5050fd5b503461033d578060031936011261033d576020604051610e108152f35b503461033d57602036600319011261033d576020610335600435613c22565b503461033d576020610335610eee366130db565b91613ae3565b503461033d57602036600319011261033d5760c090604060043591828152600160205220610f21826137c2565b918154916002810154610f3d6003600184015493015493613ab0565b93610f4b6040518097613222565b602086015260408501526060840152608083015260a0820152f35b503461033d57602036600319011261033d576020610335600435613ab0565b503461033d578060031936011261033d57602060405166b1a2bc2ec500008152f35b503461033d57602036600319011261033d5761082a610c67600435613a5c565b503461033d57604036600319011261033d57610fe1613098565b6004358252600160205260408220601581015491610ffe836132e7565b926001600160a01b039091169060168301855b8281106110395785600486866000520160205260406000205461082a60405192839283613045565b8060019188528260205260406004818a200160009087825260205220546110608289613319565b5201611011565b50611071366130db565b600454919392916110af906001600160a01b03166110908115156139fa565b838552600160205260408520601701546001600160a01b031614613a2b565b6110b7613f0d565b6004546001600160a01b0316803b15610523578360049160405192838092630d0e30db60e41b825234905af18015610a3557611111575b506110fb92933492613fe0565b5060016000805160206157898339815191525580f35b9261111f816110fb95613142565b926110ee565b503461033d578060031936011261033d576004546040516001600160a01b039091168152602090f35b503461033d578060031936011261033d575061082a604051611171604082613142565b60058152640352e302e360dc1b6020820152604051918291602083526020830190613245565b503461033d57602036600319011261033d57610be76004356111b7613f0d565b6111c08161482a565b9083526001602052604083206017015433906001600160a01b031661468b565b503461033d57604036600319011261033d576111fa613098565b60043582526001602052604082209060018060a01b0316825260048101602052604082205491670de0b6b3a7640000830292808404670de0b6b3a764000014901517156112525760206103358460028501549061358b565b634e487b7160e01b81526011600452602490fd5b503461033d578060031936011261033d576000805160206156e9833981519152546040516001600160a01b039091168152602090f35b503461033d5760206103356112b03661320c565b90613900565b503461033d578060031936011261033d576020600254604051908152f35b503461033d57602036600319011261033d5760206112f36004356137c2565b6113006040518092613222565bf35b503461033d57602036600319011261033d5760043580825260016020526015604083200154611330816132e7565b925b818110611352578361134384613c22565b61082a60405192839283613045565b8061135f60019285613900565b6113698287613319565b5201611332565b503461033d5761137f366130db565b9091611389613f0d565b80845260016020526040842054421015806117ae575b6117a0575b808452600160205260ff600660408620015416600381101561178c576113ca9015613343565b6113dc60ff60045460a01c161561372f565b80845260016020526113fb60ff601960408720015460a01c161561375f565b808452600160205260408420926002840192835482101561176157338652600485016020819052604087205490949061143690841115614627565b83875260016020526040872061148c600c600b8301928354936114748c61146b611460888c613549565b60028601549061358b565b96879150613595565b9055338b5201602081905260408a2054909290613595565b33895260209190915260408820556114a384613a5c565b92601587018054966114b4886132e7565b976000198b5b82811061173c57506114cc9085613549565b6114d88654809261358b565b97888d5b8c888683106116f1575050509150506114f6915088615464565b611501838554613595565b8455338a52602081905260408a205461151b908490613595565b338b5260209190915260408a2055885b815481101561156857806115416001928a613319565b5161154d575b0161152b565b61156361155a828b613319565b51828a336153ee565b611547565b509085929189978961157986613804565b8a9354935b84811061163e5750505050509082600360008051602061572983398151915293604051908a825260208201528760408201524260608201526000805160206156c983398151915260803392a4546115d483613c22565b6115e56040519283924291846132ba565b0390a281106116135790825260016020526040822060170154610be7919033906001600160a01b031661468b565b60405162461bcd60e51b81526020600482015260036024820152621d8f1b60ea1b6044820152606490fd5b839495969750611652816001939495613319565b51611666575b01908996959493929161157e565b8a8c866000805160206156c98339815191526116e9670de0b6b3a76400006116d66116bb60168c01878052806020526116a6600360408a2001548d613549565b908a895260205260036040892001549061358b565b6116d0896116c98189613319565b5197613319565b51613549565b0492604051918291339542918a8561426f565b0390a4611658565b8261172d6001956117128961170d611733966116d0878d613319565b61358b565b61171c8487613319565b526117278386613319565b51613595565b92613319565b520189906114dc565b611746818a613319565b51808311611758575b506001016114ba565b9150600161174f565b60405162461bcd60e51b81526020600482015260036024820152621ccf9b60ea1b6044820152606490fd5b634e487b7160e01b85526021600452602485fd5b6117a9816142c1565b6113a4565b50808452600160205260ff600660408620015416600381101561178c571561139f565b503461033d578060031936011261033d576117ea61428b565b6004546117fd60ff8260a01c16156134e7565b60ff60a01b1916600160a01b176004556040516001815233906000805160206156a983398151915290602090a280f35b503461033d5761183c3661320c565b9091828152600160205260ff6006604083200154166003811015611987576002611867911415613343565b8281526001602090815260408083206018810154601782015492516359938d0d60e11b8152919693919283916001600160a01b0390811691839182916118b391339116600484016137a8565b03915afa908115610e8f578391611968575b50156119235782600860209501558060405184815242868201526001604082015260008051602061568983398151915260603392a361190381614301565b815260018352604090819020600601805460ff1916600217905551908152f35b60405162461bcd60e51b815260206004820152601d60248201527f6e6f7420616c6c6f77656420746f207265736f6c7665206d61726b65740000006044820152606490fd5b611981915060203d6020116107b9576107ab8183613142565b386118c5565b634e487b7160e01b82526021600452602482fd5b503461033d57602036600319011261033d5760206103356004356134c2565b503461033d578060031936011261033d576000805160206157e983398151915254336001600160a01b03909116036119f8576119f533614901565b80f35b63118cdaa760e01b815233600452602490fd5b503461033d57611a6a6000805160206157c9833981519152611a2c366131d2565b92949395908092611a3b613f0d565b87895260016020526040892060170154611a63908390309033906001600160a01b0316613f49565b8688613fe0565b50611a806040519260a0845260a0840190613245565b93866020840152604083015260608201524260808201528033930390a360016000805160206157898339815191525580f35b503461033d578060031936011261033d57611acb61428b565b6000805160206157e983398151915280546001600160a01b03199081169091556000805160206156e98339815191528054918216905581906001600160a01b03166000805160206157498339815191528280a380f35b503461033d57602036600319011261033d57600435611b3e613f0d565b808252600160205260ff6006604084200154166003811015611ca6576002611b669114613343565b611b7860ff60045460a01c161561372f565b8082526001602052611b9760ff601960408520015460a01c161561375f565b8082526001602052604082206008810191825484526016820160205260408420611bc0826136c4565b611c7c57338552600481810160208190526040872054610be7968594909160059190611bed9015156147c8565b338a520160208190526040892054611c089060ff16156147f9565b338952602083905260408920546001979097018054611c2f908990610b7582821015614659565b905533808a5260209182526040808b20805460ff191660011790559254818b529390915281892054915190926000805160206156c9833981519152928291610bc59142918b91908561426f565b60405162461bcd60e51b815260206004820152600260248201526136bb60f11b6044820152606490fd5b634e487b7160e01b83526021600452602483fd5b503461033d57602036600319011261033d57600435611cdc60025482106136fe565b808252600160205260ff601960408420015460a01c1615611e0957611cff613f0d565b8082526001602090815260408084206018810154601782015492516359938d0d60e11b81529193919283916001600160a01b039081169183918291611d4a91339116600484016137a8565b03915afa908115610a35578491611dea575b5015611da557601901805460ff60a01b1916905560408051838152426020820152339160008051602061576983398151915291a360016000805160206157898339815191525580f35b60405162461bcd60e51b815260206004820152601d60248201527f6e6f7420616c6c6f77656420746f20756e7061757365206d61726b65740000006044820152606490fd5b611e03915060203d6020116107b9576107ab8183613142565b38611d5c565b60405162461bcd60e51b81526020600482015260036024820152620216d760ec1b6044820152606490fd5b503461033d57602036600319011261033d57600435611e51613f0d565b808252600160205260ff6006604084200154166003811015611ca6576002611e799114613343565b611e8b60ff60045460a01c161561372f565b8082526001602052611eaa60ff601960408520015460a01c161561375f565b8082526001602052611fbe60408320916004830160018060a01b033316855280602052611edc604086205415156147c8565b3385526005840160208190526040862054611efa9060ff16156147f9565b6001670de0b6b3a7640000611f2a611f1186613c22565b838060a01b0333168a528560205260408a205490613549565b049501611f3f868254610b7582821015614659565b90553380875260209182526040808820805460ff191660011790558188529282528287205483518881529283015291810185905242606082015282916005916000805160206156c983398151915290608090a480845260016020526040842060170180549093611fb99133906001600160a01b031661468b565b61482a565b80611fda575b8260016000805160206157898339815191525580f35b9054611ff1919033906001600160a01b031661468b565b3880611fc4565b503461033d578060031936011261033d57602060ff60045460a01c166040519015158152f35b503461033d57602036600319011261033d5760043561204060025482106136fe565b61205260ff60045460a01c161561372f565b808252600160205261207160ff601960408520015460a01c161561375f565b612079613f0d565b8082526001602090815260408084206018810154601782015492516359938d0d60e11b81529193919283916001600160a01b0390811691839182916120c491339116600484016137a8565b03915afa908115610a35578491612169575b501561212657601901805460ff60a01b1916600160a01b1790556040805160018152426020820152339160008051602061576983398151915291a360016000805160206157898339815191525580f35b60405162461bcd60e51b815260206004820152601b60248201527a1b9bdd08185b1b1bddd959081d1bc81c185d5cd9481b585c9ad95d602a1b6044820152606490fd5b612182915060203d6020116107b9576107ab8183613142565b386120d6565b503461033d578060031936011261033d577f000000000000000000000000537dc41fbb4f9faa4b9d6f8e6c2eb9071274f72b6001600160a01b031630036121e15760206040516000805160206157098339815191528152f35b63703e46dd60e11b8152600490fd5b50604036600319011261033d57612205613082565b906024356001600160401b0381116123ed57366023820112156123ed57612236903690602481600401359101613180565b6001600160a01b037f000000000000000000000000537dc41fbb4f9faa4b9d6f8e6c2eb9071274f72b163081149081156123ca575b506123bb5761227861428b565b6040516352d1902d60e01b8152926001600160a01b0381169190602085600481865afa80958596612387575b506122bd57634c9c8ce360e01b84526004839052602484fd5b90918460008051602061570983398151915281036123755750813b156123635760008051602061570983398151915280546001600160a01b031916821790557fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b8480a28151839015612349578083602061234595519101845af461233f613d6f565b91615627565b5080f35b505050346123545780f35b63b398979f60e01b8152600490fd5b634c9c8ce360e01b8452600452602483fd5b632a87526960e21b8552600452602484fd5b9095506020813d6020116123b3575b816123a360209383613142565b8101031261051f575194386122a4565b3d9150612396565b63703e46dd60e11b8252600482fd5b600080516020615709833981519152546001600160a01b0316141590503861226b565b5080fd5b503461033d57602036600319011261033d5760ff6019604060209360043581526001855220015460a01c166040519015158152f35b503461033d57604036600319011261033d576004356001600160a01b038116908190036123ed57612455613098565b6000805160206157a983398151915254604081901c60ff16159291906001600160401b038116801590816125e1575b60011490816125d7575b1590816125ce575b506125bf576001600160401b031981166001176000805160206157a98339815191525583612596575b506124c8615543565b6124d0615543565b6001600080516020615789833981519152556124ea615543565b6124f2615543565b6001600160a01b038116156125825761250a90614901565b612512615543565b600480546001600160a01b03191691909117905561252d5780f35b60ff60401b196000805160206157a983398151915254166000805160206157a9833981519152557fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d2602060405160018152a180f35b631e4fbdf760e01b84526004849052602484fd5b6001600160481b0319166001600160401b01176000805160206157a983398151915255386124bf565b63f92ee8a960e01b8552600485fd5b90501538612496565b303b15915061248e565b859150612484565b503461033d57602036600319011261033d5760206126086004356136c4565b6040519015158152f35b503461033d57602036600319011261033d5760096040602092600435815260018452200154604051908152f35b503461033d576020610335612653366130db565b916135d3565b503461033d57612668366130db565b91612671613f0d565b602093604051926126828685613142565b8184528136813782825260018652604082205442101580612aa2575b612a94575b8282526001865260ff6006604084200154166003811015611ca6576126c89015613343565b6126da60ff60045460a01c161561372f565b828252600186526126f860ff601960408520015460a01c161561375f565b82825260018652604082209461270f8215156146ed565b61271884613a5c565b60158701908154612728816132e7565b60028a0180549199909388939183156129c95761274690511561471e565b885b8281106129a45750885b828110612973575050509061170d61276a9287613549565b9161277583886154ec565b612780838354613375565b825533865260048901808b52604087205461279c908590613375565b338852908b5260408720556127b18588615362565b855b81548110156127f057806127c96001928b613319565b516127d5575b016127b3565b6127eb6127e2828c613319565b51828b336153ee565b6127cf565b50909193968693959861280285613804565b908a9354935b8b8d8683106128e257505050505050506000805160206157298339815191529061283183613c22565b908360028a8c88670de0b6b3a764000061284b8289613549565b049160405193845283015260408201524260608201526000805160206156c983398151915260803392a454906128886040519283924291846132ba565b0390a2106128b7578252600190925260408120601701549091610be791309033906001600160a01b0316613f49565b60405162461bcd60e51b81526004810185905260036024820152621ccf1b60ea1b6044820152606490fd5b9085858582999a9b946128f9876001999a9b613319565b51612912575b5050505050500190889594939291612808565b6116d66116bb670de0b6b3a7640000926000805160206156c98339815191529561295160166129649701918a8052828452600360408c20015490613549565b918b8a525260036040892001549061358b565b0390a4898c868f8688916128ff565b808c61299d8261172d8d6129978b61170d61299060019a8c613319565b5184613549565b90613595565b5201612752565b6129ae8183613319565b518086106129c0575b50600101612748565b945060016129b7565b9250509150805191826129e1575b5050508391612775565b8203612a67578690875b838110612a42575086885b8b858210612a06575050506129d7565b612a398261172d612a288861170d600198612a21868c613319565b5190613549565b612a3381151561471e565b8d613595565b520187906129f6565b612a4c8183613319565b51808410612a5e575b506001016129eb565b92506001612a55565b60405162461bcd60e51b8152600481018c9052600560248201526464213d6f6360d81b6044820152606490fd5b612a9d836142c1565b6126a3565b508282526001865260ff6006604084200154166003811015611ca6571561269e565b503461033d578060031936011261033d57612add61428b565b600454612aef60ff8260a01c166134e7565b60ff60a01b191660045560405181815233906000805160206156a983398151915290602090a280f35b503461033d57602036600319011261033d576020906004358152600182526019604060018060a01b039220015416604051908152f35b503461033d57610be7612b75612b633661305f565b90809492612b6f613f0d565b846143a4565b5083526001602052604083206017015433906001600160a01b031661468b565b503461033d57602036600319011261033d57600435815260016020526015604082200154612bc2816132e7565b915b818110612be1576040516020808252819061082a90820186613011565b8080612bef60019386613319565b5201612bc4565b503461033d57602036600319011261033d57604061010091612c1661347b565b50612c1f61347b565b506004358152600160205220600d810154600e8201546001600160a01b039081169116612c74612c5d6012612c56600f870161349a565b950161349a565b612c6a60405180966130c2565b60608501906130c2565b60c083015260e0820152f35b503461033d57604036600319011261033d5760a0612ca7612c9f613098565b6004356133c6565b9260409291925194151585521515602085015215156040840152151560608301526080820152f35b503461033d57602036600319011261033d576020610335600435613398565b503461033d57602036600319011261033d576004358082526001602052604082205442101580612e16575b612e08575b808252600160205260ff6006604084200154166003811015611ca6576001612d469114613343565b8082526001602052604082209060018060a01b03600783015416916020600982015460246040518096819363684e62bf60e11b835260048301525afa928315610a35578493612dd2575b509080602094846008610335950155604051908582524287830152604082015260008051602061568983398151915260603392a3612dcd81614301565b6142c1565b909192506020813d602011612e00575b81612def60209383613142565b810103126105235751919081612d90565b3d9150612de2565b612e11816142c1565b612d1e565b50808252600160205260ff6006604084200154166003811015611ca65715612d19565b503461033d57604036600319011261033d57612e53613082565b60243590811515809203610a1c5760207f27e8ce8763c0cbe1d9c8cc9c7ba821966e6c23ec9c1bbe62347d4f621f47378291612e8d61428b565b6001600160a01b0316808552600382526040808620805460ff191660ff87161790555193845292a280f35b503461033d57602036600319011261033d57600435815260016020908152604091829020600f810154600982015460178301546010840154600d8501546007860154600a8701546018909701548951968752978601859052978501939093526001600160a01b039182166060850152608084015290811660a083015293841660c082015260e0810191909152911661010082015261012090f35b503461033d576110fb612f643661305f565b92612f70929192613f0d565b80865260016020526040862060170154612f98908590309033906001600160a01b0316613f49565b613fe0565b503461033d57602036600319011261033d5760043581526001602052604081206015810154612fcb816132e7565b9260168301815b838110612fee5785600286015461082a60405192839283613045565b80600191845282602052600360408520015461300a8289613319565b5201612fd2565b906020808351928381520192019060005b81811061302f5750505090565b8251845260209384019390920191600101613022565b60409061305c939281528160208201520190613011565b90565b608090600319011261307d5760043590602435906044359060643590565b600080fd5b600435906001600160a01b038216820361307d57565b602435906001600160a01b038216820361307d57565b35906001600160a01b038216820361307d57565b6040809180518452602081015160208501520151910152565b606090600319011261307d57600435906024359060443590565b6101c081019081106001600160401b0382111761311157604052565b634e487b7160e01b600052604160045260246000fd5b606081019081106001600160401b0382111761311157604052565b601f909101601f19168101906001600160401b0382119082101761311157604052565b6001600160401b03811161311157601f01601f191660200190565b92919261318c82613165565b9161319a6040519384613142565b82948184528183011161307d578281602093846000960137010152565b9080601f8301121561307d5781602061305c93359101613180565b60a060031982011261307d5760043591602435916044359160643591608435906001600160401b03821161307d5761305c916004016131b7565b604090600319011261307d576004359060243590565b90600382101561322f5752565b634e487b7160e01b600052602160045260246000fd5b919082519283825260005b848110613271575050826000602080949584010152601f8019910116010190565b80602080928401015182828601015201613250565b602060031982011261307d57600435906001600160401b03821161307d5761024090829003600319011261307d5760040190565b6040919493926060820195825260208201520152565b6001600160401b0381116131115760051b60200190565b906132f1826132d0565b6132fe6040519182613142565b828152809261330f601f19916132d0565b0190602036910137565b805182101561332d5760209160051b010190565b634e487b7160e01b600052603260045260246000fd5b1561334a57565b60405162461bcd60e51b8152602060048201526003602482015262216d7360e81b6044820152606490fd5b9190820180921161338257565b634e487b7160e01b600052601160045260246000fd5b600052600160205261305c604060002060146133bd6012830154601384015490613375565b91015490613375565b91909180600052600160205260406000209160ff600684015416600381101561322f57600203613460576008830154600090815260168401602090815260408083206001600160a01b0388168452600480820184528285205460059283018552838620549189018552838620549290980190935292205460ff9182169692151595911693901515929161345891613e85565b919493929190565b929061346c9250613e85565b60009160009160009160009190565b6040519061348882613127565b60006040838281528260208201520152565b906040516134a781613127565b60406002829480548452600181015460208501520154910152565b600052600160205261305c604060002060116133bd600f830154601084015490613375565b156134ee57565b60405162461bcd60e51b8152602060048201526002602482015261021760f41b6044820152606490fd5b1561351f57565b60405162461bcd60e51b8152602060048201526002602482015261216f60f01b6044820152606490fd5b8181029291811591840414171561338257565b8015613575576a0c097ce7bc90715b34b9f160241b0490565b634e487b7160e01b600052601260045260246000fd5b8115613575570490565b9190820391821161338257565b156135a957565b60405162461bcd60e51b8152602060048201526002602482015261062360f41b6044820152606490fd5b929190806000526001602052613622601560406000200154946135f7868510613518565b670de0b6b3a764000061361b61361561360f86613a5c565b956134c2565b83613549565b0490613595565b9361362d8383613319565b5191670de0b6b3a76400008302838104670de0b6b3a76400001484151715613382579360005b838110613680575050505061367a61305c9394612997926136758515156135a2565b613375565b9161474f565b818103613690575b600101613653565b946136bc6001916136b68a6136b06136a88b89613319565b518094613549565b92613375565b90614798565b959050613688565b6000526001602052604060002060ff600682015416600381101561322f576002036136f85760156008820154910154111590565b50600090565b1561370557565b60405162461bcd60e51b8152602060048201526002602482015261216d60f01b6044820152606490fd5b1561373657565b60405162461bcd60e51b81526020600482015260016024820152600760fc1b6044820152606490fd5b1561376657565b60405162461bcd60e51b815260206004820152600260248201526106d760f41b6044820152606490fd5b9081602091031261307d5751801515810361307d5790565b6001600160a01b0391821681529116602082015260400190565b6000526001602052604060002060ff60068201541690600382101561322f57811590816137f8575b506137f25790565b50600190565b905054421015386137ea565b9081600052600160205260406000209160ff600684015416600381101561322f5760021490816138ef575b506138d157670de0b6b3a76400006000601660158501549401935b80821061385e57505061305c91925061355c565b909182156138c8576000805284602052600360406000200154670de0b6b3a7640000810290808204670de0b6b3a76400001490151715613382576001916138b96138bf9286600052886020526003604060002001549061358b565b90613375565b925b019061384a565b916001906138c1565b9060080154156000146138ea57670de0b6b3a764000090565b600090565b6138f991506136c4565b153861382f565b919082600052600160205260406000209260ff600685015416600381101561322f5760021490816139e9575b506139cf5791670de0b6b3a764000090600090601660158201549101945b81831061395f5750505061305c91925061355c565b9091928184146139c6578160005285602052600360406000200154670de0b6b3a7640000810290808204670de0b6b3a76400001490151715613382576001916138b96139bc9287600052896020526003604060002001549061358b565b935b01919061394a565b926001906139be565b909160080154146000146138ea57670de0b6b3a764000090565b6139f391506136c4565b153861392c565b15613a0157565b60405162461bcd60e51b8152602060048201526002602482015261077360f41b6044820152606490fd5b15613a3257565b60405162461bcd60e51b8152602060048201526002602482015261217760f01b6044820152606490fd5b60005260016020526040600020906015820154613a78816132e7565b9260160160005b828110613a8b57505050565b8060019160005282602052600360406000200154613aa98288613319565b5201613a7f565b6000526001602052604060002060ff600682015416600381101561322f57600203613adc576008015490565b5060021990565b909182600052600160205260156040600020015491613b03838310613518565b613b15613b0f85613a5c565b94613398565b670de0b6b3a7640000820291808304670de0b6b3a7640000149015171561338257670de0b6b3a764000003670de0b6b3a7640000811161338257613b589161358b565b91613b638285613319565b5193670de0b6b3a76400008502858104670de0b6b3a76400001486151715613382579260005b838110613bb0575050505061305c92916138b982613bab610b759415156135a2565b61474f565b818103613bc0575b600101613b89565b93613bcb8584613319565b519086821115613bf757816136b688613be9600195613bef95613549565b92613595565b949050613bb8565b60405162461bcd60e51b815260206004820152600360248201526221736160e81b6044820152606490fd5b80600052600160205260406000209060ff600683015416600381101561322f576002149081613d5e575b50613d175760008091601581015492601682015b848210613cee575050670de0b6b3a7640000830292808404670de0b6b3a76400001481151715613382576a0c097ce7bc90715b34b9f160241b810293808504670de0b6b3a76400001490151715613382576f29c30f1029939b146664242d97d9f64960361b0292808404670de0b6b3a764000014901517156133825761305c92600261170d9201549061358b565b9092613d0f60019185600052836020526138b960036040600020015461355c565b930190613c60565b600881015460005260168101602052600360406000200154670de0b6b3a7640000810290808204670de0b6b3a7640000149015171561338257600261305c9201549061358b565b613d6891506136c4565b1538613c4c565b3d15613d9a573d90613d8082613165565b91613d8e6040519384613142565b82523d6000602084013e565b606090565b356001600160a01b038116810361307d5790565b359063ffffffff8216820361307d57565b929190613dd0816132d0565b93613dde6040519586613142565b602085838152019160051b810192831161307d57905b828210613e0057505050565b8135815260209182019101613df4565b919082606091031261307d57604051613e2881613127565b604080829480358452602081013560208501520135910152565b3563ffffffff8116810361307d5790565b903590601e198136030182121561307d57018035906001600160401b03821161307d5760200191813603831361307d57565b60005260016020526040600020600c613ec9613ebe600b84015460018060a01b0386166000526004850160205260406000205490613549565b60028401549061358b565b910160018060a01b038316600052806020528160406000205411613f055761305c9260018060a01b031660005260205260406000205490613595565b505050600090565b60026000805160206157898339815191525414613f3857600260008051602061578983398151915255565b633ee5aeb560e01b60005260046000fd5b6040516323b872dd60e01b60009081526001600160a01b039384166004529290931660245260449390935260209060648180865af190600160005114821615613fbe575b604052600060605215613f9d5750565b635274afe760e01b60009081526001600160a01b0391909116600452602490fd5b906001811516613fd657823b15153d15161690613f8d565b503d6000823e3d90fd5b909181600052600160205260406000205442101580614219575b61420b575b81600052600160205260ff60066040600020015416600381101561322f576140279015613343565b61403960ff60045460a01c161561372f565b81600052600160205261405a60ff60196040600020015460a01c161561375f565b8160005260016020526040600020926140748184876135d3565b9182106141e05761408682151561423e565b6140b9600b8501670de0b6b3a76400006140a4600f88015489613549565b04906140b1828254613375565b905586613595565b92670de0b6b3a76400006140d1601087015488613549565b04928060036140fc670de0b6b3a76400006140f060118b01548c613549565b04976129978989613375565b856000526016890160205261411660406000209186615362565b0154106141b5576000816000805160206156c983398151915261415486614143879661415c9988336153ee565b6040519182918d339642928561426f565b0390a4614301565b8061418e575b508061416d57505090565b6017820154600e9092015461305c926001600160a01b03918216911661468b565b6017830154600d8401546141af92916001600160a01b03918216911661468b565b38614162565b606460405162461bcd60e51b81526020600482015260046024820152630733c73760e41b6044820152fd5b60405162461bcd60e51b8152602060048201526003602482015262733c6d60e81b6044820152606490fd5b614214826142c1565b613fff565b5081600052600160205260ff60066040600020015416600381101561322f5715613ffa565b1561424557565b60405162461bcd60e51b8152602060048201526002602482015261073360f41b6044820152606490fd5b9094939260609260808301968352602083015260408201520152565b6000805160206156e9833981519152546001600160a01b031633036142ac57565b63118cdaa760e01b6000523360045260246000fd5b6000526001602052600660406000200160ff815416600381101561322f576001810180911161338257600381101561322f5760ff80198354169116179055565b806000526001602052604060002060158101549061431e826132e7565b916016820160005b82811061437f575050507fb1bbae7680415a1349ae813ba7d737ca09df07db1f6ce058b3e0812ec15e8886916002614374920154604051928392428452606060208501526060840190613011565b9060408301520390a2565b806001916000528260205260036040600020015461439d8288613319565b5201614326565b91909282600052600160205260406000205442101580614602575b6145f4575b82600052600160205260ff60066040600020015416600381101561322f576143ec9015613343565b6143fe60ff60045460a01c161561372f565b82600052600160205261441f60ff60196040600020015460a01c161561375f565b82600052600160205260406000209284600052601684016020526040600020614449868386613ae3565b9283116145c95760049061445e84151561423e565b3360009081529101602052604090205461447a90831115614627565b8060005260016020526003604060002086600052601681016020528160406000206004810160018060a01b033316600052806020526144be87604060002054613595565b9060018060a01b033316600052602052604060002055016144e0858254613375565b9055016144ee838254613375565b90556144f981613398565b80670de0b6b3a76400000391670de0b6b3a76400008311613382578060016145b8956000805160206156c98339815191526145696145638861170d614597998e61455b8f8561170d614554926012600b870196015490613549565b8254613375565b90558d613549565b8a613375565b9a6145798c858d01541015614659565b6145838c86615464565b8b614154604051928392339642928561426f565b61170d6145ac8261170d601388015487613549565b93601486015490613549565b908061418e57508061416d57505090565b60405162461bcd60e51b8152602060048201526003602482015262733e6d60e81b6044820152606490fd5b6145fd836142c1565b6143c4565b5082600052600160205260ff60066040600020015416600381101561322f57156143bf565b1561462e57565b60405162461bcd60e51b81526020600482015260036024820152620e67cd60eb1b6044820152606490fd5b1561466057565b60405162461bcd60e51b8152602060048201526003602482015262311e3b60e91b6044820152606490fd5b60405163a9059cbb60e01b60009081526001600160a01b03909316600452602493909352919060209060448180865af1906001600051148216156146d5575b60405215613f9d5750565b906001811516613fd657823b15153d151616906146ca565b156146f457565b60405162461bcd60e51b8152602060048201526002602482015261076360f41b6044820152606490fd5b1561472557565b60405162461bcd60e51b8152602060048201526002602482015261085960f21b6044820152606490fd5b906000918061475b5750565b60001981019081116147845782670de0b6b3a76400009293505004600181018091116133825790565b634e487b7160e01b83526011600452602483fd5b90816147a5575050600090565b6000198201918211613382576147ba9161358b565b600181018091116133825790565b156147cf57565b60405162461bcd60e51b8152602060048201526002602482015261042d60f31b6044820152606490fd5b1561480057565b60405162461bcd60e51b8152602060048201526002602482015261216360f01b6044820152606490fd5b61483c60ff60045460a01c161561372f565b80600052600160205261485d60ff60196040600020015460a01c161561375f565b80600052600160205260406000209060046148783383613e85565b92836148c7575b60018060a01b033316600052016020526006604060002054604051906000825260208201528360408201524260608201526000805160206156c983398151915260803392a490565b600c810160018060a01b033316600052806020526148ea85604060002054613375565b33600090815260209290925260409091205561487f565b6000805160206157e983398151915280546001600160a01b03199081169091556000805160206156e983398151915280549182166001600160a01b039384169081179091559116600080516020615749833981519152600080a3565b9060025491600054600160401b81101561311157600181018060005581101561332d577f290decd9548b62a8d60345a988386fc84ba6bc95484008f6362f93160ef3e563018390556000838152600160209081526040918290206101a08401805160608601805195516323a4808b60e21b81526001600160a01b03968716600482015293979096909590949293929183916024918391165afa9081156151bc57600091615320575b5060018060a01b0316614a1a835115156146ed565b602083019563ffffffff8751164210156152f55760e0840180519093906001600160a01b0316156152cb5760408501978851600281101590816152bf575b501561529457831561526a57610180860190610e1063ffffffff8351161061523d5782516001600160a01b031660009081526003602052604090205460ff161561521257825189516040516325c7205960e01b81529160209183916001600160a01b039081169183918291614ad391339116600484016137a8565b03915afa9081156151bc576000916151f3575b50156151c85788516017850180546001600160a01b0319166001600160a01b0392909216919091179055805163ffffffff16845560068401805460ff191690556101008701805160409190614b3a90615571565b518051600f870155602081015160108701550151601185015560406101208801614b648151615571565b518051601287015560208082015160138801559101516014860155610140880151600d860180546001600160a01b03199081166001600160a01b03938416179091556101608a0151600e8801805490921690831617905560001960088701558b51601587015560a08901805198518551945160405163d4876b9f60e01b81526002600482015260e06024820152929a92958694859493169263ffffffff928316929190911690614c189060e4860190613245565b92604485015260648401526084830152600060a4830152600060c483015203816000895af19081156151bc57600091615187575b5060098401556007830180546001600160a01b03199081166001600160a01b0396871617909155905163ffffffff16600a8401559051601883018054831691909416179092556019018054909116331790558151608083015160008881526001602052604090205490969195919042101580615162575b615154575b87600052600160205260ff60066040600020015416600381101561322f57614cf09015613343565b614d0260ff60045460a01c161561372f565b876000526001602052614d2360ff60196040600020015460a01c161561375f565b876000526001602052604060002096614d3d8715156146ed565b6000614d488a613a5c565b978960158101928354614d5a816132e7565b9b6002839401968754938415156000146150855750908f97969594939291614d8390511561471e565b60005b82811061504e575060008e5b8382106150135750505050614db2839261170d614db993614e0196613549565b80966154ec565b614dc4858554613375565b845560048c0160018060a01b03331660005280602052614de986604060002054613375565b3360009081526020929092526040909120558c615362565b60005b8154811015614e4957808a8d82614e1d60019584613319565b51614e2c575b50505001614e04565b614e3981614e4194613319565b5191336153ee565b8a8d82614e23565b5090919293949596988a98614e5d8a613804565b9160009354935b848110614f7057505050505060c0614f5193886000805160206157298339815191527f57c2e8e67a3a13bc1991cd4ba3ed6733e269f1de098668140234d41dcb145ee4989795614f4395836002614eba82613c22565b93670de0b6b3a7640000614ece8287613549565b046040519160008352602083015260408201524260608201526000805160206156c983398151915260803392a45490614f0e6040519283924291846132ba565b0390a2614f1a89614301565b5194519601519160018060a01b0390511695604051948552608060208601526080850190613245565b908382036040850152613245565b9260608201528033930390a36002546001810180911161338257600255565b82939495969798999a9b50614f888160019394613319565b51614fa0575b01908c9a999897969594939291614e64565b8d6000614fd76016860182805280602052614fc260036040852001548a613549565b9085845260205260036040842001549061358b565b6000805160206156c983398151915261500b670de0b6b3a76400006116d6614fff888c613319565b51946116d0898d613319565b0390a4614f8e565b869798995061503d8261172d6150378961170d88999a9b9c612a218660019b613319565b8b613595565b5201908f979695949392918e614d92565b9091929394959697506150618183613319565b5180861061507c575b50600101908f97969594939291614d86565b9450600161506a565b93509193505080959493955192836150a5575b50505050614e0183614db9565b8303615127578582805b8581106150fc57505b8d8582106150c7575050615098565b6150f38261172d6150e28861170d600198612a21868c613319565b6150ed81151561471e565b8c613595565b520186906150b8565b9091506151098184613319565b5180851061511e575b506001019087916150af565b93506001615112565b60405162461bcd60e51b815260206004820152600560248201526464213d6f6360d81b6044820152606490fd5b61515d886142c1565b614cc8565b5087600052600160205260ff60066040600020015416600381101561322f5715614cc3565b9190506020823d6020116151b4575b816151a360209383613142565b8101031261307d5790516019614c4c565b3d9150615196565b6040513d6000823e3d90fd5b606460405162461bcd60e51b81526020600482015260046024820152636d213d6160e01b6044820152fd5b61520c915060203d6020116107b9576107ab8183613142565b38614ae6565b60405162461bcd60e51b815260206004820152600360248201526221616d60e81b6044820152606490fd5b60405162461bcd60e51b81526020600482015260056024820152640e4e87862d60db1b6044820152606490fd5b60405162461bcd60e51b8152602060048201526002602482015261072360f41b6044820152606490fd5b60405162461bcd60e51b8152602060048201526003602482015262216f6360e81b6044820152606490fd5b60209150111538614a58565b60405162461bcd60e51b8152602060048201526002602482015261061360f41b6044820152606490fd5b60405162461bcd60e51b8152602060048201526003602482015262319e3760e91b6044820152606490fd5b6020813d60201161535a575b8161533960209383613142565b810103126123ed5751906001600160a01b038216820361033d575038614a05565b3d915061532c565b919091600052600160205260406000206000906015810192601682019160038101935b85548110156153d3578060019160005284602052604060002060036002820191016153b18a8254613375565b90556153be898254613375565b90556153cb888754613375565b865501615385565b50909493506153ea92506001915001918254613375565b9055565b9160036153ea9381936000526001602052604060002092600052601683016020526040600020906004820160018060a01b0382166000528060205261543888604060002054613375565b9160018060a01b031660005260205260406000205501615459858254613595565b905501918254613595565b919091600052600160205260406000206000906015810192601682019160038101935b85548110156154d5578060019160005284602052604060002060036002820191016154b38a8254613595565b90556154c0898254613595565b90556154cd888754613595565b865501615487565b50909493506153ea92506001915001918254613595565b6000526001602052600c604060002061551961550e600b830194855490613549565b60028301549061358b565b92615525848254613375565b9055336000908152910160205260409020805490916153ea91613375565b60ff6000805160206157a98339815191525460401c161561556057565b631afcd79f60e31b60005260046000fd5b66b1a2bc2ec500008151116155fc5766b1a2bc2ec500006020820151116155d157604066b1a2bc2ec50000910151116155a657565b606460405162461bcd60e51b815260206004820152600460248201526364663e3560e01b6044820152fd5b606460405162461bcd60e51b815260206004820152600460248201526374663e3560e01b6044820152fd5b60405162461bcd60e51b8152602060048201526003602482015262663e3560e81b6044820152606490fd5b9061564d575080511561563c57602081519101fd5b63d6bda27560e01b60005260046000fd5b8151158061567f575b61565e575090565b639996b31560e01b60009081526001600160a01b0391909116600452602490fd5b50803b1561565656fe32c8457b93ca1561f798921516a9997de723415a87991bf1187b70434dc5cdeabe7c303f209cd18ec0555e186104232ac132a445e860bb535d9d28b9f76ad1fa9dcabe311735ed0d65f0c22c5425d1f17331f94c9d0767f59e58473cf95ada619016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c199300360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc1eca98f266e5348ae38d5d057a4d8e451e76672f69ac6ba4b0e3b31ea9c7eb2b8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e02365271d929532d684e6178b913d905d884cfec52891f3d66a6b042aaf0522959b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f00f0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00c993f9a8447446a00c879dadbeefa69111000411f1a1a9f67cf75a12ec08a3ec237e158222e3e6968b72b9db0d8043aacf074ad9f650f0d1606b4d82ee432c00a2646970667358221220a1e566c38918d7c738e9b048e72a39e5d29c01ea9f2e461b400248e54211527b64736f6c634300081a0033
Loading...
Loading
Loading...
Loading
Net Worth in USD
$0.00
Net Worth in BNB
Multichain Portfolio | 32 Chains
| Chain | Token | Portfolio % | Price | Amount | Value |
|---|
Loading...
Loading
Loading...
Loading
Loading...
Loading
[ Download: CSV Export ]
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.