Source Code
Latest 25 from a total of 30 transactions
| Transaction Hash |
|
Block
|
From
|
To
|
|||||
|---|---|---|---|---|---|---|---|---|---|
| Create Market | 32611087 | 48 days ago | IN | 0 FRAX | 0.000189 | ||||
| Create Market | 32611024 | 48 days ago | IN | 0 FRAX | 0.00021707 | ||||
| Create Market | 32610419 | 48 days ago | IN | 0 FRAX | 0.00008974 | ||||
| Create Market | 32610297 | 48 days ago | IN | 0 FRAX | 0.00011454 | ||||
| Create Market | 32610025 | 48 days ago | IN | 0 FRAX | 0.00004714 | ||||
| Match Orders Mul... | 32570743 | 49 days ago | IN | 0 FRAX | 0.00010704 | ||||
| Match Orders Mul... | 32272821 | 56 days ago | IN | 0 FRAX | 0.00004899 | ||||
| Match Orders Mul... | 32268041 | 56 days ago | IN | 0 FRAX | 0.00011179 | ||||
| Match Orders Mul... | 32267814 | 56 days ago | IN | 0 FRAX | 0.00014018 | ||||
| Create Market | 32264986 | 56 days ago | IN | 0 FRAX | 0.00002427 | ||||
| Match Orders Wit... | 32264656 | 56 days ago | IN | 0 FRAX | 0.00003599 | ||||
| Match Orders | 32264646 | 56 days ago | IN | 0 FRAX | 0.00003325 | ||||
| Match Orders | 32264614 | 56 days ago | IN | 0 FRAX | 0.00003191 | ||||
| Match Orders | 32264109 | 56 days ago | IN | 0 FRAX | 0.00001937 | ||||
| Match Orders Wit... | 32264010 | 56 days ago | IN | 0 FRAX | 0.00002213 | ||||
| Match Orders Wit... | 32263988 | 56 days ago | IN | 0 FRAX | 0.00002551 | ||||
| Match Orders Wit... | 32263886 | 56 days ago | IN | 0 FRAX | 0.00002413 | ||||
| Match Orders Wit... | 32263101 | 56 days ago | IN | 0 FRAX | 0.00002313 | ||||
| Match Orders Wit... | 32263082 | 56 days ago | IN | 0 FRAX | 0.0000181 | ||||
| Create Market | 32262485 | 56 days ago | IN | 0 FRAX | 0.00000998 | ||||
| Match Orders Wit... | 32262211 | 56 days ago | IN | 0 FRAX | 0.00001771 | ||||
| Match Orders Wit... | 32262043 | 56 days ago | IN | 0 FRAX | 0.00001763 | ||||
| Match Orders Wit... | 32260605 | 56 days ago | IN | 0 FRAX | 0.00001186 | ||||
| Match Orders Wit... | 32260197 | 56 days ago | IN | 0 FRAX | 0.00000884 | ||||
| Permit Collatera... | 32260008 | 56 days ago | IN | 0 FRAX | 0.00000508 |
View more zero value Internal Transactions in Advanced View mode
Advanced mode:
Cross-Chain Transactions
Loading...
Loading
Contract Name:
FraxBetExchange
Compiler Version
v0.8.30+commit.73712a01
Optimization Enabled:
Yes with 777 runs
Other Settings:
prague EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.20;
import { AccessControl } from "@openzeppelin/contracts/access/AccessControl.sol";
import { EIP712 } from "@openzeppelin/contracts/utils/cryptography/EIP712.sol";
import { SignatureChecker } from "@openzeppelin/contracts/utils/cryptography/SignatureChecker.sol";
import { ReentrancyGuard } from "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import { IERC20Permit } from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Permit.sol";
import { Math } from "@openzeppelin/contracts/utils/math/Math.sol";
import { ERC2771Context } from "@openzeppelin/contracts/metatx/ERC2771Context.sol";
import { Context } from "@openzeppelin/contracts/utils/Context.sol";
import { IFraxBetToken } from "./interfaces/IFraxBetToken.sol";
import {
Market,
Order,
DisputeInfo,
MarketStatus,
OrderSide,
TokenIdLib,
PRICE_PRECISION,
MIN_DISPUTE_WINDOW,
MAX_PROTOCOL_FEE_BPS,
MAX_OPERATOR_FEE_BPS,
MAX_TOTAL_FEE_BPS,
InvalidNumOutcomes,
InvalidOutcomeIndex,
InvalidTickSize,
InvalidPrice,
PriceNotOnTick,
FeeTooHigh,
MarketNotActive,
MarketNotProposed,
MarketNotResolved,
MarketNotVoided,
MarketAlreadyResolved,
DisputeWindowActive,
DisputeWindowExpired,
DisputeWindowTooShort,
NoDisputeToResolve,
UnresolvedDisputeExists,
OrderExpired,
OrderCancelled,
OrderNonceMismatch,
OrderAlreadyFilled,
IncompatibleOrders,
IncompatiblePrices,
InvalidSignature,
NotOrderMaker,
NotMarketOracle,
ZeroAmount,
ZeroAddress,
InsufficientCounterOrders,
MintBurnNotAllowed
} from "./libraries/FraxBetTypes.sol";
/// @title FraxBetExchange
/// @notice Core exchange for prediction market: market creation, order matching, resolution, and redemption.
/// Fully gasless for users via ERC2771 meta-transactions.
contract FraxBetExchange is AccessControl, EIP712, ReentrancyGuard, ERC2771Context {
using SafeERC20 for IERC20;
using TokenIdLib for uint256;
// ============ Constants ============
bytes32 public constant OPERATOR_ROLE = keccak256("OPERATOR_ROLE");
bytes32 public constant ORDER_TYPEHASH = keccak256(
"Order(uint248 marketId,address maker,uint8 outcomeIndex,uint8 side,uint256 price,uint256 amount,uint256 nonce,uint40 expiry,bool allowMintBurn)"
);
// ============ Immutables ============
IFraxBetToken public immutable token;
IERC20 public immutable frxUSD;
// ============ State Variables ============
address public protocolFeeRecipient;
uint40 public disputeWindowDuration;
uint256 public disputeBondAmount;
uint248 public nextMarketId;
// ============ Mappings ============
mapping(uint248 => Market) public markets;
mapping(bytes32 => uint256) public orderFills;
mapping(bytes32 => bool) public orderCancelled;
mapping(address => uint256) public userNonce;
mapping(uint248 => DisputeInfo) public disputes;
uint256 public accumulatedProtocolFees;
mapping(address => uint256) public accumulatedOperatorFees;
// ============ Events ============
event MarketCreated(
uint248 indexed marketId,
uint8 numOutcomes,
address indexed oracle,
address indexed operator,
uint256 tickSize,
string metadata
);
event ResultProposed(uint248 indexed marketId, uint8 winningOutcome, uint40 disputeDeadline);
event ResultDisputed(uint248 indexed marketId, address indexed disputer);
event DisputeResolved(uint248 indexed marketId, bool bondReturned, bool directResolve, uint8 newWinningOutcome);
event MarketResolved(uint248 indexed marketId, uint8 winningOutcome);
event MarketVoided(uint248 indexed marketId);
event CompleteSetMinted(uint248 indexed marketId, address indexed user, uint256 amount);
event CompleteSetBurned(uint248 indexed marketId, address indexed user, uint256 amount);
event OrdersMatched(bytes32 indexed makerOrderHash, bytes32 indexed takerOrderHash, uint256 fillAmount, uint256 executionPrice);
event OrderCancelledEvent(bytes32 indexed orderHash, address indexed maker);
event NonceIncremented(address indexed user, uint256 newNonce);
event WinningRedeemed(uint248 indexed marketId, address indexed user, uint256 amount, uint256 collateralReceived);
event VoidedRedeemed(uint248 indexed marketId, address indexed user, uint256 totalTokensBurned, uint256 collateralReceived);
event ProtocolFeesWithdrawn(address indexed recipient, uint256 amount);
event OperatorFeesWithdrawn(address indexed operator, uint256 amount);
event DisputeWindowDurationUpdated(uint40 newDuration);
event DisputeBondAmountUpdated(uint256 newAmount);
event ProtocolFeeRecipientUpdated(address newRecipient);
// ============ Constructor ============
constructor(
address _token,
address _frxUSD,
address _admin,
address _operator,
address _protocolFeeRecipient,
uint40 _disputeWindowDuration,
uint256 _disputeBondAmount,
address _trustedForwarder
) EIP712("FraxBetExchange", "1") ERC2771Context(_trustedForwarder) {
if (_token == address(0) || _frxUSD == address(0) || _admin == address(0) || _operator == address(0)) revert ZeroAddress();
if (_disputeWindowDuration < MIN_DISPUTE_WINDOW) revert DisputeWindowTooShort();
token = IFraxBetToken(_token);
frxUSD = IERC20(_frxUSD);
protocolFeeRecipient = _protocolFeeRecipient;
disputeWindowDuration = _disputeWindowDuration;
disputeBondAmount = _disputeBondAmount;
_grantRole(DEFAULT_ADMIN_ROLE, _admin);
_grantRole(OPERATOR_ROLE, _operator);
}
// ============ Market Management ============
function createMarket(
uint8 numOutcomes,
address oracle,
uint16 protocolFeeBps,
uint16 operatorFeeBps,
uint256 tickSize,
string calldata metadata
) external onlyRole(OPERATOR_ROLE) returns (uint248 marketId) {
if (numOutcomes < 2) revert InvalidNumOutcomes();
if (oracle == address(0)) revert ZeroAddress();
if (tickSize == 0 || tickSize >= PRICE_PRECISION) revert InvalidTickSize();
if (protocolFeeBps > MAX_PROTOCOL_FEE_BPS) revert FeeTooHigh();
if (operatorFeeBps > MAX_OPERATOR_FEE_BPS) revert FeeTooHigh();
if (protocolFeeBps + operatorFeeBps > MAX_TOTAL_FEE_BPS) revert FeeTooHigh();
marketId = nextMarketId++;
markets[marketId] = Market({
numOutcomes: numOutcomes,
winningOutcome: 0,
status: MarketStatus.Active,
disputeDeadline: 0,
oracle: oracle,
protocolFeeBps: protocolFeeBps,
operatorFeeBps: operatorFeeBps,
operator: _msgSender(),
tickSize: tickSize,
metadata: metadata
});
emit MarketCreated(marketId, numOutcomes, oracle, _msgSender(), tickSize, metadata);
}
// ============ Complete Set Operations ============
function mintCompleteSet(uint248 marketId, uint256 amount) external nonReentrant {
if (amount == 0) revert ZeroAmount();
if (markets[marketId].status != MarketStatus.Active) revert MarketNotActive();
_mintCompleteSetInternal(marketId, _msgSender(), amount);
}
function burnCompleteSet(uint248 marketId, uint256 amount) external nonReentrant {
if (amount == 0) revert ZeroAmount();
if (markets[marketId].status != MarketStatus.Active) revert MarketNotActive();
_burnCompleteSetInternal(marketId, _msgSender(), amount);
}
// ============ Order Matching ============
function matchOrders(
Order calldata makerOrder,
bytes calldata makerSignature,
Order calldata takerOrder,
bytes calldata takerSignature,
uint256 fillAmount
) external onlyRole(OPERATOR_ROLE) nonReentrant {
if (fillAmount == 0) revert ZeroAmount();
_validateOrderPair(makerOrder, takerOrder);
bytes32 makerHash = _validateAndHashOrder(makerOrder, makerSignature);
bytes32 takerHash = _validateAndHashOrder(takerOrder, takerSignature);
uint256 effectiveFill = _min3(
fillAmount,
makerOrder.amount - orderFills[makerHash],
takerOrder.amount - orderFills[takerHash]
);
if (effectiveFill == 0) revert OrderAlreadyFilled();
// Update fill amounts before external calls (CEI pattern)
orderFills[makerHash] += effectiveFill;
orderFills[takerHash] += effectiveFill;
_executeTransfers(makerOrder, takerOrder, effectiveFill);
emit OrdersMatched(makerHash, takerHash, effectiveFill, makerOrder.price);
}
/// @notice Match orders with automatic complete set minting for the seller.
/// Used for "Buy No" — seller mints a complete set, sells the specified outcome.
function matchOrdersWithMint(
Order calldata makerOrder,
bytes calldata makerSignature,
Order calldata takerOrder,
bytes calldata takerSignature,
uint256 fillAmount
) external onlyRole(OPERATOR_ROLE) nonReentrant {
if (fillAmount == 0) revert ZeroAmount();
_validateOrderPair(makerOrder, takerOrder);
// Seller gets minted — verify their order allows mint/burn
if (makerOrder.side == OrderSide.Sell) {
if (!makerOrder.allowMintBurn) revert MintBurnNotAllowed();
} else {
if (!takerOrder.allowMintBurn) revert MintBurnNotAllowed();
}
bytes32 makerHash = _validateAndHashOrder(makerOrder, makerSignature);
bytes32 takerHash = _validateAndHashOrder(takerOrder, takerSignature);
uint256 effectiveFill = _min3(
fillAmount,
makerOrder.amount - orderFills[makerHash],
takerOrder.amount - orderFills[takerHash]
);
if (effectiveFill == 0) revert OrderAlreadyFilled();
orderFills[makerHash] += effectiveFill;
orderFills[takerHash] += effectiveFill;
// Determine the seller and mint a complete set for them
address seller = makerOrder.side == OrderSide.Sell ? makerOrder.maker : takerOrder.maker;
_mintCompleteSetInternal(makerOrder.marketId, seller, effectiveFill);
// Execute the trade (outcome token from seller → buyer, frxUSD from buyer → seller)
_executeTransfers(makerOrder, takerOrder, effectiveFill);
emit OrdersMatched(makerHash, takerHash, effectiveFill, makerOrder.price);
}
/// @notice Match orders with automatic complete set burning for the buyer.
/// Used for "Sell No" — buyer purchases the missing outcome, burns the complete set.
/// Buyer must already hold all other outcome tokens.
function matchOrdersWithBurn(
Order calldata makerOrder,
bytes calldata makerSignature,
Order calldata takerOrder,
bytes calldata takerSignature,
uint256 fillAmount
) external onlyRole(OPERATOR_ROLE) nonReentrant {
if (fillAmount == 0) revert ZeroAmount();
_validateOrderPair(makerOrder, takerOrder);
// Buyer gets burned — verify their order allows mint/burn
if (makerOrder.side == OrderSide.Buy) {
if (!makerOrder.allowMintBurn) revert MintBurnNotAllowed();
} else {
if (!takerOrder.allowMintBurn) revert MintBurnNotAllowed();
}
bytes32 makerHash = _validateAndHashOrder(makerOrder, makerSignature);
bytes32 takerHash = _validateAndHashOrder(takerOrder, takerSignature);
uint256 effectiveFill = _min3(
fillAmount,
makerOrder.amount - orderFills[makerHash],
takerOrder.amount - orderFills[takerHash]
);
if (effectiveFill == 0) revert OrderAlreadyFilled();
orderFills[makerHash] += effectiveFill;
orderFills[takerHash] += effectiveFill;
// Execute the trade (outcome token from seller → buyer, frxUSD from buyer → seller)
_executeTransfers(makerOrder, takerOrder, effectiveFill);
// Determine the buyer and burn a complete set from them
address buyer = makerOrder.side == OrderSide.Buy ? makerOrder.maker : takerOrder.maker;
_burnCompleteSetInternal(makerOrder.marketId, buyer, effectiveFill);
emit OrdersMatched(makerHash, takerHash, effectiveFill, makerOrder.price);
}
/// @notice Multi-leg match: mint complete set for the primary buyer, sell each other outcome
/// to individual counterparties. Used for "Buy Yes (alternative)" execution path.
/// Primary order must be Buy side. Counter-orders must be Buy side for each OTHER outcome.
function matchOrdersMultiWithMint(
Order calldata primaryOrder,
bytes calldata primarySignature,
Order[] calldata counterOrders,
bytes[] calldata counterSignatures,
uint256 fillAmount
) external onlyRole(OPERATOR_ROLE) nonReentrant {
if (fillAmount == 0) revert ZeroAmount();
if (primaryOrder.side != OrderSide.Buy) revert IncompatibleOrders();
if (!primaryOrder.allowMintBurn) revert MintBurnNotAllowed();
(bytes32 primaryHash, uint256 effectiveFill) = _validatePrimaryOrder(primaryOrder, primarySignature, counterOrders.length, fillAmount);
(bytes32[] memory counterHashes, uint256 finalFill, uint256 totalCounterPrices)
= _validateCounterOrders(primaryOrder, counterOrders, counterSignatures, effectiveFill, OrderSide.Buy);
// Price constraint: sum(counter prices) >= 1e18 - primary price
if (totalCounterPrices < PRICE_PRECISION - primaryOrder.price) revert IncompatiblePrices();
_updateMultiFills(primaryHash, counterHashes, finalFill);
_mintCompleteSetInternal(primaryOrder.marketId, primaryOrder.maker, finalFill);
_executeMultiLegs(primaryOrder.maker, primaryOrder.marketId, primaryHash, counterOrders, counterHashes, finalFill, true);
}
/// @notice Multi-leg match: buy each other outcome from individual counterparties, then burn
/// complete set for the primary seller. Used for "Sell Yes (alternative)" execution path.
/// Primary order must be Sell side. Counter-orders must be Sell side for each OTHER outcome.
function matchOrdersMultiWithBurn(
Order calldata primaryOrder,
bytes calldata primarySignature,
Order[] calldata counterOrders,
bytes[] calldata counterSignatures,
uint256 fillAmount
) external onlyRole(OPERATOR_ROLE) nonReentrant {
if (fillAmount == 0) revert ZeroAmount();
if (primaryOrder.side != OrderSide.Sell) revert IncompatibleOrders();
if (!primaryOrder.allowMintBurn) revert MintBurnNotAllowed();
(bytes32 primaryHash, uint256 effectiveFill) = _validatePrimaryOrder(primaryOrder, primarySignature, counterOrders.length, fillAmount);
(bytes32[] memory counterHashes, uint256 finalFill, uint256 totalCounterPrices)
= _validateCounterOrders(primaryOrder, counterOrders, counterSignatures, effectiveFill, OrderSide.Sell);
// Price constraint: sum(counter prices) <= 1e18 - primary price
if (totalCounterPrices > PRICE_PRECISION - primaryOrder.price) revert IncompatiblePrices();
_updateMultiFills(primaryHash, counterHashes, finalFill);
_executeMultiLegs(primaryOrder.maker, primaryOrder.marketId, primaryHash, counterOrders, counterHashes, finalFill, false);
_burnCompleteSetInternal(primaryOrder.marketId, primaryOrder.maker, finalFill);
}
// ============ Order Management ============
function cancelOrder(Order calldata order) external {
if (_msgSender() != order.maker) revert NotOrderMaker();
bytes32 orderHash = hashOrder(order);
orderCancelled[orderHash] = true;
emit OrderCancelledEvent(orderHash, order.maker);
}
function incrementNonce() external {
address sender = _msgSender();
uint256 newNonce = ++userNonce[sender];
emit NonceIncremented(sender, newNonce);
}
// ============ Oracle Resolution ============
function proposeResult(uint248 marketId, uint8 winningOutcome) external {
Market storage market = markets[marketId];
if (market.status != MarketStatus.Active) revert MarketNotActive();
if (disputes[marketId].disputer != address(0)) revert UnresolvedDisputeExists();
if (_msgSender() != market.oracle) revert NotMarketOracle();
if (winningOutcome >= market.numOutcomes) revert InvalidOutcomeIndex();
market.winningOutcome = winningOutcome;
market.status = MarketStatus.OracleProposed;
market.disputeDeadline = uint40(block.timestamp) + disputeWindowDuration;
emit ResultProposed(marketId, winningOutcome, market.disputeDeadline);
}
function disputeResult(uint248 marketId) external nonReentrant {
Market storage market = markets[marketId];
if (market.status != MarketStatus.OracleProposed) revert MarketNotProposed();
if (block.timestamp >= market.disputeDeadline) revert DisputeWindowExpired();
if (disputes[marketId].disputer != address(0)) revert UnresolvedDisputeExists();
address sender = _msgSender();
// Require dispute bond
if (disputeBondAmount > 0) {
frxUSD.safeTransferFrom(sender, address(this), disputeBondAmount);
}
disputes[marketId] = DisputeInfo({ disputer: sender, bondAmount: disputeBondAmount });
// Reset market to Active
market.status = MarketStatus.Active;
market.disputeDeadline = 0;
market.winningOutcome = 0;
emit ResultDisputed(marketId, sender);
}
function finalizeResult(uint248 marketId) external {
Market storage market = markets[marketId];
if (market.status != MarketStatus.OracleProposed) revert MarketNotProposed();
if (block.timestamp < market.disputeDeadline) revert DisputeWindowActive();
market.status = MarketStatus.Resolved;
emit MarketResolved(marketId, market.winningOutcome);
}
function voidMarket(uint248 marketId) external nonReentrant onlyRole(DEFAULT_ADMIN_ROLE) {
Market storage market = markets[marketId];
if (market.status == MarketStatus.Resolved || market.status == MarketStatus.Voided) {
revert MarketAlreadyResolved();
}
market.status = MarketStatus.Voided;
// Auto-return dispute bond if one exists
DisputeInfo storage dispute = disputes[marketId];
if (dispute.disputer != address(0)) {
uint256 bondAmount = dispute.bondAmount;
address disputer = dispute.disputer;
delete disputes[marketId];
if (bondAmount > 0) {
frxUSD.safeTransfer(disputer, bondAmount);
}
emit DisputeResolved(marketId, true, false, 0);
}
emit MarketVoided(marketId);
}
function resolveDispute(
uint248 marketId,
bool returnBond,
bool directResolve,
uint8 newWinningOutcome
) external onlyRole(DEFAULT_ADMIN_ROLE) {
DisputeInfo storage dispute = disputes[marketId];
if (dispute.disputer == address(0)) revert NoDisputeToResolve();
Market storage market = markets[marketId];
if (directResolve) {
if (market.status != MarketStatus.Active) revert MarketNotActive();
if (newWinningOutcome >= market.numOutcomes) revert InvalidOutcomeIndex();
market.winningOutcome = newWinningOutcome;
market.status = MarketStatus.Resolved;
emit MarketResolved(marketId, newWinningOutcome);
}
uint256 bondAmount = dispute.bondAmount;
address disputer = dispute.disputer;
// Clear dispute
delete disputes[marketId];
if (bondAmount > 0) {
if (returnBond) {
frxUSD.safeTransfer(disputer, bondAmount);
} else {
accumulatedProtocolFees += bondAmount;
}
}
emit DisputeResolved(marketId, returnBond, directResolve, newWinningOutcome);
}
// ============ Redemption ============
function redeemWinning(uint248 marketId, uint256 amount) external nonReentrant {
if (amount == 0) revert ZeroAmount();
Market storage market = markets[marketId];
if (market.status != MarketStatus.Resolved) revert MarketNotResolved();
address sender = _msgSender();
uint256 tokenId = TokenIdLib.encode(marketId, market.winningOutcome);
// Burn winning tokens
token.burnFromExchange(sender, tokenId, amount);
// Calculate payout: 1 winning token = 1 frxUSD
uint256 payout = amount;
// Transfer collateral
frxUSD.safeTransfer(sender, payout);
emit WinningRedeemed(marketId, sender, amount, payout);
}
function redeemVoided(uint248 marketId, uint256[] calldata amounts) external nonReentrant {
Market storage market = markets[marketId];
if (market.status != MarketStatus.Voided) revert MarketNotVoided();
address sender = _msgSender();
uint8 n = market.numOutcomes;
if (amounts.length != n) revert InvalidNumOutcomes();
uint256 totalBurned = 0;
uint256[] memory ids = new uint256[](n);
uint256[] memory burnAmounts = new uint256[](n);
for (uint8 i = 0; i < n; i++) {
ids[i] = TokenIdLib.encode(marketId, i);
burnAmounts[i] = amounts[i];
totalBurned += amounts[i];
}
if (totalBurned == 0) revert ZeroAmount();
// Burn all specified outcome tokens
token.burnBatchFromExchange(sender, ids, burnAmounts);
// Each outcome token is worth 1/N frxUSD (N tokens were minted per 1 frxUSD deposited)
uint256 payout = totalBurned / uint256(n);
frxUSD.safeTransfer(sender, payout);
emit VoidedRedeemed(marketId, sender, totalBurned, payout);
}
// ============ Fee Management ============
function withdrawProtocolFees() external onlyRole(DEFAULT_ADMIN_ROLE) {
uint256 amount = accumulatedProtocolFees;
if (amount == 0) revert ZeroAmount();
accumulatedProtocolFees = 0;
frxUSD.safeTransfer(protocolFeeRecipient, amount);
emit ProtocolFeesWithdrawn(protocolFeeRecipient, amount);
}
function withdrawOperatorFees() external {
address sender = _msgSender();
uint256 amount = accumulatedOperatorFees[sender];
if (amount == 0) revert ZeroAmount();
accumulatedOperatorFees[sender] = 0;
frxUSD.safeTransfer(sender, amount);
emit OperatorFeesWithdrawn(sender, amount);
}
// ============ Admin Configuration ============
function setDisputeWindowDuration(uint40 duration) external onlyRole(DEFAULT_ADMIN_ROLE) {
if (duration < MIN_DISPUTE_WINDOW) revert DisputeWindowTooShort();
disputeWindowDuration = duration;
emit DisputeWindowDurationUpdated(duration);
}
function setDisputeBondAmount(uint256 amount) external onlyRole(DEFAULT_ADMIN_ROLE) {
disputeBondAmount = amount;
emit DisputeBondAmountUpdated(amount);
}
function setProtocolFeeRecipient(address recipient) external onlyRole(DEFAULT_ADMIN_ROLE) {
if (recipient == address(0)) revert ZeroAddress();
protocolFeeRecipient = recipient;
emit ProtocolFeeRecipientUpdated(recipient);
}
// ============ Permit Helper ============
function permitCollateral(
address owner_,
uint256 amount,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) external {
IERC20Permit(address(frxUSD)).permit(owner_, address(this), amount, deadline, v, r, s);
}
// ============ View Functions ============
function hashOrder(Order calldata order) public view returns (bytes32) {
return _hashTypedDataV4(
keccak256(
abi.encode(
ORDER_TYPEHASH,
order.marketId,
order.maker,
order.outcomeIndex,
uint8(order.side),
order.price,
order.amount,
order.nonce,
order.expiry,
order.allowMintBurn
)
)
);
}
function getOrderRemainingAmount(Order calldata order) external view returns (uint256) {
bytes32 orderHash = hashOrder(order);
if (orderCancelled[orderHash]) return 0;
if (order.nonce != userNonce[order.maker]) return 0;
if (block.timestamp > order.expiry) return 0;
return order.amount - orderFills[orderHash];
}
function getMarketTokenIds(uint248 marketId) external view returns (uint256[] memory) {
uint8 n = markets[marketId].numOutcomes;
uint256[] memory ids = new uint256[](n);
for (uint8 i = 0; i < n; i++) {
ids[i] = TokenIdLib.encode(marketId, i);
}
return ids;
}
function isOrderValid(Order calldata order) external view returns (bool) {
bytes32 orderHash = hashOrder(order);
if (orderCancelled[orderHash]) return false;
if (order.nonce != userNonce[order.maker]) return false;
if (block.timestamp > order.expiry) return false;
if (orderFills[orderHash] >= order.amount) return false;
if (markets[order.marketId].status != MarketStatus.Active) return false;
return true;
}
// ============ Internal Functions ============
function _validateAndHashOrder(
Order calldata order,
bytes calldata signature
) internal view returns (bytes32 orderHash) {
// Expiry check
if (block.timestamp > order.expiry) revert OrderExpired();
// Nonce check
if (order.nonce != userNonce[order.maker]) revert OrderNonceMismatch();
// Hash and verify signature
orderHash = hashOrder(order);
// Cancellation check
if (orderCancelled[orderHash]) revert OrderCancelled();
// Signature verification (supports both EOA via ECDSA and smart contract wallets via ERC-1271)
if (!SignatureChecker.isValidSignatureNow(order.maker, orderHash, signature)) revert InvalidSignature();
}
function _validateOrderPair(Order calldata makerOrder, Order calldata takerOrder) internal view {
if (makerOrder.marketId != takerOrder.marketId) revert IncompatibleOrders();
if (makerOrder.outcomeIndex != takerOrder.outcomeIndex) revert IncompatibleOrders();
if (makerOrder.side == takerOrder.side) revert IncompatibleOrders();
Market storage market = markets[makerOrder.marketId];
if (market.status != MarketStatus.Active) revert MarketNotActive();
if (makerOrder.outcomeIndex >= market.numOutcomes) revert InvalidOutcomeIndex();
// Price bounds
if (makerOrder.price == 0 || makerOrder.price >= PRICE_PRECISION) revert InvalidPrice();
if (takerOrder.price == 0 || takerOrder.price >= PRICE_PRECISION) revert InvalidPrice();
// Tick size validation
if (makerOrder.price % market.tickSize != 0) revert PriceNotOnTick();
if (takerOrder.price % market.tickSize != 0) revert PriceNotOnTick();
// Price compatibility
if (makerOrder.side == OrderSide.Buy) {
if (makerOrder.price < takerOrder.price) revert IncompatiblePrices();
} else {
if (takerOrder.price < makerOrder.price) revert IncompatiblePrices();
}
}
function _executeTransfers(
Order calldata makerOrder,
Order calldata takerOrder,
uint256 effectiveFill
) internal {
address buyer = makerOrder.side == OrderSide.Buy ? makerOrder.maker : takerOrder.maker;
address seller = makerOrder.side == OrderSide.Sell ? makerOrder.maker : takerOrder.maker;
uint256 collateralAmount = Math.mulDiv(effectiveFill, makerOrder.price, PRICE_PRECISION);
Market storage market = markets[makerOrder.marketId];
uint256 protocolFee = Math.mulDiv(collateralAmount, market.protocolFeeBps, 10_000);
uint256 operatorFee = Math.mulDiv(collateralAmount, market.operatorFeeBps, 10_000);
uint256 totalFees = protocolFee + operatorFee;
// Transfer collateral: buyer → seller
frxUSD.safeTransferFrom(buyer, seller, collateralAmount);
if (totalFees > 0) {
frxUSD.safeTransferFrom(buyer, address(this), totalFees);
accumulatedProtocolFees += protocolFee;
accumulatedOperatorFees[market.operator] += operatorFee;
}
// Transfer outcome tokens: seller → buyer (auto-approved via token contract)
uint256 tokenId = TokenIdLib.encode(makerOrder.marketId, makerOrder.outcomeIndex);
token.safeTransferFrom(seller, buyer, tokenId, effectiveFill, "");
}
function _validatePrimaryOrder(
Order calldata primaryOrder,
bytes calldata primarySignature,
uint256 numCounterOrders,
uint256 fillAmount
) internal view returns (bytes32 primaryHash, uint256 effectiveFill) {
Market storage market = markets[primaryOrder.marketId];
if (market.status != MarketStatus.Active) revert MarketNotActive();
if (primaryOrder.outcomeIndex >= market.numOutcomes) revert InvalidOutcomeIndex();
if (primaryOrder.price == 0 || primaryOrder.price >= PRICE_PRECISION) revert InvalidPrice();
if (primaryOrder.price % market.tickSize != 0) revert PriceNotOnTick();
uint8 numOthers = market.numOutcomes - 1;
if (numCounterOrders != numOthers) revert InsufficientCounterOrders();
primaryHash = _validateAndHashOrder(primaryOrder, primarySignature);
effectiveFill = fillAmount;
uint256 primaryRemaining = primaryOrder.amount - orderFills[primaryHash];
if (primaryRemaining < effectiveFill) effectiveFill = primaryRemaining;
}
function _validateCounterOrders(
Order calldata primaryOrder,
Order[] calldata counterOrders,
bytes[] calldata counterSignatures,
uint256 effectiveFill,
OrderSide expectedSide
) internal view returns (bytes32[] memory counterHashes, uint256 finalFill, uint256 totalCounterPrices) {
if (counterOrders.length != counterSignatures.length) revert IncompatibleOrders();
counterHashes = new bytes32[](counterOrders.length);
finalFill = effectiveFill;
uint256 outcomesBitmap = uint256(1) << primaryOrder.outcomeIndex;
for (uint256 i = 0; i < counterOrders.length; i++) {
_validateSingleCounter(counterOrders[i], primaryOrder.marketId, expectedSide, outcomesBitmap);
outcomesBitmap |= uint256(1) << counterOrders[i].outcomeIndex;
counterHashes[i] = _validateAndHashOrder(counterOrders[i], counterSignatures[i]);
uint256 remaining = counterOrders[i].amount - orderFills[counterHashes[i]];
if (remaining < finalFill) finalFill = remaining;
totalCounterPrices += counterOrders[i].price;
}
if (finalFill == 0) revert OrderAlreadyFilled();
}
function _validateSingleCounter(
Order calldata counter,
uint248 marketId,
OrderSide expectedSide,
uint256 outcomesBitmap
) internal view {
Market storage market = markets[marketId];
if (counter.marketId != marketId) revert IncompatibleOrders();
if (counter.side != expectedSide) revert IncompatibleOrders();
if (counter.outcomeIndex >= market.numOutcomes) revert InvalidOutcomeIndex();
if (outcomesBitmap & (uint256(1) << counter.outcomeIndex) != 0) revert IncompatibleOrders();
if (counter.price == 0 || counter.price >= PRICE_PRECISION) revert InvalidPrice();
if (counter.price % market.tickSize != 0) revert PriceNotOnTick();
}
/// @param primaryIsSeller true if primary user sells to counter buyers (multi-with-mint),
/// false if primary user buys from counter sellers (multi-with-burn)
function _executeMultiLegs(
address primaryUser,
uint248 marketId,
bytes32 primaryHash,
Order[] calldata counterOrders,
bytes32[] memory counterHashes,
uint256 effectiveFill,
bool primaryIsSeller
) internal {
for (uint256 i = 0; i < counterOrders.length; i++) {
if (primaryIsSeller) {
_transferLeg(primaryUser, counterOrders[i].maker, marketId, counterOrders[i].outcomeIndex, effectiveFill, counterOrders[i].price);
} else {
_transferLeg(counterOrders[i].maker, primaryUser, marketId, counterOrders[i].outcomeIndex, effectiveFill, counterOrders[i].price);
}
emit OrdersMatched(primaryHash, counterHashes[i], effectiveFill, counterOrders[i].price);
}
}
function _updateMultiFills(
bytes32 primaryHash,
bytes32[] memory counterHashes,
uint256 effectiveFill
) internal {
orderFills[primaryHash] += effectiveFill;
for (uint256 i = 0; i < counterHashes.length; i++) {
orderFills[counterHashes[i]] += effectiveFill;
}
}
function _mintCompleteSetInternal(uint248 marketId, address user, uint256 amount) internal {
Market storage market = markets[marketId];
frxUSD.safeTransferFrom(user, address(this), amount);
uint8 n = market.numOutcomes;
uint256[] memory ids = new uint256[](n);
uint256[] memory amounts = new uint256[](n);
for (uint8 i = 0; i < n; i++) {
ids[i] = TokenIdLib.encode(marketId, i);
amounts[i] = amount;
}
token.mintBatch(user, ids, amounts, "");
emit CompleteSetMinted(marketId, user, amount);
}
function _burnCompleteSetInternal(uint248 marketId, address user, uint256 amount) internal {
Market storage market = markets[marketId];
uint8 n = market.numOutcomes;
uint256[] memory ids = new uint256[](n);
uint256[] memory amounts = new uint256[](n);
for (uint8 i = 0; i < n; i++) {
ids[i] = TokenIdLib.encode(marketId, i);
amounts[i] = amount;
}
token.burnBatchFromExchange(user, ids, amounts);
frxUSD.safeTransfer(user, amount);
emit CompleteSetBurned(marketId, user, amount);
}
function _transferLeg(
address seller,
address buyer,
uint248 marketId,
uint8 outcomeIndex,
uint256 tokenAmount,
uint256 executionPrice
) internal {
uint256 collateralAmount = Math.mulDiv(tokenAmount, executionPrice, PRICE_PRECISION);
Market storage market = markets[marketId];
uint256 protocolFee = Math.mulDiv(collateralAmount, market.protocolFeeBps, 10_000);
uint256 operatorFee = Math.mulDiv(collateralAmount, market.operatorFeeBps, 10_000);
uint256 totalFees = protocolFee + operatorFee;
frxUSD.safeTransferFrom(buyer, seller, collateralAmount);
if (totalFees > 0) {
frxUSD.safeTransferFrom(buyer, address(this), totalFees);
accumulatedProtocolFees += protocolFee;
accumulatedOperatorFees[market.operator] += operatorFee;
}
uint256 tokenId = TokenIdLib.encode(marketId, outcomeIndex);
token.safeTransferFrom(seller, buyer, tokenId, tokenAmount, "");
}
function _min3(uint256 a, uint256 b, uint256 c) internal pure returns (uint256) {
return a < b ? (a < c ? a : c) : (b < c ? b : c);
}
// ============ ERC2771 Context Overrides ============
function _msgSender() internal view override(Context, ERC2771Context) returns (address) {
return ERC2771Context._msgSender();
}
function _msgData() internal view override(Context, ERC2771Context) returns (bytes calldata) {
return ERC2771Context._msgData();
}
function _contextSuffixLength() internal view override(Context, ERC2771Context) returns (uint256) {
return ERC2771Context._contextSuffixLength();
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (access/AccessControl.sol)
pragma solidity ^0.8.20;
import {IAccessControl} from "./IAccessControl.sol";
import {Context} from "../utils/Context.sol";
import {IERC165, ERC165} from "../utils/introspection/ERC165.sol";
/**
* @dev Contract module that allows children to implement role-based access
* control mechanisms. This is a lightweight version that doesn't allow enumerating role
* members except through off-chain means by accessing the contract event logs. Some
* applications may benefit from on-chain enumerability, for those cases see
* {AccessControlEnumerable}.
*
* Roles are referred to by their `bytes32` identifier. These should be exposed
* in the external API and be unique. The best way to achieve this is by
* using `public constant` hash digests:
*
* ```solidity
* bytes32 public constant MY_ROLE = keccak256("MY_ROLE");
* ```
*
* Roles can be used to represent a set of permissions. To restrict access to a
* function call, use {hasRole}:
*
* ```solidity
* function foo() public {
* require(hasRole(MY_ROLE, msg.sender));
* ...
* }
* ```
*
* Roles can be granted and revoked dynamically via the {grantRole} and
* {revokeRole} functions. Each role has an associated admin role, and only
* accounts that have a role's admin role can call {grantRole} and {revokeRole}.
*
* By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means
* that only accounts with this role will be able to grant or revoke other
* roles. More complex role relationships can be created by using
* {_setRoleAdmin}.
*
* WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to
* grant and revoke this role. Extra precautions should be taken to secure
* accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules}
* to enforce additional security measures for this role.
*/
abstract contract AccessControl is Context, IAccessControl, ERC165 {
struct RoleData {
mapping(address account => bool) hasRole;
bytes32 adminRole;
}
mapping(bytes32 role => RoleData) private _roles;
bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;
/**
* @dev Modifier that checks that an account has a specific role. Reverts
* with an {AccessControlUnauthorizedAccount} error including the required role.
*/
modifier onlyRole(bytes32 role) {
_checkRole(role);
_;
}
/// @inheritdoc IERC165
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);
}
/**
* @dev Returns `true` if `account` has been granted `role`.
*/
function hasRole(bytes32 role, address account) public view virtual returns (bool) {
return _roles[role].hasRole[account];
}
/**
* @dev Reverts with an {AccessControlUnauthorizedAccount} error if `_msgSender()`
* is missing `role`. Overriding this function changes the behavior of the {onlyRole} modifier.
*/
function _checkRole(bytes32 role) internal view virtual {
_checkRole(role, _msgSender());
}
/**
* @dev Reverts with an {AccessControlUnauthorizedAccount} error if `account`
* is missing `role`.
*/
function _checkRole(bytes32 role, address account) internal view virtual {
if (!hasRole(role, account)) {
revert AccessControlUnauthorizedAccount(account, role);
}
}
/**
* @dev Returns the admin role that controls `role`. See {grantRole} and
* {revokeRole}.
*
* To change a role's admin, use {_setRoleAdmin}.
*/
function getRoleAdmin(bytes32 role) public view virtual returns (bytes32) {
return _roles[role].adminRole;
}
/**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*
* May emit a {RoleGranted} event.
*/
function grantRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {
_grantRole(role, account);
}
/**
* @dev Revokes `role` from `account`.
*
* If `account` had been granted `role`, emits a {RoleRevoked} event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*
* May emit a {RoleRevoked} event.
*/
function revokeRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {
_revokeRole(role, account);
}
/**
* @dev Revokes `role` from the calling account.
*
* Roles are often managed via {grantRole} and {revokeRole}: this function's
* purpose is to provide a mechanism for accounts to lose their privileges
* if they are compromised (such as when a trusted device is misplaced).
*
* If the calling account had been revoked `role`, emits a {RoleRevoked}
* event.
*
* Requirements:
*
* - the caller must be `callerConfirmation`.
*
* May emit a {RoleRevoked} event.
*/
function renounceRole(bytes32 role, address callerConfirmation) public virtual {
if (callerConfirmation != _msgSender()) {
revert AccessControlBadConfirmation();
}
_revokeRole(role, callerConfirmation);
}
/**
* @dev Sets `adminRole` as ``role``'s admin role.
*
* Emits a {RoleAdminChanged} event.
*/
function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {
bytes32 previousAdminRole = getRoleAdmin(role);
_roles[role].adminRole = adminRole;
emit RoleAdminChanged(role, previousAdminRole, adminRole);
}
/**
* @dev Attempts to grant `role` to `account` and returns a boolean indicating if `role` was granted.
*
* Internal function without access restriction.
*
* May emit a {RoleGranted} event.
*/
function _grantRole(bytes32 role, address account) internal virtual returns (bool) {
if (!hasRole(role, account)) {
_roles[role].hasRole[account] = true;
emit RoleGranted(role, account, _msgSender());
return true;
} else {
return false;
}
}
/**
* @dev Attempts to revoke `role` from `account` and returns a boolean indicating if `role` was revoked.
*
* Internal function without access restriction.
*
* May emit a {RoleRevoked} event.
*/
function _revokeRole(bytes32 role, address account) internal virtual returns (bool) {
if (hasRole(role, account)) {
_roles[role].hasRole[account] = false;
emit RoleRevoked(role, account, _msgSender());
return true;
} else {
return false;
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (utils/cryptography/EIP712.sol)
pragma solidity ^0.8.20;
import {MessageHashUtils} from "./MessageHashUtils.sol";
import {ShortStrings, ShortString} from "../ShortStrings.sol";
import {IERC5267} from "../../interfaces/IERC5267.sol";
/**
* @dev https://eips.ethereum.org/EIPS/eip-712[EIP-712] is a standard for hashing and signing of typed structured data.
*
* The encoding scheme specified in the EIP requires a domain separator and a hash of the typed structured data, whose
* encoding is very generic and therefore its implementation in Solidity is not feasible, thus this contract
* does not implement the encoding itself. Protocols need to implement the type-specific encoding they need in order to
* produce the hash of their typed data using a combination of `abi.encode` and `keccak256`.
*
* This contract implements the EIP-712 domain separator ({_domainSeparatorV4}) that is used as part of the encoding
* scheme, and the final step of the encoding to obtain the message digest that is then signed via ECDSA
* ({_hashTypedDataV4}).
*
* The implementation of the domain separator was designed to be as efficient as possible while still properly updating
* the chain id to protect against replay attacks on an eventual fork of the chain.
*
* NOTE: This contract implements the version of the encoding known as "v4", as implemented by the JSON RPC method
* https://docs.metamask.io/guide/signing-data.html[`eth_signTypedDataV4` in MetaMask].
*
* NOTE: In the upgradeable version of this contract, the cached values will correspond to the address, and the domain
* separator of the implementation contract. This will cause the {_domainSeparatorV4} function to always rebuild the
* separator from the immutable values, which is cheaper than accessing a cached version in cold storage.
*
* @custom:oz-upgrades-unsafe-allow state-variable-immutable
*/
abstract contract EIP712 is IERC5267 {
using ShortStrings for *;
bytes32 private constant TYPE_HASH =
keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)");
// Cache the domain separator as an immutable value, but also store the chain id that it corresponds to, in order to
// invalidate the cached domain separator if the chain id changes.
bytes32 private immutable _cachedDomainSeparator;
uint256 private immutable _cachedChainId;
address private immutable _cachedThis;
bytes32 private immutable _hashedName;
bytes32 private immutable _hashedVersion;
ShortString private immutable _name;
ShortString private immutable _version;
// slither-disable-next-line constable-states
string private _nameFallback;
// slither-disable-next-line constable-states
string private _versionFallback;
/**
* @dev Initializes the domain separator and parameter caches.
*
* The meaning of `name` and `version` is specified in
* https://eips.ethereum.org/EIPS/eip-712#definition-of-domainseparator[EIP-712]:
*
* - `name`: the user readable name of the signing domain, i.e. the name of the DApp or the protocol.
* - `version`: the current major version of the signing domain.
*
* NOTE: These parameters cannot be changed except through a xref:learn::upgrading-smart-contracts.adoc[smart
* contract upgrade].
*/
constructor(string memory name, string memory version) {
_name = name.toShortStringWithFallback(_nameFallback);
_version = version.toShortStringWithFallback(_versionFallback);
_hashedName = keccak256(bytes(name));
_hashedVersion = keccak256(bytes(version));
_cachedChainId = block.chainid;
_cachedDomainSeparator = _buildDomainSeparator();
_cachedThis = address(this);
}
/**
* @dev Returns the domain separator for the current chain.
*/
function _domainSeparatorV4() internal view returns (bytes32) {
if (address(this) == _cachedThis && block.chainid == _cachedChainId) {
return _cachedDomainSeparator;
} else {
return _buildDomainSeparator();
}
}
function _buildDomainSeparator() private view returns (bytes32) {
return keccak256(abi.encode(TYPE_HASH, _hashedName, _hashedVersion, block.chainid, address(this)));
}
/**
* @dev Given an already https://eips.ethereum.org/EIPS/eip-712#definition-of-hashstruct[hashed struct], this
* function returns the hash of the fully encoded EIP712 message for this domain.
*
* This hash can be used together with {ECDSA-recover} to obtain the signer of a message. For example:
*
* ```solidity
* bytes32 digest = _hashTypedDataV4(keccak256(abi.encode(
* keccak256("Mail(address to,string contents)"),
* mailTo,
* keccak256(bytes(mailContents))
* )));
* address signer = ECDSA.recover(digest, signature);
* ```
*/
function _hashTypedDataV4(bytes32 structHash) internal view virtual returns (bytes32) {
return MessageHashUtils.toTypedDataHash(_domainSeparatorV4(), structHash);
}
/// @inheritdoc IERC5267
function eip712Domain()
public
view
virtual
returns (
bytes1 fields,
string memory name,
string memory version,
uint256 chainId,
address verifyingContract,
bytes32 salt,
uint256[] memory extensions
)
{
return (
hex"0f", // 01111
_EIP712Name(),
_EIP712Version(),
block.chainid,
address(this),
bytes32(0),
new uint256[](0)
);
}
/**
* @dev The name parameter for the EIP712 domain.
*
* NOTE: By default this function reads _name which is an immutable value.
* It only reads from storage if necessary (in case the value is too large to fit in a ShortString).
*/
// solhint-disable-next-line func-name-mixedcase
function _EIP712Name() internal view returns (string memory) {
return _name.toStringWithFallback(_nameFallback);
}
/**
* @dev The version parameter for the EIP712 domain.
*
* NOTE: By default this function reads _version which is an immutable value.
* It only reads from storage if necessary (in case the value is too large to fit in a ShortString).
*/
// solhint-disable-next-line func-name-mixedcase
function _EIP712Version() internal view returns (string memory) {
return _version.toStringWithFallback(_versionFallback);
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (utils/cryptography/SignatureChecker.sol)
pragma solidity ^0.8.24;
import {ECDSA} from "./ECDSA.sol";
import {IERC1271} from "../../interfaces/IERC1271.sol";
import {IERC7913SignatureVerifier} from "../../interfaces/IERC7913.sol";
import {Bytes} from "../../utils/Bytes.sol";
/**
* @dev Signature verification helper that can be used instead of `ECDSA.recover` to seamlessly support:
*
* * ECDSA signatures from externally owned accounts (EOAs)
* * ERC-1271 signatures from smart contract wallets like Argent and Safe Wallet (previously Gnosis Safe)
* * ERC-7913 signatures from keys that do not have an Ethereum address of their own
*
* See https://eips.ethereum.org/EIPS/eip-1271[ERC-1271] and https://eips.ethereum.org/EIPS/eip-7913[ERC-7913].
*/
library SignatureChecker {
using Bytes for bytes;
/**
* @dev Checks if a signature is valid for a given signer and data hash. If the signer has code, the
* signature is validated against it using ERC-1271, otherwise it's validated using `ECDSA.recover`.
*
* NOTE: Unlike ECDSA signatures, contract signatures are revocable, and the outcome of this function can thus
* change through time. It could return true at block N and false at block N+1 (or the opposite).
*
* NOTE: For an extended version of this function that supports ERC-7913 signatures, see {isValidSignatureNow-bytes-bytes32-bytes-}.
*/
function isValidSignatureNow(address signer, bytes32 hash, bytes memory signature) internal view returns (bool) {
if (signer.code.length == 0) {
(address recovered, ECDSA.RecoverError err, ) = ECDSA.tryRecover(hash, signature);
return err == ECDSA.RecoverError.NoError && recovered == signer;
} else {
return isValidERC1271SignatureNow(signer, hash, signature);
}
}
/**
* @dev Checks if a signature is valid for a given signer and data hash. The signature is validated
* against the signer smart contract using ERC-1271.
*
* NOTE: Unlike ECDSA signatures, contract signatures are revocable, and the outcome of this function can thus
* change through time. It could return true at block N and false at block N+1 (or the opposite).
*/
function isValidERC1271SignatureNow(
address signer,
bytes32 hash,
bytes memory signature
) internal view returns (bool) {
(bool success, bytes memory result) = signer.staticcall(
abi.encodeCall(IERC1271.isValidSignature, (hash, signature))
);
return (success &&
result.length >= 32 &&
abi.decode(result, (bytes32)) == bytes32(IERC1271.isValidSignature.selector));
}
/**
* @dev Verifies a signature for a given ERC-7913 signer and hash.
*
* The signer is a `bytes` object that is the concatenation of an address and optionally a key:
* `verifier || key`. A signer must be at least 20 bytes long.
*
* Verification is done as follows:
*
* * If `signer.length < 20`: verification fails
* * If `signer.length == 20`: verification is done using {isValidSignatureNow}
* * Otherwise: verification is done using {IERC7913SignatureVerifier}
*
* NOTE: Unlike ECDSA signatures, contract signatures are revocable, and the outcome of this function can thus
* change through time. It could return true at block N and false at block N+1 (or the opposite).
*/
function isValidSignatureNow(
bytes memory signer,
bytes32 hash,
bytes memory signature
) internal view returns (bool) {
if (signer.length < 20) {
return false;
} else if (signer.length == 20) {
return isValidSignatureNow(address(bytes20(signer)), hash, signature);
} else {
(bool success, bytes memory result) = address(bytes20(signer)).staticcall(
abi.encodeCall(IERC7913SignatureVerifier.verify, (signer.slice(20), hash, signature))
);
return (success &&
result.length >= 32 &&
abi.decode(result, (bytes32)) == bytes32(IERC7913SignatureVerifier.verify.selector));
}
}
/**
* @dev Verifies multiple ERC-7913 `signatures` for a given `hash` using a set of `signers`.
* Returns `false` if the number of signers and signatures is not the same.
*
* The signers should be ordered by their `keccak256` hash to ensure efficient duplication check. Unordered
* signers are supported, but the uniqueness check will be more expensive.
*
* NOTE: Unlike ECDSA signatures, contract signatures are revocable, and the outcome of this function can thus
* change through time. It could return true at block N and false at block N+1 (or the opposite).
*/
function areValidSignaturesNow(
bytes32 hash,
bytes[] memory signers,
bytes[] memory signatures
) internal view returns (bool) {
if (signers.length != signatures.length) return false;
bytes32 lastId = bytes32(0);
for (uint256 i = 0; i < signers.length; ++i) {
bytes memory signer = signers[i];
// If one of the signatures is invalid, reject the batch
if (!isValidSignatureNow(signer, hash, signatures[i])) return false;
bytes32 id = keccak256(signer);
// If the current signer ID is greater than all previous IDs, then this is a new signer.
if (lastId < id) {
lastId = id;
} else {
// If this signer id is not greater than all the previous ones, verify that it is not a duplicate of a previous one
// This loop is never executed if the signers are ordered by id.
for (uint256 j = 0; j < i; ++j) {
if (id == keccak256(signers[j])) return false;
}
}
}
return true;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/ReentrancyGuard.sol)
pragma solidity ^0.8.20;
/**
* @dev Contract module that helps prevent reentrant calls to a function.
*
* Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
* available, which can be 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 ReentrancyGuard {
// 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;
uint256 private _status;
/**
* @dev Unauthorized reentrant call.
*/
error ReentrancyGuardReentrantCall();
constructor() {
_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 {
// 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 {
// 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) {
return _status == ENTERED;
}
}// 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 {
_callOptionalReturn(token, abi.encodeCall(token.transfer, (to, value)));
}
/**
* @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the
* calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.
*/
function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeCall(token.transferFrom, (from, to, value)));
}
/**
* @dev 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 _callOptionalReturnBool(token, abi.encodeCall(token.transfer, (to, value)));
}
/**
* @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 _callOptionalReturnBool(token, abi.encodeCall(token.transferFrom, (from, to, value)));
}
/**
* @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*
* 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 {
bytes memory approvalCall = abi.encodeCall(token.approve, (spender, value));
if (!_callOptionalReturnBool(token, approvalCall)) {
_callOptionalReturn(token, abi.encodeCall(token.approve, (spender, 0)));
_callOptionalReturn(token, approvalCall);
}
}
/**
* @dev 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 high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*
* This is a variant of {_callOptionalReturnBool} that reverts if call fails to meet the requirements.
*/
function _callOptionalReturn(IERC20 token, bytes memory data) private {
uint256 returnSize;
uint256 returnValue;
assembly ("memory-safe") {
let success := call(gas(), token, 0, add(data, 0x20), mload(data), 0, 0x20)
// bubble errors
if iszero(success) {
let ptr := mload(0x40)
returndatacopy(ptr, 0, returndatasize())
revert(ptr, returndatasize())
}
returnSize := returndatasize()
returnValue := mload(0)
}
if (returnSize == 0 ? address(token).code.length == 0 : returnValue != 1) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*
* This is a variant of {_callOptionalReturn} that silently catches all reverts and returns a bool instead.
*/
function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {
bool success;
uint256 returnSize;
uint256 returnValue;
assembly ("memory-safe") {
success := call(gas(), token, 0, add(data, 0x20), mload(data), 0, 0x20)
returnSize := returndatasize()
returnValue := mload(0)
}
return success && (returnSize == 0 ? address(token).code.length > 0 : returnValue == 1);
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.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.4.0) (token/ERC20/extensions/IERC20Permit.sol)
pragma solidity >=0.4.16;
/**
* @dev Interface of the ERC-20 Permit extension allowing approvals to be made via signatures, as defined in
* https://eips.ethereum.org/EIPS/eip-2612[ERC-2612].
*
* Adds the {permit} method, which can be used to change an account's ERC-20 allowance (see {IERC20-allowance}) by
* presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't
* need to send a transaction, and thus is not required to hold Ether at all.
*
* ==== Security Considerations
*
* There are two important considerations concerning the use of `permit`. The first is that a valid permit signature
* expresses an allowance, and it should not be assumed to convey additional meaning. In particular, it should not be
* considered as an intention to spend the allowance in any specific way. The second is that because permits have
* built-in replay protection and can be submitted by anyone, they can be frontrun. A protocol that uses permits should
* take this into consideration and allow a `permit` call to fail. Combining these two aspects, a pattern that may be
* generally recommended is:
*
* ```solidity
* function doThingWithPermit(..., uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public {
* try token.permit(msg.sender, address(this), value, deadline, v, r, s) {} catch {}
* doThing(..., value);
* }
*
* function doThing(..., uint256 value) public {
* token.safeTransferFrom(msg.sender, address(this), value);
* ...
* }
* ```
*
* Observe that: 1) `msg.sender` is used as the owner, leaving no ambiguity as to the signer intent, and 2) the use of
* `try/catch` allows the permit to fail and makes the code tolerant to frontrunning. (See also
* {SafeERC20-safeTransferFrom}).
*
* Additionally, note that smart contract wallets (such as Argent or Safe) are not able to produce permit signatures, so
* contracts should have entry points that don't rely on permit.
*/
interface IERC20Permit {
/**
* @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,
* given ``owner``'s signed approval.
*
* IMPORTANT: The same issues {IERC20-approve} has related to transaction
* ordering also apply here.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `deadline` must be a timestamp in the future.
* - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`
* over the EIP712-formatted function arguments.
* - the signature must use ``owner``'s current nonce (see {nonces}).
*
* For more information on the signature format, see the
* https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP
* section].
*
* CAUTION: See Security Considerations above.
*/
function permit(
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) external;
/**
* @dev Returns the current nonce for `owner`. This value must be
* included whenever a signature is generated for {permit}.
*
* Every successful call to {permit} increases ``owner``'s nonce by one. This
* prevents a signature from being used multiple times.
*/
function nonces(address owner) external view returns (uint256);
/**
* @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.
*/
// solhint-disable-next-line func-name-mixedcase
function DOMAIN_SEPARATOR() external view returns (bytes32);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.3.0) (utils/math/Math.sol)
pragma solidity ^0.8.20;
import {Panic} from "../Panic.sol";
import {SafeCast} from "./SafeCast.sol";
/**
* @dev Standard math utilities missing in the Solidity language.
*/
library Math {
enum Rounding {
Floor, // Toward negative infinity
Ceil, // Toward positive infinity
Trunc, // Toward zero
Expand // Away from zero
}
/**
* @dev Return the 512-bit addition of two uint256.
*
* The result is stored in two 256 variables such that sum = high * 2²⁵⁶ + low.
*/
function add512(uint256 a, uint256 b) internal pure returns (uint256 high, uint256 low) {
assembly ("memory-safe") {
low := add(a, b)
high := lt(low, a)
}
}
/**
* @dev Return the 512-bit multiplication of two uint256.
*
* The result is stored in two 256 variables such that product = high * 2²⁵⁶ + low.
*/
function mul512(uint256 a, uint256 b) internal pure returns (uint256 high, uint256 low) {
// 512-bit multiply [high low] = x * y. Compute the product mod 2²⁵⁶ and mod 2²⁵⁶ - 1, then use
// the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256
// variables such that product = high * 2²⁵⁶ + low.
assembly ("memory-safe") {
let mm := mulmod(a, b, not(0))
low := mul(a, b)
high := sub(sub(mm, low), lt(mm, low))
}
}
/**
* @dev Returns the addition of two unsigned integers, with a success flag (no overflow).
*/
function tryAdd(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {
unchecked {
uint256 c = a + b;
success = c >= a;
result = c * SafeCast.toUint(success);
}
}
/**
* @dev Returns the subtraction of two unsigned integers, with a success flag (no overflow).
*/
function trySub(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {
unchecked {
uint256 c = a - b;
success = c <= a;
result = c * SafeCast.toUint(success);
}
}
/**
* @dev Returns the multiplication of two unsigned integers, with a success flag (no overflow).
*/
function tryMul(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {
unchecked {
uint256 c = a * b;
assembly ("memory-safe") {
// Only true when the multiplication doesn't overflow
// (c / a == b) || (a == 0)
success := or(eq(div(c, a), b), iszero(a))
}
// equivalent to: success ? c : 0
result = c * SafeCast.toUint(success);
}
}
/**
* @dev Returns the division of two unsigned integers, with a success flag (no division by zero).
*/
function tryDiv(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {
unchecked {
success = b > 0;
assembly ("memory-safe") {
// The `DIV` opcode returns zero when the denominator is 0.
result := div(a, b)
}
}
}
/**
* @dev Returns the remainder of dividing two unsigned integers, with a success flag (no division by zero).
*/
function tryMod(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {
unchecked {
success = b > 0;
assembly ("memory-safe") {
// The `MOD` opcode returns zero when the denominator is 0.
result := mod(a, b)
}
}
}
/**
* @dev Unsigned saturating addition, bounds to `2²⁵⁶ - 1` instead of overflowing.
*/
function saturatingAdd(uint256 a, uint256 b) internal pure returns (uint256) {
(bool success, uint256 result) = tryAdd(a, b);
return ternary(success, result, type(uint256).max);
}
/**
* @dev Unsigned saturating subtraction, bounds to zero instead of overflowing.
*/
function saturatingSub(uint256 a, uint256 b) internal pure returns (uint256) {
(, uint256 result) = trySub(a, b);
return result;
}
/**
* @dev Unsigned saturating multiplication, bounds to `2²⁵⁶ - 1` instead of overflowing.
*/
function saturatingMul(uint256 a, uint256 b) internal pure returns (uint256) {
(bool success, uint256 result) = tryMul(a, b);
return ternary(success, result, type(uint256).max);
}
/**
* @dev Branchless ternary evaluation for `a ? b : c`. Gas costs are constant.
*
* IMPORTANT: This function may reduce bytecode size and consume less gas when used standalone.
* However, the compiler may optimize Solidity ternary operations (i.e. `a ? b : c`) to only compute
* one branch when needed, making this function more expensive.
*/
function ternary(bool condition, uint256 a, uint256 b) internal pure returns (uint256) {
unchecked {
// branchless ternary works because:
// b ^ (a ^ b) == a
// b ^ 0 == b
return b ^ ((a ^ b) * SafeCast.toUint(condition));
}
}
/**
* @dev Returns the largest of two numbers.
*/
function max(uint256 a, uint256 b) internal pure returns (uint256) {
return ternary(a > b, a, b);
}
/**
* @dev Returns the smallest of two numbers.
*/
function min(uint256 a, uint256 b) internal pure returns (uint256) {
return ternary(a < b, a, b);
}
/**
* @dev Returns the average of two numbers. The result is rounded towards
* zero.
*/
function average(uint256 a, uint256 b) internal pure returns (uint256) {
// (a + b) / 2 can overflow.
return (a & b) + (a ^ b) / 2;
}
/**
* @dev Returns the ceiling of the division of two numbers.
*
* This differs from standard division with `/` in that it rounds towards infinity instead
* of rounding towards zero.
*/
function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
if (b == 0) {
// Guarantee the same behavior as in a regular Solidity division.
Panic.panic(Panic.DIVISION_BY_ZERO);
}
// The following calculation ensures accurate ceiling division without overflow.
// Since a is non-zero, (a - 1) / b will not overflow.
// The largest possible result occurs when (a - 1) / b is type(uint256).max,
// but the largest value we can obtain is type(uint256).max - 1, which happens
// when a = type(uint256).max and b = 1.
unchecked {
return SafeCast.toUint(a > 0) * ((a - 1) / b + 1);
}
}
/**
* @dev Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or
* denominator == 0.
*
* Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv) with further edits by
* Uniswap Labs also under MIT license.
*/
function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) {
unchecked {
(uint256 high, uint256 low) = mul512(x, y);
// Handle non-overflow cases, 256 by 256 division.
if (high == 0) {
// Solidity will revert if denominator == 0, unlike the div opcode on its own.
// The surrounding unchecked block does not change this fact.
// See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic.
return low / denominator;
}
// Make sure the result is less than 2²⁵⁶. Also prevents denominator == 0.
if (denominator <= high) {
Panic.panic(ternary(denominator == 0, Panic.DIVISION_BY_ZERO, Panic.UNDER_OVERFLOW));
}
///////////////////////////////////////////////
// 512 by 256 division.
///////////////////////////////////////////////
// Make division exact by subtracting the remainder from [high low].
uint256 remainder;
assembly ("memory-safe") {
// Compute remainder using mulmod.
remainder := mulmod(x, y, denominator)
// Subtract 256 bit number from 512 bit number.
high := sub(high, gt(remainder, low))
low := sub(low, remainder)
}
// Factor powers of two out of denominator and compute largest power of two divisor of denominator.
// Always >= 1. See https://cs.stackexchange.com/q/138556/92363.
uint256 twos = denominator & (0 - denominator);
assembly ("memory-safe") {
// Divide denominator by twos.
denominator := div(denominator, twos)
// Divide [high low] by twos.
low := div(low, twos)
// Flip twos such that it is 2²⁵⁶ / twos. If twos is zero, then it becomes one.
twos := add(div(sub(0, twos), twos), 1)
}
// Shift in bits from high into low.
low |= high * twos;
// Invert denominator mod 2²⁵⁶. Now that denominator is an odd number, it has an inverse modulo 2²⁵⁶ such
// that denominator * inv ≡ 1 mod 2²⁵⁶. Compute the inverse by starting with a seed that is correct for
// four bits. That is, denominator * inv ≡ 1 mod 2⁴.
uint256 inverse = (3 * denominator) ^ 2;
// Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also
// works in modular arithmetic, doubling the correct bits in each step.
inverse *= 2 - denominator * inverse; // inverse mod 2⁸
inverse *= 2 - denominator * inverse; // inverse mod 2¹⁶
inverse *= 2 - denominator * inverse; // inverse mod 2³²
inverse *= 2 - denominator * inverse; // inverse mod 2⁶⁴
inverse *= 2 - denominator * inverse; // inverse mod 2¹²⁸
inverse *= 2 - denominator * inverse; // inverse mod 2²⁵⁶
// Because the division is now exact we can divide by multiplying with the modular inverse of denominator.
// This will give us the correct result modulo 2²⁵⁶. Since the preconditions guarantee that the outcome is
// less than 2²⁵⁶, this is the final result. We don't need to compute the high bits of the result and high
// is no longer required.
result = low * inverse;
return result;
}
}
/**
* @dev Calculates x * y / denominator with full precision, following the selected rounding direction.
*/
function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) {
return mulDiv(x, y, denominator) + SafeCast.toUint(unsignedRoundsUp(rounding) && mulmod(x, y, denominator) > 0);
}
/**
* @dev Calculates floor(x * y >> n) with full precision. Throws if result overflows a uint256.
*/
function mulShr(uint256 x, uint256 y, uint8 n) internal pure returns (uint256 result) {
unchecked {
(uint256 high, uint256 low) = mul512(x, y);
if (high >= 1 << n) {
Panic.panic(Panic.UNDER_OVERFLOW);
}
return (high << (256 - n)) | (low >> n);
}
}
/**
* @dev Calculates x * y >> n with full precision, following the selected rounding direction.
*/
function mulShr(uint256 x, uint256 y, uint8 n, Rounding rounding) internal pure returns (uint256) {
return mulShr(x, y, n) + SafeCast.toUint(unsignedRoundsUp(rounding) && mulmod(x, y, 1 << n) > 0);
}
/**
* @dev Calculate the modular multiplicative inverse of a number in Z/nZ.
*
* If n is a prime, then Z/nZ is a field. In that case all elements are inversible, except 0.
* If n is not a prime, then Z/nZ is not a field, and some elements might not be inversible.
*
* If the input value is not inversible, 0 is returned.
*
* NOTE: If you know for sure that n is (big) a prime, it may be cheaper to use Fermat's little theorem and get the
* inverse using `Math.modExp(a, n - 2, n)`. See {invModPrime}.
*/
function invMod(uint256 a, uint256 n) internal pure returns (uint256) {
unchecked {
if (n == 0) return 0;
// The inverse modulo is calculated using the Extended Euclidean Algorithm (iterative version)
// Used to compute integers x and y such that: ax + ny = gcd(a, n).
// When the gcd is 1, then the inverse of a modulo n exists and it's x.
// ax + ny = 1
// ax = 1 + (-y)n
// ax ≡ 1 (mod n) # x is the inverse of a modulo n
// If the remainder is 0 the gcd is n right away.
uint256 remainder = a % n;
uint256 gcd = n;
// Therefore the initial coefficients are:
// ax + ny = gcd(a, n) = n
// 0a + 1n = n
int256 x = 0;
int256 y = 1;
while (remainder != 0) {
uint256 quotient = gcd / remainder;
(gcd, remainder) = (
// The old remainder is the next gcd to try.
remainder,
// Compute the next remainder.
// Can't overflow given that (a % gcd) * (gcd // (a % gcd)) <= gcd
// where gcd is at most n (capped to type(uint256).max)
gcd - remainder * quotient
);
(x, y) = (
// Increment the coefficient of a.
y,
// Decrement the coefficient of n.
// Can overflow, but the result is casted to uint256 so that the
// next value of y is "wrapped around" to a value between 0 and n - 1.
x - y * int256(quotient)
);
}
if (gcd != 1) return 0; // No inverse exists.
return ternary(x < 0, n - uint256(-x), uint256(x)); // Wrap the result if it's negative.
}
}
/**
* @dev Variant of {invMod}. More efficient, but only works if `p` is known to be a prime greater than `2`.
*
* From https://en.wikipedia.org/wiki/Fermat%27s_little_theorem[Fermat's little theorem], we know that if p is
* prime, then `a**(p-1) ≡ 1 mod p`. As a consequence, we have `a * a**(p-2) ≡ 1 mod p`, which means that
* `a**(p-2)` is the modular multiplicative inverse of a in Fp.
*
* NOTE: this function does NOT check that `p` is a prime greater than `2`.
*/
function invModPrime(uint256 a, uint256 p) internal view returns (uint256) {
unchecked {
return Math.modExp(a, p - 2, p);
}
}
/**
* @dev Returns the modular exponentiation of the specified base, exponent and modulus (b ** e % m)
*
* Requirements:
* - modulus can't be zero
* - underlying staticcall to precompile must succeed
*
* IMPORTANT: The result is only valid if the underlying call succeeds. When using this function, make
* sure the chain you're using it on supports the precompiled contract for modular exponentiation
* at address 0x05 as specified in https://eips.ethereum.org/EIPS/eip-198[EIP-198]. Otherwise,
* the underlying function will succeed given the lack of a revert, but the result may be incorrectly
* interpreted as 0.
*/
function modExp(uint256 b, uint256 e, uint256 m) internal view returns (uint256) {
(bool success, uint256 result) = tryModExp(b, e, m);
if (!success) {
Panic.panic(Panic.DIVISION_BY_ZERO);
}
return result;
}
/**
* @dev Returns the modular exponentiation of the specified base, exponent and modulus (b ** e % m).
* It includes a success flag indicating if the operation succeeded. Operation will be marked as failed if trying
* to operate modulo 0 or if the underlying precompile reverted.
*
* IMPORTANT: The result is only valid if the success flag is true. When using this function, make sure the chain
* you're using it on supports the precompiled contract for modular exponentiation at address 0x05 as specified in
* https://eips.ethereum.org/EIPS/eip-198[EIP-198]. Otherwise, the underlying function will succeed given the lack
* of a revert, but the result may be incorrectly interpreted as 0.
*/
function tryModExp(uint256 b, uint256 e, uint256 m) internal view returns (bool success, uint256 result) {
if (m == 0) return (false, 0);
assembly ("memory-safe") {
let ptr := mload(0x40)
// | Offset | Content | Content (Hex) |
// |-----------|------------|--------------------------------------------------------------------|
// | 0x00:0x1f | size of b | 0x0000000000000000000000000000000000000000000000000000000000000020 |
// | 0x20:0x3f | size of e | 0x0000000000000000000000000000000000000000000000000000000000000020 |
// | 0x40:0x5f | size of m | 0x0000000000000000000000000000000000000000000000000000000000000020 |
// | 0x60:0x7f | value of b | 0x<.............................................................b> |
// | 0x80:0x9f | value of e | 0x<.............................................................e> |
// | 0xa0:0xbf | value of m | 0x<.............................................................m> |
mstore(ptr, 0x20)
mstore(add(ptr, 0x20), 0x20)
mstore(add(ptr, 0x40), 0x20)
mstore(add(ptr, 0x60), b)
mstore(add(ptr, 0x80), e)
mstore(add(ptr, 0xa0), m)
// Given the result < m, it's guaranteed to fit in 32 bytes,
// so we can use the memory scratch space located at offset 0.
success := staticcall(gas(), 0x05, ptr, 0xc0, 0x00, 0x20)
result := mload(0x00)
}
}
/**
* @dev Variant of {modExp} that supports inputs of arbitrary length.
*/
function modExp(bytes memory b, bytes memory e, bytes memory m) internal view returns (bytes memory) {
(bool success, bytes memory result) = tryModExp(b, e, m);
if (!success) {
Panic.panic(Panic.DIVISION_BY_ZERO);
}
return result;
}
/**
* @dev Variant of {tryModExp} that supports inputs of arbitrary length.
*/
function tryModExp(
bytes memory b,
bytes memory e,
bytes memory m
) internal view returns (bool success, bytes memory result) {
if (_zeroBytes(m)) return (false, new bytes(0));
uint256 mLen = m.length;
// Encode call args in result and move the free memory pointer
result = abi.encodePacked(b.length, e.length, mLen, b, e, m);
assembly ("memory-safe") {
let dataPtr := add(result, 0x20)
// Write result on top of args to avoid allocating extra memory.
success := staticcall(gas(), 0x05, dataPtr, mload(result), dataPtr, mLen)
// Overwrite the length.
// result.length > returndatasize() is guaranteed because returndatasize() == m.length
mstore(result, mLen)
// Set the memory pointer after the returned data.
mstore(0x40, add(dataPtr, mLen))
}
}
/**
* @dev Returns whether the provided byte array is zero.
*/
function _zeroBytes(bytes memory byteArray) private pure returns (bool) {
for (uint256 i = 0; i < byteArray.length; ++i) {
if (byteArray[i] != 0) {
return false;
}
}
return true;
}
/**
* @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded
* towards zero.
*
* This method is based on Newton's method for computing square roots; the algorithm is restricted to only
* using integer operations.
*/
function sqrt(uint256 a) internal pure returns (uint256) {
unchecked {
// Take care of easy edge cases when a == 0 or a == 1
if (a <= 1) {
return a;
}
// In this function, we use Newton's method to get a root of `f(x) := x² - a`. It involves building a
// sequence x_n that converges toward sqrt(a). For each iteration x_n, we also define the error between
// the current value as `ε_n = | x_n - sqrt(a) |`.
//
// For our first estimation, we consider `e` the smallest power of 2 which is bigger than the square root
// of the target. (i.e. `2**(e-1) ≤ sqrt(a) < 2**e`). We know that `e ≤ 128` because `(2¹²⁸)² = 2²⁵⁶` is
// bigger than any uint256.
//
// By noticing that
// `2**(e-1) ≤ sqrt(a) < 2**e → (2**(e-1))² ≤ a < (2**e)² → 2**(2*e-2) ≤ a < 2**(2*e)`
// we can deduce that `e - 1` is `log2(a) / 2`. We can thus compute `x_n = 2**(e-1)` using a method similar
// to the msb function.
uint256 aa = a;
uint256 xn = 1;
if (aa >= (1 << 128)) {
aa >>= 128;
xn <<= 64;
}
if (aa >= (1 << 64)) {
aa >>= 64;
xn <<= 32;
}
if (aa >= (1 << 32)) {
aa >>= 32;
xn <<= 16;
}
if (aa >= (1 << 16)) {
aa >>= 16;
xn <<= 8;
}
if (aa >= (1 << 8)) {
aa >>= 8;
xn <<= 4;
}
if (aa >= (1 << 4)) {
aa >>= 4;
xn <<= 2;
}
if (aa >= (1 << 2)) {
xn <<= 1;
}
// We now have x_n such that `x_n = 2**(e-1) ≤ sqrt(a) < 2**e = 2 * x_n`. This implies ε_n ≤ 2**(e-1).
//
// We can refine our estimation by noticing that the middle of that interval minimizes the error.
// If we move x_n to equal 2**(e-1) + 2**(e-2), then we reduce the error to ε_n ≤ 2**(e-2).
// This is going to be our x_0 (and ε_0)
xn = (3 * xn) >> 1; // ε_0 := | x_0 - sqrt(a) | ≤ 2**(e-2)
// From here, Newton's method give us:
// x_{n+1} = (x_n + a / x_n) / 2
//
// One should note that:
// x_{n+1}² - a = ((x_n + a / x_n) / 2)² - a
// = ((x_n² + a) / (2 * x_n))² - a
// = (x_n⁴ + 2 * a * x_n² + a²) / (4 * x_n²) - a
// = (x_n⁴ + 2 * a * x_n² + a² - 4 * a * x_n²) / (4 * x_n²)
// = (x_n⁴ - 2 * a * x_n² + a²) / (4 * x_n²)
// = (x_n² - a)² / (2 * x_n)²
// = ((x_n² - a) / (2 * x_n))²
// ≥ 0
// Which proves that for all n ≥ 1, sqrt(a) ≤ x_n
//
// This gives us the proof of quadratic convergence of the sequence:
// ε_{n+1} = | x_{n+1} - sqrt(a) |
// = | (x_n + a / x_n) / 2 - sqrt(a) |
// = | (x_n² + a - 2*x_n*sqrt(a)) / (2 * x_n) |
// = | (x_n - sqrt(a))² / (2 * x_n) |
// = | ε_n² / (2 * x_n) |
// = ε_n² / | (2 * x_n) |
//
// For the first iteration, we have a special case where x_0 is known:
// ε_1 = ε_0² / | (2 * x_0) |
// ≤ (2**(e-2))² / (2 * (2**(e-1) + 2**(e-2)))
// ≤ 2**(2*e-4) / (3 * 2**(e-1))
// ≤ 2**(e-3) / 3
// ≤ 2**(e-3-log2(3))
// ≤ 2**(e-4.5)
//
// For the following iterations, we use the fact that, 2**(e-1) ≤ sqrt(a) ≤ x_n:
// ε_{n+1} = ε_n² / | (2 * x_n) |
// ≤ (2**(e-k))² / (2 * 2**(e-1))
// ≤ 2**(2*e-2*k) / 2**e
// ≤ 2**(e-2*k)
xn = (xn + a / xn) >> 1; // ε_1 := | x_1 - sqrt(a) | ≤ 2**(e-4.5) -- special case, see above
xn = (xn + a / xn) >> 1; // ε_2 := | x_2 - sqrt(a) | ≤ 2**(e-9) -- general case with k = 4.5
xn = (xn + a / xn) >> 1; // ε_3 := | x_3 - sqrt(a) | ≤ 2**(e-18) -- general case with k = 9
xn = (xn + a / xn) >> 1; // ε_4 := | x_4 - sqrt(a) | ≤ 2**(e-36) -- general case with k = 18
xn = (xn + a / xn) >> 1; // ε_5 := | x_5 - sqrt(a) | ≤ 2**(e-72) -- general case with k = 36
xn = (xn + a / xn) >> 1; // ε_6 := | x_6 - sqrt(a) | ≤ 2**(e-144) -- general case with k = 72
// Because e ≤ 128 (as discussed during the first estimation phase), we know have reached a precision
// ε_6 ≤ 2**(e-144) < 1. Given we're operating on integers, then we can ensure that xn is now either
// sqrt(a) or sqrt(a) + 1.
return xn - SafeCast.toUint(xn > a / xn);
}
}
/**
* @dev Calculates sqrt(a), following the selected rounding direction.
*/
function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = sqrt(a);
return result + SafeCast.toUint(unsignedRoundsUp(rounding) && result * result < a);
}
}
/**
* @dev Return the log in base 2 of a positive value rounded towards zero.
* Returns 0 if given 0.
*/
function log2(uint256 x) internal pure returns (uint256 r) {
// If value has upper 128 bits set, log2 result is at least 128
r = SafeCast.toUint(x > 0xffffffffffffffffffffffffffffffff) << 7;
// If upper 64 bits of 128-bit half set, add 64 to result
r |= SafeCast.toUint((x >> r) > 0xffffffffffffffff) << 6;
// If upper 32 bits of 64-bit half set, add 32 to result
r |= SafeCast.toUint((x >> r) > 0xffffffff) << 5;
// If upper 16 bits of 32-bit half set, add 16 to result
r |= SafeCast.toUint((x >> r) > 0xffff) << 4;
// If upper 8 bits of 16-bit half set, add 8 to result
r |= SafeCast.toUint((x >> r) > 0xff) << 3;
// If upper 4 bits of 8-bit half set, add 4 to result
r |= SafeCast.toUint((x >> r) > 0xf) << 2;
// Shifts value right by the current result and use it as an index into this lookup table:
//
// | x (4 bits) | index | table[index] = MSB position |
// |------------|---------|-----------------------------|
// | 0000 | 0 | table[0] = 0 |
// | 0001 | 1 | table[1] = 0 |
// | 0010 | 2 | table[2] = 1 |
// | 0011 | 3 | table[3] = 1 |
// | 0100 | 4 | table[4] = 2 |
// | 0101 | 5 | table[5] = 2 |
// | 0110 | 6 | table[6] = 2 |
// | 0111 | 7 | table[7] = 2 |
// | 1000 | 8 | table[8] = 3 |
// | 1001 | 9 | table[9] = 3 |
// | 1010 | 10 | table[10] = 3 |
// | 1011 | 11 | table[11] = 3 |
// | 1100 | 12 | table[12] = 3 |
// | 1101 | 13 | table[13] = 3 |
// | 1110 | 14 | table[14] = 3 |
// | 1111 | 15 | table[15] = 3 |
//
// The lookup table is represented as a 32-byte value with the MSB positions for 0-15 in the last 16 bytes.
assembly ("memory-safe") {
r := or(r, byte(shr(r, x), 0x0000010102020202030303030303030300000000000000000000000000000000))
}
}
/**
* @dev Return the log in base 2, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log2(value);
return result + SafeCast.toUint(unsignedRoundsUp(rounding) && 1 << result < value);
}
}
/**
* @dev Return the log in base 10 of a positive value rounded towards zero.
* Returns 0 if given 0.
*/
function log10(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >= 10 ** 64) {
value /= 10 ** 64;
result += 64;
}
if (value >= 10 ** 32) {
value /= 10 ** 32;
result += 32;
}
if (value >= 10 ** 16) {
value /= 10 ** 16;
result += 16;
}
if (value >= 10 ** 8) {
value /= 10 ** 8;
result += 8;
}
if (value >= 10 ** 4) {
value /= 10 ** 4;
result += 4;
}
if (value >= 10 ** 2) {
value /= 10 ** 2;
result += 2;
}
if (value >= 10 ** 1) {
result += 1;
}
}
return result;
}
/**
* @dev Return the log in base 10, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log10(value);
return result + SafeCast.toUint(unsignedRoundsUp(rounding) && 10 ** result < value);
}
}
/**
* @dev Return the log in base 256 of a positive value rounded towards zero.
* Returns 0 if given 0.
*
* Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.
*/
function log256(uint256 x) internal pure returns (uint256 r) {
// If value has upper 128 bits set, log2 result is at least 128
r = SafeCast.toUint(x > 0xffffffffffffffffffffffffffffffff) << 7;
// If upper 64 bits of 128-bit half set, add 64 to result
r |= SafeCast.toUint((x >> r) > 0xffffffffffffffff) << 6;
// If upper 32 bits of 64-bit half set, add 32 to result
r |= SafeCast.toUint((x >> r) > 0xffffffff) << 5;
// If upper 16 bits of 32-bit half set, add 16 to result
r |= SafeCast.toUint((x >> r) > 0xffff) << 4;
// Add 1 if upper 8 bits of 16-bit half set, and divide accumulated result by 8
return (r >> 3) | SafeCast.toUint((x >> r) > 0xff);
}
/**
* @dev Return the log in base 256, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log256(value);
return result + SafeCast.toUint(unsignedRoundsUp(rounding) && 1 << (result << 3) < value);
}
}
/**
* @dev Returns whether a provided rounding mode is considered rounding up for unsigned integers.
*/
function unsignedRoundsUp(Rounding rounding) internal pure returns (bool) {
return uint8(rounding) % 2 == 1;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (metatx/ERC2771Context.sol)
pragma solidity ^0.8.20;
import {Context} from "../utils/Context.sol";
/**
* @dev Context variant with ERC-2771 support.
*
* WARNING: Avoid using this pattern in contracts that rely in a specific calldata length as they'll
* be affected by any forwarder whose `msg.data` is suffixed with the `from` address according to the ERC-2771
* specification adding the address size in bytes (20) to the calldata size. An example of an unexpected
* behavior could be an unintended fallback (or another function) invocation while trying to invoke the `receive`
* function only accessible if `msg.data.length == 0`.
*
* WARNING: The usage of `delegatecall` in this contract is dangerous and may result in context corruption.
* Any forwarded request to this contract triggering a `delegatecall` to itself will result in an invalid {_msgSender}
* recovery.
*/
abstract contract ERC2771Context is Context {
/// @custom:oz-upgrades-unsafe-allow state-variable-immutable
address private immutable _trustedForwarder;
/**
* @dev Initializes the contract with a trusted forwarder, which will be able to
* invoke functions on this contract on behalf of other accounts.
*
* NOTE: The trusted forwarder can be replaced by overriding {trustedForwarder}.
*/
/// @custom:oz-upgrades-unsafe-allow constructor
constructor(address trustedForwarder_) {
_trustedForwarder = trustedForwarder_;
}
/**
* @dev Returns the address of the trusted forwarder.
*/
function trustedForwarder() public view virtual returns (address) {
return _trustedForwarder;
}
/**
* @dev Indicates whether any particular address is the trusted forwarder.
*/
function isTrustedForwarder(address forwarder) public view virtual returns (bool) {
return forwarder == trustedForwarder();
}
/**
* @dev Override for `msg.sender`. Defaults to the original `msg.sender` whenever
* a call is not performed by the trusted forwarder or the calldata length is less than
* 20 bytes (an address length).
*/
function _msgSender() internal view virtual override returns (address) {
uint256 calldataLength = msg.data.length;
uint256 contextSuffixLength = _contextSuffixLength();
if (calldataLength >= contextSuffixLength && isTrustedForwarder(msg.sender)) {
unchecked {
return address(bytes20(msg.data[calldataLength - contextSuffixLength:]));
}
} else {
return super._msgSender();
}
}
/**
* @dev Override for `msg.data`. Defaults to the original `msg.data` whenever
* a call is not performed by the trusted forwarder or the calldata length is less than
* 20 bytes (an address length).
*/
function _msgData() internal view virtual override returns (bytes calldata) {
uint256 calldataLength = msg.data.length;
uint256 contextSuffixLength = _contextSuffixLength();
if (calldataLength >= contextSuffixLength && isTrustedForwarder(msg.sender)) {
unchecked {
return msg.data[:calldataLength - contextSuffixLength];
}
} else {
return super._msgData();
}
}
/**
* @dev ERC-2771 specifies the context as being a single address (20 bytes).
*/
function _contextSuffixLength() internal view virtual override returns (uint256) {
return 20;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)
pragma solidity ^0.8.20;
/**
* @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 Context {
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: UNLICENSED
pragma solidity ^0.8.20;
import { IERC1155 } from "@openzeppelin/contracts/token/ERC1155/IERC1155.sol";
interface IFraxBetToken is IERC1155 {
function mint(address to, uint256 id, uint256 amount, bytes memory data) external;
function mintBatch(address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data) external;
function burnFromExchange(address from, uint256 id, uint256 amount) external;
function burnBatchFromExchange(address from, uint256[] memory ids, uint256[] memory amounts) external;
function totalSupply(uint256 id) external view returns (uint256);
function exists(uint256 id) external view returns (bool);
}// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.20;
// ============ Enums ============
enum MarketStatus {
Active, // Market open for trading
OracleProposed, // Oracle proposed result, dispute window active
Resolved, // Finalized, winning tokens redeemable
Voided // Voided, all outcome tokens redeemable 1:1
}
enum OrderSide {
Buy, // Maker wants to buy outcome tokens (pays frxUSD)
Sell // Maker wants to sell outcome tokens (receives frxUSD)
}
// ============ Structs ============
struct Market {
uint8 numOutcomes; // Number of outcomes (2-255)
uint8 winningOutcome; // Set after resolution (0-indexed)
MarketStatus status;
uint40 disputeDeadline; // Timestamp when dispute window ends
address oracle; // Per-market oracle
uint16 protocolFeeBps;
uint16 operatorFeeBps;
address operator; // Market creator (receives operator fees)
uint256 tickSize; // Minimum price increment (18-decimal fixed point)
string metadata; // IPFS hash or question text
}
struct Order {
uint248 marketId;
address maker;
uint8 outcomeIndex;
OrderSide side;
uint256 price; // 18-decimal fixed point (0 < price < 1e18)
uint256 amount; // Number of outcome tokens
uint256 nonce; // Must match userNonce[maker]
uint40 expiry; // Unix timestamp
bool allowMintBurn; // Must be true for composite execution paths (mint/burn)
}
struct DisputeInfo {
address disputer;
uint256 bondAmount;
}
// ============ Library ============
library TokenIdLib {
function encode(uint248 marketId, uint8 outcomeIndex) internal pure returns (uint256) {
return (uint256(marketId) << 8) | uint256(outcomeIndex);
}
function decode(uint256 tokenId) internal pure returns (uint248 marketId, uint8 outcomeIndex) {
marketId = uint248(tokenId >> 8);
outcomeIndex = uint8(tokenId);
}
function getMarketId(uint256 tokenId) internal pure returns (uint248) {
return uint248(tokenId >> 8);
}
function getOutcomeIndex(uint256 tokenId) internal pure returns (uint8) {
return uint8(tokenId);
}
}
// ============ Constants ============
uint256 constant PRICE_PRECISION = 1e18;
uint40 constant MIN_DISPUTE_WINDOW = 1 hours;
uint16 constant MAX_PROTOCOL_FEE_BPS = 500; // 5%
uint16 constant MAX_OPERATOR_FEE_BPS = 500; // 5%
uint16 constant MAX_TOTAL_FEE_BPS = 1000; // 10%
// ============ Custom Errors ============
error InvalidNumOutcomes();
error InvalidOutcomeIndex();
error InvalidTickSize();
error InvalidPrice();
error PriceNotOnTick();
error FeeTooHigh();
error MarketNotActive();
error MarketNotProposed();
error MarketNotResolved();
error MarketNotVoided();
error MarketAlreadyResolved();
error DisputeWindowActive();
error DisputeWindowExpired();
error DisputeWindowTooShort();
error NoDisputeToResolve();
error UnresolvedDisputeExists();
error OrderExpired();
error OrderCancelled();
error OrderNonceMismatch();
error OrderAlreadyFilled();
error IncompatibleOrders();
error IncompatiblePrices();
error InvalidSignature();
error NotOrderMaker();
error NotMarketOracle();
error ZeroAmount();
error ZeroAddress();
error InsufficientCounterOrders();
error MintBurnNotAllowed();// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (access/IAccessControl.sol)
pragma solidity >=0.8.4;
/**
* @dev External interface of AccessControl declared to support ERC-165 detection.
*/
interface IAccessControl {
/**
* @dev The `account` is missing a role.
*/
error AccessControlUnauthorizedAccount(address account, bytes32 neededRole);
/**
* @dev The caller of a function is not the expected one.
*
* NOTE: Don't confuse with {AccessControlUnauthorizedAccount}.
*/
error AccessControlBadConfirmation();
/**
* @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`
*
* `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite
* {RoleAdminChanged} not being emitted to signal this.
*/
event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);
/**
* @dev Emitted when `account` is granted `role`.
*
* `sender` is the account that originated the contract call. This account bears the admin role (for the granted role).
* Expected in cases where the role was granted using the internal {AccessControl-_grantRole}.
*/
event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);
/**
* @dev Emitted when `account` is revoked `role`.
*
* `sender` is the account that originated the contract call:
* - if using `revokeRole`, it is the admin role bearer
* - if using `renounceRole`, it is the role bearer (i.e. `account`)
*/
event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);
/**
* @dev Returns `true` if `account` has been granted `role`.
*/
function hasRole(bytes32 role, address account) external view returns (bool);
/**
* @dev Returns the admin role that controls `role`. See {grantRole} and
* {revokeRole}.
*
* To change a role's admin, use {AccessControl-_setRoleAdmin}.
*/
function getRoleAdmin(bytes32 role) external view returns (bytes32);
/**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*/
function grantRole(bytes32 role, address account) external;
/**
* @dev Revokes `role` from `account`.
*
* If `account` had been granted `role`, emits a {RoleRevoked} event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*/
function revokeRole(bytes32 role, address account) external;
/**
* @dev Revokes `role` from the calling account.
*
* Roles are often managed via {grantRole} and {revokeRole}: this function's
* purpose is to provide a mechanism for accounts to lose their privileges
* if they are compromised (such as when a trusted device is misplaced).
*
* If the calling account had been granted `role`, emits a {RoleRevoked}
* event.
*
* Requirements:
*
* - the caller must be `callerConfirmation`.
*/
function renounceRole(bytes32 role, address callerConfirmation) external;
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (utils/introspection/ERC165.sol)
pragma solidity ^0.8.20;
import {IERC165} from "./IERC165.sol";
/**
* @dev Implementation of the {IERC165} interface.
*
* Contracts that want to implement ERC-165 should inherit from this contract and override {supportsInterface} to check
* for the additional interface id that will be supported. For example:
*
* ```solidity
* function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
* return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
* }
* ```
*/
abstract contract ERC165 is IERC165 {
/// @inheritdoc IERC165
function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {
return interfaceId == type(IERC165).interfaceId;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.3.0) (utils/cryptography/MessageHashUtils.sol)
pragma solidity ^0.8.20;
import {Strings} from "../Strings.sol";
/**
* @dev Signature message hash utilities for producing digests to be consumed by {ECDSA} recovery or signing.
*
* The library provides methods for generating a hash of a message that conforms to the
* https://eips.ethereum.org/EIPS/eip-191[ERC-191] and https://eips.ethereum.org/EIPS/eip-712[EIP 712]
* specifications.
*/
library MessageHashUtils {
/**
* @dev Returns the keccak256 digest of an ERC-191 signed data with version
* `0x45` (`personal_sign` messages).
*
* The digest is calculated by prefixing a bytes32 `messageHash` with
* `"\x19Ethereum Signed Message:\n32"` and hashing the result. It corresponds with the
* hash signed when using the https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_sign[`eth_sign`] JSON-RPC method.
*
* NOTE: The `messageHash` parameter is intended to be the result of hashing a raw message with
* keccak256, although any bytes32 value can be safely used because the final digest will
* be re-hashed.
*
* See {ECDSA-recover}.
*/
function toEthSignedMessageHash(bytes32 messageHash) internal pure returns (bytes32 digest) {
assembly ("memory-safe") {
mstore(0x00, "\x19Ethereum Signed Message:\n32") // 32 is the bytes-length of messageHash
mstore(0x1c, messageHash) // 0x1c (28) is the length of the prefix
digest := keccak256(0x00, 0x3c) // 0x3c is the length of the prefix (0x1c) + messageHash (0x20)
}
}
/**
* @dev Returns the keccak256 digest of an ERC-191 signed data with version
* `0x45` (`personal_sign` messages).
*
* The digest is calculated by prefixing an arbitrary `message` with
* `"\x19Ethereum Signed Message:\n" + len(message)` and hashing the result. It corresponds with the
* hash signed when using the https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_sign[`eth_sign`] JSON-RPC method.
*
* See {ECDSA-recover}.
*/
function toEthSignedMessageHash(bytes memory message) internal pure returns (bytes32) {
return
keccak256(bytes.concat("\x19Ethereum Signed Message:\n", bytes(Strings.toString(message.length)), message));
}
/**
* @dev Returns the keccak256 digest of an ERC-191 signed data with version
* `0x00` (data with intended validator).
*
* The digest is calculated by prefixing an arbitrary `data` with `"\x19\x00"` and the intended
* `validator` address. Then hashing the result.
*
* See {ECDSA-recover}.
*/
function toDataWithIntendedValidatorHash(address validator, bytes memory data) internal pure returns (bytes32) {
return keccak256(abi.encodePacked(hex"19_00", validator, data));
}
/**
* @dev Variant of {toDataWithIntendedValidatorHash-address-bytes} optimized for cases where `data` is a bytes32.
*/
function toDataWithIntendedValidatorHash(
address validator,
bytes32 messageHash
) internal pure returns (bytes32 digest) {
assembly ("memory-safe") {
mstore(0x00, hex"19_00")
mstore(0x02, shl(96, validator))
mstore(0x16, messageHash)
digest := keccak256(0x00, 0x36)
}
}
/**
* @dev Returns the keccak256 digest of an EIP-712 typed data (ERC-191 version `0x01`).
*
* The digest is calculated from a `domainSeparator` and a `structHash`, by prefixing them with
* `\x19\x01` and hashing the result. It corresponds to the hash signed by the
* https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`] JSON-RPC method as part of EIP-712.
*
* See {ECDSA-recover}.
*/
function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32 digest) {
assembly ("memory-safe") {
let ptr := mload(0x40)
mstore(ptr, hex"19_01")
mstore(add(ptr, 0x02), domainSeparator)
mstore(add(ptr, 0x22), structHash)
digest := keccak256(ptr, 0x42)
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.3.0) (utils/ShortStrings.sol)
pragma solidity ^0.8.20;
import {StorageSlot} from "./StorageSlot.sol";
// | string | 0xAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA |
// | length | 0x BB |
type ShortString is bytes32;
/**
* @dev This library provides functions to convert short memory strings
* into a `ShortString` type that can be used as an immutable variable.
*
* Strings of arbitrary length can be optimized using this library if
* they are short enough (up to 31 bytes) by packing them with their
* length (1 byte) in a single EVM word (32 bytes). Additionally, a
* fallback mechanism can be used for every other case.
*
* Usage example:
*
* ```solidity
* contract Named {
* using ShortStrings for *;
*
* ShortString private immutable _name;
* string private _nameFallback;
*
* constructor(string memory contractName) {
* _name = contractName.toShortStringWithFallback(_nameFallback);
* }
*
* function name() external view returns (string memory) {
* return _name.toStringWithFallback(_nameFallback);
* }
* }
* ```
*/
library ShortStrings {
// Used as an identifier for strings longer than 31 bytes.
bytes32 private constant FALLBACK_SENTINEL = 0x00000000000000000000000000000000000000000000000000000000000000FF;
error StringTooLong(string str);
error InvalidShortString();
/**
* @dev Encode a string of at most 31 chars into a `ShortString`.
*
* This will trigger a `StringTooLong` error is the input string is too long.
*/
function toShortString(string memory str) internal pure returns (ShortString) {
bytes memory bstr = bytes(str);
if (bstr.length > 31) {
revert StringTooLong(str);
}
return ShortString.wrap(bytes32(uint256(bytes32(bstr)) | bstr.length));
}
/**
* @dev Decode a `ShortString` back to a "normal" string.
*/
function toString(ShortString sstr) internal pure returns (string memory) {
uint256 len = byteLength(sstr);
// using `new string(len)` would work locally but is not memory safe.
string memory str = new string(32);
assembly ("memory-safe") {
mstore(str, len)
mstore(add(str, 0x20), sstr)
}
return str;
}
/**
* @dev Return the length of a `ShortString`.
*/
function byteLength(ShortString sstr) internal pure returns (uint256) {
uint256 result = uint256(ShortString.unwrap(sstr)) & 0xFF;
if (result > 31) {
revert InvalidShortString();
}
return result;
}
/**
* @dev Encode a string into a `ShortString`, or write it to storage if it is too long.
*/
function toShortStringWithFallback(string memory value, string storage store) internal returns (ShortString) {
if (bytes(value).length < 32) {
return toShortString(value);
} else {
StorageSlot.getStringSlot(store).value = value;
return ShortString.wrap(FALLBACK_SENTINEL);
}
}
/**
* @dev Decode a string that was encoded to `ShortString` or written to storage using {toShortStringWithFallback}.
*/
function toStringWithFallback(ShortString value, string storage store) internal pure returns (string memory) {
if (ShortString.unwrap(value) != FALLBACK_SENTINEL) {
return toString(value);
} else {
return store;
}
}
/**
* @dev Return the length of a string that was encoded to `ShortString` or written to storage using
* {toShortStringWithFallback}.
*
* WARNING: This will return the "byte length" of the string. This may not reflect the actual length in terms of
* actual characters as the UTF-8 encoding of a single character can span over multiple bytes.
*/
function byteLengthWithFallback(ShortString value, string storage store) internal view returns (uint256) {
if (ShortString.unwrap(value) != FALLBACK_SENTINEL) {
return byteLength(value);
} else {
return bytes(store).length;
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (interfaces/IERC5267.sol)
pragma solidity >=0.4.16;
interface IERC5267 {
/**
* @dev MAY be emitted to signal that the domain could have changed.
*/
event EIP712DomainChanged();
/**
* @dev returns the fields and values that describe the domain separator used by this contract for EIP-712
* signature.
*/
function eip712Domain()
external
view
returns (
bytes1 fields,
string memory name,
string memory version,
uint256 chainId,
address verifyingContract,
bytes32 salt,
uint256[] memory extensions
);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/cryptography/ECDSA.sol)
pragma solidity ^0.8.20;
/**
* @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.
*
* These functions can be used to verify that a message was signed by the holder
* of the private keys of a given address.
*/
library ECDSA {
enum RecoverError {
NoError,
InvalidSignature,
InvalidSignatureLength,
InvalidSignatureS
}
/**
* @dev The signature derives the `address(0)`.
*/
error ECDSAInvalidSignature();
/**
* @dev The signature has an invalid length.
*/
error ECDSAInvalidSignatureLength(uint256 length);
/**
* @dev The signature has an S value that is in the upper half order.
*/
error ECDSAInvalidSignatureS(bytes32 s);
/**
* @dev Returns the address that signed a hashed message (`hash`) with `signature` or an error. This will not
* return address(0) without also returning an error description. Errors are documented using an enum (error type)
* and a bytes32 providing additional information about the error.
*
* If no error is returned, then the address can be used for verification purposes.
*
* The `ecrecover` EVM precompile allows for malleable (non-unique) signatures:
* this function rejects them by requiring the `s` value to be in the lower
* half order, and the `v` value to be either 27 or 28.
*
* IMPORTANT: `hash` _must_ be the result of a hash operation for the
* verification to be secure: it is possible to craft signatures that
* recover to arbitrary addresses for non-hashed data. A safe way to ensure
* this is by receiving a hash of the original message (which may otherwise
* be too long), and then calling {MessageHashUtils-toEthSignedMessageHash} on it.
*
* Documentation for signature generation:
* - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]
* - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]
*/
function tryRecover(
bytes32 hash,
bytes memory signature
) internal pure returns (address recovered, RecoverError err, bytes32 errArg) {
if (signature.length == 65) {
bytes32 r;
bytes32 s;
uint8 v;
// ecrecover takes the signature parameters, and the only way to get them
// currently is to use assembly.
assembly ("memory-safe") {
r := mload(add(signature, 0x20))
s := mload(add(signature, 0x40))
v := byte(0, mload(add(signature, 0x60)))
}
return tryRecover(hash, v, r, s);
} else {
return (address(0), RecoverError.InvalidSignatureLength, bytes32(signature.length));
}
}
/**
* @dev Returns the address that signed a hashed message (`hash`) with
* `signature`. This address can then be used for verification purposes.
*
* The `ecrecover` EVM precompile allows for malleable (non-unique) signatures:
* this function rejects them by requiring the `s` value to be in the lower
* half order, and the `v` value to be either 27 or 28.
*
* IMPORTANT: `hash` _must_ be the result of a hash operation for the
* verification to be secure: it is possible to craft signatures that
* recover to arbitrary addresses for non-hashed data. A safe way to ensure
* this is by receiving a hash of the original message (which may otherwise
* be too long), and then calling {MessageHashUtils-toEthSignedMessageHash} on it.
*/
function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {
(address recovered, RecoverError error, bytes32 errorArg) = tryRecover(hash, signature);
_throwError(error, errorArg);
return recovered;
}
/**
* @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.
*
* See https://eips.ethereum.org/EIPS/eip-2098[ERC-2098 short signatures]
*/
function tryRecover(
bytes32 hash,
bytes32 r,
bytes32 vs
) internal pure returns (address recovered, RecoverError err, bytes32 errArg) {
unchecked {
bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);
// We do not check for an overflow here since the shift operation results in 0 or 1.
uint8 v = uint8((uint256(vs) >> 255) + 27);
return tryRecover(hash, v, r, s);
}
}
/**
* @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.
*/
function recover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address) {
(address recovered, RecoverError error, bytes32 errorArg) = tryRecover(hash, r, vs);
_throwError(error, errorArg);
return recovered;
}
/**
* @dev Overload of {ECDSA-tryRecover} that receives the `v`,
* `r` and `s` signature fields separately.
*/
function tryRecover(
bytes32 hash,
uint8 v,
bytes32 r,
bytes32 s
) internal pure returns (address recovered, RecoverError err, bytes32 errArg) {
// EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature
// unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines
// the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most
// signatures from current libraries generate a unique signature with an s-value in the lower half order.
//
// If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value
// with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or
// vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept
// these malleable signatures as well.
if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {
return (address(0), RecoverError.InvalidSignatureS, s);
}
// If the signature is valid (and not malleable), return the signer address
address signer = ecrecover(hash, v, r, s);
if (signer == address(0)) {
return (address(0), RecoverError.InvalidSignature, bytes32(0));
}
return (signer, RecoverError.NoError, bytes32(0));
}
/**
* @dev Overload of {ECDSA-recover} that receives the `v`,
* `r` and `s` signature fields separately.
*/
function recover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) internal pure returns (address) {
(address recovered, RecoverError error, bytes32 errorArg) = tryRecover(hash, v, r, s);
_throwError(error, errorArg);
return recovered;
}
/**
* @dev Optionally reverts with the corresponding custom error according to the `error` argument provided.
*/
function _throwError(RecoverError error, bytes32 errorArg) private pure {
if (error == RecoverError.NoError) {
return; // no error: do nothing
} else if (error == RecoverError.InvalidSignature) {
revert ECDSAInvalidSignature();
} else if (error == RecoverError.InvalidSignatureLength) {
revert ECDSAInvalidSignatureLength(uint256(errorArg));
} else if (error == RecoverError.InvalidSignatureS) {
revert ECDSAInvalidSignatureS(errorArg);
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (interfaces/IERC1271.sol)
pragma solidity >=0.5.0;
/**
* @dev Interface of the ERC-1271 standard signature validation method for
* contracts as defined in https://eips.ethereum.org/EIPS/eip-1271[ERC-1271].
*/
interface IERC1271 {
/**
* @dev Should return whether the signature provided is valid for the provided data
* @param hash Hash of the data to be signed
* @param signature Signature byte array associated with `hash`
*/
function isValidSignature(bytes32 hash, bytes calldata signature) external view returns (bytes4 magicValue);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (interfaces/IERC7913.sol)
pragma solidity >=0.5.0;
/**
* @dev Signature verifier interface.
*/
interface IERC7913SignatureVerifier {
/**
* @dev Verifies `signature` as a valid signature of `hash` by `key`.
*
* MUST return the bytes4 magic value IERC7913SignatureVerifier.verify.selector if the signature is valid.
* SHOULD return 0xffffffff or revert if the signature is not valid.
* SHOULD return 0xffffffff or revert if the key is empty
*/
function verify(bytes calldata key, bytes32 hash, bytes calldata signature) external view returns (bytes4);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (utils/Bytes.sol)
pragma solidity ^0.8.24;
import {Math} from "./math/Math.sol";
/**
* @dev Bytes operations.
*/
library Bytes {
/**
* @dev Forward search for `s` in `buffer`
* * If `s` is present in the buffer, returns the index of the first instance
* * If `s` is not present in the buffer, returns type(uint256).max
*
* NOTE: replicates the behavior of https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/indexOf[Javascript's `Array.indexOf`]
*/
function indexOf(bytes memory buffer, bytes1 s) internal pure returns (uint256) {
return indexOf(buffer, s, 0);
}
/**
* @dev Forward search for `s` in `buffer` starting at position `pos`
* * If `s` is present in the buffer (at or after `pos`), returns the index of the next instance
* * If `s` is not present in the buffer (at or after `pos`), returns type(uint256).max
*
* NOTE: replicates the behavior of https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/indexOf[Javascript's `Array.indexOf`]
*/
function indexOf(bytes memory buffer, bytes1 s, uint256 pos) internal pure returns (uint256) {
uint256 length = buffer.length;
for (uint256 i = pos; i < length; ++i) {
if (bytes1(_unsafeReadBytesOffset(buffer, i)) == s) {
return i;
}
}
return type(uint256).max;
}
/**
* @dev Backward search for `s` in `buffer`
* * If `s` is present in the buffer, returns the index of the last instance
* * If `s` is not present in the buffer, returns type(uint256).max
*
* NOTE: replicates the behavior of https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/lastIndexOf[Javascript's `Array.lastIndexOf`]
*/
function lastIndexOf(bytes memory buffer, bytes1 s) internal pure returns (uint256) {
return lastIndexOf(buffer, s, type(uint256).max);
}
/**
* @dev Backward search for `s` in `buffer` starting at position `pos`
* * If `s` is present in the buffer (at or before `pos`), returns the index of the previous instance
* * If `s` is not present in the buffer (at or before `pos`), returns type(uint256).max
*
* NOTE: replicates the behavior of https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/lastIndexOf[Javascript's `Array.lastIndexOf`]
*/
function lastIndexOf(bytes memory buffer, bytes1 s, uint256 pos) internal pure returns (uint256) {
unchecked {
uint256 length = buffer.length;
for (uint256 i = Math.min(Math.saturatingAdd(pos, 1), length); i > 0; --i) {
if (bytes1(_unsafeReadBytesOffset(buffer, i - 1)) == s) {
return i - 1;
}
}
return type(uint256).max;
}
}
/**
* @dev Copies the content of `buffer`, from `start` (included) to the end of `buffer` into a new bytes object in
* memory.
*
* NOTE: replicates the behavior of https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/slice[Javascript's `Array.slice`]
*/
function slice(bytes memory buffer, uint256 start) internal pure returns (bytes memory) {
return slice(buffer, start, buffer.length);
}
/**
* @dev Copies the content of `buffer`, from `start` (included) to `end` (excluded) into a new bytes object in
* memory.
*
* NOTE: replicates the behavior of https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/slice[Javascript's `Array.slice`]
*/
function slice(bytes memory buffer, uint256 start, uint256 end) internal pure returns (bytes memory) {
// sanitize
uint256 length = buffer.length;
end = Math.min(end, length);
start = Math.min(start, end);
// allocate and copy
bytes memory result = new bytes(end - start);
assembly ("memory-safe") {
mcopy(add(result, 0x20), add(add(buffer, 0x20), start), sub(end, start))
}
return result;
}
/**
* @dev Reads a bytes32 from a bytes array without bounds checking.
*
* NOTE: making this function internal would mean it could be used with memory unsafe offset, and marking the
* assembly block as such would prevent some optimizations.
*/
function _unsafeReadBytesOffset(bytes memory buffer, uint256 offset) private pure returns (bytes32 value) {
// This is not memory safe in the general case, but all calls to this private function are within bounds.
assembly ("memory-safe") {
value := mload(add(add(buffer, 0x20), offset))
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.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.1.0) (utils/Panic.sol)
pragma solidity ^0.8.20;
/**
* @dev Helper library for emitting standardized panic codes.
*
* ```solidity
* contract Example {
* using Panic for uint256;
*
* // Use any of the declared internal constants
* function foo() { Panic.GENERIC.panic(); }
*
* // Alternatively
* function foo() { Panic.panic(Panic.GENERIC); }
* }
* ```
*
* Follows the list from https://github.com/ethereum/solidity/blob/v0.8.24/libsolutil/ErrorCodes.h[libsolutil].
*
* _Available since v5.1._
*/
// slither-disable-next-line unused-state
library Panic {
/// @dev generic / unspecified error
uint256 internal constant GENERIC = 0x00;
/// @dev used by the assert() builtin
uint256 internal constant ASSERT = 0x01;
/// @dev arithmetic underflow or overflow
uint256 internal constant UNDER_OVERFLOW = 0x11;
/// @dev division or modulo by zero
uint256 internal constant DIVISION_BY_ZERO = 0x12;
/// @dev enum conversion error
uint256 internal constant ENUM_CONVERSION_ERROR = 0x21;
/// @dev invalid encoding in storage
uint256 internal constant STORAGE_ENCODING_ERROR = 0x22;
/// @dev empty array pop
uint256 internal constant EMPTY_ARRAY_POP = 0x31;
/// @dev array out of bounds access
uint256 internal constant ARRAY_OUT_OF_BOUNDS = 0x32;
/// @dev resource error (too large allocation or too large array)
uint256 internal constant RESOURCE_ERROR = 0x41;
/// @dev calling invalid internal function
uint256 internal constant INVALID_INTERNAL_FUNCTION = 0x51;
/// @dev Reverts with a panic code. Recommended to use with
/// the internal constants with predefined codes.
function panic(uint256 code) internal pure {
assembly ("memory-safe") {
mstore(0x00, 0x4e487b71)
mstore(0x20, code)
revert(0x1c, 0x24)
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/math/SafeCast.sol)
// This file was procedurally generated from scripts/generate/templates/SafeCast.js.
pragma solidity ^0.8.20;
/**
* @dev Wrappers over Solidity's uintXX/intXX/bool casting operators with added overflow
* checks.
*
* Downcasting from uint256/int256 in Solidity does not revert on overflow. This can
* easily result in undesired exploitation or bugs, since developers usually
* assume that overflows raise errors. `SafeCast` restores this intuition by
* reverting the transaction when such an operation overflows.
*
* Using this library instead of the unchecked operations eliminates an entire
* class of bugs, so it's recommended to use it always.
*/
library SafeCast {
/**
* @dev Value doesn't fit in an uint of `bits` size.
*/
error SafeCastOverflowedUintDowncast(uint8 bits, uint256 value);
/**
* @dev An int value doesn't fit in an uint of `bits` size.
*/
error SafeCastOverflowedIntToUint(int256 value);
/**
* @dev Value doesn't fit in an int of `bits` size.
*/
error SafeCastOverflowedIntDowncast(uint8 bits, int256 value);
/**
* @dev An uint value doesn't fit in an int of `bits` size.
*/
error SafeCastOverflowedUintToInt(uint256 value);
/**
* @dev Returns the downcasted uint248 from uint256, reverting on
* overflow (when the input is greater than largest uint248).
*
* Counterpart to Solidity's `uint248` operator.
*
* Requirements:
*
* - input must fit into 248 bits
*/
function toUint248(uint256 value) internal pure returns (uint248) {
if (value > type(uint248).max) {
revert SafeCastOverflowedUintDowncast(248, value);
}
return uint248(value);
}
/**
* @dev Returns the downcasted uint240 from uint256, reverting on
* overflow (when the input is greater than largest uint240).
*
* Counterpart to Solidity's `uint240` operator.
*
* Requirements:
*
* - input must fit into 240 bits
*/
function toUint240(uint256 value) internal pure returns (uint240) {
if (value > type(uint240).max) {
revert SafeCastOverflowedUintDowncast(240, value);
}
return uint240(value);
}
/**
* @dev Returns the downcasted uint232 from uint256, reverting on
* overflow (when the input is greater than largest uint232).
*
* Counterpart to Solidity's `uint232` operator.
*
* Requirements:
*
* - input must fit into 232 bits
*/
function toUint232(uint256 value) internal pure returns (uint232) {
if (value > type(uint232).max) {
revert SafeCastOverflowedUintDowncast(232, value);
}
return uint232(value);
}
/**
* @dev Returns the downcasted uint224 from uint256, reverting on
* overflow (when the input is greater than largest uint224).
*
* Counterpart to Solidity's `uint224` operator.
*
* Requirements:
*
* - input must fit into 224 bits
*/
function toUint224(uint256 value) internal pure returns (uint224) {
if (value > type(uint224).max) {
revert SafeCastOverflowedUintDowncast(224, value);
}
return uint224(value);
}
/**
* @dev Returns the downcasted uint216 from uint256, reverting on
* overflow (when the input is greater than largest uint216).
*
* Counterpart to Solidity's `uint216` operator.
*
* Requirements:
*
* - input must fit into 216 bits
*/
function toUint216(uint256 value) internal pure returns (uint216) {
if (value > type(uint216).max) {
revert SafeCastOverflowedUintDowncast(216, value);
}
return uint216(value);
}
/**
* @dev Returns the downcasted uint208 from uint256, reverting on
* overflow (when the input is greater than largest uint208).
*
* Counterpart to Solidity's `uint208` operator.
*
* Requirements:
*
* - input must fit into 208 bits
*/
function toUint208(uint256 value) internal pure returns (uint208) {
if (value > type(uint208).max) {
revert SafeCastOverflowedUintDowncast(208, value);
}
return uint208(value);
}
/**
* @dev Returns the downcasted uint200 from uint256, reverting on
* overflow (when the input is greater than largest uint200).
*
* Counterpart to Solidity's `uint200` operator.
*
* Requirements:
*
* - input must fit into 200 bits
*/
function toUint200(uint256 value) internal pure returns (uint200) {
if (value > type(uint200).max) {
revert SafeCastOverflowedUintDowncast(200, value);
}
return uint200(value);
}
/**
* @dev Returns the downcasted uint192 from uint256, reverting on
* overflow (when the input is greater than largest uint192).
*
* Counterpart to Solidity's `uint192` operator.
*
* Requirements:
*
* - input must fit into 192 bits
*/
function toUint192(uint256 value) internal pure returns (uint192) {
if (value > type(uint192).max) {
revert SafeCastOverflowedUintDowncast(192, value);
}
return uint192(value);
}
/**
* @dev Returns the downcasted uint184 from uint256, reverting on
* overflow (when the input is greater than largest uint184).
*
* Counterpart to Solidity's `uint184` operator.
*
* Requirements:
*
* - input must fit into 184 bits
*/
function toUint184(uint256 value) internal pure returns (uint184) {
if (value > type(uint184).max) {
revert SafeCastOverflowedUintDowncast(184, value);
}
return uint184(value);
}
/**
* @dev Returns the downcasted uint176 from uint256, reverting on
* overflow (when the input is greater than largest uint176).
*
* Counterpart to Solidity's `uint176` operator.
*
* Requirements:
*
* - input must fit into 176 bits
*/
function toUint176(uint256 value) internal pure returns (uint176) {
if (value > type(uint176).max) {
revert SafeCastOverflowedUintDowncast(176, value);
}
return uint176(value);
}
/**
* @dev Returns the downcasted uint168 from uint256, reverting on
* overflow (when the input is greater than largest uint168).
*
* Counterpart to Solidity's `uint168` operator.
*
* Requirements:
*
* - input must fit into 168 bits
*/
function toUint168(uint256 value) internal pure returns (uint168) {
if (value > type(uint168).max) {
revert SafeCastOverflowedUintDowncast(168, value);
}
return uint168(value);
}
/**
* @dev Returns the downcasted uint160 from uint256, reverting on
* overflow (when the input is greater than largest uint160).
*
* Counterpart to Solidity's `uint160` operator.
*
* Requirements:
*
* - input must fit into 160 bits
*/
function toUint160(uint256 value) internal pure returns (uint160) {
if (value > type(uint160).max) {
revert SafeCastOverflowedUintDowncast(160, value);
}
return uint160(value);
}
/**
* @dev Returns the downcasted uint152 from uint256, reverting on
* overflow (when the input is greater than largest uint152).
*
* Counterpart to Solidity's `uint152` operator.
*
* Requirements:
*
* - input must fit into 152 bits
*/
function toUint152(uint256 value) internal pure returns (uint152) {
if (value > type(uint152).max) {
revert SafeCastOverflowedUintDowncast(152, value);
}
return uint152(value);
}
/**
* @dev Returns the downcasted uint144 from uint256, reverting on
* overflow (when the input is greater than largest uint144).
*
* Counterpart to Solidity's `uint144` operator.
*
* Requirements:
*
* - input must fit into 144 bits
*/
function toUint144(uint256 value) internal pure returns (uint144) {
if (value > type(uint144).max) {
revert SafeCastOverflowedUintDowncast(144, value);
}
return uint144(value);
}
/**
* @dev Returns the downcasted uint136 from uint256, reverting on
* overflow (when the input is greater than largest uint136).
*
* Counterpart to Solidity's `uint136` operator.
*
* Requirements:
*
* - input must fit into 136 bits
*/
function toUint136(uint256 value) internal pure returns (uint136) {
if (value > type(uint136).max) {
revert SafeCastOverflowedUintDowncast(136, value);
}
return uint136(value);
}
/**
* @dev Returns the downcasted uint128 from uint256, reverting on
* overflow (when the input is greater than largest uint128).
*
* Counterpart to Solidity's `uint128` operator.
*
* Requirements:
*
* - input must fit into 128 bits
*/
function toUint128(uint256 value) internal pure returns (uint128) {
if (value > type(uint128).max) {
revert SafeCastOverflowedUintDowncast(128, value);
}
return uint128(value);
}
/**
* @dev Returns the downcasted uint120 from uint256, reverting on
* overflow (when the input is greater than largest uint120).
*
* Counterpart to Solidity's `uint120` operator.
*
* Requirements:
*
* - input must fit into 120 bits
*/
function toUint120(uint256 value) internal pure returns (uint120) {
if (value > type(uint120).max) {
revert SafeCastOverflowedUintDowncast(120, value);
}
return uint120(value);
}
/**
* @dev Returns the downcasted uint112 from uint256, reverting on
* overflow (when the input is greater than largest uint112).
*
* Counterpart to Solidity's `uint112` operator.
*
* Requirements:
*
* - input must fit into 112 bits
*/
function toUint112(uint256 value) internal pure returns (uint112) {
if (value > type(uint112).max) {
revert SafeCastOverflowedUintDowncast(112, value);
}
return uint112(value);
}
/**
* @dev Returns the downcasted uint104 from uint256, reverting on
* overflow (when the input is greater than largest uint104).
*
* Counterpart to Solidity's `uint104` operator.
*
* Requirements:
*
* - input must fit into 104 bits
*/
function toUint104(uint256 value) internal pure returns (uint104) {
if (value > type(uint104).max) {
revert SafeCastOverflowedUintDowncast(104, value);
}
return uint104(value);
}
/**
* @dev Returns the downcasted uint96 from uint256, reverting on
* overflow (when the input is greater than largest uint96).
*
* Counterpart to Solidity's `uint96` operator.
*
* Requirements:
*
* - input must fit into 96 bits
*/
function toUint96(uint256 value) internal pure returns (uint96) {
if (value > type(uint96).max) {
revert SafeCastOverflowedUintDowncast(96, value);
}
return uint96(value);
}
/**
* @dev Returns the downcasted uint88 from uint256, reverting on
* overflow (when the input is greater than largest uint88).
*
* Counterpart to Solidity's `uint88` operator.
*
* Requirements:
*
* - input must fit into 88 bits
*/
function toUint88(uint256 value) internal pure returns (uint88) {
if (value > type(uint88).max) {
revert SafeCastOverflowedUintDowncast(88, value);
}
return uint88(value);
}
/**
* @dev Returns the downcasted uint80 from uint256, reverting on
* overflow (when the input is greater than largest uint80).
*
* Counterpart to Solidity's `uint80` operator.
*
* Requirements:
*
* - input must fit into 80 bits
*/
function toUint80(uint256 value) internal pure returns (uint80) {
if (value > type(uint80).max) {
revert SafeCastOverflowedUintDowncast(80, value);
}
return uint80(value);
}
/**
* @dev Returns the downcasted uint72 from uint256, reverting on
* overflow (when the input is greater than largest uint72).
*
* Counterpart to Solidity's `uint72` operator.
*
* Requirements:
*
* - input must fit into 72 bits
*/
function toUint72(uint256 value) internal pure returns (uint72) {
if (value > type(uint72).max) {
revert SafeCastOverflowedUintDowncast(72, value);
}
return uint72(value);
}
/**
* @dev Returns the downcasted uint64 from uint256, reverting on
* overflow (when the input is greater than largest uint64).
*
* Counterpart to Solidity's `uint64` operator.
*
* Requirements:
*
* - input must fit into 64 bits
*/
function toUint64(uint256 value) internal pure returns (uint64) {
if (value > type(uint64).max) {
revert SafeCastOverflowedUintDowncast(64, value);
}
return uint64(value);
}
/**
* @dev Returns the downcasted uint56 from uint256, reverting on
* overflow (when the input is greater than largest uint56).
*
* Counterpart to Solidity's `uint56` operator.
*
* Requirements:
*
* - input must fit into 56 bits
*/
function toUint56(uint256 value) internal pure returns (uint56) {
if (value > type(uint56).max) {
revert SafeCastOverflowedUintDowncast(56, value);
}
return uint56(value);
}
/**
* @dev Returns the downcasted uint48 from uint256, reverting on
* overflow (when the input is greater than largest uint48).
*
* Counterpart to Solidity's `uint48` operator.
*
* Requirements:
*
* - input must fit into 48 bits
*/
function toUint48(uint256 value) internal pure returns (uint48) {
if (value > type(uint48).max) {
revert SafeCastOverflowedUintDowncast(48, value);
}
return uint48(value);
}
/**
* @dev Returns the downcasted uint40 from uint256, reverting on
* overflow (when the input is greater than largest uint40).
*
* Counterpart to Solidity's `uint40` operator.
*
* Requirements:
*
* - input must fit into 40 bits
*/
function toUint40(uint256 value) internal pure returns (uint40) {
if (value > type(uint40).max) {
revert SafeCastOverflowedUintDowncast(40, value);
}
return uint40(value);
}
/**
* @dev Returns the downcasted uint32 from uint256, reverting on
* overflow (when the input is greater than largest uint32).
*
* Counterpart to Solidity's `uint32` operator.
*
* Requirements:
*
* - input must fit into 32 bits
*/
function toUint32(uint256 value) internal pure returns (uint32) {
if (value > type(uint32).max) {
revert SafeCastOverflowedUintDowncast(32, value);
}
return uint32(value);
}
/**
* @dev Returns the downcasted uint24 from uint256, reverting on
* overflow (when the input is greater than largest uint24).
*
* Counterpart to Solidity's `uint24` operator.
*
* Requirements:
*
* - input must fit into 24 bits
*/
function toUint24(uint256 value) internal pure returns (uint24) {
if (value > type(uint24).max) {
revert SafeCastOverflowedUintDowncast(24, value);
}
return uint24(value);
}
/**
* @dev Returns the downcasted uint16 from uint256, reverting on
* overflow (when the input is greater than largest uint16).
*
* Counterpart to Solidity's `uint16` operator.
*
* Requirements:
*
* - input must fit into 16 bits
*/
function toUint16(uint256 value) internal pure returns (uint16) {
if (value > type(uint16).max) {
revert SafeCastOverflowedUintDowncast(16, value);
}
return uint16(value);
}
/**
* @dev Returns the downcasted uint8 from uint256, reverting on
* overflow (when the input is greater than largest uint8).
*
* Counterpart to Solidity's `uint8` operator.
*
* Requirements:
*
* - input must fit into 8 bits
*/
function toUint8(uint256 value) internal pure returns (uint8) {
if (value > type(uint8).max) {
revert SafeCastOverflowedUintDowncast(8, value);
}
return uint8(value);
}
/**
* @dev Converts a signed int256 into an unsigned uint256.
*
* Requirements:
*
* - input must be greater than or equal to 0.
*/
function toUint256(int256 value) internal pure returns (uint256) {
if (value < 0) {
revert SafeCastOverflowedIntToUint(value);
}
return uint256(value);
}
/**
* @dev Returns the downcasted int248 from int256, reverting on
* overflow (when the input is less than smallest int248 or
* greater than largest int248).
*
* Counterpart to Solidity's `int248` operator.
*
* Requirements:
*
* - input must fit into 248 bits
*/
function toInt248(int256 value) internal pure returns (int248 downcasted) {
downcasted = int248(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(248, value);
}
}
/**
* @dev Returns the downcasted int240 from int256, reverting on
* overflow (when the input is less than smallest int240 or
* greater than largest int240).
*
* Counterpart to Solidity's `int240` operator.
*
* Requirements:
*
* - input must fit into 240 bits
*/
function toInt240(int256 value) internal pure returns (int240 downcasted) {
downcasted = int240(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(240, value);
}
}
/**
* @dev Returns the downcasted int232 from int256, reverting on
* overflow (when the input is less than smallest int232 or
* greater than largest int232).
*
* Counterpart to Solidity's `int232` operator.
*
* Requirements:
*
* - input must fit into 232 bits
*/
function toInt232(int256 value) internal pure returns (int232 downcasted) {
downcasted = int232(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(232, value);
}
}
/**
* @dev Returns the downcasted int224 from int256, reverting on
* overflow (when the input is less than smallest int224 or
* greater than largest int224).
*
* Counterpart to Solidity's `int224` operator.
*
* Requirements:
*
* - input must fit into 224 bits
*/
function toInt224(int256 value) internal pure returns (int224 downcasted) {
downcasted = int224(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(224, value);
}
}
/**
* @dev Returns the downcasted int216 from int256, reverting on
* overflow (when the input is less than smallest int216 or
* greater than largest int216).
*
* Counterpart to Solidity's `int216` operator.
*
* Requirements:
*
* - input must fit into 216 bits
*/
function toInt216(int256 value) internal pure returns (int216 downcasted) {
downcasted = int216(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(216, value);
}
}
/**
* @dev Returns the downcasted int208 from int256, reverting on
* overflow (when the input is less than smallest int208 or
* greater than largest int208).
*
* Counterpart to Solidity's `int208` operator.
*
* Requirements:
*
* - input must fit into 208 bits
*/
function toInt208(int256 value) internal pure returns (int208 downcasted) {
downcasted = int208(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(208, value);
}
}
/**
* @dev Returns the downcasted int200 from int256, reverting on
* overflow (when the input is less than smallest int200 or
* greater than largest int200).
*
* Counterpart to Solidity's `int200` operator.
*
* Requirements:
*
* - input must fit into 200 bits
*/
function toInt200(int256 value) internal pure returns (int200 downcasted) {
downcasted = int200(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(200, value);
}
}
/**
* @dev Returns the downcasted int192 from int256, reverting on
* overflow (when the input is less than smallest int192 or
* greater than largest int192).
*
* Counterpart to Solidity's `int192` operator.
*
* Requirements:
*
* - input must fit into 192 bits
*/
function toInt192(int256 value) internal pure returns (int192 downcasted) {
downcasted = int192(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(192, value);
}
}
/**
* @dev Returns the downcasted int184 from int256, reverting on
* overflow (when the input is less than smallest int184 or
* greater than largest int184).
*
* Counterpart to Solidity's `int184` operator.
*
* Requirements:
*
* - input must fit into 184 bits
*/
function toInt184(int256 value) internal pure returns (int184 downcasted) {
downcasted = int184(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(184, value);
}
}
/**
* @dev Returns the downcasted int176 from int256, reverting on
* overflow (when the input is less than smallest int176 or
* greater than largest int176).
*
* Counterpart to Solidity's `int176` operator.
*
* Requirements:
*
* - input must fit into 176 bits
*/
function toInt176(int256 value) internal pure returns (int176 downcasted) {
downcasted = int176(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(176, value);
}
}
/**
* @dev Returns the downcasted int168 from int256, reverting on
* overflow (when the input is less than smallest int168 or
* greater than largest int168).
*
* Counterpart to Solidity's `int168` operator.
*
* Requirements:
*
* - input must fit into 168 bits
*/
function toInt168(int256 value) internal pure returns (int168 downcasted) {
downcasted = int168(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(168, value);
}
}
/**
* @dev Returns the downcasted int160 from int256, reverting on
* overflow (when the input is less than smallest int160 or
* greater than largest int160).
*
* Counterpart to Solidity's `int160` operator.
*
* Requirements:
*
* - input must fit into 160 bits
*/
function toInt160(int256 value) internal pure returns (int160 downcasted) {
downcasted = int160(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(160, value);
}
}
/**
* @dev Returns the downcasted int152 from int256, reverting on
* overflow (when the input is less than smallest int152 or
* greater than largest int152).
*
* Counterpart to Solidity's `int152` operator.
*
* Requirements:
*
* - input must fit into 152 bits
*/
function toInt152(int256 value) internal pure returns (int152 downcasted) {
downcasted = int152(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(152, value);
}
}
/**
* @dev Returns the downcasted int144 from int256, reverting on
* overflow (when the input is less than smallest int144 or
* greater than largest int144).
*
* Counterpart to Solidity's `int144` operator.
*
* Requirements:
*
* - input must fit into 144 bits
*/
function toInt144(int256 value) internal pure returns (int144 downcasted) {
downcasted = int144(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(144, value);
}
}
/**
* @dev Returns the downcasted int136 from int256, reverting on
* overflow (when the input is less than smallest int136 or
* greater than largest int136).
*
* Counterpart to Solidity's `int136` operator.
*
* Requirements:
*
* - input must fit into 136 bits
*/
function toInt136(int256 value) internal pure returns (int136 downcasted) {
downcasted = int136(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(136, value);
}
}
/**
* @dev Returns the downcasted int128 from int256, reverting on
* overflow (when the input is less than smallest int128 or
* greater than largest int128).
*
* Counterpart to Solidity's `int128` operator.
*
* Requirements:
*
* - input must fit into 128 bits
*/
function toInt128(int256 value) internal pure returns (int128 downcasted) {
downcasted = int128(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(128, value);
}
}
/**
* @dev Returns the downcasted int120 from int256, reverting on
* overflow (when the input is less than smallest int120 or
* greater than largest int120).
*
* Counterpart to Solidity's `int120` operator.
*
* Requirements:
*
* - input must fit into 120 bits
*/
function toInt120(int256 value) internal pure returns (int120 downcasted) {
downcasted = int120(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(120, value);
}
}
/**
* @dev Returns the downcasted int112 from int256, reverting on
* overflow (when the input is less than smallest int112 or
* greater than largest int112).
*
* Counterpart to Solidity's `int112` operator.
*
* Requirements:
*
* - input must fit into 112 bits
*/
function toInt112(int256 value) internal pure returns (int112 downcasted) {
downcasted = int112(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(112, value);
}
}
/**
* @dev Returns the downcasted int104 from int256, reverting on
* overflow (when the input is less than smallest int104 or
* greater than largest int104).
*
* Counterpart to Solidity's `int104` operator.
*
* Requirements:
*
* - input must fit into 104 bits
*/
function toInt104(int256 value) internal pure returns (int104 downcasted) {
downcasted = int104(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(104, value);
}
}
/**
* @dev Returns the downcasted int96 from int256, reverting on
* overflow (when the input is less than smallest int96 or
* greater than largest int96).
*
* Counterpart to Solidity's `int96` operator.
*
* Requirements:
*
* - input must fit into 96 bits
*/
function toInt96(int256 value) internal pure returns (int96 downcasted) {
downcasted = int96(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(96, value);
}
}
/**
* @dev Returns the downcasted int88 from int256, reverting on
* overflow (when the input is less than smallest int88 or
* greater than largest int88).
*
* Counterpart to Solidity's `int88` operator.
*
* Requirements:
*
* - input must fit into 88 bits
*/
function toInt88(int256 value) internal pure returns (int88 downcasted) {
downcasted = int88(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(88, value);
}
}
/**
* @dev Returns the downcasted int80 from int256, reverting on
* overflow (when the input is less than smallest int80 or
* greater than largest int80).
*
* Counterpart to Solidity's `int80` operator.
*
* Requirements:
*
* - input must fit into 80 bits
*/
function toInt80(int256 value) internal pure returns (int80 downcasted) {
downcasted = int80(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(80, value);
}
}
/**
* @dev Returns the downcasted int72 from int256, reverting on
* overflow (when the input is less than smallest int72 or
* greater than largest int72).
*
* Counterpart to Solidity's `int72` operator.
*
* Requirements:
*
* - input must fit into 72 bits
*/
function toInt72(int256 value) internal pure returns (int72 downcasted) {
downcasted = int72(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(72, value);
}
}
/**
* @dev Returns the downcasted int64 from int256, reverting on
* overflow (when the input is less than smallest int64 or
* greater than largest int64).
*
* Counterpart to Solidity's `int64` operator.
*
* Requirements:
*
* - input must fit into 64 bits
*/
function toInt64(int256 value) internal pure returns (int64 downcasted) {
downcasted = int64(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(64, value);
}
}
/**
* @dev Returns the downcasted int56 from int256, reverting on
* overflow (when the input is less than smallest int56 or
* greater than largest int56).
*
* Counterpart to Solidity's `int56` operator.
*
* Requirements:
*
* - input must fit into 56 bits
*/
function toInt56(int256 value) internal pure returns (int56 downcasted) {
downcasted = int56(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(56, value);
}
}
/**
* @dev Returns the downcasted int48 from int256, reverting on
* overflow (when the input is less than smallest int48 or
* greater than largest int48).
*
* Counterpart to Solidity's `int48` operator.
*
* Requirements:
*
* - input must fit into 48 bits
*/
function toInt48(int256 value) internal pure returns (int48 downcasted) {
downcasted = int48(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(48, value);
}
}
/**
* @dev Returns the downcasted int40 from int256, reverting on
* overflow (when the input is less than smallest int40 or
* greater than largest int40).
*
* Counterpart to Solidity's `int40` operator.
*
* Requirements:
*
* - input must fit into 40 bits
*/
function toInt40(int256 value) internal pure returns (int40 downcasted) {
downcasted = int40(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(40, value);
}
}
/**
* @dev Returns the downcasted int32 from int256, reverting on
* overflow (when the input is less than smallest int32 or
* greater than largest int32).
*
* Counterpart to Solidity's `int32` operator.
*
* Requirements:
*
* - input must fit into 32 bits
*/
function toInt32(int256 value) internal pure returns (int32 downcasted) {
downcasted = int32(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(32, value);
}
}
/**
* @dev Returns the downcasted int24 from int256, reverting on
* overflow (when the input is less than smallest int24 or
* greater than largest int24).
*
* Counterpart to Solidity's `int24` operator.
*
* Requirements:
*
* - input must fit into 24 bits
*/
function toInt24(int256 value) internal pure returns (int24 downcasted) {
downcasted = int24(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(24, value);
}
}
/**
* @dev Returns the downcasted int16 from int256, reverting on
* overflow (when the input is less than smallest int16 or
* greater than largest int16).
*
* Counterpart to Solidity's `int16` operator.
*
* Requirements:
*
* - input must fit into 16 bits
*/
function toInt16(int256 value) internal pure returns (int16 downcasted) {
downcasted = int16(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(16, value);
}
}
/**
* @dev Returns the downcasted int8 from int256, reverting on
* overflow (when the input is less than smallest int8 or
* greater than largest int8).
*
* Counterpart to Solidity's `int8` operator.
*
* Requirements:
*
* - input must fit into 8 bits
*/
function toInt8(int256 value) internal pure returns (int8 downcasted) {
downcasted = int8(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(8, value);
}
}
/**
* @dev Converts an unsigned uint256 into a signed int256.
*
* Requirements:
*
* - input must be less than or equal to maxInt256.
*/
function toInt256(uint256 value) internal pure returns (int256) {
// Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive
if (value > uint256(type(int256).max)) {
revert SafeCastOverflowedUintToInt(value);
}
return int256(value);
}
/**
* @dev Cast a boolean (false or true) to a uint256 (0 or 1) with no jump.
*/
function toUint(bool b) internal pure returns (uint256 u) {
assembly ("memory-safe") {
u := iszero(iszero(b))
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (token/ERC1155/IERC1155.sol)
pragma solidity >=0.6.2;
import {IERC165} from "../../utils/introspection/IERC165.sol";
/**
* @dev Required interface of an ERC-1155 compliant contract, as defined in the
* https://eips.ethereum.org/EIPS/eip-1155[ERC].
*/
interface IERC1155 is IERC165 {
/**
* @dev Emitted when `value` amount of tokens of type `id` are transferred from `from` to `to` by `operator`.
*/
event TransferSingle(address indexed operator, address indexed from, address indexed to, uint256 id, uint256 value);
/**
* @dev Equivalent to multiple {TransferSingle} events, where `operator`, `from` and `to` are the same for all
* transfers.
*/
event TransferBatch(
address indexed operator,
address indexed from,
address indexed to,
uint256[] ids,
uint256[] values
);
/**
* @dev Emitted when `account` grants or revokes permission to `operator` to transfer their tokens, according to
* `approved`.
*/
event ApprovalForAll(address indexed account, address indexed operator, bool approved);
/**
* @dev Emitted when the URI for token type `id` changes to `value`, if it is a non-programmatic URI.
*
* If an {URI} event was emitted for `id`, the standard
* https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[guarantees] that `value` will equal the value
* returned by {IERC1155MetadataURI-uri}.
*/
event URI(string value, uint256 indexed id);
/**
* @dev Returns the value of tokens of token type `id` owned by `account`.
*/
function balanceOf(address account, uint256 id) external view returns (uint256);
/**
* @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {balanceOf}.
*
* Requirements:
*
* - `accounts` and `ids` must have the same length.
*/
function balanceOfBatch(
address[] calldata accounts,
uint256[] calldata ids
) external view returns (uint256[] memory);
/**
* @dev Grants or revokes permission to `operator` to transfer the caller's tokens, according to `approved`,
*
* Emits an {ApprovalForAll} event.
*
* Requirements:
*
* - `operator` cannot be the zero address.
*/
function setApprovalForAll(address operator, bool approved) external;
/**
* @dev Returns true if `operator` is approved to transfer ``account``'s tokens.
*
* See {setApprovalForAll}.
*/
function isApprovedForAll(address account, address operator) external view returns (bool);
/**
* @dev Transfers a `value` amount of tokens of type `id` from `from` to `to`.
*
* WARNING: This function can potentially allow a reentrancy attack when transferring tokens
* to an untrusted contract, when invoking {IERC1155Receiver-onERC1155Received} on the receiver.
* Ensure to follow the checks-effects-interactions pattern and consider employing
* reentrancy guards when interacting with untrusted contracts.
*
* Emits a {TransferSingle} event.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - If the caller is not `from`, it must have been approved to spend ``from``'s tokens via {setApprovalForAll}.
* - `from` must have a balance of tokens of type `id` of at least `value` amount.
* - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the
* acceptance magic value.
*/
function safeTransferFrom(address from, address to, uint256 id, uint256 value, bytes calldata data) external;
/**
* @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {safeTransferFrom}.
*
* WARNING: This function can potentially allow a reentrancy attack when transferring tokens
* to an untrusted contract, when invoking {IERC1155Receiver-onERC1155BatchReceived} on the receiver.
* Ensure to follow the checks-effects-interactions pattern and consider employing
* reentrancy guards when interacting with untrusted contracts.
*
* Emits either a {TransferSingle} or a {TransferBatch} event, depending on the length of the array arguments.
*
* Requirements:
*
* - `ids` and `values` must have the same length.
* - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the
* acceptance magic value.
*/
function safeBatchTransferFrom(
address from,
address to,
uint256[] calldata ids,
uint256[] calldata values,
bytes calldata data
) external;
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.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);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (utils/Strings.sol)
pragma solidity ^0.8.20;
import {Math} from "./math/Math.sol";
import {SafeCast} from "./math/SafeCast.sol";
import {SignedMath} from "./math/SignedMath.sol";
/**
* @dev String operations.
*/
library Strings {
using SafeCast for *;
bytes16 private constant HEX_DIGITS = "0123456789abcdef";
uint8 private constant ADDRESS_LENGTH = 20;
uint256 private constant SPECIAL_CHARS_LOOKUP =
(1 << 0x08) | // backspace
(1 << 0x09) | // tab
(1 << 0x0a) | // newline
(1 << 0x0c) | // form feed
(1 << 0x0d) | // carriage return
(1 << 0x22) | // double quote
(1 << 0x5c); // backslash
/**
* @dev The `value` string doesn't fit in the specified `length`.
*/
error StringsInsufficientHexLength(uint256 value, uint256 length);
/**
* @dev The string being parsed contains characters that are not in scope of the given base.
*/
error StringsInvalidChar();
/**
* @dev The string being parsed is not a properly formatted address.
*/
error StringsInvalidAddressFormat();
/**
* @dev Converts a `uint256` to its ASCII `string` decimal representation.
*/
function toString(uint256 value) internal pure returns (string memory) {
unchecked {
uint256 length = Math.log10(value) + 1;
string memory buffer = new string(length);
uint256 ptr;
assembly ("memory-safe") {
ptr := add(add(buffer, 0x20), length)
}
while (true) {
ptr--;
assembly ("memory-safe") {
mstore8(ptr, byte(mod(value, 10), HEX_DIGITS))
}
value /= 10;
if (value == 0) break;
}
return buffer;
}
}
/**
* @dev Converts a `int256` to its ASCII `string` decimal representation.
*/
function toStringSigned(int256 value) internal pure returns (string memory) {
return string.concat(value < 0 ? "-" : "", toString(SignedMath.abs(value)));
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
*/
function toHexString(uint256 value) internal pure returns (string memory) {
unchecked {
return toHexString(value, Math.log256(value) + 1);
}
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
*/
function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
uint256 localValue = value;
bytes memory buffer = new bytes(2 * length + 2);
buffer[0] = "0";
buffer[1] = "x";
for (uint256 i = 2 * length + 1; i > 1; --i) {
buffer[i] = HEX_DIGITS[localValue & 0xf];
localValue >>= 4;
}
if (localValue != 0) {
revert StringsInsufficientHexLength(value, length);
}
return string(buffer);
}
/**
* @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal
* representation.
*/
function toHexString(address addr) internal pure returns (string memory) {
return toHexString(uint256(uint160(addr)), ADDRESS_LENGTH);
}
/**
* @dev Converts an `address` with fixed length of 20 bytes to its checksummed ASCII `string` hexadecimal
* representation, according to EIP-55.
*/
function toChecksumHexString(address addr) internal pure returns (string memory) {
bytes memory buffer = bytes(toHexString(addr));
// hash the hex part of buffer (skip length + 2 bytes, length 40)
uint256 hashValue;
assembly ("memory-safe") {
hashValue := shr(96, keccak256(add(buffer, 0x22), 40))
}
for (uint256 i = 41; i > 1; --i) {
// possible values for buffer[i] are 48 (0) to 57 (9) and 97 (a) to 102 (f)
if (hashValue & 0xf > 7 && uint8(buffer[i]) > 96) {
// case shift by xoring with 0x20
buffer[i] ^= 0x20;
}
hashValue >>= 4;
}
return string(buffer);
}
/**
* @dev Returns true if the two strings are equal.
*/
function equal(string memory a, string memory b) internal pure returns (bool) {
return bytes(a).length == bytes(b).length && keccak256(bytes(a)) == keccak256(bytes(b));
}
/**
* @dev Parse a decimal string and returns the value as a `uint256`.
*
* Requirements:
* - The string must be formatted as `[0-9]*`
* - The result must fit into an `uint256` type
*/
function parseUint(string memory input) internal pure returns (uint256) {
return parseUint(input, 0, bytes(input).length);
}
/**
* @dev Variant of {parseUint-string} that parses a substring of `input` located between position `begin` (included) and
* `end` (excluded).
*
* Requirements:
* - The substring must be formatted as `[0-9]*`
* - The result must fit into an `uint256` type
*/
function parseUint(string memory input, uint256 begin, uint256 end) internal pure returns (uint256) {
(bool success, uint256 value) = tryParseUint(input, begin, end);
if (!success) revert StringsInvalidChar();
return value;
}
/**
* @dev Variant of {parseUint-string} that returns false if the parsing fails because of an invalid character.
*
* NOTE: This function will revert if the result does not fit in a `uint256`.
*/
function tryParseUint(string memory input) internal pure returns (bool success, uint256 value) {
return _tryParseUintUncheckedBounds(input, 0, bytes(input).length);
}
/**
* @dev Variant of {parseUint-string-uint256-uint256} that returns false if the parsing fails because of an invalid
* character.
*
* NOTE: This function will revert if the result does not fit in a `uint256`.
*/
function tryParseUint(
string memory input,
uint256 begin,
uint256 end
) internal pure returns (bool success, uint256 value) {
if (end > bytes(input).length || begin > end) return (false, 0);
return _tryParseUintUncheckedBounds(input, begin, end);
}
/**
* @dev Implementation of {tryParseUint-string-uint256-uint256} that does not check bounds. Caller should make sure that
* `begin <= end <= input.length`. Other inputs would result in undefined behavior.
*/
function _tryParseUintUncheckedBounds(
string memory input,
uint256 begin,
uint256 end
) private pure returns (bool success, uint256 value) {
bytes memory buffer = bytes(input);
uint256 result = 0;
for (uint256 i = begin; i < end; ++i) {
uint8 chr = _tryParseChr(bytes1(_unsafeReadBytesOffset(buffer, i)));
if (chr > 9) return (false, 0);
result *= 10;
result += chr;
}
return (true, result);
}
/**
* @dev Parse a decimal string and returns the value as a `int256`.
*
* Requirements:
* - The string must be formatted as `[-+]?[0-9]*`
* - The result must fit in an `int256` type.
*/
function parseInt(string memory input) internal pure returns (int256) {
return parseInt(input, 0, bytes(input).length);
}
/**
* @dev Variant of {parseInt-string} that parses a substring of `input` located between position `begin` (included) and
* `end` (excluded).
*
* Requirements:
* - The substring must be formatted as `[-+]?[0-9]*`
* - The result must fit in an `int256` type.
*/
function parseInt(string memory input, uint256 begin, uint256 end) internal pure returns (int256) {
(bool success, int256 value) = tryParseInt(input, begin, end);
if (!success) revert StringsInvalidChar();
return value;
}
/**
* @dev Variant of {parseInt-string} that returns false if the parsing fails because of an invalid character or if
* the result does not fit in a `int256`.
*
* NOTE: This function will revert if the absolute value of the result does not fit in a `uint256`.
*/
function tryParseInt(string memory input) internal pure returns (bool success, int256 value) {
return _tryParseIntUncheckedBounds(input, 0, bytes(input).length);
}
uint256 private constant ABS_MIN_INT256 = 2 ** 255;
/**
* @dev Variant of {parseInt-string-uint256-uint256} that returns false if the parsing fails because of an invalid
* character or if the result does not fit in a `int256`.
*
* NOTE: This function will revert if the absolute value of the result does not fit in a `uint256`.
*/
function tryParseInt(
string memory input,
uint256 begin,
uint256 end
) internal pure returns (bool success, int256 value) {
if (end > bytes(input).length || begin > end) return (false, 0);
return _tryParseIntUncheckedBounds(input, begin, end);
}
/**
* @dev Implementation of {tryParseInt-string-uint256-uint256} that does not check bounds. Caller should make sure that
* `begin <= end <= input.length`. Other inputs would result in undefined behavior.
*/
function _tryParseIntUncheckedBounds(
string memory input,
uint256 begin,
uint256 end
) private pure returns (bool success, int256 value) {
bytes memory buffer = bytes(input);
// Check presence of a negative sign.
bytes1 sign = begin == end ? bytes1(0) : bytes1(_unsafeReadBytesOffset(buffer, begin)); // don't do out-of-bound (possibly unsafe) read if sub-string is empty
bool positiveSign = sign == bytes1("+");
bool negativeSign = sign == bytes1("-");
uint256 offset = (positiveSign || negativeSign).toUint();
(bool absSuccess, uint256 absValue) = tryParseUint(input, begin + offset, end);
if (absSuccess && absValue < ABS_MIN_INT256) {
return (true, negativeSign ? -int256(absValue) : int256(absValue));
} else if (absSuccess && negativeSign && absValue == ABS_MIN_INT256) {
return (true, type(int256).min);
} else return (false, 0);
}
/**
* @dev Parse a hexadecimal string (with or without "0x" prefix), and returns the value as a `uint256`.
*
* Requirements:
* - The string must be formatted as `(0x)?[0-9a-fA-F]*`
* - The result must fit in an `uint256` type.
*/
function parseHexUint(string memory input) internal pure returns (uint256) {
return parseHexUint(input, 0, bytes(input).length);
}
/**
* @dev Variant of {parseHexUint-string} that parses a substring of `input` located between position `begin` (included) and
* `end` (excluded).
*
* Requirements:
* - The substring must be formatted as `(0x)?[0-9a-fA-F]*`
* - The result must fit in an `uint256` type.
*/
function parseHexUint(string memory input, uint256 begin, uint256 end) internal pure returns (uint256) {
(bool success, uint256 value) = tryParseHexUint(input, begin, end);
if (!success) revert StringsInvalidChar();
return value;
}
/**
* @dev Variant of {parseHexUint-string} that returns false if the parsing fails because of an invalid character.
*
* NOTE: This function will revert if the result does not fit in a `uint256`.
*/
function tryParseHexUint(string memory input) internal pure returns (bool success, uint256 value) {
return _tryParseHexUintUncheckedBounds(input, 0, bytes(input).length);
}
/**
* @dev Variant of {parseHexUint-string-uint256-uint256} that returns false if the parsing fails because of an
* invalid character.
*
* NOTE: This function will revert if the result does not fit in a `uint256`.
*/
function tryParseHexUint(
string memory input,
uint256 begin,
uint256 end
) internal pure returns (bool success, uint256 value) {
if (end > bytes(input).length || begin > end) return (false, 0);
return _tryParseHexUintUncheckedBounds(input, begin, end);
}
/**
* @dev Implementation of {tryParseHexUint-string-uint256-uint256} that does not check bounds. Caller should make sure that
* `begin <= end <= input.length`. Other inputs would result in undefined behavior.
*/
function _tryParseHexUintUncheckedBounds(
string memory input,
uint256 begin,
uint256 end
) private pure returns (bool success, uint256 value) {
bytes memory buffer = bytes(input);
// skip 0x prefix if present
bool hasPrefix = (end > begin + 1) && bytes2(_unsafeReadBytesOffset(buffer, begin)) == bytes2("0x"); // don't do out-of-bound (possibly unsafe) read if sub-string is empty
uint256 offset = hasPrefix.toUint() * 2;
uint256 result = 0;
for (uint256 i = begin + offset; i < end; ++i) {
uint8 chr = _tryParseChr(bytes1(_unsafeReadBytesOffset(buffer, i)));
if (chr > 15) return (false, 0);
result *= 16;
unchecked {
// Multiplying by 16 is equivalent to a shift of 4 bits (with additional overflow check).
// This guarantees that adding a value < 16 will not cause an overflow, hence the unchecked.
result += chr;
}
}
return (true, result);
}
/**
* @dev Parse a hexadecimal string (with or without "0x" prefix), and returns the value as an `address`.
*
* Requirements:
* - The string must be formatted as `(0x)?[0-9a-fA-F]{40}`
*/
function parseAddress(string memory input) internal pure returns (address) {
return parseAddress(input, 0, bytes(input).length);
}
/**
* @dev Variant of {parseAddress-string} that parses a substring of `input` located between position `begin` (included) and
* `end` (excluded).
*
* Requirements:
* - The substring must be formatted as `(0x)?[0-9a-fA-F]{40}`
*/
function parseAddress(string memory input, uint256 begin, uint256 end) internal pure returns (address) {
(bool success, address value) = tryParseAddress(input, begin, end);
if (!success) revert StringsInvalidAddressFormat();
return value;
}
/**
* @dev Variant of {parseAddress-string} that returns false if the parsing fails because the input is not a properly
* formatted address. See {parseAddress-string} requirements.
*/
function tryParseAddress(string memory input) internal pure returns (bool success, address value) {
return tryParseAddress(input, 0, bytes(input).length);
}
/**
* @dev Variant of {parseAddress-string-uint256-uint256} that returns false if the parsing fails because input is not a properly
* formatted address. See {parseAddress-string-uint256-uint256} requirements.
*/
function tryParseAddress(
string memory input,
uint256 begin,
uint256 end
) internal pure returns (bool success, address value) {
if (end > bytes(input).length || begin > end) return (false, address(0));
bool hasPrefix = (end > begin + 1) && bytes2(_unsafeReadBytesOffset(bytes(input), begin)) == bytes2("0x"); // don't do out-of-bound (possibly unsafe) read if sub-string is empty
uint256 expectedLength = 40 + hasPrefix.toUint() * 2;
// check that input is the correct length
if (end - begin == expectedLength) {
// length guarantees that this does not overflow, and value is at most type(uint160).max
(bool s, uint256 v) = _tryParseHexUintUncheckedBounds(input, begin, end);
return (s, address(uint160(v)));
} else {
return (false, address(0));
}
}
function _tryParseChr(bytes1 chr) private pure returns (uint8) {
uint8 value = uint8(chr);
// Try to parse `chr`:
// - Case 1: [0-9]
// - Case 2: [a-f]
// - Case 3: [A-F]
// - otherwise not supported
unchecked {
if (value > 47 && value < 58) value -= 48;
else if (value > 96 && value < 103) value -= 87;
else if (value > 64 && value < 71) value -= 55;
else return type(uint8).max;
}
return value;
}
/**
* @dev Escape special characters in JSON strings. This can be useful to prevent JSON injection in NFT metadata.
*
* WARNING: This function should only be used in double quoted JSON strings. Single quotes are not escaped.
*
* NOTE: This function escapes all unicode characters, and not just the ones in ranges defined in section 2.5 of
* RFC-4627 (U+0000 to U+001F, U+0022 and U+005C). ECMAScript's `JSON.parse` does recover escaped unicode
* characters that are not in this range, but other tooling may provide different results.
*/
function escapeJSON(string memory input) internal pure returns (string memory) {
bytes memory buffer = bytes(input);
bytes memory output = new bytes(2 * buffer.length); // worst case scenario
uint256 outputLength = 0;
for (uint256 i; i < buffer.length; ++i) {
bytes1 char = bytes1(_unsafeReadBytesOffset(buffer, i));
if (((SPECIAL_CHARS_LOOKUP & (1 << uint8(char))) != 0)) {
output[outputLength++] = "\\";
if (char == 0x08) output[outputLength++] = "b";
else if (char == 0x09) output[outputLength++] = "t";
else if (char == 0x0a) output[outputLength++] = "n";
else if (char == 0x0c) output[outputLength++] = "f";
else if (char == 0x0d) output[outputLength++] = "r";
else if (char == 0x5c) output[outputLength++] = "\\";
else if (char == 0x22) {
// solhint-disable-next-line quotes
output[outputLength++] = '"';
}
} else {
output[outputLength++] = char;
}
}
// write the actual length and deallocate unused memory
assembly ("memory-safe") {
mstore(output, outputLength)
mstore(0x40, add(output, shl(5, shr(5, add(outputLength, 63)))))
}
return string(output);
}
/**
* @dev Reads a bytes32 from a bytes array without bounds checking.
*
* NOTE: making this function internal would mean it could be used with memory unsafe offset, and marking the
* assembly block as such would prevent some optimizations.
*/
function _unsafeReadBytesOffset(bytes memory buffer, uint256 offset) private pure returns (bytes32 value) {
// This is not memory safe in the general case, but all calls to this private function are within bounds.
assembly ("memory-safe") {
value := mload(add(add(buffer, 0x20), offset))
}
}
}// 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.4.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.4.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/math/SignedMath.sol)
pragma solidity ^0.8.20;
import {SafeCast} from "./SafeCast.sol";
/**
* @dev Standard signed math utilities missing in the Solidity language.
*/
library SignedMath {
/**
* @dev Branchless ternary evaluation for `a ? b : c`. Gas costs are constant.
*
* IMPORTANT: This function may reduce bytecode size and consume less gas when used standalone.
* However, the compiler may optimize Solidity ternary operations (i.e. `a ? b : c`) to only compute
* one branch when needed, making this function more expensive.
*/
function ternary(bool condition, int256 a, int256 b) internal pure returns (int256) {
unchecked {
// branchless ternary works because:
// b ^ (a ^ b) == a
// b ^ 0 == b
return b ^ ((a ^ b) * int256(SafeCast.toUint(condition)));
}
}
/**
* @dev Returns the largest of two signed numbers.
*/
function max(int256 a, int256 b) internal pure returns (int256) {
return ternary(a > b, a, b);
}
/**
* @dev Returns the smallest of two signed numbers.
*/
function min(int256 a, int256 b) internal pure returns (int256) {
return ternary(a < b, a, b);
}
/**
* @dev Returns the average of two signed numbers without overflow.
* The result is rounded towards zero.
*/
function average(int256 a, int256 b) internal pure returns (int256) {
// Formula from the book "Hacker's Delight"
int256 x = (a & b) + ((a ^ b) >> 1);
return x + (int256(uint256(x) >> 255) & (a ^ b));
}
/**
* @dev Returns the absolute unsigned value of a signed value.
*/
function abs(int256 n) internal pure returns (uint256) {
unchecked {
// Formula from the "Bit Twiddling Hacks" by Sean Eron Anderson.
// Since `n` is a signed integer, the generated bytecode will use the SAR opcode to perform the right shift,
// taking advantage of the most significant (or "sign" bit) in two's complement representation.
// This opcode adds new most significant bits set to the value of the previous most significant bit. As a result,
// the mask will either be `bytes32(0)` (if n is positive) or `~bytes32(0)` (if n is negative).
int256 mask = n >> 255;
// A `bytes32(0)` mask leaves the input unchanged, while a `~bytes32(0)` mask complements it.
return uint256((n + mask) ^ mask);
}
}
}{
"remappings": [
"frax-std/=node_modules/frax-standard-solidity/src/",
"@prb/test/=node_modules/@prb/test/",
"forge-std/=node_modules/forge-std/src/",
"ds-test/=node_modules/ds-test/src/",
"@openzeppelin/=node_modules/@openzeppelin/",
"frax-standard-solidity/=node_modules/frax-standard-solidity/",
"solidity-bytes-utils/=node_modules/solidity-bytes-utils/"
],
"optimizer": {
"enabled": true,
"runs": 777
},
"metadata": {
"useLiteralContent": false,
"bytecodeHash": "none",
"appendCBOR": false
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"evmVersion": "prague",
"viaIR": false
}Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"inputs":[{"internalType":"address","name":"_token","type":"address"},{"internalType":"address","name":"_frxUSD","type":"address"},{"internalType":"address","name":"_admin","type":"address"},{"internalType":"address","name":"_operator","type":"address"},{"internalType":"address","name":"_protocolFeeRecipient","type":"address"},{"internalType":"uint40","name":"_disputeWindowDuration","type":"uint40"},{"internalType":"uint256","name":"_disputeBondAmount","type":"uint256"},{"internalType":"address","name":"_trustedForwarder","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"AccessControlBadConfirmation","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"bytes32","name":"neededRole","type":"bytes32"}],"name":"AccessControlUnauthorizedAccount","type":"error"},{"inputs":[],"name":"DisputeWindowActive","type":"error"},{"inputs":[],"name":"DisputeWindowExpired","type":"error"},{"inputs":[],"name":"DisputeWindowTooShort","type":"error"},{"inputs":[],"name":"FeeTooHigh","type":"error"},{"inputs":[],"name":"IncompatibleOrders","type":"error"},{"inputs":[],"name":"IncompatiblePrices","type":"error"},{"inputs":[],"name":"InsufficientCounterOrders","type":"error"},{"inputs":[],"name":"InvalidNumOutcomes","type":"error"},{"inputs":[],"name":"InvalidOutcomeIndex","type":"error"},{"inputs":[],"name":"InvalidPrice","type":"error"},{"inputs":[],"name":"InvalidShortString","type":"error"},{"inputs":[],"name":"InvalidSignature","type":"error"},{"inputs":[],"name":"InvalidTickSize","type":"error"},{"inputs":[],"name":"MarketAlreadyResolved","type":"error"},{"inputs":[],"name":"MarketNotActive","type":"error"},{"inputs":[],"name":"MarketNotProposed","type":"error"},{"inputs":[],"name":"MarketNotResolved","type":"error"},{"inputs":[],"name":"MarketNotVoided","type":"error"},{"inputs":[],"name":"MintBurnNotAllowed","type":"error"},{"inputs":[],"name":"NoDisputeToResolve","type":"error"},{"inputs":[],"name":"NotMarketOracle","type":"error"},{"inputs":[],"name":"NotOrderMaker","type":"error"},{"inputs":[],"name":"OrderAlreadyFilled","type":"error"},{"inputs":[],"name":"OrderCancelled","type":"error"},{"inputs":[],"name":"OrderExpired","type":"error"},{"inputs":[],"name":"OrderNonceMismatch","type":"error"},{"inputs":[],"name":"PriceNotOnTick","type":"error"},{"inputs":[],"name":"ReentrancyGuardReentrantCall","type":"error"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"SafeERC20FailedOperation","type":"error"},{"inputs":[{"internalType":"string","name":"str","type":"string"}],"name":"StringTooLong","type":"error"},{"inputs":[],"name":"UnresolvedDisputeExists","type":"error"},{"inputs":[],"name":"ZeroAddress","type":"error"},{"inputs":[],"name":"ZeroAmount","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint248","name":"marketId","type":"uint248"},{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"CompleteSetBurned","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint248","name":"marketId","type":"uint248"},{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"CompleteSetMinted","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"newAmount","type":"uint256"}],"name":"DisputeBondAmountUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint248","name":"marketId","type":"uint248"},{"indexed":false,"internalType":"bool","name":"bondReturned","type":"bool"},{"indexed":false,"internalType":"bool","name":"directResolve","type":"bool"},{"indexed":false,"internalType":"uint8","name":"newWinningOutcome","type":"uint8"}],"name":"DisputeResolved","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint40","name":"newDuration","type":"uint40"}],"name":"DisputeWindowDurationUpdated","type":"event"},{"anonymous":false,"inputs":[],"name":"EIP712DomainChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint248","name":"marketId","type":"uint248"},{"indexed":false,"internalType":"uint8","name":"numOutcomes","type":"uint8"},{"indexed":true,"internalType":"address","name":"oracle","type":"address"},{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":false,"internalType":"uint256","name":"tickSize","type":"uint256"},{"indexed":false,"internalType":"string","name":"metadata","type":"string"}],"name":"MarketCreated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint248","name":"marketId","type":"uint248"},{"indexed":false,"internalType":"uint8","name":"winningOutcome","type":"uint8"}],"name":"MarketResolved","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint248","name":"marketId","type":"uint248"}],"name":"MarketVoided","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"newNonce","type":"uint256"}],"name":"NonceIncremented","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"OperatorFeesWithdrawn","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"orderHash","type":"bytes32"},{"indexed":true,"internalType":"address","name":"maker","type":"address"}],"name":"OrderCancelledEvent","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"makerOrderHash","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"takerOrderHash","type":"bytes32"},{"indexed":false,"internalType":"uint256","name":"fillAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"executionPrice","type":"uint256"}],"name":"OrdersMatched","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"newRecipient","type":"address"}],"name":"ProtocolFeeRecipientUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"recipient","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"ProtocolFeesWithdrawn","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint248","name":"marketId","type":"uint248"},{"indexed":true,"internalType":"address","name":"disputer","type":"address"}],"name":"ResultDisputed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint248","name":"marketId","type":"uint248"},{"indexed":false,"internalType":"uint8","name":"winningOutcome","type":"uint8"},{"indexed":false,"internalType":"uint40","name":"disputeDeadline","type":"uint40"}],"name":"ResultProposed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint248","name":"marketId","type":"uint248"},{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"totalTokensBurned","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"collateralReceived","type":"uint256"}],"name":"VoidedRedeemed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint248","name":"marketId","type":"uint248"},{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"collateralReceived","type":"uint256"}],"name":"WinningRedeemed","type":"event"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"OPERATOR_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ORDER_TYPEHASH","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"accumulatedOperatorFees","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"accumulatedProtocolFees","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint248","name":"marketId","type":"uint248"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"burnCompleteSet","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"uint248","name":"marketId","type":"uint248"},{"internalType":"address","name":"maker","type":"address"},{"internalType":"uint8","name":"outcomeIndex","type":"uint8"},{"internalType":"enum OrderSide","name":"side","type":"uint8"},{"internalType":"uint256","name":"price","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"nonce","type":"uint256"},{"internalType":"uint40","name":"expiry","type":"uint40"},{"internalType":"bool","name":"allowMintBurn","type":"bool"}],"internalType":"struct Order","name":"order","type":"tuple"}],"name":"cancelOrder","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint8","name":"numOutcomes","type":"uint8"},{"internalType":"address","name":"oracle","type":"address"},{"internalType":"uint16","name":"protocolFeeBps","type":"uint16"},{"internalType":"uint16","name":"operatorFeeBps","type":"uint16"},{"internalType":"uint256","name":"tickSize","type":"uint256"},{"internalType":"string","name":"metadata","type":"string"}],"name":"createMarket","outputs":[{"internalType":"uint248","name":"marketId","type":"uint248"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"disputeBondAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint248","name":"marketId","type":"uint248"}],"name":"disputeResult","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"disputeWindowDuration","outputs":[{"internalType":"uint40","name":"","type":"uint40"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint248","name":"","type":"uint248"}],"name":"disputes","outputs":[{"internalType":"address","name":"disputer","type":"address"},{"internalType":"uint256","name":"bondAmount","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"eip712Domain","outputs":[{"internalType":"bytes1","name":"fields","type":"bytes1"},{"internalType":"string","name":"name","type":"string"},{"internalType":"string","name":"version","type":"string"},{"internalType":"uint256","name":"chainId","type":"uint256"},{"internalType":"address","name":"verifyingContract","type":"address"},{"internalType":"bytes32","name":"salt","type":"bytes32"},{"internalType":"uint256[]","name":"extensions","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint248","name":"marketId","type":"uint248"}],"name":"finalizeResult","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"frxUSD","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint248","name":"marketId","type":"uint248"}],"name":"getMarketTokenIds","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"uint248","name":"marketId","type":"uint248"},{"internalType":"address","name":"maker","type":"address"},{"internalType":"uint8","name":"outcomeIndex","type":"uint8"},{"internalType":"enum OrderSide","name":"side","type":"uint8"},{"internalType":"uint256","name":"price","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"nonce","type":"uint256"},{"internalType":"uint40","name":"expiry","type":"uint40"},{"internalType":"bool","name":"allowMintBurn","type":"bool"}],"internalType":"struct Order","name":"order","type":"tuple"}],"name":"getOrderRemainingAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"uint248","name":"marketId","type":"uint248"},{"internalType":"address","name":"maker","type":"address"},{"internalType":"uint8","name":"outcomeIndex","type":"uint8"},{"internalType":"enum OrderSide","name":"side","type":"uint8"},{"internalType":"uint256","name":"price","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"nonce","type":"uint256"},{"internalType":"uint40","name":"expiry","type":"uint40"},{"internalType":"bool","name":"allowMintBurn","type":"bool"}],"internalType":"struct Order","name":"order","type":"tuple"}],"name":"hashOrder","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"incrementNonce","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"uint248","name":"marketId","type":"uint248"},{"internalType":"address","name":"maker","type":"address"},{"internalType":"uint8","name":"outcomeIndex","type":"uint8"},{"internalType":"enum OrderSide","name":"side","type":"uint8"},{"internalType":"uint256","name":"price","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"nonce","type":"uint256"},{"internalType":"uint40","name":"expiry","type":"uint40"},{"internalType":"bool","name":"allowMintBurn","type":"bool"}],"internalType":"struct Order","name":"order","type":"tuple"}],"name":"isOrderValid","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"forwarder","type":"address"}],"name":"isTrustedForwarder","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint248","name":"","type":"uint248"}],"name":"markets","outputs":[{"internalType":"uint8","name":"numOutcomes","type":"uint8"},{"internalType":"uint8","name":"winningOutcome","type":"uint8"},{"internalType":"enum MarketStatus","name":"status","type":"uint8"},{"internalType":"uint40","name":"disputeDeadline","type":"uint40"},{"internalType":"address","name":"oracle","type":"address"},{"internalType":"uint16","name":"protocolFeeBps","type":"uint16"},{"internalType":"uint16","name":"operatorFeeBps","type":"uint16"},{"internalType":"address","name":"operator","type":"address"},{"internalType":"uint256","name":"tickSize","type":"uint256"},{"internalType":"string","name":"metadata","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"uint248","name":"marketId","type":"uint248"},{"internalType":"address","name":"maker","type":"address"},{"internalType":"uint8","name":"outcomeIndex","type":"uint8"},{"internalType":"enum OrderSide","name":"side","type":"uint8"},{"internalType":"uint256","name":"price","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"nonce","type":"uint256"},{"internalType":"uint40","name":"expiry","type":"uint40"},{"internalType":"bool","name":"allowMintBurn","type":"bool"}],"internalType":"struct Order","name":"makerOrder","type":"tuple"},{"internalType":"bytes","name":"makerSignature","type":"bytes"},{"components":[{"internalType":"uint248","name":"marketId","type":"uint248"},{"internalType":"address","name":"maker","type":"address"},{"internalType":"uint8","name":"outcomeIndex","type":"uint8"},{"internalType":"enum OrderSide","name":"side","type":"uint8"},{"internalType":"uint256","name":"price","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"nonce","type":"uint256"},{"internalType":"uint40","name":"expiry","type":"uint40"},{"internalType":"bool","name":"allowMintBurn","type":"bool"}],"internalType":"struct Order","name":"takerOrder","type":"tuple"},{"internalType":"bytes","name":"takerSignature","type":"bytes"},{"internalType":"uint256","name":"fillAmount","type":"uint256"}],"name":"matchOrders","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"uint248","name":"marketId","type":"uint248"},{"internalType":"address","name":"maker","type":"address"},{"internalType":"uint8","name":"outcomeIndex","type":"uint8"},{"internalType":"enum OrderSide","name":"side","type":"uint8"},{"internalType":"uint256","name":"price","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"nonce","type":"uint256"},{"internalType":"uint40","name":"expiry","type":"uint40"},{"internalType":"bool","name":"allowMintBurn","type":"bool"}],"internalType":"struct Order","name":"primaryOrder","type":"tuple"},{"internalType":"bytes","name":"primarySignature","type":"bytes"},{"components":[{"internalType":"uint248","name":"marketId","type":"uint248"},{"internalType":"address","name":"maker","type":"address"},{"internalType":"uint8","name":"outcomeIndex","type":"uint8"},{"internalType":"enum OrderSide","name":"side","type":"uint8"},{"internalType":"uint256","name":"price","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"nonce","type":"uint256"},{"internalType":"uint40","name":"expiry","type":"uint40"},{"internalType":"bool","name":"allowMintBurn","type":"bool"}],"internalType":"struct Order[]","name":"counterOrders","type":"tuple[]"},{"internalType":"bytes[]","name":"counterSignatures","type":"bytes[]"},{"internalType":"uint256","name":"fillAmount","type":"uint256"}],"name":"matchOrdersMultiWithBurn","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"uint248","name":"marketId","type":"uint248"},{"internalType":"address","name":"maker","type":"address"},{"internalType":"uint8","name":"outcomeIndex","type":"uint8"},{"internalType":"enum OrderSide","name":"side","type":"uint8"},{"internalType":"uint256","name":"price","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"nonce","type":"uint256"},{"internalType":"uint40","name":"expiry","type":"uint40"},{"internalType":"bool","name":"allowMintBurn","type":"bool"}],"internalType":"struct Order","name":"primaryOrder","type":"tuple"},{"internalType":"bytes","name":"primarySignature","type":"bytes"},{"components":[{"internalType":"uint248","name":"marketId","type":"uint248"},{"internalType":"address","name":"maker","type":"address"},{"internalType":"uint8","name":"outcomeIndex","type":"uint8"},{"internalType":"enum OrderSide","name":"side","type":"uint8"},{"internalType":"uint256","name":"price","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"nonce","type":"uint256"},{"internalType":"uint40","name":"expiry","type":"uint40"},{"internalType":"bool","name":"allowMintBurn","type":"bool"}],"internalType":"struct Order[]","name":"counterOrders","type":"tuple[]"},{"internalType":"bytes[]","name":"counterSignatures","type":"bytes[]"},{"internalType":"uint256","name":"fillAmount","type":"uint256"}],"name":"matchOrdersMultiWithMint","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"uint248","name":"marketId","type":"uint248"},{"internalType":"address","name":"maker","type":"address"},{"internalType":"uint8","name":"outcomeIndex","type":"uint8"},{"internalType":"enum OrderSide","name":"side","type":"uint8"},{"internalType":"uint256","name":"price","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"nonce","type":"uint256"},{"internalType":"uint40","name":"expiry","type":"uint40"},{"internalType":"bool","name":"allowMintBurn","type":"bool"}],"internalType":"struct Order","name":"makerOrder","type":"tuple"},{"internalType":"bytes","name":"makerSignature","type":"bytes"},{"components":[{"internalType":"uint248","name":"marketId","type":"uint248"},{"internalType":"address","name":"maker","type":"address"},{"internalType":"uint8","name":"outcomeIndex","type":"uint8"},{"internalType":"enum OrderSide","name":"side","type":"uint8"},{"internalType":"uint256","name":"price","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"nonce","type":"uint256"},{"internalType":"uint40","name":"expiry","type":"uint40"},{"internalType":"bool","name":"allowMintBurn","type":"bool"}],"internalType":"struct Order","name":"takerOrder","type":"tuple"},{"internalType":"bytes","name":"takerSignature","type":"bytes"},{"internalType":"uint256","name":"fillAmount","type":"uint256"}],"name":"matchOrdersWithBurn","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"uint248","name":"marketId","type":"uint248"},{"internalType":"address","name":"maker","type":"address"},{"internalType":"uint8","name":"outcomeIndex","type":"uint8"},{"internalType":"enum OrderSide","name":"side","type":"uint8"},{"internalType":"uint256","name":"price","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"nonce","type":"uint256"},{"internalType":"uint40","name":"expiry","type":"uint40"},{"internalType":"bool","name":"allowMintBurn","type":"bool"}],"internalType":"struct Order","name":"makerOrder","type":"tuple"},{"internalType":"bytes","name":"makerSignature","type":"bytes"},{"components":[{"internalType":"uint248","name":"marketId","type":"uint248"},{"internalType":"address","name":"maker","type":"address"},{"internalType":"uint8","name":"outcomeIndex","type":"uint8"},{"internalType":"enum OrderSide","name":"side","type":"uint8"},{"internalType":"uint256","name":"price","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"nonce","type":"uint256"},{"internalType":"uint40","name":"expiry","type":"uint40"},{"internalType":"bool","name":"allowMintBurn","type":"bool"}],"internalType":"struct Order","name":"takerOrder","type":"tuple"},{"internalType":"bytes","name":"takerSignature","type":"bytes"},{"internalType":"uint256","name":"fillAmount","type":"uint256"}],"name":"matchOrdersWithMint","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint248","name":"marketId","type":"uint248"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"mintCompleteSet","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"nextMarketId","outputs":[{"internalType":"uint248","name":"","type":"uint248"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"orderCancelled","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"orderFills","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner_","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"name":"permitCollateral","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint248","name":"marketId","type":"uint248"},{"internalType":"uint8","name":"winningOutcome","type":"uint8"}],"name":"proposeResult","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"protocolFeeRecipient","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint248","name":"marketId","type":"uint248"},{"internalType":"uint256[]","name":"amounts","type":"uint256[]"}],"name":"redeemVoided","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint248","name":"marketId","type":"uint248"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"redeemWinning","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"callerConfirmation","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint248","name":"marketId","type":"uint248"},{"internalType":"bool","name":"returnBond","type":"bool"},{"internalType":"bool","name":"directResolve","type":"bool"},{"internalType":"uint8","name":"newWinningOutcome","type":"uint8"}],"name":"resolveDispute","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"setDisputeBondAmount","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint40","name":"duration","type":"uint40"}],"name":"setDisputeWindowDuration","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"}],"name":"setProtocolFeeRecipient","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"token","outputs":[{"internalType":"contract IFraxBetToken","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"trustedForwarder","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"userNonce","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint248","name":"marketId","type":"uint248"}],"name":"voidMarket","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"withdrawOperatorFees","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"withdrawProtocolFees","outputs":[],"stateMutability":"nonpayable","type":"function"}]Contract Creation Code
6101c0604052348015610010575f5ffd5b50604051615e8f380380615e8f83398101604081905261002f916103fa565b806040518060400160405280600f81526020016e4672617842657445786368616e676560881b815250604051806040016040528060018152602001603160f81b81525061008660018361024560201b90919060201c565b61012052610095816002610245565b61014052815160208084019190912060e052815190820120610100524660a05261012160e05161010051604080517f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f60208201529081019290925260608201524660808201523060a08201525f9060c00160405160208183030381529060405280519060200120905090565b60805250503060c05260016003556001600160a01b03908116610160528816158061015357506001600160a01b038716155b8061016557506001600160a01b038616155b8061017757506001600160a01b038516155b156101955760405163d92e233d60e01b815260040160405180910390fd5b610e1064ffffffffff841610156101bf57604051630c59931360e31b815260040160405180910390fd5b6001600160a01b03888116610180528781166101a052600480549186166001600160c81b031990921691909117600160a01b64ffffffffff861602179055600582905561020c5f87610277565b506102377f97667070c54ef182b0f5858b034beac1b6f3089aa2d3188bb1e8929f4fa9b92986610277565b50505050505050505061069a565b5f602083511015610260576102598361031f565b9050610271565b8161026b8482610529565b5060ff90505b92915050565b5f828152602081815260408083206001600160a01b038516845290915281205460ff16610318575f838152602081815260408083206001600160a01b03861684529091529020805460ff191660011790556102d0610365565b6001600160a01b0316826001600160a01b0316847f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a4506001610271565b505f610271565b5f5f829050601f81511115610352578260405163305a27a960e01b815260040161034991906105e3565b60405180910390fd5b805161035d82610618565b179392505050565b5f61036e610373565b905090565b5f36601480821080159061038b575061038b336103b9565b156103b15761039e36828403815f61063b565b6103a791610662565b60601c9250505090565b339250505090565b5f6103c46101605190565b6001600160a01b0316826001600160a01b0316149050919050565b80516001600160a01b03811681146103f5575f5ffd5b919050565b5f5f5f5f5f5f5f5f610100898b031215610412575f5ffd5b61041b896103df565b975061042960208a016103df565b965061043760408a016103df565b955061044560608a016103df565b945061045360808a016103df565b935060a089015164ffffffffff8116811461046c575f5ffd5b60c08a0151909350915061048260e08a016103df565b90509295985092959890939650565b634e487b7160e01b5f52604160045260245ffd5b600181811c908216806104b957607f821691505b6020821081036104d757634e487b7160e01b5f52602260045260245ffd5b50919050565b601f82111561052457805f5260205f20601f840160051c810160208510156105025750805b601f840160051c820191505b81811015610521575f815560010161050e565b50505b505050565b81516001600160401b0381111561054257610542610491565b6105568161055084546104a5565b846104dd565b6020601f821160018114610588575f83156105715750848201515b5f19600385901b1c1916600184901b178455610521565b5f84815260208120601f198516915b828110156105b75787850151825560209485019460019092019101610597565b50848210156105d457868401515f19600387901b60f8161c191681555b50505050600190811b01905550565b602081525f82518060208401528060208501604085015e5f604082850101526040601f19601f83011684010191505092915050565b805160208083015191908110156104d7575f1960209190910360031b1b16919050565b5f5f85851115610649575f5ffd5b83861115610655575f5ffd5b5050820193919092039150565b80356001600160601b03198116906014841015610693576001600160601b0319601485900360031b81901b82161691505b5092915050565b60805160a05160c05160e05161010051610120516101405161016051610180516101a0516156ec6107a35f395f818161041a01528181610b1a01528181610d530152818161162501528181611a8401528181611dd201528181611fbe015281816126eb01528181612db30152818161304d015281816137de015281816138190152818161407d015281816145fd015261463801525f818161088601528181611f5501528181612d2e01528181613189015281816138ff0152818161400a01526146fb01525f81816104db0152818161058301526141bb01525f61415801525f61412b01525f6148e401525f6148bc01525f61481701525f61484101525f61486b01526156ec5ff3fe608060405234801561000f575f5ffd5b506004361061033b575f3560e01c80638795cccb116101b3578063d0fec535116100f3578063e521cb921161009e578063f5b541a611610079578063f5b541a614610814578063f7213db61461083b578063f973a2091461085a578063fc0c546a14610881575f5ffd5b8063e521cb92146107db578063ee69bfd5146107ee578063efbf25a614610801575f5ffd5b8063d92c2e5e116100ce578063d92c2e5e14610795578063dbee7f63146107a8578063e1b192fc146107bb575f5ffd5b8063d0fec53514610746578063d547741f14610759578063d8f03a221461076c575f5ffd5b80639dd0c5f01161015e578063afbe4a4011610139578063afbe4a40146106df578063b150ceb0146106f2578063c931d52214610720578063cfbfdff914610733575f5ffd5b80639dd0c5f0146106b2578063a217fddf146106c5578063a63906da146106cc575f5ffd5b806396dd802e1161018e57806396dd802e1461068357806397f03f1c1461069657806399ba67f41461069f575f5ffd5b80638795cccb1461062657806391d148541461062e57806395e6630e14610664575f5ffd5b806354607c061161027e57806364df049e116102295780637da0a877116102045780637da0a87714610581578063801435af146105a757806381f8cf64146105f857806384b0196e1461060b575f5ffd5b806364df049e14610548578063669ba61c1461055b5780637bc10a971461056e575f5ffd5b80635889bf5e116102595780635889bf5e1461050b5780635c60bedb1461052d578063627cdcb914610540575f5ffd5b806354607c06146104a557806354718d30146104b8578063572b6c05146104cb575f5ffd5b806332a9bc12116102e95780633b1c4f4a116102c45780633b1c4f4a146104155780633c79c5e014610454578063406ef2ef146104675780634218161214610492575f5ffd5b806332a9bc12146103e757806336568abe146103ef5780633a86cc1c14610402575f5ffd5b80632e04b8e7116103195780632e04b8e7146103ac5780632f2ff15d146103cb57806331d1c1b3146103de575f5ffd5b806301ffc9a71461033f5780632358cb2f14610367578063248a9ca31461037c575b5f5ffd5b61035261034d366004614bad565b6108a8565b60405190151581526020015b60405180910390f35b61037a610375366004614bff565b6108de565b005b61039e61038a366004614c30565b5f9081526020819052604090206001015490565b60405190815260200161035e565b61039e6103ba366004614c5d565b600a6020525f908152604090205481565b61037a6103d9366004614c76565b610a8d565b61039e600c5481565b61037a610ab7565b61037a6103fd366004614c76565b610b88565b61037a610410366004614ca6565b610bd0565b61043c7f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b03909116815260200161035e565b61037a610462366004614cf7565b610df2565b60065461047a906001600160f81b031681565b6040516001600160f81b03909116815260200161035e565b61037a6104a0366004614d7b565b610e8b565b61039e6104b3366004614e1b565b611011565b61037a6104c6366004614e77565b6110cc565b6103526104d9366004614c5d565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0390811691161490565b610352610519366004614c30565b60096020525f908152604090205460ff1681565b61037a61053b366004614d7b565b611276565b61037a6114c2565b60045461043c906001600160a01b031681565b61037a610569366004614f66565b611537565b61035261057c366004614e1b565b6116ed565b7f000000000000000000000000000000000000000000000000000000000000000061043c565b6105d96105b5366004614f66565b600b6020525f9081526040902080546001909101546001600160a01b039091169082565b604080516001600160a01b03909316835260208301919091520161035e565b61037a610606366004614d7b565b6117ff565b6106136119ff565b60405161035e9796959493929190614fe7565b61037a611a41565b61035261063c366004614c76565b5f918252602082815260408084206001600160a01b0393909316845291905290205460ff1690565b61039e610672366004614c5d565b600d6020525f908152604090205481565b61037a610691366004615054565b611aec565b61039e60055481565b61039e6106ad366004614e1b565b611b95565b61037a6106c0366004614f66565b611cbf565b61039e5f81565b61037a6106da366004614cf7565b611e88565b61037a6106ed366004614f66565b612042565b60045461070a90600160a01b900464ffffffffff1681565b60405164ffffffffff909116815260200161035e565b61037a61072e366004614e77565b612118565b61047a610741366004615089565b6122a9565b61037a610754366004615113565b6126a1565b61037a610767366004614c76565b61274a565b61077f61077a366004614f66565b61276e565b60405161035e9a9998979695949392919061517b565b61037a6107a3366004614cf7565b612873565b61037a6107b6366004614c30565b6128fe565b6107ce6107c9366004614f66565b61293d565b60405161035e9190615220565b61037a6107e9366004614c5d565b6129f1565b61037a6107fc366004614e1b565b612a70565b61037a61080f366004615232565b612b2a565b61039e7f97667070c54ef182b0f5858b034beac1b6f3089aa2d3188bb1e8929f4fa9b92981565b61039e610849366004614c30565b60086020525f908152604090205481565b61039e7f0452520e6e3abf7cfe2cd1b64887f0531498ddf5f8b463e317004d844883643581565b61043c7f000000000000000000000000000000000000000000000000000000000000000081565b5f6001600160e01b03198216637965db0b60e01b14806108d857506301ffc9a760e01b6001600160e01b03198316145b92915050565b6001600160f81b0382165f90815260076020526040812090815462010000900460ff16600381111561091257610912615167565b1461093057604051635a90bb8d60e11b815260040160405180910390fd5b6001600160f81b0383165f908152600b60205260409020546001600160a01b03161561096f5760405163122f29db60e11b815260040160405180910390fd5b80546801000000000000000090046001600160a01b031661098e612e3a565b6001600160a01b0316146109b557604051635ebdb59560e11b815260040160405180910390fd5b805460ff908116908316106109dd5760405163bdc9571560e01b815260040160405180910390fd5b805460ff83166101000262ff0000191662ffff00199091161762010000178155600454610a1890600160a01b900464ffffffffff1642615295565b815467ffffffffff0000001916630100000064ffffffffff9283168102919091178084556040805160ff871681529290910490921660208201526001600160f81b038516917fcf62110793fb65f4050739a12585196ba707028fe3a672e608953a955225bf8e910160405180910390a2505050565b5f82815260208190526040902060010154610aa781612e48565b610ab18383612e59565b50505050565b5f610ac0612e3a565b6001600160a01b0381165f908152600d6020526040812054919250819003610afb57604051631f2a200560e01b815260040160405180910390fd5b6001600160a01b038083165f908152600d6020526040812055610b41907f0000000000000000000000000000000000000000000000000000000000000000168383612f01565b816001600160a01b03167f570faf8e540b6c7c198632dd242fe58f4511bd8d4398c1517a3a6cd55d44310a82604051610b7c91815260200190565b60405180910390a25050565b610b90612e3a565b6001600160a01b0316816001600160a01b031614610bc15760405163334bd91960e11b815260040160405180910390fd5b610bcb8282612f60565b505050565b5f610bda81612e48565b6001600160f81b0385165f908152600b6020526040902080546001600160a01b0316610c1957604051635b92b88960e01b815260040160405180910390fd5b6001600160f81b0386165f9081526007602052604090208415610cfc575f815462010000900460ff166003811115610c5357610c53615167565b14610c7157604051635a90bb8d60e11b815260040160405180910390fd5b805460ff90811690851610610c995760405163bdc9571560e01b815260040160405180910390fd5b805460ff8516610100810262ff0000191662ffff0019909216919091176202000017825560408051918252516001600160f81b038916917f46f334b6549590870b9c902d856546ee9daf2a4e2148b940586c6b586180a3df919081900360200190a25b60018083015483546001600160f81b038a165f908152600b6020526040812080546001600160a01b031916815590930192909255906001600160a01b03168115610d96578715610d7f57610d7a6001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000168284612f01565b610d96565b81600c5f828254610d9091906152b2565b90915550505b604080518915158152881515602082015260ff88168183015290516001600160f81b038b16917fdf55a9e8ed4528619e4dcd8ec5e3014c7fb0e8166bed5a4266fda5d8ecaf568a919081900360600190a2505050505050505050565b610dfa612fff565b805f03610e1a57604051631f2a200560e01b815260040160405180910390fd5b5f6001600160f81b0383165f9081526007602052604090205462010000900460ff166003811115610e4d57610e4d615167565b14610e6b57604051635a90bb8d60e11b815260040160405180910390fd5b610e7d82610e77612e3a565b83613029565b610e876001600355565b5050565b7f97667070c54ef182b0f5858b034beac1b6f3089aa2d3188bb1e8929f4fa9b929610eb581612e48565b610ebd612fff565b815f03610edd57604051631f2a200560e01b815260040160405180910390fd5b610ee78886613245565b5f610ef389898961351f565b90505f610f0187878761351f565b5f8381526008602052604081205491925090610f48908690610f279060a08f01356152c5565b5f85815260086020526040902054610f439060a08d01356152c5565b61366e565b9050805f03610f6a5760405163ee3b3d4b60e01b815260040160405180910390fd5b5f8381526008602052604081208054839290610f879084906152b2565b90915550505f8281526008602052604081208054839290610fa99084906152b2565b90915550610fba90508b89836136a0565b6040805182815260808d01356020820152839185917f9ea76c0c413771a9b77ef3c9bae7ec0ebe255543f9747496c52e0db8aa88f9eb910160405180910390a35050506110076001600355565b5050505050505050565b5f5f61101c83611b95565b5f8181526009602052604090205490915060ff161561103d57505f92915050565b600a5f6110506040860160208701614c5d565b6001600160a01b03166001600160a01b031681526020019081526020015f20548360c001351461108257505f92915050565b611093610100840160e08501615054565b64ffffffffff164211156110a957505f92915050565b5f818152600860205260409020546110c59060a08501356152c5565b9392505050565b7f97667070c54ef182b0f5858b034beac1b6f3089aa2d3188bb1e8929f4fa9b9296110f681612e48565b6110fe612fff565b815f0361111e57604051631f2a200560e01b815260040160405180910390fd5b5f61112f60808b0160608c016152d8565b600181111561114057611140615167565b1461115e576040516306141cb160e21b815260040160405180910390fd5b6111706101208a016101008b016152f6565b61118d57604051632274719960e11b815260040160405180910390fd5b5f8061119c8b8b8b8a88613965565b915091505f5f5f6111b28e8c8c8c8c895f613af0565b919450925090506111cf60808f0135670de0b6b3a76400006152c5565b8110156111ef57604051632c1265b160e21b815260040160405180910390fd5b6111fa858484613d11565b6112288e5f01602081019061120f9190614f66565b8f60200160208101906112229190614c5d565b84613029565b61125c8e602001602081019061123e9190614c5d565b8f5f0160208101906112509190614f66565b878e8e88886001613d85565b505050505061126b6001600355565b505050505050505050565b7f97667070c54ef182b0f5858b034beac1b6f3089aa2d3188bb1e8929f4fa9b9296112a081612e48565b6112a8612fff565b815f036112c857604051631f2a200560e01b815260040160405180910390fd5b6112d28886613245565b5f6112e360808a0160608b016152d8565b60018111156112f4576112f4615167565b0361132d5761130b61012089016101008a016152f6565b61132857604051632274719960e11b815260040160405180910390fd5b61135c565b61133f610120860161010087016152f6565b61135c57604051632274719960e11b815260040160405180910390fd5b5f61136889898961351f565b90505f61137687878761351f565b5f838152600860205260408120549192509061139c908690610f279060a08f01356152c5565b9050805f036113be5760405163ee3b3d4b60e01b815260040160405180910390fd5b5f83815260086020526040812080548392906113db9084906152b2565b90915550505f82815260086020526040812080548392906113fd9084906152b2565b9091555061140e90508b89836136a0565b5f8061142060808e0160608f016152d8565b600181111561143157611431615167565b1461144b5761144660408a0160208b01614c5d565b61145b565b61145b60408d0160208e01614c5d565b905061147461146d60208e018e614f66565b8284613edb565b6040805183815260808e01356020820152849186917f9ea76c0c413771a9b77ef3c9bae7ec0ebe255543f9747496c52e0db8aa88f9eb910160405180910390a3505050506110076001600355565b5f6114cb612e3a565b6001600160a01b0381165f908152600a602052604081208054929350909182906114f49061530f565b9190508190559050816001600160a01b03167fa82a649bbd060c9099cd7b7326e2b0dc9e9af0836480e0f849dc9eaa79710b3b82604051610b7c91815260200190565b61153f612fff565b6001600160f81b0381165f9081526007602052604090206001815462010000900460ff16600381111561157457611574615167565b14611592576040516345c913c760e11b815260040160405180910390fd5b80546301000000900464ffffffffff1642106115c15760405163234c0ffd60e21b815260040160405180910390fd5b6001600160f81b0382165f908152600b60205260409020546001600160a01b0316156116005760405163122f29db60e11b815260040160405180910390fd5b5f611609612e3a565b6005549091501561164f5760055461164f906001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001690839030906140eb565b6040805180820182526001600160a01b0383811680835260055460208085019182526001600160f81b0389165f818152600b909252868220955186546001600160a01b03191695169490941785559051600190940193909355855467ffffffffffffff0019168655925190917fa8bd0374973bb323ec34c74782b20d8812906842bbe12184839e0de4a7aef24391a350506116ea6001600355565b50565b5f5f6116f883611b95565b5f8181526009602052604090205490915060ff161561171957505f92915050565b600a5f61172c6040860160208701614c5d565b6001600160a01b03166001600160a01b031681526020019081526020015f20548360c001351461175e57505f92915050565b61176f610100840160e08501615054565b64ffffffffff1642111561178557505f92915050565b5f8181526008602052604090205460a0840135116117a557505f92915050565b5f60075f6117b66020870187614f66565b6001600160f81b0316815260208101919091526040015f205462010000900460ff1660038111156117e9576117e9615167565b146117f657505f92915050565b50600192915050565b7f97667070c54ef182b0f5858b034beac1b6f3089aa2d3188bb1e8929f4fa9b92961182981612e48565b611831612fff565b815f0361185157604051631f2a200560e01b815260040160405180910390fd5b61185b8886613245565b600161186d60808a0160608b016152d8565b600181111561187e5761187e615167565b036118b75761189561012089016101008a016152f6565b6118b257604051632274719960e11b815260040160405180910390fd5b6118e6565b6118c9610120860161010087016152f6565b6118e657604051632274719960e11b815260040160405180910390fd5b5f6118f289898961351f565b90505f61190087878761351f565b5f8381526008602052604081205491925090611926908690610f279060a08f01356152c5565b9050805f036119485760405163ee3b3d4b60e01b815260040160405180910390fd5b5f83815260086020526040812080548392906119659084906152b2565b90915550505f82815260086020526040812080548392906119879084906152b2565b909155505f905060016119a060808e0160608f016152d8565b60018111156119b1576119b1615167565b146119cb576119c660408a0160208b01614c5d565b6119db565b6119db60408d0160208e01614c5d565b90506119f46119ed60208e018e614f66565b8284613029565b6114748c8a846136a0565b5f6060805f5f5f6060611a10614124565b611a18614151565b604080515f80825260208201909252600f60f81b9b939a50919850469750309650945092509050565b5f611a4b81612e48565b600c545f819003611a6f57604051631f2a200560e01b815260040160405180910390fd5b5f600c55600454611aad906001600160a01b037f00000000000000000000000000000000000000000000000000000000000000008116911683612f01565b6004546040518281526001600160a01b03909116907fa087657e3d85162090ffd700fbfdf5070d816f63aa5da00063f6ffd369c8a6db90602001610b7c565b5f611af681612e48565b610e1064ffffffffff83161015611b2057604051630c59931360e31b815260040160405180910390fd5b600480547fffffffffffffff0000000000ffffffffffffffffffffffffffffffffffffffff16600160a01b64ffffffffff8516908102919091179091556040519081527fb8a6b2453f0ff93f116d7b6170f0e78d6a3aaf1b26e0be8c6d3760f59240c8ab906020015b60405180910390a15050565b5f6108d87f0452520e6e3abf7cfe2cd1b64887f0531498ddf5f8b463e317004d8448836435611bc76020850185614f66565b611bd76040860160208701614c5d565b611be7606087016040880161533b565b611bf760808801606089016152d8565b6001811115611c0857611c08615167565b608088013560a089013560c08a0135611c286101008c0160e08d01615054565b611c3a6101208d016101008e016152f6565b60408051602081019b909b526001600160f81b03909916988a01989098526001600160a01b03909616606089015260ff94851660808901529390921660a087015260c086015260e085015261010084015264ffffffffff166101208301521515610140820152610160016040516020818303038152906040528051906020012061417e565b611cc7612fff565b5f611cd181612e48565b6001600160f81b0382165f9081526007602052604090206002815462010000900460ff166003811115611d0657611d06615167565b1480611d2d57506003815462010000900460ff166003811115611d2b57611d2b615167565b145b15611d4b5760405163aa43cb2d60e01b815260040160405180910390fd5b805462ff00001916620300001781556001600160f81b0383165f908152600b6020526040902080546001600160a01b031615611e485760018082015482546001600160f81b0387165f908152600b6020526040812080546001600160a01b031916815590930192909255906001600160a01b03168115611df957611df96001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000168284612f01565b60408051600181525f602082018190528183015290516001600160f81b038816917fdf55a9e8ed4528619e4dcd8ec5e3014c7fb0e8166bed5a4266fda5d8ecaf568a919081900360600190a250505b6040516001600160f81b038516907f366891c1ca4127e2ac608063f4bd5d0ecd89465d6e5106335a1e549810d70600905f90a25050506116ea6001600355565b611e90612fff565b805f03611eb057604051631f2a200560e01b815260040160405180910390fd5b6001600160f81b0382165f9081526007602052604090206002815462010000900460ff166003811115611ee557611ee5615167565b14611f035760405163174b639360e11b815260040160405180910390fd5b5f611f0c612e3a565b82549091505f90610100900460ff16600886901b60ff191617604051634fd8bf9d60e01b81526001600160a01b03848116600483015260248201839052604482018790529192507f000000000000000000000000000000000000000000000000000000000000000090911690634fd8bf9d906064015f604051808303815f87803b158015611f98575f5ffd5b505af1158015611faa573d5f5f3e3d5ffd5b50869250611fe59150506001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000168483612f01565b60408051868152602081018390526001600160a01b038516916001600160f81b038916917f39bf51896a7ca4f38294c954d2fb7681789b6b7f2cbfff26beed75d33d1d8484910160405180910390a350505050610e876001600355565b6001600160f81b0381165f9081526007602052604090206001815462010000900460ff16600381111561207757612077615167565b14612095576040516345c913c760e11b815260040160405180910390fd5b80546301000000900464ffffffffff164210156120c55760405163e52e798f60e01b815260040160405180910390fd5b805462ff00001916620200001780825560405161010090910460ff1681526001600160f81b038316907f46f334b6549590870b9c902d856546ee9daf2a4e2148b940586c6b586180a3df90602001610b7c565b7f97667070c54ef182b0f5858b034beac1b6f3089aa2d3188bb1e8929f4fa9b92961214281612e48565b61214a612fff565b815f0361216a57604051631f2a200560e01b815260040160405180910390fd5b600161217c60808b0160608c016152d8565b600181111561218d5761218d615167565b146121ab576040516306141cb160e21b815260040160405180910390fd5b6121bd6101208a016101008b016152f6565b6121da57604051632274719960e11b815260040160405180910390fd5b5f806121e98b8b8b8a88613965565b915091505f5f5f6122008e8c8c8c8c896001613af0565b9194509250905061221d60808f0135670de0b6b3a76400006152c5565b81111561223d57604051632c1265b160e21b815260040160405180910390fd5b612248858484613d11565b61227b8e602001602081019061225e9190614c5d565b8f5f0160208101906122709190614f66565b878e8e88885f613d85565b61125c8e5f0160208101906122909190614f66565b8f60200160208101906122a39190614c5d565b84613edb565b5f7f97667070c54ef182b0f5858b034beac1b6f3089aa2d3188bb1e8929f4fa9b9296122d481612e48565b60028960ff1610156122f95760405163566f431760e11b815260040160405180910390fd5b6001600160a01b0388166123205760405163d92e233d60e01b815260040160405180910390fd5b8415806123355750670de0b6b3a76400008510155b156123535760405163747a60fb60e01b815260040160405180910390fd5b6101f461ffff8816111561237a5760405163cd4e616760e01b815260040160405180910390fd5b6101f461ffff871611156123a15760405163cd4e616760e01b815260040160405180910390fd5b6103e86123ae8789615354565b61ffff1611156123d15760405163cd4e616760e01b815260040160405180910390fd5b600680546001600160f81b0316905f6123e98361536e565b91906101000a8154816001600160f81b0302191690836001600160f81b0316021790555091506040518061014001604052808a60ff1681526020015f60ff1681526020015f600381111561243f5761243f615167565b81525f60208201526001600160a01b038a16604082015261ffff808a1660608301528816608082015260a001612473612e3a565b6001600160a01b0316815260200186815260200185858080601f0160208091040260200160405190810160405280939291908181526020018383808284375f9201829052509390945250506001600160f81b038516815260076020908152604091829020845181549286015160ff9081166101000261ffff19909416911617919091178082559184015190925090829062ff000019166201000083600381111561251f5761251f615167565b021790555060608201518154608084015160a085015160c08601517fffffffff00000000000000000000000000000000000000000000000000ffffff909316630100000064ffffffffff909516949094027fffffffff0000000000000000000000000000000000000000ffffffffffffffff1693909317680100000000000000006001600160a01b0392831602176001600160e01b0316600160e01b61ffff948516027dffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1617600160f01b939092169290920217825560e08301516001830180546001600160a01b031916919092161790556101008201516002820155610120820151600382019061262f908261540e565b5090505061263b612e3a565b6001600160a01b0316886001600160a01b0316836001600160f81b03167f2cce45ac64e7edbd91a5dbe797417fe383fcba68cce29f0bf36c041d11df317a8c89898960405161268d94939291906154c9565b60405180910390a450979650505050505050565b60405163d505accf60e01b81526001600160a01b038781166004830152306024830152604482018790526064820186905260ff8516608483015260a4820184905260c482018390527f0000000000000000000000000000000000000000000000000000000000000000169063d505accf9060e4015f604051808303815f87803b15801561272c575f5ffd5b505af115801561273e573d5f5f3e3d5ffd5b50505050505050505050565b5f8281526020819052604090206001015461276481612e48565b610ab18383612f60565b60076020525f9081526040902080546001820154600283015460038401805460ff8086169661010087048216966201000081049092169564ffffffffff6301000000840416956001600160a01b0368010000000000000000850481169661ffff600160e01b8704811697600160f01b9097041695939091169391926127f290615398565b80601f016020809104026020016040519081016040528092919081815260200182805461281e90615398565b80156128695780601f1061284057610100808354040283529160200191612869565b820191905f5260205f20905b81548152906001019060200180831161284c57829003601f168201915b505050505090508a565b61287b612fff565b805f0361289b57604051631f2a200560e01b815260040160405180910390fd5b5f6001600160f81b0383165f9081526007602052604090205462010000900460ff1660038111156128ce576128ce615167565b146128ec57604051635a90bb8d60e11b815260040160405180910390fd5b610e7d826128f8612e3a565b83613edb565b5f61290881612e48565b60058290556040518281527f0bfcb41fac269ec524d9147ffa162d270dfb52bce652428b0d4d73f77f85144190602001611b89565b6001600160f81b0381165f9081526007602052604081205460609160ff909116908167ffffffffffffffff81111561297757612977615327565b6040519080825280602002602001820160405280156129a0578160200160208202803683370190505b5090505f5b8260ff168160ff1610156129e95760ff19600886901b1660ff821617828260ff16815181106129d6576129d6615508565b60209081029190910101526001016129a5565b509392505050565b5f6129fb81612e48565b6001600160a01b038216612a225760405163d92e233d60e01b815260040160405180910390fd5b600480546001600160a01b0319166001600160a01b0384169081179091556040519081527fc1b5345cce283376356748dc57f2dfa7120431d016fc7ca9ba641bc65f91411d90602001611b89565b612a806040820160208301614c5d565b6001600160a01b0316612a91612e3a565b6001600160a01b031614612ab8576040516380f806d960e01b815260040160405180910390fd5b5f612ac282611b95565b5f81815260096020908152604091829020805460ff19166001179055919250612af091908401908401614c5d565b6001600160a01b0316817f8277c0cf4ef7be7ca99936f92601619d3610c9a743875b6af5d59b50e07c880960405160405180910390a35050565b612b32612fff565b6001600160f81b0383165f9081526007602052604090206003815462010000900460ff166003811115612b6757612b67615167565b14612b8557604051630cbbcc0960e41b815260040160405180910390fd5b5f612b8e612e3a565b825490915060ff16838114612bb65760405163566f431760e11b815260040160405180910390fd5b5f8060ff831667ffffffffffffffff811115612bd457612bd4615327565b604051908082528060200260200182016040528015612bfd578160200160208202803683370190505b5090505f8360ff1667ffffffffffffffff811115612c1d57612c1d615327565b604051908082528060200260200182016040528015612c46578160200160208202803683370190505b5090505f5b8460ff168160ff161015612cf65760ff1960088b901b1660ff821617838260ff1681518110612c7c57612c7c615508565b60200260200101818152505088888260ff16818110612c9d57612c9d615508565b90506020020135828260ff1681518110612cb957612cb9615508565b60200260200101818152505088888260ff16818110612cda57612cda615508565b9050602002013584612cec91906152b2565b9350600101612c4b565b50825f03612d1757604051631f2a200560e01b815260040160405180910390fd5b6040516356b5c29160e01b81526001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016906356b5c29190612d679088908690869060040161551c565b5f604051808303815f87803b158015612d7e575f5ffd5b505af1158015612d90573d5f5f3e3d5ffd5b505050505f8460ff1684612da49190615563565b9050612dda6001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000168783612f01565b60408051858152602081018390526001600160a01b038816916001600160f81b038d16917fe7681c907e01adc23e016af849be430846685a98d69478af3f95ff16b3996b38910160405180910390a350505050505050610bcb6001600355565b5f612e436141aa565b905090565b6116ea81612e54612e3a565b614214565b5f828152602081815260408083206001600160a01b038516845290915281205460ff16612efa575f838152602081815260408083206001600160a01b03861684529091529020805460ff19166001179055612eb2612e3a565b6001600160a01b0316826001600160a01b0316847f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45060016108d8565b505f6108d8565b6040516001600160a01b03838116602483015260448201839052610bcb91859182169063a9059cbb906064015b604051602081830303815290604052915060e01b6020820180516001600160e01b03838183161783525050505061426b565b5f828152602081815260408083206001600160a01b038516845290915281205460ff1615612efa575f838152602081815260408083206001600160a01b03861684529091529020805460ff19169055612fb7612e3a565b6001600160a01b0316826001600160a01b0316847ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b60405160405180910390a45060016108d8565b60026003540361302257604051633ee5aeb560e01b815260040160405180910390fd5b6002600355565b6001600160f81b0383165f9081526007602052604090206130756001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000168430856140eb565b805460ff165f8167ffffffffffffffff81111561309457613094615327565b6040519080825280602002602001820160405280156130bd578160200160208202803683370190505b5090505f8260ff1667ffffffffffffffff8111156130dd576130dd615327565b604051908082528060200260200182016040528015613106578160200160208202803683370190505b5090505f5b8360ff168160ff1610156131715760ff19600889901b1660ff821617838260ff168151811061313c5761313c615508565b60200260200101818152505085828260ff168151811061315e5761315e615508565b602090810291909101015260010161310b565b50604051630fbfeffd60e11b81526001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001690631f7fdffa906131c290899086908690600401615576565b5f604051808303815f87803b1580156131d9575f5ffd5b505af11580156131eb573d5f5f3e3d5ffd5b50505050856001600160a01b0316876001600160f81b03167f2a8bd3a7527adaac071b804b0b3a57b13202b517a8853a761ab2cb945930a5668760405161323491815260200190565b60405180910390a350505050505050565b6132526020820182614f66565b6001600160f81b03166132686020840184614f66565b6001600160f81b03161461328f576040516306141cb160e21b815260040160405180910390fd5b61329f606082016040830161533b565b60ff166132b2606084016040850161533b565b60ff16146132d3576040516306141cb160e21b815260040160405180910390fd5b6132e360808201606083016152d8565b60018111156132f4576132f4615167565b61330460808401606085016152d8565b600181111561331557613315615167565b03613333576040516306141cb160e21b815260040160405180910390fd5b5f6007816133446020860186614f66565b6001600160f81b0316815260208101919091526040015f9081209150815462010000900460ff16600381111561337c5761337c615167565b1461339a57604051635a90bb8d60e11b815260040160405180910390fd5b805460ff166133af606085016040860161533b565b60ff16106133d05760405163bdc9571560e01b815260040160405180910390fd5b608083013515806133ed5750670de0b6b3a7640000836080013510155b1561340a5760405162bfc92160e01b815260040160405180910390fd5b608082013515806134275750670de0b6b3a7640000826080013510155b156134445760405162bfc92160e01b815260040160405180910390fd5b60028101546134579060808501356155c4565b15613475576040516362d6f91760e01b815260040160405180910390fd5b60028101546134889060808401356155c4565b156134a6576040516362d6f91760e01b815260040160405180910390fd5b5f6134b760808501606086016152d8565b60018111156134c8576134c8615167565b036134f657816080013583608001351015610bcb57604051632c1265b160e21b815260040160405180910390fd5b826080013582608001351015610bcb57604051632c1265b160e21b815260040160405180910390fd5b5f613531610100850160e08601615054565b64ffffffffff16421115613558576040516362b439dd60e11b815260040160405180910390fd5b600a5f61356b6040870160208801614c5d565b6001600160a01b03166001600160a01b031681526020019081526020015f20548460c00135146135ae57604051636ab7e19560e11b815260040160405180910390fd5b6135b784611b95565b5f8181526009602052604090205490915060ff1615613602576040517fff55f94400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6136516136156040860160208701614c5d565b8285858080601f0160208091040260200160405190810160405280939291908181526020018383808284375f920191909152506142d792505050565b6110c557604051638baa579f60e01b815260040160405180910390fd5b5f828410613689578183106136835781613698565b82613698565b8184106136965781613698565b835b949350505050565b5f806136b260808601606087016152d8565b60018111156136c3576136c3615167565b146136dd576136d86040840160208501614c5d565b6136ed565b6136ed6040850160208601614c5d565b90505f600161370260808701606088016152d8565b600181111561371357613713615167565b1461372d576137286040850160208601614c5d565b61373d565b61373d6040860160208701614c5d565b90505f613757848760800135670de0b6b3a7640000614347565b90505f60078161376a60208a018a614f66565b6001600160f81b0316815260208101919091526040015f90812080549092506137a2908490600160e01b900461ffff16612710614347565b82549091505f906137c2908590600160f01b900461ffff16612710614347565b90505f6137cf82846152b2565b90506138066001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000168888886140eb565b8015613888576138416001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000168830846140eb565b82600c5f82825461385291906152b2565b909155505060018401546001600160a01b03165f908152600d6020526040812080548492906138829084906152b2565b90915550505b5f6138ba61389960208d018d614f66565b6138a960608e0160408f0161533b565b60ff1660089190911b60ff19161790565b604051637921219560e11b81526001600160a01b0389811660048301528a8116602483015260448201839052606482018c905260a060848301525f60a48301529192507f00000000000000000000000000000000000000000000000000000000000000009091169063f242432a9060c4015f604051808303815f87803b158015613942575f5ffd5b505af1158015613954573d5f5f3e3d5ffd5b505050505050505050505050505050565b5f808060078161397860208b018b614f66565b6001600160f81b0316815260208101919091526040015f9081209150815462010000900460ff1660038111156139b0576139b0615167565b146139ce57604051635a90bb8d60e11b815260040160405180910390fd5b805460ff166139e360608a0160408b0161533b565b60ff1610613a045760405163bdc9571560e01b815260040160405180910390fd5b60808801351580613a215750670de0b6b3a7640000886080013510155b15613a3e5760405162bfc92160e01b815260040160405180910390fd5b6002810154613a519060808a01356155c4565b15613a6f576040516362d6f91760e01b815260040160405180910390fd5b80545f90613a829060019060ff166155d7565b90508060ff168614613aa757604051631842fb1960e11b815260040160405180910390fd5b613ab289898961351f565b5f8181526008602052604081205491955086945090613ad59060a08c01356152c5565b905083811015613ae3578093505b5050509550959350505050565b60605f80878614613b14576040516306141cb160e21b815260040160405180910390fd5b8767ffffffffffffffff811115613b2d57613b2d615327565b604051908082528060200260200182016040528015613b56578160200160208202803683370190505b5092508491505f613b6d60608c0160408d0161533b565b600160ff919091161b90505f5b89811015613ce257613bb58b8b83818110613b9757613b97615508565b61012002919091019050613bae60208f018f614f66565b88856143f7565b8a8a82818110613bc757613bc7615508565b905061012002016040016020810190613be0919061533b565b60ff166001901b82179150613c308b8b83818110613c0057613c00615508565b905061012002018a8a84818110613c1957613c19615508565b9050602002810190613c2b91906155f0565b61351f565b858281518110613c4257613c42615508565b6020026020010181815250505f60085f878481518110613c6457613c64615508565b602002602001015181526020019081526020015f20548c8c84818110613c8c57613c8c615508565b9050610120020160a00135613ca191906152c5565b905084811015613caf578094505b8b8b83818110613cc157613cc1615508565b905061012002016080013584613cd791906152b2565b935050600101613b7a565b50825f03613d035760405163ee3b3d4b60e01b815260040160405180910390fd5b509750975097945050505050565b5f8381526008602052604081208054839290613d2e9084906152b2565b909155505f90505b8251811015610ab1578160085f858481518110613d5557613d55615508565b602002602001015181526020019081526020015f205f828254613d7891906152b2565b9091555050600101613d36565b5f5b8481101561126b578115613e1857613e1389878784818110613dab57613dab615508565b905061012002016020016020810190613dc49190614c5d565b8a898986818110613dd757613dd7615508565b905061012002016040016020810190613df0919061533b565b878b8b88818110613e0357613e03615508565b9050610120020160800135614577565b613e5a565b613e5a868683818110613e2d57613e2d615508565b905061012002016020016020810190613e469190614c5d565b8a8a898986818110613dd757613dd7615508565b838181518110613e6c57613e6c615508565b6020026020010151877f9ea76c0c413771a9b77ef3c9bae7ec0ebe255543f9747496c52e0db8aa88f9eb85898986818110613ea957613ea9615508565b9050610120020160800135604051613ecb929190918252602082015260400190565b60405180910390a3600101613d87565b6001600160f81b0383165f9081526007602052604081208054909160ff909116908167ffffffffffffffff811115613f1557613f15615327565b604051908082528060200260200182016040528015613f3e578160200160208202803683370190505b5090505f8260ff1667ffffffffffffffff811115613f5e57613f5e615327565b604051908082528060200260200182016040528015613f87578160200160208202803683370190505b5090505f5b8360ff168160ff161015613ff25760ff19600889901b1660ff821617838260ff1681518110613fbd57613fbd615508565b60200260200101818152505085828260ff1681518110613fdf57613fdf615508565b6020908102919091010152600101613f8c565b506040516356b5c29160e01b81526001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016906356b5c291906140439089908690869060040161551c565b5f604051808303815f87803b15801561405a575f5ffd5b505af115801561406c573d5f5f3e3d5ffd5b506140a69250506001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001690508787612f01565b856001600160a01b0316876001600160f81b03167ff91cdbe75f20036f2765f7089ede766b58a5a332146e5d7af0d96c32505d93178760405161323491815260200190565b6040516001600160a01b038481166024830152838116604483015260648201839052610ab19186918216906323b872dd90608401612f2e565b6060612e437f00000000000000000000000000000000000000000000000000000000000000006001614762565b6060612e437f00000000000000000000000000000000000000000000000000000000000000006002614762565b5f6108d861418a61480b565b8360405161190160f01b8152600281019290925260228201526042902090565b5f3660148082108015906141e657507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031633145b1561420c576141f936828403815f615633565b6142029161565a565b60601c9250505090565b339250505090565b5f828152602081815260408083206001600160a01b038516845290915290205460ff16610e875760405163e2517d3f60e01b81526001600160a01b0382166004820152602481018390526044015b60405180910390fd5b5f5f60205f8451602086015f885af18061428a576040513d5f823e3d81fd5b50505f513d915081156142a15780600114156142ae565b6001600160a01b0384163b155b15610ab157604051635274afe760e01b81526001600160a01b0385166004820152602401614262565b5f836001600160a01b03163b5f03614335575f5f6142f58585614934565b5090925090505f81600381111561430e5761430e615167565b14801561432c5750856001600160a01b0316826001600160a01b0316145b925050506110c5565b61434084848461497d565b90506110c5565b5f5f5f6143548686614a54565b91509150815f036143785783818161436e5761436e61554f565b04925050506110c5565b81841161438f5761438f6003851502601118614a70565b5f848688095f868103871696879004966002600389028118808a02820302808a02820302808a02820302808a02820302808a02820302808a02909103029181900381900460010185841190960395909502919093039390930492909217029150509392505050565b6001600160f81b0383165f818152600760209081526040909120919061441f90870187614f66565b6001600160f81b031614614446576040516306141cb160e21b815260040160405180910390fd5b82600181111561445857614458615167565b61446860808701606088016152d8565b600181111561447957614479615167565b14614497576040516306141cb160e21b815260040160405180910390fd5b805460ff166144ac606087016040880161533b565b60ff16106144cd5760405163bdc9571560e01b815260040160405180910390fd5b6144dd606086016040870161533b565b60ff166001901b82165f14614505576040516306141cb160e21b815260040160405180910390fd5b608085013515806145225750670de0b6b3a7640000856080013510155b1561453f5760405162bfc92160e01b815260040160405180910390fd5b60028101546145529060808701356155c4565b15614570576040516362d6f91760e01b815260040160405180910390fd5b5050505050565b5f61458b8383670de0b6b3a7640000614347565b6001600160f81b0386165f9081526007602052604081208054929350916145c1908490600160e01b900461ffff16612710614347565b82549091505f906145e1908590600160f01b900461ffff16612710614347565b90505f6145ee82846152b2565b90506146256001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000168b8d886140eb565b80156146a7576146606001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000168b30846140eb565b82600c5f82825461467191906152b2565b909155505060018401546001600160a01b03165f908152600d6020526040812080548492906146a19084906152b2565b90915550505b5f60ff1960088b901b1660ff8a1617604051637921219560e11b81526001600160a01b038e811660048301528d8116602483015260448201839052606482018b905260a060848301525f60a48301529192507f00000000000000000000000000000000000000000000000000000000000000009091169063f242432a9060c4015f604051808303815f87803b15801561473e575f5ffd5b505af1158015614750573d5f5f3e3d5ffd5b50505050505050505050505050505050565b606060ff831461477c5761477583614a81565b90506108d8565b81805461478890615398565b80601f01602080910402602001604051908101604052809291908181526020018280546147b490615398565b80156147ff5780601f106147d6576101008083540402835291602001916147ff565b820191905f5260205f20905b8154815290600101906020018083116147e257829003601f168201915b505050505090506108d8565b5f306001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001614801561486357507f000000000000000000000000000000000000000000000000000000000000000046145b1561488d57507f000000000000000000000000000000000000000000000000000000000000000090565b612e43604080517f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f60208201527f0000000000000000000000000000000000000000000000000000000000000000918101919091527f000000000000000000000000000000000000000000000000000000000000000060608201524660808201523060a08201525f9060c00160405160208183030381529060405280519060200120905090565b5f5f5f835160410361496b576020840151604085015160608601515f1a61495d88828585614abe565b955095509550505050614976565b505081515f91506002905b9250925092565b5f5f5f856001600160a01b0316858560405160240161499d9291906156a7565b60408051601f198184030181529181526020820180516001600160e01b0316630b135d3f60e11b179052516149d291906156bf565b5f60405180830381855afa9150503d805f8114614a0a576040519150601f19603f3d011682016040523d82523d5f602084013e614a0f565b606091505b5091509150818015614a2357506020815110155b8015614a4a57508051630b135d3f60e11b90614a4890830160209081019084016156d5565b145b9695505050505050565b5f805f1983850993909202808410938190039390930393915050565b634e487b715f52806020526024601cfd5b60605f614a8d83614b86565b6040805160208082528183019092529192505f91906020820181803683375050509182525060208101929092525090565b5f80807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0841115614af757505f91506003905082614b7c565b604080515f808252602082018084528a905260ff891692820192909252606081018790526080810186905260019060a0016020604051602081039080840390855afa158015614b48573d5f5f3e3d5ffd5b5050604051601f1901519150506001600160a01b038116614b7357505f925060019150829050614b7c565b92505f91508190505b9450945094915050565b5f60ff8216601f8111156108d857604051632cd44ac360e21b815260040160405180910390fd5b5f60208284031215614bbd575f5ffd5b81356001600160e01b0319811681146110c5575f5ffd5b80356001600160f81b0381168114614bea575f5ffd5b919050565b803560ff81168114614bea575f5ffd5b5f5f60408385031215614c10575f5ffd5b614c1983614bd4565b9150614c2760208401614bef565b90509250929050565b5f60208284031215614c40575f5ffd5b5035919050565b80356001600160a01b0381168114614bea575f5ffd5b5f60208284031215614c6d575f5ffd5b6110c582614c47565b5f5f60408385031215614c87575f5ffd5b82359150614c2760208401614c47565b80358015158114614bea575f5ffd5b5f5f5f5f60808587031215614cb9575f5ffd5b614cc285614bd4565b9350614cd060208601614c97565b9250614cde60408601614c97565b9150614cec60608601614bef565b905092959194509250565b5f5f60408385031215614d08575f5ffd5b614d1183614bd4565b946020939093013593505050565b5f6101208284031215614d30575f5ffd5b50919050565b5f5f83601f840112614d46575f5ffd5b50813567ffffffffffffffff811115614d5d575f5ffd5b602083019150836020828501011115614d74575f5ffd5b9250929050565b5f5f5f5f5f5f5f6102a0888a031215614d92575f5ffd5b614d9c8989614d1f565b965061012088013567ffffffffffffffff811115614db8575f5ffd5b614dc48a828b01614d36565b9097509550614dd99050896101408a01614d1f565b935061026088013567ffffffffffffffff811115614df5575f5ffd5b614e018a828b01614d36565b989b979a5095989497959661028090950135949350505050565b5f6101208284031215614e2c575f5ffd5b6110c58383614d1f565b5f5f83601f840112614e46575f5ffd5b50813567ffffffffffffffff811115614e5d575f5ffd5b6020830191508360208260051b8501011115614d74575f5ffd5b5f5f5f5f5f5f5f5f6101a0898b031215614e8f575f5ffd5b614e998a8a614d1f565b975061012089013567ffffffffffffffff811115614eb5575f5ffd5b614ec18b828c01614d36565b90985096505061014089013567ffffffffffffffff811115614ee1575f5ffd5b8901601f81018b13614ef1575f5ffd5b803567ffffffffffffffff811115614f07575f5ffd5b8b602061012083028401011115614f1c575f5ffd5b6020919091019550935061016089013567ffffffffffffffff811115614f40575f5ffd5b614f4c8b828c01614e36565b999c989b5096999598949794956101800135949350505050565b5f60208284031215614f76575f5ffd5b6110c582614bd4565b5f81518084528060208401602086015e5f602082860101526020601f19601f83011685010191505092915050565b5f8151808452602084019350602083015f5b82811015614fdd578151865260209586019590910190600101614fbf565b5093949350505050565b60ff60f81b8816815260e060208201525f61500560e0830189614f7f565b82810360408401526150178189614f7f565b90508660608401526001600160a01b03861660808401528460a084015282810360c08401526150468185614fad565b9a9950505050505050505050565b5f60208284031215615064575f5ffd5b813564ffffffffff811681146110c5575f5ffd5b803561ffff81168114614bea575f5ffd5b5f5f5f5f5f5f5f60c0888a03121561509f575f5ffd5b6150a888614bef565b96506150b660208901614c47565b95506150c460408901615078565b94506150d260608901615078565b93506080880135925060a088013567ffffffffffffffff8111156150f4575f5ffd5b6151008a828b01614d36565b989b979a50959850939692959293505050565b5f5f5f5f5f5f60c08789031215615128575f5ffd5b61513187614c47565b9550602087013594506040870135935061514d60608801614bef565b9598949750929560808101359460a0909101359350915050565b634e487b7160e01b5f52602160045260245ffd5b60ff8b16815260ff8a1660208201525f60048a106151a757634e487b7160e01b5f52602160045260245ffd5b8960408301526151c0606083018a64ffffffffff169052565b6001600160a01b038816608083015261ffff871660a083015261ffff861660c08301526001600160a01b03851660e083015283610100830152610140610120830152615210610140830184614f7f565b9c9b505050505050505050505050565b602081525f6110c56020830184614fad565b5f5f5f60408486031215615244575f5ffd5b61524d84614bd4565b9250602084013567ffffffffffffffff811115615268575f5ffd5b61527486828701614e36565b9497909650939450505050565b634e487b7160e01b5f52601160045260245ffd5b64ffffffffff81811683821601908111156108d8576108d8615281565b808201808211156108d8576108d8615281565b818103818111156108d8576108d8615281565b5f602082840312156152e8575f5ffd5b8135600281106110c5575f5ffd5b5f60208284031215615306575f5ffd5b6110c582614c97565b5f6001820161532057615320615281565b5060010190565b634e487b7160e01b5f52604160045260245ffd5b5f6020828403121561534b575f5ffd5b6110c582614bef565b61ffff81811683821601908111156108d8576108d8615281565b5f6001600160f81b0382166001600160f81b03810361538f5761538f615281565b60010192915050565b600181811c908216806153ac57607f821691505b602082108103614d3057634e487b7160e01b5f52602260045260245ffd5b601f821115610bcb57805f5260205f20601f840160051c810160208510156153ef5750805b601f840160051c820191505b81811015614570575f81556001016153fb565b815167ffffffffffffffff81111561542857615428615327565b61543c816154368454615398565b846153ca565b6020601f82116001811461546e575f83156154575750848201515b5f19600385901b1c1916600184901b178455614570565b5f84815260208120601f198516915b8281101561549d578785015182556020948501946001909201910161547d565b50848210156154ba57868401515f19600387901b60f8161c191681555b50505050600190811b01905550565b60ff8516815283602082015260606040820152816060820152818360808301375f818301608090810191909152601f909201601f191601019392505050565b634e487b7160e01b5f52603260045260245ffd5b6001600160a01b0384168152606060208201525f61553d6060830185614fad565b8281036040840152614a4a8185614fad565b634e487b7160e01b5f52601260045260245ffd5b5f826155715761557161554f565b500490565b6001600160a01b0384168152608060208201525f6155976080830185614fad565b82810360408401526155a98185614fad565b83810360609094019390935250505f81526020019392505050565b5f826155d2576155d261554f565b500690565b60ff82811682821603908111156108d8576108d8615281565b5f5f8335601e19843603018112615605575f5ffd5b83018035915067ffffffffffffffff82111561561f575f5ffd5b602001915036819003821315614d74575f5ffd5b5f5f85851115615641575f5ffd5b8386111561564d575f5ffd5b5050820193919092039150565b80356bffffffffffffffffffffffff1981169060148410156156a0576bffffffffffffffffffffffff196bffffffffffffffffffffffff198560140360031b1b82161691505b5092915050565b828152604060208201525f6136986040830184614f7f565b5f82518060208501845e5f920191825250919050565b5f602082840312156156e5575f5ffd5b5051919050560000000000000000000000001825127f8ace24ab22ac290cb58ca1e14d5e05ba000000000000000000000000fc00000000000000000000000000000000000001000000000000000000000000c6ef452b0de9e95ccb153c2a5a7a90154aab34190000000000000000000000005b35dbefb8b4918799246664ed3a7fe099619814000000000000000000000000c6ef452b0de9e95ccb153c2a5a7a90154aab341900000000000000000000000000000000000000000000000000000000000151800000000000000000000000000000000000000000000000056bc75e2d63100000000000000000000000000000b826477f9e2440f9c17a5e373aebfb811d57bd8a
Deployed Bytecode
0x608060405234801561000f575f5ffd5b506004361061033b575f3560e01c80638795cccb116101b3578063d0fec535116100f3578063e521cb921161009e578063f5b541a611610079578063f5b541a614610814578063f7213db61461083b578063f973a2091461085a578063fc0c546a14610881575f5ffd5b8063e521cb92146107db578063ee69bfd5146107ee578063efbf25a614610801575f5ffd5b8063d92c2e5e116100ce578063d92c2e5e14610795578063dbee7f63146107a8578063e1b192fc146107bb575f5ffd5b8063d0fec53514610746578063d547741f14610759578063d8f03a221461076c575f5ffd5b80639dd0c5f01161015e578063afbe4a4011610139578063afbe4a40146106df578063b150ceb0146106f2578063c931d52214610720578063cfbfdff914610733575f5ffd5b80639dd0c5f0146106b2578063a217fddf146106c5578063a63906da146106cc575f5ffd5b806396dd802e1161018e57806396dd802e1461068357806397f03f1c1461069657806399ba67f41461069f575f5ffd5b80638795cccb1461062657806391d148541461062e57806395e6630e14610664575f5ffd5b806354607c061161027e57806364df049e116102295780637da0a877116102045780637da0a87714610581578063801435af146105a757806381f8cf64146105f857806384b0196e1461060b575f5ffd5b806364df049e14610548578063669ba61c1461055b5780637bc10a971461056e575f5ffd5b80635889bf5e116102595780635889bf5e1461050b5780635c60bedb1461052d578063627cdcb914610540575f5ffd5b806354607c06146104a557806354718d30146104b8578063572b6c05146104cb575f5ffd5b806332a9bc12116102e95780633b1c4f4a116102c45780633b1c4f4a146104155780633c79c5e014610454578063406ef2ef146104675780634218161214610492575f5ffd5b806332a9bc12146103e757806336568abe146103ef5780633a86cc1c14610402575f5ffd5b80632e04b8e7116103195780632e04b8e7146103ac5780632f2ff15d146103cb57806331d1c1b3146103de575f5ffd5b806301ffc9a71461033f5780632358cb2f14610367578063248a9ca31461037c575b5f5ffd5b61035261034d366004614bad565b6108a8565b60405190151581526020015b60405180910390f35b61037a610375366004614bff565b6108de565b005b61039e61038a366004614c30565b5f9081526020819052604090206001015490565b60405190815260200161035e565b61039e6103ba366004614c5d565b600a6020525f908152604090205481565b61037a6103d9366004614c76565b610a8d565b61039e600c5481565b61037a610ab7565b61037a6103fd366004614c76565b610b88565b61037a610410366004614ca6565b610bd0565b61043c7f000000000000000000000000fc0000000000000000000000000000000000000181565b6040516001600160a01b03909116815260200161035e565b61037a610462366004614cf7565b610df2565b60065461047a906001600160f81b031681565b6040516001600160f81b03909116815260200161035e565b61037a6104a0366004614d7b565b610e8b565b61039e6104b3366004614e1b565b611011565b61037a6104c6366004614e77565b6110cc565b6103526104d9366004614c5d565b7f000000000000000000000000b826477f9e2440f9c17a5e373aebfb811d57bd8a6001600160a01b0390811691161490565b610352610519366004614c30565b60096020525f908152604090205460ff1681565b61037a61053b366004614d7b565b611276565b61037a6114c2565b60045461043c906001600160a01b031681565b61037a610569366004614f66565b611537565b61035261057c366004614e1b565b6116ed565b7f000000000000000000000000b826477f9e2440f9c17a5e373aebfb811d57bd8a61043c565b6105d96105b5366004614f66565b600b6020525f9081526040902080546001909101546001600160a01b039091169082565b604080516001600160a01b03909316835260208301919091520161035e565b61037a610606366004614d7b565b6117ff565b6106136119ff565b60405161035e9796959493929190614fe7565b61037a611a41565b61035261063c366004614c76565b5f918252602082815260408084206001600160a01b0393909316845291905290205460ff1690565b61039e610672366004614c5d565b600d6020525f908152604090205481565b61037a610691366004615054565b611aec565b61039e60055481565b61039e6106ad366004614e1b565b611b95565b61037a6106c0366004614f66565b611cbf565b61039e5f81565b61037a6106da366004614cf7565b611e88565b61037a6106ed366004614f66565b612042565b60045461070a90600160a01b900464ffffffffff1681565b60405164ffffffffff909116815260200161035e565b61037a61072e366004614e77565b612118565b61047a610741366004615089565b6122a9565b61037a610754366004615113565b6126a1565b61037a610767366004614c76565b61274a565b61077f61077a366004614f66565b61276e565b60405161035e9a9998979695949392919061517b565b61037a6107a3366004614cf7565b612873565b61037a6107b6366004614c30565b6128fe565b6107ce6107c9366004614f66565b61293d565b60405161035e9190615220565b61037a6107e9366004614c5d565b6129f1565b61037a6107fc366004614e1b565b612a70565b61037a61080f366004615232565b612b2a565b61039e7f97667070c54ef182b0f5858b034beac1b6f3089aa2d3188bb1e8929f4fa9b92981565b61039e610849366004614c30565b60086020525f908152604090205481565b61039e7f0452520e6e3abf7cfe2cd1b64887f0531498ddf5f8b463e317004d844883643581565b61043c7f0000000000000000000000001825127f8ace24ab22ac290cb58ca1e14d5e05ba81565b5f6001600160e01b03198216637965db0b60e01b14806108d857506301ffc9a760e01b6001600160e01b03198316145b92915050565b6001600160f81b0382165f90815260076020526040812090815462010000900460ff16600381111561091257610912615167565b1461093057604051635a90bb8d60e11b815260040160405180910390fd5b6001600160f81b0383165f908152600b60205260409020546001600160a01b03161561096f5760405163122f29db60e11b815260040160405180910390fd5b80546801000000000000000090046001600160a01b031661098e612e3a565b6001600160a01b0316146109b557604051635ebdb59560e11b815260040160405180910390fd5b805460ff908116908316106109dd5760405163bdc9571560e01b815260040160405180910390fd5b805460ff83166101000262ff0000191662ffff00199091161762010000178155600454610a1890600160a01b900464ffffffffff1642615295565b815467ffffffffff0000001916630100000064ffffffffff9283168102919091178084556040805160ff871681529290910490921660208201526001600160f81b038516917fcf62110793fb65f4050739a12585196ba707028fe3a672e608953a955225bf8e910160405180910390a2505050565b5f82815260208190526040902060010154610aa781612e48565b610ab18383612e59565b50505050565b5f610ac0612e3a565b6001600160a01b0381165f908152600d6020526040812054919250819003610afb57604051631f2a200560e01b815260040160405180910390fd5b6001600160a01b038083165f908152600d6020526040812055610b41907f000000000000000000000000fc00000000000000000000000000000000000001168383612f01565b816001600160a01b03167f570faf8e540b6c7c198632dd242fe58f4511bd8d4398c1517a3a6cd55d44310a82604051610b7c91815260200190565b60405180910390a25050565b610b90612e3a565b6001600160a01b0316816001600160a01b031614610bc15760405163334bd91960e11b815260040160405180910390fd5b610bcb8282612f60565b505050565b5f610bda81612e48565b6001600160f81b0385165f908152600b6020526040902080546001600160a01b0316610c1957604051635b92b88960e01b815260040160405180910390fd5b6001600160f81b0386165f9081526007602052604090208415610cfc575f815462010000900460ff166003811115610c5357610c53615167565b14610c7157604051635a90bb8d60e11b815260040160405180910390fd5b805460ff90811690851610610c995760405163bdc9571560e01b815260040160405180910390fd5b805460ff8516610100810262ff0000191662ffff0019909216919091176202000017825560408051918252516001600160f81b038916917f46f334b6549590870b9c902d856546ee9daf2a4e2148b940586c6b586180a3df919081900360200190a25b60018083015483546001600160f81b038a165f908152600b6020526040812080546001600160a01b031916815590930192909255906001600160a01b03168115610d96578715610d7f57610d7a6001600160a01b037f000000000000000000000000fc00000000000000000000000000000000000001168284612f01565b610d96565b81600c5f828254610d9091906152b2565b90915550505b604080518915158152881515602082015260ff88168183015290516001600160f81b038b16917fdf55a9e8ed4528619e4dcd8ec5e3014c7fb0e8166bed5a4266fda5d8ecaf568a919081900360600190a2505050505050505050565b610dfa612fff565b805f03610e1a57604051631f2a200560e01b815260040160405180910390fd5b5f6001600160f81b0383165f9081526007602052604090205462010000900460ff166003811115610e4d57610e4d615167565b14610e6b57604051635a90bb8d60e11b815260040160405180910390fd5b610e7d82610e77612e3a565b83613029565b610e876001600355565b5050565b7f97667070c54ef182b0f5858b034beac1b6f3089aa2d3188bb1e8929f4fa9b929610eb581612e48565b610ebd612fff565b815f03610edd57604051631f2a200560e01b815260040160405180910390fd5b610ee78886613245565b5f610ef389898961351f565b90505f610f0187878761351f565b5f8381526008602052604081205491925090610f48908690610f279060a08f01356152c5565b5f85815260086020526040902054610f439060a08d01356152c5565b61366e565b9050805f03610f6a5760405163ee3b3d4b60e01b815260040160405180910390fd5b5f8381526008602052604081208054839290610f879084906152b2565b90915550505f8281526008602052604081208054839290610fa99084906152b2565b90915550610fba90508b89836136a0565b6040805182815260808d01356020820152839185917f9ea76c0c413771a9b77ef3c9bae7ec0ebe255543f9747496c52e0db8aa88f9eb910160405180910390a35050506110076001600355565b5050505050505050565b5f5f61101c83611b95565b5f8181526009602052604090205490915060ff161561103d57505f92915050565b600a5f6110506040860160208701614c5d565b6001600160a01b03166001600160a01b031681526020019081526020015f20548360c001351461108257505f92915050565b611093610100840160e08501615054565b64ffffffffff164211156110a957505f92915050565b5f818152600860205260409020546110c59060a08501356152c5565b9392505050565b7f97667070c54ef182b0f5858b034beac1b6f3089aa2d3188bb1e8929f4fa9b9296110f681612e48565b6110fe612fff565b815f0361111e57604051631f2a200560e01b815260040160405180910390fd5b5f61112f60808b0160608c016152d8565b600181111561114057611140615167565b1461115e576040516306141cb160e21b815260040160405180910390fd5b6111706101208a016101008b016152f6565b61118d57604051632274719960e11b815260040160405180910390fd5b5f8061119c8b8b8b8a88613965565b915091505f5f5f6111b28e8c8c8c8c895f613af0565b919450925090506111cf60808f0135670de0b6b3a76400006152c5565b8110156111ef57604051632c1265b160e21b815260040160405180910390fd5b6111fa858484613d11565b6112288e5f01602081019061120f9190614f66565b8f60200160208101906112229190614c5d565b84613029565b61125c8e602001602081019061123e9190614c5d565b8f5f0160208101906112509190614f66565b878e8e88886001613d85565b505050505061126b6001600355565b505050505050505050565b7f97667070c54ef182b0f5858b034beac1b6f3089aa2d3188bb1e8929f4fa9b9296112a081612e48565b6112a8612fff565b815f036112c857604051631f2a200560e01b815260040160405180910390fd5b6112d28886613245565b5f6112e360808a0160608b016152d8565b60018111156112f4576112f4615167565b0361132d5761130b61012089016101008a016152f6565b61132857604051632274719960e11b815260040160405180910390fd5b61135c565b61133f610120860161010087016152f6565b61135c57604051632274719960e11b815260040160405180910390fd5b5f61136889898961351f565b90505f61137687878761351f565b5f838152600860205260408120549192509061139c908690610f279060a08f01356152c5565b9050805f036113be5760405163ee3b3d4b60e01b815260040160405180910390fd5b5f83815260086020526040812080548392906113db9084906152b2565b90915550505f82815260086020526040812080548392906113fd9084906152b2565b9091555061140e90508b89836136a0565b5f8061142060808e0160608f016152d8565b600181111561143157611431615167565b1461144b5761144660408a0160208b01614c5d565b61145b565b61145b60408d0160208e01614c5d565b905061147461146d60208e018e614f66565b8284613edb565b6040805183815260808e01356020820152849186917f9ea76c0c413771a9b77ef3c9bae7ec0ebe255543f9747496c52e0db8aa88f9eb910160405180910390a3505050506110076001600355565b5f6114cb612e3a565b6001600160a01b0381165f908152600a602052604081208054929350909182906114f49061530f565b9190508190559050816001600160a01b03167fa82a649bbd060c9099cd7b7326e2b0dc9e9af0836480e0f849dc9eaa79710b3b82604051610b7c91815260200190565b61153f612fff565b6001600160f81b0381165f9081526007602052604090206001815462010000900460ff16600381111561157457611574615167565b14611592576040516345c913c760e11b815260040160405180910390fd5b80546301000000900464ffffffffff1642106115c15760405163234c0ffd60e21b815260040160405180910390fd5b6001600160f81b0382165f908152600b60205260409020546001600160a01b0316156116005760405163122f29db60e11b815260040160405180910390fd5b5f611609612e3a565b6005549091501561164f5760055461164f906001600160a01b037f000000000000000000000000fc000000000000000000000000000000000000011690839030906140eb565b6040805180820182526001600160a01b0383811680835260055460208085019182526001600160f81b0389165f818152600b909252868220955186546001600160a01b03191695169490941785559051600190940193909355855467ffffffffffffff0019168655925190917fa8bd0374973bb323ec34c74782b20d8812906842bbe12184839e0de4a7aef24391a350506116ea6001600355565b50565b5f5f6116f883611b95565b5f8181526009602052604090205490915060ff161561171957505f92915050565b600a5f61172c6040860160208701614c5d565b6001600160a01b03166001600160a01b031681526020019081526020015f20548360c001351461175e57505f92915050565b61176f610100840160e08501615054565b64ffffffffff1642111561178557505f92915050565b5f8181526008602052604090205460a0840135116117a557505f92915050565b5f60075f6117b66020870187614f66565b6001600160f81b0316815260208101919091526040015f205462010000900460ff1660038111156117e9576117e9615167565b146117f657505f92915050565b50600192915050565b7f97667070c54ef182b0f5858b034beac1b6f3089aa2d3188bb1e8929f4fa9b92961182981612e48565b611831612fff565b815f0361185157604051631f2a200560e01b815260040160405180910390fd5b61185b8886613245565b600161186d60808a0160608b016152d8565b600181111561187e5761187e615167565b036118b75761189561012089016101008a016152f6565b6118b257604051632274719960e11b815260040160405180910390fd5b6118e6565b6118c9610120860161010087016152f6565b6118e657604051632274719960e11b815260040160405180910390fd5b5f6118f289898961351f565b90505f61190087878761351f565b5f8381526008602052604081205491925090611926908690610f279060a08f01356152c5565b9050805f036119485760405163ee3b3d4b60e01b815260040160405180910390fd5b5f83815260086020526040812080548392906119659084906152b2565b90915550505f82815260086020526040812080548392906119879084906152b2565b909155505f905060016119a060808e0160608f016152d8565b60018111156119b1576119b1615167565b146119cb576119c660408a0160208b01614c5d565b6119db565b6119db60408d0160208e01614c5d565b90506119f46119ed60208e018e614f66565b8284613029565b6114748c8a846136a0565b5f6060805f5f5f6060611a10614124565b611a18614151565b604080515f80825260208201909252600f60f81b9b939a50919850469750309650945092509050565b5f611a4b81612e48565b600c545f819003611a6f57604051631f2a200560e01b815260040160405180910390fd5b5f600c55600454611aad906001600160a01b037f000000000000000000000000fc000000000000000000000000000000000000018116911683612f01565b6004546040518281526001600160a01b03909116907fa087657e3d85162090ffd700fbfdf5070d816f63aa5da00063f6ffd369c8a6db90602001610b7c565b5f611af681612e48565b610e1064ffffffffff83161015611b2057604051630c59931360e31b815260040160405180910390fd5b600480547fffffffffffffff0000000000ffffffffffffffffffffffffffffffffffffffff16600160a01b64ffffffffff8516908102919091179091556040519081527fb8a6b2453f0ff93f116d7b6170f0e78d6a3aaf1b26e0be8c6d3760f59240c8ab906020015b60405180910390a15050565b5f6108d87f0452520e6e3abf7cfe2cd1b64887f0531498ddf5f8b463e317004d8448836435611bc76020850185614f66565b611bd76040860160208701614c5d565b611be7606087016040880161533b565b611bf760808801606089016152d8565b6001811115611c0857611c08615167565b608088013560a089013560c08a0135611c286101008c0160e08d01615054565b611c3a6101208d016101008e016152f6565b60408051602081019b909b526001600160f81b03909916988a01989098526001600160a01b03909616606089015260ff94851660808901529390921660a087015260c086015260e085015261010084015264ffffffffff166101208301521515610140820152610160016040516020818303038152906040528051906020012061417e565b611cc7612fff565b5f611cd181612e48565b6001600160f81b0382165f9081526007602052604090206002815462010000900460ff166003811115611d0657611d06615167565b1480611d2d57506003815462010000900460ff166003811115611d2b57611d2b615167565b145b15611d4b5760405163aa43cb2d60e01b815260040160405180910390fd5b805462ff00001916620300001781556001600160f81b0383165f908152600b6020526040902080546001600160a01b031615611e485760018082015482546001600160f81b0387165f908152600b6020526040812080546001600160a01b031916815590930192909255906001600160a01b03168115611df957611df96001600160a01b037f000000000000000000000000fc00000000000000000000000000000000000001168284612f01565b60408051600181525f602082018190528183015290516001600160f81b038816917fdf55a9e8ed4528619e4dcd8ec5e3014c7fb0e8166bed5a4266fda5d8ecaf568a919081900360600190a250505b6040516001600160f81b038516907f366891c1ca4127e2ac608063f4bd5d0ecd89465d6e5106335a1e549810d70600905f90a25050506116ea6001600355565b611e90612fff565b805f03611eb057604051631f2a200560e01b815260040160405180910390fd5b6001600160f81b0382165f9081526007602052604090206002815462010000900460ff166003811115611ee557611ee5615167565b14611f035760405163174b639360e11b815260040160405180910390fd5b5f611f0c612e3a565b82549091505f90610100900460ff16600886901b60ff191617604051634fd8bf9d60e01b81526001600160a01b03848116600483015260248201839052604482018790529192507f0000000000000000000000001825127f8ace24ab22ac290cb58ca1e14d5e05ba90911690634fd8bf9d906064015f604051808303815f87803b158015611f98575f5ffd5b505af1158015611faa573d5f5f3e3d5ffd5b50869250611fe59150506001600160a01b037f000000000000000000000000fc00000000000000000000000000000000000001168483612f01565b60408051868152602081018390526001600160a01b038516916001600160f81b038916917f39bf51896a7ca4f38294c954d2fb7681789b6b7f2cbfff26beed75d33d1d8484910160405180910390a350505050610e876001600355565b6001600160f81b0381165f9081526007602052604090206001815462010000900460ff16600381111561207757612077615167565b14612095576040516345c913c760e11b815260040160405180910390fd5b80546301000000900464ffffffffff164210156120c55760405163e52e798f60e01b815260040160405180910390fd5b805462ff00001916620200001780825560405161010090910460ff1681526001600160f81b038316907f46f334b6549590870b9c902d856546ee9daf2a4e2148b940586c6b586180a3df90602001610b7c565b7f97667070c54ef182b0f5858b034beac1b6f3089aa2d3188bb1e8929f4fa9b92961214281612e48565b61214a612fff565b815f0361216a57604051631f2a200560e01b815260040160405180910390fd5b600161217c60808b0160608c016152d8565b600181111561218d5761218d615167565b146121ab576040516306141cb160e21b815260040160405180910390fd5b6121bd6101208a016101008b016152f6565b6121da57604051632274719960e11b815260040160405180910390fd5b5f806121e98b8b8b8a88613965565b915091505f5f5f6122008e8c8c8c8c896001613af0565b9194509250905061221d60808f0135670de0b6b3a76400006152c5565b81111561223d57604051632c1265b160e21b815260040160405180910390fd5b612248858484613d11565b61227b8e602001602081019061225e9190614c5d565b8f5f0160208101906122709190614f66565b878e8e88885f613d85565b61125c8e5f0160208101906122909190614f66565b8f60200160208101906122a39190614c5d565b84613edb565b5f7f97667070c54ef182b0f5858b034beac1b6f3089aa2d3188bb1e8929f4fa9b9296122d481612e48565b60028960ff1610156122f95760405163566f431760e11b815260040160405180910390fd5b6001600160a01b0388166123205760405163d92e233d60e01b815260040160405180910390fd5b8415806123355750670de0b6b3a76400008510155b156123535760405163747a60fb60e01b815260040160405180910390fd5b6101f461ffff8816111561237a5760405163cd4e616760e01b815260040160405180910390fd5b6101f461ffff871611156123a15760405163cd4e616760e01b815260040160405180910390fd5b6103e86123ae8789615354565b61ffff1611156123d15760405163cd4e616760e01b815260040160405180910390fd5b600680546001600160f81b0316905f6123e98361536e565b91906101000a8154816001600160f81b0302191690836001600160f81b0316021790555091506040518061014001604052808a60ff1681526020015f60ff1681526020015f600381111561243f5761243f615167565b81525f60208201526001600160a01b038a16604082015261ffff808a1660608301528816608082015260a001612473612e3a565b6001600160a01b0316815260200186815260200185858080601f0160208091040260200160405190810160405280939291908181526020018383808284375f9201829052509390945250506001600160f81b038516815260076020908152604091829020845181549286015160ff9081166101000261ffff19909416911617919091178082559184015190925090829062ff000019166201000083600381111561251f5761251f615167565b021790555060608201518154608084015160a085015160c08601517fffffffff00000000000000000000000000000000000000000000000000ffffff909316630100000064ffffffffff909516949094027fffffffff0000000000000000000000000000000000000000ffffffffffffffff1693909317680100000000000000006001600160a01b0392831602176001600160e01b0316600160e01b61ffff948516027dffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1617600160f01b939092169290920217825560e08301516001830180546001600160a01b031916919092161790556101008201516002820155610120820151600382019061262f908261540e565b5090505061263b612e3a565b6001600160a01b0316886001600160a01b0316836001600160f81b03167f2cce45ac64e7edbd91a5dbe797417fe383fcba68cce29f0bf36c041d11df317a8c89898960405161268d94939291906154c9565b60405180910390a450979650505050505050565b60405163d505accf60e01b81526001600160a01b038781166004830152306024830152604482018790526064820186905260ff8516608483015260a4820184905260c482018390527f000000000000000000000000fc00000000000000000000000000000000000001169063d505accf9060e4015f604051808303815f87803b15801561272c575f5ffd5b505af115801561273e573d5f5f3e3d5ffd5b50505050505050505050565b5f8281526020819052604090206001015461276481612e48565b610ab18383612f60565b60076020525f9081526040902080546001820154600283015460038401805460ff8086169661010087048216966201000081049092169564ffffffffff6301000000840416956001600160a01b0368010000000000000000850481169661ffff600160e01b8704811697600160f01b9097041695939091169391926127f290615398565b80601f016020809104026020016040519081016040528092919081815260200182805461281e90615398565b80156128695780601f1061284057610100808354040283529160200191612869565b820191905f5260205f20905b81548152906001019060200180831161284c57829003601f168201915b505050505090508a565b61287b612fff565b805f0361289b57604051631f2a200560e01b815260040160405180910390fd5b5f6001600160f81b0383165f9081526007602052604090205462010000900460ff1660038111156128ce576128ce615167565b146128ec57604051635a90bb8d60e11b815260040160405180910390fd5b610e7d826128f8612e3a565b83613edb565b5f61290881612e48565b60058290556040518281527f0bfcb41fac269ec524d9147ffa162d270dfb52bce652428b0d4d73f77f85144190602001611b89565b6001600160f81b0381165f9081526007602052604081205460609160ff909116908167ffffffffffffffff81111561297757612977615327565b6040519080825280602002602001820160405280156129a0578160200160208202803683370190505b5090505f5b8260ff168160ff1610156129e95760ff19600886901b1660ff821617828260ff16815181106129d6576129d6615508565b60209081029190910101526001016129a5565b509392505050565b5f6129fb81612e48565b6001600160a01b038216612a225760405163d92e233d60e01b815260040160405180910390fd5b600480546001600160a01b0319166001600160a01b0384169081179091556040519081527fc1b5345cce283376356748dc57f2dfa7120431d016fc7ca9ba641bc65f91411d90602001611b89565b612a806040820160208301614c5d565b6001600160a01b0316612a91612e3a565b6001600160a01b031614612ab8576040516380f806d960e01b815260040160405180910390fd5b5f612ac282611b95565b5f81815260096020908152604091829020805460ff19166001179055919250612af091908401908401614c5d565b6001600160a01b0316817f8277c0cf4ef7be7ca99936f92601619d3610c9a743875b6af5d59b50e07c880960405160405180910390a35050565b612b32612fff565b6001600160f81b0383165f9081526007602052604090206003815462010000900460ff166003811115612b6757612b67615167565b14612b8557604051630cbbcc0960e41b815260040160405180910390fd5b5f612b8e612e3a565b825490915060ff16838114612bb65760405163566f431760e11b815260040160405180910390fd5b5f8060ff831667ffffffffffffffff811115612bd457612bd4615327565b604051908082528060200260200182016040528015612bfd578160200160208202803683370190505b5090505f8360ff1667ffffffffffffffff811115612c1d57612c1d615327565b604051908082528060200260200182016040528015612c46578160200160208202803683370190505b5090505f5b8460ff168160ff161015612cf65760ff1960088b901b1660ff821617838260ff1681518110612c7c57612c7c615508565b60200260200101818152505088888260ff16818110612c9d57612c9d615508565b90506020020135828260ff1681518110612cb957612cb9615508565b60200260200101818152505088888260ff16818110612cda57612cda615508565b9050602002013584612cec91906152b2565b9350600101612c4b565b50825f03612d1757604051631f2a200560e01b815260040160405180910390fd5b6040516356b5c29160e01b81526001600160a01b037f0000000000000000000000001825127f8ace24ab22ac290cb58ca1e14d5e05ba16906356b5c29190612d679088908690869060040161551c565b5f604051808303815f87803b158015612d7e575f5ffd5b505af1158015612d90573d5f5f3e3d5ffd5b505050505f8460ff1684612da49190615563565b9050612dda6001600160a01b037f000000000000000000000000fc00000000000000000000000000000000000001168783612f01565b60408051858152602081018390526001600160a01b038816916001600160f81b038d16917fe7681c907e01adc23e016af849be430846685a98d69478af3f95ff16b3996b38910160405180910390a350505050505050610bcb6001600355565b5f612e436141aa565b905090565b6116ea81612e54612e3a565b614214565b5f828152602081815260408083206001600160a01b038516845290915281205460ff16612efa575f838152602081815260408083206001600160a01b03861684529091529020805460ff19166001179055612eb2612e3a565b6001600160a01b0316826001600160a01b0316847f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45060016108d8565b505f6108d8565b6040516001600160a01b03838116602483015260448201839052610bcb91859182169063a9059cbb906064015b604051602081830303815290604052915060e01b6020820180516001600160e01b03838183161783525050505061426b565b5f828152602081815260408083206001600160a01b038516845290915281205460ff1615612efa575f838152602081815260408083206001600160a01b03861684529091529020805460ff19169055612fb7612e3a565b6001600160a01b0316826001600160a01b0316847ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b60405160405180910390a45060016108d8565b60026003540361302257604051633ee5aeb560e01b815260040160405180910390fd5b6002600355565b6001600160f81b0383165f9081526007602052604090206130756001600160a01b037f000000000000000000000000fc00000000000000000000000000000000000001168430856140eb565b805460ff165f8167ffffffffffffffff81111561309457613094615327565b6040519080825280602002602001820160405280156130bd578160200160208202803683370190505b5090505f8260ff1667ffffffffffffffff8111156130dd576130dd615327565b604051908082528060200260200182016040528015613106578160200160208202803683370190505b5090505f5b8360ff168160ff1610156131715760ff19600889901b1660ff821617838260ff168151811061313c5761313c615508565b60200260200101818152505085828260ff168151811061315e5761315e615508565b602090810291909101015260010161310b565b50604051630fbfeffd60e11b81526001600160a01b037f0000000000000000000000001825127f8ace24ab22ac290cb58ca1e14d5e05ba1690631f7fdffa906131c290899086908690600401615576565b5f604051808303815f87803b1580156131d9575f5ffd5b505af11580156131eb573d5f5f3e3d5ffd5b50505050856001600160a01b0316876001600160f81b03167f2a8bd3a7527adaac071b804b0b3a57b13202b517a8853a761ab2cb945930a5668760405161323491815260200190565b60405180910390a350505050505050565b6132526020820182614f66565b6001600160f81b03166132686020840184614f66565b6001600160f81b03161461328f576040516306141cb160e21b815260040160405180910390fd5b61329f606082016040830161533b565b60ff166132b2606084016040850161533b565b60ff16146132d3576040516306141cb160e21b815260040160405180910390fd5b6132e360808201606083016152d8565b60018111156132f4576132f4615167565b61330460808401606085016152d8565b600181111561331557613315615167565b03613333576040516306141cb160e21b815260040160405180910390fd5b5f6007816133446020860186614f66565b6001600160f81b0316815260208101919091526040015f9081209150815462010000900460ff16600381111561337c5761337c615167565b1461339a57604051635a90bb8d60e11b815260040160405180910390fd5b805460ff166133af606085016040860161533b565b60ff16106133d05760405163bdc9571560e01b815260040160405180910390fd5b608083013515806133ed5750670de0b6b3a7640000836080013510155b1561340a5760405162bfc92160e01b815260040160405180910390fd5b608082013515806134275750670de0b6b3a7640000826080013510155b156134445760405162bfc92160e01b815260040160405180910390fd5b60028101546134579060808501356155c4565b15613475576040516362d6f91760e01b815260040160405180910390fd5b60028101546134889060808401356155c4565b156134a6576040516362d6f91760e01b815260040160405180910390fd5b5f6134b760808501606086016152d8565b60018111156134c8576134c8615167565b036134f657816080013583608001351015610bcb57604051632c1265b160e21b815260040160405180910390fd5b826080013582608001351015610bcb57604051632c1265b160e21b815260040160405180910390fd5b5f613531610100850160e08601615054565b64ffffffffff16421115613558576040516362b439dd60e11b815260040160405180910390fd5b600a5f61356b6040870160208801614c5d565b6001600160a01b03166001600160a01b031681526020019081526020015f20548460c00135146135ae57604051636ab7e19560e11b815260040160405180910390fd5b6135b784611b95565b5f8181526009602052604090205490915060ff1615613602576040517fff55f94400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6136516136156040860160208701614c5d565b8285858080601f0160208091040260200160405190810160405280939291908181526020018383808284375f920191909152506142d792505050565b6110c557604051638baa579f60e01b815260040160405180910390fd5b5f828410613689578183106136835781613698565b82613698565b8184106136965781613698565b835b949350505050565b5f806136b260808601606087016152d8565b60018111156136c3576136c3615167565b146136dd576136d86040840160208501614c5d565b6136ed565b6136ed6040850160208601614c5d565b90505f600161370260808701606088016152d8565b600181111561371357613713615167565b1461372d576137286040850160208601614c5d565b61373d565b61373d6040860160208701614c5d565b90505f613757848760800135670de0b6b3a7640000614347565b90505f60078161376a60208a018a614f66565b6001600160f81b0316815260208101919091526040015f90812080549092506137a2908490600160e01b900461ffff16612710614347565b82549091505f906137c2908590600160f01b900461ffff16612710614347565b90505f6137cf82846152b2565b90506138066001600160a01b037f000000000000000000000000fc00000000000000000000000000000000000001168888886140eb565b8015613888576138416001600160a01b037f000000000000000000000000fc00000000000000000000000000000000000001168830846140eb565b82600c5f82825461385291906152b2565b909155505060018401546001600160a01b03165f908152600d6020526040812080548492906138829084906152b2565b90915550505b5f6138ba61389960208d018d614f66565b6138a960608e0160408f0161533b565b60ff1660089190911b60ff19161790565b604051637921219560e11b81526001600160a01b0389811660048301528a8116602483015260448201839052606482018c905260a060848301525f60a48301529192507f0000000000000000000000001825127f8ace24ab22ac290cb58ca1e14d5e05ba9091169063f242432a9060c4015f604051808303815f87803b158015613942575f5ffd5b505af1158015613954573d5f5f3e3d5ffd5b505050505050505050505050505050565b5f808060078161397860208b018b614f66565b6001600160f81b0316815260208101919091526040015f9081209150815462010000900460ff1660038111156139b0576139b0615167565b146139ce57604051635a90bb8d60e11b815260040160405180910390fd5b805460ff166139e360608a0160408b0161533b565b60ff1610613a045760405163bdc9571560e01b815260040160405180910390fd5b60808801351580613a215750670de0b6b3a7640000886080013510155b15613a3e5760405162bfc92160e01b815260040160405180910390fd5b6002810154613a519060808a01356155c4565b15613a6f576040516362d6f91760e01b815260040160405180910390fd5b80545f90613a829060019060ff166155d7565b90508060ff168614613aa757604051631842fb1960e11b815260040160405180910390fd5b613ab289898961351f565b5f8181526008602052604081205491955086945090613ad59060a08c01356152c5565b905083811015613ae3578093505b5050509550959350505050565b60605f80878614613b14576040516306141cb160e21b815260040160405180910390fd5b8767ffffffffffffffff811115613b2d57613b2d615327565b604051908082528060200260200182016040528015613b56578160200160208202803683370190505b5092508491505f613b6d60608c0160408d0161533b565b600160ff919091161b90505f5b89811015613ce257613bb58b8b83818110613b9757613b97615508565b61012002919091019050613bae60208f018f614f66565b88856143f7565b8a8a82818110613bc757613bc7615508565b905061012002016040016020810190613be0919061533b565b60ff166001901b82179150613c308b8b83818110613c0057613c00615508565b905061012002018a8a84818110613c1957613c19615508565b9050602002810190613c2b91906155f0565b61351f565b858281518110613c4257613c42615508565b6020026020010181815250505f60085f878481518110613c6457613c64615508565b602002602001015181526020019081526020015f20548c8c84818110613c8c57613c8c615508565b9050610120020160a00135613ca191906152c5565b905084811015613caf578094505b8b8b83818110613cc157613cc1615508565b905061012002016080013584613cd791906152b2565b935050600101613b7a565b50825f03613d035760405163ee3b3d4b60e01b815260040160405180910390fd5b509750975097945050505050565b5f8381526008602052604081208054839290613d2e9084906152b2565b909155505f90505b8251811015610ab1578160085f858481518110613d5557613d55615508565b602002602001015181526020019081526020015f205f828254613d7891906152b2565b9091555050600101613d36565b5f5b8481101561126b578115613e1857613e1389878784818110613dab57613dab615508565b905061012002016020016020810190613dc49190614c5d565b8a898986818110613dd757613dd7615508565b905061012002016040016020810190613df0919061533b565b878b8b88818110613e0357613e03615508565b9050610120020160800135614577565b613e5a565b613e5a868683818110613e2d57613e2d615508565b905061012002016020016020810190613e469190614c5d565b8a8a898986818110613dd757613dd7615508565b838181518110613e6c57613e6c615508565b6020026020010151877f9ea76c0c413771a9b77ef3c9bae7ec0ebe255543f9747496c52e0db8aa88f9eb85898986818110613ea957613ea9615508565b9050610120020160800135604051613ecb929190918252602082015260400190565b60405180910390a3600101613d87565b6001600160f81b0383165f9081526007602052604081208054909160ff909116908167ffffffffffffffff811115613f1557613f15615327565b604051908082528060200260200182016040528015613f3e578160200160208202803683370190505b5090505f8260ff1667ffffffffffffffff811115613f5e57613f5e615327565b604051908082528060200260200182016040528015613f87578160200160208202803683370190505b5090505f5b8360ff168160ff161015613ff25760ff19600889901b1660ff821617838260ff1681518110613fbd57613fbd615508565b60200260200101818152505085828260ff1681518110613fdf57613fdf615508565b6020908102919091010152600101613f8c565b506040516356b5c29160e01b81526001600160a01b037f0000000000000000000000001825127f8ace24ab22ac290cb58ca1e14d5e05ba16906356b5c291906140439089908690869060040161551c565b5f604051808303815f87803b15801561405a575f5ffd5b505af115801561406c573d5f5f3e3d5ffd5b506140a69250506001600160a01b037f000000000000000000000000fc000000000000000000000000000000000000011690508787612f01565b856001600160a01b0316876001600160f81b03167ff91cdbe75f20036f2765f7089ede766b58a5a332146e5d7af0d96c32505d93178760405161323491815260200190565b6040516001600160a01b038481166024830152838116604483015260648201839052610ab19186918216906323b872dd90608401612f2e565b6060612e437f4672617842657445786368616e6765000000000000000000000000000000000f6001614762565b6060612e437f31000000000000000000000000000000000000000000000000000000000000016002614762565b5f6108d861418a61480b565b8360405161190160f01b8152600281019290925260228201526042902090565b5f3660148082108015906141e657507f000000000000000000000000b826477f9e2440f9c17a5e373aebfb811d57bd8a6001600160a01b031633145b1561420c576141f936828403815f615633565b6142029161565a565b60601c9250505090565b339250505090565b5f828152602081815260408083206001600160a01b038516845290915290205460ff16610e875760405163e2517d3f60e01b81526001600160a01b0382166004820152602481018390526044015b60405180910390fd5b5f5f60205f8451602086015f885af18061428a576040513d5f823e3d81fd5b50505f513d915081156142a15780600114156142ae565b6001600160a01b0384163b155b15610ab157604051635274afe760e01b81526001600160a01b0385166004820152602401614262565b5f836001600160a01b03163b5f03614335575f5f6142f58585614934565b5090925090505f81600381111561430e5761430e615167565b14801561432c5750856001600160a01b0316826001600160a01b0316145b925050506110c5565b61434084848461497d565b90506110c5565b5f5f5f6143548686614a54565b91509150815f036143785783818161436e5761436e61554f565b04925050506110c5565b81841161438f5761438f6003851502601118614a70565b5f848688095f868103871696879004966002600389028118808a02820302808a02820302808a02820302808a02820302808a02820302808a02909103029181900381900460010185841190960395909502919093039390930492909217029150509392505050565b6001600160f81b0383165f818152600760209081526040909120919061441f90870187614f66565b6001600160f81b031614614446576040516306141cb160e21b815260040160405180910390fd5b82600181111561445857614458615167565b61446860808701606088016152d8565b600181111561447957614479615167565b14614497576040516306141cb160e21b815260040160405180910390fd5b805460ff166144ac606087016040880161533b565b60ff16106144cd5760405163bdc9571560e01b815260040160405180910390fd5b6144dd606086016040870161533b565b60ff166001901b82165f14614505576040516306141cb160e21b815260040160405180910390fd5b608085013515806145225750670de0b6b3a7640000856080013510155b1561453f5760405162bfc92160e01b815260040160405180910390fd5b60028101546145529060808701356155c4565b15614570576040516362d6f91760e01b815260040160405180910390fd5b5050505050565b5f61458b8383670de0b6b3a7640000614347565b6001600160f81b0386165f9081526007602052604081208054929350916145c1908490600160e01b900461ffff16612710614347565b82549091505f906145e1908590600160f01b900461ffff16612710614347565b90505f6145ee82846152b2565b90506146256001600160a01b037f000000000000000000000000fc00000000000000000000000000000000000001168b8d886140eb565b80156146a7576146606001600160a01b037f000000000000000000000000fc00000000000000000000000000000000000001168b30846140eb565b82600c5f82825461467191906152b2565b909155505060018401546001600160a01b03165f908152600d6020526040812080548492906146a19084906152b2565b90915550505b5f60ff1960088b901b1660ff8a1617604051637921219560e11b81526001600160a01b038e811660048301528d8116602483015260448201839052606482018b905260a060848301525f60a48301529192507f0000000000000000000000001825127f8ace24ab22ac290cb58ca1e14d5e05ba9091169063f242432a9060c4015f604051808303815f87803b15801561473e575f5ffd5b505af1158015614750573d5f5f3e3d5ffd5b50505050505050505050505050505050565b606060ff831461477c5761477583614a81565b90506108d8565b81805461478890615398565b80601f01602080910402602001604051908101604052809291908181526020018280546147b490615398565b80156147ff5780601f106147d6576101008083540402835291602001916147ff565b820191905f5260205f20905b8154815290600101906020018083116147e257829003601f168201915b505050505090506108d8565b5f306001600160a01b037f0000000000000000000000001d8b27951e37e259a1c694fce66d5de17173e5781614801561486357507f00000000000000000000000000000000000000000000000000000000000000fc46145b1561488d57507f0212000d65b1ead9a5096f455bdd980cd6304ca44e6797edc103374a4075dc4990565b612e43604080517f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f60208201527f4141c7603a77c5c4dd74ec000112e6fedb3d8f2503f7688f949169bb2b3eeffe918101919091527fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc660608201524660808201523060a08201525f9060c00160405160208183030381529060405280519060200120905090565b5f5f5f835160410361496b576020840151604085015160608601515f1a61495d88828585614abe565b955095509550505050614976565b505081515f91506002905b9250925092565b5f5f5f856001600160a01b0316858560405160240161499d9291906156a7565b60408051601f198184030181529181526020820180516001600160e01b0316630b135d3f60e11b179052516149d291906156bf565b5f60405180830381855afa9150503d805f8114614a0a576040519150601f19603f3d011682016040523d82523d5f602084013e614a0f565b606091505b5091509150818015614a2357506020815110155b8015614a4a57508051630b135d3f60e11b90614a4890830160209081019084016156d5565b145b9695505050505050565b5f805f1983850993909202808410938190039390930393915050565b634e487b715f52806020526024601cfd5b60605f614a8d83614b86565b6040805160208082528183019092529192505f91906020820181803683375050509182525060208101929092525090565b5f80807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0841115614af757505f91506003905082614b7c565b604080515f808252602082018084528a905260ff891692820192909252606081018790526080810186905260019060a0016020604051602081039080840390855afa158015614b48573d5f5f3e3d5ffd5b5050604051601f1901519150506001600160a01b038116614b7357505f925060019150829050614b7c565b92505f91508190505b9450945094915050565b5f60ff8216601f8111156108d857604051632cd44ac360e21b815260040160405180910390fd5b5f60208284031215614bbd575f5ffd5b81356001600160e01b0319811681146110c5575f5ffd5b80356001600160f81b0381168114614bea575f5ffd5b919050565b803560ff81168114614bea575f5ffd5b5f5f60408385031215614c10575f5ffd5b614c1983614bd4565b9150614c2760208401614bef565b90509250929050565b5f60208284031215614c40575f5ffd5b5035919050565b80356001600160a01b0381168114614bea575f5ffd5b5f60208284031215614c6d575f5ffd5b6110c582614c47565b5f5f60408385031215614c87575f5ffd5b82359150614c2760208401614c47565b80358015158114614bea575f5ffd5b5f5f5f5f60808587031215614cb9575f5ffd5b614cc285614bd4565b9350614cd060208601614c97565b9250614cde60408601614c97565b9150614cec60608601614bef565b905092959194509250565b5f5f60408385031215614d08575f5ffd5b614d1183614bd4565b946020939093013593505050565b5f6101208284031215614d30575f5ffd5b50919050565b5f5f83601f840112614d46575f5ffd5b50813567ffffffffffffffff811115614d5d575f5ffd5b602083019150836020828501011115614d74575f5ffd5b9250929050565b5f5f5f5f5f5f5f6102a0888a031215614d92575f5ffd5b614d9c8989614d1f565b965061012088013567ffffffffffffffff811115614db8575f5ffd5b614dc48a828b01614d36565b9097509550614dd99050896101408a01614d1f565b935061026088013567ffffffffffffffff811115614df5575f5ffd5b614e018a828b01614d36565b989b979a5095989497959661028090950135949350505050565b5f6101208284031215614e2c575f5ffd5b6110c58383614d1f565b5f5f83601f840112614e46575f5ffd5b50813567ffffffffffffffff811115614e5d575f5ffd5b6020830191508360208260051b8501011115614d74575f5ffd5b5f5f5f5f5f5f5f5f6101a0898b031215614e8f575f5ffd5b614e998a8a614d1f565b975061012089013567ffffffffffffffff811115614eb5575f5ffd5b614ec18b828c01614d36565b90985096505061014089013567ffffffffffffffff811115614ee1575f5ffd5b8901601f81018b13614ef1575f5ffd5b803567ffffffffffffffff811115614f07575f5ffd5b8b602061012083028401011115614f1c575f5ffd5b6020919091019550935061016089013567ffffffffffffffff811115614f40575f5ffd5b614f4c8b828c01614e36565b999c989b5096999598949794956101800135949350505050565b5f60208284031215614f76575f5ffd5b6110c582614bd4565b5f81518084528060208401602086015e5f602082860101526020601f19601f83011685010191505092915050565b5f8151808452602084019350602083015f5b82811015614fdd578151865260209586019590910190600101614fbf565b5093949350505050565b60ff60f81b8816815260e060208201525f61500560e0830189614f7f565b82810360408401526150178189614f7f565b90508660608401526001600160a01b03861660808401528460a084015282810360c08401526150468185614fad565b9a9950505050505050505050565b5f60208284031215615064575f5ffd5b813564ffffffffff811681146110c5575f5ffd5b803561ffff81168114614bea575f5ffd5b5f5f5f5f5f5f5f60c0888a03121561509f575f5ffd5b6150a888614bef565b96506150b660208901614c47565b95506150c460408901615078565b94506150d260608901615078565b93506080880135925060a088013567ffffffffffffffff8111156150f4575f5ffd5b6151008a828b01614d36565b989b979a50959850939692959293505050565b5f5f5f5f5f5f60c08789031215615128575f5ffd5b61513187614c47565b9550602087013594506040870135935061514d60608801614bef565b9598949750929560808101359460a0909101359350915050565b634e487b7160e01b5f52602160045260245ffd5b60ff8b16815260ff8a1660208201525f60048a106151a757634e487b7160e01b5f52602160045260245ffd5b8960408301526151c0606083018a64ffffffffff169052565b6001600160a01b038816608083015261ffff871660a083015261ffff861660c08301526001600160a01b03851660e083015283610100830152610140610120830152615210610140830184614f7f565b9c9b505050505050505050505050565b602081525f6110c56020830184614fad565b5f5f5f60408486031215615244575f5ffd5b61524d84614bd4565b9250602084013567ffffffffffffffff811115615268575f5ffd5b61527486828701614e36565b9497909650939450505050565b634e487b7160e01b5f52601160045260245ffd5b64ffffffffff81811683821601908111156108d8576108d8615281565b808201808211156108d8576108d8615281565b818103818111156108d8576108d8615281565b5f602082840312156152e8575f5ffd5b8135600281106110c5575f5ffd5b5f60208284031215615306575f5ffd5b6110c582614c97565b5f6001820161532057615320615281565b5060010190565b634e487b7160e01b5f52604160045260245ffd5b5f6020828403121561534b575f5ffd5b6110c582614bef565b61ffff81811683821601908111156108d8576108d8615281565b5f6001600160f81b0382166001600160f81b03810361538f5761538f615281565b60010192915050565b600181811c908216806153ac57607f821691505b602082108103614d3057634e487b7160e01b5f52602260045260245ffd5b601f821115610bcb57805f5260205f20601f840160051c810160208510156153ef5750805b601f840160051c820191505b81811015614570575f81556001016153fb565b815167ffffffffffffffff81111561542857615428615327565b61543c816154368454615398565b846153ca565b6020601f82116001811461546e575f83156154575750848201515b5f19600385901b1c1916600184901b178455614570565b5f84815260208120601f198516915b8281101561549d578785015182556020948501946001909201910161547d565b50848210156154ba57868401515f19600387901b60f8161c191681555b50505050600190811b01905550565b60ff8516815283602082015260606040820152816060820152818360808301375f818301608090810191909152601f909201601f191601019392505050565b634e487b7160e01b5f52603260045260245ffd5b6001600160a01b0384168152606060208201525f61553d6060830185614fad565b8281036040840152614a4a8185614fad565b634e487b7160e01b5f52601260045260245ffd5b5f826155715761557161554f565b500490565b6001600160a01b0384168152608060208201525f6155976080830185614fad565b82810360408401526155a98185614fad565b83810360609094019390935250505f81526020019392505050565b5f826155d2576155d261554f565b500690565b60ff82811682821603908111156108d8576108d8615281565b5f5f8335601e19843603018112615605575f5ffd5b83018035915067ffffffffffffffff82111561561f575f5ffd5b602001915036819003821315614d74575f5ffd5b5f5f85851115615641575f5ffd5b8386111561564d575f5ffd5b5050820193919092039150565b80356bffffffffffffffffffffffff1981169060148410156156a0576bffffffffffffffffffffffff196bffffffffffffffffffffffff198560140360031b1b82161691505b5092915050565b828152604060208201525f6136986040830184614f7f565b5f82518060208501845e5f920191825250919050565b5f602082840312156156e5575f5ffd5b505191905056
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
0000000000000000000000001825127f8ace24ab22ac290cb58ca1e14d5e05ba000000000000000000000000fc00000000000000000000000000000000000001000000000000000000000000c6ef452b0de9e95ccb153c2a5a7a90154aab34190000000000000000000000005b35dbefb8b4918799246664ed3a7fe099619814000000000000000000000000c6ef452b0de9e95ccb153c2a5a7a90154aab341900000000000000000000000000000000000000000000000000000000000151800000000000000000000000000000000000000000000000056bc75e2d63100000000000000000000000000000b826477f9e2440f9c17a5e373aebfb811d57bd8a
-----Decoded View---------------
Arg [0] : _token (address): 0x1825127F8acE24aB22Ac290cb58CA1E14D5e05Ba
Arg [1] : _frxUSD (address): 0xFc00000000000000000000000000000000000001
Arg [2] : _admin (address): 0xC6EF452b0de9E95Ccb153c2A5A7a90154aab3419
Arg [3] : _operator (address): 0x5B35dBeFb8b4918799246664ed3A7Fe099619814
Arg [4] : _protocolFeeRecipient (address): 0xC6EF452b0de9E95Ccb153c2A5A7a90154aab3419
Arg [5] : _disputeWindowDuration (uint40): 86400
Arg [6] : _disputeBondAmount (uint256): 100000000000000000000
Arg [7] : _trustedForwarder (address): 0xb826477f9e2440F9c17A5e373AEbFB811D57BD8a
-----Encoded View---------------
8 Constructor Arguments found :
Arg [0] : 0000000000000000000000001825127f8ace24ab22ac290cb58ca1e14d5e05ba
Arg [1] : 000000000000000000000000fc00000000000000000000000000000000000001
Arg [2] : 000000000000000000000000c6ef452b0de9e95ccb153c2a5a7a90154aab3419
Arg [3] : 0000000000000000000000005b35dbefb8b4918799246664ed3a7fe099619814
Arg [4] : 000000000000000000000000c6ef452b0de9e95ccb153c2a5a7a90154aab3419
Arg [5] : 0000000000000000000000000000000000000000000000000000000000015180
Arg [6] : 0000000000000000000000000000000000000000000000056bc75e2d63100000
Arg [7] : 000000000000000000000000b826477f9e2440f9c17a5e373aebfb811d57bd8a
Loading...
Loading
Loading...
Loading
Loading...
Loading
Net Worth in USD
$15.99
Net Worth in FRAX
36.55267
Token Allocations
FRXUSD
100.00%
Multichain Portfolio | 32 Chains
| Chain | Token | Portfolio % | Price | Amount | Value |
|---|---|---|---|---|---|
| FRAXTAL | 100.00% | $0.999373 | 16 | $15.99 |
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.