Overview
ETH Balance
0 ETH
Eth Value
$0.00More Info
Private Name Tags
ContractCreator
Latest 20 from a total of 20 transactions
Transaction Hash |
Method
|
Block
|
From
|
To
|
|||||
---|---|---|---|---|---|---|---|---|---|
Transfer Ownersh... | 16235930 | 666 days ago | IN | 0 ETH | 0.00038061 | ||||
White List | 16227210 | 667 days ago | IN | 0 ETH | 0.00080492 | ||||
Set Token Base P... | 16222887 | 668 days ago | IN | 0 ETH | 0.00094996 | ||||
Set Token Base P... | 16222886 | 668 days ago | IN | 0 ETH | 0.00094328 | ||||
Set Token Base P... | 16222885 | 668 days ago | IN | 0 ETH | 0.00092087 | ||||
Set Same Token | 16222884 | 668 days ago | IN | 0 ETH | 0.00064869 | ||||
Set Stargate Poo... | 16222883 | 668 days ago | IN | 0 ETH | 0.00065321 | ||||
Set Stargate Poo... | 16222882 | 668 days ago | IN | 0 ETH | 0.00064749 | ||||
Set Stargate Poo... | 16222881 | 668 days ago | IN | 0 ETH | 0.000669 | ||||
Set Stargate Poo... | 16222880 | 668 days ago | IN | 0 ETH | 0.00064641 | ||||
Set Stargate Poo... | 16222879 | 668 days ago | IN | 0 ETH | 0.00066927 | ||||
Set Stargate Poo... | 16222878 | 668 days ago | IN | 0 ETH | 0.00065091 | ||||
Set Stargate Poo... | 16222877 | 668 days ago | IN | 0 ETH | 0.00069641 | ||||
Set Trusted Remo... | 16222841 | 668 days ago | IN | 0 ETH | 0.00126609 | ||||
Set Trusted Remo... | 16222840 | 668 days ago | IN | 0 ETH | 0.0012984 | ||||
Set Trusted Remo... | 16222839 | 668 days ago | IN | 0 ETH | 0.00133105 | ||||
Set Trusted Remo... | 16222838 | 668 days ago | IN | 0 ETH | 0.00133282 | ||||
Set Trusted Remo... | 16222837 | 668 days ago | IN | 0 ETH | 0.0013772 | ||||
Set Trusted Remo... | 16222836 | 668 days ago | IN | 0 ETH | 0.00144041 | ||||
0x60c06040 | 16222824 | 668 days ago | IN | 0 ETH | 0.04846431 |
View more zero value Internal Transactions in Advanced View mode
Advanced mode:
Loading...
Loading
Contract Name:
StargateFeeLibraryV05
Compiler Version
v0.7.6+commit.7338295f
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: BUSL-1.1 pragma solidity 0.7.6; pragma abicoder v2; import "../interfaces/IStargateFeeLibrary.sol"; import "../Pool.sol"; import "../Factory.sol"; import "../interfaces/IStargateLPStaking.sol"; import "../chainlink/interfaces/AggregatorV3Interface.sol"; import "../lzApp/LzApp.sol"; import "@openzeppelin/contracts/math/SafeMath.sol"; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; contract StargateFeeLibraryV05 is LzApp, IStargateFeeLibrary { using SafeMath for uint256; //--------------------------------------------------------------------------- // VARIABLES // equilibrium func params. all in BPs * 10 ^ 2, i.e. 1 % = 10 ^ 6 units uint256 public constant DENOMINATOR = 1e18; uint256 public constant DELTA_1 = 6000 * 1e14; uint256 public constant DELTA_2 = 500 * 1e14; uint256 public constant LAMBDA_1 = 40 * 1e14; uint256 public constant LAMBDA_2 = 9960 * 1e14; // fee/reward bps uint256 public constant LP_FEE = 1 * 1e14; uint256 public constant LP_FEE_WITH_EQ_REWARD = 34 * 1e12; uint256 public constant PROTOCOL_FEE = 9 * 1e14; uint256 public constant PROTOCOL_FEE_FOR_SAME_TOKEN = 5 * 1e14; uint256 public constant PROTOCOL_FEE_WITH_EQ_REWARD = 166 * 1e12; uint256 public constant EQ_REWARD_CAP = 25 * 1e14; uint256 public constant EQ_REWARD_THRESHOLD = 6 * 1e14; uint256 public constant PROTOCOL_SUBSIDY = 3 * 1e13; uint256 public constant FIFTY_PERCENT = 5 * 1e17; uint256 public constant SIXTY_PERCENT = 6 * 1e17; // price and state thresholds, may be configurable in the future uint8 public constant PRICE_SHARED_DECIMALS = 8; // for price normalization uint256 public constant ONE_BPS_PRICE_CHANGE_THRESHOLD = 1 * 1e14; uint256 public constant TEN_BPS_PRICE_CHANGE_THRESHOLD = 10 * 1e14; uint256 public constant PRICE_DRIFT_THRESHOLD = 10 * 1e14; // 10 bps uint256 public constant PRICE_DEPEG_THRESHOLD = 150 * 1e14; // 150 bps mapping(address => bool) public whitelist; mapping(uint256 => uint256) public poolIdToLpId; // poolId -> index of the pool in the lpStaking contract Factory public immutable factory; mapping(uint256 => Price) public poolIdToPrice; mapping(uint256 => mapping(uint256 => bool)) public sameToken; // only for protocol fee, poolId -> poolId -> bool mapping(uint16 => bytes) public defaultAdapterParams; // for price sync, chainId -> params mapping(uint256 => address) public stargatePoolIdToLPStaking; enum PriceDeviationState { Normal, Drift, Depeg } struct Price { address priceFeedAddress; uint256 basePriceSD; // e.g. $1 for USD token uint256 currentPriceSD; // price of the pool's token in USD PriceDeviationState state; // default is Normal uint16[] remoteChainIds; // chainIds of the pools that are connected to the pool } event PriceUpdated(uint256 indexed poolId, uint256 priceSD, PriceDeviationState state); modifier notDepeg(uint256 _srcPoolId, uint256 _dstPoolId) { if (_srcPoolId != _dstPoolId) { require(poolIdToPrice[_srcPoolId].state != PriceDeviationState.Depeg, "FeeLibrary: _srcPoolId depeg"); } _; } constructor( address _factory, address _endpoint ) LzApp(_endpoint) { require(_factory != address(0x0), "FeeLibrary: Factory cannot be 0x0"); require(_endpoint != address(0x0), "FeeLibrary: Endpoint cannot be 0x0"); factory = Factory(_factory); } // --------------------- ONLY OWNER --------------------- function whiteList(address _from, bool _whiteListed) external onlyOwner { whitelist[_from] = _whiteListed; } function setPoolToLpId(uint256 _poolId, uint256 _lpId) external onlyOwner { poolIdToLpId[_poolId] = _lpId; } // for those chains where to get the price from oracle and sync to other chains function setTokenPriceFeed( uint256 _poolId, address _priceFeedAddress, uint16[] calldata _remoteChainIds ) external onlyOwner { poolIdToPrice[_poolId].priceFeedAddress = _priceFeedAddress; poolIdToPrice[_poolId].remoteChainIds = _remoteChainIds; } function setStargatePoolIdToLPStakingAddress(uint256 _poolId, address _lpStaking) external onlyOwner { stargatePoolIdToLPStaking[_poolId] = _lpStaking; } function setTokenBasePrice(uint256 _poolId, uint256 _basePriceSD) external onlyOwner { require(_basePriceSD > 0, "FeeLibrary: _basePriceSD cannot be 0"); poolIdToPrice[_poolId].basePriceSD = _basePriceSD; poolIdToPrice[_poolId].currentPriceSD = _basePriceSD; // reset current price and state poolIdToPrice[_poolId].state = PriceDeviationState.Normal; } function setSameToken(uint256 _poolId1, uint256 _poolId2, bool _isSame) external onlyOwner { require(_poolId1 != _poolId2, "FeeLibrary: _poolId1 cannot be the same as _poolId2"); if (_poolId1 < _poolId2) { sameToken[_poolId1][_poolId2] = _isSame; } else { sameToken[_poolId2][_poolId1] = _isSame; } } function setDefaultAdapterParams(uint16 _remoteChainId, bytes calldata _adapterParams) external onlyOwner { defaultAdapterParams[_remoteChainId] = _adapterParams; } // Override the renounce ownership inherited by zeppelin ownable function renounceOwnership() public override onlyOwner {} // --------------------- PUBLIC FUNCTIONS --------------------- // anyone can update and sync price at any time even though the price is not changed function updateTokenPrice(uint256 _poolId) external payable { Price storage priceObj = poolIdToPrice[_poolId]; (uint256 newPriceSD, PriceDeviationState newState) = _getLatestPriceSDFromPriceFeed(priceObj); // update price and state _updatePrice(_poolId, newPriceSD, newState); // sync the price to remote pools uint16[] memory remoteChainIds = priceObj.remoteChainIds; bytes memory payload = abi.encode(_poolId, newPriceSD, newState); for (uint256 i = 0; i < remoteChainIds.length; i++) { uint16 remoteChainId = remoteChainIds[i]; address refundAddress = i == remoteChainIds.length - 1? msg.sender : address(this); // refund to msg.sender only for the last call _lzSend(remoteChainId, payload, payable(refundAddress), address(0), defaultAdapterParams[remoteChainId], address(this).balance); } } // --------------------- VIEW FUNCTIONS --------------------- function getFees( uint256 _srcPoolId, uint256 _dstPoolId, uint16 _dstChainId, address _from, uint256 _amountSD ) external view override notDepeg(_srcPoolId, _dstPoolId) returns (Pool.SwapObj memory s) { // calculate the equilibrium reward bool whitelisted = whitelist[_from]; (s.eqReward, s.protocolFee) = getEqReward(_srcPoolId, _amountSD, whitelisted); // protocol fee is 0 if whitelisted // calculate the equilibrium fee bool hasEqReward = s.eqReward > 0; uint256 protocolSubsidy; (s.eqFee, protocolSubsidy) = getEquilibriumFee(_srcPoolId, _dstPoolId, _dstChainId, _amountSD, whitelisted, hasEqReward); // calculate protocol and lp fee (uint256 protocolFee, uint256 lpFee) = getProtocolAndLpFee(_srcPoolId, _dstPoolId, _dstChainId, _amountSD, protocolSubsidy, whitelisted, hasEqReward); s.protocolFee = s.protocolFee.add(protocolFee); s.lpFee = lpFee; // calculate drift fee uint256 driftFee = getDriftFee(_srcPoolId, _dstPoolId, _amountSD, whitelisted); s.protocolFee = s.protocolFee.add(driftFee); return s; } // quote fee for price update and sync to remote chains function quoteFeeForPriceUpdate(uint256 _poolId) external view returns (uint256) { uint256 total = 0; uint16[] memory remoteChainIds = poolIdToPrice[_poolId].remoteChainIds; bytes memory payload = abi.encode(_poolId, uint256(0), PriceDeviationState.Normal); // mock the payload for (uint256 i = 0; i < remoteChainIds.length; i++) { uint16 remoteChainId = remoteChainIds[i]; (uint256 fee, ) = lzEndpoint.estimateFees(remoteChainId, address(this), payload, false, defaultAdapterParams[remoteChainId]); total = total.add(fee); } return total; } // check if the token price is changed and return the new price and state function isTokenPriceChanged(uint256 _poolId) external view returns (bool, uint256, PriceDeviationState) { Price storage priceObj = poolIdToPrice[_poolId]; (uint256 newPriceSD, PriceDeviationState newState) = _getLatestPriceSDFromPriceFeed(priceObj); // compare two prices and check if the price and sate are changed or not bool isChanged = _isPriceChanged(priceObj, newPriceSD, newState); uint256 rtnPrice = isChanged? newPriceSD : priceObj.currentPriceSD; return (isChanged, rtnPrice, newState); } function getEqReward( uint256 _srcPoolId, uint256 _amountSD, bool _whitelisted ) public view returns (uint256 eqReward, uint256 protocolFee) { Pool pool = factory.getPool(_srcPoolId); uint256 currentAssetSD = _getPoolBalanceSD(pool); uint256 lpAsset = pool.totalLiquidity(); uint256 rewardPoolSize = pool.eqFeePool(); if (lpAsset <= currentAssetSD) { return (0, 0); } uint256 poolDeficit = lpAsset.sub(currentAssetSD); uint256 rate = rewardPoolSize.mul(DENOMINATOR).div(poolDeficit); if (rate <= EQ_REWARD_THRESHOLD && !_whitelisted) { return (0, 0); } eqReward = _amountSD.mul(rate).div(DENOMINATOR); eqReward = eqReward > rewardPoolSize ? rewardPoolSize : eqReward; if (_whitelisted) { return (eqReward, 0); } uint256 rewardBps = eqReward.mul(DENOMINATOR).div(_amountSD); if (rewardBps > EQ_REWARD_CAP) { uint256 cap = _amountSD.mul(EQ_REWARD_CAP).div(DENOMINATOR); protocolFee = eqReward.sub(cap); eqReward = cap; } else { protocolFee = 0; } } function getEquilibriumFee( uint256 srcPoolId, uint256 dstPoolId, uint16 dstChainId, uint256 amountSD, bool whitelisted, bool hasEqReward ) public view returns (uint256, uint256) { if (whitelisted) { return (0, 0); } Pool.ChainPath memory chainPath = factory.getPool(srcPoolId).getChainPath(dstChainId, dstPoolId); uint256 idealBalance = chainPath.idealBalance; uint256 beforeBalance = chainPath.balance; require(beforeBalance >= amountSD, "FeeLibrary: not enough balance"); uint256 afterBalance = beforeBalance.sub(amountSD); uint256 safeZoneMax = idealBalance.mul(DELTA_1).div(DENOMINATOR); uint256 safeZoneMin = idealBalance.mul(DELTA_2).div(DENOMINATOR); uint256 eqFee = 0; uint256 protocolSubsidy = 0; uint256 amountSD_ = amountSD; // stack too deep if (afterBalance >= safeZoneMax) { // no fee zone, protocol subsidize it. eqFee = amountSD_.mul(PROTOCOL_SUBSIDY).div(DENOMINATOR); // no subsidy if has eqReward if (!hasEqReward) { protocolSubsidy = eqFee; } } else if (afterBalance >= safeZoneMin) { // safe zone uint256 proxyBeforeBalance = beforeBalance < safeZoneMax ? beforeBalance : safeZoneMax; eqFee = _getTrapezoidArea(LAMBDA_1, 0, safeZoneMax, safeZoneMin, proxyBeforeBalance, afterBalance); } else { // danger zone if (beforeBalance >= safeZoneMin) { // across 2 or 3 zones // part 1 uint256 proxyBeforeBalance = beforeBalance < safeZoneMax ? beforeBalance : safeZoneMax; eqFee = eqFee.add(_getTrapezoidArea(LAMBDA_1, 0, safeZoneMax, safeZoneMin, proxyBeforeBalance, safeZoneMin)); // part 2 eqFee = eqFee.add(_getTrapezoidArea(LAMBDA_2, LAMBDA_1, safeZoneMin, 0, safeZoneMin, afterBalance)); } else { // only in danger zone // part 2 only uint256 beforeBalance_ = beforeBalance; // Stack too deep eqFee = eqFee.add(_getTrapezoidArea(LAMBDA_2, LAMBDA_1, safeZoneMin, 0, beforeBalance_, afterBalance)); } } return (eqFee, protocolSubsidy); } function getProtocolAndLpFee( uint256 _srcPoolId, uint256 _dstPoolId, uint16, // _dstChainId uint256 _amountSD, uint256 _protocolSubsidy, bool _whitelisted, bool _hasEqReward ) public view returns (uint256, uint256) { if (_whitelisted) { return (0, 0); } uint256 protocolFeeBps = _hasEqReward ? PROTOCOL_FEE_WITH_EQ_REWARD : isSameToken(_srcPoolId, _dstPoolId) ? PROTOCOL_FEE_FOR_SAME_TOKEN : PROTOCOL_FEE; uint256 lpFeeBps = _hasEqReward ? LP_FEE_WITH_EQ_REWARD : LP_FEE; uint256 amountSD = _amountSD; // Stack too deep uint256 srcPoolId = _srcPoolId; uint256 protocolFee = amountSD.mul(protocolFeeBps).div(DENOMINATOR).sub(_protocolSubsidy); uint256 lpFee = amountSD.mul(lpFeeBps).div(DENOMINATOR); // when there are active emissions, give the lp fee to the protocol // lookup LPStaking[Time] address. If it address lpStakingAddr = stargatePoolIdToLPStaking[srcPoolId]; if(lpStakingAddr != address(0x0)){ IStargateLPStaking lpStaking = IStargateLPStaking(lpStakingAddr); (, uint256 allocPoint, , ) = lpStaking.poolInfo(poolIdToLpId[srcPoolId]); if (allocPoint > 0) { protocolFee = protocolFee.add(lpFee); lpFee = 0; } } return (protocolFee, lpFee); } function getDriftFee( uint256 _srcPoolId, uint256 _dstPoolId, uint256 _amountSD, bool _whitelisted ) public view returns (uint256) { if (_srcPoolId == _dstPoolId || _whitelisted) { return 0; } uint256 srcPriceSD = _getTokenPriceSD(_srcPoolId); uint256 dstPriceSD = _getTokenPriceSD(_dstPoolId); if (srcPriceSD >= dstPriceSD) { return 0; } uint256 amountSDAfterFee = _amountSD.mul(srcPriceSD).div(dstPriceSD); return _amountSD.sub(amountSDAfterFee); } function isSameToken(uint256 _poolId1, uint256 _poolId2) public view returns (bool) { if (_poolId1 == _poolId2) { return true; } return _poolId1 < _poolId2 ? sameToken[_poolId1][_poolId2] : sameToken[_poolId2][_poolId1]; } function getRemoteChainIds(uint256 _poolId) external view returns (uint16[] memory) { return poolIdToPrice[_poolId].remoteChainIds; } function getVersion() external pure override returns (string memory) { return "5.0.0"; } // --------------------- INTERNAL FUNCTIONS --------------------- function _getTrapezoidArea( uint256 lambda, uint256 yOffset, uint256 xUpperBound, uint256 xLowerBound, uint256 xStart, uint256 xEnd ) internal pure returns (uint256) { require(xEnd >= xLowerBound && xStart <= xUpperBound, "FeeLibrary: balance out of bound"); uint256 xBoundWidth = xUpperBound.sub(xLowerBound); // xStartDrift = xUpperBound.sub(xStart); uint256 yStart = xUpperBound.sub(xStart).mul(lambda).div(xBoundWidth).add(yOffset); // xEndDrift = xUpperBound.sub(xEnd) uint256 yEnd = xUpperBound.sub(xEnd).mul(lambda).div(xBoundWidth).add(yOffset); // compute the area uint256 deltaX = xStart.sub(xEnd); return yStart.add(yEnd).mul(deltaX).div(2).div(DENOMINATOR); } function _blockingLzReceive(uint16, bytes memory, uint64, bytes memory _payload) internal override { (uint256 poolId, uint256 amount, PriceDeviationState state) = abi.decode(_payload, (uint16, uint256, PriceDeviationState)); _updatePrice(poolId, amount, state); } function _getLatestPriceSDFromPriceFeed(Price storage _priceObj) internal view returns (uint256, PriceDeviationState) { // get the latest price from the oracle address priceFeedAddress = _priceObj.priceFeedAddress; require(priceFeedAddress != address(0x0), "FeeLibrary: price feed not set"); uint8 decimals = AggregatorV3Interface(priceFeedAddress).decimals(); (, int256 price, , , ) = AggregatorV3Interface(priceFeedAddress).latestRoundData(); require(price >= 0, "FeeLibrary: price is negative"); // normalize the price uint256 newPriceSD = _scalePrice(uint256(price), decimals); uint256 basePriceSD = _safeGetBasePriceSD(_priceObj); newPriceSD = newPriceSD > basePriceSD? basePriceSD : newPriceSD; // get the new state PriceDeviationState newState = _getPriceDeviationState(newPriceSD, basePriceSD); return (newPriceSD, newState); } function _isPriceChanged(Price storage _priceObj, uint256 _newPriceSD, PriceDeviationState _newState) internal view returns (bool) { if (_newState != _priceObj.state) { return true; } uint256 threshold = _newState == PriceDeviationState.Drift? ONE_BPS_PRICE_CHANGE_THRESHOLD : TEN_BPS_PRICE_CHANGE_THRESHOLD; uint256 currentPriceSD = _priceObj.currentPriceSD; uint256 diff = _newPriceSD > currentPriceSD ? _newPriceSD.sub(currentPriceSD) : currentPriceSD.sub(_newPriceSD); return currentPriceSD == 0 ? diff > 0 : diff.mul(DENOMINATOR).div(currentPriceSD) >= threshold; } function _getTokenPriceSD(uint256 _poolId) internal view returns (uint256) { Price storage priceObj = poolIdToPrice[_poolId]; return priceObj.state == PriceDeviationState.Normal? _safeGetBasePriceSD(priceObj) : priceObj.currentPriceSD; } function _updatePrice(uint256 _poolId, uint256 _priceSD, PriceDeviationState _state) internal { Price storage priceObj = poolIdToPrice[_poolId]; priceObj.currentPriceSD = _priceSD; // update state if (_state != priceObj.state) { priceObj.state = _state; } emit PriceUpdated(_poolId, _priceSD, _state); } function _getPriceDeviationState(uint256 _currentPriceSD, uint256 _basePriceSD) internal pure returns (PriceDeviationState) { uint256 diff = _basePriceSD.sub(_currentPriceSD).mul(DENOMINATOR).div(_basePriceSD); if (diff <= PRICE_DRIFT_THRESHOLD) { return PriceDeviationState.Normal; } else if (diff >= PRICE_DEPEG_THRESHOLD) { return PriceDeviationState.Depeg; } else { return PriceDeviationState.Drift; } } function _scalePrice(uint256 _price, uint8 _decimals) internal pure returns (uint256) { if (_decimals == PRICE_SHARED_DECIMALS) { return _price; } uint256 rate = _scaleRate(_decimals, PRICE_SHARED_DECIMALS); return _decimals < PRICE_SHARED_DECIMALS ? _price.mul(rate) : _price.div(rate); } function _scaleRate(uint8 _decimals, uint8 _sharedDecimals) internal pure returns (uint256) { uint256 diff = _decimals > _sharedDecimals? _decimals - _sharedDecimals : _sharedDecimals - _decimals; require(diff <= 20, "FeeLibrary: diff of decimals is too large"); return 10 ** diff; } function _getPoolBalanceSD(Pool _pool) internal view returns (uint256) { return IERC20(_pool.token()).balanceOf(address(_pool)).div(_pool.convertRate()); } function _safeGetBasePriceSD(Price storage _priceObj) internal view returns (uint256 priceSD) { priceSD = _priceObj.basePriceSD; require(priceSD > 0, "FeeLibrary: base price not set"); } receive() external payable {} // receive ETH from lz endpoint }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /* * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with GSN meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address payable) { return msg.sender; } function _msgData() internal view virtual returns (bytes memory) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } }
// SPDX-License-Identifier: MIT pragma solidity ^0.7.0; import "../utils/Context.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor () { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity >=0.5.0; interface ILayerZeroReceiver { // @notice LayerZero endpoint will invoke this function to deliver the message on the destination // @param _srcChainId - the source endpoint identifier // @param _srcAddress - the source sending contract address from the source chain // @param _nonce - the ordered message nonce // @param _payload - the signed payload is the UA bytes has encoded to be sent function lzReceive(uint16 _srcChainId, bytes calldata _srcAddress, uint64 _nonce, bytes calldata _payload) external; }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity >=0.5.0; import "./ILayerZeroUserApplicationConfig.sol"; interface ILayerZeroEndpoint is ILayerZeroUserApplicationConfig { // @notice send a LayerZero message to the specified address at a LayerZero endpoint. // @param _dstChainId - the destination chain identifier // @param _destination - the address on destination chain (in bytes). address length/format may vary by chains // @param _payload - a custom bytes payload to send to the destination contract // @param _refundAddress - if the source transaction is cheaper than the amount of value passed, refund the additional amount to this address // @param _zroPaymentAddress - the address of the ZRO token holder who would pay for the transaction // @param _adapterParams - parameters for custom functionality. e.g. receive airdropped native gas from the relayer on destination function send(uint16 _dstChainId, bytes calldata _destination, bytes calldata _payload, address payable _refundAddress, address _zroPaymentAddress, bytes calldata _adapterParams) external payable; // @notice used by the messaging library to publish verified payload // @param _srcChainId - the source chain identifier // @param _srcAddress - the source contract (as bytes) at the source chain // @param _dstAddress - the address on destination chain // @param _nonce - the unbound message ordering nonce // @param _gasLimit - the gas limit for external contract execution // @param _payload - verified payload to send to the destination contract function receivePayload(uint16 _srcChainId, bytes calldata _srcAddress, address _dstAddress, uint64 _nonce, uint _gasLimit, bytes calldata _payload) external; // @notice get the inboundNonce of a receiver from a source chain which could be EVM or non-EVM chain // @param _srcChainId - the source chain identifier // @param _srcAddress - the source chain contract address function getInboundNonce(uint16 _srcChainId, bytes calldata _srcAddress) external view returns (uint64); // @notice get the outboundNonce from this source chain which, consequently, is always an EVM // @param _srcAddress - the source chain contract address function getOutboundNonce(uint16 _dstChainId, address _srcAddress) external view returns (uint64); // @notice gets a quote in source native gas, for the amount that send() requires to pay for message delivery // @param _dstChainId - the destination chain identifier // @param _userApplication - the user app address on this EVM chain // @param _payload - the custom message to send over LayerZero // @param _payInZRO - if false, user app pays the protocol fee in native token // @param _adapterParam - parameters for the adapter service, e.g. send some dust native token to dstChain function estimateFees(uint16 _dstChainId, address _userApplication, bytes calldata _payload, bool _payInZRO, bytes calldata _adapterParam) external view returns (uint nativeFee, uint zroFee); // @notice get this Endpoint's immutable source identifier function getChainId() external view returns (uint16); // @notice the interface to retry failed message on this Endpoint destination // @param _srcChainId - the source chain identifier // @param _srcAddress - the source chain contract address // @param _payload - the payload to be retried function retryPayload(uint16 _srcChainId, bytes calldata _srcAddress, bytes calldata _payload) external; // @notice query if any STORED payload (message blocking) at the endpoint. // @param _srcChainId - the source chain identifier // @param _srcAddress - the source chain contract address function hasStoredPayload(uint16 _srcChainId, bytes calldata _srcAddress) external view returns (bool); // @notice query if the _libraryAddress is valid for sending msgs. // @param _userApplication - the user app address on this EVM chain function getSendLibraryAddress(address _userApplication) external view returns (address); // @notice query if the _libraryAddress is valid for receiving msgs. // @param _userApplication - the user app address on this EVM chain function getReceiveLibraryAddress(address _userApplication) external view returns (address); // @notice query if the non-reentrancy guard for send() is on // @return true if the guard is on. false otherwise function isSendingPayload() external view returns (bool); // @notice query if the non-reentrancy guard for receive() is on // @return true if the guard is on. false otherwise function isReceivingPayload() external view returns (bool); // @notice get the configuration of the LayerZero messaging library of the specified version // @param _version - messaging library version // @param _chainId - the chainId for the pending config change // @param _userApplication - the contract address of the user application // @param _configType - type of configuration. every messaging library has its own convention. function getConfig(uint16 _version, uint16 _chainId, address _userApplication, uint _configType) external view returns (bytes memory); // @notice get the send() LayerZero messaging library version // @param _userApplication - the contract address of the user application function getSendVersion(address _userApplication) external view returns (uint16); // @notice get the lzReceive() LayerZero messaging library version // @param _userApplication - the contract address of the user application function getReceiveVersion(address _userApplication) external view returns (uint16); }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity >=0.5.0; interface ILayerZeroUserApplicationConfig { // @notice set the configuration of the LayerZero messaging library of the specified version // @param _version - messaging library version // @param _chainId - the chainId for the pending config change // @param _configType - type of configuration. every messaging library has its own convention. // @param _config - configuration in the bytes. can encode arbitrary content. function setConfig(uint16 _version, uint16 _chainId, uint _configType, bytes calldata _config) external; // @notice set the send() LayerZero messaging library version to _version // @param _version - new messaging library version function setSendVersion(uint16 _version) external; // @notice set the lzReceive() LayerZero messaging library version to _version // @param _version - new messaging library version function setReceiveVersion(uint16 _version) external; // @notice Only when the UA needs to resume the message flow in blocking mode and clear the stored payload // @param _srcChainId - the chainId of the source chain // @param _srcAddress - the contract address of the source contract at the source chain function forceResumeReceive(uint16 _srcChainId, bytes calldata _srcAddress) external; }
// SPDX-License-Identifier: MIT pragma solidity ^0.7.0; /** * @dev Contract module that helps prevent reentrant calls to a function. * * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier * available, which can be applied to functions to make sure there are no nested * (reentrant) calls to them. * * Note that because there is a single `nonReentrant` guard, functions marked as * `nonReentrant` may not call one another. This can be worked around by making * those functions `private`, and then adding `external` `nonReentrant` entry * points to them. * * TIP: If you would like to learn more about reentrancy and alternative ways * to protect against it, check out our blog post * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul]. */ abstract contract ReentrancyGuard { // Booleans are more expensive than uint256 or any type that takes up a full // word because each write operation emits an extra SLOAD to first read the // slot's contents, replace the bits taken up by the boolean, and then write // back. This is the compiler's defense against contract upgrades and // pointer aliasing, and it cannot be disabled. // The values being non-zero value makes deployment a bit more expensive, // but in exchange the refund on every call to nonReentrant will be lower in // amount. Since refunds are capped to a percentage of the total // transaction's gas, it is best to keep them low in cases like this one, to // increase the likelihood of the full refund coming into effect. uint256 private constant _NOT_ENTERED = 1; uint256 private constant _ENTERED = 2; uint256 private _status; constructor () { _status = _NOT_ENTERED; } /** * @dev Prevents a contract from calling itself, directly or indirectly. * Calling a `nonReentrant` function from another `nonReentrant` * function is not supported. It is possible to prevent this from happening * by making the `nonReentrant` function external, and make it call a * `private` function that does the actual work. */ modifier nonReentrant() { // On the first call to nonReentrant, _notEntered will be true require(_status != _ENTERED, "ReentrancyGuard: reentrant call"); // Any calls to nonReentrant after this point will fail _status = _ENTERED; _; // By storing the original value once again, a refund is triggered (see // https://eips.ethereum.org/EIPS/eip-2200) _status = _NOT_ENTERED; } }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity 0.7.6; // libraries import "@openzeppelin/contracts/math/SafeMath.sol"; contract LPTokenERC20 { using SafeMath for uint256; //--------------------------------------------------------------------------- // CONSTANTS string public name; string public symbol; bytes32 public constant PERMIT_TYPEHASH = 0x6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9; // set in constructor bytes32 public DOMAIN_SEPARATOR; //--------------------------------------------------------------------------- // VARIABLES uint256 public decimals; uint256 public totalSupply; mapping(address => uint256) public balanceOf; mapping(address => mapping(address => uint256)) public allowance; mapping(address => uint256) public nonces; //--------------------------------------------------------------------------- // EVENTS event Approval(address indexed owner, address indexed spender, uint256 value); event Transfer(address indexed from, address indexed to, uint256 value); constructor(string memory _name, string memory _symbol) { name = _name; symbol = _symbol; uint256 chainId; assembly { chainId := chainid() } DOMAIN_SEPARATOR = keccak256( abi.encode( keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"), keccak256(bytes(name)), keccak256(bytes("1")), chainId, address(this) ) ); } function _mint(address to, uint256 value) internal { totalSupply = totalSupply.add(value); balanceOf[to] = balanceOf[to].add(value); emit Transfer(address(0), to, value); } function _burn(address from, uint256 value) internal { balanceOf[from] = balanceOf[from].sub(value); totalSupply = totalSupply.sub(value); emit Transfer(from, address(0), value); } function _approve( address owner, address spender, uint256 value ) private { allowance[owner][spender] = value; emit Approval(owner, spender, value); } function _transfer( address from, address to, uint256 value ) private { balanceOf[from] = balanceOf[from].sub(value); balanceOf[to] = balanceOf[to].add(value); emit Transfer(from, to, value); } function approve(address spender, uint256 value) external returns (bool) { _approve(msg.sender, spender, value); return true; } function transfer(address to, uint256 value) external returns (bool) { _transfer(msg.sender, to, value); return true; } function transferFrom( address from, address to, uint256 value ) external returns (bool) { if (allowance[from][msg.sender] != uint256(-1)) { allowance[from][msg.sender] = allowance[from][msg.sender].sub(value); } _transfer(from, to, value); return true; } function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(msg.sender, spender, allowance[msg.sender][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(msg.sender, spender, allowance[msg.sender][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) external { require(deadline >= block.timestamp, "Bridge: EXPIRED"); bytes32 digest = keccak256( abi.encodePacked( "\x19\x01", DOMAIN_SEPARATOR, keccak256(abi.encode(PERMIT_TYPEHASH, owner, spender, value, nonces[owner]++, deadline)) ) ); address recoveredAddress = ecrecover(digest, v, r, s); require(recoveredAddress != address(0) && recoveredAddress == owner, "Bridge: INVALID_SIGNATURE"); _approve(owner, spender, value); } }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.7.6; pragma abicoder v2; import "../Pool.sol"; interface IStargateFeeLibrary { function getFees( uint256 _srcPoolId, uint256 _dstPoolId, uint16 _dstChainId, address _from, uint256 _amountSD ) external returns (Pool.SwapObj memory s); function getVersion() external view returns (string memory); }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity 0.7.6; pragma abicoder v2; // imports import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/utils/ReentrancyGuard.sol"; import "./LPTokenERC20.sol"; import "./interfaces/IStargateFeeLibrary.sol"; // libraries import "@openzeppelin/contracts/math/SafeMath.sol"; /// Pool contracts on other chains and managed by the Stargate protocol. contract Pool is LPTokenERC20, ReentrancyGuard { using SafeMath for uint256; //--------------------------------------------------------------------------- // CONSTANTS bytes4 private constant SELECTOR = bytes4(keccak256(bytes("transfer(address,uint256)"))); uint256 public constant BP_DENOMINATOR = 10000; //--------------------------------------------------------------------------- // STRUCTS struct ChainPath { bool ready; // indicate if the counter chainPath has been created. uint16 dstChainId; uint256 dstPoolId; uint256 weight; uint256 balance; uint256 lkb; uint256 credits; uint256 idealBalance; } struct SwapObj { uint256 amount; uint256 eqFee; uint256 eqReward; uint256 lpFee; uint256 protocolFee; uint256 lkbRemove; } struct CreditObj { uint256 credits; uint256 idealBalance; } //--------------------------------------------------------------------------- // VARIABLES // chainPath ChainPath[] public chainPaths; // list of connected chains with shared pools mapping(uint16 => mapping(uint256 => uint256)) public chainPathIndexLookup; // lookup for chainPath by chainId => poolId =>index // metadata uint256 public immutable poolId; // shared id between chains to represent same pool uint256 public sharedDecimals; // the shared decimals (lowest common decimals between chains) uint256 public localDecimals; // the decimals for the token uint256 public immutable convertRate; // the decimals for the token address public immutable token; // the token for the pool address public immutable router; // the token for the pool bool public stopSwap; // flag to stop swapping in extreme cases // Fee and Liquidity uint256 public totalLiquidity; // the total amount of tokens added on this side of the chain (fees + deposits - withdrawals) uint256 public totalWeight; // total weight for pool percentages uint256 public mintFeeBP; // fee basis points for the mint/deposit uint256 public protocolFeeBalance; // fee balance created from dao fee uint256 public mintFeeBalance; // fee balance created from mint fee uint256 public eqFeePool; // pool rewards in Shared Decimal format. indicate the total budget for reverse swap incentive address public feeLibrary; // address for retrieving fee params for swaps // Delta related uint256 public deltaCredit; // credits accumulated from txn bool public batched; // flag to indicate if we want batch processing. bool public defaultSwapMode; // flag for the default mode for swap bool public defaultLPMode; // flag for the default mode for lp uint256 public swapDeltaBP; // basis points of poolCredits to activate Delta in swap uint256 public lpDeltaBP; // basis points of poolCredits to activate Delta in liquidity events //--------------------------------------------------------------------------- // EVENTS event Mint(address to, uint256 amountLP, uint256 amountSD, uint256 mintFeeAmountSD); event Burn(address from, uint256 amountLP, uint256 amountSD); event RedeemLocalCallback(address _to, uint256 _amountSD, uint256 _amountToMintSD); event Swap( uint16 chainId, uint256 dstPoolId, address from, uint256 amountSD, uint256 eqReward, uint256 eqFee, uint256 protocolFee, uint256 lpFee ); event SendCredits(uint16 dstChainId, uint256 dstPoolId, uint256 credits, uint256 idealBalance); event RedeemRemote(uint16 chainId, uint256 dstPoolId, address from, uint256 amountLP, uint256 amountSD); event RedeemLocal(address from, uint256 amountLP, uint256 amountSD, uint16 chainId, uint256 dstPoolId, bytes to); event InstantRedeemLocal(address from, uint256 amountLP, uint256 amountSD, address to); event CreditChainPath(uint16 chainId, uint256 srcPoolId, uint256 amountSD, uint256 idealBalance); event SwapRemote(address to, uint256 amountSD, uint256 protocolFee, uint256 dstFee); event WithdrawRemote(uint16 srcChainId, uint256 srcPoolId, uint256 swapAmount, uint256 mintAmount); event ChainPathUpdate(uint16 dstChainId, uint256 dstPoolId, uint256 weight); event FeesUpdated(uint256 mintFeeBP); event FeeLibraryUpdated(address feeLibraryAddr); event StopSwapUpdated(bool swapStop); event WithdrawProtocolFeeBalance(address to, uint256 amountSD); event WithdrawMintFeeBalance(address to, uint256 amountSD); event DeltaParamUpdated(bool batched, uint256 swapDeltaBP, uint256 lpDeltaBP, bool defaultSwapMode, bool defaultLPMode); //--------------------------------------------------------------------------- // MODIFIERS modifier onlyRouter() { require(msg.sender == router, "Stargate: only the router can call this method"); _; } constructor( uint256 _poolId, address _router, address _token, uint256 _sharedDecimals, uint256 _localDecimals, address _feeLibrary, string memory _name, string memory _symbol ) LPTokenERC20(_name, _symbol) { require(_token != address(0x0), "Stargate: _token cannot be 0x0"); require(_router != address(0x0), "Stargate: _router cannot be 0x0"); poolId = _poolId; router = _router; token = _token; sharedDecimals = _sharedDecimals; decimals = uint8(_sharedDecimals); localDecimals = _localDecimals; convertRate = 10**(uint256(localDecimals).sub(sharedDecimals)); totalWeight = 0; feeLibrary = _feeLibrary; //delta algo related batched = false; defaultSwapMode = true; defaultLPMode = true; } function getChainPathsLength() public view returns (uint256) { return chainPaths.length; } //--------------------------------------------------------------------------- // LOCAL CHAIN FUNCTIONS function mint(address _to, uint256 _amountLD) external nonReentrant onlyRouter returns (uint256) { return _mintLocal(_to, _amountLD, true, true); } // Local Remote // ------- --------- // swap -> swapRemote function swap( uint16 _dstChainId, uint256 _dstPoolId, address _from, uint256 _amountLD, uint256 _minAmountLD, bool newLiquidity ) external nonReentrant onlyRouter returns (SwapObj memory) { require(!stopSwap, "Stargate: swap func stopped"); ChainPath storage cp = getAndCheckCP(_dstChainId, _dstPoolId); require(cp.ready == true, "Stargate: counter chainPath is not ready"); uint256 amountSD = amountLDtoSD(_amountLD); uint256 minAmountSD = amountLDtoSD(_minAmountLD); // request fee params from library SwapObj memory s = IStargateFeeLibrary(feeLibrary).getFees(poolId, _dstPoolId, _dstChainId, _from, amountSD); // equilibrium fee and reward. note eqFee/eqReward are separated from swap liquidity eqFeePool = eqFeePool.sub(s.eqReward); // update the new amount the user gets minus the fees s.amount = amountSD.sub(s.eqFee).sub(s.protocolFee).sub(s.lpFee); // users will also get the eqReward require(s.amount.add(s.eqReward) >= minAmountSD, "Stargate: slippage too high"); // behaviours // - protocolFee: booked, stayed and withdrawn at remote. // - eqFee: booked, stayed and withdrawn at remote. // - lpFee: booked and stayed at remote, can be withdrawn anywhere s.lkbRemove = amountSD.sub(s.lpFee).add(s.eqReward); // check for transfer solvency. require(cp.balance >= s.lkbRemove, "Stargate: dst balance too low"); cp.balance = cp.balance.sub(s.lkbRemove); if (newLiquidity) { deltaCredit = deltaCredit.add(amountSD).add(s.eqReward); } else if (s.eqReward > 0) { deltaCredit = deltaCredit.add(s.eqReward); } // distribute credits on condition. if (!batched || deltaCredit >= totalLiquidity.mul(swapDeltaBP).div(BP_DENOMINATOR)) { _delta(defaultSwapMode); } emit Swap(_dstChainId, _dstPoolId, _from, s.amount, s.eqReward, s.eqFee, s.protocolFee, s.lpFee); return s; } // Local Remote // ------- --------- // sendCredits -> creditChainPath function sendCredits(uint16 _dstChainId, uint256 _dstPoolId) external nonReentrant onlyRouter returns (CreditObj memory c) { ChainPath storage cp = getAndCheckCP(_dstChainId, _dstPoolId); require(cp.ready == true, "Stargate: counter chainPath is not ready"); cp.lkb = cp.lkb.add(cp.credits); c.idealBalance = totalLiquidity.mul(cp.weight).div(totalWeight); c.credits = cp.credits; cp.credits = 0; emit SendCredits(_dstChainId, _dstPoolId, c.credits, c.idealBalance); } // Local Remote // ------- --------- // redeemRemote -> swapRemote function redeemRemote( uint16 _dstChainId, uint256 _dstPoolId, address _from, uint256 _amountLP ) external nonReentrant onlyRouter { require(_from != address(0x0), "Stargate: _from cannot be 0x0"); uint256 amountSD = _burnLocal(_from, _amountLP); //run Delta if (!batched || deltaCredit > totalLiquidity.mul(lpDeltaBP).div(BP_DENOMINATOR)) { _delta(defaultLPMode); } uint256 amountLD = amountSDtoLD(amountSD); emit RedeemRemote(_dstChainId, _dstPoolId, _from, _amountLP, amountLD); } function instantRedeemLocal( address _from, uint256 _amountLP, address _to ) external nonReentrant onlyRouter returns (uint256 amountSD) { require(_from != address(0x0), "Stargate: _from cannot be 0x0"); uint256 _deltaCredit = deltaCredit; // sload optimization. uint256 _capAmountLP = _amountSDtoLP(_deltaCredit); if (_amountLP > _capAmountLP) _amountLP = _capAmountLP; amountSD = _burnLocal(_from, _amountLP); deltaCredit = _deltaCredit.sub(amountSD); uint256 amountLD = amountSDtoLD(amountSD); _safeTransfer(token, _to, amountLD); emit InstantRedeemLocal(_from, _amountLP, amountSD, _to); } // Local Remote // ------- --------- // redeemLocal -> redeemLocalCheckOnRemote // redeemLocalCallback <- function redeemLocal( address _from, uint256 _amountLP, uint16 _dstChainId, uint256 _dstPoolId, bytes calldata _to ) external nonReentrant onlyRouter returns (uint256 amountSD) { require(_from != address(0x0), "Stargate: _from cannot be 0x0"); // safeguard. require(chainPaths[chainPathIndexLookup[_dstChainId][_dstPoolId]].ready == true, "Stargate: counter chainPath is not ready"); amountSD = _burnLocal(_from, _amountLP); // run Delta if (!batched || deltaCredit > totalLiquidity.mul(lpDeltaBP).div(BP_DENOMINATOR)) { _delta(false); } emit RedeemLocal(_from, _amountLP, amountSD, _dstChainId, _dstPoolId, _to); } //--------------------------------------------------------------------------- // REMOTE CHAIN FUNCTIONS // Local Remote // ------- --------- // sendCredits -> creditChainPath function creditChainPath( uint16 _dstChainId, uint256 _dstPoolId, CreditObj memory _c ) external nonReentrant onlyRouter { ChainPath storage cp = chainPaths[chainPathIndexLookup[_dstChainId][_dstPoolId]]; cp.balance = cp.balance.add(_c.credits); if (cp.idealBalance != _c.idealBalance) { cp.idealBalance = _c.idealBalance; } emit CreditChainPath(_dstChainId, _dstPoolId, _c.credits, _c.idealBalance); } // Local Remote // ------- --------- // swap -> swapRemote function swapRemote( uint16 _srcChainId, uint256 _srcPoolId, address _to, SwapObj memory _s ) external nonReentrant onlyRouter returns (uint256 amountLD) { // booking lpFee totalLiquidity = totalLiquidity.add(_s.lpFee); // booking eqFee eqFeePool = eqFeePool.add(_s.eqFee); // booking stargateFee protocolFeeBalance = protocolFeeBalance.add(_s.protocolFee); // update LKB uint256 chainPathIndex = chainPathIndexLookup[_srcChainId][_srcPoolId]; chainPaths[chainPathIndex].lkb = chainPaths[chainPathIndex].lkb.sub(_s.lkbRemove); // user receives the amount + the srcReward amountLD = amountSDtoLD(_s.amount.add(_s.eqReward)); _safeTransfer(token, _to, amountLD); emit SwapRemote(_to, _s.amount.add(_s.eqReward), _s.protocolFee, _s.eqFee); } // Local Remote // ------- --------- // redeemLocal -> redeemLocalCheckOnRemote // redeemLocalCallback <- function redeemLocalCallback( uint16 _srcChainId, uint256 _srcPoolId, address _to, uint256 _amountSD, uint256 _amountToMintSD ) external nonReentrant onlyRouter { if (_amountToMintSD > 0) { _mintLocal(_to, amountSDtoLD(_amountToMintSD), false, false); } ChainPath storage cp = getAndCheckCP(_srcChainId, _srcPoolId); cp.lkb = cp.lkb.sub(_amountSD); uint256 amountLD = amountSDtoLD(_amountSD); _safeTransfer(token, _to, amountLD); emit RedeemLocalCallback(_to, _amountSD, _amountToMintSD); } // Local Remote // ------- --------- // redeemLocal(amount) -> redeemLocalCheckOnRemote // redeemLocalCallback <- function redeemLocalCheckOnRemote( uint16 _srcChainId, uint256 _srcPoolId, uint256 _amountSD ) external nonReentrant onlyRouter returns (uint256 swapAmount, uint256 mintAmount) { ChainPath storage cp = getAndCheckCP(_srcChainId, _srcPoolId); if (_amountSD > cp.balance) { mintAmount = _amountSD - cp.balance; swapAmount = cp.balance; cp.balance = 0; } else { cp.balance = cp.balance.sub(_amountSD); swapAmount = _amountSD; mintAmount = 0; } emit WithdrawRemote(_srcChainId, _srcPoolId, swapAmount, mintAmount); } //--------------------------------------------------------------------------- // DAO Calls function createChainPath( uint16 _dstChainId, uint256 _dstPoolId, uint256 _weight ) external onlyRouter { for (uint256 i = 0; i < chainPaths.length; ++i) { ChainPath memory cp = chainPaths[i]; bool exists = cp.dstChainId == _dstChainId && cp.dstPoolId == _dstPoolId; require(!exists, "Stargate: cant createChainPath of existing dstChainId and _dstPoolId"); } totalWeight = totalWeight.add(_weight); chainPathIndexLookup[_dstChainId][_dstPoolId] = chainPaths.length; chainPaths.push(ChainPath(false, _dstChainId, _dstPoolId, _weight, 0, 0, 0, 0)); emit ChainPathUpdate(_dstChainId, _dstPoolId, _weight); } function setWeightForChainPath( uint16 _dstChainId, uint256 _dstPoolId, uint16 _weight ) external onlyRouter { ChainPath storage cp = getAndCheckCP(_dstChainId, _dstPoolId); totalWeight = totalWeight.sub(cp.weight).add(_weight); cp.weight = _weight; emit ChainPathUpdate(_dstChainId, _dstPoolId, _weight); } function setFee(uint256 _mintFeeBP) external onlyRouter { require(_mintFeeBP <= BP_DENOMINATOR, "Bridge: cum fees > 100%"); mintFeeBP = _mintFeeBP; emit FeesUpdated(mintFeeBP); } function setFeeLibrary(address _feeLibraryAddr) external onlyRouter { require(_feeLibraryAddr != address(0x0), "Stargate: fee library cant be 0x0"); feeLibrary = _feeLibraryAddr; emit FeeLibraryUpdated(_feeLibraryAddr); } function setSwapStop(bool _swapStop) external onlyRouter { stopSwap = _swapStop; emit StopSwapUpdated(_swapStop); } function setDeltaParam( bool _batched, uint256 _swapDeltaBP, uint256 _lpDeltaBP, bool _defaultSwapMode, bool _defaultLPMode ) external onlyRouter { require(_swapDeltaBP <= BP_DENOMINATOR && _lpDeltaBP <= BP_DENOMINATOR, "Stargate: wrong Delta param"); batched = _batched; swapDeltaBP = _swapDeltaBP; lpDeltaBP = _lpDeltaBP; defaultSwapMode = _defaultSwapMode; defaultLPMode = _defaultLPMode; emit DeltaParamUpdated(_batched, _swapDeltaBP, _lpDeltaBP, _defaultSwapMode, _defaultLPMode); } function callDelta(bool _fullMode) external onlyRouter { _delta(_fullMode); } function activateChainPath(uint16 _dstChainId, uint256 _dstPoolId) external onlyRouter { ChainPath storage cp = getAndCheckCP(_dstChainId, _dstPoolId); require(cp.ready == false, "Stargate: chainPath is already active"); // this func will only be called once cp.ready = true; } function withdrawProtocolFeeBalance(address _to) external onlyRouter { if (protocolFeeBalance > 0) { uint256 amountOfLD = amountSDtoLD(protocolFeeBalance); protocolFeeBalance = 0; _safeTransfer(token, _to, amountOfLD); emit WithdrawProtocolFeeBalance(_to, amountOfLD); } } function withdrawMintFeeBalance(address _to) external onlyRouter { if (mintFeeBalance > 0) { uint256 amountOfLD = amountSDtoLD(mintFeeBalance); mintFeeBalance = 0; _safeTransfer(token, _to, amountOfLD); emit WithdrawMintFeeBalance(_to, amountOfLD); } } //--------------------------------------------------------------------------- // INTERNAL // Conversion Helpers //--------------------------------------------------------------------------- function amountLPtoLD(uint256 _amountLP) external view returns (uint256) { return amountSDtoLD(_amountLPtoSD(_amountLP)); } function _amountLPtoSD(uint256 _amountLP) internal view returns (uint256) { require(totalSupply > 0, "Stargate: cant convert LPtoSD when totalSupply == 0"); return _amountLP.mul(totalLiquidity).div(totalSupply); } function _amountSDtoLP(uint256 _amountSD) internal view returns (uint256) { require(totalLiquidity > 0, "Stargate: cant convert SDtoLP when totalLiq == 0"); return _amountSD.mul(totalSupply).div(totalLiquidity); } function amountSDtoLD(uint256 _amount) internal view returns (uint256) { return _amount.mul(convertRate); } function amountLDtoSD(uint256 _amount) internal view returns (uint256) { return _amount.div(convertRate); } function getAndCheckCP(uint16 _dstChainId, uint256 _dstPoolId) internal view returns (ChainPath storage) { require(chainPaths.length > 0, "Stargate: no chainpaths exist"); ChainPath storage cp = chainPaths[chainPathIndexLookup[_dstChainId][_dstPoolId]]; require(cp.dstChainId == _dstChainId && cp.dstPoolId == _dstPoolId, "Stargate: local chainPath does not exist"); return cp; } function getChainPath(uint16 _dstChainId, uint256 _dstPoolId) external view returns (ChainPath memory) { ChainPath memory cp = chainPaths[chainPathIndexLookup[_dstChainId][_dstPoolId]]; require(cp.dstChainId == _dstChainId && cp.dstPoolId == _dstPoolId, "Stargate: local chainPath does not exist"); return cp; } function _burnLocal(address _from, uint256 _amountLP) internal returns (uint256) { require(totalSupply > 0, "Stargate: cant burn when totalSupply == 0"); uint256 amountOfLPTokens = balanceOf[_from]; require(amountOfLPTokens >= _amountLP, "Stargate: not enough LP tokens to burn"); uint256 amountSD = _amountLP.mul(totalLiquidity).div(totalSupply); //subtract totalLiquidity accordingly totalLiquidity = totalLiquidity.sub(amountSD); _burn(_from, _amountLP); emit Burn(_from, _amountLP, amountSD); return amountSD; } function _delta(bool fullMode) internal { if (deltaCredit > 0 && totalWeight > 0) { uint256 cpLength = chainPaths.length; uint256[] memory deficit = new uint256[](cpLength); uint256 totalDeficit = 0; // algorithm steps 6-9: calculate the total and the amounts required to get to balance state for (uint256 i = 0; i < cpLength; ++i) { ChainPath storage cp = chainPaths[i]; // (liquidity * (weight/totalWeight)) - (lkb+credits) uint256 balLiq = totalLiquidity.mul(cp.weight).div(totalWeight); uint256 currLiq = cp.lkb.add(cp.credits); if (balLiq > currLiq) { // save gas since we know balLiq > currLiq and we know deficit[i] > 0 deficit[i] = balLiq - currLiq; totalDeficit = totalDeficit.add(deficit[i]); } } // indicates how much delta credit is distributed uint256 spent; // handle credits with 2 tranches. the [ < totalDeficit] [excessCredit] // run full Delta, allocate all credits if (totalDeficit == 0) { // only fullMode delta will allocate excess credits if (fullMode && deltaCredit > 0) { // credit ChainPath by weights for (uint256 i = 0; i < cpLength; ++i) { ChainPath storage cp = chainPaths[i]; // credits = credits + toBalanceChange + remaining allocation based on weight uint256 amtToCredit = deltaCredit.mul(cp.weight).div(totalWeight); spent = spent.add(amtToCredit); cp.credits = cp.credits.add(amtToCredit); } } // else do nth } else if (totalDeficit <= deltaCredit) { if (fullMode) { // algorithm step 13: calculate amount to disperse to bring to balance state or as close as possible uint256 excessCredit = deltaCredit - totalDeficit; // algorithm steps 14-16: calculate credits for (uint256 i = 0; i < cpLength; ++i) { if (deficit[i] > 0) { ChainPath storage cp = chainPaths[i]; // credits = credits + deficit + remaining allocation based on weight uint256 amtToCredit = deficit[i].add(excessCredit.mul(cp.weight).div(totalWeight)); spent = spent.add(amtToCredit); cp.credits = cp.credits.add(amtToCredit); } } } else { // totalDeficit <= deltaCredit but not running fullMode // credit chainPaths as is if any deficit, not using all deltaCredit for (uint256 i = 0; i < cpLength; ++i) { if (deficit[i] > 0) { ChainPath storage cp = chainPaths[i]; uint256 amtToCredit = deficit[i]; spent = spent.add(amtToCredit); cp.credits = cp.credits.add(amtToCredit); } } } } else { // totalDeficit > deltaCredit, fullMode or not, normalize the deficit by deltaCredit for (uint256 i = 0; i < cpLength; ++i) { if (deficit[i] > 0) { ChainPath storage cp = chainPaths[i]; uint256 proportionalDeficit = deficit[i].mul(deltaCredit).div(totalDeficit); spent = spent.add(proportionalDeficit); cp.credits = cp.credits.add(proportionalDeficit); } } } // deduct the amount of credit sent deltaCredit = deltaCredit.sub(spent); } } function _mintLocal( address _to, uint256 _amountLD, bool _feesEnabled, bool _creditDelta ) internal returns (uint256 amountSD) { require(totalWeight > 0, "Stargate: No ChainPaths exist"); amountSD = amountLDtoSD(_amountLD); uint256 mintFeeSD = 0; if (_feesEnabled) { mintFeeSD = amountSD.mul(mintFeeBP).div(BP_DENOMINATOR); amountSD = amountSD.sub(mintFeeSD); mintFeeBalance = mintFeeBalance.add(mintFeeSD); } if (_creditDelta) { deltaCredit = deltaCredit.add(amountSD); } uint256 amountLPTokens = amountSD; if (totalSupply != 0) { amountLPTokens = amountSD.mul(totalSupply).div(totalLiquidity); } totalLiquidity = totalLiquidity.add(amountSD); _mint(_to, amountLPTokens); emit Mint(_to, amountLPTokens, amountSD, mintFeeSD); // add to credits and call delta. short circuit to save gas if (!batched || deltaCredit > totalLiquidity.mul(lpDeltaBP).div(BP_DENOMINATOR)) { _delta(defaultLPMode); } } function _safeTransfer( address _token, address _to, uint256 _value ) private { (bool success, bytes memory data) = _token.call(abi.encodeWithSelector(SELECTOR, _to, _value)); require(success && (data.length == 0 || abi.decode(data, (bool))), "Stargate: TRANSFER_FAILED"); } }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity 0.7.6; pragma abicoder v2; import "@openzeppelin/contracts/math/SafeMath.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; import "./Pool.sol"; contract Factory is Ownable { using SafeMath for uint256; //--------------------------------------------------------------------------- // VARIABLES mapping(uint256 => Pool) public getPool; // poolId -> PoolInfo address[] public allPools; address public immutable router; address public defaultFeeLibrary; // address for retrieving fee params for swaps //--------------------------------------------------------------------------- // MODIFIERS modifier onlyRouter() { require(msg.sender == router, "Stargate: caller must be Router."); _; } constructor(address _router) { require(_router != address(0x0), "Stargate: _router cant be 0x0"); // 1 time only router = _router; } function setDefaultFeeLibrary(address _defaultFeeLibrary) external onlyOwner { require(_defaultFeeLibrary != address(0x0), "Stargate: fee library cant be 0x0"); defaultFeeLibrary = _defaultFeeLibrary; } function allPoolsLength() external view returns (uint256) { return allPools.length; } function createPool( uint256 _poolId, address _token, uint8 _sharedDecimals, uint8 _localDecimals, string memory _name, string memory _symbol ) public onlyRouter returns (address poolAddress) { require(address(getPool[_poolId]) == address(0x0), "Stargate: Pool already created"); Pool pool = new Pool(_poolId, router, _token, _sharedDecimals, _localDecimals, defaultFeeLibrary, _name, _symbol); getPool[_poolId] = pool; poolAddress = address(pool); allPools.push(poolAddress); } function renounceOwnership() public override onlyOwner {} }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.7.6; pragma abicoder v2; interface IStargateLPStaking { function poolInfo(uint256 _poolIndex) external view returns ( address, uint256, uint256, uint256 ); }
// SPDX-License-Identifier: MIT pragma solidity ^0.7.6; interface AggregatorV3Interface { function decimals() external view returns (uint8); function description() external view returns (string memory); function version() external view returns (uint256); // getRoundData and latestRoundData should both raise "No data present" // if they do not have data to report, instead of returning unset values // which could be misinterpreted as actual reported values. function getRoundData(uint80 _roundId) external view returns ( uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound ); function latestRoundData() external view returns ( uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound ); }
// SPDX-License-Identifier: MIT pragma solidity 0.7.6; import "@openzeppelin/contracts/access/Ownable.sol"; import "@layerzerolabs/layerzero-core/contracts/interfaces/ILayerZeroReceiver.sol"; import "@layerzerolabs/layerzero-core/contracts/interfaces/ILayerZeroEndpoint.sol"; import "@layerzerolabs/layerzero-core/contracts/interfaces/ILayerZeroUserApplicationConfig.sol"; /* * a generic LzReceiver implementation */ abstract contract LzApp is Ownable, ILayerZeroReceiver, ILayerZeroUserApplicationConfig { ILayerZeroEndpoint public immutable lzEndpoint; mapping(uint16 => bytes) public trustedRemoteLookup; mapping(uint16 => mapping(uint16 => uint)) public minDstGasLookup; address public precrime; event SetPrecrime(address precrime); event SetTrustedRemote(uint16 _remoteChainId, bytes _path); event SetTrustedRemoteAddress(uint16 _remoteChainId, bytes _remoteAddress); event SetMinDstGas(uint16 _dstChainId, uint16 _type, uint _minDstGas); constructor(address _endpoint) { lzEndpoint = ILayerZeroEndpoint(_endpoint); } function lzReceive(uint16 _srcChainId, bytes calldata _srcAddress, uint64 _nonce, bytes calldata _payload) public virtual override { // lzReceive must be called by the endpoint for security require(_msgSender() == address(lzEndpoint), "LzApp: invalid endpoint caller"); bytes memory trustedRemote = trustedRemoteLookup[_srcChainId]; // if will still block the message pathway from (srcChainId, srcAddress). should not receive message from untrusted remote. require(_srcAddress.length == trustedRemote.length && trustedRemote.length > 0 && keccak256(_srcAddress) == keccak256(trustedRemote), "LzApp: invalid source sending contract"); _blockingLzReceive(_srcChainId, _srcAddress, _nonce, _payload); } // abstract function - the default behaviour of LayerZero is blocking. See: NonblockingLzApp if you dont need to enforce ordered messaging function _blockingLzReceive(uint16 _srcChainId, bytes memory _srcAddress, uint64 _nonce, bytes memory _payload) internal virtual; function _lzSend(uint16 _dstChainId, bytes memory _payload, address payable _refundAddress, address _zroPaymentAddress, bytes memory _adapterParams, uint _nativeFee) internal virtual { bytes memory trustedRemote = trustedRemoteLookup[_dstChainId]; require(trustedRemote.length != 0, "LzApp: destination chain is not a trusted source"); lzEndpoint.send{value: _nativeFee}(_dstChainId, trustedRemote, _payload, _refundAddress, _zroPaymentAddress, _adapterParams); } function _checkGasLimit(uint16 _dstChainId, uint16 _type, bytes memory _adapterParams, uint _extraGas) internal view virtual { uint providedGasLimit = _getGasLimit(_adapterParams); uint minGasLimit = minDstGasLookup[_dstChainId][_type] + _extraGas; require(minGasLimit > 0, "LzApp: minGasLimit not set"); require(providedGasLimit >= minGasLimit, "LzApp: gas limit is too low"); } function _getGasLimit(bytes memory _adapterParams) internal pure virtual returns (uint gasLimit) { require(_adapterParams.length >= 34, "LzApp: invalid adapterParams"); assembly { gasLimit := mload(add(_adapterParams, 34)) } } //---------------------------UserApplication config---------------------------------------- function getConfig(uint16 _version, uint16 _chainId, address, uint _configType) external view returns (bytes memory) { return lzEndpoint.getConfig(_version, _chainId, address(this), _configType); } // generic config for LayerZero user Application function setConfig(uint16 _version, uint16 _chainId, uint _configType, bytes calldata _config) external override onlyOwner { lzEndpoint.setConfig(_version, _chainId, _configType, _config); } function setSendVersion(uint16 _version) external override onlyOwner { lzEndpoint.setSendVersion(_version); } function setReceiveVersion(uint16 _version) external override onlyOwner { lzEndpoint.setReceiveVersion(_version); } function forceResumeReceive(uint16 _srcChainId, bytes calldata _srcAddress) external override onlyOwner { lzEndpoint.forceResumeReceive(_srcChainId, _srcAddress); } // _path = abi.encodePacked(remoteAddress, localAddress) // this function set the trusted path for the cross-chain communication function setTrustedRemote(uint16 _srcChainId, bytes calldata _path) external onlyOwner { trustedRemoteLookup[_srcChainId] = _path; emit SetTrustedRemote(_srcChainId, _path); } function setPrecrime(address _precrime) external onlyOwner { precrime = _precrime; emit SetPrecrime(_precrime); } function setMinDstGas(uint16 _dstChainId, uint16 _packetType, uint _minGas) external onlyOwner { require(_minGas > 0, "LzApp: invalid minGas"); minDstGasLookup[_dstChainId][_packetType] = _minGas; emit SetMinDstGas(_dstChainId, _packetType, _minGas); } //--------------------------- VIEW FUNCTION ---------------------------------------- function isTrustedRemote(uint16 _srcChainId, bytes calldata _srcAddress) external view returns (bool) { bytes memory trustedSource = trustedRemoteLookup[_srcChainId]; return keccak256(trustedSource) == keccak256(_srcAddress); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.7.0; /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) { uint256 c = a + b; if (c < a) return (false, 0); return (true, c); } /** * @dev Returns the substraction of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) { if (b > a) return (false, 0); return (true, a - b); } /** * @dev Returns the multiplication of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) return (true, 0); uint256 c = a * b; if (c / a != b) return (false, 0); return (true, c); } /** * @dev Returns the division of two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) { if (b == 0) return (false, 0); return (true, a / b); } /** * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) { if (b == 0) return (false, 0); return (true, a % b); } /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { require(b <= a, "SafeMath: subtraction overflow"); return a - b; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) return 0; uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers, reverting on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0, "SafeMath: division by zero"); return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0, "SafeMath: modulo by zero"); return a % b; } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {trySub}. * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); return a - b; } /** * @dev Returns the integer division of two unsigned integers, reverting with custom message on * division by zero. The result is rounded towards zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryDiv}. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting with custom message when dividing by zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryMod}. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); return a % b; } }
// SPDX-License-Identifier: MIT pragma solidity ^0.7.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); }
{ "optimizer": { "enabled": true, "runs": 200 }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "metadata": { "useLiteralContent": true } }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[{"internalType":"address","name":"_factory","type":"address"},{"internalType":"address","name":"_endpoint","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"poolId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"priceSD","type":"uint256"},{"indexed":false,"internalType":"enum StargateFeeLibraryV05.PriceDeviationState","name":"state","type":"uint8"}],"name":"PriceUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint16","name":"_dstChainId","type":"uint16"},{"indexed":false,"internalType":"uint16","name":"_type","type":"uint16"},{"indexed":false,"internalType":"uint256","name":"_minDstGas","type":"uint256"}],"name":"SetMinDstGas","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"precrime","type":"address"}],"name":"SetPrecrime","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint16","name":"_remoteChainId","type":"uint16"},{"indexed":false,"internalType":"bytes","name":"_path","type":"bytes"}],"name":"SetTrustedRemote","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint16","name":"_remoteChainId","type":"uint16"},{"indexed":false,"internalType":"bytes","name":"_remoteAddress","type":"bytes"}],"name":"SetTrustedRemoteAddress","type":"event"},{"inputs":[],"name":"DELTA_1","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"DELTA_2","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"DENOMINATOR","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"EQ_REWARD_CAP","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"EQ_REWARD_THRESHOLD","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"FIFTY_PERCENT","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"LAMBDA_1","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"LAMBDA_2","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"LP_FEE","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"LP_FEE_WITH_EQ_REWARD","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ONE_BPS_PRICE_CHANGE_THRESHOLD","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"PRICE_DEPEG_THRESHOLD","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"PRICE_DRIFT_THRESHOLD","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"PRICE_SHARED_DECIMALS","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"PROTOCOL_FEE","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"PROTOCOL_FEE_FOR_SAME_TOKEN","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"PROTOCOL_FEE_WITH_EQ_REWARD","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"PROTOCOL_SUBSIDY","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"SIXTY_PERCENT","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"TEN_BPS_PRICE_CHANGE_THRESHOLD","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint16","name":"","type":"uint16"}],"name":"defaultAdapterParams","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"factory","outputs":[{"internalType":"contract Factory","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint16","name":"_srcChainId","type":"uint16"},{"internalType":"bytes","name":"_srcAddress","type":"bytes"}],"name":"forceResumeReceive","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"_version","type":"uint16"},{"internalType":"uint16","name":"_chainId","type":"uint16"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"_configType","type":"uint256"}],"name":"getConfig","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_srcPoolId","type":"uint256"},{"internalType":"uint256","name":"_dstPoolId","type":"uint256"},{"internalType":"uint256","name":"_amountSD","type":"uint256"},{"internalType":"bool","name":"_whitelisted","type":"bool"}],"name":"getDriftFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_srcPoolId","type":"uint256"},{"internalType":"uint256","name":"_amountSD","type":"uint256"},{"internalType":"bool","name":"_whitelisted","type":"bool"}],"name":"getEqReward","outputs":[{"internalType":"uint256","name":"eqReward","type":"uint256"},{"internalType":"uint256","name":"protocolFee","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"srcPoolId","type":"uint256"},{"internalType":"uint256","name":"dstPoolId","type":"uint256"},{"internalType":"uint16","name":"dstChainId","type":"uint16"},{"internalType":"uint256","name":"amountSD","type":"uint256"},{"internalType":"bool","name":"whitelisted","type":"bool"},{"internalType":"bool","name":"hasEqReward","type":"bool"}],"name":"getEquilibriumFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_srcPoolId","type":"uint256"},{"internalType":"uint256","name":"_dstPoolId","type":"uint256"},{"internalType":"uint16","name":"_dstChainId","type":"uint16"},{"internalType":"address","name":"_from","type":"address"},{"internalType":"uint256","name":"_amountSD","type":"uint256"}],"name":"getFees","outputs":[{"components":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"eqFee","type":"uint256"},{"internalType":"uint256","name":"eqReward","type":"uint256"},{"internalType":"uint256","name":"lpFee","type":"uint256"},{"internalType":"uint256","name":"protocolFee","type":"uint256"},{"internalType":"uint256","name":"lkbRemove","type":"uint256"}],"internalType":"struct Pool.SwapObj","name":"s","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_srcPoolId","type":"uint256"},{"internalType":"uint256","name":"_dstPoolId","type":"uint256"},{"internalType":"uint16","name":"","type":"uint16"},{"internalType":"uint256","name":"_amountSD","type":"uint256"},{"internalType":"uint256","name":"_protocolSubsidy","type":"uint256"},{"internalType":"bool","name":"_whitelisted","type":"bool"},{"internalType":"bool","name":"_hasEqReward","type":"bool"}],"name":"getProtocolAndLpFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_poolId","type":"uint256"}],"name":"getRemoteChainIds","outputs":[{"internalType":"uint16[]","name":"","type":"uint16[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getVersion","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"_poolId1","type":"uint256"},{"internalType":"uint256","name":"_poolId2","type":"uint256"}],"name":"isSameToken","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_poolId","type":"uint256"}],"name":"isTokenPriceChanged","outputs":[{"internalType":"bool","name":"","type":"bool"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"enum StargateFeeLibraryV05.PriceDeviationState","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint16","name":"_srcChainId","type":"uint16"},{"internalType":"bytes","name":"_srcAddress","type":"bytes"}],"name":"isTrustedRemote","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lzEndpoint","outputs":[{"internalType":"contract ILayerZeroEndpoint","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint16","name":"_srcChainId","type":"uint16"},{"internalType":"bytes","name":"_srcAddress","type":"bytes"},{"internalType":"uint64","name":"_nonce","type":"uint64"},{"internalType":"bytes","name":"_payload","type":"bytes"}],"name":"lzReceive","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"","type":"uint16"},{"internalType":"uint16","name":"","type":"uint16"}],"name":"minDstGasLookup","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"poolIdToLpId","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"poolIdToPrice","outputs":[{"internalType":"address","name":"priceFeedAddress","type":"address"},{"internalType":"uint256","name":"basePriceSD","type":"uint256"},{"internalType":"uint256","name":"currentPriceSD","type":"uint256"},{"internalType":"enum StargateFeeLibraryV05.PriceDeviationState","name":"state","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"precrime","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_poolId","type":"uint256"}],"name":"quoteFeeForPriceUpdate","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"sameToken","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint16","name":"_version","type":"uint16"},{"internalType":"uint16","name":"_chainId","type":"uint16"},{"internalType":"uint256","name":"_configType","type":"uint256"},{"internalType":"bytes","name":"_config","type":"bytes"}],"name":"setConfig","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"_remoteChainId","type":"uint16"},{"internalType":"bytes","name":"_adapterParams","type":"bytes"}],"name":"setDefaultAdapterParams","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"_dstChainId","type":"uint16"},{"internalType":"uint16","name":"_packetType","type":"uint16"},{"internalType":"uint256","name":"_minGas","type":"uint256"}],"name":"setMinDstGas","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_poolId","type":"uint256"},{"internalType":"uint256","name":"_lpId","type":"uint256"}],"name":"setPoolToLpId","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_precrime","type":"address"}],"name":"setPrecrime","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"_version","type":"uint16"}],"name":"setReceiveVersion","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_poolId1","type":"uint256"},{"internalType":"uint256","name":"_poolId2","type":"uint256"},{"internalType":"bool","name":"_isSame","type":"bool"}],"name":"setSameToken","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"_version","type":"uint16"}],"name":"setSendVersion","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_poolId","type":"uint256"},{"internalType":"address","name":"_lpStaking","type":"address"}],"name":"setStargatePoolIdToLPStakingAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_poolId","type":"uint256"},{"internalType":"uint256","name":"_basePriceSD","type":"uint256"}],"name":"setTokenBasePrice","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_poolId","type":"uint256"},{"internalType":"address","name":"_priceFeedAddress","type":"address"},{"internalType":"uint16[]","name":"_remoteChainIds","type":"uint16[]"}],"name":"setTokenPriceFeed","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"_srcChainId","type":"uint16"},{"internalType":"bytes","name":"_path","type":"bytes"}],"name":"setTrustedRemote","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"stargatePoolIdToLPStaking","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"","type":"uint16"}],"name":"trustedRemoteLookup","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_poolId","type":"uint256"}],"name":"updateTokenPrice","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"_from","type":"address"},{"internalType":"bool","name":"_whiteListed","type":"bool"}],"name":"whiteList","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"whitelist","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"stateMutability":"payable","type":"receive"}]
Contract Creation Code
60c06040523480156200001157600080fd5b50604051620047403803806200474083398101604081905262000034916200012e565b806000620000416200010d565b600080546001600160a01b0319166001600160a01b0383169081178255604051929350917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908290a35060601b6001600160601b0319166080526001600160a01b038216620000cd5760405162461bcd60e51b8152600401620000c49062000165565b60405180910390fd5b6001600160a01b038116620000f65760405162461bcd60e51b8152600401620000c490620001a6565b5060601b6001600160601b03191660a052620001e8565b3390565b80516001600160a01b03811681146200012957600080fd5b919050565b6000806040838503121562000141578182fd5b6200014c8362000111565b91506200015c6020840162000111565b90509250929050565b60208082526021908201527f4665654c6962726172793a20466163746f72792063616e6e6f742062652030786040820152600360fc1b606082015260800190565b60208082526022908201527f4665654c6962726172793a20456e64706f696e742063616e6e6f742062652030604082015261078360f41b606082015260800190565b60805160601c60a05160601c6144fc62000244600039806119635280611d86528061235c525080610aa75280610d405280610e51528061129b528061142d528061201452806123e252806129de5280612f2a52506144fc6000f3fe6080604052600436106103b05760003560e01c80637ba5c12f116101e7578063baf3292d1161010d578063e18bce50116100a0578063f100e6771161006f578063f100e67714610a18578063f2fde38b14610a45578063f5ecbdbc14610a65578063fc6834a114610a85576103b7565b8063e18bce50146109a3578063e91e9b6f146109c3578063ea8e7530146109d8578063eb8d72b7146109f8576103b7565b8063d16baeb9116100dc578063d16baeb91461094e578063d616f0dd1461096e578063d7f6bde314610566578063df2a5b3b14610983576103b7565b8063baf3292d146108d9578063bb05078d146108f9578063c45a015514610919578063cbed8b9c1461092e576103b7565b8063950c8a7411610185578063a810de6c11610154578063a810de6c1461086f578063ad7bbfc914610884578063b353aaa7146108a4578063ba6afedf146108b9576103b7565b8063950c8a7414610805578063972883c41461081a5780639b19251a1461083a578063a14986351461085a576103b7565b806389ca9256116101c157806389ca92561461078c5780638cfd8f5c146107bb5780638da5cb5b146107db578063918f8674146107f0576103b7565b80637ba5c12f1461077757806380651ee2146106ac578063886a9c50146105c8576103b7565b80633d8b38f6116102d757806358cbb8ed1161026a5780636ddc4561116102395780636ddc4561146106f4578063715018a6146107145780637533d788146107295780637b35c26014610749576103b7565b806358cbb8ed1461068c5780635e3f2727146106ac5780636548c4ac146106c1578063676c0d77146106e1576103b7565b80634f6412d8116102a65780634f6412d814610612578063518a9f9f1461063257806352863703146106475780635436ac171461065c576103b7565b80633d8b38f6146105a85780633dad0dd5146105c857806342d65a8d146105dd5780634e8f4fa8146105fd576103b7565b806313c6e3801161034f57806323a443251161031e57806323a443251461051957806327274e85146105395780632b3ec8c9146105665780633c2c30651461057b576103b7565b806313c6e380146104a25780631738fe38146104c25780631ab62430146104d75780631e04cbf314610504576103b7565b806307e0db171161038b57806307e0db171461042b5780630b4501fd1461044b5780630d8e6e2c1461046057806310ddb13714610482576103b7565b80621d3567146103bc578063012a1c2d146103de578063040d583514610409576103b7565b366103b757005b600080fd5b3480156103c857600080fd5b506103dc6103d73660046139e4565b610aa5565b005b3480156103ea57600080fd5b506103f3610ccb565b6040516104009190614373565b60405180910390f35b34801561041557600080fd5b5061041e610cd7565b60405161040091906143b9565b34801561043757600080fd5b506103dc610446366004613975565b610cdc565b34801561045757600080fd5b506103f3610dc3565b34801561046c57600080fd5b50610475610dce565b6040516104009190614023565b34801561048e57600080fd5b506103dc61049d366004613975565b610ded565b3480156104ae57600080fd5b506103f36104bd366004613bef565b610eb9565b3480156104ce57600080fd5b506103f3610ecb565b3480156104e357600080fd5b506104f76104f2366004613d3a565b610ed6565b604051610400919061425e565b34801561051057600080fd5b506103f3610fe7565b34801561052557600080fd5b506103dc610534366004613cc9565b610ff3565b34801561054557600080fd5b50610559610554366004613cc9565b6110a0565b6040516104009190613ffb565b34801561057257600080fd5b506103f3611102565b34801561058757600080fd5b5061059b610596366004613bef565b61110d565b6040516104009190613f6b565b3480156105b457600080fd5b506105596105c3366004613991565b611128565b3480156105d457600080fd5b506103f36111fb565b3480156105e957600080fd5b506103dc6105f8366004613991565b611207565b34801561060957600080fd5b506103f361131c565b34801561061e57600080fd5b506103f361062d366004613bef565b611327565b34801561063e57600080fd5b506103f36114dc565b34801561065357600080fd5b506103f36114e7565b34801561066857600080fd5b5061067c610677366004613bef565b6114f2565b6040516104009493929190613f7f565b34801561069857600080fd5b506104756106a7366004613975565b611526565b3480156106b857600080fd5b506103f36115c1565b3480156106cd57600080fd5b506103dc6106dc366004613cc9565b6115cb565b6103dc6106ef366004613bef565b61163f565b34801561070057600080fd5b506103dc61070f366004613c1f565b611801565b34801561072057600080fd5b506103dc611891565b34801561073557600080fd5b50610475610744366004613975565b6118f5565b34801561075557600080fd5b50610769610764366004613d0d565b61195c565b604051610400929190614390565b34801561078357600080fd5b506103f3611c19565b34801561079857600080fd5b506107ac6107a7366004613bef565b611c23565b60405161040093929190614006565b3480156107c757600080fd5b506103f36107d6366004613a7c565b611c76565b3480156107e757600080fd5b5061059b611c93565b3480156107fc57600080fd5b506103f3611ca2565b34801561081157600080fd5b5061059b611cae565b34801561082657600080fd5b506103f3610835366004613e62565b611cbd565b34801561084657600080fd5b50610559610855366004613830565b611d2d565b34801561086657600080fd5b506103f3611d42565b34801561087b57600080fd5b506103f3611d4d565b34801561089057600080fd5b5061076961089f366004613d8b565b611d58565b3480156108b057600080fd5b5061059b612012565b3480156108c557600080fd5b506103dc6108d4366004613d0d565b612036565b3480156108e557600080fd5b506103dc6108f4366004613830565b612115565b34801561090557600080fd5b50610769610914366004613df1565b6121cb565b34801561092557600080fd5b5061059b61235a565b34801561093a57600080fd5b506103dc610949366004613b39565b61237e565b34801561095a57600080fd5b506103dc610969366004613868565b6124b1565b34801561097a57600080fd5b506103f361253e565b34801561098f57600080fd5b506103dc61099e366004613af9565b612548565b3480156109af57600080fd5b506105596109be366004613cc9565b612660565b3480156109cf57600080fd5b506103f3612680565b3480156109e457600080fd5b506103dc6109f3366004613c43565b61268a565b348015610a0457600080fd5b506103dc610a13366004613991565b612721565b348015610a2457600080fd5b50610a38610a33366004613bef565b612813565b6040516104009190613fb3565b348015610a5157600080fd5b506103dc610a60366004613830565b6128a0565b348015610a7157600080fd5b50610475610a80366004613aa9565b6129a2565b348015610a9157600080fd5b506103dc610aa0366004613991565b612b1c565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316610ad7612ba2565b6001600160a01b031614610b32576040805162461bcd60e51b815260206004820152601e60248201527f4c7a4170703a20696e76616c696420656e64706f696e742063616c6c65720000604482015290519081900360640190fd5b61ffff8616600090815260016020818152604080842080548251600295821615610100026000190190911694909404601f810184900484028501840190925281845291830182828015610bc65780601f10610b9b57610100808354040283529160200191610bc6565b820191906000526020600020905b815481529060010190602001808311610ba957829003601f168201915b50505050509050805186869050148015610be1575060008151115b8015610c115750808051906020012086866040518083838082843780830192505050925050506040518091039020145b610c4c5760405162461bcd60e51b81526004018080602001828103825260268152602001806144a16026913960400191505060405180910390fd5b610cc28787878080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525050604080516020601f8a018190048102820181019092528881528a935091508890889081908401838280828437600092019190915250612ba692505050565b50505050505050565b670dd280b9144a000081565b600881565b610ce4612ba2565b6001600160a01b0316610cf5611c93565b6001600160a01b031614610d3e576040805162461bcd60e51b81526020600482018190526024820152600080516020614481833981519152604482015290519081900360640190fd5b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166307e0db17826040518263ffffffff1660e01b8152600401808261ffff168152602001915050600060405180830381600087803b158015610da857600080fd5b505af1158015610dbc573d6000803e3d6000fd5b5050505050565b6603328b944c400081565b6040805180820190915260058152640352e302e360dc1b602082015290565b610df5612ba2565b6001600160a01b0316610e06611c93565b6001600160a01b031614610e4f576040805162461bcd60e51b81526020600482018190526024820152600080516020614481833981519152604482015290519081900360640190fd5b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166310ddb137826040518263ffffffff1660e01b8152600401808261ffff168152602001915050600060405180830381600087803b158015610da857600080fd5b60056020526000908152604090205481565b66354a6ba7a1800081565b610ede613645565b8585808214610f3057600260008381526006602052604090206003015460ff166002811115610f0957fe5b1415610f305760405162461bcd60e51b8152600401610f27906141f0565b60405180910390fd5b6001600160a01b03851660009081526004602052604090205460ff16610f5789868361195c565b60808601526040850181905215156000610f758b8b8b8a8787611d58565b60208801919091529050600080610f918d8d8d8c878a8a6121cb565b60808a01519193509150610fa59083612bd4565b6080890152606088018190526000610fbf8e8e8c89611cbd565b60808a0151909150610fd19082612bd4565b60808a0152505050505050505095945050505050565b6706f05b59d3b2000081565b610ffb612ba2565b6001600160a01b031661100c611c93565b6001600160a01b031614611055576040805162461bcd60e51b81526020600482018190526024820152600080516020614481833981519152604482015290519081900360640190fd5b600081116110755760405162461bcd60e51b8152600401610f2790614175565b600091825260066020526040909120600181018290556002810191909155600301805460ff19169055565b6000818314156110b2575060016110fc565b8183106110db57600082815260076020908152604080832086845290915290205460ff166110f9565b600083815260076020908152604080832085845290915290205460ff165b90505b92915050565b66038d7ea4c6800081565b6009602052600090815260409020546001600160a01b031681565b61ffff8316600090815260016020818152604080842080548251600295821615610100026000190190911694909404601f81018490048402850184019092528184528493929091908301828280156111c15780601f10611196576101008083540402835291602001916111c1565b820191906000526020600020905b8154815290600101906020018083116111a457829003601f168201915b50505050509050838360405180838380828437808301925050509250505060405180910390208180519060200120149150505b9392505050565b670853a0d2313c000081565b61120f612ba2565b6001600160a01b0316611220611c93565b6001600160a01b031614611269576040805162461bcd60e51b81526020600482018190526024820152600080516020614481833981519152604482015290519081900360640190fd5b604080516342d65a8d60e01b815261ffff85166004820190815260248201928352604482018490526001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016926342d65a8d92879287928792606401848480828437600081840152601f19601f820116905080830192505050945050505050600060405180830381600087803b15801561130857600080fd5b505af1158015610cc2573d6000803e3d6000fd5b6608e1bc9bf0400081565b60008181526006602090815260408083206004018054825181850281018501909352808352849384939291908301828280156113aa57602002820191906000526020600020906000905b82829054906101000a900461ffff1661ffff16815260200190600201906020826001010492830192600103820291508084116113715790505b505050505090506000846000806040516020016113c99392919061439e565b604051602081830303815290604052905060005b82518110156114d05760008382815181106113f457fe5b60209081029190910181015161ffff8116600090815260089092526040808320905163040a7bb160e41b81529193506001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016916340a7bb109161146891869130918a9188916004016142a2565b604080518083038186803b15801561147f57600080fd5b505afa158015611493573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114b79190613cea565b5090506114c48682612bd4565b955050506001016113dd565b5091925050505b919050565b66b1a2bc2ec5000081565b6601c6bf5263400081565b60066020526000908152604090208054600182015460028301546003909301546001600160a01b0390921692909160ff1684565b60086020908152600091825260409182902080548351601f6002600019610100600186161502019093169290920491820184900484028101840190945280845290918301828280156115b95780601f1061158e576101008083540402835291602001916115b9565b820191906000526020600020905b81548152906001019060200180831161159c57829003601f168201915b505050505081565b655af3107a400081565b6115d3612ba2565b6001600160a01b03166115e4611c93565b6001600160a01b03161461162d576040805162461bcd60e51b81526020600482018190526024820152600080516020614481833981519152604482015290519081900360640190fd5b60009182526005602052604090912055565b6000818152600660205260408120908061165883612c2e565b91509150611667848383612db2565b6000836004018054806020026020016040519081016040528092919081815260200182805480156116df57602002820191906000526020600020906000905b82829054906101000a900461ffff1661ffff16815260200190600201906020826001010492830192600103820291508084116116a65790505b5050505050905060008584846040516020016116fd9392919061439e565b604051602081830303815290604052905060005b8251811015610cc257600083828151811061172857fe5b602002602001015190506000600185510383146117455730611747565b335b61ffff831660009081526008602090815260408083208054825160026001831615610100026000190190921691909104601f81018590048502820185019093528281529495506117f79487948a948894919391908301828280156117ec5780601f106117c1576101008083540402835291602001916117ec565b820191906000526020600020905b8154815290600101906020018083116117cf57829003601f168201915b505050505047612e4c565b5050600101611711565b611809612ba2565b6001600160a01b031661181a611c93565b6001600160a01b031614611863576040805162461bcd60e51b81526020600482018190526024820152600080516020614481833981519152604482015290519081900360640190fd5b60009182526009602052604090912080546001600160a01b0319166001600160a01b03909216919091179055565b611899612ba2565b6001600160a01b03166118aa611c93565b6001600160a01b0316146118f3576040805162461bcd60e51b81526020600482018190526024820152600080516020614481833981519152604482015290519081900360640190fd5b565b60016020818152600092835260409283902080548451600294821615610100026000190190911693909304601f81018390048302840183019094528383529192908301828280156115b95780601f1061158e576101008083540402835291602001916115b9565b60008060007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663068bcd8d876040518263ffffffff1660e01b81526004016119ad9190614373565b60206040518083038186803b1580156119c557600080fd5b505afa1580156119d9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119fd919061384c565b90506000611a0a8261310e565b90506000826001600160a01b03166315770f926040518163ffffffff1660e01b815260040160206040518083038186803b158015611a4757600080fd5b505afa158015611a5b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a7f9190613c07565b90506000836001600160a01b0316639bb811196040518163ffffffff1660e01b815260040160206040518083038186803b158015611abc57600080fd5b505afa158015611ad0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611af49190613c07565b9050828211611b0d576000809550955050505050611c11565b6000611b198385613270565b90506000611b3982611b3385670de0b6b3a76400006132cd565b90613326565b9050660221b262dd80008111158015611b50575088155b15611b675760008097509750505050505050611c11565b611b7d670de0b6b3a7640000611b338c846132cd565b9750828811611b8c5787611b8e565b825b97508815611ba6575060009550611c11945050505050565b6000611bbe8b611b338b670de0b6b3a76400006132cd565b90506608e1bc9bf04000811115611c04576000611bee670de0b6b3a7640000611b338e6608e1bc9bf040006132cd565b9050611bfa8a82613270565b9099509750611c09565b600097505b505050505050505b935093915050565b651b48eb57e00081565b6000818152600660205260408120819081908180611c4083612c2e565b915091506000611c5184848461338d565b9050600081611c64578460020154611c66565b835b9199919850919650945050505050565b600260209081526000928352604080842090915290825290205481565b6000546001600160a01b031690565b670de0b6b3a764000081565b6003546001600160a01b031681565b600083851480611cca5750815b15611cd757506000611d25565b6000611ce286613446565b90506000611cef86613446565b9050808210611d0357600092505050611d25565b6000611d1382611b3388866132cd565b9050611d1f8682613270565b93505050505b949350505050565b60046020526000908152604090205460ff1681565b660221b262dd800081565b660e35fa931a000081565b6000808315611d6c57506000905080612007565b60405163068bcd8d60e01b81526000906001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169063068bcd8d90611dbb908c90600401614373565b60206040518083038186803b158015611dd357600080fd5b505afa158015611de7573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e0b919061384c565b6001600160a01b031663159f6add888a6040518363ffffffff1660e01b8152600401611e3892919061435f565b6101006040518083038186803b158015611e5157600080fd5b505afa158015611e65573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e8991906138de565b60e081015160808201519192509087811015611eb75760405162461bcd60e51b8152600401610f27906141b9565b6000611ec3828a613270565b90506000611ee5670de0b6b3a7640000611b3386670853a0d2313c00006132cd565b90506000611f06670de0b6b3a7640000611b338766b1a2bc2ec500006132cd565b90506000808c848610611f3f57611f2f670de0b6b3a7640000611b3383651b48eb57e0006132cd565b92508b611f3a578291505b611ffa565b838610611f77576000858810611f555785611f57565b875b9050611f6f660e35fa931a000060008888858c613480565b935050611ffa565b838710611fd4576000858810611f8d5785611f8f565b875b9050611fb1611faa660e35fa931a000060008989868b613480565b8590612bd4565b9350611f6f611faa670dd280b9144a0000660e35fa931a00008860008a8d613480565b86611ff6611faa670dd280b9144a0000660e35fa931a0000886000868d613480565b9350505b5090985096505050505050505b965096945050505050565b7f000000000000000000000000000000000000000000000000000000000000000081565b61203e612ba2565b6001600160a01b031661204f611c93565b6001600160a01b031614612098576040805162461bcd60e51b81526020600482018190526024820152600080516020614481833981519152604482015290519081900360640190fd5b818314156120b85760405162461bcd60e51b8152600401610f2790614036565b818310156120ea5760008381526007602090815260408083208584529091529020805460ff1916821515179055612110565b60008281526007602090815260408083208684529091529020805460ff19168215151790555b505050565b61211d612ba2565b6001600160a01b031661212e611c93565b6001600160a01b031614612177576040805162461bcd60e51b81526020600482018190526024820152600080516020614481833981519152604482015290519081900360640190fd5b600380546001600160a01b0383166001600160a01b0319909116811790915560408051918252517f5db758e995a17ec1ad84bdef7e8c3293a0bd6179bcce400dff5d4c3d87db726b9181900360200190a150565b60008083156121df5750600090508061234e565b60008361220f576121f08a8a6110a0565b612201576603328b944c400061220a565b6601c6bf526340005b612217565b6596f9e30860005b905060008461222c57655af3107a4000612234565b651eec3dec20005b9050878b600061225a8a612254670de0b6b3a7640000611b33878a6132cd565b90613270565b90506000612274670de0b6b3a7640000611b3386886132cd565b6000848152600960205260409020549091506001600160a01b0316801561234357600084815260056020526040808220549051631526fe2760e01b81528392916001600160a01b03841691631526fe27916122d191600401614373565b60806040518083038186803b1580156122e957600080fd5b505afa1580156122fd573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061232191906138a0565b50509150506000811115612340576123398585612bd4565b9450600093505b50505b509096509450505050505b97509795505050505050565b7f000000000000000000000000000000000000000000000000000000000000000081565b612386612ba2565b6001600160a01b0316612397611c93565b6001600160a01b0316146123e0576040805162461bcd60e51b81526020600482018190526024820152600080516020614481833981519152604482015290519081900360640190fd5b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663cbed8b9c86868686866040518663ffffffff1660e01b8152600401808661ffff1681526020018561ffff168152602001848152602001806020018281038252848482818152602001925080828437600081840152601f19601f8201169050808301925050509650505050505050600060405180830381600087803b15801561249257600080fd5b505af11580156124a6573d6000803e3d6000fd5b505050505050505050565b6124b9612ba2565b6001600160a01b03166124ca611c93565b6001600160a01b031614612513576040805162461bcd60e51b81526020600482018190526024820152600080516020614481833981519152604482015290519081900360640190fd5b6001600160a01b03919091166000908152600460205260409020805460ff1916911515919091179055565b6596f9e308600081565b612550612ba2565b6001600160a01b0316612561611c93565b6001600160a01b0316146125aa576040805162461bcd60e51b81526020600482018190526024820152600080516020614481833981519152604482015290519081900360640190fd5b600081116125f7576040805162461bcd60e51b81526020600482015260156024820152744c7a4170703a20696e76616c6964206d696e47617360581b604482015290519081900360640190fd5b61ffff808416600081815260026020908152604080832094871680845294825291829020859055815192835282019290925280820183905290517f9d5c7c0b934da8fefa9c7760c98383778a12dfbfc0c3b3106518f43fb9508ac09181900360600190a1505050565b600760209081526000928352604080842090915290825290205460ff1681565b651eec3dec200081565b612692612ba2565b6001600160a01b03166126a3611c93565b6001600160a01b0316146126ec576040805162461bcd60e51b81526020600482018190526024820152600080516020614481833981519152604482015290519081900360640190fd5b600084815260066020526040902080546001600160a01b0319166001600160a01b038516178155610dbc90600401838361367b565b612729612ba2565b6001600160a01b031661273a611c93565b6001600160a01b031614612783576040805162461bcd60e51b81526020600482018190526024820152600080516020614481833981519152604482015290519081900360640190fd5b61ffff831660009081526001602052604090206127a1908383613728565b507ffa41487ad5d6728f0b19276fa1eddc16558578f5109fc39d2dc33c3230470dab838383604051808461ffff168152602001806020018281038252848482818152602001925080828437600083820152604051601f909101601f1916909201829003965090945050505050a1505050565b60008181526006602090815260409182902060040180548351818402810184019094528084526060939283018282801561289457602002820191906000526020600020906000905b82829054906101000a900461ffff1661ffff168152602001906002019060208260010104928301926001038202915080841161285b5790505b50505050509050919050565b6128a8612ba2565b6001600160a01b03166128b9611c93565b6001600160a01b031614612902576040805162461bcd60e51b81526020600482018190526024820152600080516020614481833981519152604482015290519081900360640190fd5b6001600160a01b0381166129475760405162461bcd60e51b815260040180806020018281038252602681526020018061440a6026913960400191505060405180910390fd5b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b60408051633d7b2f6f60e21b815261ffff8087166004830152851660248201523060448201526064810183905290516060916001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169163f5ecbdbc91608480820192600092909190829003018186803b158015612a2557600080fd5b505afa158015612a39573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526020811015612a6257600080fd5b8101908080516040519392919084640100000000821115612a8257600080fd5b908301906020820185811115612a9757600080fd5b8251640100000000811182820188101715612ab157600080fd5b82525081516020918201929091019080838360005b83811015612ade578181015183820152602001612ac6565b50505050905090810190601f168015612b0b5780820380516001836020036101000a031916815260200191505b506040525050509050949350505050565b612b24612ba2565b6001600160a01b0316612b35611c93565b6001600160a01b031614612b7e576040805162461bcd60e51b81526020600482018190526024820152600080516020614481833981519152604482015290519081900360640190fd5b61ffff83166000908152600860205260409020612b9c908383613728565b50505050565b3390565b600080600083806020019051810190612bbf9190613baa565b9250925061ffff169250610cc2838383612db2565b6000828201838110156110f9576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b805460009081906001600160a01b031680612c5b5760405162461bcd60e51b8152600401610f279061413e565b6000816001600160a01b031663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b158015612c9657600080fd5b505afa158015612caa573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612cce9190613ef1565b90506000826001600160a01b031663feaf968c6040518163ffffffff1660e01b815260040160a06040518083038186803b158015612d0b57600080fd5b505afa158015612d1f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612d439190613ea2565b5050509150506000811215612d6a5760405162461bcd60e51b8152600401610f2790614107565b6000612d768284613536565b90506000612d838861357e565b9050808211612d925781612d94565b805b91506000612da283836135a0565b9297509195505050505050915091565b60008381526006602052604090206002808201849055600382015460ff1690811115612dda57fe5b826002811115612de657fe5b14612e0c5760038101805483919060ff19166001836002811115612e0657fe5b02179055505b837f5f4a9a1b73bee700ca1fb203bb004bcc0a7eca48af3f147b24dcf5bf4bf3c00b8484604051612e3e92919061437c565b60405180910390a250505050565b61ffff8616600090815260016020818152604080842080548251600295821615610100026000190190911694909404601f810184900484028501840190925281845291830182828015612ee05780601f10612eb557610100808354040283529160200191612ee0565b820191906000526020600020905b815481529060010190602001808311612ec357829003601f168201915b50505050509050805160001415612f285760405162461bcd60e51b81526004018080602001828103825260308152602001806144306030913960400191505060405180910390fd5b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663c58031008389848a8a8a8a6040518863ffffffff1660e01b8152600401808761ffff1681526020018060200180602001866001600160a01b03168152602001856001600160a01b0316815260200180602001848103845289818151815260200191508051906020019080838360005b83811015612fda578181015183820152602001612fc2565b50505050905090810190601f1680156130075780820380516001836020036101000a031916815260200191505b5084810383528851815288516020918201918a019080838360005b8381101561303a578181015183820152602001613022565b50505050905090810190601f1680156130675780820380516001836020036101000a031916815260200191505b50848103825285518152855160209182019187019080838360005b8381101561309a578181015183820152602001613082565b50505050905090810190601f1680156130c75780820380516001836020036101000a031916815260200191505b5099505050505050505050506000604051808303818588803b1580156130ec57600080fd5b505af1158015613100573d6000803e3d6000fd5b505050505050505050505050565b60006110fc826001600160a01b031663feb56b156040518163ffffffff1660e01b815260040160206040518083038186803b15801561314c57600080fd5b505afa158015613160573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906131849190613c07565b836001600160a01b031663fc0c546a6040518163ffffffff1660e01b815260040160206040518083038186803b1580156131bd57600080fd5b505afa1580156131d1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906131f5919061384c565b6001600160a01b03166370a08231856040518263ffffffff1660e01b81526004016132209190613f6b565b60206040518083038186803b15801561323857600080fd5b505afa15801561324c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b339190613c07565b6000828211156132c7576040805162461bcd60e51b815260206004820152601e60248201527f536166654d6174683a207375627472616374696f6e206f766572666c6f770000604482015290519081900360640190fd5b50900390565b6000826132dc575060006110fc565b828202828482816132e957fe5b04146110f95760405162461bcd60e51b81526004018080602001828103825260218152602001806144606021913960400191505060405180910390fd5b600080821161337c576040805162461bcd60e51b815260206004820152601a60248201527f536166654d6174683a206469766973696f6e206279207a65726f000000000000604482015290519081900360640190fd5b81838161338557fe5b049392505050565b600383015460009060ff1660028111156133a357fe5b8260028111156133af57fe5b146133bc575060016111f4565b600060018360028111156133cc57fe5b146133de5766038d7ea4c680006133e6565b655af3107a40005b60028601549091506000818611613406576134018287613270565b613410565b6134108683613270565b90508115613436578261342f83611b3384670de0b6b3a76400006132cd565b101561343b565b600081115b979650505050505050565b600081815260066020526040812081600382015460ff16600281111561346857fe5b146134775780600201546111f4565b6111f48161357e565b60008382101580156134925750848311155b6134ae5760405162461bcd60e51b8152600401610f2790614089565b60006134ba8686613270565b905060006134e0886134da84611b338d6134d48d8c613270565b906132cd565b90612bd4565b905060006134fa896134da85611b338e6134d48e8c613270565b905060006135088787613270565b9050613527670de0b6b3a7640000611b33600281856134d48989612bd4565b9b9a5050505050505050505050565b600060ff82166008141561354b5750816110fc565b60006135588360086135f9565b9050600860ff8416106135745761356f8482613326565b611d25565b611d2584826132cd565b6001810154806114d75760405162461bcd60e51b8152600401610f2790614227565b6000806135bd83611b33670de0b6b3a76400006134d48389613270565b905066038d7ea4c6800081116135d75760009150506110fc565b66354a6ba7a1800081106135ef5760029150506110fc565b60019150506110fc565b6000808260ff168460ff161161361157838303613615565b8284035b60ff169050601481111561363b5760405162461bcd60e51b8152600401610f27906140be565b600a0a9392505050565b6040518060c001604052806000815260200160008152602001600081526020016000815260200160008152602001600081525090565b82805482825590600052602060002090600f016010900481019282156137185791602002820160005b838211156136e857833561ffff1683826101000a81548161ffff021916908361ffff16021790555092602001926002016020816001010492830192600103026136a4565b80156137165782816101000a81549061ffff02191690556002016020816001010492830192600103026136e8565b505b506137249291506137a4565b5090565b828054600181600116156101000203166002900490600052602060002090601f01602090048101928261375e5760008555613718565b82601f106137775782800160ff19823516178555613718565b82800160010185558215613718579182015b82811115613718578235825591602001919060010190613789565b5b8082111561372457600081556001016137a5565b80516114d7816143eb565b60008083601f8401126137d5578182fd5b50813567ffffffffffffffff8111156137ec578182fd5b60208301915083602082850101111561380457600080fd5b9250929050565b80516114d7816143f9565b805169ffffffffffffffffffff811681146114d757600080fd5b600060208284031215613841578081fd5b81356110f9816143d3565b60006020828403121561385d578081fd5b81516110f9816143d3565b6000806040838503121561387a578081fd5b8235613885816143d3565b91506020830135613895816143eb565b809150509250929050565b600080600080608085870312156138b5578182fd5b84516138c0816143d3565b60208601516040870151606090970151919890975090945092505050565b60006101008083850312156138f1578182fd5b6040519081019067ffffffffffffffff8211818310171561390e57fe5b8160405261391b846137b9565b81526139296020850161380b565b602082015260408401516040820152606084015160608201526080840151608082015260a084015160a082015260c084015160c082015260e084015160e0820152809250505092915050565b600060208284031215613986578081fd5b81356110f9816143f9565b6000806000604084860312156139a5578283fd5b83356139b0816143f9565b9250602084013567ffffffffffffffff8111156139cb578283fd5b6139d7868287016137c4565b9497909650939450505050565b600080600080600080608087890312156139fc578182fd5b8635613a07816143f9565b9550602087013567ffffffffffffffff80821115613a23578384fd5b613a2f8a838b016137c4565b9097509550604089013591508082168214613a48578384fd5b90935060608801359080821115613a5d578384fd5b50613a6a89828a016137c4565b979a9699509497509295939492505050565b60008060408385031215613a8e578182fd5b8235613a99816143f9565b91506020830135613895816143f9565b60008060008060808587031215613abe578182fd5b8435613ac9816143f9565b93506020850135613ad9816143f9565b92506040850135613ae9816143d3565b9396929550929360600135925050565b600080600060608486031215613b0d578081fd5b8335613b18816143f9565b92506020840135613b28816143f9565b929592945050506040919091013590565b600080600080600060808688031215613b50578283fd5b8535613b5b816143f9565b94506020860135613b6b816143f9565b935060408601359250606086013567ffffffffffffffff811115613b8d578182fd5b613b99888289016137c4565b969995985093965092949392505050565b600080600060608486031215613bbe578081fd5b8351613bc9816143f9565b60208501516040860151919450925060038110613be4578182fd5b809150509250925092565b600060208284031215613c00578081fd5b5035919050565b600060208284031215613c18578081fd5b5051919050565b60008060408385031215613c31578182fd5b823591506020830135613895816143d3565b60008060008060608587031215613c58578182fd5b843593506020850135613c6a816143d3565b9250604085013567ffffffffffffffff80821115613c86578384fd5b818701915087601f830112613c99578384fd5b813581811115613ca7578485fd5b8860208083028501011115613cba578485fd5b95989497505060200194505050565b60008060408385031215613cdb578182fd5b50508035926020909101359150565b60008060408385031215613cfc578182fd5b505080516020909101519092909150565b600080600060608486031215613d21578081fd5b83359250602084013591506040840135613be4816143eb565b600080600080600060a08688031215613d51578283fd5b85359450602086013593506040860135613d6a816143f9565b92506060860135613d7a816143d3565b949793965091946080013592915050565b60008060008060008060c08789031215613da3578384fd5b86359550602087013594506040870135613dbc816143f9565b9350606087013592506080870135613dd3816143eb565b915060a0870135613de3816143eb565b809150509295509295509295565b600080600080600080600060e0888a031215613e0b578485fd5b87359650602088013595506040880135613e24816143f9565b9450606088013593506080880135925060a0880135613e42816143eb565b915060c0880135613e52816143eb565b8091505092959891949750929550565b60008060008060808587031215613e77578182fd5b8435935060208501359250604085013591506060850135613e97816143eb565b939692955090935050565b600080600080600060a08688031215613eb9578283fd5b613ec286613816565b9450602086015193506040860151925060608601519150613ee560808701613816565b90509295509295909350565b600060208284031215613f02578081fd5b815160ff811681146110f9578182fd5b60008151808452815b81811015613f3757602081850181015186830182015201613f1b565b81811115613f485782602083870101525b50601f01601f19169290920160200192915050565b60038110613f6757fe5b9052565b6001600160a01b0391909116815260200190565b6001600160a01b0385168152602081018490526040810183905260808101613faa6060830184613f5d565b95945050505050565b6020808252825182820181905260009190848201906040850190845b81811015613fef57835161ffff1683529284019291840191600101613fcf565b50909695505050505050565b901515815260200190565b83151581526020810183905260608101611d256040830184613f5d565b6000602082526110f96020830184613f12565b60208082526033908201527f4665654c6962726172793a205f706f6f6c4964312063616e6e6f74206265207460408201527234329039b0b6b29030b9902fb837b7b624b21960691b606082015260800190565b6020808252818101527f4665654c6962726172793a2062616c616e6365206f7574206f6620626f756e64604082015260600190565b60208082526029908201527f4665654c6962726172793a2064696666206f6620646563696d616c7320697320604082015268746f6f206c6172676560b81b606082015260800190565b6020808252601d908201527f4665654c6962726172793a207072696365206973206e65676174697665000000604082015260600190565b6020808252601e908201527f4665654c6962726172793a2070726963652066656564206e6f74207365740000604082015260600190565b60208082526024908201527f4665654c6962726172793a205f62617365507269636553442063616e6e6f74206040820152630626520360e41b606082015260800190565b6020808252601e908201527f4665654c6962726172793a206e6f7420656e6f7567682062616c616e63650000604082015260600190565b6020808252601c908201527f4665654c6962726172793a205f737263506f6f6c496420646570656700000000604082015260600190565b6020808252601e908201527f4665654c6962726172793a2062617365207072696365206e6f74207365740000604082015260600190565b600060c082019050825182526020830151602083015260408301516040830152606083015160608301526080830151608083015260a083015160a083015292915050565b600061ffff87168252602060018060a01b0387168184015260a060408401526142ce60a0840187613f12565b851515606085015283810360808501528285546001808216600081146142fb57600181146143185761434e565b60028304607f16855260ff1983168686015260408501935061434e565b600283048086526143288a6143c7565b885b828110156143455781548882018a015290840190880161432a565b87018801955050505b50919b9a5050505050505050505050565b61ffff929092168252602082015260400190565b90815260200190565b828152604081016111f46020830184613f5d565b918252602082015260400190565b8381526020810183905260608101611d256040830184613f5d565b60ff91909116815260200190565b60009081526020902090565b6001600160a01b03811681146143e857600080fd5b50565b80151581146143e857600080fd5b61ffff811681146143e857600080fdfe4f776e61626c653a206e6577206f776e657220697320746865207a65726f20616464726573734c7a4170703a2064657374696e6174696f6e20636861696e206973206e6f742061207472757374656420736f75726365536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f774f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65724c7a4170703a20696e76616c696420736f757263652073656e64696e6720636f6e7472616374a2646970667358221220ba361558e8444fb5ccc10eb9a31b223f4a62840ba0d112d4512b043ab1238a4964736f6c6343000706003300000000000000000000000006d538690af257da524f25d0cd52fd85b1c2173e00000000000000000000000066a71dcef29a0ffbdbe3c6a460a3b5bc225cd675
Deployed Bytecode
0x6080604052600436106103b05760003560e01c80637ba5c12f116101e7578063baf3292d1161010d578063e18bce50116100a0578063f100e6771161006f578063f100e67714610a18578063f2fde38b14610a45578063f5ecbdbc14610a65578063fc6834a114610a85576103b7565b8063e18bce50146109a3578063e91e9b6f146109c3578063ea8e7530146109d8578063eb8d72b7146109f8576103b7565b8063d16baeb9116100dc578063d16baeb91461094e578063d616f0dd1461096e578063d7f6bde314610566578063df2a5b3b14610983576103b7565b8063baf3292d146108d9578063bb05078d146108f9578063c45a015514610919578063cbed8b9c1461092e576103b7565b8063950c8a7411610185578063a810de6c11610154578063a810de6c1461086f578063ad7bbfc914610884578063b353aaa7146108a4578063ba6afedf146108b9576103b7565b8063950c8a7414610805578063972883c41461081a5780639b19251a1461083a578063a14986351461085a576103b7565b806389ca9256116101c157806389ca92561461078c5780638cfd8f5c146107bb5780638da5cb5b146107db578063918f8674146107f0576103b7565b80637ba5c12f1461077757806380651ee2146106ac578063886a9c50146105c8576103b7565b80633d8b38f6116102d757806358cbb8ed1161026a5780636ddc4561116102395780636ddc4561146106f4578063715018a6146107145780637533d788146107295780637b35c26014610749576103b7565b806358cbb8ed1461068c5780635e3f2727146106ac5780636548c4ac146106c1578063676c0d77146106e1576103b7565b80634f6412d8116102a65780634f6412d814610612578063518a9f9f1461063257806352863703146106475780635436ac171461065c576103b7565b80633d8b38f6146105a85780633dad0dd5146105c857806342d65a8d146105dd5780634e8f4fa8146105fd576103b7565b806313c6e3801161034f57806323a443251161031e57806323a443251461051957806327274e85146105395780632b3ec8c9146105665780633c2c30651461057b576103b7565b806313c6e380146104a25780631738fe38146104c25780631ab62430146104d75780631e04cbf314610504576103b7565b806307e0db171161038b57806307e0db171461042b5780630b4501fd1461044b5780630d8e6e2c1461046057806310ddb13714610482576103b7565b80621d3567146103bc578063012a1c2d146103de578063040d583514610409576103b7565b366103b757005b600080fd5b3480156103c857600080fd5b506103dc6103d73660046139e4565b610aa5565b005b3480156103ea57600080fd5b506103f3610ccb565b6040516104009190614373565b60405180910390f35b34801561041557600080fd5b5061041e610cd7565b60405161040091906143b9565b34801561043757600080fd5b506103dc610446366004613975565b610cdc565b34801561045757600080fd5b506103f3610dc3565b34801561046c57600080fd5b50610475610dce565b6040516104009190614023565b34801561048e57600080fd5b506103dc61049d366004613975565b610ded565b3480156104ae57600080fd5b506103f36104bd366004613bef565b610eb9565b3480156104ce57600080fd5b506103f3610ecb565b3480156104e357600080fd5b506104f76104f2366004613d3a565b610ed6565b604051610400919061425e565b34801561051057600080fd5b506103f3610fe7565b34801561052557600080fd5b506103dc610534366004613cc9565b610ff3565b34801561054557600080fd5b50610559610554366004613cc9565b6110a0565b6040516104009190613ffb565b34801561057257600080fd5b506103f3611102565b34801561058757600080fd5b5061059b610596366004613bef565b61110d565b6040516104009190613f6b565b3480156105b457600080fd5b506105596105c3366004613991565b611128565b3480156105d457600080fd5b506103f36111fb565b3480156105e957600080fd5b506103dc6105f8366004613991565b611207565b34801561060957600080fd5b506103f361131c565b34801561061e57600080fd5b506103f361062d366004613bef565b611327565b34801561063e57600080fd5b506103f36114dc565b34801561065357600080fd5b506103f36114e7565b34801561066857600080fd5b5061067c610677366004613bef565b6114f2565b6040516104009493929190613f7f565b34801561069857600080fd5b506104756106a7366004613975565b611526565b3480156106b857600080fd5b506103f36115c1565b3480156106cd57600080fd5b506103dc6106dc366004613cc9565b6115cb565b6103dc6106ef366004613bef565b61163f565b34801561070057600080fd5b506103dc61070f366004613c1f565b611801565b34801561072057600080fd5b506103dc611891565b34801561073557600080fd5b50610475610744366004613975565b6118f5565b34801561075557600080fd5b50610769610764366004613d0d565b61195c565b604051610400929190614390565b34801561078357600080fd5b506103f3611c19565b34801561079857600080fd5b506107ac6107a7366004613bef565b611c23565b60405161040093929190614006565b3480156107c757600080fd5b506103f36107d6366004613a7c565b611c76565b3480156107e757600080fd5b5061059b611c93565b3480156107fc57600080fd5b506103f3611ca2565b34801561081157600080fd5b5061059b611cae565b34801561082657600080fd5b506103f3610835366004613e62565b611cbd565b34801561084657600080fd5b50610559610855366004613830565b611d2d565b34801561086657600080fd5b506103f3611d42565b34801561087b57600080fd5b506103f3611d4d565b34801561089057600080fd5b5061076961089f366004613d8b565b611d58565b3480156108b057600080fd5b5061059b612012565b3480156108c557600080fd5b506103dc6108d4366004613d0d565b612036565b3480156108e557600080fd5b506103dc6108f4366004613830565b612115565b34801561090557600080fd5b50610769610914366004613df1565b6121cb565b34801561092557600080fd5b5061059b61235a565b34801561093a57600080fd5b506103dc610949366004613b39565b61237e565b34801561095a57600080fd5b506103dc610969366004613868565b6124b1565b34801561097a57600080fd5b506103f361253e565b34801561098f57600080fd5b506103dc61099e366004613af9565b612548565b3480156109af57600080fd5b506105596109be366004613cc9565b612660565b3480156109cf57600080fd5b506103f3612680565b3480156109e457600080fd5b506103dc6109f3366004613c43565b61268a565b348015610a0457600080fd5b506103dc610a13366004613991565b612721565b348015610a2457600080fd5b50610a38610a33366004613bef565b612813565b6040516104009190613fb3565b348015610a5157600080fd5b506103dc610a60366004613830565b6128a0565b348015610a7157600080fd5b50610475610a80366004613aa9565b6129a2565b348015610a9157600080fd5b506103dc610aa0366004613991565b612b1c565b7f00000000000000000000000066a71dcef29a0ffbdbe3c6a460a3b5bc225cd6756001600160a01b0316610ad7612ba2565b6001600160a01b031614610b32576040805162461bcd60e51b815260206004820152601e60248201527f4c7a4170703a20696e76616c696420656e64706f696e742063616c6c65720000604482015290519081900360640190fd5b61ffff8616600090815260016020818152604080842080548251600295821615610100026000190190911694909404601f810184900484028501840190925281845291830182828015610bc65780601f10610b9b57610100808354040283529160200191610bc6565b820191906000526020600020905b815481529060010190602001808311610ba957829003601f168201915b50505050509050805186869050148015610be1575060008151115b8015610c115750808051906020012086866040518083838082843780830192505050925050506040518091039020145b610c4c5760405162461bcd60e51b81526004018080602001828103825260268152602001806144a16026913960400191505060405180910390fd5b610cc28787878080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525050604080516020601f8a018190048102820181019092528881528a935091508890889081908401838280828437600092019190915250612ba692505050565b50505050505050565b670dd280b9144a000081565b600881565b610ce4612ba2565b6001600160a01b0316610cf5611c93565b6001600160a01b031614610d3e576040805162461bcd60e51b81526020600482018190526024820152600080516020614481833981519152604482015290519081900360640190fd5b7f00000000000000000000000066a71dcef29a0ffbdbe3c6a460a3b5bc225cd6756001600160a01b03166307e0db17826040518263ffffffff1660e01b8152600401808261ffff168152602001915050600060405180830381600087803b158015610da857600080fd5b505af1158015610dbc573d6000803e3d6000fd5b5050505050565b6603328b944c400081565b6040805180820190915260058152640352e302e360dc1b602082015290565b610df5612ba2565b6001600160a01b0316610e06611c93565b6001600160a01b031614610e4f576040805162461bcd60e51b81526020600482018190526024820152600080516020614481833981519152604482015290519081900360640190fd5b7f00000000000000000000000066a71dcef29a0ffbdbe3c6a460a3b5bc225cd6756001600160a01b03166310ddb137826040518263ffffffff1660e01b8152600401808261ffff168152602001915050600060405180830381600087803b158015610da857600080fd5b60056020526000908152604090205481565b66354a6ba7a1800081565b610ede613645565b8585808214610f3057600260008381526006602052604090206003015460ff166002811115610f0957fe5b1415610f305760405162461bcd60e51b8152600401610f27906141f0565b60405180910390fd5b6001600160a01b03851660009081526004602052604090205460ff16610f5789868361195c565b60808601526040850181905215156000610f758b8b8b8a8787611d58565b60208801919091529050600080610f918d8d8d8c878a8a6121cb565b60808a01519193509150610fa59083612bd4565b6080890152606088018190526000610fbf8e8e8c89611cbd565b60808a0151909150610fd19082612bd4565b60808a0152505050505050505095945050505050565b6706f05b59d3b2000081565b610ffb612ba2565b6001600160a01b031661100c611c93565b6001600160a01b031614611055576040805162461bcd60e51b81526020600482018190526024820152600080516020614481833981519152604482015290519081900360640190fd5b600081116110755760405162461bcd60e51b8152600401610f2790614175565b600091825260066020526040909120600181018290556002810191909155600301805460ff19169055565b6000818314156110b2575060016110fc565b8183106110db57600082815260076020908152604080832086845290915290205460ff166110f9565b600083815260076020908152604080832085845290915290205460ff165b90505b92915050565b66038d7ea4c6800081565b6009602052600090815260409020546001600160a01b031681565b61ffff8316600090815260016020818152604080842080548251600295821615610100026000190190911694909404601f81018490048402850184019092528184528493929091908301828280156111c15780601f10611196576101008083540402835291602001916111c1565b820191906000526020600020905b8154815290600101906020018083116111a457829003601f168201915b50505050509050838360405180838380828437808301925050509250505060405180910390208180519060200120149150505b9392505050565b670853a0d2313c000081565b61120f612ba2565b6001600160a01b0316611220611c93565b6001600160a01b031614611269576040805162461bcd60e51b81526020600482018190526024820152600080516020614481833981519152604482015290519081900360640190fd5b604080516342d65a8d60e01b815261ffff85166004820190815260248201928352604482018490526001600160a01b037f00000000000000000000000066a71dcef29a0ffbdbe3c6a460a3b5bc225cd67516926342d65a8d92879287928792606401848480828437600081840152601f19601f820116905080830192505050945050505050600060405180830381600087803b15801561130857600080fd5b505af1158015610cc2573d6000803e3d6000fd5b6608e1bc9bf0400081565b60008181526006602090815260408083206004018054825181850281018501909352808352849384939291908301828280156113aa57602002820191906000526020600020906000905b82829054906101000a900461ffff1661ffff16815260200190600201906020826001010492830192600103820291508084116113715790505b505050505090506000846000806040516020016113c99392919061439e565b604051602081830303815290604052905060005b82518110156114d05760008382815181106113f457fe5b60209081029190910181015161ffff8116600090815260089092526040808320905163040a7bb160e41b81529193506001600160a01b037f00000000000000000000000066a71dcef29a0ffbdbe3c6a460a3b5bc225cd67516916340a7bb109161146891869130918a9188916004016142a2565b604080518083038186803b15801561147f57600080fd5b505afa158015611493573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114b79190613cea565b5090506114c48682612bd4565b955050506001016113dd565b5091925050505b919050565b66b1a2bc2ec5000081565b6601c6bf5263400081565b60066020526000908152604090208054600182015460028301546003909301546001600160a01b0390921692909160ff1684565b60086020908152600091825260409182902080548351601f6002600019610100600186161502019093169290920491820184900484028101840190945280845290918301828280156115b95780601f1061158e576101008083540402835291602001916115b9565b820191906000526020600020905b81548152906001019060200180831161159c57829003601f168201915b505050505081565b655af3107a400081565b6115d3612ba2565b6001600160a01b03166115e4611c93565b6001600160a01b03161461162d576040805162461bcd60e51b81526020600482018190526024820152600080516020614481833981519152604482015290519081900360640190fd5b60009182526005602052604090912055565b6000818152600660205260408120908061165883612c2e565b91509150611667848383612db2565b6000836004018054806020026020016040519081016040528092919081815260200182805480156116df57602002820191906000526020600020906000905b82829054906101000a900461ffff1661ffff16815260200190600201906020826001010492830192600103820291508084116116a65790505b5050505050905060008584846040516020016116fd9392919061439e565b604051602081830303815290604052905060005b8251811015610cc257600083828151811061172857fe5b602002602001015190506000600185510383146117455730611747565b335b61ffff831660009081526008602090815260408083208054825160026001831615610100026000190190921691909104601f81018590048502820185019093528281529495506117f79487948a948894919391908301828280156117ec5780601f106117c1576101008083540402835291602001916117ec565b820191906000526020600020905b8154815290600101906020018083116117cf57829003601f168201915b505050505047612e4c565b5050600101611711565b611809612ba2565b6001600160a01b031661181a611c93565b6001600160a01b031614611863576040805162461bcd60e51b81526020600482018190526024820152600080516020614481833981519152604482015290519081900360640190fd5b60009182526009602052604090912080546001600160a01b0319166001600160a01b03909216919091179055565b611899612ba2565b6001600160a01b03166118aa611c93565b6001600160a01b0316146118f3576040805162461bcd60e51b81526020600482018190526024820152600080516020614481833981519152604482015290519081900360640190fd5b565b60016020818152600092835260409283902080548451600294821615610100026000190190911693909304601f81018390048302840183019094528383529192908301828280156115b95780601f1061158e576101008083540402835291602001916115b9565b60008060007f00000000000000000000000006d538690af257da524f25d0cd52fd85b1c2173e6001600160a01b031663068bcd8d876040518263ffffffff1660e01b81526004016119ad9190614373565b60206040518083038186803b1580156119c557600080fd5b505afa1580156119d9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119fd919061384c565b90506000611a0a8261310e565b90506000826001600160a01b03166315770f926040518163ffffffff1660e01b815260040160206040518083038186803b158015611a4757600080fd5b505afa158015611a5b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a7f9190613c07565b90506000836001600160a01b0316639bb811196040518163ffffffff1660e01b815260040160206040518083038186803b158015611abc57600080fd5b505afa158015611ad0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611af49190613c07565b9050828211611b0d576000809550955050505050611c11565b6000611b198385613270565b90506000611b3982611b3385670de0b6b3a76400006132cd565b90613326565b9050660221b262dd80008111158015611b50575088155b15611b675760008097509750505050505050611c11565b611b7d670de0b6b3a7640000611b338c846132cd565b9750828811611b8c5787611b8e565b825b97508815611ba6575060009550611c11945050505050565b6000611bbe8b611b338b670de0b6b3a76400006132cd565b90506608e1bc9bf04000811115611c04576000611bee670de0b6b3a7640000611b338e6608e1bc9bf040006132cd565b9050611bfa8a82613270565b9099509750611c09565b600097505b505050505050505b935093915050565b651b48eb57e00081565b6000818152600660205260408120819081908180611c4083612c2e565b915091506000611c5184848461338d565b9050600081611c64578460020154611c66565b835b9199919850919650945050505050565b600260209081526000928352604080842090915290825290205481565b6000546001600160a01b031690565b670de0b6b3a764000081565b6003546001600160a01b031681565b600083851480611cca5750815b15611cd757506000611d25565b6000611ce286613446565b90506000611cef86613446565b9050808210611d0357600092505050611d25565b6000611d1382611b3388866132cd565b9050611d1f8682613270565b93505050505b949350505050565b60046020526000908152604090205460ff1681565b660221b262dd800081565b660e35fa931a000081565b6000808315611d6c57506000905080612007565b60405163068bcd8d60e01b81526000906001600160a01b037f00000000000000000000000006d538690af257da524f25d0cd52fd85b1c2173e169063068bcd8d90611dbb908c90600401614373565b60206040518083038186803b158015611dd357600080fd5b505afa158015611de7573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e0b919061384c565b6001600160a01b031663159f6add888a6040518363ffffffff1660e01b8152600401611e3892919061435f565b6101006040518083038186803b158015611e5157600080fd5b505afa158015611e65573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e8991906138de565b60e081015160808201519192509087811015611eb75760405162461bcd60e51b8152600401610f27906141b9565b6000611ec3828a613270565b90506000611ee5670de0b6b3a7640000611b3386670853a0d2313c00006132cd565b90506000611f06670de0b6b3a7640000611b338766b1a2bc2ec500006132cd565b90506000808c848610611f3f57611f2f670de0b6b3a7640000611b3383651b48eb57e0006132cd565b92508b611f3a578291505b611ffa565b838610611f77576000858810611f555785611f57565b875b9050611f6f660e35fa931a000060008888858c613480565b935050611ffa565b838710611fd4576000858810611f8d5785611f8f565b875b9050611fb1611faa660e35fa931a000060008989868b613480565b8590612bd4565b9350611f6f611faa670dd280b9144a0000660e35fa931a00008860008a8d613480565b86611ff6611faa670dd280b9144a0000660e35fa931a0000886000868d613480565b9350505b5090985096505050505050505b965096945050505050565b7f00000000000000000000000066a71dcef29a0ffbdbe3c6a460a3b5bc225cd67581565b61203e612ba2565b6001600160a01b031661204f611c93565b6001600160a01b031614612098576040805162461bcd60e51b81526020600482018190526024820152600080516020614481833981519152604482015290519081900360640190fd5b818314156120b85760405162461bcd60e51b8152600401610f2790614036565b818310156120ea5760008381526007602090815260408083208584529091529020805460ff1916821515179055612110565b60008281526007602090815260408083208684529091529020805460ff19168215151790555b505050565b61211d612ba2565b6001600160a01b031661212e611c93565b6001600160a01b031614612177576040805162461bcd60e51b81526020600482018190526024820152600080516020614481833981519152604482015290519081900360640190fd5b600380546001600160a01b0383166001600160a01b0319909116811790915560408051918252517f5db758e995a17ec1ad84bdef7e8c3293a0bd6179bcce400dff5d4c3d87db726b9181900360200190a150565b60008083156121df5750600090508061234e565b60008361220f576121f08a8a6110a0565b612201576603328b944c400061220a565b6601c6bf526340005b612217565b6596f9e30860005b905060008461222c57655af3107a4000612234565b651eec3dec20005b9050878b600061225a8a612254670de0b6b3a7640000611b33878a6132cd565b90613270565b90506000612274670de0b6b3a7640000611b3386886132cd565b6000848152600960205260409020549091506001600160a01b0316801561234357600084815260056020526040808220549051631526fe2760e01b81528392916001600160a01b03841691631526fe27916122d191600401614373565b60806040518083038186803b1580156122e957600080fd5b505afa1580156122fd573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061232191906138a0565b50509150506000811115612340576123398585612bd4565b9450600093505b50505b509096509450505050505b97509795505050505050565b7f00000000000000000000000006d538690af257da524f25d0cd52fd85b1c2173e81565b612386612ba2565b6001600160a01b0316612397611c93565b6001600160a01b0316146123e0576040805162461bcd60e51b81526020600482018190526024820152600080516020614481833981519152604482015290519081900360640190fd5b7f00000000000000000000000066a71dcef29a0ffbdbe3c6a460a3b5bc225cd6756001600160a01b031663cbed8b9c86868686866040518663ffffffff1660e01b8152600401808661ffff1681526020018561ffff168152602001848152602001806020018281038252848482818152602001925080828437600081840152601f19601f8201169050808301925050509650505050505050600060405180830381600087803b15801561249257600080fd5b505af11580156124a6573d6000803e3d6000fd5b505050505050505050565b6124b9612ba2565b6001600160a01b03166124ca611c93565b6001600160a01b031614612513576040805162461bcd60e51b81526020600482018190526024820152600080516020614481833981519152604482015290519081900360640190fd5b6001600160a01b03919091166000908152600460205260409020805460ff1916911515919091179055565b6596f9e308600081565b612550612ba2565b6001600160a01b0316612561611c93565b6001600160a01b0316146125aa576040805162461bcd60e51b81526020600482018190526024820152600080516020614481833981519152604482015290519081900360640190fd5b600081116125f7576040805162461bcd60e51b81526020600482015260156024820152744c7a4170703a20696e76616c6964206d696e47617360581b604482015290519081900360640190fd5b61ffff808416600081815260026020908152604080832094871680845294825291829020859055815192835282019290925280820183905290517f9d5c7c0b934da8fefa9c7760c98383778a12dfbfc0c3b3106518f43fb9508ac09181900360600190a1505050565b600760209081526000928352604080842090915290825290205460ff1681565b651eec3dec200081565b612692612ba2565b6001600160a01b03166126a3611c93565b6001600160a01b0316146126ec576040805162461bcd60e51b81526020600482018190526024820152600080516020614481833981519152604482015290519081900360640190fd5b600084815260066020526040902080546001600160a01b0319166001600160a01b038516178155610dbc90600401838361367b565b612729612ba2565b6001600160a01b031661273a611c93565b6001600160a01b031614612783576040805162461bcd60e51b81526020600482018190526024820152600080516020614481833981519152604482015290519081900360640190fd5b61ffff831660009081526001602052604090206127a1908383613728565b507ffa41487ad5d6728f0b19276fa1eddc16558578f5109fc39d2dc33c3230470dab838383604051808461ffff168152602001806020018281038252848482818152602001925080828437600083820152604051601f909101601f1916909201829003965090945050505050a1505050565b60008181526006602090815260409182902060040180548351818402810184019094528084526060939283018282801561289457602002820191906000526020600020906000905b82829054906101000a900461ffff1661ffff168152602001906002019060208260010104928301926001038202915080841161285b5790505b50505050509050919050565b6128a8612ba2565b6001600160a01b03166128b9611c93565b6001600160a01b031614612902576040805162461bcd60e51b81526020600482018190526024820152600080516020614481833981519152604482015290519081900360640190fd5b6001600160a01b0381166129475760405162461bcd60e51b815260040180806020018281038252602681526020018061440a6026913960400191505060405180910390fd5b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b60408051633d7b2f6f60e21b815261ffff8087166004830152851660248201523060448201526064810183905290516060916001600160a01b037f00000000000000000000000066a71dcef29a0ffbdbe3c6a460a3b5bc225cd675169163f5ecbdbc91608480820192600092909190829003018186803b158015612a2557600080fd5b505afa158015612a39573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526020811015612a6257600080fd5b8101908080516040519392919084640100000000821115612a8257600080fd5b908301906020820185811115612a9757600080fd5b8251640100000000811182820188101715612ab157600080fd5b82525081516020918201929091019080838360005b83811015612ade578181015183820152602001612ac6565b50505050905090810190601f168015612b0b5780820380516001836020036101000a031916815260200191505b506040525050509050949350505050565b612b24612ba2565b6001600160a01b0316612b35611c93565b6001600160a01b031614612b7e576040805162461bcd60e51b81526020600482018190526024820152600080516020614481833981519152604482015290519081900360640190fd5b61ffff83166000908152600860205260409020612b9c908383613728565b50505050565b3390565b600080600083806020019051810190612bbf9190613baa565b9250925061ffff169250610cc2838383612db2565b6000828201838110156110f9576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b805460009081906001600160a01b031680612c5b5760405162461bcd60e51b8152600401610f279061413e565b6000816001600160a01b031663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b158015612c9657600080fd5b505afa158015612caa573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612cce9190613ef1565b90506000826001600160a01b031663feaf968c6040518163ffffffff1660e01b815260040160a06040518083038186803b158015612d0b57600080fd5b505afa158015612d1f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612d439190613ea2565b5050509150506000811215612d6a5760405162461bcd60e51b8152600401610f2790614107565b6000612d768284613536565b90506000612d838861357e565b9050808211612d925781612d94565b805b91506000612da283836135a0565b9297509195505050505050915091565b60008381526006602052604090206002808201849055600382015460ff1690811115612dda57fe5b826002811115612de657fe5b14612e0c5760038101805483919060ff19166001836002811115612e0657fe5b02179055505b837f5f4a9a1b73bee700ca1fb203bb004bcc0a7eca48af3f147b24dcf5bf4bf3c00b8484604051612e3e92919061437c565b60405180910390a250505050565b61ffff8616600090815260016020818152604080842080548251600295821615610100026000190190911694909404601f810184900484028501840190925281845291830182828015612ee05780601f10612eb557610100808354040283529160200191612ee0565b820191906000526020600020905b815481529060010190602001808311612ec357829003601f168201915b50505050509050805160001415612f285760405162461bcd60e51b81526004018080602001828103825260308152602001806144306030913960400191505060405180910390fd5b7f00000000000000000000000066a71dcef29a0ffbdbe3c6a460a3b5bc225cd6756001600160a01b031663c58031008389848a8a8a8a6040518863ffffffff1660e01b8152600401808761ffff1681526020018060200180602001866001600160a01b03168152602001856001600160a01b0316815260200180602001848103845289818151815260200191508051906020019080838360005b83811015612fda578181015183820152602001612fc2565b50505050905090810190601f1680156130075780820380516001836020036101000a031916815260200191505b5084810383528851815288516020918201918a019080838360005b8381101561303a578181015183820152602001613022565b50505050905090810190601f1680156130675780820380516001836020036101000a031916815260200191505b50848103825285518152855160209182019187019080838360005b8381101561309a578181015183820152602001613082565b50505050905090810190601f1680156130c75780820380516001836020036101000a031916815260200191505b5099505050505050505050506000604051808303818588803b1580156130ec57600080fd5b505af1158015613100573d6000803e3d6000fd5b505050505050505050505050565b60006110fc826001600160a01b031663feb56b156040518163ffffffff1660e01b815260040160206040518083038186803b15801561314c57600080fd5b505afa158015613160573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906131849190613c07565b836001600160a01b031663fc0c546a6040518163ffffffff1660e01b815260040160206040518083038186803b1580156131bd57600080fd5b505afa1580156131d1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906131f5919061384c565b6001600160a01b03166370a08231856040518263ffffffff1660e01b81526004016132209190613f6b565b60206040518083038186803b15801561323857600080fd5b505afa15801561324c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b339190613c07565b6000828211156132c7576040805162461bcd60e51b815260206004820152601e60248201527f536166654d6174683a207375627472616374696f6e206f766572666c6f770000604482015290519081900360640190fd5b50900390565b6000826132dc575060006110fc565b828202828482816132e957fe5b04146110f95760405162461bcd60e51b81526004018080602001828103825260218152602001806144606021913960400191505060405180910390fd5b600080821161337c576040805162461bcd60e51b815260206004820152601a60248201527f536166654d6174683a206469766973696f6e206279207a65726f000000000000604482015290519081900360640190fd5b81838161338557fe5b049392505050565b600383015460009060ff1660028111156133a357fe5b8260028111156133af57fe5b146133bc575060016111f4565b600060018360028111156133cc57fe5b146133de5766038d7ea4c680006133e6565b655af3107a40005b60028601549091506000818611613406576134018287613270565b613410565b6134108683613270565b90508115613436578261342f83611b3384670de0b6b3a76400006132cd565b101561343b565b600081115b979650505050505050565b600081815260066020526040812081600382015460ff16600281111561346857fe5b146134775780600201546111f4565b6111f48161357e565b60008382101580156134925750848311155b6134ae5760405162461bcd60e51b8152600401610f2790614089565b60006134ba8686613270565b905060006134e0886134da84611b338d6134d48d8c613270565b906132cd565b90612bd4565b905060006134fa896134da85611b338e6134d48e8c613270565b905060006135088787613270565b9050613527670de0b6b3a7640000611b33600281856134d48989612bd4565b9b9a5050505050505050505050565b600060ff82166008141561354b5750816110fc565b60006135588360086135f9565b9050600860ff8416106135745761356f8482613326565b611d25565b611d2584826132cd565b6001810154806114d75760405162461bcd60e51b8152600401610f2790614227565b6000806135bd83611b33670de0b6b3a76400006134d48389613270565b905066038d7ea4c6800081116135d75760009150506110fc565b66354a6ba7a1800081106135ef5760029150506110fc565b60019150506110fc565b6000808260ff168460ff161161361157838303613615565b8284035b60ff169050601481111561363b5760405162461bcd60e51b8152600401610f27906140be565b600a0a9392505050565b6040518060c001604052806000815260200160008152602001600081526020016000815260200160008152602001600081525090565b82805482825590600052602060002090600f016010900481019282156137185791602002820160005b838211156136e857833561ffff1683826101000a81548161ffff021916908361ffff16021790555092602001926002016020816001010492830192600103026136a4565b80156137165782816101000a81549061ffff02191690556002016020816001010492830192600103026136e8565b505b506137249291506137a4565b5090565b828054600181600116156101000203166002900490600052602060002090601f01602090048101928261375e5760008555613718565b82601f106137775782800160ff19823516178555613718565b82800160010185558215613718579182015b82811115613718578235825591602001919060010190613789565b5b8082111561372457600081556001016137a5565b80516114d7816143eb565b60008083601f8401126137d5578182fd5b50813567ffffffffffffffff8111156137ec578182fd5b60208301915083602082850101111561380457600080fd5b9250929050565b80516114d7816143f9565b805169ffffffffffffffffffff811681146114d757600080fd5b600060208284031215613841578081fd5b81356110f9816143d3565b60006020828403121561385d578081fd5b81516110f9816143d3565b6000806040838503121561387a578081fd5b8235613885816143d3565b91506020830135613895816143eb565b809150509250929050565b600080600080608085870312156138b5578182fd5b84516138c0816143d3565b60208601516040870151606090970151919890975090945092505050565b60006101008083850312156138f1578182fd5b6040519081019067ffffffffffffffff8211818310171561390e57fe5b8160405261391b846137b9565b81526139296020850161380b565b602082015260408401516040820152606084015160608201526080840151608082015260a084015160a082015260c084015160c082015260e084015160e0820152809250505092915050565b600060208284031215613986578081fd5b81356110f9816143f9565b6000806000604084860312156139a5578283fd5b83356139b0816143f9565b9250602084013567ffffffffffffffff8111156139cb578283fd5b6139d7868287016137c4565b9497909650939450505050565b600080600080600080608087890312156139fc578182fd5b8635613a07816143f9565b9550602087013567ffffffffffffffff80821115613a23578384fd5b613a2f8a838b016137c4565b9097509550604089013591508082168214613a48578384fd5b90935060608801359080821115613a5d578384fd5b50613a6a89828a016137c4565b979a9699509497509295939492505050565b60008060408385031215613a8e578182fd5b8235613a99816143f9565b91506020830135613895816143f9565b60008060008060808587031215613abe578182fd5b8435613ac9816143f9565b93506020850135613ad9816143f9565b92506040850135613ae9816143d3565b9396929550929360600135925050565b600080600060608486031215613b0d578081fd5b8335613b18816143f9565b92506020840135613b28816143f9565b929592945050506040919091013590565b600080600080600060808688031215613b50578283fd5b8535613b5b816143f9565b94506020860135613b6b816143f9565b935060408601359250606086013567ffffffffffffffff811115613b8d578182fd5b613b99888289016137c4565b969995985093965092949392505050565b600080600060608486031215613bbe578081fd5b8351613bc9816143f9565b60208501516040860151919450925060038110613be4578182fd5b809150509250925092565b600060208284031215613c00578081fd5b5035919050565b600060208284031215613c18578081fd5b5051919050565b60008060408385031215613c31578182fd5b823591506020830135613895816143d3565b60008060008060608587031215613c58578182fd5b843593506020850135613c6a816143d3565b9250604085013567ffffffffffffffff80821115613c86578384fd5b818701915087601f830112613c99578384fd5b813581811115613ca7578485fd5b8860208083028501011115613cba578485fd5b95989497505060200194505050565b60008060408385031215613cdb578182fd5b50508035926020909101359150565b60008060408385031215613cfc578182fd5b505080516020909101519092909150565b600080600060608486031215613d21578081fd5b83359250602084013591506040840135613be4816143eb565b600080600080600060a08688031215613d51578283fd5b85359450602086013593506040860135613d6a816143f9565b92506060860135613d7a816143d3565b949793965091946080013592915050565b60008060008060008060c08789031215613da3578384fd5b86359550602087013594506040870135613dbc816143f9565b9350606087013592506080870135613dd3816143eb565b915060a0870135613de3816143eb565b809150509295509295509295565b600080600080600080600060e0888a031215613e0b578485fd5b87359650602088013595506040880135613e24816143f9565b9450606088013593506080880135925060a0880135613e42816143eb565b915060c0880135613e52816143eb565b8091505092959891949750929550565b60008060008060808587031215613e77578182fd5b8435935060208501359250604085013591506060850135613e97816143eb565b939692955090935050565b600080600080600060a08688031215613eb9578283fd5b613ec286613816565b9450602086015193506040860151925060608601519150613ee560808701613816565b90509295509295909350565b600060208284031215613f02578081fd5b815160ff811681146110f9578182fd5b60008151808452815b81811015613f3757602081850181015186830182015201613f1b565b81811115613f485782602083870101525b50601f01601f19169290920160200192915050565b60038110613f6757fe5b9052565b6001600160a01b0391909116815260200190565b6001600160a01b0385168152602081018490526040810183905260808101613faa6060830184613f5d565b95945050505050565b6020808252825182820181905260009190848201906040850190845b81811015613fef57835161ffff1683529284019291840191600101613fcf565b50909695505050505050565b901515815260200190565b83151581526020810183905260608101611d256040830184613f5d565b6000602082526110f96020830184613f12565b60208082526033908201527f4665654c6962726172793a205f706f6f6c4964312063616e6e6f74206265207460408201527234329039b0b6b29030b9902fb837b7b624b21960691b606082015260800190565b6020808252818101527f4665654c6962726172793a2062616c616e6365206f7574206f6620626f756e64604082015260600190565b60208082526029908201527f4665654c6962726172793a2064696666206f6620646563696d616c7320697320604082015268746f6f206c6172676560b81b606082015260800190565b6020808252601d908201527f4665654c6962726172793a207072696365206973206e65676174697665000000604082015260600190565b6020808252601e908201527f4665654c6962726172793a2070726963652066656564206e6f74207365740000604082015260600190565b60208082526024908201527f4665654c6962726172793a205f62617365507269636553442063616e6e6f74206040820152630626520360e41b606082015260800190565b6020808252601e908201527f4665654c6962726172793a206e6f7420656e6f7567682062616c616e63650000604082015260600190565b6020808252601c908201527f4665654c6962726172793a205f737263506f6f6c496420646570656700000000604082015260600190565b6020808252601e908201527f4665654c6962726172793a2062617365207072696365206e6f74207365740000604082015260600190565b600060c082019050825182526020830151602083015260408301516040830152606083015160608301526080830151608083015260a083015160a083015292915050565b600061ffff87168252602060018060a01b0387168184015260a060408401526142ce60a0840187613f12565b851515606085015283810360808501528285546001808216600081146142fb57600181146143185761434e565b60028304607f16855260ff1983168686015260408501935061434e565b600283048086526143288a6143c7565b885b828110156143455781548882018a015290840190880161432a565b87018801955050505b50919b9a5050505050505050505050565b61ffff929092168252602082015260400190565b90815260200190565b828152604081016111f46020830184613f5d565b918252602082015260400190565b8381526020810183905260608101611d256040830184613f5d565b60ff91909116815260200190565b60009081526020902090565b6001600160a01b03811681146143e857600080fd5b50565b80151581146143e857600080fd5b61ffff811681146143e857600080fdfe4f776e61626c653a206e6577206f776e657220697320746865207a65726f20616464726573734c7a4170703a2064657374696e6174696f6e20636861696e206973206e6f742061207472757374656420736f75726365536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f774f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65724c7a4170703a20696e76616c696420736f757263652073656e64696e6720636f6e7472616374a2646970667358221220ba361558e8444fb5ccc10eb9a31b223f4a62840ba0d112d4512b043ab1238a4964736f6c63430007060033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
00000000000000000000000006d538690af257da524f25d0cd52fd85b1c2173e00000000000000000000000066a71dcef29a0ffbdbe3c6a460a3b5bc225cd675
-----Decoded View---------------
Arg [0] : _factory (address): 0x06D538690AF257Da524f25D0CD52fD85b1c2173E
Arg [1] : _endpoint (address): 0x66A71Dcef29A0fFBDBE3c6a460a3B5BC225Cd675
-----Encoded View---------------
2 Constructor Arguments found :
Arg [0] : 00000000000000000000000006d538690af257da524f25d0cd52fd85b1c2173e
Arg [1] : 00000000000000000000000066a71dcef29a0ffbdbe3c6a460a3b5bc225cd675
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 27 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|
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.