Source Code
Overview
S Balance
S Value
$0.00Latest 1 from a total of 1 transactions
| Transaction Hash |
|
Block
|
From
|
To
|
|||||
|---|---|---|---|---|---|---|---|---|---|
| _become | 44628512 | 152 days ago | IN | 0 S | 0.0019932 |
View more zero value Internal Transactions in Advanced View mode
Advanced mode:
Cross-Chain Transactions
Loading...
Loading
Contract Name:
TradingFloorV1
Compiler Version
v0.8.24+commit.e11b9ed9
Optimization Enabled:
Yes with 200 runs
Other Settings:
paris EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.24;
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "../interfaces/ITradingFloorV1.sol";
import "../interfaces/IRegistryV1.sol";
import "../interfaces/ILexPoolV1.sol";
import "../interfaces/IPoolAccountantV1.sol";
import {ILynxVersionedContract} from "../interfaces/ILynxVersionedContract.sol";
import "./TradingFloorStorage.sol";
import "./TradingFloorProxy.sol";
/**
* @title TradingFloorV1
* @notice The TradingFloor contract is the main contract for the Lynx trading platform.
* It handles the opening, updating and closing of positions.
*
* @dev Version History:
* - v1.00 (1000): Initial version with core trading functionality
* - Per-pair trader tracking using pairTraders and pairTradersInfo mappings
* - Basic position management with maxTradesPerPair limit
* - Standard fee collection and position lifecycle management
*
* - v1.01 (1010): Global trader tracking system implementation
* - Replaced per-pair trader tracking with global trader array
* - Added `traders` array for all active traders across all pairs
* - Added `tradersIndex` mapping with 1-based indexing (0 = not in array)
* - Added `activePositionIdsByTrader` for global position tracking
* - Added `positionIdToActivePositionIndex` for O(1) position removal
* - Changed `maxTradesPerPair` to `maxTradesPerTrader` for global limits
* - Implemented swap-and-pop pattern for efficient trader removal
* - Deprecated old mappings: `pairTraders` → `deprecated_pairTraders`,
* `pairTradersInfo` → `deprecated_pairTradersInfo`
* - Benefits: Better gas efficiency, simplified cross-pair management, O(1) operations
*/
contract TradingFloorV1 is
TradingFloorV1Storage,
ITradingFloorV1Functionality,
ILynxVersionedContract,
LexErrors
{
using SafeERC20 for IERC20;
// ***** Constants (ILynxVersionedContract interface) *****
string public constant CONTRACT_NAME = "TradingFloorV1";
string public constant CONTRACT_VERSION = "1010"; // 1.01 - Added global trader tracking
// ***** Constants *****
uint public constant MAX_FEE_FRACTION_FOR_CANCEL = FRACTION_SCALE / 100; // FRACTION_SCALE
// ***** Events *****
event SettlementAssetAdded(
address indexed asset,
address indexed lexPool,
address indexed poolAccountant
);
event NumberUpdated(string indexed name, uint value);
event PairPausedChange(uint indexed pairId, bool indexed isPaused);
event PositionIdentifiersStored(
bytes32 indexed positionId,
PositionIdentifiers identifiers
);
// Old event, left for indexing purposes
event PendingPositionStored(
bytes32 indexed positionId,
PositionPhase phase,
PositionRequestIdentifiers_Old requestIdentifiers,
PositionRequestParams requestParams,
uint32 _spreadReductionF
);
event PendingPositionStoredV1010(
bytes32 indexed positionId,
PositionPhase phase,
uint32 index,
PositionRequestIdentifiers requestIdentifiers,
PositionRequestParams requestParams,
uint32 _spreadReductionF
);
event PositionOpenCancelledByMarketPriceRange(
bytes32 indexed positionId,
uint64 triggerPrice
);
event PositionOpenCancelledByCap(
bytes32 indexed positionId,
CapType capType,
uint256 value
);
event PositionOpened(
bytes32 indexed positionId,
uint64 openPrice,
uint64 tp,
uint64 sl,
uint totalOpenFee,
uint lexFeePart
);
event PositionSetForMarketClose(
bytes32 indexed positionId,
uint64 _minPrice,
uint64 _maxPrice
);
event PositionClosedMarket(
bytes32 indexed positionId,
uint triggerPrice,
uint tradeValue,
int profitPrecision
);
event PositionClosedLimit(
bytes32 indexed positionId,
LimitTrigger indexed limitTrigger,
uint triggerPrice,
uint effectiveClosePrice,
uint tradeValue,
int profitPrecision
);
event FeeRegistered(
bytes32 indexed positionId,
address indexed token,
FeeType indexed feeType,
uint amount
);
event FeeCollected(
address indexed token,
FeeType indexed feeType,
address indexed receiver,
uint amount
);
event PendingPositionCancelled(
bytes32 indexed positionId,
address indexed source,
uint fee
);
event PositionMarketCloseCancelled(
bytes32 indexed positionId,
address indexed source,
uint fee
);
event PendingPositionUpdated(
bytes32 indexed positionId,
uint64 tp,
uint64 sl,
uint64 minPrice,
uint64 maxPrice
);
event OpenedPositionUpdated(
bytes32 indexed positionId,
uint16 indexed pairId,
bool buy,
PositionField indexed updatedField,
uint64 fieldValue
);
// ***** Modifiers *****
modifier onlyTradersPortal() {
require(
IRegistryV1(registry).isTradersPortalAndLocker(msg.sender),
"!TradersPortal"
);
_;
}
modifier onlyTriggers() {
require(IRegistryV1(registry).isTriggersAndLocker(msg.sender), "!Triggers");
_;
}
modifier onlyTradersPortalOrTriggers() {
require(
IRegistryV1(registry).isTradersPortalOrTriggersAndLocker(msg.sender),
"!(TradersPortal||Triggers)"
);
_;
}
// ***** Views (ILynxVersionedContract interface) *****
function getContractName() external pure override returns (string memory) {
return CONTRACT_NAME;
}
function getContractVersion() external pure override returns (string memory) {
return CONTRACT_VERSION;
}
// ***** Views *****
/**
* Generates the hash used to identify a position
*/
function generatePositionHashId(
address settlementAsset,
address trader,
uint16 pairId,
uint32 index
) public pure returns (bytes32 hashId) {
hashId = keccak256(
abi.encodePacked(settlementAsset, trader, pairId, index)
);
}
/**
* Builds the structs with info needed fo 'Triggers' interactions
*/
function getPositionTriggerInfo(
bytes32 _positionId
)
external
view
returns (
PositionPhase positionPhase,
uint64 timestamp,
uint16 pairId,
bool long,
uint32 spreadReductionF
)
{
return (
positionsById[_positionId].phase,
positionsById[_positionId].inPhaseSince,
positionIdentifiersById[_positionId].pairId,
positionsById[_positionId].long,
positionsById[_positionId].spreadReductionF
);
}
/**
* Builds the structs with info needed for 'TradersPortal' interactions
*/
function getPositionPortalInfo(
bytes32 _positionId
)
external
view
returns (PositionPhase positionPhase, uint64 timestamp, address trader)
{
return (
positionsById[_positionId].phase,
positionsById[_positionId].inPhaseSince,
positionIdentifiersById[_positionId].trader
);
}
/**
* Builds the structs with info needed for 'PoolAccountnat' interactions
*/
function getPositionRegistrationParams(
bytes32 _positionId
)
public
view
returns (
PoolAccountantStructs.PositionRegistrationParams memory registrationParams
)
{
Position memory position = positionsById[_positionId];
registrationParams.collateral = position.collateral;
registrationParams.leverage = position.leverage;
registrationParams.openPrice = position.openPrice;
registrationParams.long = position.long;
registrationParams.tp = positionLimitsInfoById[_positionId].tp;
return registrationParams;
}
/**
* @return true if the given asset has a Lex defined for it
*/
function isSettlementAssetSupported(
address settlementAsset
) public view returns (bool) {
return lexPoolForAsset[settlementAsset] != address(0);
}
function deprecated_pairTradersArray(
address _asset,
uint _pairIndex
) external view returns (address[] memory) {
return deprecated_pairTraders[_asset][_pairIndex];
}
/**
* @notice Returns the length of the global traders array
* @dev Part of the v1.01 global trader tracking system
* @return Number of traders with at least one active position
*/
function tradersAmount() external view returns (uint256) {
return traders.length;
}
/**
* @notice Gets the next position index for a trader to use in position ID generation
* @dev Part of the v1.01 global tracking system. Indices start at 11 to avoid
* collision with legacy positions. This ensures unique position IDs across
* all pairs for a given trader.
* @param _trader The trader address
* @return The next available position index for this trader
*/
function getNextPositionIndexForTrader(
address _trader
) public view returns (uint32) {
uint32 lastUsedIndex = pairTradersLastUsedPositionIndex[_trader];
require(lastUsedIndex < type(uint32).max, "POSITION_INDEX_OVERFLOW");
// If this is the first position for this trader,
// start from index 11 to avoid collision with existing positions
if (lastUsedIndex < 11) {
return 11;
}
return lastUsedIndex + 1;
}
/**
* @notice Returns all active position IDs for a trader across ALL pairs
* @dev Part of the v1.01 global tracking system. This replaces the old per-pair
* position tracking with a unified view of all trader positions.
* @param _trader The trader address
* @return Array of active position IDs across all trading pairs
*/
function getActivePositionIdsForTrader(
address _trader
) external view returns (bytes32[] memory) {
return activePositionIdsByTrader[_trader];
}
function getActivePositionsAmountForTrader(
address _trader
) external view returns (uint256) {
return activePositionIdsByTrader[_trader].length;
}
// ***** Initialization functions *****
/**
* @notice Part of the Proxy mechanism
*/
function _become(TradingFloorProxy tradingFloorProxy) public {
require(msg.sender == tradingFloorProxy.admin(), "!proxy.admin");
require(tradingFloorProxy._acceptImplementation() == 0, "fail");
}
// ***** Registry Functions *****
/**
* Adds a new settlement asset to the trading floor with the given LexPool and PoolAccountant
* @dev This function is only callable by the registry
*/
function supportNewSettlementAsset(
address _asset,
address _lexPool,
address _poolAccountant
) external {
require(msg.sender == registry, "!Registry");
require(lexPoolForAsset[_asset] == address(0), "ASSET_ALREADY_SUPPORTED");
// Store addresses
lexPoolForAsset[_asset] = _lexPool;
poolAccountantForAsset[_asset] = _poolAccountant;
emit SettlementAssetAdded(_asset, _lexPool, _poolAccountant);
}
// ***** Admin Functions *****
/**
* Setter for numeric parameters
*/
function setTradeParam(
AdminNumericParam numericParam,
uint value
) external onlyAdmin {
require(value > 0, "CANNOT_BE_ZERO");
string memory name;
if (numericParam == AdminNumericParam.MAX_TRADES_PER_TRADER) {
name = "maxTradesPerTrader";
maxTradesPerTrader = value;
} else if (numericParam == AdminNumericParam.MAX_SL_F) {
// Note: Forcing a value of 50% or above
require(value >= (FRACTION_SCALE * 50) / 100, "TRADE_PARAM_RESTRICTION");
name = "maxSlF";
maxSlF = value;
} else if (numericParam == AdminNumericParam.MAX_SANITY_PROFIT_F) {
// Note : Forcing a value of 200% or above
require(value >= 2 * FRACTION_SCALE, "TRADE_PARAM_RESTRICTION");
name = "maxSanityProfitF";
maxSanityProfitF = value;
} else {
revert("UNSUPPORTED");
}
emit NumberUpdated(name, value);
}
/**
* Allows to pause/unpause the opening/updating of positions in the given pair
*/
function setPairPaused(uint _pairId, bool _isPaused) external onlyAdmin {
pausedPairs[_pairId] = _isPaused;
emit PairPausedChange(_pairId, _isPaused);
}
// ***** Traders Portal Interaction *****
/**
* This function stores the request for opening a new Position
* @return positionId The id of the new position (pending to be opened)
*/
function storePendingPosition(
OpenOrderType _orderType,
PositionRequestIdentifiers memory _requestIdentifiers,
PositionRequestParams memory _requestParams,
uint32 _spreadReductionF
) external override onlyTradersPortal returns (bytes32 positionId) {
require(
isSettlementAssetSupported(_requestIdentifiers.settlementAsset),
"NON_SUPPORTED_SETTLEMENT_ASSET"
);
require(!pausedPairs[_requestIdentifiers.pairId], "PAIR_PAUSED");
require(
_orderType == OpenOrderType.MARKET || _orderType == OpenOrderType.LIMIT,
"UNSUPPORTED_ORDER_TYPE"
);
requireValidOpenTradeParameters(
_requestParams.long,
_requestParams.minPrice,
_requestParams.maxPrice,
_requestParams.tp,
_requestParams.sl
);
require(
activePositionIdsByTrader[_requestIdentifiers.trader].length <
maxTradesPerTrader,
"MAX_TRADES_PER_TRADER"
);
uint32 index;
(positionId, index) = storeIdentifiersIfNeeded(
_requestIdentifiers.settlementAsset,
_requestIdentifiers.trader,
_requestIdentifiers.pairId
);
takeSettlement(
_requestIdentifiers.settlementAsset,
_requestIdentifiers.trader,
_requestParams.collateral
);
// Add/Increase in traders
increaseOrAddToTradersLists(_requestIdentifiers.trader);
Position storage position = positionsById[positionId];
require(position.collateral == 0, "ID_USED");
position.spreadReductionF = _spreadReductionF;
position.long = _requestParams.long;
position.leverage = _requestParams.leverage;
position.collateral = _requestParams.collateral;
PositionPhase phase = _orderType == OpenOrderType.MARKET
? PositionPhase.OPEN_MARKET
: PositionPhase.OPEN_LIMIT;
position.phase = phase;
position.inPhaseSince = uint64(block.timestamp);
PositionLimitsInfo storage positionLimitInfo = positionLimitsInfoById[
positionId
];
positionLimitInfo.tp = _requestParams.tp;
positionLimitInfo.sl = _requestParams.sl;
PositionTriggerPrices storage triggerPrices = triggerPricesById[positionId];
triggerPrices.minPrice = _requestParams.minPrice;
triggerPrices.maxPrice = _requestParams.maxPrice;
triggerPrices.tpByFraction = _requestParams.tpByFraction;
triggerPrices.slByFraction = _requestParams.slByFraction;
emit PendingPositionStoredV1010(
positionId,
phase,
index,
_requestIdentifiers,
_requestParams,
_spreadReductionF
);
}
/**
* Sets the given position to be market closed
*/
function setOpenedPositionToMarketClose(
bytes32 _positionId,
uint64 _minPrice,
uint64 _maxPrice
) external override onlyTradersPortal {
// note : using 'storage' to reduce gas cost and contract size
Position storage position = positionsById[_positionId];
require(position.collateral > 0, "NO_SUCH_POSITION");
require(position.phase == PositionPhase.OPENED, "WRONG_PHASE");
position.phase = PositionPhase.CLOSE_MARKET;
position.inPhaseSince = uint64(block.timestamp);
PositionTriggerPrices storage triggerPrices = triggerPricesById[
_positionId
];
triggerPrices.minPrice = _minPrice;
triggerPrices.maxPrice = _maxPrice;
emit PositionSetForMarketClose(_positionId, _minPrice, _maxPrice);
}
/**
* Updates one of the fields in a pending LIMIT_OPEN position
*/
function updatePendingPosition_openLimit(
bytes32 _positionId,
uint64 _minPrice,
uint64 _maxPrice,
uint64 _tp,
uint64 _sl
) external override onlyTradersPortal {
Position storage _position = positionsById[_positionId];
require(_position.phase == PositionPhase.OPEN_LIMIT, "WRONG_PHASE");
require(
!pausedPairs[positionIdentifiersById[_positionId].pairId],
"PAIR_PAUSED"
);
requireValidOpenTradeParameters(
_position.long,
_minPrice,
_maxPrice,
_tp,
_sl
);
// Update the pending position timestamp
_position.inPhaseSince = uint64(block.timestamp);
// Update the position locally
PositionLimitsInfo storage _positionLimitInfo = positionLimitsInfoById[
_positionId
];
_positionLimitInfo.tp = _tp;
_positionLimitInfo.sl = _sl;
// Note : Not updating the timestamps as they only need to be updated for Opened positions
PositionTriggerPrices storage triggerPrices = triggerPricesById[
_positionId
];
triggerPrices.minPrice = _minPrice;
triggerPrices.maxPrice = _maxPrice;
emit PendingPositionUpdated(_positionId, _tp, _sl, _minPrice, _maxPrice);
}
// ***** Triggers Interaction *****
/**
* Called by the triggers in order to Open a new position by market price
*/
function openNewPosition_market(
bytes32 _positionId,
uint64 assetEffectivePrice,
uint256 feeForCancellation
) external onlyTriggers {
openNewTradeInternal(
_positionId,
PositionPhase.OPEN_MARKET,
assetEffectivePrice,
feeForCancellation
);
}
/**
* Called by the triggers in order to Open a new position by reached limit
*/
function openNewPosition_limit(
bytes32 _positionId,
uint64 assetEffectivePrice,
uint256 feeForCancellation
) external onlyTriggers {
openNewTradeInternal(
_positionId,
PositionPhase.OPEN_LIMIT,
assetEffectivePrice,
feeForCancellation
);
}
/**
* Called by the triggers in order to Close an existing position by market price
*/
function closeExistingPosition_Market(
bytes32 _positionId,
uint64, // assetPrice
uint64 effectivePrice
) external override onlyTriggers {
PositionTriggerPrices memory triggerPrices = triggerPricesById[_positionId];
require(triggerPrices.maxPrice > 0, "NO_SUCH_POSITION");
if (
triggerPrices.minPrice > effectivePrice ||
triggerPrices.maxPrice < effectivePrice
) {
cancelMarketCloseForPositionInternal(
address(this),
_positionId,
CloseOrderType.MARKET
);
} else {
(
uint tradeValue,
int profitPrecision,
uint finalClosingPrice
) = closeExistingTradeInternal(
_positionId,
effectivePrice,
PositionCloseType.MARKET
);
emit PositionClosedMarket(
_positionId,
finalClosingPrice,
tradeValue,
profitPrecision
);
}
}
/**
* Called by the triggers in order to Close an existing position by a reached limit value
*/
function closeExistingPosition_Limit(
bytes32 _positionId,
LimitTrigger limitTrigger,
uint64, // assetPrice
uint64 effectivePrice
) external override onlyTriggers {
Position memory position = positionsById[_positionId];
require(position.collateral > 0, "NO_SUCH_POSITION");
PositionLimitsInfo memory positionLimitInfo = positionLimitsInfoById[
_positionId
];
bool triggerValid = false;
uint effectiveClosingPrice;
PositionCloseType positionCloseType;
if (limitTrigger == LimitTrigger.SL) {
triggerValid = position.long
? effectivePrice <= positionLimitInfo.sl
: effectivePrice >= positionLimitInfo.sl;
effectiveClosingPrice = positionLimitInfo.sl;
positionCloseType = PositionCloseType.SL;
} else if (limitTrigger == LimitTrigger.TP) {
triggerValid = position.long
? effectivePrice >= positionLimitInfo.tp
: effectivePrice <= positionLimitInfo.tp;
effectiveClosingPrice = positionLimitInfo.tp;
positionCloseType = PositionCloseType.TP;
} else if (limitTrigger == LimitTrigger.LIQ) {
// Note : The Accountant will be the one to adjust the price for liquidation
triggerValid = true;
effectiveClosingPrice = effectivePrice;
positionCloseType = PositionCloseType.LIQ;
} else {
revert("WRONG_LIMIT_TRIGGER");
}
// Revert if the conditions are not met for triggering
require(triggerValid, "FALSE_TRIGGER");
(
uint tradeValue,
int profitPrecision,
uint finalClosingPrice
) = closeExistingTradeInternal(
_positionId,
effectiveClosingPrice,
positionCloseType
);
// Checking again for liq to allow quicker failure in TP and SL
if (positionCloseType == PositionCloseType.LIQ) {
triggerValid = position.long
? effectivePrice <= finalClosingPrice
: effectivePrice >= finalClosingPrice;
require(triggerValid, "FALSE_TRIGGER");
}
emit PositionClosedLimit(
_positionId,
limitTrigger,
effectivePrice,
finalClosingPrice,
tradeValue,
profitPrecision
);
}
/**
* Updates a PositionField of an OPEN position
*/
function updateOpenedPosition(
bytes32 positionId,
PositionField updateField,
uint64 fieldValue,
uint64 effectivePrice
) external onlyTriggers {
Position storage p = positionsById[positionId];
PositionLimitsInfo storage limitInfo = positionLimitsInfoById[positionId];
PositionIdentifiers memory identifiers = positionIdentifiersById[
positionId
];
require(p.collateral > 0, "NO_SUCH_POSITION");
require(p.phase == PositionPhase.OPENED, "WRONG_PHASE");
IPoolAccountantV1 poolAccountant = IPoolAccountantV1(
poolAccountantForAsset[identifiers.settlementAsset]
);
uint64 tpToUse;
uint64 slToUse;
if (updateField == PositionField.TP) {
uint64 correctedTp = correctTp(
uint64(poolAccountant.maxGainF()),
p.openPrice,
p.leverage,
fieldValue,
p.long
);
// Sanity
require(correctedTp == fieldValue, "BAD_FIELD_VALUE");
require(correctedTp != limitInfo.tp, "SAME_TP");
tpToUse = correctedTp;
slToUse = limitInfo.sl;
limitInfo.tpLastUpdated = uint64(block.timestamp);
// Register the change in the LexPool
// Might revert if a cap is reached
poolAccountant.registerUpdateTp(
positionId,
identifiers.trader,
identifiers.pairId,
p.collateral,
p.leverage,
p.long,
p.openPrice,
limitInfo.tp,
tpToUse
);
} else if (updateField == PositionField.SL) {
uint64 correctedSl = correctSl(
uint64(poolAccountant.maxGainF()),
p.openPrice,
p.leverage,
fieldValue,
p.long
);
// Sanity
require(correctedSl == fieldValue, "BAD_FIELD_VALUE");
require(correctedSl != limitInfo.sl, "SAME_SL");
tpToUse = limitInfo.tp;
slToUse = correctedSl;
limitInfo.slLastUpdated = uint64(block.timestamp);
} else {
revert("UNSUPPORTED");
}
uint effectiveMinPrice = p.openPrice > effectivePrice
? effectivePrice
: p.openPrice;
uint effectiveMaxPrice = p.openPrice < effectivePrice
? effectivePrice
: p.openPrice;
// Ensure the new params are valid
requireValidOpenTradeParameters(
p.long,
effectiveMinPrice,
effectiveMaxPrice,
tpToUse,
slToUse
);
limitInfo.sl = slToUse;
limitInfo.tp = tpToUse;
emit OpenedPositionUpdated(
positionId,
identifiers.pairId,
p.long,
updateField,
fieldValue
);
}
// ***** Traders Portal/Triggers Shared Interaction *****
/**
* Cancel a pending open position, returning assets to trader.
*/
function cancelPendingPosition(
bytes32 _positionId,
OpenOrderType _orderType,
uint feeFraction
) external override onlyTradersPortalOrTriggers {
require(feeFraction <= MAX_FEE_FRACTION_FOR_CANCEL, "FEE_FRACTION_TOO_BIG");
Position memory position = positionsById[_positionId];
require(positionsById[_positionId].collateral > 0, "NO_SUCH_POSITION");
PositionIdentifiers memory identifiers = positionIdentifiersById[
_positionId
];
if (_orderType == OpenOrderType.MARKET) {
require(position.phase == PositionPhase.OPEN_MARKET, "NOT_MARKET_ORDER");
} else if (_orderType == OpenOrderType.LIMIT) {
require(position.phase == PositionPhase.OPEN_LIMIT, "NOT_LIMIT_ORDER");
} else {
revert("WRONG_ORDER_TYPE");
}
settleCanceledOpenOrderInternal(
_positionId,
identifiers.settlementAsset,
identifiers.trader,
position.collateral,
position.leverage,
feeFraction,
msg.sender
);
}
/**
* Cancel a CLOSE_MARKET position, returning the position to an OPEN phase.
* @dev Currently no fee is being taken for this action
*/
function cancelMarketCloseForPosition(
bytes32 _positionId,
CloseOrderType _orderType,
uint // feeFraction
) external override onlyTradersPortalOrTriggers {
cancelMarketCloseForPositionInternal(msg.sender, _positionId, _orderType);
}
/**
* Handles the cancellation of a "market close" order
*/
function cancelMarketCloseForPositionInternal(
address source,
bytes32 _positionId,
CloseOrderType _orderType
) internal {
require(positionsById[_positionId].collateral > 0, "NO_SUCH_POSITION");
delete triggerPricesById[_positionId];
if (_orderType == CloseOrderType.MARKET) {
require(
positionsById[_positionId].phase == PositionPhase.CLOSE_MARKET,
"WRONG_PHASE"
);
} else {
revert("WRONG_ORDER_TYPE");
}
positionsById[_positionId].phase = PositionPhase.OPENED;
positionsById[_positionId].inPhaseSince = uint64(block.timestamp);
emit PositionMarketCloseCancelled(_positionId, source, 0);
}
// ***** Fees Manager Interaction *****
/**
* Sends all fee accrued in the SA+feeType to the '_to' address
* @dev Allows a dynamic and flexible way to direct fees.
*/
function collectFee(address _asset, FeeType _feeType, address _to) external {
require(
msg.sender == IRegistryV1(registry).feesManagers(_asset),
"!FeesManager"
);
collectFeeInternal(_asset, _feeType, _to);
}
// ***** Internal Position Open/Close logic *****
/**
* Stores the identifying values of the position.
* @dev Saves gas after the first time a SA-trader-pair-index position was registered in this contract
* @return positionId The position id that matched these identifiers
*/
function storeIdentifiersIfNeeded(
address settlementAsset,
address trader,
uint16 pairId
) internal returns (bytes32 positionId, uint32 index) {
index = getNextPositionIndexForTrader(trader);
positionId = generatePositionHashId(settlementAsset, trader, pairId, index);
PositionIdentifiers storage identifiers = positionIdentifiersById[
positionId
];
// Store the identifier once
if (identifiers.index == 0) {
identifiers.settlementAsset = settlementAsset;
identifiers.trader = trader;
identifiers.pairId = pairId;
identifiers.index = index;
// Update lastUsedPositionIndex
pairTradersLastUsedPositionIndex[trader] = index;
// Add to active position IDs tracking
addToActivePositionIds(trader, positionId);
emit PositionIdentifiersStored(positionId, identifiers);
}
}
/**
* Handles verifications and logic for the opening of a new position.
* @dev This function will "swallow" the "CapError" custom error that can be thrown by the 'PoolAccountant' contract
* and in such case will proceed to cancel the open order.
*/
function openNewTradeInternal(
bytes32 _positionId,
PositionPhase _expectedPhase,
uint64 assetEffectivePrice,
uint256 feeForCancellation
) internal {
PositionTriggerPrices memory triggerPrices = triggerPricesById[_positionId];
Position memory _position = positionsById[_positionId];
require(_position.collateral > 0, "NO_SUCH_POSITION");
PositionIdentifiers memory identifiers = positionIdentifiersById[
_positionId
];
require(!pausedPairs[identifiers.pairId], "PAIR_PAUSED");
require(_position.phase == _expectedPhase, "WRONG_PHASE");
if (_expectedPhase == PositionPhase.OPEN_MARKET) {
if (
triggerPrices.minPrice > assetEffectivePrice ||
triggerPrices.maxPrice < assetEffectivePrice
) {
emit PositionOpenCancelledByMarketPriceRange(
_positionId,
assetEffectivePrice
);
settleCanceledOpenOrderInternal(
_positionId,
identifiers.settlementAsset,
identifiers.trader,
_position.collateral,
_position.leverage,
feeForCancellation,
address(this)
);
return;
}
} else if (_expectedPhase == PositionPhase.OPEN_LIMIT) {
// Limit Orders cannot be triggered if the price is wrong
require(
triggerPrices.minPrice <= assetEffectivePrice &&
triggerPrices.maxPrice >= assetEffectivePrice,
"PRICE_RANGE"
);
} else {
revert("UNSUPPORTED");
}
address poolAccountant = poolAccountantForAsset[
identifiers.settlementAsset
];
PositionLimitsInfo
memory positionLimits = storeCorrectLimitsForOpenedPosition(
_positionId,
poolAccountant,
_position.leverage,
_position.long,
assetEffectivePrice,
triggerPrices
);
try
IPoolAccountantFunctionality(poolAccountant).registerOpenTrade(
_positionId,
identifiers.trader,
identifiers.pairId,
_position.collateral,
_position.leverage,
_position.long,
positionLimits.tp,
assetEffectivePrice
)
returns (uint openFeePart, uint lexFeePart) {
Position storage _positionStorage = positionsById[_positionId];
_positionStorage.openPrice = assetEffectivePrice;
// Store the position's initial collateral
initialCollateralByPositionId[_positionId] = _position.collateral;
// Note : Subtracting the open fee before storing the position
_positionStorage.collateral = _position.collateral - openFeePart;
// Mark the position as opened
_positionStorage.phase = PositionPhase.OPENED;
_positionStorage.inPhaseSince = uint64(block.timestamp);
registerFeeInternal(
_positionId,
identifiers.settlementAsset,
FeeType.OPEN_FEE,
openFeePart - lexFeePart
);
sendSettlement(
identifiers.settlementAsset,
lexPoolForAsset[identifiers.settlementAsset],
lexFeePart
);
delete triggerPricesById[_positionId];
emit PositionOpened(
_positionId,
assetEffectivePrice,
positionLimits.tp,
positionLimits.sl,
openFeePart,
lexFeePart
);
} catch Error(string memory error) {
revert(error);
} catch (bytes memory err) {
if (bytes4(err) == LexErrors.CapError.selector) {
LexErrors.CapType capType;
uint256 value;
assembly {
capType := mload(add(err, 0x24))
value := mload(add(err, 0x44))
}
emit PositionOpenCancelledByCap(_positionId, capType, value);
settleCanceledOpenOrderInternal(
_positionId,
identifiers.settlementAsset,
identifiers.trader,
_position.collateral,
_position.leverage,
feeForCancellation,
address(this)
);
} else {
revert();
}
}
}
/**
* Stores the limits values of a newly opened position (after correcting them to the valid ranges if needed)
*/
function storeCorrectLimitsForOpenedPosition(
bytes32 positionId,
address poolAccountant,
uint32 leverage,
bool isLong,
uint64 assetEffectivePrice,
PositionTriggerPrices memory triggerPrices
) internal returns (PositionLimitsInfo memory positionLimits) {
uint maxGainF = IPoolAccountantV1(poolAccountant).maxGainF();
positionLimits = positionLimitsInfoById[positionId];
require(
positionLimits.tp == 0 || triggerPrices.tpByFraction == 0,
"MULTIPLE_TP_DEFINITIONS"
);
require(
positionLimits.sl == 0 || triggerPrices.slByFraction == 0,
"MULTIPLE_SL_DEFINITIONS"
);
if (triggerPrices.tpByFraction > 0) {
uint64 priceDiff = calculatePriceDiffFromFractionAndLeverage(
assetEffectivePrice,
triggerPrices.tpByFraction,
leverage
);
positionLimits.tp = isLong
? assetEffectivePrice + priceDiff
: priceDiff < assetEffectivePrice
? assetEffectivePrice - priceDiff
: 0;
}
if (triggerPrices.slByFraction > 0) {
uint64 priceDiff = calculatePriceDiffFromFractionAndLeverage(
assetEffectivePrice,
triggerPrices.slByFraction,
leverage
);
positionLimits.sl = isLong
? priceDiff < assetEffectivePrice
? assetEffectivePrice - priceDiff
: 0
: assetEffectivePrice + priceDiff;
}
positionLimits.tp = correctTp(
uint64(maxGainF),
assetEffectivePrice,
leverage,
positionLimits.tp,
isLong
);
positionLimits.tpLastUpdated = uint64(block.timestamp);
positionLimits.sl = correctSl(
uint64(maxGainF),
assetEffectivePrice,
leverage,
positionLimits.sl,
isLong
);
positionLimits.slLastUpdated = uint64(block.timestamp);
// Store
positionLimitsInfoById[positionId] = positionLimits;
}
/**
* Handles the all closing types of an existing opened position.
*/
function closeExistingTradeInternal(
bytes32 _positionId,
uint effectivePrice,
PositionCloseType positionCloseType
)
internal
returns (uint tradeValue, int profitPrecision, uint finalClosingPrice)
{
PositionIdentifiers memory identifiers = positionIdentifiersById[
_positionId
];
PoolAccountantStructs.PositionRegistrationParams
memory positionRegistrationParams = getPositionRegistrationParams(
_positionId
);
require(positionRegistrationParams.collateral > 0, "NO_SUCH_POSITION");
// Note : 'tradeValue' is the value after subtracting the 'closeFeePart'
(
uint closeFeePart,
uint _tradeValue,
int _profitPrecision,
uint _finalClosePrice
) = registerTradeCloseInLexInternal(
_positionId,
identifiers,
positionRegistrationParams,
effectivePrice,
positionCloseType
);
if (_tradeValue > positionRegistrationParams.collateral) {
uint totalProfitF = ((_tradeValue -
positionRegistrationParams.collateral) * FRACTION_SCALE) /
positionRegistrationParams.collateral;
require(totalProfitF <= maxSanityProfitF, "INVALID_PROFIT");
}
profitPrecision = _profitPrecision;
tradeValue = _tradeValue;
finalClosingPrice = _finalClosePrice;
// sanity
require(
closeFeePart <= positionRegistrationParams.collateral,
"CLOSE_FEE_LARGER_THAN_POSITION"
);
registerFeeInternal(
_positionId,
identifiers.settlementAsset,
FeeType.CLOSE_FEE,
closeFeePart
);
// Decrease/Remove from the traders
decreaseOrRemoveFromTradersLists(identifiers.trader);
// Remove from active position IDs tracking
removeFromActivePositionIds(identifiers.trader, _positionId);
// Delete the position
delete positionsById[_positionId];
delete positionLimitsInfoById[_positionId];
delete initialCollateralByPositionId[_positionId];
// Settle the position
settleTradeCloseInternal(
identifiers.trader,
identifiers.settlementAsset,
tradeValue,
positionRegistrationParams.collateral,
closeFeePart
);
}
// **** LeX-Center Interaction ****
/**
* Utility function to inform the "PoolAccountant" that a position is being closed and retrieve it's closing values.
* @dev Using a separate function to bypass the "stack too depp" issue.
*/
function registerTradeCloseInLexInternal(
bytes32 _positionId,
PositionIdentifiers memory _identifiers,
PoolAccountantStructs.PositionRegistrationParams
memory positionRegistrationParams,
uint closePrice,
PositionCloseType positionCloseType
)
internal
returns (
uint closeFeePart,
uint tradeValue,
int profitPrecision,
uint finalClosePrice
)
{
return
IPoolAccountantFunctionality(
poolAccountantForAsset[_identifiers.settlementAsset]
).registerCloseTrade(
_positionId,
_identifiers.trader,
_identifiers.pairId,
positionRegistrationParams,
closePrice,
positionCloseType
);
}
// **** Trade Closing Settlement ****
/**
* Handles the logic for cancellation of a position in any "pending open" for any reason (trader request/timeout/cap error etc...)
*/
function settleCanceledOpenOrderInternal(
bytes32 positionId,
address settlementAsset,
address trader,
uint collateral,
uint32 leverage,
uint feeF,
address canceller
) internal {
delete positionsById[positionId];
delete triggerPricesById[positionId];
uint cancellationFee = calculateFractionInternal(
calculateLeveragedPosition(collateral, leverage),
feeF
);
registerFeeInternal(
positionId,
settlementAsset,
FeeType.TRIGGER_FEE,
cancellationFee
);
// Decrease/Remove from the pair traders
decreaseOrRemoveFromTradersLists(trader);
// Remove from active position IDs tracking
removeFromActivePositionIds(trader, positionId);
uint collateralLeft = collateral - cancellationFee;
sendSettlement(settlementAsset, trader, collateralLeft);
emit PendingPositionCancelled(positionId, canceller, cancellationFee);
}
/**
* Handles the asset transferring of a closing position.
*/
function settleTradeCloseInternal(
address trader,
address settlementAsset,
uint tradeValue,
uint tradeCollateral,
uint closingFee
) internal {
ILexPoolV1 lexToken = ILexPoolV1(lexPoolForAsset[settlementAsset]);
uint assetForTraderFromFloor;
// Trade gain
if (tradeValue >= tradeCollateral) {
// Note : The closing fee stays in the TradingFloor
assetForTraderFromFloor = tradeCollateral - closingFee;
uint assetForTraderFromPool = tradeValue - assetForTraderFromFloor;
lexToken.sendAssetToTrader(trader, assetForTraderFromPool);
}
// Trade loss
else {
assetForTraderFromFloor = tradeValue;
uint diff = tradeCollateral - tradeValue;
if (diff > closingFee) {
// Send to the lex
sendSettlement(settlementAsset, address(lexToken), diff - closingFee);
} else {
// Take the missing amount for the 'closingFee' from the lex
lexToken.sendAssetToTrader(address(this), closingFee - diff);
}
}
sendSettlement(settlementAsset, trader, assetForTraderFromFloor);
}
// ***** Internal Fees *****
/**
* Sends all fees collected in for the SA+FeeType and zeros the counter
*/
function collectFeeInternal(
address _asset,
FeeType _feeType,
address _to
) internal {
uint amount = feesMap[_asset][_feeType];
feesMap[_asset][_feeType] = 0;
IERC20(_asset).safeTransfer(_to, amount);
emit FeeCollected(_asset, _feeType, _to, amount);
}
/**
* Adds '_amount' to the SA+FeeType counter
*/
function registerFeeInternal(
bytes32 _positionId,
address _token,
FeeType _feeType,
uint _amount
) internal {
if (_amount > 0) {
feesMap[_token][_feeType] += _amount;
emit FeeRegistered(_positionId, _token, _feeType, _amount);
}
}
// ***** Internal Tokens Utils *****
/**
* Utility function to safely take an ERC20 settlement asset from a pre-approved account
*/
function takeSettlement(
address settlementAsset,
address from,
uint amount
) internal {
if (amount > 0) {
uint balanceBefore = IERC20(settlementAsset).balanceOf(address(this));
IERC20(settlementAsset).safeTransferFrom(from, address(this), amount);
uint balanceAfter = IERC20(settlementAsset).balanceOf(address(this));
require(balanceAfter - balanceBefore == amount, "DID_NOT_RECEIVE_EXACT");
}
}
/**
* Utility function to safely send an ERC20 settlement asset to an account
*/
function sendSettlement(
address settlementAsset,
address to,
uint amount
) internal {
if (amount > 0) {
IERC20(settlementAsset).safeTransfer(to, amount);
}
}
// ***** Internal State Utils *****
/**
* @notice Adds a trader to the global traders array if this is their first position
* @dev Part of v1.01 global tracking. Called AFTER position is added to activePositionIdsByTrader.
* Uses 1-based indexing in tradersIndex mapping (0 = not in array).
* This replaces the old per-pair trader tracking system.
* @param trader The trader address to potentially add to the global array
*/
function increaseOrAddToTradersLists(address trader) internal {
// Check if this is the first position for this trader across ALL pairs
// Note: Position has already been added to activePositionIdsByTrader when this is called
if (activePositionIdsByTrader[trader].length == 1) {
// Add trader to global array
traders.push(trader);
// Store 1-based index (array position + 1)
tradersIndex[trader] = traders.length;
}
// If not first position, trader is already in the array
}
/**
* @notice Removes a trader from the global array if this is their last position
* @dev Part of v1.01 global tracking. Called BEFORE position is removed from activePositionIdsByTrader.
* Uses swap-and-pop pattern for O(1) removal:
* 1. Move last trader to the removed trader's position
* 2. Update the moved trader's index
* 3. Delete the removed trader's index
* 4. Pop the last element
* @param trader The trader address to potentially remove from the global array
*/
function decreaseOrRemoveFromTradersLists(address trader) internal {
// Check if this is the last position for this trader across ALL pairs
// Note: Position has NOT been removed from activePositionIdsByTrader yet
if (activePositionIdsByTrader[trader].length == 1) {
// Use swap-and-pop pattern for O(1) removal
if (traders.length > 1) {
uint256 _traderIndex = tradersIndex[trader];
// Move last trader to the removed trader's position (convert 1-based to 0-based)
traders[_traderIndex - 1] = traders[traders.length - 1];
// Update the moved trader's index to the new position
tradersIndex[traders[_traderIndex - 1]] = _traderIndex;
}
// Clear the removed trader's index (set to 0 = not in array)
delete tradersIndex[trader];
// Remove the last element
traders.pop();
}
// If not the last position, keep trader in the global array
}
/**
* @notice Adds a position ID to the trader's active positions array
* @dev Part of v1.01 global tracking. Maintains a dynamic array of all active
* positions for each trader across all pairs. Uses 1-based indexing in
* the mapping for efficient existence checks (0 = not in array).
* @param trader The trader who owns the position
* @param positionId The position ID to add to the trader's active list
*/
function addToActivePositionIds(address trader, bytes32 positionId) internal {
bytes32[] storage activeIds = activePositionIdsByTrader[trader];
activeIds.push(positionId);
// Store as 1-based index (array position + 1) for O(1) lookups
// 0 = not in array, 1 = at array[0], 2 = at array[1], etc.
positionIdToActivePositionIndex[trader][positionId] = activeIds.length;
}
/**
* @notice Removes a position ID from the trader's active positions array
* @dev Part of v1.01 global tracking. Uses swap-and-pop pattern for O(1) removal:
* 1. Get the position's index from the mapping
* 2. Move the last position ID to this index
* 3. Update the moved position's index in the mapping
* 4. Delete the removed position's index
* 5. Pop the last element
* @param trader The trader who owns the position
* @param positionId The position ID to remove from the trader's active list
*/
function removeFromActivePositionIds(
address trader,
bytes32 positionId
) internal {
uint256 storedArrayIndex = positionIdToActivePositionIndex[trader][
positionId
];
// Only process if the position is in the array (storedArrayIndex > 0)
if (storedArrayIndex > 0) {
bytes32[] storage activeIds = activePositionIdsByTrader[trader];
// Convert from 1-based to 0-based for array access
uint256 arrayIndex = storedArrayIndex - 1;
// If not the last element, swap with last
if (arrayIndex < activeIds.length - 1) {
bytes32 lastPositionId = activeIds[activeIds.length - 1];
activeIds[arrayIndex] = lastPositionId;
// Update the moved element's array index mapping (store as 1-based)
positionIdToActivePositionIndex[trader][
lastPositionId
] = storedArrayIndex;
}
// Remove last element
activeIds.pop();
// Clean up the mapping
delete positionIdToActivePositionIndex[trader][positionId];
}
}
// ***** Internal Calculation Utils *****
/**
* Utility function to calculate a 'FRACTION_SCALE' value of a given amount
* @return The fraction value out of the given amount
*/
function calculateFractionInternal(
uint amount,
uint feeFraction
) internal pure returns (uint) {
return (amount * feeFraction) / FRACTION_SCALE;
}
// Trade validity functions
/**
* Runs some sanity requires to ensure the position values are in the right range
*/
function requireValidOpenTradeParameters(
bool isLong,
uint minPrice,
uint maxPrice,
uint tp,
uint sl
) internal pure {
require(minPrice <= maxPrice, "MIN_MAX_REVERSE");
require(tp == 0 || (isLong ? tp > maxPrice : tp < minPrice), "WRONG_TP");
require(sl == 0 || (isLong ? sl < minPrice : sl > maxPrice), "WRONG_SL");
}
/**
* Receives the wanted sl for a position (with other relevant params) and makes sure the value is within the expected range
* @notice In case of TP == 0 or a breach of max value, the value returned will be the max allowed value
* (can be capped by 0 in case of a SHORT position)
*/
function correctTp(
uint64 maxGainF,
uint64 openPrice,
uint64 leverage, // scaled up from 32
uint64 tp,
bool buy
) internal pure returns (uint64) {
if (
tp == 0 ||
currentProfitFraction(maxGainF, openPrice, tp, buy, leverage) >=
int64(maxGainF)
) {
uint64 tpDiff = uint64(
((uint256(openPrice) * uint256(maxGainF)) * LEVERAGE_SCALE) /
uint256(leverage) /
FRACTION_SCALE
);
return
buy
? openPrice + tpDiff
: tpDiff <= openPrice
? openPrice - tpDiff
: 0;
}
return tp;
}
/**
* Receives the wanted sl for a position (with other relevant params) and makes sure the value is within the expected range
* @notice In case of SL == 0 or a breach of max value, the value returned will be the max allowed value
* (can be capped by 0 in case of a LONG position)
*/
function correctSl(
uint64 maxGainF,
uint64 openPrice,
uint64 leverage, // scaled up from 32
uint64 sl,
bool buy
) internal view returns (uint64) {
if (
sl == 0 ||
currentProfitFraction(maxGainF, openPrice, sl, buy, leverage) <=
int(maxSlF) * -1
) {
uint64 slDiff = uint64(
(uint256(openPrice) * maxSlF * LEVERAGE_SCALE) /
uint256(leverage) /
FRACTION_SCALE
);
return
buy
? slDiff <= openPrice
? openPrice - slDiff
: 0
: openPrice + slDiff;
}
return sl;
}
/**
* Calculates the (positive or negative) profit fraction by given position values
* @return f The profit fraction, with scale of FRACTION_SCALE
*/
function currentProfitFraction(
uint64 maxGainF,
uint64 openPrice,
uint64 currentPrice,
bool buy,
uint64 leverage // scaled from 32
) internal pure returns (int64 f) {
int64 maxPnlF = int64(maxGainF);
int64 priceDiff = buy
? int64(currentPrice) - int64(openPrice)
: int64(openPrice) - int64(currentPrice);
int256 nominator = int256(priceDiff) *
int256(FRACTION_SCALE) *
int256(int64(leverage));
int256 longF = nominator /
int256(LEVERAGE_SCALE) /
int256(int64(openPrice));
f = int64(longF);
f = f > maxPnlF ? maxPnlF : f;
}
function calculatePriceDiffFromFractionAndLeverage(
uint64 originPrice,
uint64 fractionDiff,
uint64 leverage
) internal pure returns (uint64) {
uint64 diffInPrice = uint64(
(uint256(originPrice) * uint256(fractionDiff) * LEVERAGE_SCALE) /
FRACTION_SCALE /
uint256(leverage)
);
return diffInPrice;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/IERC20Permit.sol)
pragma solidity ^0.8.20;
/**
* @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
* https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
*
* Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
* presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't
* need to send a transaction, and thus is not required to hold Ether at all.
*
* ==== Security Considerations
*
* There are two important considerations concerning the use of `permit`. The first is that a valid permit signature
* expresses an allowance, and it should not be assumed to convey additional meaning. In particular, it should not be
* considered as an intention to spend the allowance in any specific way. The second is that because permits have
* built-in replay protection and can be submitted by anyone, they can be frontrun. A protocol that uses permits should
* take this into consideration and allow a `permit` call to fail. Combining these two aspects, a pattern that may be
* generally recommended is:
*
* ```solidity
* function doThingWithPermit(..., uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public {
* try token.permit(msg.sender, address(this), value, deadline, v, r, s) {} catch {}
* doThing(..., value);
* }
*
* function doThing(..., uint256 value) public {
* token.safeTransferFrom(msg.sender, address(this), value);
* ...
* }
* ```
*
* Observe that: 1) `msg.sender` is used as the owner, leaving no ambiguity as to the signer intent, and 2) the use of
* `try/catch` allows the permit to fail and makes the code tolerant to frontrunning. (See also
* {SafeERC20-safeTransferFrom}).
*
* Additionally, note that smart contract wallets (such as Argent or Safe) are not able to produce permit signatures, so
* contracts should have entry points that don't rely on permit.
*/
interface IERC20Permit {
/**
* @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,
* given ``owner``'s signed approval.
*
* IMPORTANT: The same issues {IERC20-approve} has related to transaction
* ordering also apply here.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `deadline` must be a timestamp in the future.
* - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`
* over the EIP712-formatted function arguments.
* - the signature must use ``owner``'s current nonce (see {nonces}).
*
* For more information on the signature format, see the
* https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP
* section].
*
* CAUTION: See Security Considerations above.
*/
function permit(
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) external;
/**
* @dev Returns the current nonce for `owner`. This value must be
* included whenever a signature is generated for {permit}.
*
* Every successful call to {permit} increases ``owner``'s nonce by one. This
* prevents a signature from being used multiple times.
*/
function nonces(address owner) external view returns (uint256);
/**
* @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.
*/
// solhint-disable-next-line func-name-mixedcase
function DOMAIN_SEPARATOR() external view returns (bytes32);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.20;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
/**
* @dev Returns the value of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the value of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves a `value` amount of tokens from the caller's account to `to`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address to, uint256 value) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets a `value` amount of tokens as the allowance of `spender` over the
* caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 value) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from `from` to `to` using the
* allowance mechanism. `value` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address from, address to, uint256 value) external returns (bool);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/utils/SafeERC20.sol)
pragma solidity ^0.8.20;
import {IERC20} from "../IERC20.sol";
import {IERC20Permit} from "../extensions/IERC20Permit.sol";
import {Address} from "../../../utils/Address.sol";
/**
* @title SafeERC20
* @dev Wrappers around ERC20 operations that throw on failure (when the token
* contract returns false). Tokens that return no value (and instead revert or
* throw on failure) are also supported, non-reverting calls are assumed to be
* successful.
* To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
* which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
*/
library SafeERC20 {
using Address for address;
/**
* @dev An operation with an ERC20 token failed.
*/
error SafeERC20FailedOperation(address token);
/**
* @dev Indicates a failed `decreaseAllowance` request.
*/
error SafeERC20FailedDecreaseAllowance(address spender, uint256 currentAllowance, uint256 requestedDecrease);
/**
* @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*/
function safeTransfer(IERC20 token, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeCall(token.transfer, (to, value)));
}
/**
* @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the
* calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.
*/
function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeCall(token.transferFrom, (from, to, value)));
}
/**
* @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*/
function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
uint256 oldAllowance = token.allowance(address(this), spender);
forceApprove(token, spender, oldAllowance + value);
}
/**
* @dev Decrease the calling contract's allowance toward `spender` by `requestedDecrease`. If `token` returns no
* value, non-reverting calls are assumed to be successful.
*/
function safeDecreaseAllowance(IERC20 token, address spender, uint256 requestedDecrease) internal {
unchecked {
uint256 currentAllowance = token.allowance(address(this), spender);
if (currentAllowance < requestedDecrease) {
revert SafeERC20FailedDecreaseAllowance(spender, currentAllowance, requestedDecrease);
}
forceApprove(token, spender, currentAllowance - requestedDecrease);
}
}
/**
* @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval
* to be set to zero before setting it to a non-zero value, such as USDT.
*/
function forceApprove(IERC20 token, address spender, uint256 value) internal {
bytes memory approvalCall = abi.encodeCall(token.approve, (spender, value));
if (!_callOptionalReturnBool(token, approvalCall)) {
_callOptionalReturn(token, abi.encodeCall(token.approve, (spender, 0)));
_callOptionalReturn(token, approvalCall);
}
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*/
function _callOptionalReturn(IERC20 token, bytes memory data) private {
// We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
// we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that
// the target address contains contract code and also asserts for success in the low-level call.
bytes memory returndata = address(token).functionCall(data);
if (returndata.length != 0 && !abi.decode(returndata, (bool))) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*
* This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead.
*/
function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {
// We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
// we're implementing it ourselves. We cannot use {Address-functionCall} here since this should return false
// and not revert is the subcall reverts.
(bool success, bytes memory returndata) = address(token).call(data);
return success && (returndata.length == 0 || abi.decode(returndata, (bool))) && address(token).code.length > 0;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/Address.sol)
pragma solidity ^0.8.20;
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev The ETH balance of the account is not enough to perform the operation.
*/
error AddressInsufficientBalance(address account);
/**
* @dev There's no code at `target` (it is not a contract).
*/
error AddressEmptyCode(address target);
/**
* @dev A call to an address target failed. The target may have reverted.
*/
error FailedInnerCall();
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
if (address(this).balance < amount) {
revert AddressInsufficientBalance(address(this));
}
(bool success, ) = recipient.call{value: amount}("");
if (!success) {
revert FailedInnerCall();
}
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason or custom error, it is bubbled
* up by this function (like regular Solidity function calls). However, if
* the call reverted with no returned reason, this function reverts with a
* {FailedInnerCall} error.
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
if (address(this).balance < value) {
revert AddressInsufficientBalance(address(this));
}
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResultFromTarget(target, success, returndata);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResultFromTarget(target, success, returndata);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResultFromTarget(target, success, returndata);
}
/**
* @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target
* was not a contract or bubbling up the revert reason (falling back to {FailedInnerCall}) in case of an
* unsuccessful call.
*/
function verifyCallResultFromTarget(
address target,
bool success,
bytes memory returndata
) internal view returns (bytes memory) {
if (!success) {
_revert(returndata);
} else {
// only check if target is a contract if the call was successful and the return data is empty
// otherwise we already know that it was a contract
if (returndata.length == 0 && target.code.length == 0) {
revert AddressEmptyCode(target);
}
return returndata;
}
}
/**
* @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the
* revert reason or with a default {FailedInnerCall} error.
*/
function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) {
if (!success) {
_revert(returndata);
} else {
return returndata;
}
}
/**
* @dev Reverts with returndata if present. Otherwise reverts with {FailedInnerCall}.
*/
function _revert(bytes memory returndata) private pure {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
/// @solidity memory-safe-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert FailedInnerCall();
}
}
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.24;
import "./AcceptableImplementationClaimableAdminStorage.sol";
/**
* @title SafeUpgradeableClaimableAdmin
* @dev based on Compound's Unitroller
* https://github.com/compound-finance/compound-protocol/blob/a3214f67b73310d547e00fc578e8355911c9d376/contracts/Unitroller.sol
*/
contract AcceptableImplementationClaimableAdmin is
AcceptableImplementationClaimableAdminStorage
{
/**
* @notice Emitted when pendingImplementation is changed
*/
event NewPendingImplementation(
address oldPendingImplementation,
address newPendingImplementation
);
/**
* @notice Emitted when pendingImplementation is accepted, which means delegation implementation is updated
*/
event NewImplementation(address oldImplementation, address newImplementation);
/**
* @notice Emitted when pendingAdmin is changed
*/
event NewPendingAdmin(address oldPendingAdmin, address newPendingAdmin);
/**
* @notice Emitted when pendingAdmin is accepted, which means admin is updated
*/
event NewAdmin(address oldAdmin, address newAdmin);
/*** Admin Functions ***/
function _setPendingImplementation(address newPendingImplementation) public {
require(msg.sender == admin, "not admin");
require(
approvePendingImplementationInternal(newPendingImplementation),
"INVALID_IMPLEMENTATION"
);
address oldPendingImplementation = pendingImplementation;
pendingImplementation = newPendingImplementation;
emit NewPendingImplementation(
oldPendingImplementation,
pendingImplementation
);
}
/**
* @notice Accepts new implementation. msg.sender must be pendingImplementation
* @dev Admin function for new implementation to accept it's role as implementation
*/
function _acceptImplementation() public returns (uint) {
// Check caller is pendingImplementation and pendingImplementation ≠ address(0)
require(
msg.sender == pendingImplementation &&
pendingImplementation != address(0),
"Not the EXISTING pending implementation"
);
// Save current values for inclusion in log
address oldImplementation = implementation;
address oldPendingImplementation = pendingImplementation;
implementation = pendingImplementation;
pendingImplementation = address(0);
emit NewImplementation(oldImplementation, implementation);
emit NewPendingImplementation(
oldPendingImplementation,
pendingImplementation
);
return 0;
}
/**
* @notice Begins transfer of admin rights. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer.
* @dev Admin function to begin change of admin. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer.
* @param newPendingAdmin New pending admin.
*/
function _setPendingAdmin(address newPendingAdmin) public {
// Check caller = admin
require(msg.sender == admin, "Not Admin");
// Save current value, if any, for inclusion in log
address oldPendingAdmin = pendingAdmin;
// Store pendingAdmin with value newPendingAdmin
pendingAdmin = newPendingAdmin;
// Emit NewPendingAdmin(oldPendingAdmin, newPendingAdmin)
emit NewPendingAdmin(oldPendingAdmin, newPendingAdmin);
}
/**
* @notice Accepts transfer of admin rights. msg.sender must be pendingAdmin
* @dev Admin function for pending admin to accept role and update admin
*/
function _acceptAdmin() public {
// Check caller is pendingAdmin and pendingAdmin ≠ address(0)
require(
msg.sender == pendingAdmin && pendingAdmin != address(0),
"Not the EXISTING pending admin"
);
// Save current values for inclusion in log
address oldAdmin = admin;
address oldPendingAdmin = pendingAdmin;
// Store admin with value pendingAdmin
admin = pendingAdmin;
// Clear the pending value
pendingAdmin = address(0);
emit NewAdmin(oldAdmin, admin);
emit NewPendingAdmin(oldPendingAdmin, pendingAdmin);
}
constructor(address _initialAdmin) {
admin = _initialAdmin;
emit NewAdmin(address(0), _initialAdmin);
}
/**
* @dev Delegates execution to an implementation contract.
* It returns to the external caller whatever the implementation returns
* or forwards reverts.
*/
fallback() external payable {
// delegate all other functions to current implementation
(bool success, ) = implementation.delegatecall(msg.data);
assembly {
let free_mem_ptr := mload(0x40)
returndatacopy(free_mem_ptr, 0, returndatasize())
switch success
case 0 {
revert(free_mem_ptr, returndatasize())
}
default {
return(free_mem_ptr, returndatasize())
}
}
}
receive() external payable {}
function approvePendingImplementationInternal(
address // _implementation
) internal virtual returns (bool) {
return true;
}
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.24;
contract ClaimableAdminStorage {
/**
* @notice Administrator for this contract
*/
address public admin;
/**
* @notice Pending administrator for this contract
*/
address public pendingAdmin;
/*** Modifiers ***/
modifier onlyAdmin() {
require(msg.sender == admin, "ONLY_ADMIN");
_;
}
/*** Constructor ***/
constructor() {
// Set admin to caller
admin = msg.sender;
}
}
contract AcceptableImplementationClaimableAdminStorage is
ClaimableAdminStorage
{
/**
* @notice Active logic
*/
address public implementation;
/**
* @notice Pending logic
*/
address public pendingImplementation;
}
contract AcceptableRegistryImplementationClaimableAdminStorage is
AcceptableImplementationClaimableAdminStorage
{
/**
* @notice System Registry
*/
address public registry;
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.24;
import "./AcceptableImplementationClaimableAdmin.sol";
import "./IContractRegistryBase.sol";
/**
* @title AcceptableRegistryImplementationClaimableAdmin
*/
contract AcceptableRegistryImplementationClaimableAdmin is
AcceptableImplementationClaimableAdmin,
AcceptableRegistryImplementationClaimableAdminStorage
{
bytes32 public immutable CONTRACT_NAME_HASH;
constructor(
address _registry,
string memory proxyName,
address _initialAdmin
) AcceptableImplementationClaimableAdmin(_initialAdmin) {
registry = _registry;
CONTRACT_NAME_HASH = keccak256(abi.encodePacked(proxyName));
}
function approvePendingImplementationInternal(
address _implementation
) internal view override returns (bool) {
return
IContractRegistryBase(registry).isImplementationValidForProxy(
CONTRACT_NAME_HASH,
_implementation
);
}
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.24;
interface IContractRegistryBase {
function isImplementationValidForProxy(
bytes32 proxyNameHash,
address _implementation
) external view returns (bool);
}// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.24;
/**
* @dev only use immutables and constants in this contract
*/
contract CommonScales {
uint256 public constant PRECISION = 1e18; // 18 decimals
uint256 public constant LEVERAGE_SCALE = 100; // 2 decimal points
uint256 public constant FRACTION_SCALE = 100000; // 5 decimal points
uint256 public constant ACCURACY_IMPROVEMENT_SCALE = 1e9;
function calculateLeveragedPosition(
uint256 collateral,
uint256 leverage
) internal pure returns (uint256) {
return (collateral * leverage) / LEVERAGE_SCALE;
}
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.24;
interface IFundingRateModel {
// return value is the "funding paid by heavier side" in PRECISION per OI (heavier side) per second
// e.g : (0.01 * PRECISION) = Paying (heavier) side (as a whole) pays 1% of funding per second for each OI unit
function getFundingRate(
uint256 pairId,
uint256 openInterestLong,
uint256 openInterestShort,
uint256 pairMaxOpenInterest
) external view returns (uint256);
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.24;
interface IGlobalLock {
function lock() external;
function freeLock() external;
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.24;
interface IInterestRateModel {
// Returns asset/second of interest per borrowed unit
// e.g : (0.01 * PRECISION) = 1% of interest per second
function getBorrowRate(uint256 utilization) external view returns (uint256);
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.24;
import "./LexErrors.sol";
import "./LexPoolAdminEnums.sol";
import "./IPoolAccountantV1.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
interface LexPoolStructs {
struct PendingDeposit {
uint256 amount;
uint256 minAmountOut;
}
struct PendingRedeem {
uint256 amount;
uint256 minAmountOut;
uint256 maxAmountOut;
}
}
interface LexPoolEvents is LexPoolAdminEnums {
event NewEpoch(
uint256 epochId,
int256 reportedUnrealizedPricePnL,
uint256 exchangeRate,
uint256 virtualUnderlyingBalance,
uint256 totalSupply
);
event AddressUpdated(LexPoolAddressesEnum indexed enumCode, address a);
event NumberUpdated(LexPoolNumbersEnum indexed enumCode, uint value);
event DepositRequest(
address indexed user,
uint256 amount,
uint256 minAmountOut,
uint256 processingEpoch
);
event RedeemRequest(
address indexed user,
uint256 amount,
uint256 minAmountOut,
uint256 processingEpoch
);
event ProcessedDeposit(
address indexed user,
bool deposited,
uint256 depositedAmount
);
event ProcessedRedeem(
address indexed user,
bool redeemed,
uint256 withdrawnAmount // Underlying amount
);
event CanceledDeposit(
address indexed user,
uint256 epoch,
uint256 cancelledAmount
);
event CanceledRedeem(
address indexed user,
uint256 epoch,
uint256 cancelledAmount
);
event ImmediateDepositAllowedToggled(bool indexed value);
event ImmediateDeposit(
address indexed depositor,
uint256 depositAmount,
uint256 mintAmount
);
event ReservesWithdrawn(
address _to,
uint256 interestShare,
uint256 totalFundingShare
);
}
interface ILexPoolFunctionality is
IERC20,
LexPoolStructs,
LexPoolEvents,
LexErrors
{
function setPoolAccountant(
IPoolAccountantFunctionality _poolAccountant
) external;
function setPnlRole(address pnl) external;
function setMaxExtraWithdrawalAmountF(uint256 maxExtra) external;
function setEpochsDelayDeposit(uint256 delay) external;
function setEpochsDelayRedeem(uint256 delay) external;
function setEpochDuration(uint256 duration) external;
function setMinDepositAmount(uint256 amount) external;
function toggleImmediateDepositAllowed() external;
function reduceReserves(
address _to
) external returns (uint256 interestShare, uint256 totalFundingShare);
function requestDeposit(
uint256 amount,
uint256 minAmountOut,
bytes32 domain,
bytes32 referralCode
) external;
function requestDepositViaIntent(
address user,
uint256 amount,
uint256 minAmountOut,
bytes32 domain,
bytes32 referralCode
) external;
function requestRedeem(uint256 amount, uint256 minAmountOut) external;
function requestRedeemViaIntent(
address user,
uint256 amount,
uint256 minAmountOut
) external;
function processDeposit(
address[] memory users
)
external
returns (
uint256 amountDeposited,
uint256 amountCancelled,
uint256 counterDeposited,
uint256 counterCancelled
);
function cancelDeposits(
address[] memory users,
uint256[] memory epochs
) external;
function processRedeems(
address[] memory users
)
external
returns (
uint256 amountRedeemed,
uint256 amountCancelled,
uint256 counterDeposited,
uint256 counterCancelled
);
function cancelRedeems(
address[] memory users,
uint256[] memory epochs
) external;
function nextEpoch(
int256 totalUnrealizedPricePnL
) external returns (uint256 newExchangeRate);
function currentVirtualUtilization() external view returns (uint256);
function currentVirtualUtilization(
uint256 totalBorrows,
uint256 totalReserves,
int256 unrealizedFunding
) external view returns (uint256);
function virtualBalanceForUtilization() external view returns (uint256);
function virtualBalanceForUtilization(
uint256 extraAmount,
int256 unrealizedFunding
) external view returns (uint256);
function underlyingBalanceForExchangeRate() external view returns (uint256);
function sendAssetToTrader(address to, uint256 amount) external;
function isUtilizationForLPsValid() external view returns (bool);
}
interface ILexPoolV1 is ILexPoolFunctionality {
function name() external view returns (string memory);
function symbol() external view returns (string memory);
function SELF_UNIT_SCALE() external view returns (uint);
function underlyingDecimals() external view returns (uint256);
function poolAccountant() external view returns (address);
function underlying() external view returns (IERC20);
function tradingFloor() external view returns (address);
function currentEpoch() external view returns (uint256);
function currentExchangeRate() external view returns (uint256);
function nextEpochStartMin() external view returns (uint256);
function epochDuration() external view returns (uint256);
function minDepositAmount() external view returns (uint256);
function epochsDelayDeposit() external view returns (uint256);
function epochsDelayRedeem() external view returns (uint256);
function immediateDepositAllowed() external view returns (bool);
function pendingDeposits(
uint epoch,
address account
) external view returns (PendingDeposit memory);
function pendingRedeems(
uint epoch,
address account
) external view returns (PendingRedeem memory);
function pendingDepositAmount() external view returns (uint256);
function pendingWithdrawalAmount() external view returns (uint256);
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.24;
interface ILynxVersionedContract {
/**
* @notice Returns the name of the contract
*/
function getContractName() external view returns (string memory);
/**
* @notice Returns the version of the contract
* @dev units are scaled by 1000 (1,000 = 1.00, 1,120 = 1.12)
*/
function getContractVersion() external view returns (string memory);
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.24;
import "./LexErrors.sol";
import "./ILexPoolV1.sol";
import "./IInterestRateModel.sol";
import "./IFundingRateModel.sol";
import "./TradingEnumsV1.sol";
interface PoolAccountantStructs {
// @note To be used for passing information in function calls
struct PositionRegistrationParams {
uint256 collateral;
uint32 leverage;
bool long;
uint64 openPrice;
uint64 tp;
}
struct PairFunding {
// Slot 0
int256 accPerOiLong; // 32 bytes -- Underlying Decimals
// Slot 1
int256 accPerOiShort; // 32 bytes -- Underlying Decimals
// Slot 2
uint256 lastUpdateTimestamp; // 32 bytes
}
struct TradeInitialAccFees {
// Slot 0
uint256 borrowIndex; // 32 bytes
// Slot 1
int256 funding; // 32 bytes -- underlying units -- Underlying Decimals
}
struct PairOpenInterest {
// Slot 0
uint256 long; // 32 bytes -- underlying units -- Dynamic open interest for long positions
// Slot 1
uint256 short; // 32 bytes -- underlying units -- Dynamic open interest for short positions
}
// This struct is not kept in storage
struct PairFromTo {
string from;
string to;
}
struct Pair {
// Slot 0
uint16 id; // 02 bytes
uint16 groupId; // 02 bytes
uint16 feeId; // 02 bytes
uint32 minLeverage; // 04 bytes
uint32 maxLeverage; // 04 bytes
uint32 maxBorrowF; // 04 bytes -- FRACTION_SCALE (5)
// Slot 1
uint256 maxPositionSize; // 32 bytes -- underlying units
// Slot 2
uint256 maxGain; // 32 bytes -- underlying units
// Slot 3
uint256 maxOpenInterest; // 32 bytes -- Underlying units
// Slot 4
uint256 maxSkew; // 32 bytes -- underlying units
// Slot 5
uint256 minOpenFee; // 32 bytes -- underlying units. MAX_UINT means use the default group level value
// Slot 6
uint256 minPerformanceFee; // 32 bytes -- underlying units
}
struct Group {
// Slot 0
uint16 id; // 02 bytes
uint32 minLeverage; // 04 bytes
uint32 maxLeverage; // 04 bytes
uint32 maxBorrowF; // 04 bytes -- FRACTION_SCALE (5)
// Slot 1
uint256 maxPositionSize; // 32 bytes (Underlying units)
// Slot 2
uint256 minOpenFee; // 32 bytes (Underlying uints). MAX_UINT means use the default global level value
}
struct Fee {
// Slot 0
uint16 id; // 02 bytes
uint32 openFeeF; // 04 bytes -- FRACTION_SCALE (5) (Fraction of leveraged pos)
uint32 closeFeeF; // 04 bytes -- FRACTION_SCALE (5) (Fraction of leveraged pos)
uint32 performanceFeeF; // 04 bytes -- FRACTION_SCALE (5) (Fraction of performance)
}
}
interface PoolAccountantEvents is PoolAccountantStructs {
event PairAdded(
uint256 indexed id,
string indexed from,
string indexed to,
Pair pair
);
event PairUpdated(uint256 indexed id, Pair pair);
event GroupAdded(uint256 indexed id, string indexed groupName, Group group);
event GroupUpdated(uint256 indexed id, Group group);
event FeeAdded(uint256 indexed id, string indexed name, Fee fee);
event FeeUpdated(uint256 indexed id, Fee fee);
event TradeInitialAccFeesStored(
bytes32 indexed positionId,
uint256 borrowIndex,
// uint256 rollover,
int256 funding
);
event AccrueFunding(
uint256 indexed pairId,
int256 valueLong,
int256 valueShort
);
event ProtocolFundingShareAccrued(
uint16 indexed pairId,
uint256 protocolFundingShare
);
// event AccRolloverFeesStored(uint256 pairIndex, uint256 value);
event FeesCharged(
bytes32 indexed positionId,
address indexed trader,
uint16 indexed pairId,
PositionRegistrationParams positionRegistrationParams,
// bool long,
// uint256 collateral, // Underlying Decimals
// uint256 leverage,
int256 profitPrecision, // PRECISION
uint256 interest,
int256 funding, // Underlying Decimals
uint256 closingFee,
uint256 tradeValue
);
event PerformanceFeeCharging(
bytes32 indexed positionId,
uint256 performanceFee
);
event MaxOpenInterestUpdated(uint256 pairIndex, uint256 maxOpenInterest);
event AccrueInterest(
uint256 cash,
uint256 totalInterestNew,
uint256 borrowIndexNew,
uint256 interestShareNew
);
event Borrow(
uint256 indexed pairId,
uint256 borrowAmount,
uint256 newTotalBorrows
);
event Repay(
uint256 indexed pairId,
uint256 repayAmount,
uint256 newTotalBorrows
);
}
interface IPoolAccountantFunctionality is
PoolAccountantStructs,
PoolAccountantEvents,
LexErrors,
TradingEnumsV1
{
function setTradeIncentivizer(address _tradeIncentivizer) external;
function setMaxGainF(uint256 _maxGainF) external;
function setFrm(IFundingRateModel _frm) external;
function setMinOpenFee(uint256 min) external;
function setLexPartF(uint256 partF) external;
function setFundingRateMax(uint256 maxValue) external;
function setLiquidationThresholdF(uint256 threshold) external;
function setLiquidationFeeF(uint256 fee) external;
function setIrm(IInterestRateModel _irm) external;
function setIrmHard(IInterestRateModel _irm) external;
function setInterestShareFactor(uint256 factor) external;
function setFundingShareFactor(uint256 factor) external;
function setBorrowRateMax(uint256 rate) external;
function setMaxTotalBorrows(uint256 maxBorrows) external;
function setMaxVirtualUtilization(uint256 _maxVirtualUtilization) external;
function resetTradersPairGains(uint256 pairId) external;
function addGroup(Group calldata _group) external;
function updateGroup(Group calldata _group) external;
function addFee(Fee calldata _fee) external;
function updateFee(Fee calldata _fee) external;
function addPair(Pair calldata _pair) external;
function addPairs(Pair[] calldata _pairs) external;
function updatePair(Pair calldata _pair) external;
function readAndZeroReserves()
external
returns (uint256 accumulatedInterestShare, uint256 accFundingShare);
function registerOpenTrade(
bytes32 positionId,
address trader,
uint16 pairId,
uint256 collateral,
uint32 leverage,
bool long,
uint256 tp,
uint256 openPrice
) external returns (uint256 fee, uint256 lexPartFee);
function registerCloseTrade(
bytes32 positionId,
address trader,
uint16 pairId,
PositionRegistrationParams calldata positionRegistrationParams,
uint256 closePrice,
PositionCloseType positionCloseType
)
external
returns (
uint256 closingFee,
uint256 tradeValue,
int256 profitPrecision,
uint finalClosePrice
);
function registerUpdateTp(
bytes32 positionId,
address trader,
uint16 pairId,
uint256 collateral,
uint32 leverage,
bool long,
uint256 openPrice,
uint256 oldTriggerPrice,
uint256 triggerPrice
) external;
// function registerUpdateSl(
// address trader,
// uint256 pairIndex,
// uint256 index,
// uint256 collateral,
// uint256 leverage,
// bool long,
// uint256 openPrice,
// uint256 triggerPrice
// ) external returns (uint256 fee);
function accrueInterest()
external
returns (
uint256 totalInterestNew,
uint256 interestShareNew,
uint256 borrowIndexNew
);
// Limited only for the LexPool
function accrueInterest(
uint256 availableCash
)
external
returns (
uint256 totalInterestNew,
uint256 interestShareNew,
uint256 borrowIndexNew
);
function getTradeClosingValues(
bytes32 positionId,
uint16 pairId,
PositionRegistrationParams calldata positionRegistrationParams,
uint256 closePrice,
bool isLiquidation
)
external
returns (
uint256 tradeValue, // Underlying Decimals
uint256 safeClosingFee,
int256 profitPrecision,
uint256 interest,
int256 funding
);
function getTradeLiquidationPrice(
bytes32 positionId,
uint16 pairId,
uint256 openPrice, // PRICE_SCALE (8)
uint256 tp,
bool long,
uint256 collateral, // Underlying Decimals
uint32 leverage
)
external
returns (
uint256 // PRICE_SCALE (8)
);
function calcTradeDynamicFees(
bytes32 positionId,
uint16 pairId,
bool long,
uint256 collateral,
uint32 leverage,
uint256 openPrice,
uint256 tp
) external returns (uint256 interest, int256 funding);
function unrealizedFunding() external view returns (int256);
function totalBorrows() external view returns (uint256);
function interestShare() external view returns (uint256);
function fundingShare() external view returns (uint256);
function totalReservesView() external view returns (uint256);
function borrowsAndInterestShare()
external
view
returns (uint256 totalBorrows, uint256 totalInterestShare);
function pairTotalOpenInterest(
uint256 pairIndex
) external view returns (int256);
function pricePnL(
uint256 pairId,
uint256 price
) external view returns (int256);
function getAllSupportedPairIds() external view returns (uint16[] memory);
function getAllSupportedGroupsIds() external view returns (uint16[] memory);
function getAllSupportedFeeIds() external view returns (uint16[] memory);
}
interface IPoolAccountantV1 is IPoolAccountantFunctionality {
function totalBorrows() external view returns (uint256);
function maxTotalBorrows() external view returns (uint256);
function pairBorrows(uint256 pairId) external view returns (uint256);
function groupBorrows(uint256 groupId) external view returns (uint256);
function pairMaxBorrow(uint16 pairId) external view returns (uint256);
function groupMaxBorrow(uint16 groupId) external view returns (uint256);
function lexPool() external view returns (ILexPoolV1);
function maxGainF() external view returns (uint256);
function interestShareFactor() external view returns (uint256);
function fundingShareFactor() external view returns (uint256);
function frm() external view returns (IFundingRateModel);
function irm() external view returns (IInterestRateModel);
function pairs(uint16 pairId) external view returns (Pair memory);
function groups(uint16 groupId) external view returns (Group memory);
function fees(uint16 feeId) external view returns (Fee memory);
function openInterestInPair(
uint pairId
) external view returns (PairOpenInterest memory);
function minOpenFee() external view returns (uint256);
function liquidationThresholdF() external view returns (uint256);
function liquidationFeeF() external view returns (uint256);
function lexPartF() external view returns (uint256);
function tradersPairGains(uint256 pairId) external view returns (int256);
function calcBorrowAmount(
uint256 collateral,
uint256 leverage,
bool long,
uint256 openPrice,
uint256 tp
) external pure returns (uint256);
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.24;
import "../../AdministrationContracts/IContractRegistryBase.sol";
import "./IGlobalLock.sol";
interface IRegistryV1Functionality is IContractRegistryBase, IGlobalLock {
// **** Locking mechanism ****
function isTradersPortalAndLocker(
address _address
) external view returns (bool);
function isTriggersAndLocker(address _address) external view returns (bool);
function isTradersPortalOrTriggersAndLocker(
address _address
) external view returns (bool);
}
interface IRegistryV1 is IRegistryV1Functionality {
// **** Public Storage params ****
function feesManagers(address asset) external view returns (address);
function orderBook() external view returns (address);
function tradersPortal() external view returns (address);
function triggers() external view returns (address);
function tradeIntentsVerifier() external view returns (address);
function liquidityIntentsVerifier() external view returns (address);
function chipsIntentsVerifier() external view returns (address);
function lexProxiesFactory() external view returns (address);
function chipsFactory() external view returns (address);
/**
* @return An array of all supported trading floors
*/
function getAllSupportedTradingFloors()
external
view
returns (address[] memory);
/**
* @return An array of all supported settlement assets
*/
function getSettlementAssetsForTradingFloor(
address _tradingFloor
) external view returns (address[] memory);
/**
* @return The spender role address that is set for this chip
*/
function getValidSpenderTargetForChipByRole(
address chip,
string calldata role
) external view returns (address);
/**
* @return the address of the valid 'burnHandler' for the chip
*/
function validBurnHandlerForChip(
address chip
) external view returns (address);
/**
* @return The address matching for the given role
*/
function getDynamicRoleAddress(
string calldata _role
) external view returns (address);
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.24;
import "./TradingFloorStructsV1.sol";
import "./IPoolAccountantV1.sol";
import "./ILexPoolV1.sol";
interface ITradingFloorV1Functionality is TradingFloorStructsV1 {
function supportNewSettlementAsset(
address _asset,
address _lexPool,
address _poolAccountant
) external;
function getPositionTriggerInfo(
bytes32 _positionId
)
external
view
returns (
PositionPhase positionPhase,
uint64 timestamp,
uint16 pairId,
bool long,
uint32 spreadReductionF
);
function getPositionPortalInfo(
bytes32 _positionId
)
external
view
returns (
PositionPhase positionPhase,
uint64 inPhaseSince,
address positionTrader
);
function storePendingPosition(
OpenOrderType _orderType,
PositionRequestIdentifiers memory _requestIdentifiers,
PositionRequestParams memory _requestParams,
uint32 _spreadReductionF
) external returns (bytes32 positionId);
function setOpenedPositionToMarketClose(
bytes32 _positionId,
uint64 _minPrice,
uint64 _maxPrice
) external;
function cancelPendingPosition(
bytes32 _positionId,
OpenOrderType _orderType,
uint feeFraction
) external;
function cancelMarketCloseForPosition(
bytes32 _positionId,
CloseOrderType _orderType,
uint feeFraction
) external;
function updatePendingPosition_openLimit(
bytes32 _positionId,
uint64 _minPrice,
uint64 _maxPrice,
uint64 _tp,
uint64 _sl
) external;
function openNewPosition_market(
bytes32 _positionId,
uint64 assetEffectivePrice,
uint256 feeForCancellation
) external;
function openNewPosition_limit(
bytes32 _positionId,
uint64 assetEffectivePrice,
uint256 feeForCancellation
) external;
function closeExistingPosition_Market(
bytes32 _positionId,
uint64 assetPrice,
uint64 effectivePrice
) external;
function closeExistingPosition_Limit(
bytes32 _positionId,
LimitTrigger limitTrigger,
uint64 assetPrice,
uint64 effectivePrice
) external;
// Manage open trade
function updateOpenedPosition(
bytes32 _positionId,
PositionField updateField,
uint64 fieldValue,
uint64 effectivePrice
) external;
// Fees
function collectFee(address _asset, FeeType _feeType, address _to) external;
}
interface ITradingFloorV1 is ITradingFloorV1Functionality {
function PRECISION() external pure returns (uint);
// *** Views ***
function deprecated_pairTradersArray(
address _asset,
uint _pairIndex
) external view returns (address[] memory);
function traders(uint256 index) external view returns (address);
function tradersAmount() external view returns (uint256);
function getNextPositionIndexForTrader(
address _trader
) external view returns (uint32);
function getActivePositionIdsForTrader(
address _trader
) external view returns (bytes32[] memory);
function getActivePositionsAmountForTrader(address _trader) external view returns (uint256);
function generatePositionHashId(
address settlementAsset,
address trader,
uint16 pairId,
uint32 index
) external pure returns (bytes32 hashId);
// *** Public Storage addresses ***
function lexPoolForAsset(address asset) external view returns (ILexPoolV1);
function poolAccountantForAsset(
address asset
) external view returns (IPoolAccountantV1);
function registry() external view returns (address);
// *** Public Storage params ***
function positionsById(bytes32 id) external view returns (Position memory);
function positionIdentifiersById(
bytes32 id
) external view returns (PositionIdentifiers memory);
function positionLimitsInfoById(
bytes32 id
) external view returns (PositionLimitsInfo memory);
function triggerPricesById(
bytes32 id
) external view returns (PositionTriggerPrices memory);
function pairTradersInfo(
address settlementAsset,
address trader,
uint pairId
) external view returns (PairTraderInfo memory);
function spreadReductionsP(uint) external view returns (uint);
function maxSlF() external view returns (uint);
function maxTradesPerTrader() external view returns (uint);
function maxSanityProfitF() external view returns (uint);
function feesMap(
address settlementAsset,
FeeType feeType
) external view returns (uint256);
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.24;
interface LexErrors {
enum CapType {
NONE, // 0
MIN_OPEN_FEE, // 1
MAX_POS_SIZE_PAIR, // 2
MAX_POS_SIZE_GROUP, // 3
MAX_LEVERAGE, // 4
MIN_LEVERAGE, // 5
MAX_VIRTUAL_UTILIZATION, // 6
MAX_OPEN_INTEREST, // 7
MAX_ABS_SKEW, // 8
MAX_BORROW_PAIR, // 9
MAX_BORROW_GROUP, // 10
MIN_DEPOSIT_AMOUNT, // 11
MAX_ACCUMULATED_GAINS, // 12
BORROW_RATE_MAX, // 13
FUNDING_RATE_MAX, // 14
MAX_POTENTIAL_GAIN, // 15
MAX_TOTAL_BORROW, // 16
MIN_PERFORMANCE_FEE // 17
//...
}
error CapError(CapType, uint256 value);
}// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.24;
interface LexPoolAdminEnums {
enum LexPoolAddressesEnum {
none,
poolAccountant,
pnlRole
}
enum LexPoolNumbersEnum {
none,
maxExtraWithdrawalAmountF,
epochsDelayDeposit,
epochsDelayRedeem,
epochDuration,
minDepositAmount
}
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.24;
interface TradingEnumsV1 {
enum PositionPhase {
NONE,
OPEN_MARKET,
OPEN_LIMIT,
OPENED,
CLOSE_MARKET,
CLOSED
}
enum OpenOrderType {
NONE,
MARKET,
LIMIT
}
enum CloseOrderType {
NONE,
MARKET
}
enum FeeType {
NONE,
OPEN_FEE,
CLOSE_FEE,
TRIGGER_FEE
}
enum LimitTrigger {
NONE,
TP,
SL,
LIQ
}
enum PositionField {
NONE,
TP,
SL
}
enum PositionCloseType {
NONE,
TP,
SL,
LIQ,
MARKET
}
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.24;
import "./TradingEnumsV1.sol";
interface TradingFloorStructsV1 is TradingEnumsV1 {
enum AdminNumericParam {
NONE,
MAX_TRADES_PER_TRADER,
MAX_SL_F,
MAX_SANITY_PROFIT_F
}
/**
* @dev Memory struct for identifiers
*/
struct PositionRequestIdentifiers {
address trader;
uint16 pairId;
address settlementAsset;
}
/**
* @dev Memory struct for identifiers
*/
struct PositionRequestIdentifiers_Old {
address trader;
uint16 pairId;
address settlementAsset;
uint32 positionIndex;
}
struct PositionRequestParams {
bool long;
uint256 collateral; // Settlement Asset Decimals
uint32 leverage;
uint64 minPrice; // PRICE_SCALE
uint64 maxPrice; // PRICE_SCALE
uint64 tp; // PRICE_SCALE
uint64 sl; // PRICE_SCALE
uint64 tpByFraction; // FRACTION_SCALE
uint64 slByFraction; // FRACTION_SCALE
}
/**
* @dev Storage struct for identifiers
*/
struct PositionIdentifiers {
// Slot 0
address settlementAsset; // 20 bytes
uint16 pairId; // 02 bytes
uint32 index; // 04 bytes
// Slot 1
address trader; // 20 bytes
}
struct Position {
// Slot 0
uint collateral; // 32 bytes -- Settlement Asset Decimals
// Slot 1
PositionPhase phase; // 01 bytes
uint64 inPhaseSince; // 08 bytes
uint32 leverage; // 04 bytes
bool long; // 01 bytes
uint64 openPrice; // 08 bytes -- PRICE_SCALE (8)
uint32 spreadReductionF; // 04 bytes -- FRACTION_SCALE (5)
}
/**
* Holds the non liquidation limits for the position
*/
struct PositionLimitsInfo {
uint64 tpLastUpdated; // 08 bytes -- timestamp
uint64 slLastUpdated; // 08 bytes -- timestamp
uint64 tp; // 08 bytes -- PRICE_SCALE (8)
uint64 sl; // 08 bytes -- PRICE_SCALE (8)
}
/**
* Holds the prices for opening (and market closing) of a position
*/
struct PositionTriggerPrices {
uint64 minPrice; // 08 bytes -- PRICE_SCALE
uint64 maxPrice; // 08 bytes -- PRICE_SCALE
uint64 tpByFraction; // 04 bytes -- FRACTION_SCALE
uint64 slByFraction; // 04 bytes -- FRACTION_SCALE
}
/**
* @dev administration struct, used to keep tracks on the 'PairTraders' list and
* to limit the amount of positions a trader can have
*/
struct PairTraderInfo {
uint32 deprecated_positionsCounter; // 04 bytes - DEPRECATED: Use activePositionIdsByTrader.length instead
uint32 positionInArray; // 04 bytes (the index + 1)
//! Note : Can NOT (!) add more fields here
}
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.24;
import "../../AdministrationContracts/AcceptableRegistryImplementationClaimableAdmin.sol";
/**
* @title TradingFloorProxy
* @dev Used as the upgradable brain of the Lynx platform
*/
contract TradingFloorProxy is AcceptableRegistryImplementationClaimableAdmin {
constructor(
address _registry
)
AcceptableRegistryImplementationClaimableAdmin(
_registry,
"TradingFloor",
msg.sender
)
{}
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.24;
import "../../AdministrationContracts/AcceptableImplementationClaimableAdminStorage.sol";
import "../interfaces/ITradingFloorV1.sol";
import "../Common/CommonScales.sol";
/**
* @title TradingFloorStorageV1
* @dev Storage contract for the TradingFloor
*/
contract TradingFloorV1Storage is
AcceptableRegistryImplementationClaimableAdminStorage,
TradingFloorStructsV1,
CommonScales
{
// ***** Trading variables *****
// Maximum number of open positions a trader can have globally across all pairs
// Replaces the old maxTradesPerPair with global position limiting
uint public maxTradesPerTrader;
uint public maxSlF; // FRACTION_SCALE (5)
uint public maxSanityProfitF; // FRACTION_SCALE (5)
// ***** Pair pausing *****
mapping(uint => bool) public pausedPairs;
// ***** Fees *****
// Token => Fee Type => Amount
mapping(address => mapping(FeeType => uint)) public feesMap;
// ***** Lex&Accountant *****
// settlement asset => lex pool
mapping(address => address) public lexPoolForAsset;
// settlement asset => pool accountant
mapping(address => address) public poolAccountantForAsset;
// ***** Position Identifiers *****
// position id => PositionIdentifiers struct
mapping(bytes32 => PositionIdentifiers) public positionIdentifiersById;
// ***** Positions *****
// position id => Position Struct
mapping(bytes32 => Position) public positionsById;
// position id => OpenTradeInfo struct
mapping(bytes32 => PositionLimitsInfo) public positionLimitsInfoById;
// position id => trigger prices
mapping(bytes32 => PositionTriggerPrices) public triggerPricesById;
// Position id => initial collateral
mapping(bytes32 => uint) public initialCollateralByPositionId;
// ***** DEPRECATED: Per-pair trader tracking (kept for backward compatibility) *****
// asset => pair id => traders list
mapping(address => mapping(uint => address[])) public deprecated_pairTraders;
// asset => trader => pair id => index in traders list
mapping(address => mapping(address => mapping(uint => PairTraderInfo)))
public deprecated_pairTradersInfo;
// ***** NEW: Global trader tracking system (introduced in v1.01) *****
// Global array of all traders with active positions across any pair
// Traders are added when opening their first position and removed when closing their last
address[] public traders;
// Maps trader address to their index in the traders array (1-based indexing)
// 0 = not in array (default), 1 = at array[0], 2 = at array[1], etc.
// This enables O(1) existence checks and efficient array management
mapping(address => uint) public tradersIndex;
// Tracks the last used position index for generating unique position IDs
// Increments with each new position opened by the trader
mapping(address => uint32) public pairTradersLastUsedPositionIndex;
// Maps trader to their list of active position IDs across all pairs
// Enables efficient iteration through only active positions for a trader
// Positions are added on open and removed on close using swap-and-pop
mapping(address => bytes32[]) public activePositionIdsByTrader;
// Maps position ID to its index in the trader's activePositionIdsByTrader array (1-based)
// 0 = not in array, 1 = at array[0], etc.
// Enables O(1) removal from activePositionIdsByTrader when closing positions
mapping(address => mapping(bytes32 => uint256)) public positionIdToActivePositionIndex;
}{
"optimizer": {
"enabled": true,
"runs": 200
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"evmVersion": "paris",
"metadata": {
"useLiteralContent": true
}
}Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"inputs":[{"internalType":"address","name":"target","type":"address"}],"name":"AddressEmptyCode","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"AddressInsufficientBalance","type":"error"},{"inputs":[{"internalType":"enum LexErrors.CapType","name":"","type":"uint8"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"CapError","type":"error"},{"inputs":[],"name":"FailedInnerCall","type":"error"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"SafeERC20FailedOperation","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":true,"internalType":"enum TradingEnumsV1.FeeType","name":"feeType","type":"uint8"},{"indexed":true,"internalType":"address","name":"receiver","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"FeeCollected","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"positionId","type":"bytes32"},{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":true,"internalType":"enum TradingEnumsV1.FeeType","name":"feeType","type":"uint8"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"FeeRegistered","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"string","name":"name","type":"string"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"NumberUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"positionId","type":"bytes32"},{"indexed":true,"internalType":"uint16","name":"pairId","type":"uint16"},{"indexed":false,"internalType":"bool","name":"buy","type":"bool"},{"indexed":true,"internalType":"enum TradingEnumsV1.PositionField","name":"updatedField","type":"uint8"},{"indexed":false,"internalType":"uint64","name":"fieldValue","type":"uint64"}],"name":"OpenedPositionUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"pairId","type":"uint256"},{"indexed":true,"internalType":"bool","name":"isPaused","type":"bool"}],"name":"PairPausedChange","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"positionId","type":"bytes32"},{"indexed":true,"internalType":"address","name":"source","type":"address"},{"indexed":false,"internalType":"uint256","name":"fee","type":"uint256"}],"name":"PendingPositionCancelled","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"positionId","type":"bytes32"},{"indexed":false,"internalType":"enum TradingEnumsV1.PositionPhase","name":"phase","type":"uint8"},{"components":[{"internalType":"address","name":"trader","type":"address"},{"internalType":"uint16","name":"pairId","type":"uint16"},{"internalType":"address","name":"settlementAsset","type":"address"},{"internalType":"uint32","name":"positionIndex","type":"uint32"}],"indexed":false,"internalType":"struct TradingFloorStructsV1.PositionRequestIdentifiers_Old","name":"requestIdentifiers","type":"tuple"},{"components":[{"internalType":"bool","name":"long","type":"bool"},{"internalType":"uint256","name":"collateral","type":"uint256"},{"internalType":"uint32","name":"leverage","type":"uint32"},{"internalType":"uint64","name":"minPrice","type":"uint64"},{"internalType":"uint64","name":"maxPrice","type":"uint64"},{"internalType":"uint64","name":"tp","type":"uint64"},{"internalType":"uint64","name":"sl","type":"uint64"},{"internalType":"uint64","name":"tpByFraction","type":"uint64"},{"internalType":"uint64","name":"slByFraction","type":"uint64"}],"indexed":false,"internalType":"struct TradingFloorStructsV1.PositionRequestParams","name":"requestParams","type":"tuple"},{"indexed":false,"internalType":"uint32","name":"_spreadReductionF","type":"uint32"}],"name":"PendingPositionStored","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"positionId","type":"bytes32"},{"indexed":false,"internalType":"enum TradingEnumsV1.PositionPhase","name":"phase","type":"uint8"},{"indexed":false,"internalType":"uint32","name":"index","type":"uint32"},{"components":[{"internalType":"address","name":"trader","type":"address"},{"internalType":"uint16","name":"pairId","type":"uint16"},{"internalType":"address","name":"settlementAsset","type":"address"}],"indexed":false,"internalType":"struct TradingFloorStructsV1.PositionRequestIdentifiers","name":"requestIdentifiers","type":"tuple"},{"components":[{"internalType":"bool","name":"long","type":"bool"},{"internalType":"uint256","name":"collateral","type":"uint256"},{"internalType":"uint32","name":"leverage","type":"uint32"},{"internalType":"uint64","name":"minPrice","type":"uint64"},{"internalType":"uint64","name":"maxPrice","type":"uint64"},{"internalType":"uint64","name":"tp","type":"uint64"},{"internalType":"uint64","name":"sl","type":"uint64"},{"internalType":"uint64","name":"tpByFraction","type":"uint64"},{"internalType":"uint64","name":"slByFraction","type":"uint64"}],"indexed":false,"internalType":"struct TradingFloorStructsV1.PositionRequestParams","name":"requestParams","type":"tuple"},{"indexed":false,"internalType":"uint32","name":"_spreadReductionF","type":"uint32"}],"name":"PendingPositionStoredV1010","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"positionId","type":"bytes32"},{"indexed":false,"internalType":"uint64","name":"tp","type":"uint64"},{"indexed":false,"internalType":"uint64","name":"sl","type":"uint64"},{"indexed":false,"internalType":"uint64","name":"minPrice","type":"uint64"},{"indexed":false,"internalType":"uint64","name":"maxPrice","type":"uint64"}],"name":"PendingPositionUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"positionId","type":"bytes32"},{"indexed":true,"internalType":"enum TradingEnumsV1.LimitTrigger","name":"limitTrigger","type":"uint8"},{"indexed":false,"internalType":"uint256","name":"triggerPrice","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"effectiveClosePrice","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"tradeValue","type":"uint256"},{"indexed":false,"internalType":"int256","name":"profitPrecision","type":"int256"}],"name":"PositionClosedLimit","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"positionId","type":"bytes32"},{"indexed":false,"internalType":"uint256","name":"triggerPrice","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"tradeValue","type":"uint256"},{"indexed":false,"internalType":"int256","name":"profitPrecision","type":"int256"}],"name":"PositionClosedMarket","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"positionId","type":"bytes32"},{"components":[{"internalType":"address","name":"settlementAsset","type":"address"},{"internalType":"uint16","name":"pairId","type":"uint16"},{"internalType":"uint32","name":"index","type":"uint32"},{"internalType":"address","name":"trader","type":"address"}],"indexed":false,"internalType":"struct TradingFloorStructsV1.PositionIdentifiers","name":"identifiers","type":"tuple"}],"name":"PositionIdentifiersStored","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"positionId","type":"bytes32"},{"indexed":true,"internalType":"address","name":"source","type":"address"},{"indexed":false,"internalType":"uint256","name":"fee","type":"uint256"}],"name":"PositionMarketCloseCancelled","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"positionId","type":"bytes32"},{"indexed":false,"internalType":"enum LexErrors.CapType","name":"capType","type":"uint8"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"PositionOpenCancelledByCap","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"positionId","type":"bytes32"},{"indexed":false,"internalType":"uint64","name":"triggerPrice","type":"uint64"}],"name":"PositionOpenCancelledByMarketPriceRange","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"positionId","type":"bytes32"},{"indexed":false,"internalType":"uint64","name":"openPrice","type":"uint64"},{"indexed":false,"internalType":"uint64","name":"tp","type":"uint64"},{"indexed":false,"internalType":"uint64","name":"sl","type":"uint64"},{"indexed":false,"internalType":"uint256","name":"totalOpenFee","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"lexFeePart","type":"uint256"}],"name":"PositionOpened","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"positionId","type":"bytes32"},{"indexed":false,"internalType":"uint64","name":"_minPrice","type":"uint64"},{"indexed":false,"internalType":"uint64","name":"_maxPrice","type":"uint64"}],"name":"PositionSetForMarketClose","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"asset","type":"address"},{"indexed":true,"internalType":"address","name":"lexPool","type":"address"},{"indexed":true,"internalType":"address","name":"poolAccountant","type":"address"}],"name":"SettlementAssetAdded","type":"event"},{"inputs":[],"name":"ACCURACY_IMPROVEMENT_SCALE","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"CONTRACT_NAME","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"CONTRACT_VERSION","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"FRACTION_SCALE","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"LEVERAGE_SCALE","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MAX_FEE_FRACTION_FOR_CANCEL","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"PRECISION","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract TradingFloorProxy","name":"tradingFloorProxy","type":"address"}],"name":"_become","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"activePositionIdsByTrader","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"admin","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_positionId","type":"bytes32"},{"internalType":"enum TradingEnumsV1.CloseOrderType","name":"_orderType","type":"uint8"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"cancelMarketCloseForPosition","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_positionId","type":"bytes32"},{"internalType":"enum TradingEnumsV1.OpenOrderType","name":"_orderType","type":"uint8"},{"internalType":"uint256","name":"feeFraction","type":"uint256"}],"name":"cancelPendingPosition","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_positionId","type":"bytes32"},{"internalType":"enum TradingEnumsV1.LimitTrigger","name":"limitTrigger","type":"uint8"},{"internalType":"uint64","name":"","type":"uint64"},{"internalType":"uint64","name":"effectivePrice","type":"uint64"}],"name":"closeExistingPosition_Limit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_positionId","type":"bytes32"},{"internalType":"uint64","name":"","type":"uint64"},{"internalType":"uint64","name":"effectivePrice","type":"uint64"}],"name":"closeExistingPosition_Market","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_asset","type":"address"},{"internalType":"enum TradingEnumsV1.FeeType","name":"_feeType","type":"uint8"},{"internalType":"address","name":"_to","type":"address"}],"name":"collectFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"deprecated_pairTraders","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_asset","type":"address"},{"internalType":"uint256","name":"_pairIndex","type":"uint256"}],"name":"deprecated_pairTradersArray","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"deprecated_pairTradersInfo","outputs":[{"internalType":"uint32","name":"deprecated_positionsCounter","type":"uint32"},{"internalType":"uint32","name":"positionInArray","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"enum TradingEnumsV1.FeeType","name":"","type":"uint8"}],"name":"feesMap","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"settlementAsset","type":"address"},{"internalType":"address","name":"trader","type":"address"},{"internalType":"uint16","name":"pairId","type":"uint16"},{"internalType":"uint32","name":"index","type":"uint32"}],"name":"generatePositionHashId","outputs":[{"internalType":"bytes32","name":"hashId","type":"bytes32"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"_trader","type":"address"}],"name":"getActivePositionIdsForTrader","outputs":[{"internalType":"bytes32[]","name":"","type":"bytes32[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_trader","type":"address"}],"name":"getActivePositionsAmountForTrader","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getContractName","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"getContractVersion","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"_trader","type":"address"}],"name":"getNextPositionIndexForTrader","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_positionId","type":"bytes32"}],"name":"getPositionPortalInfo","outputs":[{"internalType":"enum TradingEnumsV1.PositionPhase","name":"positionPhase","type":"uint8"},{"internalType":"uint64","name":"timestamp","type":"uint64"},{"internalType":"address","name":"trader","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_positionId","type":"bytes32"}],"name":"getPositionRegistrationParams","outputs":[{"components":[{"internalType":"uint256","name":"collateral","type":"uint256"},{"internalType":"uint32","name":"leverage","type":"uint32"},{"internalType":"bool","name":"long","type":"bool"},{"internalType":"uint64","name":"openPrice","type":"uint64"},{"internalType":"uint64","name":"tp","type":"uint64"}],"internalType":"struct PoolAccountantStructs.PositionRegistrationParams","name":"registrationParams","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_positionId","type":"bytes32"}],"name":"getPositionTriggerInfo","outputs":[{"internalType":"enum TradingEnumsV1.PositionPhase","name":"positionPhase","type":"uint8"},{"internalType":"uint64","name":"timestamp","type":"uint64"},{"internalType":"uint16","name":"pairId","type":"uint16"},{"internalType":"bool","name":"long","type":"bool"},{"internalType":"uint32","name":"spreadReductionF","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"implementation","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"initialCollateralByPositionId","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"settlementAsset","type":"address"}],"name":"isSettlementAssetSupported","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"lexPoolForAsset","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxSanityProfitF","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxSlF","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxTradesPerTrader","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_positionId","type":"bytes32"},{"internalType":"uint64","name":"assetEffectivePrice","type":"uint64"},{"internalType":"uint256","name":"feeForCancellation","type":"uint256"}],"name":"openNewPosition_limit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_positionId","type":"bytes32"},{"internalType":"uint64","name":"assetEffectivePrice","type":"uint64"},{"internalType":"uint256","name":"feeForCancellation","type":"uint256"}],"name":"openNewPosition_market","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"pairTradersLastUsedPositionIndex","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"pausedPairs","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pendingAdmin","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pendingImplementation","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"poolAccountantForAsset","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"positionIdToActivePositionIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"positionIdentifiersById","outputs":[{"internalType":"address","name":"settlementAsset","type":"address"},{"internalType":"uint16","name":"pairId","type":"uint16"},{"internalType":"uint32","name":"index","type":"uint32"},{"internalType":"address","name":"trader","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"positionLimitsInfoById","outputs":[{"internalType":"uint64","name":"tpLastUpdated","type":"uint64"},{"internalType":"uint64","name":"slLastUpdated","type":"uint64"},{"internalType":"uint64","name":"tp","type":"uint64"},{"internalType":"uint64","name":"sl","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"positionsById","outputs":[{"internalType":"uint256","name":"collateral","type":"uint256"},{"internalType":"enum TradingEnumsV1.PositionPhase","name":"phase","type":"uint8"},{"internalType":"uint64","name":"inPhaseSince","type":"uint64"},{"internalType":"uint32","name":"leverage","type":"uint32"},{"internalType":"bool","name":"long","type":"bool"},{"internalType":"uint64","name":"openPrice","type":"uint64"},{"internalType":"uint32","name":"spreadReductionF","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"registry","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_positionId","type":"bytes32"},{"internalType":"uint64","name":"_minPrice","type":"uint64"},{"internalType":"uint64","name":"_maxPrice","type":"uint64"}],"name":"setOpenedPositionToMarketClose","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_pairId","type":"uint256"},{"internalType":"bool","name":"_isPaused","type":"bool"}],"name":"setPairPaused","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"enum TradingFloorStructsV1.AdminNumericParam","name":"numericParam","type":"uint8"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"setTradeParam","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"enum TradingEnumsV1.OpenOrderType","name":"_orderType","type":"uint8"},{"components":[{"internalType":"address","name":"trader","type":"address"},{"internalType":"uint16","name":"pairId","type":"uint16"},{"internalType":"address","name":"settlementAsset","type":"address"}],"internalType":"struct TradingFloorStructsV1.PositionRequestIdentifiers","name":"_requestIdentifiers","type":"tuple"},{"components":[{"internalType":"bool","name":"long","type":"bool"},{"internalType":"uint256","name":"collateral","type":"uint256"},{"internalType":"uint32","name":"leverage","type":"uint32"},{"internalType":"uint64","name":"minPrice","type":"uint64"},{"internalType":"uint64","name":"maxPrice","type":"uint64"},{"internalType":"uint64","name":"tp","type":"uint64"},{"internalType":"uint64","name":"sl","type":"uint64"},{"internalType":"uint64","name":"tpByFraction","type":"uint64"},{"internalType":"uint64","name":"slByFraction","type":"uint64"}],"internalType":"struct TradingFloorStructsV1.PositionRequestParams","name":"_requestParams","type":"tuple"},{"internalType":"uint32","name":"_spreadReductionF","type":"uint32"}],"name":"storePendingPosition","outputs":[{"internalType":"bytes32","name":"positionId","type":"bytes32"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_asset","type":"address"},{"internalType":"address","name":"_lexPool","type":"address"},{"internalType":"address","name":"_poolAccountant","type":"address"}],"name":"supportNewSettlementAsset","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"traders","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"tradersAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"tradersIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"triggerPricesById","outputs":[{"internalType":"uint64","name":"minPrice","type":"uint64"},{"internalType":"uint64","name":"maxPrice","type":"uint64"},{"internalType":"uint64","name":"tpByFraction","type":"uint64"},{"internalType":"uint64","name":"slByFraction","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"positionId","type":"bytes32"},{"internalType":"enum TradingEnumsV1.PositionField","name":"updateField","type":"uint8"},{"internalType":"uint64","name":"fieldValue","type":"uint64"},{"internalType":"uint64","name":"effectivePrice","type":"uint64"}],"name":"updateOpenedPosition","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_positionId","type":"bytes32"},{"internalType":"uint64","name":"_minPrice","type":"uint64"},{"internalType":"uint64","name":"_maxPrice","type":"uint64"},{"internalType":"uint64","name":"_tp","type":"uint64"},{"internalType":"uint64","name":"_sl","type":"uint64"}],"name":"updatePendingPosition_openLimit","outputs":[],"stateMutability":"nonpayable","type":"function"}]Contract Creation Code
608060405234801561001057600080fd5b50600080546001600160a01b03191633179055615d0580620000336000396000f3fe608060405234801561001057600080fd5b506004361061038e5760003560e01c806382571409116101de578063b71f3cfe1161010f578063ece938cf116100ad578063f555f6971161007c578063f555f69714610aed578063f5f5ba7214610b0d578063f851a44014610b37578063f9b9484e14610b4a57600080fd5b8063ece938cf14610a5b578063ef6ecc5514610a64578063f2eb245e14610ac4578063f51f3fd314610ae457600080fd5b8063ddf474f1116100e9578063ddf474f1146109cd578063e640f33b14610a15578063eb48914014610a28578063ec7f8a3a14610a3b57600080fd5b8063b71f3cfe1461099c578063c07f9921146109a7578063ca3a3a82146109ba57600080fd5b806395be50501161017c578063a40d726811610156578063a40d726814610947578063aaf5eb681461095a578063acfd6b9214610969578063ad1f2b561461099457600080fd5b806395be5050146108a65780639ff69ffa14610921578063a2a25ea61461093457600080fd5b80638f7a8fb5116101b85780638f7a8fb5146107e257806390f24cac1461085d57806393a7f6a71461087057806394a1e6e51461089e57600080fd5b806382571409146107a657806386dc4975146107af5780638aa10435146107c257600080fd5b8063396f7b23116102c357806368f296a51161026157806376d901be1161023057806376d901be146107435780637b1039991461077657806380193b261461078957806380a7f3d41461079357600080fd5b806368f296a5146106c15780636e01af8d146106e7578063725b7d52146106fa57806374d8b78e1461071a57600080fd5b80634ebe5c331161029d5780634ebe5c33146105f35780635c60da1b14610606578063614d08f81461061957806366307a4f1461064657600080fd5b8063396f7b23146105ad5780633ad6f124146105c05780633b17a497146105d357600080fd5b80631ea9af6b1161033057806324b22a1f1161030a57806324b22a1f1461052c578063267822471461053f57806330d073d01461055257806338b903331461057d57600080fd5b80631ea9af6b146104e95780632457bc3a146104fc5780632485f3f11461050457600080fd5b8063135e563d1161036c578063135e563d1461048557806318fa4714146104985780631961aba0146104ad5780631d504dc6146104d657600080fd5b8063010570851461039357806303b90a87146103b9578063042e37c5146103fa575b600080fd5b6103a66103a1366004615055565b610bac565b6040519081526020015b60405180910390f35b6103e26103c7366004615199565b600b602052600090815260409020546001600160a01b031681565b6040516001600160a01b0390911681526020016103b0565b6104496104083660046151b6565b600c60205260009081526040902080546001909101546001600160a01b0380831692600160a01b810461ffff1692600160b01b90910463ffffffff16911684565b604080516001600160a01b03958616815261ffff909416602085015263ffffffff909216918301919091529190911660608201526080016103b0565b6103e26104933660046151b6565b611107565b6104ab6104a63660046151dc565b611131565b005b6103a66104bb366004615199565b6001600160a01b031660009081526016602052604090205490565b6104ab6104e4366004615199565b611200565b6104ab6104f7366004615227565b61134e565b6013546103a6565b610517610512366004615199565b6113e4565b60405163ffffffff90911681526020016103b0565b6104ab61053a36600461525c565b61147e565b6001546103e2906001600160a01b031681565b6103a6610560366004615288565b600960209081526000928352604080842090915290825290205481565b6105a0604051806040016040528060048152602001630313031360e41b81525081565b6040516103b091906152e5565b6003546103e2906001600160a01b031681565b6103a66105ce366004615318565b61171d565b6105e66105e1366004615199565b61174e565b6040516103b09190615336565b6104ab61060136600461537a565b6117ba565b6002546103e2906001600160a01b031681565b6105a06040518060400160405280600e81526020016d54726164696e67466c6f6f72563160901b81525081565b61068e6106543660046151b6565b600e602052600090815260409020546001600160401b0380821691600160401b8104821691600160801b8204811691600160c01b90041684565b604080516001600160401b03958616815293851660208501529184169183019190915290911660608201526080016103b0565b6105176106cf366004615199565b60156020526000908152604090205463ffffffff1681565b6104ab6106f53660046153b6565b61187e565b61070d610708366004615318565b611c14565b6040516103b091906153dd565b6103e2610728366004615199565b600a602052600090815260409020546001600160a01b031681565b6107666107513660046151b6565b60086020526000908152604090205460ff1681565b60405190151581526020016103b0565b6004546103e2906001600160a01b031681565b6103a6620186a081565b6104ab6107a136600461541e565b611c94565b6103a660075481565b6104ab6107bd366004615462565b6120ec565b6040805180820190915260048152630313031360e41b60208201526105a0565b61084a6107f03660046151b6565b600d602052600090815260409020805460019091015460ff808216916001600160401b03610100820481169263ffffffff600160481b8404811693600160681b810490921692600160701b83041691600160b01b90041687565b6040516103b097969594939291906154b1565b6103e261086b366004615506565b61217f565b61076661087e366004615199565b6001600160a01b039081166000908152600a602052604090205416151590565b6103a66121c4565b6109106108b43660046151b6565b6000908152600d6020818152604080842060010154600c835293205491905260ff8083169361010084046001600160401b031693600160a01b90930461ffff1692600160681b810490921691600160b01b900463ffffffff1690565b6040516103b095949392919061553b565b6104ab61092f36600461557f565b6121d5565b6104ab6109423660046155dd565b61241c565b6103a661095536600461560d565b61253e565b6103a6670de0b6b3a764000081565b6103a6610977366004615318565b601760209081526000928352604080842090915290825290205481565b6103a6606481565b6103a6633b9aca0081565b6104ab6109b536600461565a565b6125ad565b6104ab6109c8366004615682565b612cfa565b61068e6109db3660046151b6565b600f602052600090815260409020546001600160401b0380821691600160401b8104821691600160801b8204811691600160c01b90041684565b6104ab610a23366004615682565b612eab565b6104ab610a36366004615227565b61303c565b6103a6610a49366004615199565b60146020526000908152604090205481565b6103a660055481565b610aa7610a723660046156be565b601260209081526000938452604080852082529284528284209052825290205463ffffffff8082169164010000000090041682565b6040805163ffffffff9384168152929091166020830152016103b0565b6103a6610ad23660046151b6565b60106020526000908152604090205481565b6103a660065481565b610b00610afb3660046151b6565b6130d2565b6040516103b09190615735565b60408051808201909152600e81526d54726164696e67466c6f6f72563160901b60208201526105a0565b6000546103e2906001600160a01b031681565b610b9d610b583660046151b6565b6000908152600d60209081526040808320600190810154600c90935292209091015460ff8216926101009092046001600160401b0316916001600160a01b0390911690565b6040516103b093929190615743565b6004805460405163731aa5f960e01b815233928101929092526000916001600160a01b039091169063731aa5f990602401602060405180830381865afa158015610bfa573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c1e9190615779565b610c435760405162461bcd60e51b8152600401610c3a90615796565b60405180910390fd5b610c6b84604001516001600160a01b039081166000908152600a602052604090205416151590565b610cb75760405162461bcd60e51b815260206004820152601e60248201527f4e4f4e5f535550504f525445445f534554544c454d454e545f415353455400006044820152606401610c3a565b60208085015161ffff1660009081526008909152604090205460ff1615610cf05760405162461bcd60e51b8152600401610c3a906157be565b6001856002811115610d0457610d04615487565b1480610d2157506002856002811115610d1f57610d1f615487565b145b610d665760405162461bcd60e51b8152602060048201526016602482015275554e535550504f525445445f4f524445525f5459504560501b6044820152606401610c3a565b610dab836000015184606001516001600160401b031685608001516001600160401b03168660a001516001600160401b03168760c001516001600160401b03166131fa565b60055484516001600160a01b031660009081526016602052604090205410610e0d5760405162461bcd60e51b815260206004820152601560248201527426a0ac2faa2920a222a9afa822a92faa2920a222a960591b6044820152606401610c3a565b6000610e268560400151866000015187602001516132dc565b8092508193505050610e4585604001518660000151866020015161344d565b8451610e5090613592565b6000828152600d60205260409020805415610e975760405162461bcd60e51b8152602060048201526007602482015266125117d554d15160ca1b6044820152606401610c3a565b600180820180548751604089015163ffffffff908116600160481b026cffffffff00000000000000000019921515600160681b0260ff60681b19928b16600160b01b02929092166cffffffff0000000000000000ff60681b1990941693909317171617905560208601518255600090886002811115610f1857610f18615487565b14610f24576002610f27565b60015b9050808260010160006101000a81548160ff02191690836005811115610f4f57610f4f615487565b0217905550428260010160016101000a8154816001600160401b0302191690836001600160401b031602179055506000600e600086815260200190815260200160002090508660a001518160000160106101000a8154816001600160401b0302191690836001600160401b031602179055508660c001518160000160186101000a8154816001600160401b0302191690836001600160401b031602179055506000600f6000878152602001908152602001600020905087606001518160000160006101000a8154816001600160401b0302191690836001600160401b0316021790555087608001518160000160086101000a8154816001600160401b0302191690836001600160401b031602179055508760e001518160000160106101000a8154816001600160401b0302191690836001600160401b031602179055508761010001518160000160186101000a8154816001600160401b0302191690836001600160401b03160217905550857f835de04f5a930b169d6564c8f1c5f91f89abd9ea026b7488c94452abb900cc7484878c8c8c6040516110f29594939291906157e3565b60405180910390a25050505050949350505050565b6013818154811061111757600080fd5b6000918252602090912001546001600160a01b0316905081565b6004805460405163a8e36e5b60e01b81526001600160a01b038681169382019390935291169063a8e36e5b90602401602060405180830381865afa15801561117d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111a191906158c7565b6001600160a01b0316336001600160a01b0316146111f05760405162461bcd60e51b815260206004820152600c60248201526b10a332b2b9a6b0b730b3b2b960a11b6044820152606401610c3a565b6111fb83838361360e565b505050565b806001600160a01b031663f851a4406040518163ffffffff1660e01b8152600401602060405180830381865afa15801561123e573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061126291906158c7565b6001600160a01b0316336001600160a01b0316146112b15760405162461bcd60e51b815260206004820152600c60248201526b10b83937bc3c9730b236b4b760a11b6044820152606401610c3a565b806001600160a01b031663c1e803346040518163ffffffff1660e01b81526004016020604051808303816000875af11580156112f1573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061131591906158e4565b1561134b5760405162461bcd60e51b8152600401610c3a9060208082526004908201526319985a5b60e21b604082015260600190565b50565b6004805460405163a5a2ed3760e01b815233928101929092526001600160a01b03169063a5a2ed3790602401602060405180830381865afa158015611397573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113bb9190615779565b6113d75760405162461bcd60e51b8152600401610c3a906158fd565b6111fb8360028484613731565b6001600160a01b03811660009081526015602052604081205463ffffffff9081169081106114545760405162461bcd60e51b815260206004820152601760248201527f504f534954494f4e5f494e4445585f4f564552464c4f570000000000000000006044820152606401610c3a565b600b8163ffffffff16101561146c5750600b92915050565b611477816001615936565b9392505050565b6000546001600160a01b031633146114c55760405162461bcd60e51b815260206004820152600a60248201526927a7262cafa0a226a4a760b11b6044820152606401610c3a565b600081116115065760405162461bcd60e51b815260206004820152600e60248201526d43414e4e4f545f42455f5a45524f60901b6044820152606401610c3a565b6060600183600381111561151c5761151c615487565b03611555575060408051808201909152601281527136b0bc2a3930b232b9a832b92a3930b232b960711b602082015260058290556116d0565b600283600381111561156957611569615487565b036115f857606461157e620186a0603261595a565b6115889190615987565b8210156115d15760405162461bcd60e51b81526020600482015260176024820152762a2920a222afa820a920a6afa922a9aa2924a1aa24a7a760491b6044820152606401610c3a565b506040805180820190915260068082526536b0bc29b62360d11b60208301528290556116d0565b600383600381111561160c5761160c615487565b0361169a5761161f620186a0600261595a565b8210156116685760405162461bcd60e51b81526020600482015260176024820152762a2920a222afa820a920a6afa922a9aa2924a1aa24a7a760491b6044820152606401610c3a565b5060408051808201909152601081526f36b0bc29b0b734ba3ca83937b334ba2360811b602082015260078290556116d0565b60405162461bcd60e51b815260206004820152600b60248201526a155394d5541413d495115160aa1b6044820152606401610c3a565b806040516116de919061599b565b604051908190038120838252907f8cf3e35f6221b16e1670a3413180c9484bf5aa71787905909fa82a6a2662e9ab9060200160405180910390a2505050565b6016602052816000526040600020818154811061173957600080fd5b90600052602060002001600091509150505481565b6001600160a01b0381166000908152601660209081526040918290208054835181840281018401909452808452606093928301828280156117ae57602002820191906000526020600020905b81548152602001906001019080831161179a575b50505050509050919050565b6004805460405163419a519360e01b815233928101929092526001600160a01b03169063419a519390602401602060405180830381865afa158015611803573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118279190615779565b6118735760405162461bcd60e51b815260206004820152601a60248201527f212854726164657273506f7274616c7c7c5472696767657273290000000000006044820152606401610c3a565b6111fb338484613dc5565b6004805460405163419a519360e01b815233928101929092526001600160a01b03169063419a519390602401602060405180830381865afa1580156118c7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118eb9190615779565b6119375760405162461bcd60e51b815260206004820152601a60248201527f212854726164657273506f7274616c7c7c5472696767657273290000000000006044820152606401610c3a565b6119456064620186a0615987565b81111561198b5760405162461bcd60e51b81526020600482015260146024820152734645455f4652414354494f4e5f544f4f5f42494760601b6044820152606401610c3a565b6000838152600d60209081526040808320815160e08101909252805482526001810154919290919083019060ff1660058111156119ca576119ca615487565b60058111156119db576119db615487565b8152600191909101546001600160401b036101008204811660208085019190915263ffffffff600160481b8404811660408087019190915260ff600160681b86041615156060870152600160701b85049093166080860152600160b01b90930490921660a0909301929092526000878152600d9091522054909150611a725760405162461bcd60e51b8152600401610c3a906159b7565b6000848152600c6020908152604091829020825160808101845281546001600160a01b038082168352600160a01b820461ffff1694830194909452600160b01b900463ffffffff16938101939093526001908101549091166060830152846002811115611ae157611ae1615487565b03611b4357600182602001516005811115611afe57611afe615487565b14611b3e5760405162461bcd60e51b815260206004820152601060248201526f2727aa2fa6a0a925a2aa2fa7a92222a960811b6044820152606401610c3a565b611bee565b6002846002811115611b5757611b57615487565b03611bb357600282602001516005811115611b7457611b74615487565b14611b3e5760405162461bcd60e51b815260206004820152600f60248201526e2727aa2fa624a6a4aa2fa7a92222a960891b6044820152606401610c3a565b60405162461bcd60e51b815260206004820152601060248201526f57524f4e475f4f524445525f5459504560801b6044820152606401610c3a565b611c0d8582600001518360600151856000015186606001518833613ed6565b5050505050565b6001600160a01b0382166000908152601160209081526040808320848452825291829020805483518184028101840190945280845260609392830182828015611c8657602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311611c68575b505050505090505b92915050565b6004805460405163a5a2ed3760e01b815233928101929092526001600160a01b03169063a5a2ed3790602401602060405180830381865afa158015611cdd573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d019190615779565b611d1d5760405162461bcd60e51b8152600401610c3a906158fd565b6000848152600d60209081526040808320815160e08101909252805482526001810154919290919083019060ff166005811115611d5c57611d5c615487565b6005811115611d6d57611d6d615487565b8152600191909101546001600160401b0361010082048116602084015263ffffffff600160481b83048116604085015260ff600160681b84041615156060850152600160701b83049091166080840152600160b01b9091041660a0909101528051909150611ded5760405162461bcd60e51b8152600401610c3a906159b7565b6000858152600e60209081526040808320815160808101835290546001600160401b038082168352600160401b8204811694830194909452600160801b8104841692820192909252600160c01b90910490911660608201529080806002886003811115611e5c57611e5c615487565b03611ebf578460800151611e895783606001516001600160401b0316866001600160401b03161015611ea4565b83606001516001600160401b0316866001600160401b031611155b925083606001516001600160401b0316915060029050611fa4565b6001886003811115611ed357611ed3615487565b03611f36578460800151611f005783604001516001600160401b0316866001600160401b03161115611f1b565b83604001516001600160401b0316866001600160401b031610155b925083604001516001600160401b0316915060019050611fa4565b6003886003811115611f4a57611f4a615487565b03611f66575060019150506001600160401b0384166003611fa4565b60405162461bcd60e51b81526020600482015260136024820152722ba927a723afa624a6a4aa2faa2924a3a3a2a960691b6044820152606401610c3a565b82611fe15760405162461bcd60e51b815260206004820152600d60248201526c2320a629a2afaa2924a3a3a2a960991b6044820152606401610c3a565b6000806000611ff18c8686613fa8565b91945092509050600384600481111561200c5761200c615487565b0361207957876080015161202c5780896001600160401b0316101561203a565b80896001600160401b031611155b9550856120795760405162461bcd60e51b815260206004820152600d60248201526c2320a629a2afaa2924a3a3a2a960991b6044820152606401610c3a565b8a600381111561208b5761208b615487565b604080516001600160401b038c16815260208101849052908101859052606081018490528d907fe67823c5c7b61d690bab4b46031d192b68f898b47bdf7daffbddff8e24aaf9bd9060800160405180910390a3505050505050505050505050565b6000546001600160a01b031633146121335760405162461bcd60e51b815260206004820152600a60248201526927a7262cafa0a226a4a760b11b6044820152606401610c3a565b600082815260086020526040808220805460ff19168415159081179091559051909184917f996384f9c771a575699aadc5e543fb849613b350a1b29584a1ecca98d2cfc1709190a35050565b601160205282600052604060002060205281600052604060002081815481106121a757600080fd5b6000918252602090912001546001600160a01b0316925083915050565b6121d26064620186a0615987565b81565b6004805460405163731aa5f960e01b815233928101929092526001600160a01b03169063731aa5f990602401602060405180830381865afa15801561221e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122429190615779565b61225e5760405162461bcd60e51b8152600401610c3a90615796565b6000858152600d602052604090206002600182015460ff16600581111561228757612287615487565b146122a45760405162461bcd60e51b8152600401610c3a906159e1565b6000868152600c6020908152604080832054600160a01b900461ffff168352600890915290205460ff16156122eb5760405162461bcd60e51b8152600401610c3a906157be565b61232d81600101600d9054906101000a900460ff16866001600160401b0316866001600160401b0316866001600160401b0316866001600160401b03166131fa565b60018101805468ffffffffffffffff001916610100426001600160401b0390811691909102919091179091556000878152600e6020908152604080832080546001600160801b0316600160801b8987169081026001600160c01b031691909117600160c01b898816908102919091178355600f85529483902080548c88166001600160801b03199091168117600160401b988d169889021782558451928352948201959095529182019290925260608101939093529188907f098a3c0f7acdf2c147440d705e162d395db886273731a238b250793cde346d859060800160405180910390a25050505050505050565b6004546001600160a01b031633146124625760405162461bcd60e51b815260206004820152600960248201526821526567697374727960b81b6044820152606401610c3a565b6001600160a01b038381166000908152600a602052604090205416156124ca5760405162461bcd60e51b815260206004820152601760248201527f41535345545f414c52454144595f535550504f525445440000000000000000006044820152606401610c3a565b6001600160a01b038084166000818152600a6020908152604080832080548689166001600160a01b03199182168117909255600b9093528184208054968816969093168617909255519092917fe34fb4592f12d191480ae66f1051ba82ee53c518b07f632579da8d40a74c77c891a4505050565b60408051606095861b6bffffffffffffffffffffffff199081166020808401919091529590961b909516603486015260f09290921b6001600160f01b031916604885015260e01b6001600160e01b031916604a8401528051602e818503018152604e9093019052815191012090565b6004805460405163a5a2ed3760e01b815233928101929092526001600160a01b03169063a5a2ed3790602401602060405180830381865afa1580156125f6573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061261a9190615779565b6126365760405162461bcd60e51b8152600401610c3a906158fd565b6000848152600d60209081526040808320600e8352818420600c845293829020825160808101845281546001600160a01b038082168352600160a01b820461ffff1696830196909652600160b01b900463ffffffff169381019390935260010154909216606082015281549192916126c05760405162461bcd60e51b8152600401610c3a906159b7565b6003600184015460ff1660058111156126db576126db615487565b146126f85760405162461bcd60e51b8152600401610c3a906159e1565b80516001600160a01b039081166000908152600b60205260408120549091169080600189600281111561272d5761272d615487565b036129e85760006127ce846001600160a01b0316631cb92ed36040518163ffffffff1660e01b8152600401602060405180830381865afa158015612775573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061279991906158e4565b6001890154600160701b81046001600160401b031690600160481b810463ffffffff16908d90600160681b900460ff166141ac565b9050886001600160401b0316816001600160401b0316146128235760405162461bcd60e51b815260206004820152600f60248201526e4241445f4649454c445f56414c554560881b6044820152606401610c3a565b85546001600160401b03600160801b9091048116908216036128715760405162461bcd60e51b8152602060048201526007602482015266053414d455f54560cc1b6044820152606401610c3a565b8092508560000160189054906101000a90046001600160401b03169150428660000160006101000a8154816001600160401b0302191690836001600160401b03160217905550836001600160a01b0316633cdc20f88c876060015188602001518b600001548c60010160099054906101000a900463ffffffff168d600101600d9054906101000a900460ff168e600101600e9054906101000a90046001600160401b03168e60000160109054906101000a90046001600160401b03168c6040518a63ffffffff1660e01b81526004016129b0999897969594939291909889526001600160a01b0397909716602089015261ffff959095166040880152606087019390935263ffffffff919091166080860152151560a08501526001600160401b0390811660c085015290811660e0840152166101008201526101200190565b600060405180830381600087803b1580156129ca57600080fd5b505af11580156129de573d6000803e3d6000fd5b5050505050612b79565b60028960028111156129fc576129fc615487565b0361169a576000612a9d846001600160a01b0316631cb92ed36040518163ffffffff1660e01b8152600401602060405180830381865afa158015612a44573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a6891906158e4565b6001890154600160701b81046001600160401b031690600160481b810463ffffffff16908d90600160681b900460ff1661427e565b9050886001600160401b0316816001600160401b031614612af25760405162461bcd60e51b815260206004820152600f60248201526e4241445f4649454c445f56414c554560881b6044820152606401610c3a565b85546001600160401b03600160c01b909104811690821603612b405760405162461bcd60e51b815260206004820152600760248201526614d0535157d4d360ca1b6044820152606401610c3a565b8554426001600160401b03908116600160401b026fffffffffffffffff0000000000000000198316178855600160801b90910416925090505b60018601546000906001600160401b03808a16600160701b9092041611612bb4576001870154600160701b90046001600160401b0316612bb6565b875b60018801546001600160401b0391821692506000918a8116600160701b9092041610612bf6576001880154600160701b90046001600160401b0316612bf8565b885b6001600160401b03169050612c3388600101600d9054906101000a900460ff168383876001600160401b0316876001600160401b03166131fa565b86546001600160401b03858116600160801b0267ffffffffffffffff60801b19918616600160c01b02919091166001600160801b03909216919091171787558a6002811115612c8457612c84615487565b866020015161ffff168d7f90bbb7e2b715065bd66ba75a34fca9b65694d5e75327dd0873a5e3e6883776678b600101600d9054906101000a900460ff168e604051612ce492919091151582526001600160401b0316602082015260400190565b60405180910390a4505050505050505050505050565b6004805460405163a5a2ed3760e01b815233928101929092526001600160a01b03169063a5a2ed3790602401602060405180830381865afa158015612d43573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612d679190615779565b612d835760405162461bcd60e51b8152600401610c3a906158fd565b6000838152600f6020908152604091829020825160808101845290546001600160401b038082168352600160401b82048116938301849052600160801b8204811694830194909452600160c01b90049092166060830152612df65760405162461bcd60e51b8152600401610c3a906159b7565b80516001600160401b0380841691161180612e265750816001600160401b031681602001516001600160401b0316105b15612e3c57612e3730856001613dc5565b612ea5565b6000806000612e5687866001600160401b03166004613fa8565b6040805182815260208101859052908101839052929550909350915087907f9912c2c8197504aea5a1b52b98eeae3f4aecabe190feebc292455c355d4297cb9060600160405180910390a25050505b50505050565b6004805460405163731aa5f960e01b815233928101929092526001600160a01b03169063731aa5f990602401602060405180830381865afa158015612ef4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612f189190615779565b612f345760405162461bcd60e51b8152600401610c3a90615796565b6000838152600d602052604090208054612f605760405162461bcd60e51b8152600401610c3a906159b7565b6003600182015460ff166005811115612f7b57612f7b615487565b14612f985760405162461bcd60e51b8152600401610c3a906159e1565b6001810180546001600160401b034281166101000268ffffffffffffffffff19909216919091176004179091556000858152600f60209081526040918290208054868516600160401b81026001600160801b03199092169589169586179190911782558351948552918401919091529186917fb7bb5d6820a30953d2858e9c448319c4cebbc70c347961e25f1adfff46566689910160405180910390a25050505050565b6004805460405163a5a2ed3760e01b815233928101929092526001600160a01b03169063a5a2ed3790602401602060405180830381865afa158015613085573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906130a99190615779565b6130c55760405162461bcd60e51b8152600401610c3a906158fd565b6111fb8360018484613731565b6040805160a081018252600080825260208083018290528284018290526060830182905260808301829052848252600d8152838220845160e0810190955280548552600181015493949293909183019060ff16600581111561313657613136615487565b600581111561314757613147615487565b8152600191909101546001600160401b036101008204811660208085019190915263ffffffff600160481b8404811660408087019190915260ff600160681b8604161515606080880191909152600160701b86048516608080890191909152600160b01b909604831660a09788015287518a52878101519092168984015294860151831690880152938201511515868401526000968752600e909352942054600160801b90041692820192909252919050565b8284111561323c5760405162461bcd60e51b815260206004820152600f60248201526e4d494e5f4d41585f5245564552534560881b6044820152606401610c3a565b81158061325557508461325157838210613255565b8282115b61328c5760405162461bcd60e51b8152602060048201526008602482015267057524f4e475f54560c41b6044820152606401610c3a565b8015806132a55750846132a1578281116132a5565b8381105b611c0d5760405162461bcd60e51b815260206004820152600860248201526715d493d391d7d4d360c21b6044820152606401610c3a565b6000806132e8846113e4565b90506132f68585858461253e565b6000818152600c60205260408120805492945091600160b01b900463ffffffff169003613444578054600180830180546001600160a01b0319166001600160a01b038981169182179092559089166001600160b01b031990931692909217600160a01b61ffff8816021763ffffffff60b01b1916600160b01b63ffffffff86169081029190911784556000838152601560209081526040808320805463ffffffff19169094179093556016815282822080549485018155808352818320909401889055925493815260178352818120878252909252902055827f487ea6416487448c3ce943d750c8f67a275e4d8f26ac4093803bf63354b7006f8260405161343b919081546001600160a01b03808216835260a082901c61ffff16602084015260b09190911c63ffffffff166040830152600190920154909116606082015260800190565b60405180910390a25b50935093915050565b80156111fb576040516370a0823160e01b81523060048201526000906001600160a01b038516906370a0823190602401602060405180830381865afa15801561349a573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906134be91906158e4565b90506134d56001600160a01b03851684308561433b565b6040516370a0823160e01b81523060048201526000906001600160a01b038616906370a0823190602401602060405180830381865afa15801561351c573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061354091906158e4565b90508261354d8383615a06565b14611c0d5760405162461bcd60e51b815260206004820152601560248201527411125117d393d517d49150d152559157d1561050d5605a1b6044820152606401610c3a565b6001600160a01b03811660009081526016602052604090205460010361134b57601380546001810182557f66de8ffda797e3de9c05e8fc57b3bf0ec28a930d40b0d285d93c06501cf6a0900180546001600160a01b0319166001600160a01b039390931692831790555460009182526014602052604090912055565b6001600160a01b03831660009081526009602052604081208184600381111561363957613639615487565b600381111561364a5761364a615487565b8152602001908152602001600020549050600060096000866001600160a01b03166001600160a01b03168152602001908152602001600020600085600381111561369657613696615487565b60038111156136a7576136a7615487565b81526020810191909152604001600020556136cc6001600160a01b03851683836143a2565b816001600160a01b03168360038111156136e8576136e8615487565b856001600160a01b03167f0e80b333c403be7cb491b3ba7f29fe30014c594adbcbec04272291b2f72f6e6a8460405161372391815260200190565b60405180910390a450505050565b6000848152600f60209081526040808320815160808101835290546001600160401b038082168352600160401b8204811683860152600160801b8204811683850152600160c01b909104166060820152878452600d8352818420825160e0810190935280548352600181015491949390919083019060ff1660058111156137ba576137ba615487565b60058111156137cb576137cb615487565b8152600191909101546001600160401b0361010082048116602084015263ffffffff600160481b83048116604085015260ff600160681b84041615156060850152600160701b83049091166080840152600160b01b9091041660a090910152805190915061384b5760405162461bcd60e51b8152600401610c3a906159b7565b6000868152600c60209081526040808320815160808101835281546001600160a01b038082168352600160a01b820461ffff16838701819052600160b01b90920463ffffffff1683860152600190930154909216606082015290845260089092529091205460ff16156138d05760405162461bcd60e51b8152600401610c3a906157be565b8560058111156138e2576138e2615487565b826020015160058111156138f8576138f8615487565b146139155760405162461bcd60e51b8152600401610c3a906159e1565b600186600581111561392957613929615487565b036139cd5782516001600160401b038087169116118061395e5750846001600160401b031683602001516001600160401b0316105b156139c8576040516001600160401b038616815287907f82c058420d58fdfcaa301ef645c860145096603267b7b7ac02831312ac2ab4479060200160405180910390a26139c08782600001518360600151856000015186606001518930613ed6565b505050612ea5565b613a53565b60028660058111156139e1576139e1615487565b0361169a5782516001600160401b03808716911611801590613a195750846001600160401b031683602001516001600160401b031610155b6139c85760405162461bcd60e51b815260206004820152600b60248201526a50524943455f52414e474560a81b6044820152606401610c3a565b80516001600160a01b039081166000908152600b6020526040812054606085015160808601519190931692613a8d918b9185918b8a6143d3565b9050816001600160a01b03166352713f678a85606001518660200151886000015189606001518a6080015188604001518f6040518963ffffffff1660e01b8152600401613b339897969594939291909788526001600160a01b0396909616602088015261ffff949094166040870152606086019290925263ffffffff166080850152151560a08401526001600160401b0390811660c08401521660e08201526101000190565b60408051808303816000875af1925050508015613b6d575060408051601f3d908101601f19168201909252613b6a91810190615a19565b60015b613c7157613b79615a3d565b806308c379a003613bb25750613b8d615a58565b80613b985750613bb4565b8060405162461bcd60e51b8152600401610c3a91906152e5565b505b3d808015613bde576040519150601f19603f3d011682016040523d82523d6000602084013e613be3565b606091505b50632eb752bf60e21b613bf582615ae1565b6001600160e01b0319160361038e57602481015160448201516040518c907ff2c847d05971bf83dd347e0732c1ef893111318fb2540f5fe6f9783cb8d6ae5b90613c429085908590615b18565b60405180910390a2613c698c876000015188606001518a600001518b606001518e30613ed6565b505050613dba565b60008b8152600d602090815260408083206001810180546001600160401b038f16600160701b0267ffffffffffffffff60701b19909116179055895160109093529220558651613cc2908490615a06565b8155600180820180546001600160401b0342166101000268ffffffffffffffffff199091161760031790558651613d05918e9190613d008688615a06565b614756565b85516001600160a01b038082166000908152600a6020526040902054613d2d9291168461480a565b60008c8152600f60205260408082209190915584810151606086015191518e927fdd0164525ce1bb6897fbd7000a7d93633016a05f498d94903ca1fcc7911cdf8192613dae928f9290899089906001600160401b03958616815293851660208501529190931660408301526060820192909252608081019190915260a00190565b60405180910390a25050505b505050505050505050565b6000828152600d6020526040902054613df05760405162461bcd60e51b8152600401610c3a906159b7565b6000828152600f60205260408120556001816001811115613e1357613e13615487565b03611bb35760046000838152600d602052604090206001015460ff166005811115613e4057613e40615487565b14613e5d5760405162461bcd60e51b8152600401610c3a906159e1565b6000828152600d6020908152604080832060010180546001600160401b0342166101000268ffffffffffffffffff19909116176003179055519182526001600160a01b0385169184917f2cb817145129b5c52a6dc17e0605285c54d9c258fbf0a21e78bfff4e00813333910160405180910390a3505050565b6000878152600d6020908152604080832083815560010180546001600160d01b0319169055600f9091528120819055613f1e613f188663ffffffff8716614824565b8461483c565b9050613f2d8888600384614756565b613f368661484c565b613f4086896149a3565b6000613f4c8287615a06565b9050613f5988888361480a565b826001600160a01b0316897f0732bc6c415e7a220efee5f866e1e91a1335745b97373898ffecfddbc708a3e784604051613f9591815260200190565b60405180910390a3505050505050505050565b6000838152600c60209081526040808320815160808101835281546001600160a01b038082168352600160a01b820461ffff1695830195909552600160b01b900463ffffffff16928101929092526001015490911660608201528190819081614010886130d2565b80519091506140315760405162461bcd60e51b8152600401610c3a906159b7565b6000806000806140448c87878e8e614ace565b935093509350935084600001518311156140c6578451600090620186a061406b8287615a06565b614075919061595a565b61407f9190615987565b90506007548111156140c45760405162461bcd60e51b815260206004820152600e60248201526d1253959053125117d41493d1925560921b6044820152606401610c3a565b505b81975082985080965084600001518411156141235760405162461bcd60e51b815260206004820152601e60248201527f434c4f53455f4645455f4c41524745525f5448414e5f504f534954494f4e00006044820152606401610c3a565b6141348c8760000151600287614756565b614141866060015161484c565b61414f86606001518d6149a3565b60008c8152600d6020908152604080832083815560010180546001600160d01b0319169055600e8252808320839055601090915281205560608601518651865161419d9291908c9088614b80565b50505050505093509350939050565b60006001600160401b03831615806141d657508560070b6141d08787868689614ce9565b60070b12155b15614272576000620186a0856001600160401b03166064896001600160401b0316896001600160401b031661420b919061595a565b614215919061595a565b61421f9190615987565b6142299190615987565b90508261426057856001600160401b0316816001600160401b0316111561425157600061426a565b61425b8187615b36565b61426a565b61426a8187615b56565b915050614275565b50815b95945050505050565b60006001600160401b03831615806142b357506006546142a090600019615b76565b6142ad8787868689614ce9565b60070b13155b15614272576000620186a0856001600160401b03166064600654896001600160401b03166142e1919061595a565b6142eb919061595a565b6142f59190615987565b6142ff9190615987565b9050826143105761425b8187615b56565b856001600160401b0316816001600160401b0316111561433157600061426a565b61426a8187615b36565b6040516001600160a01b038481166024830152838116604483015260648201839052612ea59186918216906323b872dd906084015b604051602081830303815290604052915060e01b6020820180516001600160e01b038381831617835250505050614d75565b6040516001600160a01b038381166024830152604482018390526111fb91859182169063a9059cbb90606401614370565b6040805160808101825260008082526020820181905291810182905260608101919091526000866001600160a01b0316631cb92ed36040518163ffffffff1660e01b8152600401602060405180830381865afa158015614437573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061445b91906158e4565b6000898152600e6020908152604091829020825160808101845290546001600160401b038082168352600160401b8204811693830193909352600160801b81048316938201849052600160c01b90049091166060820152935090915015806144ce575060408301516001600160401b0316155b61451a5760405162461bcd60e51b815260206004820152601760248201527f4d554c5449504c455f54505f444546494e4954494f4e530000000000000000006044820152606401610c3a565b60608201516001600160401b0316158061453f575060608301516001600160401b0316155b61458b5760405162461bcd60e51b815260206004820152601760248201527f4d554c5449504c455f534c5f444546494e4954494f4e530000000000000000006044820152606401610c3a565b60408301516001600160401b0316156146055760006145b58585604001518963ffffffff16614dd8565b9050856145eb57846001600160401b0316816001600160401b0316106145dc5760006145f5565b6145e68186615b36565b6145f5565b6145f58186615b56565b6001600160401b03166040840152505b60608301516001600160401b03161561467f57600061462f8585606001518963ffffffff16614dd8565b905085614645576146408186615b56565b61466f565b846001600160401b0316816001600160401b03161061466557600061466f565b61466f8186615b36565b6001600160401b03166060840152505b61469681858863ffffffff168560400151896141ac565b6001600160401b0390811660408401524216825260608201516146c5908290869063ffffffff8a16908961427e565b6001600160401b0390811660608401908152428216602080860191825260009b8c52600e905260409a8b90208551815492519c87015193518516600160c01b026001600160c01b03948616600160801b02949094166001600160801b039d8616600160401b026001600160801b03199094169190951617919091179a909a1691909117179097559695505050505050565b8015612ea5576001600160a01b0383166000908152600960205260408120829184600381111561478857614788615487565b600381111561479957614799615487565b815260200190815260200160002060008282546147b69190615ba6565b9091555082905060038111156147ce576147ce615487565b836001600160a01b0316857f52aab89a61b38ba21feecda2012e9c20aec817e5d709d0633c3fd693bb949cbb8460405161372391815260200190565b80156111fb576111fb6001600160a01b03841683836143a2565b60006064614832838561595a565b6114779190615987565b6000620186a0614832838561595a565b6001600160a01b03811660009081526016602052604090205460010361134b5760135460011015614954576001600160a01b038116600090815260146020526040902054601380546148a090600190615a06565b815481106148b0576148b0615bb9565b6000918252602090912001546001600160a01b031660136148d2600184615a06565b815481106148e2576148e2615bb9565b6000918252602082200180546001600160a01b0319166001600160a01b0393909316929092179091558190601490601361491d600185615a06565b8154811061492d5761492d615bb9565b60009182526020808320909101546001600160a01b03168352820192909252604001902055505b6001600160a01b038116600090815260146020526040812055601380548061497e5761497e615bcf565b600082815260209020810160001990810180546001600160a01b031916905501905550565b6001600160a01b038216600090815260176020908152604080832084845290915290205480156111fb576001600160a01b0383166000908152601660205260408120906149f1600184615a06565b8254909150614a0290600190615a06565b811015614a7e5781546000908390614a1c90600190615a06565b81548110614a2c57614a2c615bb9565b9060005260206000200154905080838381548110614a4c57614a4c615bb9565b60009182526020808320909101929092556001600160a01b038816815260178252604080822093825292909152208390555b81805480614a8e57614a8e615bcf565b6000828152602080822083016000199081018390559092019092556001600160a01b03871682526017815260408083208784529091528120555050505050565b83516001600160a01b039081166000908152600b60209081526040808320546060890151928901519151630f1a62d160e31b8152939485948594859493909216926378d3168892614b2a928e92908d908d908d90600401615be5565b6080604051808303816000875af1158015614b49573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614b6d9190615c3c565b929c919b50995090975095505050505050565b6001600160a01b038085166000908152600a602052604081205490911690838510614c2957614baf8385615a06565b90506000614bbd8287615a06565b6040516321d4911360e01b81526001600160a01b038a8116600483015260248201839052919250908416906321d4911390604401600060405180830381600087803b158015614c0b57600080fd5b505af1158015614c1f573d6000803e3d6000fd5b5050505050614cd5565b50836000614c378286615a06565b905083811115614c5a57614c558784614c508785615a06565b61480a565b614cd3565b6001600160a01b0383166321d4911330614c748488615a06565b6040516001600160e01b031960e085901b1681526001600160a01b0390921660048301526024820152604401600060405180830381600087803b158015614cba57600080fd5b505af1158015614cce573d6000803e3d6000fd5b505050505b505b614ce086888361480a565b50505050505050565b6000858184614d0157614cfc8688615c72565b614d0b565b614d0b8787615c72565b905060008460070b620186a08360070b614d259190615b76565b614d2f9190615b76565b90506000600789900b614d43606484615ca1565b614d4d9190615ca1565b90508094508360070b8560070b13614d655784614d67565b835b9a9950505050505050505050565b6000614d8a6001600160a01b03841683614e27565b90508051600014158015614daf575080806020019051810190614dad9190615779565b155b156111fb57604051635274afe760e01b81526001600160a01b0384166004820152602401610c3a565b600080826001600160401b0316620186a06064866001600160401b0316886001600160401b0316614e09919061595a565b614e13919061595a565b614e1d9190615987565b6142759190615987565b60606114778383600084600080856001600160a01b03168486604051614e4d919061599b565b60006040518083038185875af1925050503d8060008114614e8a576040519150601f19603f3d011682016040523d82523d6000602084013e614e8f565b606091505b5091509150614e9f868383614ea9565b9695505050505050565b606082614ebe57614eb982614f05565b611477565b8151158015614ed557506001600160a01b0384163b155b15614efe57604051639996b31560e01b81526001600160a01b0385166004820152602401610c3a565b5080611477565b805115614f155780518082602001fd5b604051630a12f52160e11b815260040160405180910390fd5b6003811061134b57600080fd5b606081018181106001600160401b0382111715614f6857634e487b7160e01b600052604160045260246000fd5b60405250565b61012081016001600160401b0381118282101715614f6857634e487b7160e01b600052604160045260246000fd5b601f8201601f191681016001600160401b0381118282101715614fcf57634e487b7160e01b600052604160045260246000fd5b6040525050565b604051614fe281614f6e565b90565b6001600160a01b038116811461134b57600080fd5b803561ffff8116811461500c57600080fd5b919050565b801515811461134b57600080fd5b803561500c81615011565b803563ffffffff8116811461500c57600080fd5b80356001600160401b038116811461500c57600080fd5b6000806000808486036101c081121561506d57600080fd5b853561507881614f2e565b94506060601f198201121561508c57600080fd5b60405161509881614f3b565b60208701356150a681614fe5565b81526150b460408801614ffa565b602082015260608701356150c781614fe5565b60408201529350610120607f1982018113156150e257600080fd5b6150ea614fd6565b91506150f86080880161501f565b825260a0870135602083015261511060c0880161502a565b604083015261512160e0880161503e565b606083015261010061513481890161503e565b608084015261514482890161503e565b60a0840152615156610140890161503e565b60c0840152615168610160890161503e565b60e084015261517a610180890161503e565b9083015250915061518e6101a0860161502a565b905092959194509250565b6000602082840312156151ab57600080fd5b813561147781614fe5565b6000602082840312156151c857600080fd5b5035919050565b6004811061134b57600080fd5b6000806000606084860312156151f157600080fd5b83356151fc81614fe5565b9250602084013561520c816151cf565b9150604084013561521c81614fe5565b809150509250925092565b60008060006060848603121561523c57600080fd5b8335925061524c6020850161503e565b9150604084013590509250925092565b6000806040838503121561526f57600080fd5b823561527a816151cf565b946020939093013593505050565b6000806040838503121561529b57600080fd5b82356152a681614fe5565b915060208301356152b6816151cf565b809150509250929050565b60005b838110156152dc5781810151838201526020016152c4565b50506000910152565b60208152600082518060208401526153048160408501602087016152c1565b601f01601f19169190910160400192915050565b6000806040838503121561532b57600080fd5b823561527a81614fe5565b6020808252825182820181905260009190848201906040850190845b8181101561536e57835183529284019291840191600101615352565b50909695505050505050565b60008060006060848603121561538f57600080fd5b833592506020840135600281106153a557600080fd5b929592945050506040919091013590565b6000806000606084860312156153cb57600080fd5b8335925060208401356153a581614f2e565b6020808252825182820181905260009190848201906040850190845b8181101561536e5783516001600160a01b0316835292840192918401916001016153f9565b6000806000806080858703121561543457600080fd5b843593506020850135615446816151cf565b92506154546040860161503e565b915061518e6060860161503e565b6000806040838503121561547557600080fd5b8235915060208301356152b681615011565b634e487b7160e01b600052602160045260246000fd5b600681106154ad576154ad615487565b9052565b87815260e081016154c5602083018961549d565b6001600160401b03968716604083015263ffffffff958616606083015293151560808201529190941660a08201529290911660c09092019190915292915050565b60008060006060848603121561551b57600080fd5b833561552681614fe5565b95602085013595506040909401359392505050565b60a08101615549828861549d565b6001600160401b0395909516602082015261ffff939093166040840152901515606083015263ffffffff16608090910152919050565b600080600080600060a0868803121561559757600080fd5b853594506155a76020870161503e565b93506155b56040870161503e565b92506155c36060870161503e565b91506155d16080870161503e565b90509295509295909350565b6000806000606084860312156155f257600080fd5b83356155fd81614fe5565b9250602084013561520c81614fe5565b6000806000806080858703121561562357600080fd5b843561562e81614fe5565b9350602085013561563e81614fe5565b925061564c60408601614ffa565b915061518e6060860161502a565b6000806000806080858703121561567057600080fd5b84359350602085013561544681614f2e565b60008060006060848603121561569757600080fd5b833592506156a76020850161503e565b91506156b56040850161503e565b90509250925092565b6000806000606084860312156156d357600080fd5b83356156de81614fe5565b925060208401356153a581614fe5565b8051825263ffffffff602082015116602083015260408101511515604083015260608101516001600160401b03808216606085015280608084015116608085015250505050565b60a08101611c8e82846156ee565b60608101615751828661549d565b6001600160401b039390931660208201526001600160a01b0391909116604090910152919050565b60006020828403121561578b57600080fd5b815161147781615011565b6020808252600e908201526d08551c9859195c9cd41bdc9d185b60921b604082015260600190565b6020808252600b908201526a1410525497d4105554d15160aa1b604082015260600190565b6101e081016157f2828861549d565b63ffffffff808716602084015260018060a01b0380875116604085015261ffff6020880151166060850152806040880151166080850152508451151560a0840152602085015160c08401528060408601511660e0840152506060840151610100615866818501836001600160401b03169052565b60808601516001600160401b0390811661012086015260a0870151811661014086015260c0870151811661016086015260e087015181166101808601529501519094166101a083015263ffffffff929092166101c090910152949350505050565b6000602082840312156158d957600080fd5b815161147781614fe5565b6000602082840312156158f657600080fd5b5051919050565b60208082526009908201526821547269676765727360b81b604082015260600190565b634e487b7160e01b600052601160045260246000fd5b63ffffffff81811683821601908082111561595357615953615920565b5092915050565b8082028115828204841417611c8e57611c8e615920565b634e487b7160e01b600052601260045260246000fd5b60008261599657615996615971565b500490565b600082516159ad8184602087016152c1565b9190910192915050565b60208082526010908201526f2727afa9aaa1a42fa827a9a4aa24a7a760811b604082015260600190565b6020808252600b908201526a57524f4e475f504841534560a81b604082015260600190565b81810381811115611c8e57611c8e615920565b60008060408385031215615a2c57600080fd5b505080516020909101519092909150565b600060033d1115614fe25760046000803e5060005160e01c90565b600060443d1015615a665790565b6040516003193d81016004833e81513d6001600160401b038160248401118184111715615a9557505050505090565b8285019150815181811115615aad5750505050505090565b843d8701016020828501011115615ac75750505050505090565b615ad660208286010187614f9c565b509095945050505050565b805160208201516001600160e01b03198082169291906004831015615b105780818460040360031b1b83161693505b505050919050565b6040810160128410615b2c57615b2c615487565b9281526020015290565b6001600160401b0382811682821603908082111561595357615953615920565b6001600160401b0381811683821601908082111561595357615953615920565b80820260008212600160ff1b84141615615b9257615b92615920565b8181058314821517611c8e57611c8e615920565b80820180821115611c8e57611c8e615920565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052603160045260246000fd5b8681526001600160a01b038616602082015261ffff851660408201526101408101615c1360608301866156ee565b8361010083015260058310615c2a57615c2a615487565b82610120830152979650505050505050565b60008060008060808587031215615c5257600080fd5b505082516020840151604085015160609095015191969095509092509050565b600782810b9082900b03677fffffffffffffff198112677fffffffffffffff82131715611c8e57611c8e615920565b600082615cb057615cb0615971565b600160ff1b821460001984141615615cca57615cca615920565b50059056fea26469706673582212201c75ffce6c5a12946abb22a00ed4d61e76b6f4bf5476bb6903d1b44aea3bf47b64736f6c63430008180033
Deployed Bytecode
0x608060405234801561001057600080fd5b506004361061038e5760003560e01c806382571409116101de578063b71f3cfe1161010f578063ece938cf116100ad578063f555f6971161007c578063f555f69714610aed578063f5f5ba7214610b0d578063f851a44014610b37578063f9b9484e14610b4a57600080fd5b8063ece938cf14610a5b578063ef6ecc5514610a64578063f2eb245e14610ac4578063f51f3fd314610ae457600080fd5b8063ddf474f1116100e9578063ddf474f1146109cd578063e640f33b14610a15578063eb48914014610a28578063ec7f8a3a14610a3b57600080fd5b8063b71f3cfe1461099c578063c07f9921146109a7578063ca3a3a82146109ba57600080fd5b806395be50501161017c578063a40d726811610156578063a40d726814610947578063aaf5eb681461095a578063acfd6b9214610969578063ad1f2b561461099457600080fd5b806395be5050146108a65780639ff69ffa14610921578063a2a25ea61461093457600080fd5b80638f7a8fb5116101b85780638f7a8fb5146107e257806390f24cac1461085d57806393a7f6a71461087057806394a1e6e51461089e57600080fd5b806382571409146107a657806386dc4975146107af5780638aa10435146107c257600080fd5b8063396f7b23116102c357806368f296a51161026157806376d901be1161023057806376d901be146107435780637b1039991461077657806380193b261461078957806380a7f3d41461079357600080fd5b806368f296a5146106c15780636e01af8d146106e7578063725b7d52146106fa57806374d8b78e1461071a57600080fd5b80634ebe5c331161029d5780634ebe5c33146105f35780635c60da1b14610606578063614d08f81461061957806366307a4f1461064657600080fd5b8063396f7b23146105ad5780633ad6f124146105c05780633b17a497146105d357600080fd5b80631ea9af6b1161033057806324b22a1f1161030a57806324b22a1f1461052c578063267822471461053f57806330d073d01461055257806338b903331461057d57600080fd5b80631ea9af6b146104e95780632457bc3a146104fc5780632485f3f11461050457600080fd5b8063135e563d1161036c578063135e563d1461048557806318fa4714146104985780631961aba0146104ad5780631d504dc6146104d657600080fd5b8063010570851461039357806303b90a87146103b9578063042e37c5146103fa575b600080fd5b6103a66103a1366004615055565b610bac565b6040519081526020015b60405180910390f35b6103e26103c7366004615199565b600b602052600090815260409020546001600160a01b031681565b6040516001600160a01b0390911681526020016103b0565b6104496104083660046151b6565b600c60205260009081526040902080546001909101546001600160a01b0380831692600160a01b810461ffff1692600160b01b90910463ffffffff16911684565b604080516001600160a01b03958616815261ffff909416602085015263ffffffff909216918301919091529190911660608201526080016103b0565b6103e26104933660046151b6565b611107565b6104ab6104a63660046151dc565b611131565b005b6103a66104bb366004615199565b6001600160a01b031660009081526016602052604090205490565b6104ab6104e4366004615199565b611200565b6104ab6104f7366004615227565b61134e565b6013546103a6565b610517610512366004615199565b6113e4565b60405163ffffffff90911681526020016103b0565b6104ab61053a36600461525c565b61147e565b6001546103e2906001600160a01b031681565b6103a6610560366004615288565b600960209081526000928352604080842090915290825290205481565b6105a0604051806040016040528060048152602001630313031360e41b81525081565b6040516103b091906152e5565b6003546103e2906001600160a01b031681565b6103a66105ce366004615318565b61171d565b6105e66105e1366004615199565b61174e565b6040516103b09190615336565b6104ab61060136600461537a565b6117ba565b6002546103e2906001600160a01b031681565b6105a06040518060400160405280600e81526020016d54726164696e67466c6f6f72563160901b81525081565b61068e6106543660046151b6565b600e602052600090815260409020546001600160401b0380821691600160401b8104821691600160801b8204811691600160c01b90041684565b604080516001600160401b03958616815293851660208501529184169183019190915290911660608201526080016103b0565b6105176106cf366004615199565b60156020526000908152604090205463ffffffff1681565b6104ab6106f53660046153b6565b61187e565b61070d610708366004615318565b611c14565b6040516103b091906153dd565b6103e2610728366004615199565b600a602052600090815260409020546001600160a01b031681565b6107666107513660046151b6565b60086020526000908152604090205460ff1681565b60405190151581526020016103b0565b6004546103e2906001600160a01b031681565b6103a6620186a081565b6104ab6107a136600461541e565b611c94565b6103a660075481565b6104ab6107bd366004615462565b6120ec565b6040805180820190915260048152630313031360e41b60208201526105a0565b61084a6107f03660046151b6565b600d602052600090815260409020805460019091015460ff808216916001600160401b03610100820481169263ffffffff600160481b8404811693600160681b810490921692600160701b83041691600160b01b90041687565b6040516103b097969594939291906154b1565b6103e261086b366004615506565b61217f565b61076661087e366004615199565b6001600160a01b039081166000908152600a602052604090205416151590565b6103a66121c4565b6109106108b43660046151b6565b6000908152600d6020818152604080842060010154600c835293205491905260ff8083169361010084046001600160401b031693600160a01b90930461ffff1692600160681b810490921691600160b01b900463ffffffff1690565b6040516103b095949392919061553b565b6104ab61092f36600461557f565b6121d5565b6104ab6109423660046155dd565b61241c565b6103a661095536600461560d565b61253e565b6103a6670de0b6b3a764000081565b6103a6610977366004615318565b601760209081526000928352604080842090915290825290205481565b6103a6606481565b6103a6633b9aca0081565b6104ab6109b536600461565a565b6125ad565b6104ab6109c8366004615682565b612cfa565b61068e6109db3660046151b6565b600f602052600090815260409020546001600160401b0380821691600160401b8104821691600160801b8204811691600160c01b90041684565b6104ab610a23366004615682565b612eab565b6104ab610a36366004615227565b61303c565b6103a6610a49366004615199565b60146020526000908152604090205481565b6103a660055481565b610aa7610a723660046156be565b601260209081526000938452604080852082529284528284209052825290205463ffffffff8082169164010000000090041682565b6040805163ffffffff9384168152929091166020830152016103b0565b6103a6610ad23660046151b6565b60106020526000908152604090205481565b6103a660065481565b610b00610afb3660046151b6565b6130d2565b6040516103b09190615735565b60408051808201909152600e81526d54726164696e67466c6f6f72563160901b60208201526105a0565b6000546103e2906001600160a01b031681565b610b9d610b583660046151b6565b6000908152600d60209081526040808320600190810154600c90935292209091015460ff8216926101009092046001600160401b0316916001600160a01b0390911690565b6040516103b093929190615743565b6004805460405163731aa5f960e01b815233928101929092526000916001600160a01b039091169063731aa5f990602401602060405180830381865afa158015610bfa573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c1e9190615779565b610c435760405162461bcd60e51b8152600401610c3a90615796565b60405180910390fd5b610c6b84604001516001600160a01b039081166000908152600a602052604090205416151590565b610cb75760405162461bcd60e51b815260206004820152601e60248201527f4e4f4e5f535550504f525445445f534554544c454d454e545f415353455400006044820152606401610c3a565b60208085015161ffff1660009081526008909152604090205460ff1615610cf05760405162461bcd60e51b8152600401610c3a906157be565b6001856002811115610d0457610d04615487565b1480610d2157506002856002811115610d1f57610d1f615487565b145b610d665760405162461bcd60e51b8152602060048201526016602482015275554e535550504f525445445f4f524445525f5459504560501b6044820152606401610c3a565b610dab836000015184606001516001600160401b031685608001516001600160401b03168660a001516001600160401b03168760c001516001600160401b03166131fa565b60055484516001600160a01b031660009081526016602052604090205410610e0d5760405162461bcd60e51b815260206004820152601560248201527426a0ac2faa2920a222a9afa822a92faa2920a222a960591b6044820152606401610c3a565b6000610e268560400151866000015187602001516132dc565b8092508193505050610e4585604001518660000151866020015161344d565b8451610e5090613592565b6000828152600d60205260409020805415610e975760405162461bcd60e51b8152602060048201526007602482015266125117d554d15160ca1b6044820152606401610c3a565b600180820180548751604089015163ffffffff908116600160481b026cffffffff00000000000000000019921515600160681b0260ff60681b19928b16600160b01b02929092166cffffffff0000000000000000ff60681b1990941693909317171617905560208601518255600090886002811115610f1857610f18615487565b14610f24576002610f27565b60015b9050808260010160006101000a81548160ff02191690836005811115610f4f57610f4f615487565b0217905550428260010160016101000a8154816001600160401b0302191690836001600160401b031602179055506000600e600086815260200190815260200160002090508660a001518160000160106101000a8154816001600160401b0302191690836001600160401b031602179055508660c001518160000160186101000a8154816001600160401b0302191690836001600160401b031602179055506000600f6000878152602001908152602001600020905087606001518160000160006101000a8154816001600160401b0302191690836001600160401b0316021790555087608001518160000160086101000a8154816001600160401b0302191690836001600160401b031602179055508760e001518160000160106101000a8154816001600160401b0302191690836001600160401b031602179055508761010001518160000160186101000a8154816001600160401b0302191690836001600160401b03160217905550857f835de04f5a930b169d6564c8f1c5f91f89abd9ea026b7488c94452abb900cc7484878c8c8c6040516110f29594939291906157e3565b60405180910390a25050505050949350505050565b6013818154811061111757600080fd5b6000918252602090912001546001600160a01b0316905081565b6004805460405163a8e36e5b60e01b81526001600160a01b038681169382019390935291169063a8e36e5b90602401602060405180830381865afa15801561117d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111a191906158c7565b6001600160a01b0316336001600160a01b0316146111f05760405162461bcd60e51b815260206004820152600c60248201526b10a332b2b9a6b0b730b3b2b960a11b6044820152606401610c3a565b6111fb83838361360e565b505050565b806001600160a01b031663f851a4406040518163ffffffff1660e01b8152600401602060405180830381865afa15801561123e573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061126291906158c7565b6001600160a01b0316336001600160a01b0316146112b15760405162461bcd60e51b815260206004820152600c60248201526b10b83937bc3c9730b236b4b760a11b6044820152606401610c3a565b806001600160a01b031663c1e803346040518163ffffffff1660e01b81526004016020604051808303816000875af11580156112f1573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061131591906158e4565b1561134b5760405162461bcd60e51b8152600401610c3a9060208082526004908201526319985a5b60e21b604082015260600190565b50565b6004805460405163a5a2ed3760e01b815233928101929092526001600160a01b03169063a5a2ed3790602401602060405180830381865afa158015611397573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113bb9190615779565b6113d75760405162461bcd60e51b8152600401610c3a906158fd565b6111fb8360028484613731565b6001600160a01b03811660009081526015602052604081205463ffffffff9081169081106114545760405162461bcd60e51b815260206004820152601760248201527f504f534954494f4e5f494e4445585f4f564552464c4f570000000000000000006044820152606401610c3a565b600b8163ffffffff16101561146c5750600b92915050565b611477816001615936565b9392505050565b6000546001600160a01b031633146114c55760405162461bcd60e51b815260206004820152600a60248201526927a7262cafa0a226a4a760b11b6044820152606401610c3a565b600081116115065760405162461bcd60e51b815260206004820152600e60248201526d43414e4e4f545f42455f5a45524f60901b6044820152606401610c3a565b6060600183600381111561151c5761151c615487565b03611555575060408051808201909152601281527136b0bc2a3930b232b9a832b92a3930b232b960711b602082015260058290556116d0565b600283600381111561156957611569615487565b036115f857606461157e620186a0603261595a565b6115889190615987565b8210156115d15760405162461bcd60e51b81526020600482015260176024820152762a2920a222afa820a920a6afa922a9aa2924a1aa24a7a760491b6044820152606401610c3a565b506040805180820190915260068082526536b0bc29b62360d11b60208301528290556116d0565b600383600381111561160c5761160c615487565b0361169a5761161f620186a0600261595a565b8210156116685760405162461bcd60e51b81526020600482015260176024820152762a2920a222afa820a920a6afa922a9aa2924a1aa24a7a760491b6044820152606401610c3a565b5060408051808201909152601081526f36b0bc29b0b734ba3ca83937b334ba2360811b602082015260078290556116d0565b60405162461bcd60e51b815260206004820152600b60248201526a155394d5541413d495115160aa1b6044820152606401610c3a565b806040516116de919061599b565b604051908190038120838252907f8cf3e35f6221b16e1670a3413180c9484bf5aa71787905909fa82a6a2662e9ab9060200160405180910390a2505050565b6016602052816000526040600020818154811061173957600080fd5b90600052602060002001600091509150505481565b6001600160a01b0381166000908152601660209081526040918290208054835181840281018401909452808452606093928301828280156117ae57602002820191906000526020600020905b81548152602001906001019080831161179a575b50505050509050919050565b6004805460405163419a519360e01b815233928101929092526001600160a01b03169063419a519390602401602060405180830381865afa158015611803573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118279190615779565b6118735760405162461bcd60e51b815260206004820152601a60248201527f212854726164657273506f7274616c7c7c5472696767657273290000000000006044820152606401610c3a565b6111fb338484613dc5565b6004805460405163419a519360e01b815233928101929092526001600160a01b03169063419a519390602401602060405180830381865afa1580156118c7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118eb9190615779565b6119375760405162461bcd60e51b815260206004820152601a60248201527f212854726164657273506f7274616c7c7c5472696767657273290000000000006044820152606401610c3a565b6119456064620186a0615987565b81111561198b5760405162461bcd60e51b81526020600482015260146024820152734645455f4652414354494f4e5f544f4f5f42494760601b6044820152606401610c3a565b6000838152600d60209081526040808320815160e08101909252805482526001810154919290919083019060ff1660058111156119ca576119ca615487565b60058111156119db576119db615487565b8152600191909101546001600160401b036101008204811660208085019190915263ffffffff600160481b8404811660408087019190915260ff600160681b86041615156060870152600160701b85049093166080860152600160b01b90930490921660a0909301929092526000878152600d9091522054909150611a725760405162461bcd60e51b8152600401610c3a906159b7565b6000848152600c6020908152604091829020825160808101845281546001600160a01b038082168352600160a01b820461ffff1694830194909452600160b01b900463ffffffff16938101939093526001908101549091166060830152846002811115611ae157611ae1615487565b03611b4357600182602001516005811115611afe57611afe615487565b14611b3e5760405162461bcd60e51b815260206004820152601060248201526f2727aa2fa6a0a925a2aa2fa7a92222a960811b6044820152606401610c3a565b611bee565b6002846002811115611b5757611b57615487565b03611bb357600282602001516005811115611b7457611b74615487565b14611b3e5760405162461bcd60e51b815260206004820152600f60248201526e2727aa2fa624a6a4aa2fa7a92222a960891b6044820152606401610c3a565b60405162461bcd60e51b815260206004820152601060248201526f57524f4e475f4f524445525f5459504560801b6044820152606401610c3a565b611c0d8582600001518360600151856000015186606001518833613ed6565b5050505050565b6001600160a01b0382166000908152601160209081526040808320848452825291829020805483518184028101840190945280845260609392830182828015611c8657602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311611c68575b505050505090505b92915050565b6004805460405163a5a2ed3760e01b815233928101929092526001600160a01b03169063a5a2ed3790602401602060405180830381865afa158015611cdd573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d019190615779565b611d1d5760405162461bcd60e51b8152600401610c3a906158fd565b6000848152600d60209081526040808320815160e08101909252805482526001810154919290919083019060ff166005811115611d5c57611d5c615487565b6005811115611d6d57611d6d615487565b8152600191909101546001600160401b0361010082048116602084015263ffffffff600160481b83048116604085015260ff600160681b84041615156060850152600160701b83049091166080840152600160b01b9091041660a0909101528051909150611ded5760405162461bcd60e51b8152600401610c3a906159b7565b6000858152600e60209081526040808320815160808101835290546001600160401b038082168352600160401b8204811694830194909452600160801b8104841692820192909252600160c01b90910490911660608201529080806002886003811115611e5c57611e5c615487565b03611ebf578460800151611e895783606001516001600160401b0316866001600160401b03161015611ea4565b83606001516001600160401b0316866001600160401b031611155b925083606001516001600160401b0316915060029050611fa4565b6001886003811115611ed357611ed3615487565b03611f36578460800151611f005783604001516001600160401b0316866001600160401b03161115611f1b565b83604001516001600160401b0316866001600160401b031610155b925083604001516001600160401b0316915060019050611fa4565b6003886003811115611f4a57611f4a615487565b03611f66575060019150506001600160401b0384166003611fa4565b60405162461bcd60e51b81526020600482015260136024820152722ba927a723afa624a6a4aa2faa2924a3a3a2a960691b6044820152606401610c3a565b82611fe15760405162461bcd60e51b815260206004820152600d60248201526c2320a629a2afaa2924a3a3a2a960991b6044820152606401610c3a565b6000806000611ff18c8686613fa8565b91945092509050600384600481111561200c5761200c615487565b0361207957876080015161202c5780896001600160401b0316101561203a565b80896001600160401b031611155b9550856120795760405162461bcd60e51b815260206004820152600d60248201526c2320a629a2afaa2924a3a3a2a960991b6044820152606401610c3a565b8a600381111561208b5761208b615487565b604080516001600160401b038c16815260208101849052908101859052606081018490528d907fe67823c5c7b61d690bab4b46031d192b68f898b47bdf7daffbddff8e24aaf9bd9060800160405180910390a3505050505050505050505050565b6000546001600160a01b031633146121335760405162461bcd60e51b815260206004820152600a60248201526927a7262cafa0a226a4a760b11b6044820152606401610c3a565b600082815260086020526040808220805460ff19168415159081179091559051909184917f996384f9c771a575699aadc5e543fb849613b350a1b29584a1ecca98d2cfc1709190a35050565b601160205282600052604060002060205281600052604060002081815481106121a757600080fd5b6000918252602090912001546001600160a01b0316925083915050565b6121d26064620186a0615987565b81565b6004805460405163731aa5f960e01b815233928101929092526001600160a01b03169063731aa5f990602401602060405180830381865afa15801561221e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122429190615779565b61225e5760405162461bcd60e51b8152600401610c3a90615796565b6000858152600d602052604090206002600182015460ff16600581111561228757612287615487565b146122a45760405162461bcd60e51b8152600401610c3a906159e1565b6000868152600c6020908152604080832054600160a01b900461ffff168352600890915290205460ff16156122eb5760405162461bcd60e51b8152600401610c3a906157be565b61232d81600101600d9054906101000a900460ff16866001600160401b0316866001600160401b0316866001600160401b0316866001600160401b03166131fa565b60018101805468ffffffffffffffff001916610100426001600160401b0390811691909102919091179091556000878152600e6020908152604080832080546001600160801b0316600160801b8987169081026001600160c01b031691909117600160c01b898816908102919091178355600f85529483902080548c88166001600160801b03199091168117600160401b988d169889021782558451928352948201959095529182019290925260608101939093529188907f098a3c0f7acdf2c147440d705e162d395db886273731a238b250793cde346d859060800160405180910390a25050505050505050565b6004546001600160a01b031633146124625760405162461bcd60e51b815260206004820152600960248201526821526567697374727960b81b6044820152606401610c3a565b6001600160a01b038381166000908152600a602052604090205416156124ca5760405162461bcd60e51b815260206004820152601760248201527f41535345545f414c52454144595f535550504f525445440000000000000000006044820152606401610c3a565b6001600160a01b038084166000818152600a6020908152604080832080548689166001600160a01b03199182168117909255600b9093528184208054968816969093168617909255519092917fe34fb4592f12d191480ae66f1051ba82ee53c518b07f632579da8d40a74c77c891a4505050565b60408051606095861b6bffffffffffffffffffffffff199081166020808401919091529590961b909516603486015260f09290921b6001600160f01b031916604885015260e01b6001600160e01b031916604a8401528051602e818503018152604e9093019052815191012090565b6004805460405163a5a2ed3760e01b815233928101929092526001600160a01b03169063a5a2ed3790602401602060405180830381865afa1580156125f6573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061261a9190615779565b6126365760405162461bcd60e51b8152600401610c3a906158fd565b6000848152600d60209081526040808320600e8352818420600c845293829020825160808101845281546001600160a01b038082168352600160a01b820461ffff1696830196909652600160b01b900463ffffffff169381019390935260010154909216606082015281549192916126c05760405162461bcd60e51b8152600401610c3a906159b7565b6003600184015460ff1660058111156126db576126db615487565b146126f85760405162461bcd60e51b8152600401610c3a906159e1565b80516001600160a01b039081166000908152600b60205260408120549091169080600189600281111561272d5761272d615487565b036129e85760006127ce846001600160a01b0316631cb92ed36040518163ffffffff1660e01b8152600401602060405180830381865afa158015612775573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061279991906158e4565b6001890154600160701b81046001600160401b031690600160481b810463ffffffff16908d90600160681b900460ff166141ac565b9050886001600160401b0316816001600160401b0316146128235760405162461bcd60e51b815260206004820152600f60248201526e4241445f4649454c445f56414c554560881b6044820152606401610c3a565b85546001600160401b03600160801b9091048116908216036128715760405162461bcd60e51b8152602060048201526007602482015266053414d455f54560cc1b6044820152606401610c3a565b8092508560000160189054906101000a90046001600160401b03169150428660000160006101000a8154816001600160401b0302191690836001600160401b03160217905550836001600160a01b0316633cdc20f88c876060015188602001518b600001548c60010160099054906101000a900463ffffffff168d600101600d9054906101000a900460ff168e600101600e9054906101000a90046001600160401b03168e60000160109054906101000a90046001600160401b03168c6040518a63ffffffff1660e01b81526004016129b0999897969594939291909889526001600160a01b0397909716602089015261ffff959095166040880152606087019390935263ffffffff919091166080860152151560a08501526001600160401b0390811660c085015290811660e0840152166101008201526101200190565b600060405180830381600087803b1580156129ca57600080fd5b505af11580156129de573d6000803e3d6000fd5b5050505050612b79565b60028960028111156129fc576129fc615487565b0361169a576000612a9d846001600160a01b0316631cb92ed36040518163ffffffff1660e01b8152600401602060405180830381865afa158015612a44573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a6891906158e4565b6001890154600160701b81046001600160401b031690600160481b810463ffffffff16908d90600160681b900460ff1661427e565b9050886001600160401b0316816001600160401b031614612af25760405162461bcd60e51b815260206004820152600f60248201526e4241445f4649454c445f56414c554560881b6044820152606401610c3a565b85546001600160401b03600160c01b909104811690821603612b405760405162461bcd60e51b815260206004820152600760248201526614d0535157d4d360ca1b6044820152606401610c3a565b8554426001600160401b03908116600160401b026fffffffffffffffff0000000000000000198316178855600160801b90910416925090505b60018601546000906001600160401b03808a16600160701b9092041611612bb4576001870154600160701b90046001600160401b0316612bb6565b875b60018801546001600160401b0391821692506000918a8116600160701b9092041610612bf6576001880154600160701b90046001600160401b0316612bf8565b885b6001600160401b03169050612c3388600101600d9054906101000a900460ff168383876001600160401b0316876001600160401b03166131fa565b86546001600160401b03858116600160801b0267ffffffffffffffff60801b19918616600160c01b02919091166001600160801b03909216919091171787558a6002811115612c8457612c84615487565b866020015161ffff168d7f90bbb7e2b715065bd66ba75a34fca9b65694d5e75327dd0873a5e3e6883776678b600101600d9054906101000a900460ff168e604051612ce492919091151582526001600160401b0316602082015260400190565b60405180910390a4505050505050505050505050565b6004805460405163a5a2ed3760e01b815233928101929092526001600160a01b03169063a5a2ed3790602401602060405180830381865afa158015612d43573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612d679190615779565b612d835760405162461bcd60e51b8152600401610c3a906158fd565b6000838152600f6020908152604091829020825160808101845290546001600160401b038082168352600160401b82048116938301849052600160801b8204811694830194909452600160c01b90049092166060830152612df65760405162461bcd60e51b8152600401610c3a906159b7565b80516001600160401b0380841691161180612e265750816001600160401b031681602001516001600160401b0316105b15612e3c57612e3730856001613dc5565b612ea5565b6000806000612e5687866001600160401b03166004613fa8565b6040805182815260208101859052908101839052929550909350915087907f9912c2c8197504aea5a1b52b98eeae3f4aecabe190feebc292455c355d4297cb9060600160405180910390a25050505b50505050565b6004805460405163731aa5f960e01b815233928101929092526001600160a01b03169063731aa5f990602401602060405180830381865afa158015612ef4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612f189190615779565b612f345760405162461bcd60e51b8152600401610c3a90615796565b6000838152600d602052604090208054612f605760405162461bcd60e51b8152600401610c3a906159b7565b6003600182015460ff166005811115612f7b57612f7b615487565b14612f985760405162461bcd60e51b8152600401610c3a906159e1565b6001810180546001600160401b034281166101000268ffffffffffffffffff19909216919091176004179091556000858152600f60209081526040918290208054868516600160401b81026001600160801b03199092169589169586179190911782558351948552918401919091529186917fb7bb5d6820a30953d2858e9c448319c4cebbc70c347961e25f1adfff46566689910160405180910390a25050505050565b6004805460405163a5a2ed3760e01b815233928101929092526001600160a01b03169063a5a2ed3790602401602060405180830381865afa158015613085573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906130a99190615779565b6130c55760405162461bcd60e51b8152600401610c3a906158fd565b6111fb8360018484613731565b6040805160a081018252600080825260208083018290528284018290526060830182905260808301829052848252600d8152838220845160e0810190955280548552600181015493949293909183019060ff16600581111561313657613136615487565b600581111561314757613147615487565b8152600191909101546001600160401b036101008204811660208085019190915263ffffffff600160481b8404811660408087019190915260ff600160681b8604161515606080880191909152600160701b86048516608080890191909152600160b01b909604831660a09788015287518a52878101519092168984015294860151831690880152938201511515868401526000968752600e909352942054600160801b90041692820192909252919050565b8284111561323c5760405162461bcd60e51b815260206004820152600f60248201526e4d494e5f4d41585f5245564552534560881b6044820152606401610c3a565b81158061325557508461325157838210613255565b8282115b61328c5760405162461bcd60e51b8152602060048201526008602482015267057524f4e475f54560c41b6044820152606401610c3a565b8015806132a55750846132a1578281116132a5565b8381105b611c0d5760405162461bcd60e51b815260206004820152600860248201526715d493d391d7d4d360c21b6044820152606401610c3a565b6000806132e8846113e4565b90506132f68585858461253e565b6000818152600c60205260408120805492945091600160b01b900463ffffffff169003613444578054600180830180546001600160a01b0319166001600160a01b038981169182179092559089166001600160b01b031990931692909217600160a01b61ffff8816021763ffffffff60b01b1916600160b01b63ffffffff86169081029190911784556000838152601560209081526040808320805463ffffffff19169094179093556016815282822080549485018155808352818320909401889055925493815260178352818120878252909252902055827f487ea6416487448c3ce943d750c8f67a275e4d8f26ac4093803bf63354b7006f8260405161343b919081546001600160a01b03808216835260a082901c61ffff16602084015260b09190911c63ffffffff166040830152600190920154909116606082015260800190565b60405180910390a25b50935093915050565b80156111fb576040516370a0823160e01b81523060048201526000906001600160a01b038516906370a0823190602401602060405180830381865afa15801561349a573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906134be91906158e4565b90506134d56001600160a01b03851684308561433b565b6040516370a0823160e01b81523060048201526000906001600160a01b038616906370a0823190602401602060405180830381865afa15801561351c573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061354091906158e4565b90508261354d8383615a06565b14611c0d5760405162461bcd60e51b815260206004820152601560248201527411125117d393d517d49150d152559157d1561050d5605a1b6044820152606401610c3a565b6001600160a01b03811660009081526016602052604090205460010361134b57601380546001810182557f66de8ffda797e3de9c05e8fc57b3bf0ec28a930d40b0d285d93c06501cf6a0900180546001600160a01b0319166001600160a01b039390931692831790555460009182526014602052604090912055565b6001600160a01b03831660009081526009602052604081208184600381111561363957613639615487565b600381111561364a5761364a615487565b8152602001908152602001600020549050600060096000866001600160a01b03166001600160a01b03168152602001908152602001600020600085600381111561369657613696615487565b60038111156136a7576136a7615487565b81526020810191909152604001600020556136cc6001600160a01b03851683836143a2565b816001600160a01b03168360038111156136e8576136e8615487565b856001600160a01b03167f0e80b333c403be7cb491b3ba7f29fe30014c594adbcbec04272291b2f72f6e6a8460405161372391815260200190565b60405180910390a450505050565b6000848152600f60209081526040808320815160808101835290546001600160401b038082168352600160401b8204811683860152600160801b8204811683850152600160c01b909104166060820152878452600d8352818420825160e0810190935280548352600181015491949390919083019060ff1660058111156137ba576137ba615487565b60058111156137cb576137cb615487565b8152600191909101546001600160401b0361010082048116602084015263ffffffff600160481b83048116604085015260ff600160681b84041615156060850152600160701b83049091166080840152600160b01b9091041660a090910152805190915061384b5760405162461bcd60e51b8152600401610c3a906159b7565b6000868152600c60209081526040808320815160808101835281546001600160a01b038082168352600160a01b820461ffff16838701819052600160b01b90920463ffffffff1683860152600190930154909216606082015290845260089092529091205460ff16156138d05760405162461bcd60e51b8152600401610c3a906157be565b8560058111156138e2576138e2615487565b826020015160058111156138f8576138f8615487565b146139155760405162461bcd60e51b8152600401610c3a906159e1565b600186600581111561392957613929615487565b036139cd5782516001600160401b038087169116118061395e5750846001600160401b031683602001516001600160401b0316105b156139c8576040516001600160401b038616815287907f82c058420d58fdfcaa301ef645c860145096603267b7b7ac02831312ac2ab4479060200160405180910390a26139c08782600001518360600151856000015186606001518930613ed6565b505050612ea5565b613a53565b60028660058111156139e1576139e1615487565b0361169a5782516001600160401b03808716911611801590613a195750846001600160401b031683602001516001600160401b031610155b6139c85760405162461bcd60e51b815260206004820152600b60248201526a50524943455f52414e474560a81b6044820152606401610c3a565b80516001600160a01b039081166000908152600b6020526040812054606085015160808601519190931692613a8d918b9185918b8a6143d3565b9050816001600160a01b03166352713f678a85606001518660200151886000015189606001518a6080015188604001518f6040518963ffffffff1660e01b8152600401613b339897969594939291909788526001600160a01b0396909616602088015261ffff949094166040870152606086019290925263ffffffff166080850152151560a08401526001600160401b0390811660c08401521660e08201526101000190565b60408051808303816000875af1925050508015613b6d575060408051601f3d908101601f19168201909252613b6a91810190615a19565b60015b613c7157613b79615a3d565b806308c379a003613bb25750613b8d615a58565b80613b985750613bb4565b8060405162461bcd60e51b8152600401610c3a91906152e5565b505b3d808015613bde576040519150601f19603f3d011682016040523d82523d6000602084013e613be3565b606091505b50632eb752bf60e21b613bf582615ae1565b6001600160e01b0319160361038e57602481015160448201516040518c907ff2c847d05971bf83dd347e0732c1ef893111318fb2540f5fe6f9783cb8d6ae5b90613c429085908590615b18565b60405180910390a2613c698c876000015188606001518a600001518b606001518e30613ed6565b505050613dba565b60008b8152600d602090815260408083206001810180546001600160401b038f16600160701b0267ffffffffffffffff60701b19909116179055895160109093529220558651613cc2908490615a06565b8155600180820180546001600160401b0342166101000268ffffffffffffffffff199091161760031790558651613d05918e9190613d008688615a06565b614756565b85516001600160a01b038082166000908152600a6020526040902054613d2d9291168461480a565b60008c8152600f60205260408082209190915584810151606086015191518e927fdd0164525ce1bb6897fbd7000a7d93633016a05f498d94903ca1fcc7911cdf8192613dae928f9290899089906001600160401b03958616815293851660208501529190931660408301526060820192909252608081019190915260a00190565b60405180910390a25050505b505050505050505050565b6000828152600d6020526040902054613df05760405162461bcd60e51b8152600401610c3a906159b7565b6000828152600f60205260408120556001816001811115613e1357613e13615487565b03611bb35760046000838152600d602052604090206001015460ff166005811115613e4057613e40615487565b14613e5d5760405162461bcd60e51b8152600401610c3a906159e1565b6000828152600d6020908152604080832060010180546001600160401b0342166101000268ffffffffffffffffff19909116176003179055519182526001600160a01b0385169184917f2cb817145129b5c52a6dc17e0605285c54d9c258fbf0a21e78bfff4e00813333910160405180910390a3505050565b6000878152600d6020908152604080832083815560010180546001600160d01b0319169055600f9091528120819055613f1e613f188663ffffffff8716614824565b8461483c565b9050613f2d8888600384614756565b613f368661484c565b613f4086896149a3565b6000613f4c8287615a06565b9050613f5988888361480a565b826001600160a01b0316897f0732bc6c415e7a220efee5f866e1e91a1335745b97373898ffecfddbc708a3e784604051613f9591815260200190565b60405180910390a3505050505050505050565b6000838152600c60209081526040808320815160808101835281546001600160a01b038082168352600160a01b820461ffff1695830195909552600160b01b900463ffffffff16928101929092526001015490911660608201528190819081614010886130d2565b80519091506140315760405162461bcd60e51b8152600401610c3a906159b7565b6000806000806140448c87878e8e614ace565b935093509350935084600001518311156140c6578451600090620186a061406b8287615a06565b614075919061595a565b61407f9190615987565b90506007548111156140c45760405162461bcd60e51b815260206004820152600e60248201526d1253959053125117d41493d1925560921b6044820152606401610c3a565b505b81975082985080965084600001518411156141235760405162461bcd60e51b815260206004820152601e60248201527f434c4f53455f4645455f4c41524745525f5448414e5f504f534954494f4e00006044820152606401610c3a565b6141348c8760000151600287614756565b614141866060015161484c565b61414f86606001518d6149a3565b60008c8152600d6020908152604080832083815560010180546001600160d01b0319169055600e8252808320839055601090915281205560608601518651865161419d9291908c9088614b80565b50505050505093509350939050565b60006001600160401b03831615806141d657508560070b6141d08787868689614ce9565b60070b12155b15614272576000620186a0856001600160401b03166064896001600160401b0316896001600160401b031661420b919061595a565b614215919061595a565b61421f9190615987565b6142299190615987565b90508261426057856001600160401b0316816001600160401b0316111561425157600061426a565b61425b8187615b36565b61426a565b61426a8187615b56565b915050614275565b50815b95945050505050565b60006001600160401b03831615806142b357506006546142a090600019615b76565b6142ad8787868689614ce9565b60070b13155b15614272576000620186a0856001600160401b03166064600654896001600160401b03166142e1919061595a565b6142eb919061595a565b6142f59190615987565b6142ff9190615987565b9050826143105761425b8187615b56565b856001600160401b0316816001600160401b0316111561433157600061426a565b61426a8187615b36565b6040516001600160a01b038481166024830152838116604483015260648201839052612ea59186918216906323b872dd906084015b604051602081830303815290604052915060e01b6020820180516001600160e01b038381831617835250505050614d75565b6040516001600160a01b038381166024830152604482018390526111fb91859182169063a9059cbb90606401614370565b6040805160808101825260008082526020820181905291810182905260608101919091526000866001600160a01b0316631cb92ed36040518163ffffffff1660e01b8152600401602060405180830381865afa158015614437573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061445b91906158e4565b6000898152600e6020908152604091829020825160808101845290546001600160401b038082168352600160401b8204811693830193909352600160801b81048316938201849052600160c01b90049091166060820152935090915015806144ce575060408301516001600160401b0316155b61451a5760405162461bcd60e51b815260206004820152601760248201527f4d554c5449504c455f54505f444546494e4954494f4e530000000000000000006044820152606401610c3a565b60608201516001600160401b0316158061453f575060608301516001600160401b0316155b61458b5760405162461bcd60e51b815260206004820152601760248201527f4d554c5449504c455f534c5f444546494e4954494f4e530000000000000000006044820152606401610c3a565b60408301516001600160401b0316156146055760006145b58585604001518963ffffffff16614dd8565b9050856145eb57846001600160401b0316816001600160401b0316106145dc5760006145f5565b6145e68186615b36565b6145f5565b6145f58186615b56565b6001600160401b03166040840152505b60608301516001600160401b03161561467f57600061462f8585606001518963ffffffff16614dd8565b905085614645576146408186615b56565b61466f565b846001600160401b0316816001600160401b03161061466557600061466f565b61466f8186615b36565b6001600160401b03166060840152505b61469681858863ffffffff168560400151896141ac565b6001600160401b0390811660408401524216825260608201516146c5908290869063ffffffff8a16908961427e565b6001600160401b0390811660608401908152428216602080860191825260009b8c52600e905260409a8b90208551815492519c87015193518516600160c01b026001600160c01b03948616600160801b02949094166001600160801b039d8616600160401b026001600160801b03199094169190951617919091179a909a1691909117179097559695505050505050565b8015612ea5576001600160a01b0383166000908152600960205260408120829184600381111561478857614788615487565b600381111561479957614799615487565b815260200190815260200160002060008282546147b69190615ba6565b9091555082905060038111156147ce576147ce615487565b836001600160a01b0316857f52aab89a61b38ba21feecda2012e9c20aec817e5d709d0633c3fd693bb949cbb8460405161372391815260200190565b80156111fb576111fb6001600160a01b03841683836143a2565b60006064614832838561595a565b6114779190615987565b6000620186a0614832838561595a565b6001600160a01b03811660009081526016602052604090205460010361134b5760135460011015614954576001600160a01b038116600090815260146020526040902054601380546148a090600190615a06565b815481106148b0576148b0615bb9565b6000918252602090912001546001600160a01b031660136148d2600184615a06565b815481106148e2576148e2615bb9565b6000918252602082200180546001600160a01b0319166001600160a01b0393909316929092179091558190601490601361491d600185615a06565b8154811061492d5761492d615bb9565b60009182526020808320909101546001600160a01b03168352820192909252604001902055505b6001600160a01b038116600090815260146020526040812055601380548061497e5761497e615bcf565b600082815260209020810160001990810180546001600160a01b031916905501905550565b6001600160a01b038216600090815260176020908152604080832084845290915290205480156111fb576001600160a01b0383166000908152601660205260408120906149f1600184615a06565b8254909150614a0290600190615a06565b811015614a7e5781546000908390614a1c90600190615a06565b81548110614a2c57614a2c615bb9565b9060005260206000200154905080838381548110614a4c57614a4c615bb9565b60009182526020808320909101929092556001600160a01b038816815260178252604080822093825292909152208390555b81805480614a8e57614a8e615bcf565b6000828152602080822083016000199081018390559092019092556001600160a01b03871682526017815260408083208784529091528120555050505050565b83516001600160a01b039081166000908152600b60209081526040808320546060890151928901519151630f1a62d160e31b8152939485948594859493909216926378d3168892614b2a928e92908d908d908d90600401615be5565b6080604051808303816000875af1158015614b49573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614b6d9190615c3c565b929c919b50995090975095505050505050565b6001600160a01b038085166000908152600a602052604081205490911690838510614c2957614baf8385615a06565b90506000614bbd8287615a06565b6040516321d4911360e01b81526001600160a01b038a8116600483015260248201839052919250908416906321d4911390604401600060405180830381600087803b158015614c0b57600080fd5b505af1158015614c1f573d6000803e3d6000fd5b5050505050614cd5565b50836000614c378286615a06565b905083811115614c5a57614c558784614c508785615a06565b61480a565b614cd3565b6001600160a01b0383166321d4911330614c748488615a06565b6040516001600160e01b031960e085901b1681526001600160a01b0390921660048301526024820152604401600060405180830381600087803b158015614cba57600080fd5b505af1158015614cce573d6000803e3d6000fd5b505050505b505b614ce086888361480a565b50505050505050565b6000858184614d0157614cfc8688615c72565b614d0b565b614d0b8787615c72565b905060008460070b620186a08360070b614d259190615b76565b614d2f9190615b76565b90506000600789900b614d43606484615ca1565b614d4d9190615ca1565b90508094508360070b8560070b13614d655784614d67565b835b9a9950505050505050505050565b6000614d8a6001600160a01b03841683614e27565b90508051600014158015614daf575080806020019051810190614dad9190615779565b155b156111fb57604051635274afe760e01b81526001600160a01b0384166004820152602401610c3a565b600080826001600160401b0316620186a06064866001600160401b0316886001600160401b0316614e09919061595a565b614e13919061595a565b614e1d9190615987565b6142759190615987565b60606114778383600084600080856001600160a01b03168486604051614e4d919061599b565b60006040518083038185875af1925050503d8060008114614e8a576040519150601f19603f3d011682016040523d82523d6000602084013e614e8f565b606091505b5091509150614e9f868383614ea9565b9695505050505050565b606082614ebe57614eb982614f05565b611477565b8151158015614ed557506001600160a01b0384163b155b15614efe57604051639996b31560e01b81526001600160a01b0385166004820152602401610c3a565b5080611477565b805115614f155780518082602001fd5b604051630a12f52160e11b815260040160405180910390fd5b6003811061134b57600080fd5b606081018181106001600160401b0382111715614f6857634e487b7160e01b600052604160045260246000fd5b60405250565b61012081016001600160401b0381118282101715614f6857634e487b7160e01b600052604160045260246000fd5b601f8201601f191681016001600160401b0381118282101715614fcf57634e487b7160e01b600052604160045260246000fd5b6040525050565b604051614fe281614f6e565b90565b6001600160a01b038116811461134b57600080fd5b803561ffff8116811461500c57600080fd5b919050565b801515811461134b57600080fd5b803561500c81615011565b803563ffffffff8116811461500c57600080fd5b80356001600160401b038116811461500c57600080fd5b6000806000808486036101c081121561506d57600080fd5b853561507881614f2e565b94506060601f198201121561508c57600080fd5b60405161509881614f3b565b60208701356150a681614fe5565b81526150b460408801614ffa565b602082015260608701356150c781614fe5565b60408201529350610120607f1982018113156150e257600080fd5b6150ea614fd6565b91506150f86080880161501f565b825260a0870135602083015261511060c0880161502a565b604083015261512160e0880161503e565b606083015261010061513481890161503e565b608084015261514482890161503e565b60a0840152615156610140890161503e565b60c0840152615168610160890161503e565b60e084015261517a610180890161503e565b9083015250915061518e6101a0860161502a565b905092959194509250565b6000602082840312156151ab57600080fd5b813561147781614fe5565b6000602082840312156151c857600080fd5b5035919050565b6004811061134b57600080fd5b6000806000606084860312156151f157600080fd5b83356151fc81614fe5565b9250602084013561520c816151cf565b9150604084013561521c81614fe5565b809150509250925092565b60008060006060848603121561523c57600080fd5b8335925061524c6020850161503e565b9150604084013590509250925092565b6000806040838503121561526f57600080fd5b823561527a816151cf565b946020939093013593505050565b6000806040838503121561529b57600080fd5b82356152a681614fe5565b915060208301356152b6816151cf565b809150509250929050565b60005b838110156152dc5781810151838201526020016152c4565b50506000910152565b60208152600082518060208401526153048160408501602087016152c1565b601f01601f19169190910160400192915050565b6000806040838503121561532b57600080fd5b823561527a81614fe5565b6020808252825182820181905260009190848201906040850190845b8181101561536e57835183529284019291840191600101615352565b50909695505050505050565b60008060006060848603121561538f57600080fd5b833592506020840135600281106153a557600080fd5b929592945050506040919091013590565b6000806000606084860312156153cb57600080fd5b8335925060208401356153a581614f2e565b6020808252825182820181905260009190848201906040850190845b8181101561536e5783516001600160a01b0316835292840192918401916001016153f9565b6000806000806080858703121561543457600080fd5b843593506020850135615446816151cf565b92506154546040860161503e565b915061518e6060860161503e565b6000806040838503121561547557600080fd5b8235915060208301356152b681615011565b634e487b7160e01b600052602160045260246000fd5b600681106154ad576154ad615487565b9052565b87815260e081016154c5602083018961549d565b6001600160401b03968716604083015263ffffffff958616606083015293151560808201529190941660a08201529290911660c09092019190915292915050565b60008060006060848603121561551b57600080fd5b833561552681614fe5565b95602085013595506040909401359392505050565b60a08101615549828861549d565b6001600160401b0395909516602082015261ffff939093166040840152901515606083015263ffffffff16608090910152919050565b600080600080600060a0868803121561559757600080fd5b853594506155a76020870161503e565b93506155b56040870161503e565b92506155c36060870161503e565b91506155d16080870161503e565b90509295509295909350565b6000806000606084860312156155f257600080fd5b83356155fd81614fe5565b9250602084013561520c81614fe5565b6000806000806080858703121561562357600080fd5b843561562e81614fe5565b9350602085013561563e81614fe5565b925061564c60408601614ffa565b915061518e6060860161502a565b6000806000806080858703121561567057600080fd5b84359350602085013561544681614f2e565b60008060006060848603121561569757600080fd5b833592506156a76020850161503e565b91506156b56040850161503e565b90509250925092565b6000806000606084860312156156d357600080fd5b83356156de81614fe5565b925060208401356153a581614fe5565b8051825263ffffffff602082015116602083015260408101511515604083015260608101516001600160401b03808216606085015280608084015116608085015250505050565b60a08101611c8e82846156ee565b60608101615751828661549d565b6001600160401b039390931660208201526001600160a01b0391909116604090910152919050565b60006020828403121561578b57600080fd5b815161147781615011565b6020808252600e908201526d08551c9859195c9cd41bdc9d185b60921b604082015260600190565b6020808252600b908201526a1410525497d4105554d15160aa1b604082015260600190565b6101e081016157f2828861549d565b63ffffffff808716602084015260018060a01b0380875116604085015261ffff6020880151166060850152806040880151166080850152508451151560a0840152602085015160c08401528060408601511660e0840152506060840151610100615866818501836001600160401b03169052565b60808601516001600160401b0390811661012086015260a0870151811661014086015260c0870151811661016086015260e087015181166101808601529501519094166101a083015263ffffffff929092166101c090910152949350505050565b6000602082840312156158d957600080fd5b815161147781614fe5565b6000602082840312156158f657600080fd5b5051919050565b60208082526009908201526821547269676765727360b81b604082015260600190565b634e487b7160e01b600052601160045260246000fd5b63ffffffff81811683821601908082111561595357615953615920565b5092915050565b8082028115828204841417611c8e57611c8e615920565b634e487b7160e01b600052601260045260246000fd5b60008261599657615996615971565b500490565b600082516159ad8184602087016152c1565b9190910192915050565b60208082526010908201526f2727afa9aaa1a42fa827a9a4aa24a7a760811b604082015260600190565b6020808252600b908201526a57524f4e475f504841534560a81b604082015260600190565b81810381811115611c8e57611c8e615920565b60008060408385031215615a2c57600080fd5b505080516020909101519092909150565b600060033d1115614fe25760046000803e5060005160e01c90565b600060443d1015615a665790565b6040516003193d81016004833e81513d6001600160401b038160248401118184111715615a9557505050505090565b8285019150815181811115615aad5750505050505090565b843d8701016020828501011115615ac75750505050505090565b615ad660208286010187614f9c565b509095945050505050565b805160208201516001600160e01b03198082169291906004831015615b105780818460040360031b1b83161693505b505050919050565b6040810160128410615b2c57615b2c615487565b9281526020015290565b6001600160401b0382811682821603908082111561595357615953615920565b6001600160401b0381811683821601908082111561595357615953615920565b80820260008212600160ff1b84141615615b9257615b92615920565b8181058314821517611c8e57611c8e615920565b80820180821115611c8e57611c8e615920565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052603160045260246000fd5b8681526001600160a01b038616602082015261ffff851660408201526101408101615c1360608301866156ee565b8361010083015260058310615c2a57615c2a615487565b82610120830152979650505050505050565b60008060008060808587031215615c5257600080fd5b505082516020840151604085015160609095015191969095509092509050565b600782810b9082900b03677fffffffffffffff198112677fffffffffffffff82131715611c8e57611c8e615920565b600082615cb057615cb0615971565b600160ff1b821460001984141615615cca57615cca615920565b50059056fea26469706673582212201c75ffce6c5a12946abb22a00ed4d61e76b6f4bf5476bb6903d1b44aea3bf47b64736f6c63430008180033
Loading...
Loading
Loading...
Loading
Loading...
Loading
Net Worth in USD
$0.00
Net Worth in S
Multichain Portfolio | 35 Chains
| Chain | Token | Portfolio % | Price | Amount | Value |
|---|
Loading...
Loading
Loading...
Loading
Loading...
Loading
[ Download: CSV Export ]
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.