Feature Tip: Add private address tag to any address under My Name Tag !
Overview
ETH Balance
0 ETH
Eth Value
$0.00More Info
Private Name Tags
ContractCreator
Transaction Hash |
Method
|
Block
|
From
|
To
|
|||||
---|---|---|---|---|---|---|---|---|---|
Latest 1 internal transaction
Advanced mode:
Parent Transaction Hash | Block |
From
|
To
|
|||
---|---|---|---|---|---|---|
20541559 | 140 days ago | Contract Creation | 0 ETH |
Loading...
Loading
This contract may be a proxy contract. Click on More Options and select Is this a proxy? to confirm and enable the "Read as Proxy" & "Write as Proxy" tabs.
Contract Source Code Verified (Exact Match)
Contract Name:
CornSilo
Compiler Version
v0.8.25+commit.b61c2a91
Optimization Enabled:
Yes with 200 runs
Other Settings:
paris EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT pragma solidity ^0.8.17; import {UUPSUpgradeable} from "openzeppelin-contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol"; import {PausableUpgradeable} from "openzeppelin-contracts-upgradeable/security/PausableUpgradeable.sol"; import {ReentrancyGuardUpgradeable} from "openzeppelin-contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol"; import {AddressUpgradeable} from "openzeppelin-contracts-upgradeable/utils/AddressUpgradeable.sol"; import {EnumerableSetUpgradeable} from "openzeppelin-contracts-upgradeable/utils/structs/EnumerableSetUpgradeable.sol"; import {SafeCastUpgradeable} from "openzeppelin-contracts-upgradeable/utils/math/SafeCastUpgradeable.sol"; import {SafeERC20Upgradeable} from "openzeppelin-contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol"; import {IERC20Upgradeable} from "openzeppelin-contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol"; import {AuthNoOwner} from "corn-standard-solidity/AuthNoOwner.sol"; import {IBitcorn} from "bitcorn-token/interfaces/IBitcorn.sol"; import {AddressAliasHelper} from "token-bridge-contracts/contracts/tokenbridge/libraries/AddressAliasHelper.sol"; import {IGatewayRouter, IERC20Inbox, ICornSilo} from "./interfaces/ICornSilo.sol"; import {IERC20} from "forge-std/interfaces/IERC20.sol"; /** * @title CornSilo * Allows for depositing and redeeming of ERC20 tokens with direct bridging to Corn network once that capability is available. * Terminology inspired by ERC-4626, but not intended to conform to that standard. * Supports upgradeability and pausability. User funds are never frozen. */ contract CornSilo is ICornSilo, UUPSUpgradeable, PausableUpgradeable, ReentrancyGuardUpgradeable, AuthNoOwner { using AddressUpgradeable for address; using SafeCastUpgradeable for uint256; using SafeERC20Upgradeable for IERC20Upgradeable; using EnumerableSetUpgradeable for EnumerableSetUpgradeable.AddressSet; mapping(address => mapping(address => uint256)) internal _sharesOf; mapping(address => uint256) public totalShares; EnumerableSetUpgradeable.AddressSet internal _approvedTokens; IBitcorn public immutable bitcorn; IERC20Upgradeable public immutable bitcornMinterAsset; uint256 public immutable to18ConversionFactor; address public immutable feeRecipient; IGatewayRouter internal _gatewayRouter; IERC20Inbox internal _erc20Inbox; address internal _swapFacilityVault; bool public isBridgeEnabled; uint256 public withdrawalFee = 0; uint256 public constant MAX_WITHDRAWAL_FEE_BPS = 0; uint256 public constant BPS_DIVISOR = 10000; uint256 public immutable ONE_SATOSHI_OF_BITCOIN_SHARES; /// @notice Constructor for CornSilo. Designed for use with an upgradeable contract paradigm. /// @param _bitcorn the Bitcorn (BTCN) token. The CornSilo must be granted minting rights on this token to function. /// @param _bitcornMinterAsset token which is used to mint Bitcorn (BTCN). Must be 2-18 decimals. Intended for use with wBTC (8 decimals). /// @param _feeRecipient address of fee recipient which receives withdrawal fees in a push transfer. constructor(address _bitcorn, address _bitcornMinterAsset, address _feeRecipient) { _disableInitializers(); require(IERC20(_bitcornMinterAsset).decimals() >= 2, "Minter token must be at least 2 decimals"); require(IERC20(_bitcornMinterAsset).decimals() <= 18, "Minter token must 18 decimals or less"); bitcorn = IBitcorn(_bitcorn); bitcornMinterAsset = IERC20Upgradeable(_bitcornMinterAsset); // Calculate the conversion factor to normalize input token to 18 decimals. to18ConversionFactor = 10 ** uint256(18 - IERC20(_bitcornMinterAsset).decimals()); ONE_SATOSHI_OF_BITCOIN_SHARES = to18ConversionFactor; feeRecipient = _feeRecipient; } /// @notice Initializes the CornSilo contract with necessary parameters and sets initial state. /// @param _authority The address of the authority contract for access control. /// @param _initialApprovedTokens An array of addresses for the initially approved tokens. function initialize(address _authority, address[] memory _initialApprovedTokens) external initializer { __UUPSUpgradeable_init(); __Pausable_init(); __ReentrancyGuard_init(); require(_authority != address(0), "Authority cannot be null address"); _initializeAuthority(_authority); for (uint256 i = 0; i < _initialApprovedTokens.length; i++) { _approvedTokens.add(_initialApprovedTokens[i]); } // Sanity check: bitcornMinterAsset must not be an approved token if (_approvedTokens.contains(address(bitcornMinterAsset))) { revert BitcornMinterAssetMustNotBeApprovedToken(address(bitcornMinterAsset)); } // Start paused to allow deploy and review before opening _pause(); } function _authorizeUpgrade(address target) internal override requiresAuth {} modifier onlyAfterBridgeEnabled() { if (!isBridgeEnabled) { revert BridgeNotEnabled(); } _; } /// @dev Once bridging is enabled, deposits are permanently disabled except for bitcorn which could be needed as a gas asset for bridging modifier onlyBeforeBridgeEnabled() { if (isBridgeEnabled) { revert BridgeIsEnabled(); } _; } /// @notice Pause all external functions, except redemption of assets /// @notice Redemption is opened when paused and not subject to redeemal fee function pause() external requiresAuth whenNotPaused { _pause(); } /// @notice Unpause all external functions /// @notice Redemption is opened when paused and not subject to redeemal fee function unpause() external requiresAuth whenPaused { _unpause(); } /// @notice Returns the gateway router once set /// @dev reverts if the gatewayRouter is not set /// @notice The gateway router is set atomically when bridging is enabled. function getGatewayRouter() public view returns (IGatewayRouter gatewayRouter) { gatewayRouter = _gatewayRouter; if (address(gatewayRouter) == address(0)) { revert BridgeIsNotSet(); } } /// @notice Returns the ERC20 Inbox once set /// @dev reverts if the ERC20 Inbox is not set /// @notice The ERC20 Inbox is set atomically when bridging is enabled. function getERC20Inbox() public view returns (IERC20Inbox erc20Inbox) { erc20Inbox = _erc20Inbox; if (address(erc20Inbox) == address(0)) { revert BridgeIsNotSet(); } } /// @notice Retrieves the address of the Swap Facility Backing /// @notice This address is set atomically when bridging is enabled /// @dev reverts if the swapFacilityVault is not set /// @return The address of the Swap Facility Backing function getSwapFacilityVault() external view returns (address) { address cachedSwapFacilityVault = _swapFacilityVault; if (address(cachedSwapFacilityVault) == address(0)) { revert BridgeIsNotSet(); } return cachedSwapFacilityVault; } function _setGatewayRouter(address gatewayRouter) internal { require(gatewayRouter.code.length > 0, "GatewayRouterIsNotContract"); _gatewayRouter = IGatewayRouter(gatewayRouter); } function _setERC20Inbox(address erc20Inbox) internal { require(erc20Inbox.code.length > 0, "ERC20InboxIsNotContract"); _erc20Inbox = IERC20Inbox(erc20Inbox); } function _setSwapFacilityVault(address swapFacilityVault) internal { require(swapFacilityVault.code.length > 0, "SwapFacilityVaultIsNotContract"); _swapFacilityVault = swapFacilityVault; } /// @notice Set withdrawal fee within a range of 0 to hardcoded maximum fee, in bps. function setWithdrawalFee(uint256 _fee) external requiresAuth { if (_fee > MAX_WITHDRAWAL_FEE_BPS) { revert WithdrawalFeeAboveMax(_fee); } withdrawalFee = _fee; } function sharesOf(address user, address token) external view returns (uint256) { return _sharesOf[user][token]; } /*///////////////////////// DEPOSITS /////////////////////////*/ /// @notice Deposit an approved token into the silo for the sender /// @dev Approved assets are held in the silo and the user is issued a non-transferable receipt to track their position /// @dev Redemption of shares is subject to withdrawal fee if present /// @dev Bridging the token to the Corn network once live is not subject to the fee /// @dev This function reverts if the deposit amount is zero or the token is not an approved token /// @param token The address of the token to deposit /// @param assets The amount of the token to deposit /// @return shares The number of shares issued to the sender function deposit(address token, uint256 assets) external nonReentrant whenNotPaused onlyBeforeBridgeEnabled returns (uint256 shares) { if (assets == 0) { revert ZeroDeposit(token); } if (!_isApprovedToken(token)) { revert TokenNotApproved(token); } shares = _depositFor(msg.sender, token, assets); } /// @notice Deposit an approved token for a specified recipient /// @dev Only the recipient can withdraw or bridge the deposited asset, there is no delegation of these functions /// @dev Approved assets are held in the silo and the user is issued a non-transferable receipt to track their position /// @dev Redemption of shares is subject with withdrawal fee if present /// @dev Bridging the token to the Corn network once live is not subject to the fee /// @dev This function reverts if the deposit amount is zero or the token is not an approved token /// @param recipient The address of the recipient for whom the deposit is being made /// @param token The address of the token to deposit /// @param assets The amount of the token to deposit /// @return shares The number of shares issued to the recipient function depositFor(address recipient, address token, uint256 assets) external nonReentrant whenNotPaused onlyBeforeBridgeEnabled returns (uint256 shares) { if (assets == 0) { revert ZeroDeposit(token); } if (!_isApprovedToken(token)) { revert TokenNotApproved(token); } shares = _depositFor(recipient, token, assets); } /// @notice Deposit the bitcorn minter asset and mint bitcorn /// @dev The bitcorn minter asset is held in the silo and results in the minting of BTCN /// @dev The users non-transferable receipt is stored as BTCN shares /// @dev If the shares are redeemed directly rather than bridged, the BTCN token is burned and the bitcorn minter asset is returned to the user, sans withdrawal fee, if present /// @dev This function reverts if the deposit amount is zero /// @dev Unlike approved tokens, BTCN can be deposited after the bridge is enabled to allow adding gas for bridge transfers. /// @param assets The amount of bitcorn minter asset to deposit /// @return shares The number of BTCN shares issued to the sender function mintAndDepositBitcorn(uint256 assets) external nonReentrant whenNotPaused returns (uint256 shares) { if (assets == 0) { revert ZeroDeposit(address(bitcorn)); } shares = _mintAndDepositBitcornFor(msg.sender, assets); } /// @notice Deposit an approved token for a specified recipient /// @dev Only the recipient can withdraw or bridge the deposited asset, there is no delegation of these functions /// @dev The bitcorn minter asset is held in the silo and results in the minting of BTCN /// @dev The users non-transferable receipt is stored as BTCN shares /// @dev If the shares are redeemed directly rather than bridged, the BTCN token is burned and the bitcorn minter asset is returned to the user, sans withdrawal fee, if present /// @dev This function reverts if the deposit amount is zero /// @dev Unlike approved tokens, BTCN can be deposited after the bridge is enabled to allow adding gas for bridge transfers. /// @param recipient The address of the recipient for whom the deposit is being made /// @param assets The amount of bitcorn minter asset to deposit /// @return shares The number of BTCN shares issued to the recipient function mintAndDepositBitcornFor(address recipient, uint256 assets) external nonReentrant whenNotPaused returns (uint256 shares) { if (assets == 0) { revert ZeroDeposit(address(bitcorn)); } shares = _mintAndDepositBitcornFor(recipient, assets); } function _depositFor(address recipient, address token, uint256 assets) internal returns (uint256) { _mintShares(recipient, token, assets); IERC20Upgradeable(token).safeTransferFrom(msg.sender, address(this), assets); emit TokenDeposited(recipient, token, assets, assets); return assets; } function _mintAndDepositBitcornFor(address recipient, uint256 assets) internal returns (uint256) { uint256 sharesToMint = fromAssetDecimalsTo18Decimals(assets); bitcorn.mint(sharesToMint); _mintShares(recipient, address(bitcorn), sharesToMint); bitcornMinterAsset.safeTransferFrom(msg.sender, address(this), assets); emit TokenDeposited(recipient, address(bitcorn), assets, sharesToMint); return sharesToMint; } /// @notice Convert the amount from bitcoin minter asset decimals to 18 decimals /// @param amount value in bitcoin minter asset decimals to convert /// @return converted amount in 18 decimals function fromAssetDecimalsTo18Decimals(uint256 amount) public view returns (uint256) { return amount * to18ConversionFactor; } /// @notice Convert the amount from 18 decimals to bitcoin minter asset decimals /// @param amountIn18Decimals in 18 decimals decimals to convert /// @return converted amount is bitcoin minter asset decimals /// @dev Can lose 1 wei of precision. How this is handled by the implementing function should be documented. function from18DecimalsToAssetDecimals(uint256 amountIn18Decimals) public view returns (uint256) { return amountIn18Decimals / to18ConversionFactor; } /// @notice Mint shares for a specific token /// @param user User address /// @param token Token address /// @param shares Number of shares to mint function _mintShares(address user, address token, uint256 shares) internal { _sharesOf[user][token] = _sharesOf[user][token] + shares; totalShares[token] = totalShares[token] + shares; } /// @notice Burn shares for a specific token /// @param user User address /// @param token Token address /// @param shares Number of shares to burn function _burnShares(address user, address token, uint256 shares) internal { _sharesOf[user][token] = _sharesOf[user][token] - shares; totalShares[token] = totalShares[token] - shares; } /*///////////////////////// BRIDGE /////////////////////////*/ /// @notice Enable bridge to Corn mainnet. The bridge can only be enabled once /// @notice All of the bitcorn minter asset are repurposed to the SwapFacility vault /// @param gatewayRouter gateway router on L1, entry point to token bridges /// @param erc20Inbox ERC20 inbox on L1, used for gas token (BTCN) transfers /// @param swapFacilityVault vault for swap facility on L1, used to hold the bitcorn minter asset balance backing BTCN tokens which are free-floating (i.e. not stuck in Silo) and provide a mechanism to redeem BTCN for the backing assets function enableBridge(address gatewayRouter, address erc20Inbox, address swapFacilityVault) external nonReentrant onlyBeforeBridgeEnabled requiresAuth { _setGatewayRouter(gatewayRouter); _setERC20Inbox(erc20Inbox); _setSwapFacilityVault(swapFacilityVault); isBridgeEnabled = true; emit BridgeEnabled(gatewayRouter, swapFacilityVault); } /// @notice Bridges a specific approved token to the Corn network. /// @notice Only available once bridge is enabled. /// @notice BTCN serves as the gas token on Corn. /// @dev The user pays for the L2 portion of the bridging process with BTCN shares on L1. They must have sufficient BTCN shares in the silo for the specified L2 gas limit and price. /// @dev The BTCN shares used must be clean multiple of a minterAsset amount, given the decimal conversion factor. Excess gas will end up as BTCN in the users account on L2. /// @dev minterAsset value corresponding to the amount paid as fees is moved to the SwapFacility to honor redemptions of liquid BTCN /// @dev This function is used for approved tokens, not BTCN. function bridgeToken(address token, address recipient, uint256 maxGas, uint256 gasPriceBid, bytes calldata data) external nonReentrant whenNotPaused onlyAfterBridgeEnabled { recipient = _checkAndReturnAlias(recipient); _bridgeToken(msg.sender, token, recipient, maxGas, gasPriceBid, data); } /// @notice Bridge all remaining user tokens to Corn network /// @notice Only available once bridge is enabled. /// @dev The bridging of all tokens is implemented as atomic for convenience, The number of tokens moved atomically is practially limited due to gas and is trusted to be managed by governance. Users have the right to early withdraw. /// @dev All tokens recieve the same gas parameters for bridging /// @dev some BTCN shares are required and are burned for gas in the for L2 portion of bridging transactions /// @dev Any excess BTCN value transferred in this way is given to the user on L2 as the gas token /// @dev After gas for all approved token transfers is accounted for, any remaining BTCN shares will be bridged. The gas for this bridging action will come from the remaining BTCN shares. /// @dev minterAsset value corresponding to the total amount paid as fees is moved to the SwapFacility to honor redemptions of liquid BTCN that is bridged function bridgeAllTokens(address recipient, uint256 cost, uint256 maxGas, uint256 gasPriceBid, bytes calldata data) external nonReentrant whenNotPaused onlyAfterBridgeEnabled { recipient = _checkAndReturnAlias(recipient); _bridgeAllTokens(msg.sender, recipient, cost, maxGas, gasPriceBid, data); } /// @notice Bridges BTCN to the Corn network. /// @notice Only available once bridge is enabled. /// @notice BTCN serves as the gas token on Corn. /// @dev The L2 BTCN gas required as per the gas parameters is subtracted from the amount received by the user on L2 /// @dev minterAsset value corresponding to the amount bridged (including L2 gas fees) is moved to the SwapFacility to honor redemptions of liquid BTCN function bridgeBitcorn(address recipient, uint256 cost, uint256 maxGas, uint256 gasPriceBid) external nonReentrant whenNotPaused onlyAfterBridgeEnabled { recipient = _checkAndReturnAlias(recipient); _bridgeBitcorn(msg.sender, recipient, cost, maxGas, gasPriceBid); } /// @dev Approves are done to the bridge individually on each instance to not expose other users to bridge unless they actively choose to bridge function _bridgeBitcorn(address user, address recipient, uint256 cost, uint256 maxGas, uint256 gasPriceBid) internal { uint256 cachedShares = _sharesOf[user][address(bitcorn)]; if (cachedShares == 0) { revert ZeroShares(address(bitcorn)); } _approveAndBridgeBitcorn(user, cost, cachedShares, recipient, maxGas, gasPriceBid); IERC20Upgradeable(address(bitcornMinterAsset)).safeTransfer( _swapFacilityVault, from18DecimalsToAssetDecimals(cachedShares) ); } /// @dev Approves are done to the bridge individually on each instance to not expose other users to bridge unless they actively choose to bridge function _bridgeToken( address user, address token, address recipient, uint256 maxGas, uint256 gasPriceBid, bytes calldata data ) internal { if (!_isApprovedToken(token)) { revert TokenNotApproved(token); } uint256 cachedShares = _sharesOf[user][token]; if (cachedShares == 0) { revert ZeroShares(token); } uint256 cachedBTCNShares = _sharesOf[user][address(bitcorn)]; uint256 requiredShares = maxGas * gasPriceBid; if (cachedBTCNShares < requiredShares) { revert InsufficientBitcornSharesToBridge(cachedBTCNShares, requiredShares); } if (requiredShares % ONE_SATOSHI_OF_BITCOIN_SHARES != 0) { revert SharesNotMultipleOfOneSatoshi(requiredShares, ONE_SATOSHI_OF_BITCOIN_SHARES); } IGatewayRouter gatewayRouter = getGatewayRouter(); _approveAndBridgeAsset(token, user, cachedShares, gatewayRouter, recipient, maxGas, gasPriceBid, data); } function _bridgeAllTokens( address user, address recipient, uint256 cost, uint256 maxGas, uint256 gasPriceBid, bytes calldata data ) internal { address[] memory approvedTokens = getApprovedTokens(); uint256[] memory cachedShares = new uint256[](approvedTokens.length); { bool anySharesFound; uint256 userApprovedTokenCount; (cachedShares, anySharesFound, userApprovedTokenCount) = _getAllApprovedTokenSharesFor(user); if (!anySharesFound) { revert ZeroSharesForAnyToken(user); } uint256 cachedBTCNShares = _sharesOf[user][address(bitcorn)]; uint256 requiredShares = maxGas * gasPriceBid * userApprovedTokenCount; if (cachedBTCNShares < requiredShares) { revert InsufficientBitcornSharesToBridge(cachedBTCNShares, requiredShares); } /// This should imply each individual transfer is a clean multiple if (maxGas * gasPriceBid % ONE_SATOSHI_OF_BITCOIN_SHARES != 0) { revert SharesNotMultipleOfOneSatoshi(requiredShares, ONE_SATOSHI_OF_BITCOIN_SHARES); } } IGatewayRouter gatewayRouter = getGatewayRouter(); // Bridge all approved assets for (uint256 i = 0; i < approvedTokens.length; i++) { if (cachedShares[i] > 0) { _approveAndBridgeAsset( approvedTokens[i], user, cachedShares[i], gatewayRouter, recipient, maxGas, gasPriceBid, data ); } } // Shares will be reduced by previous token transfers uint256 remainingBTCNShares = _sharesOf[user][address(bitcorn)]; // Bridge BTCN if present, transferring backing assets to SwapFacility if (remainingBTCNShares != 0 && remainingBTCNShares > cost + maxGas * gasPriceBid) { _approveAndBridgeBitcorn(user, cost, remainingBTCNShares, recipient, maxGas, gasPriceBid); IERC20Upgradeable(address(bitcornMinterAsset)).safeTransfer( _swapFacilityVault, from18DecimalsToAssetDecimals(remainingBTCNShares) ); } } function _approveAndBridgeAsset( address token, address user, uint256 amount, IGatewayRouter gatewayRouter, address recipient, uint256 maxGas, uint256 gasPriceBid, bytes calldata data ) internal { uint256 btcnGas = maxGas * gasPriceBid; _burnShares(user, token, amount); _burnShares(user, address(bitcorn), btcnGas); IERC20Upgradeable(token).safeApprove(gatewayRouter.getGateway(token), amount); if (btcnGas > 0) { IERC20Upgradeable(address(bitcorn)).safeApprove(gatewayRouter.getGateway(address(token)), btcnGas); } gatewayRouter.outboundTransferCustomRefund(token, recipient, recipient, amount, maxGas, gasPriceBid, data); emit TokenBridged(token, user, recipient, amount, maxGas, gasPriceBid, data); IERC20Upgradeable(address(bitcornMinterAsset)).safeTransfer( _swapFacilityVault, from18DecimalsToAssetDecimals(btcnGas) ); } /// @dev subtracts the gas cost from the amount to bridge function _approveAndBridgeBitcorn( address user, uint256 cost, uint256 amount, address recipient, uint256 maxGas, uint256 gasPriceBid ) internal { IERC20Inbox erc20Inbox = getERC20Inbox(); _burnShares(user, address(bitcorn), amount); IERC20Upgradeable(address(bitcorn)).safeApprove(address(_erc20Inbox), amount); erc20Inbox.unsafeCreateRetryableTicket( recipient, amount - (cost + maxGas * gasPriceBid), cost, recipient, recipient, maxGas, gasPriceBid, amount, "" ); emit TokenBridged(address(bitcorn), user, recipient, amount, maxGas, gasPriceBid, ""); } /*///////////////////////// WITHDRAWS /////////////////////////*/ /// @notice Redeem a given token from the CornSilo shares for underlying asset. /// @notice Withdrawing via this path may be considered an "early withdraw" and may be penalized in point acquisition according to those mechanics. /// @param token The address of the token to withdraw. /// @param shares The shares of the token to redeem for underlying asset. function redeemToken(address token, uint256 shares) external nonReentrant returns (uint256 assets) { assets = _redeemApprovedToken(msg.sender, token, shares); } /// @notice Redeem Bitcorn shares and withdraw the corresponding minter asset. /// @notice withdrawn BTCN will be returned as minter asset to the user and the BTCN tokens burned. /// @param shares The shares of Bitcorn to redeem for underlying minter asset. The amount will undergo decimal conversion. /// @dev because the minter asset may have less decimals, only share values which are clean multiples into that lower scale are allowed. /// @dev because BTCN share mints are denominated in the minter asset on deposit, the user deposited amount is guaranteed to scale down to the minter asset cleanly. /// @return assets bitcoin minter asset balance returned. function redeemBitcorn(uint256 shares) external nonReentrant returns (uint256 assets) { assets = _redeemBitcornAndWithdrawMinterAsset(msg.sender, shares); } /// @notice Redeem all deposited assets from the CornSilo. /// @notice Withdrawing via this path is considered an "early withdraw" and may be penalized in point acquisition according to those mechanics /// @notice withdrawn BTCN will be returned as minter asset to the user and the BTCN tokens burned. /// @return depositedTokens array of tokens with shares found for the user /// @return assets array of the underlying asset values returned to the user /// @return bitcornShares the number of BTCN shares redeemed /// @return minterAssetReturned the number of bitcoin minter asset returned to the user function redeemAll() external nonReentrant returns ( address[] memory depositedTokens, uint256[] memory assets, uint256 bitcornShares, uint256 minterAssetReturned ) { (depositedTokens, assets, bitcornShares, minterAssetReturned) = _redeemAllTokens(msg.sender); } function _redeemApprovedToken(address account, address token, uint256 shares) internal returns (uint256) { if (!_isApprovedToken(token)) { revert TokenNotApproved(token); } if (shares == 0) { revert ZeroWithdraw(token); } uint256 cachedShares = _sharesOf[account][token]; if (cachedShares == 0) { revert ZeroShares(token); } if (cachedShares < shares) { revert InsufficientShares(token, cachedShares, shares); } uint256 transferAmount = shares; _burnShares(account, token, shares); if (!paused() && withdrawalFee > 0) { uint256 fee = transferAmount * withdrawalFee / BPS_DIVISOR; if (transferAmount * withdrawalFee % BPS_DIVISOR > 0) { ++fee; } // Fee rounds up transferAmount = transferAmount - fee; IERC20Upgradeable(token).safeTransfer(feeRecipient, fee); } IERC20Upgradeable(token).safeTransfer(account, transferAmount); emit TokenWithdrawn(account, token, transferAmount, shares); return transferAmount; } function _redeemBitcornAndWithdrawMinterAsset(address account, uint256 shares) internal returns (uint256) { uint256 cachedShares = _sharesOf[account][address(bitcorn)]; if (shares == 0) { revert ZeroWithdraw(address(bitcorn)); } if (shares < ONE_SATOSHI_OF_BITCOIN_SHARES) { revert BelowOneSatoshiOfShares(shares, ONE_SATOSHI_OF_BITCOIN_SHARES); } if (cachedShares < shares) { revert InsufficientShares(address(bitcorn), cachedShares, shares); } if (shares % ONE_SATOSHI_OF_BITCOIN_SHARES != 0) { revert SharesNotMultipleOfOneSatoshi(shares, ONE_SATOSHI_OF_BITCOIN_SHARES); } uint256 transferAmount = from18DecimalsToAssetDecimals(shares); _burnShares(account, address(bitcorn), shares); bitcorn.burn(shares); if (!paused() && withdrawalFee > 0) { uint256 fee = transferAmount * withdrawalFee / BPS_DIVISOR; if (transferAmount * withdrawalFee % BPS_DIVISOR > 0) { ++fee; } // Fee rounds up transferAmount = transferAmount - fee; bitcornMinterAsset.safeTransfer(feeRecipient, fee); } bitcornMinterAsset.safeTransfer(account, transferAmount); emit TokenWithdrawn(account, address(bitcorn), transferAmount, shares); return transferAmount; } /// @notice Withdraw shares of all approved tokens and bitcorn /// @dev Will revert if no shares are found for any approved asset or bitcorn /// @dev Convenience function that contains O(n) operations. No hard guarantee of executability. The same functionality can always be executed via the individual withdraw paths. function _redeemAllTokens(address account) internal returns ( address[] memory depositAssets, uint256[] memory assetsReturned, uint256 bitcornShares, uint256 minterAssetReturned ) { bool anySharesFound; address[] memory approvedTokens = getApprovedTokens(); uint256[] memory depositedAssets; uint256 userTokenCount; (depositedAssets, anySharesFound, userTokenCount) = _getAllApprovedTokenSharesFor(account); depositAssets = new address[](userTokenCount); assetsReturned = new uint256[](userTokenCount); bitcornShares = _sharesOf[account][address(bitcorn)]; if (bitcornShares != 0) { anySharesFound = true; } if (!anySharesFound) { revert ZeroSharesForAnyToken(account); } if (bitcornShares != 0) { minterAssetReturned = _redeemBitcornAndWithdrawMinterAsset(account, bitcornShares); } uint256 tokenCount; for (uint256 i = 0; i < approvedTokens.length; i++) { if (depositedAssets[i] == 0) { continue; } else { depositAssets[tokenCount] = approvedTokens[i]; assetsReturned[tokenCount] = _redeemApprovedToken(account, approvedTokens[i], depositedAssets[i]); ++tokenCount; } } } function _getAllApprovedTokenSharesFor(address account) internal view returns (uint256[] memory cachedShares, bool anySharesFound, uint256 userApprovedTokenCount) { address[] memory approvedTokens = getApprovedTokens(); cachedShares = new uint256[](approvedTokens.length); anySharesFound = false; userApprovedTokenCount = 0; for (uint256 i = 0; i < approvedTokens.length; i++) { address token = approvedTokens[i]; uint256 cachedTokenShares = _sharesOf[account][token]; if (cachedTokenShares != 0) { cachedShares[i] = cachedTokenShares; anySharesFound = true; ++userApprovedTokenCount; } } } /*///////////////////////// APPROVED TOKENS /////////////////////////*/ /// @notice Adds a new token to the list of approved tokens /// @dev Reverts if the token is already approved or if the token is the BTCN Minter asset /// @dev Only allowed before the bridge is enabled /// @param token The address of the token to approve function addApprovedToken(address token) external nonReentrant requiresAuth onlyBeforeBridgeEnabled { if (_approvedTokens.contains(token)) { revert TokenAlreadyApproved(token); } // Sanity check: bitcornMinterAsset must not be an approved token if (token == address(bitcornMinterAsset)) { revert BitcornMinterAssetMustNotBeApprovedToken(address(bitcornMinterAsset)); } if (token == address(bitcorn)) { revert BitcornMustNotBeApprovedToken(address(bitcorn)); } _approvedTokens.add(token); } /// @notice Returns a list of all approved tokens. /// @return The list of approved tokens. function getApprovedTokens() public view returns (address[] memory) { return _approvedTokens.values(); } /// @notice Returns whether a token is approved. /// @param _asset The address of the token to check. /// @return Whether the token is approved. function _isApprovedToken(address _asset) internal view returns (bool) { return _approvedTokens.contains(_asset); } /// @notice checks whether an address is a contract on L1, if so, returns the l2 alias address. if not, returns the l1 address. /// @param _address The address to check. /// @return the l2 alias address if the address is a contract on L1, if not, returns the l1 address function _checkAndReturnAlias(address _address) internal view returns (address) { bool hasCode = AddressUpgradeable.isContract(_address); if (hasCode) { return AddressAliasHelper.applyL1ToL2Alias(_address); } else { return _address; } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (proxy/utils/UUPSUpgradeable.sol) pragma solidity ^0.8.0; import "../../interfaces/draft-IERC1822Upgradeable.sol"; import "../ERC1967/ERC1967UpgradeUpgradeable.sol"; import {Initializable} from "./Initializable.sol"; /** * @dev An upgradeability mechanism designed for UUPS proxies. The functions included here can perform an upgrade of an * {ERC1967Proxy}, when this contract is set as the implementation behind such a proxy. * * A security mechanism ensures that an upgrade does not turn off upgradeability accidentally, although this risk is * reinstated if the upgrade retains upgradeability but removes the security mechanism, e.g. by replacing * `UUPSUpgradeable` with a custom implementation of upgrades. * * The {_authorizeUpgrade} function must be overridden to include access restriction to the upgrade mechanism. * * _Available since v4.1._ */ abstract contract UUPSUpgradeable is Initializable, IERC1822ProxiableUpgradeable, ERC1967UpgradeUpgradeable { /// @custom:oz-upgrades-unsafe-allow state-variable-immutable state-variable-assignment address private immutable __self = address(this); /** * @dev Check that the execution is being performed through a delegatecall call and that the execution context is * a proxy contract with an implementation (as defined in ERC1967) pointing to self. This should only be the case * for UUPS and transparent proxies that are using the current contract as their implementation. Execution of a * function through ERC1167 minimal proxies (clones) would not normally pass this test, but is not guaranteed to * fail. */ modifier onlyProxy() { require(address(this) != __self, "Function must be called through delegatecall"); require(_getImplementation() == __self, "Function must be called through active proxy"); _; } /** * @dev Check that the execution is not being performed through a delegate call. This allows a function to be * callable on the implementing contract but not through proxies. */ modifier notDelegated() { require(address(this) == __self, "UUPSUpgradeable: must not be called through delegatecall"); _; } function __UUPSUpgradeable_init() internal onlyInitializing { } function __UUPSUpgradeable_init_unchained() internal onlyInitializing { } /** * @dev Implementation of the ERC1822 {proxiableUUID} function. This returns the storage slot used by the * implementation. It is used to validate the implementation's compatibility when performing an upgrade. * * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this * function revert if invoked through a proxy. This is guaranteed by the `notDelegated` modifier. */ function proxiableUUID() external view virtual override notDelegated returns (bytes32) { return _IMPLEMENTATION_SLOT; } /** * @dev Upgrade the implementation of the proxy to `newImplementation`. * * Calls {_authorizeUpgrade}. * * Emits an {Upgraded} event. * * @custom:oz-upgrades-unsafe-allow-reachable delegatecall */ function upgradeTo(address newImplementation) public virtual onlyProxy { _authorizeUpgrade(newImplementation); _upgradeToAndCallUUPS(newImplementation, new bytes(0), false); } /** * @dev Upgrade the implementation of the proxy to `newImplementation`, and subsequently execute the function call * encoded in `data`. * * Calls {_authorizeUpgrade}. * * Emits an {Upgraded} event. * * @custom:oz-upgrades-unsafe-allow-reachable delegatecall */ function upgradeToAndCall(address newImplementation, bytes memory data) public payable virtual onlyProxy { _authorizeUpgrade(newImplementation); _upgradeToAndCallUUPS(newImplementation, data, true); } /** * @dev Function that should revert when `msg.sender` is not authorized to upgrade the contract. Called by * {upgradeTo} and {upgradeToAndCall}. * * Normally, this function will use an xref:access.adoc[access control] modifier such as {Ownable-onlyOwner}. * * ```solidity * function _authorizeUpgrade(address) internal override onlyOwner {} * ``` */ function _authorizeUpgrade(address newImplementation) internal virtual; /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[50] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (security/Pausable.sol) pragma solidity ^0.8.0; import "../utils/ContextUpgradeable.sol"; import {Initializable} from "../proxy/utils/Initializable.sol"; /** * @dev Contract module which allows children to implement an emergency stop * mechanism that can be triggered by an authorized account. * * This module is used through inheritance. It will make available the * modifiers `whenNotPaused` and `whenPaused`, which can be applied to * the functions of your contract. Note that they will not be pausable by * simply including this module, only once the modifiers are put in place. */ abstract contract PausableUpgradeable is Initializable, ContextUpgradeable { /** * @dev Emitted when the pause is triggered by `account`. */ event Paused(address account); /** * @dev Emitted when the pause is lifted by `account`. */ event Unpaused(address account); bool private _paused; /** * @dev Initializes the contract in unpaused state. */ function __Pausable_init() internal onlyInitializing { __Pausable_init_unchained(); } function __Pausable_init_unchained() internal onlyInitializing { _paused = false; } /** * @dev Modifier to make a function callable only when the contract is not paused. * * Requirements: * * - The contract must not be paused. */ modifier whenNotPaused() { _requireNotPaused(); _; } /** * @dev Modifier to make a function callable only when the contract is paused. * * Requirements: * * - The contract must be paused. */ modifier whenPaused() { _requirePaused(); _; } /** * @dev Returns true if the contract is paused, and false otherwise. */ function paused() public view virtual returns (bool) { return _paused; } /** * @dev Throws if the contract is paused. */ function _requireNotPaused() internal view virtual { require(!paused(), "Pausable: paused"); } /** * @dev Throws if the contract is not paused. */ function _requirePaused() internal view virtual { require(paused(), "Pausable: not paused"); } /** * @dev Triggers stopped state. * * Requirements: * * - The contract must not be paused. */ function _pause() internal virtual whenNotPaused { _paused = true; emit Paused(_msgSender()); } /** * @dev Returns to normal state. * * Requirements: * * - The contract must be paused. */ function _unpause() internal virtual whenPaused { _paused = false; emit Unpaused(_msgSender()); } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[49] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (security/ReentrancyGuard.sol) pragma solidity ^0.8.0; import {Initializable} from "../proxy/utils/Initializable.sol"; /** * @dev Contract module that helps prevent reentrant calls to a function. * * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier * available, which can be applied to functions to make sure there are no nested * (reentrant) calls to them. * * Note that because there is a single `nonReentrant` guard, functions marked as * `nonReentrant` may not call one another. This can be worked around by making * those functions `private`, and then adding `external` `nonReentrant` entry * points to them. * * TIP: If you would like to learn more about reentrancy and alternative ways * to protect against it, check out our blog post * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul]. */ abstract contract ReentrancyGuardUpgradeable is Initializable { // Booleans are more expensive than uint256 or any type that takes up a full // word because each write operation emits an extra SLOAD to first read the // slot's contents, replace the bits taken up by the boolean, and then write // back. This is the compiler's defense against contract upgrades and // pointer aliasing, and it cannot be disabled. // The values being non-zero value makes deployment a bit more expensive, // but in exchange the refund on every call to nonReentrant will be lower in // amount. Since refunds are capped to a percentage of the total // transaction's gas, it is best to keep them low in cases like this one, to // increase the likelihood of the full refund coming into effect. uint256 private constant _NOT_ENTERED = 1; uint256 private constant _ENTERED = 2; uint256 private _status; function __ReentrancyGuard_init() internal onlyInitializing { __ReentrancyGuard_init_unchained(); } function __ReentrancyGuard_init_unchained() internal onlyInitializing { _status = _NOT_ENTERED; } /** * @dev Prevents a contract from calling itself, directly or indirectly. * Calling a `nonReentrant` function from another `nonReentrant` * function is not supported. It is possible to prevent this from happening * by making the `nonReentrant` function external, and making it call a * `private` function that does the actual work. */ modifier nonReentrant() { _nonReentrantBefore(); _; _nonReentrantAfter(); } function _nonReentrantBefore() private { // On the first call to nonReentrant, _status will be _NOT_ENTERED require(_status != _ENTERED, "ReentrancyGuard: reentrant call"); // Any calls to nonReentrant after this point will fail _status = _ENTERED; } function _nonReentrantAfter() private { // By storing the original value once again, a refund is triggered (see // https://eips.ethereum.org/EIPS/eip-2200) _status = _NOT_ENTERED; } /** * @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a * `nonReentrant` function in the call stack. */ function _reentrancyGuardEntered() internal view returns (bool) { return _status == _ENTERED; } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[49] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library AddressUpgradeable { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * * Furthermore, `isContract` will also return true if the target contract within * the same transaction is already scheduled for destruction by `SELFDESTRUCT`, * which only has an effect at the end of a transaction. * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.8.0/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract. * * _Available since v4.8._ */ function verifyCallResultFromTarget( address target, bool success, bytes memory returndata, string memory errorMessage ) internal view returns (bytes memory) { if (success) { if (returndata.length == 0) { // only check isContract if the call was successful and the return data is empty // otherwise we already know that it was a contract require(isContract(target), "Address: call to non-contract"); } return returndata; } else { _revert(returndata, errorMessage); } } /** * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason or using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { _revert(returndata, errorMessage); } } function _revert(bytes memory returndata, string memory errorMessage) private pure { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly /// @solidity memory-safe-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (utils/structs/EnumerableSet.sol) // This file was procedurally generated from scripts/generate/templates/EnumerableSet.js. pragma solidity ^0.8.0; /** * @dev Library for managing * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive * types. * * Sets have the following properties: * * - Elements are added, removed, and checked for existence in constant time * (O(1)). * - Elements are enumerated in O(n). No guarantees are made on the ordering. * * ```solidity * contract Example { * // Add the library methods * using EnumerableSet for EnumerableSet.AddressSet; * * // Declare a set state variable * EnumerableSet.AddressSet private mySet; * } * ``` * * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`) * and `uint256` (`UintSet`) are supported. * * [WARNING] * ==== * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure * unusable. * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info. * * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an * array of EnumerableSet. * ==== */ library EnumerableSetUpgradeable { // To implement this library for multiple types with as little code // repetition as possible, we write it in terms of a generic Set type with // bytes32 values. // The Set implementation uses private functions, and user-facing // implementations (such as AddressSet) are just wrappers around the // underlying Set. // This means that we can only create new EnumerableSets for types that fit // in bytes32. struct Set { // Storage of set values bytes32[] _values; // Position of the value in the `values` array, plus 1 because index 0 // means a value is not in the set. mapping(bytes32 => uint256) _indexes; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function _add(Set storage set, bytes32 value) private returns (bool) { if (!_contains(set, value)) { set._values.push(value); // The value is stored at length-1, but we add 1 to all indexes // and use 0 as a sentinel value set._indexes[value] = set._values.length; return true; } else { return false; } } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function _remove(Set storage set, bytes32 value) private returns (bool) { // We read and store the value's index to prevent multiple reads from the same storage slot uint256 valueIndex = set._indexes[value]; if (valueIndex != 0) { // Equivalent to contains(set, value) // To delete an element from the _values array in O(1), we swap the element to delete with the last one in // the array, and then remove the last element (sometimes called as 'swap and pop'). // This modifies the order of the array, as noted in {at}. uint256 toDeleteIndex = valueIndex - 1; uint256 lastIndex = set._values.length - 1; if (lastIndex != toDeleteIndex) { bytes32 lastValue = set._values[lastIndex]; // Move the last value to the index where the value to delete is set._values[toDeleteIndex] = lastValue; // Update the index for the moved value set._indexes[lastValue] = valueIndex; // Replace lastValue's index to valueIndex } // Delete the slot where the moved value was stored set._values.pop(); // Delete the index for the deleted slot delete set._indexes[value]; return true; } else { return false; } } /** * @dev Returns true if the value is in the set. O(1). */ function _contains(Set storage set, bytes32 value) private view returns (bool) { return set._indexes[value] != 0; } /** * @dev Returns the number of values on the set. O(1). */ function _length(Set storage set) private view returns (uint256) { return set._values.length; } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function _at(Set storage set, uint256 index) private view returns (bytes32) { return set._values[index]; } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function _values(Set storage set) private view returns (bytes32[] memory) { return set._values; } // Bytes32Set struct Bytes32Set { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _add(set._inner, value); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _remove(set._inner, value); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) { return _contains(set._inner, value); } /** * @dev Returns the number of values in the set. O(1). */ function length(Bytes32Set storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) { return _at(set._inner, index); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(Bytes32Set storage set) internal view returns (bytes32[] memory) { bytes32[] memory store = _values(set._inner); bytes32[] memory result; /// @solidity memory-safe-assembly assembly { result := store } return result; } // AddressSet struct AddressSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(AddressSet storage set, address value) internal returns (bool) { return _add(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(AddressSet storage set, address value) internal returns (bool) { return _remove(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(AddressSet storage set, address value) internal view returns (bool) { return _contains(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns the number of values in the set. O(1). */ function length(AddressSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(AddressSet storage set, uint256 index) internal view returns (address) { return address(uint160(uint256(_at(set._inner, index)))); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(AddressSet storage set) internal view returns (address[] memory) { bytes32[] memory store = _values(set._inner); address[] memory result; /// @solidity memory-safe-assembly assembly { result := store } return result; } // UintSet struct UintSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(UintSet storage set, uint256 value) internal returns (bool) { return _add(set._inner, bytes32(value)); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(UintSet storage set, uint256 value) internal returns (bool) { return _remove(set._inner, bytes32(value)); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(UintSet storage set, uint256 value) internal view returns (bool) { return _contains(set._inner, bytes32(value)); } /** * @dev Returns the number of values in the set. O(1). */ function length(UintSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(UintSet storage set, uint256 index) internal view returns (uint256) { return uint256(_at(set._inner, index)); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(UintSet storage set) internal view returns (uint256[] memory) { bytes32[] memory store = _values(set._inner); uint256[] memory result; /// @solidity memory-safe-assembly assembly { result := store } return result; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SafeCast.sol) // This file was procedurally generated from scripts/generate/templates/SafeCast.js. pragma solidity ^0.8.0; /** * @dev Wrappers over Solidity's uintXX/intXX casting operators with added overflow * checks. * * Downcasting from uint256/int256 in Solidity does not revert on overflow. This can * easily result in undesired exploitation or bugs, since developers usually * assume that overflows raise errors. `SafeCast` restores this intuition by * reverting the transaction when such an operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. * * Can be combined with {SafeMath} and {SignedSafeMath} to extend it to smaller types, by performing * all math on `uint256` and `int256` and then downcasting. */ library SafeCastUpgradeable { /** * @dev Returns the downcasted uint248 from uint256, reverting on * overflow (when the input is greater than largest uint248). * * Counterpart to Solidity's `uint248` operator. * * Requirements: * * - input must fit into 248 bits * * _Available since v4.7._ */ function toUint248(uint256 value) internal pure returns (uint248) { require(value <= type(uint248).max, "SafeCast: value doesn't fit in 248 bits"); return uint248(value); } /** * @dev Returns the downcasted uint240 from uint256, reverting on * overflow (when the input is greater than largest uint240). * * Counterpart to Solidity's `uint240` operator. * * Requirements: * * - input must fit into 240 bits * * _Available since v4.7._ */ function toUint240(uint256 value) internal pure returns (uint240) { require(value <= type(uint240).max, "SafeCast: value doesn't fit in 240 bits"); return uint240(value); } /** * @dev Returns the downcasted uint232 from uint256, reverting on * overflow (when the input is greater than largest uint232). * * Counterpart to Solidity's `uint232` operator. * * Requirements: * * - input must fit into 232 bits * * _Available since v4.7._ */ function toUint232(uint256 value) internal pure returns (uint232) { require(value <= type(uint232).max, "SafeCast: value doesn't fit in 232 bits"); return uint232(value); } /** * @dev Returns the downcasted uint224 from uint256, reverting on * overflow (when the input is greater than largest uint224). * * Counterpart to Solidity's `uint224` operator. * * Requirements: * * - input must fit into 224 bits * * _Available since v4.2._ */ function toUint224(uint256 value) internal pure returns (uint224) { require(value <= type(uint224).max, "SafeCast: value doesn't fit in 224 bits"); return uint224(value); } /** * @dev Returns the downcasted uint216 from uint256, reverting on * overflow (when the input is greater than largest uint216). * * Counterpart to Solidity's `uint216` operator. * * Requirements: * * - input must fit into 216 bits * * _Available since v4.7._ */ function toUint216(uint256 value) internal pure returns (uint216) { require(value <= type(uint216).max, "SafeCast: value doesn't fit in 216 bits"); return uint216(value); } /** * @dev Returns the downcasted uint208 from uint256, reverting on * overflow (when the input is greater than largest uint208). * * Counterpart to Solidity's `uint208` operator. * * Requirements: * * - input must fit into 208 bits * * _Available since v4.7._ */ function toUint208(uint256 value) internal pure returns (uint208) { require(value <= type(uint208).max, "SafeCast: value doesn't fit in 208 bits"); return uint208(value); } /** * @dev Returns the downcasted uint200 from uint256, reverting on * overflow (when the input is greater than largest uint200). * * Counterpart to Solidity's `uint200` operator. * * Requirements: * * - input must fit into 200 bits * * _Available since v4.7._ */ function toUint200(uint256 value) internal pure returns (uint200) { require(value <= type(uint200).max, "SafeCast: value doesn't fit in 200 bits"); return uint200(value); } /** * @dev Returns the downcasted uint192 from uint256, reverting on * overflow (when the input is greater than largest uint192). * * Counterpart to Solidity's `uint192` operator. * * Requirements: * * - input must fit into 192 bits * * _Available since v4.7._ */ function toUint192(uint256 value) internal pure returns (uint192) { require(value <= type(uint192).max, "SafeCast: value doesn't fit in 192 bits"); return uint192(value); } /** * @dev Returns the downcasted uint184 from uint256, reverting on * overflow (when the input is greater than largest uint184). * * Counterpart to Solidity's `uint184` operator. * * Requirements: * * - input must fit into 184 bits * * _Available since v4.7._ */ function toUint184(uint256 value) internal pure returns (uint184) { require(value <= type(uint184).max, "SafeCast: value doesn't fit in 184 bits"); return uint184(value); } /** * @dev Returns the downcasted uint176 from uint256, reverting on * overflow (when the input is greater than largest uint176). * * Counterpart to Solidity's `uint176` operator. * * Requirements: * * - input must fit into 176 bits * * _Available since v4.7._ */ function toUint176(uint256 value) internal pure returns (uint176) { require(value <= type(uint176).max, "SafeCast: value doesn't fit in 176 bits"); return uint176(value); } /** * @dev Returns the downcasted uint168 from uint256, reverting on * overflow (when the input is greater than largest uint168). * * Counterpart to Solidity's `uint168` operator. * * Requirements: * * - input must fit into 168 bits * * _Available since v4.7._ */ function toUint168(uint256 value) internal pure returns (uint168) { require(value <= type(uint168).max, "SafeCast: value doesn't fit in 168 bits"); return uint168(value); } /** * @dev Returns the downcasted uint160 from uint256, reverting on * overflow (when the input is greater than largest uint160). * * Counterpart to Solidity's `uint160` operator. * * Requirements: * * - input must fit into 160 bits * * _Available since v4.7._ */ function toUint160(uint256 value) internal pure returns (uint160) { require(value <= type(uint160).max, "SafeCast: value doesn't fit in 160 bits"); return uint160(value); } /** * @dev Returns the downcasted uint152 from uint256, reverting on * overflow (when the input is greater than largest uint152). * * Counterpart to Solidity's `uint152` operator. * * Requirements: * * - input must fit into 152 bits * * _Available since v4.7._ */ function toUint152(uint256 value) internal pure returns (uint152) { require(value <= type(uint152).max, "SafeCast: value doesn't fit in 152 bits"); return uint152(value); } /** * @dev Returns the downcasted uint144 from uint256, reverting on * overflow (when the input is greater than largest uint144). * * Counterpart to Solidity's `uint144` operator. * * Requirements: * * - input must fit into 144 bits * * _Available since v4.7._ */ function toUint144(uint256 value) internal pure returns (uint144) { require(value <= type(uint144).max, "SafeCast: value doesn't fit in 144 bits"); return uint144(value); } /** * @dev Returns the downcasted uint136 from uint256, reverting on * overflow (when the input is greater than largest uint136). * * Counterpart to Solidity's `uint136` operator. * * Requirements: * * - input must fit into 136 bits * * _Available since v4.7._ */ function toUint136(uint256 value) internal pure returns (uint136) { require(value <= type(uint136).max, "SafeCast: value doesn't fit in 136 bits"); return uint136(value); } /** * @dev Returns the downcasted uint128 from uint256, reverting on * overflow (when the input is greater than largest uint128). * * Counterpart to Solidity's `uint128` operator. * * Requirements: * * - input must fit into 128 bits * * _Available since v2.5._ */ function toUint128(uint256 value) internal pure returns (uint128) { require(value <= type(uint128).max, "SafeCast: value doesn't fit in 128 bits"); return uint128(value); } /** * @dev Returns the downcasted uint120 from uint256, reverting on * overflow (when the input is greater than largest uint120). * * Counterpart to Solidity's `uint120` operator. * * Requirements: * * - input must fit into 120 bits * * _Available since v4.7._ */ function toUint120(uint256 value) internal pure returns (uint120) { require(value <= type(uint120).max, "SafeCast: value doesn't fit in 120 bits"); return uint120(value); } /** * @dev Returns the downcasted uint112 from uint256, reverting on * overflow (when the input is greater than largest uint112). * * Counterpart to Solidity's `uint112` operator. * * Requirements: * * - input must fit into 112 bits * * _Available since v4.7._ */ function toUint112(uint256 value) internal pure returns (uint112) { require(value <= type(uint112).max, "SafeCast: value doesn't fit in 112 bits"); return uint112(value); } /** * @dev Returns the downcasted uint104 from uint256, reverting on * overflow (when the input is greater than largest uint104). * * Counterpart to Solidity's `uint104` operator. * * Requirements: * * - input must fit into 104 bits * * _Available since v4.7._ */ function toUint104(uint256 value) internal pure returns (uint104) { require(value <= type(uint104).max, "SafeCast: value doesn't fit in 104 bits"); return uint104(value); } /** * @dev Returns the downcasted uint96 from uint256, reverting on * overflow (when the input is greater than largest uint96). * * Counterpart to Solidity's `uint96` operator. * * Requirements: * * - input must fit into 96 bits * * _Available since v4.2._ */ function toUint96(uint256 value) internal pure returns (uint96) { require(value <= type(uint96).max, "SafeCast: value doesn't fit in 96 bits"); return uint96(value); } /** * @dev Returns the downcasted uint88 from uint256, reverting on * overflow (when the input is greater than largest uint88). * * Counterpart to Solidity's `uint88` operator. * * Requirements: * * - input must fit into 88 bits * * _Available since v4.7._ */ function toUint88(uint256 value) internal pure returns (uint88) { require(value <= type(uint88).max, "SafeCast: value doesn't fit in 88 bits"); return uint88(value); } /** * @dev Returns the downcasted uint80 from uint256, reverting on * overflow (when the input is greater than largest uint80). * * Counterpart to Solidity's `uint80` operator. * * Requirements: * * - input must fit into 80 bits * * _Available since v4.7._ */ function toUint80(uint256 value) internal pure returns (uint80) { require(value <= type(uint80).max, "SafeCast: value doesn't fit in 80 bits"); return uint80(value); } /** * @dev Returns the downcasted uint72 from uint256, reverting on * overflow (when the input is greater than largest uint72). * * Counterpart to Solidity's `uint72` operator. * * Requirements: * * - input must fit into 72 bits * * _Available since v4.7._ */ function toUint72(uint256 value) internal pure returns (uint72) { require(value <= type(uint72).max, "SafeCast: value doesn't fit in 72 bits"); return uint72(value); } /** * @dev Returns the downcasted uint64 from uint256, reverting on * overflow (when the input is greater than largest uint64). * * Counterpart to Solidity's `uint64` operator. * * Requirements: * * - input must fit into 64 bits * * _Available since v2.5._ */ function toUint64(uint256 value) internal pure returns (uint64) { require(value <= type(uint64).max, "SafeCast: value doesn't fit in 64 bits"); return uint64(value); } /** * @dev Returns the downcasted uint56 from uint256, reverting on * overflow (when the input is greater than largest uint56). * * Counterpart to Solidity's `uint56` operator. * * Requirements: * * - input must fit into 56 bits * * _Available since v4.7._ */ function toUint56(uint256 value) internal pure returns (uint56) { require(value <= type(uint56).max, "SafeCast: value doesn't fit in 56 bits"); return uint56(value); } /** * @dev Returns the downcasted uint48 from uint256, reverting on * overflow (when the input is greater than largest uint48). * * Counterpart to Solidity's `uint48` operator. * * Requirements: * * - input must fit into 48 bits * * _Available since v4.7._ */ function toUint48(uint256 value) internal pure returns (uint48) { require(value <= type(uint48).max, "SafeCast: value doesn't fit in 48 bits"); return uint48(value); } /** * @dev Returns the downcasted uint40 from uint256, reverting on * overflow (when the input is greater than largest uint40). * * Counterpart to Solidity's `uint40` operator. * * Requirements: * * - input must fit into 40 bits * * _Available since v4.7._ */ function toUint40(uint256 value) internal pure returns (uint40) { require(value <= type(uint40).max, "SafeCast: value doesn't fit in 40 bits"); return uint40(value); } /** * @dev Returns the downcasted uint32 from uint256, reverting on * overflow (when the input is greater than largest uint32). * * Counterpart to Solidity's `uint32` operator. * * Requirements: * * - input must fit into 32 bits * * _Available since v2.5._ */ function toUint32(uint256 value) internal pure returns (uint32) { require(value <= type(uint32).max, "SafeCast: value doesn't fit in 32 bits"); return uint32(value); } /** * @dev Returns the downcasted uint24 from uint256, reverting on * overflow (when the input is greater than largest uint24). * * Counterpart to Solidity's `uint24` operator. * * Requirements: * * - input must fit into 24 bits * * _Available since v4.7._ */ function toUint24(uint256 value) internal pure returns (uint24) { require(value <= type(uint24).max, "SafeCast: value doesn't fit in 24 bits"); return uint24(value); } /** * @dev Returns the downcasted uint16 from uint256, reverting on * overflow (when the input is greater than largest uint16). * * Counterpart to Solidity's `uint16` operator. * * Requirements: * * - input must fit into 16 bits * * _Available since v2.5._ */ function toUint16(uint256 value) internal pure returns (uint16) { require(value <= type(uint16).max, "SafeCast: value doesn't fit in 16 bits"); return uint16(value); } /** * @dev Returns the downcasted uint8 from uint256, reverting on * overflow (when the input is greater than largest uint8). * * Counterpart to Solidity's `uint8` operator. * * Requirements: * * - input must fit into 8 bits * * _Available since v2.5._ */ function toUint8(uint256 value) internal pure returns (uint8) { require(value <= type(uint8).max, "SafeCast: value doesn't fit in 8 bits"); return uint8(value); } /** * @dev Converts a signed int256 into an unsigned uint256. * * Requirements: * * - input must be greater than or equal to 0. * * _Available since v3.0._ */ function toUint256(int256 value) internal pure returns (uint256) { require(value >= 0, "SafeCast: value must be positive"); return uint256(value); } /** * @dev Returns the downcasted int248 from int256, reverting on * overflow (when the input is less than smallest int248 or * greater than largest int248). * * Counterpart to Solidity's `int248` operator. * * Requirements: * * - input must fit into 248 bits * * _Available since v4.7._ */ function toInt248(int256 value) internal pure returns (int248 downcasted) { downcasted = int248(value); require(downcasted == value, "SafeCast: value doesn't fit in 248 bits"); } /** * @dev Returns the downcasted int240 from int256, reverting on * overflow (when the input is less than smallest int240 or * greater than largest int240). * * Counterpart to Solidity's `int240` operator. * * Requirements: * * - input must fit into 240 bits * * _Available since v4.7._ */ function toInt240(int256 value) internal pure returns (int240 downcasted) { downcasted = int240(value); require(downcasted == value, "SafeCast: value doesn't fit in 240 bits"); } /** * @dev Returns the downcasted int232 from int256, reverting on * overflow (when the input is less than smallest int232 or * greater than largest int232). * * Counterpart to Solidity's `int232` operator. * * Requirements: * * - input must fit into 232 bits * * _Available since v4.7._ */ function toInt232(int256 value) internal pure returns (int232 downcasted) { downcasted = int232(value); require(downcasted == value, "SafeCast: value doesn't fit in 232 bits"); } /** * @dev Returns the downcasted int224 from int256, reverting on * overflow (when the input is less than smallest int224 or * greater than largest int224). * * Counterpart to Solidity's `int224` operator. * * Requirements: * * - input must fit into 224 bits * * _Available since v4.7._ */ function toInt224(int256 value) internal pure returns (int224 downcasted) { downcasted = int224(value); require(downcasted == value, "SafeCast: value doesn't fit in 224 bits"); } /** * @dev Returns the downcasted int216 from int256, reverting on * overflow (when the input is less than smallest int216 or * greater than largest int216). * * Counterpart to Solidity's `int216` operator. * * Requirements: * * - input must fit into 216 bits * * _Available since v4.7._ */ function toInt216(int256 value) internal pure returns (int216 downcasted) { downcasted = int216(value); require(downcasted == value, "SafeCast: value doesn't fit in 216 bits"); } /** * @dev Returns the downcasted int208 from int256, reverting on * overflow (when the input is less than smallest int208 or * greater than largest int208). * * Counterpart to Solidity's `int208` operator. * * Requirements: * * - input must fit into 208 bits * * _Available since v4.7._ */ function toInt208(int256 value) internal pure returns (int208 downcasted) { downcasted = int208(value); require(downcasted == value, "SafeCast: value doesn't fit in 208 bits"); } /** * @dev Returns the downcasted int200 from int256, reverting on * overflow (when the input is less than smallest int200 or * greater than largest int200). * * Counterpart to Solidity's `int200` operator. * * Requirements: * * - input must fit into 200 bits * * _Available since v4.7._ */ function toInt200(int256 value) internal pure returns (int200 downcasted) { downcasted = int200(value); require(downcasted == value, "SafeCast: value doesn't fit in 200 bits"); } /** * @dev Returns the downcasted int192 from int256, reverting on * overflow (when the input is less than smallest int192 or * greater than largest int192). * * Counterpart to Solidity's `int192` operator. * * Requirements: * * - input must fit into 192 bits * * _Available since v4.7._ */ function toInt192(int256 value) internal pure returns (int192 downcasted) { downcasted = int192(value); require(downcasted == value, "SafeCast: value doesn't fit in 192 bits"); } /** * @dev Returns the downcasted int184 from int256, reverting on * overflow (when the input is less than smallest int184 or * greater than largest int184). * * Counterpart to Solidity's `int184` operator. * * Requirements: * * - input must fit into 184 bits * * _Available since v4.7._ */ function toInt184(int256 value) internal pure returns (int184 downcasted) { downcasted = int184(value); require(downcasted == value, "SafeCast: value doesn't fit in 184 bits"); } /** * @dev Returns the downcasted int176 from int256, reverting on * overflow (when the input is less than smallest int176 or * greater than largest int176). * * Counterpart to Solidity's `int176` operator. * * Requirements: * * - input must fit into 176 bits * * _Available since v4.7._ */ function toInt176(int256 value) internal pure returns (int176 downcasted) { downcasted = int176(value); require(downcasted == value, "SafeCast: value doesn't fit in 176 bits"); } /** * @dev Returns the downcasted int168 from int256, reverting on * overflow (when the input is less than smallest int168 or * greater than largest int168). * * Counterpart to Solidity's `int168` operator. * * Requirements: * * - input must fit into 168 bits * * _Available since v4.7._ */ function toInt168(int256 value) internal pure returns (int168 downcasted) { downcasted = int168(value); require(downcasted == value, "SafeCast: value doesn't fit in 168 bits"); } /** * @dev Returns the downcasted int160 from int256, reverting on * overflow (when the input is less than smallest int160 or * greater than largest int160). * * Counterpart to Solidity's `int160` operator. * * Requirements: * * - input must fit into 160 bits * * _Available since v4.7._ */ function toInt160(int256 value) internal pure returns (int160 downcasted) { downcasted = int160(value); require(downcasted == value, "SafeCast: value doesn't fit in 160 bits"); } /** * @dev Returns the downcasted int152 from int256, reverting on * overflow (when the input is less than smallest int152 or * greater than largest int152). * * Counterpart to Solidity's `int152` operator. * * Requirements: * * - input must fit into 152 bits * * _Available since v4.7._ */ function toInt152(int256 value) internal pure returns (int152 downcasted) { downcasted = int152(value); require(downcasted == value, "SafeCast: value doesn't fit in 152 bits"); } /** * @dev Returns the downcasted int144 from int256, reverting on * overflow (when the input is less than smallest int144 or * greater than largest int144). * * Counterpart to Solidity's `int144` operator. * * Requirements: * * - input must fit into 144 bits * * _Available since v4.7._ */ function toInt144(int256 value) internal pure returns (int144 downcasted) { downcasted = int144(value); require(downcasted == value, "SafeCast: value doesn't fit in 144 bits"); } /** * @dev Returns the downcasted int136 from int256, reverting on * overflow (when the input is less than smallest int136 or * greater than largest int136). * * Counterpart to Solidity's `int136` operator. * * Requirements: * * - input must fit into 136 bits * * _Available since v4.7._ */ function toInt136(int256 value) internal pure returns (int136 downcasted) { downcasted = int136(value); require(downcasted == value, "SafeCast: value doesn't fit in 136 bits"); } /** * @dev Returns the downcasted int128 from int256, reverting on * overflow (when the input is less than smallest int128 or * greater than largest int128). * * Counterpart to Solidity's `int128` operator. * * Requirements: * * - input must fit into 128 bits * * _Available since v3.1._ */ function toInt128(int256 value) internal pure returns (int128 downcasted) { downcasted = int128(value); require(downcasted == value, "SafeCast: value doesn't fit in 128 bits"); } /** * @dev Returns the downcasted int120 from int256, reverting on * overflow (when the input is less than smallest int120 or * greater than largest int120). * * Counterpart to Solidity's `int120` operator. * * Requirements: * * - input must fit into 120 bits * * _Available since v4.7._ */ function toInt120(int256 value) internal pure returns (int120 downcasted) { downcasted = int120(value); require(downcasted == value, "SafeCast: value doesn't fit in 120 bits"); } /** * @dev Returns the downcasted int112 from int256, reverting on * overflow (when the input is less than smallest int112 or * greater than largest int112). * * Counterpart to Solidity's `int112` operator. * * Requirements: * * - input must fit into 112 bits * * _Available since v4.7._ */ function toInt112(int256 value) internal pure returns (int112 downcasted) { downcasted = int112(value); require(downcasted == value, "SafeCast: value doesn't fit in 112 bits"); } /** * @dev Returns the downcasted int104 from int256, reverting on * overflow (when the input is less than smallest int104 or * greater than largest int104). * * Counterpart to Solidity's `int104` operator. * * Requirements: * * - input must fit into 104 bits * * _Available since v4.7._ */ function toInt104(int256 value) internal pure returns (int104 downcasted) { downcasted = int104(value); require(downcasted == value, "SafeCast: value doesn't fit in 104 bits"); } /** * @dev Returns the downcasted int96 from int256, reverting on * overflow (when the input is less than smallest int96 or * greater than largest int96). * * Counterpart to Solidity's `int96` operator. * * Requirements: * * - input must fit into 96 bits * * _Available since v4.7._ */ function toInt96(int256 value) internal pure returns (int96 downcasted) { downcasted = int96(value); require(downcasted == value, "SafeCast: value doesn't fit in 96 bits"); } /** * @dev Returns the downcasted int88 from int256, reverting on * overflow (when the input is less than smallest int88 or * greater than largest int88). * * Counterpart to Solidity's `int88` operator. * * Requirements: * * - input must fit into 88 bits * * _Available since v4.7._ */ function toInt88(int256 value) internal pure returns (int88 downcasted) { downcasted = int88(value); require(downcasted == value, "SafeCast: value doesn't fit in 88 bits"); } /** * @dev Returns the downcasted int80 from int256, reverting on * overflow (when the input is less than smallest int80 or * greater than largest int80). * * Counterpart to Solidity's `int80` operator. * * Requirements: * * - input must fit into 80 bits * * _Available since v4.7._ */ function toInt80(int256 value) internal pure returns (int80 downcasted) { downcasted = int80(value); require(downcasted == value, "SafeCast: value doesn't fit in 80 bits"); } /** * @dev Returns the downcasted int72 from int256, reverting on * overflow (when the input is less than smallest int72 or * greater than largest int72). * * Counterpart to Solidity's `int72` operator. * * Requirements: * * - input must fit into 72 bits * * _Available since v4.7._ */ function toInt72(int256 value) internal pure returns (int72 downcasted) { downcasted = int72(value); require(downcasted == value, "SafeCast: value doesn't fit in 72 bits"); } /** * @dev Returns the downcasted int64 from int256, reverting on * overflow (when the input is less than smallest int64 or * greater than largest int64). * * Counterpart to Solidity's `int64` operator. * * Requirements: * * - input must fit into 64 bits * * _Available since v3.1._ */ function toInt64(int256 value) internal pure returns (int64 downcasted) { downcasted = int64(value); require(downcasted == value, "SafeCast: value doesn't fit in 64 bits"); } /** * @dev Returns the downcasted int56 from int256, reverting on * overflow (when the input is less than smallest int56 or * greater than largest int56). * * Counterpart to Solidity's `int56` operator. * * Requirements: * * - input must fit into 56 bits * * _Available since v4.7._ */ function toInt56(int256 value) internal pure returns (int56 downcasted) { downcasted = int56(value); require(downcasted == value, "SafeCast: value doesn't fit in 56 bits"); } /** * @dev Returns the downcasted int48 from int256, reverting on * overflow (when the input is less than smallest int48 or * greater than largest int48). * * Counterpart to Solidity's `int48` operator. * * Requirements: * * - input must fit into 48 bits * * _Available since v4.7._ */ function toInt48(int256 value) internal pure returns (int48 downcasted) { downcasted = int48(value); require(downcasted == value, "SafeCast: value doesn't fit in 48 bits"); } /** * @dev Returns the downcasted int40 from int256, reverting on * overflow (when the input is less than smallest int40 or * greater than largest int40). * * Counterpart to Solidity's `int40` operator. * * Requirements: * * - input must fit into 40 bits * * _Available since v4.7._ */ function toInt40(int256 value) internal pure returns (int40 downcasted) { downcasted = int40(value); require(downcasted == value, "SafeCast: value doesn't fit in 40 bits"); } /** * @dev Returns the downcasted int32 from int256, reverting on * overflow (when the input is less than smallest int32 or * greater than largest int32). * * Counterpart to Solidity's `int32` operator. * * Requirements: * * - input must fit into 32 bits * * _Available since v3.1._ */ function toInt32(int256 value) internal pure returns (int32 downcasted) { downcasted = int32(value); require(downcasted == value, "SafeCast: value doesn't fit in 32 bits"); } /** * @dev Returns the downcasted int24 from int256, reverting on * overflow (when the input is less than smallest int24 or * greater than largest int24). * * Counterpart to Solidity's `int24` operator. * * Requirements: * * - input must fit into 24 bits * * _Available since v4.7._ */ function toInt24(int256 value) internal pure returns (int24 downcasted) { downcasted = int24(value); require(downcasted == value, "SafeCast: value doesn't fit in 24 bits"); } /** * @dev Returns the downcasted int16 from int256, reverting on * overflow (when the input is less than smallest int16 or * greater than largest int16). * * Counterpart to Solidity's `int16` operator. * * Requirements: * * - input must fit into 16 bits * * _Available since v3.1._ */ function toInt16(int256 value) internal pure returns (int16 downcasted) { downcasted = int16(value); require(downcasted == value, "SafeCast: value doesn't fit in 16 bits"); } /** * @dev Returns the downcasted int8 from int256, reverting on * overflow (when the input is less than smallest int8 or * greater than largest int8). * * Counterpart to Solidity's `int8` operator. * * Requirements: * * - input must fit into 8 bits * * _Available since v3.1._ */ function toInt8(int256 value) internal pure returns (int8 downcasted) { downcasted = int8(value); require(downcasted == value, "SafeCast: value doesn't fit in 8 bits"); } /** * @dev Converts an unsigned uint256 into a signed int256. * * Requirements: * * - input must be less than or equal to maxInt256. * * _Available since v3.0._ */ function toInt256(uint256 value) internal pure returns (int256) { // Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive require(value <= uint256(type(int256).max), "SafeCast: value doesn't fit in an int256"); return int256(value); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.3) (token/ERC20/utils/SafeERC20.sol) pragma solidity ^0.8.0; import "../IERC20Upgradeable.sol"; import "../extensions/IERC20PermitUpgradeable.sol"; import "../../../utils/AddressUpgradeable.sol"; /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20Upgradeable { using AddressUpgradeable for address; /** * @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value, * non-reverting calls are assumed to be successful. */ function safeTransfer(IERC20Upgradeable token, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } /** * @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the * calling contract. If `token` returns no value, non-reverting calls are assumed to be successful. */ function safeTransferFrom(IERC20Upgradeable token, address from, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } /** * @dev Deprecated. This function has issues similar to the ones found in * {IERC20-approve}, and its usage is discouraged. * * Whenever possible, use {safeIncreaseAllowance} and * {safeDecreaseAllowance} instead. */ function safeApprove(IERC20Upgradeable token, address spender, uint256 value) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' require( (value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } /** * @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value, * non-reverting calls are assumed to be successful. */ function safeIncreaseAllowance(IERC20Upgradeable token, address spender, uint256 value) internal { uint256 oldAllowance = token.allowance(address(this), spender); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance + value)); } /** * @dev Decrease the calling contract's allowance toward `spender` by `value`. If `token` returns no value, * non-reverting calls are assumed to be successful. */ function safeDecreaseAllowance(IERC20Upgradeable token, address spender, uint256 value) internal { unchecked { uint256 oldAllowance = token.allowance(address(this), spender); require(oldAllowance >= value, "SafeERC20: decreased allowance below zero"); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance - value)); } } /** * @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value, * non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval * to be set to zero before setting it to a non-zero value, such as USDT. */ function forceApprove(IERC20Upgradeable token, address spender, uint256 value) internal { bytes memory approvalCall = abi.encodeWithSelector(token.approve.selector, spender, value); if (!_callOptionalReturnBool(token, approvalCall)) { _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, 0)); _callOptionalReturn(token, approvalCall); } } /** * @dev Use a ERC-2612 signature to set the `owner` approval toward `spender` on `token`. * Revert on invalid signature. */ function safePermit( IERC20PermitUpgradeable token, address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) internal { uint256 nonceBefore = token.nonces(owner); token.permit(owner, spender, value, deadline, v, r, s); uint256 nonceAfter = token.nonces(owner); require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed"); } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function _callOptionalReturn(IERC20Upgradeable token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed"); require(returndata.length == 0 || abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). * * This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead. */ function _callOptionalReturnBool(IERC20Upgradeable token, bytes memory data) private returns (bool) { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We cannot use {Address-functionCall} here since this should return false // and not revert is the subcall reverts. (bool success, bytes memory returndata) = address(token).call(data); return success && (returndata.length == 0 || abi.decode(returndata, (bool))) && AddressUpgradeable.isContract(address(token)); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/IERC20.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20Upgradeable { /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); /** * @dev Returns the 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 `to`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address to, 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 `from` to `to` 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 from, address to, uint256 amount) external returns (bool); }
// SPDX-License-Identifier: AGPL-3.0-only pragma solidity >=0.8.13; import {Authority} from "solmate/auth/Auth.sol"; /// @notice Provides a flexible and updatable auth pattern which is completely separate from application logic. /// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/auth/Auth.sol) /// @author Modified from Dappsys (https://github.com/dapphub/ds-auth/blob/master/src/auth.sol) contract AuthNoOwner { event AuthorityUpdated(address indexed user, Authority indexed newAuthority); Authority private _authority; bool private _authorityInitialized; /// @notice Modifier to require caller authorization for function execution. modifier requiresAuth() virtual { require(isAuthorized(msg.sender, msg.sig), "Auth: UNAUTHORIZED"); _; } /// @notice Returns the authority contract that controls access permissions. /// @return The Authority contract instance. function authority() public view returns (Authority) { return _authority; } /// @notice Checks if the authority has been initialized. /// @notice The authority can only be initialized once. /// @return bool Returns true if the authority has been initialized, false otherwise. function authorityInitialized() public view returns (bool) { return _authorityInitialized; } /// @notice Determines if a user is authorized to call a specific function. /// @dev Memoizes the authority instance to save gas and checks if the authority allows the call. /// @param user The address of the user attempting to call the function. /// @param functionSig The signature of the function being called. /// @return bool Returns true if the user is authorized to call the function, false otherwise. function isAuthorized(address user, bytes4 functionSig) internal view virtual returns (bool) { Authority auth = _authority; // Memoizing authority saves us a warm SLOAD, around 100 gas. // Checking if the caller is the owner only after calling the authority saves gas in most cases, but be // aware that this makes protected functions uncallable even to the owner if the authority is out of order. return (address(auth) != address(0) && auth.canCall(user, address(this), functionSig)); } /// @notice Changed constructor to initialize to allow flexiblity of constructor vs initializer use /// @notice sets authorityInitiailzed flag to ensure only one use of function _initializeAuthority(address newAuthority) internal { require(address(_authority) == address(0), "Auth: authority is non-zero"); require(!_authorityInitialized, "Auth: authority already initialized"); _authority = Authority(newAuthority); _authorityInitialized = true; emit AuthorityUpdated(address(this), Authority(newAuthority)); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.20; import {IERC20Upgradeable} from "openzeppelin-contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol"; import {IERC20MetadataUpgradeable} from "openzeppelin-contracts-upgradeable/interfaces/IERC20MetadataUpgradeable.sol"; import {IERC20PermitUpgradeable} from "openzeppelin-contracts-upgradeable/token/ERC20/extensions/IERC20PermitUpgradeable.sol"; interface IBitcorn is IERC20Upgradeable, IERC20MetadataUpgradeable, IERC20PermitUpgradeable { // Initializes the contract with the given initial authority. function initialize(address initialAuthority) external; // Mints `amount` tokens to the caller's account. function mint(uint256 amount) external; // Mints `amount` tokens to the specified `to` address. function mintTo(address to, uint256 amount) external; // Burns `amount` tokens from the caller's account. function burn(uint256 amount) external; // Pauses all token transfers. function pause() external; // Unpauses all token transfers. function unpause() external; }
// SPDX-License-Identifier: Apache-2.0 /* * Copyright 2019-2021, Offchain Labs, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ pragma solidity ^0.8.0; library AddressAliasHelper { uint160 constant offset = uint160(0x1111000000000000000000000000000000001111); /// @notice Utility function that converts the address in the L1 that submitted a tx to /// the inbox to the msg.sender viewed in the L2 /// @param l1Address the address in the L1 that triggered the tx to L2 /// @return l2Address L2 address as viewed in msg.sender function applyL1ToL2Alias(address l1Address) internal pure returns (address l2Address) { unchecked { l2Address = address(uint160(l1Address) + offset); } } /// @notice Utility function that converts the msg.sender viewed in the L2 to the /// address in the L1 that submitted a tx to the inbox /// @param l2Address L2 address as viewed in msg.sender /// @return l1Address the address in the L1 that triggered the tx to L2 function undoL1ToL2Alias(address l2Address) internal pure returns (address l1Address) { unchecked { l1Address = address(uint160(l2Address) - offset); } } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.15; interface IGatewayRouter { function getGateway(address) external view returns (address); function outboundTransferCustomRefund( address _l1Token, address _refundTo, address _to, uint256 _amount, uint256 _maxGas, uint256 _gasPriceBid, bytes calldata _data ) external payable returns (bytes memory); } interface IERC20Inbox { function createRetryableTicket( address to, uint256 l2CallValue, uint256 maxSubmissionCost, address excessFeeRefundAddress, address callValueRefundAddress, uint256 gasLimit, uint256 maxFeePerGas, uint256 tokenTotalFeeAmount, bytes calldata data ) external returns (uint256); function unsafeCreateRetryableTicket( address to, uint256 l2CallValue, uint256 maxSubmissionCost, address excessFeeRefundAddress, address callValueRefundAddress, uint256 gasLimit, uint256 maxFeePerGas, uint256 tokenTotalFeeAmount, bytes calldata data ) external returns (uint256); } interface ICornSilo { // Events event TokenDeposited(address indexed user, address indexed token, uint256 assets, uint256 shares); event TokenWithdrawn(address indexed user, address indexed token, uint256 assets, uint256 shares); event TokenBridged( address indexed token, address indexed user, address indexed recipient, uint256 amount, uint256 maxGas, uint256 gasPriceBid, bytes data ); event BridgeEnabled(address gatewayRouter, address swapFacilityVault); // Errors error BridgeNotEnabled(); error BridgeIsEnabled(); error BridgeIsNotSet(); error ZeroDeposit(address token); error ZeroWithdraw(address token); error ZeroShares(address token); error ZeroSharesForAnyToken(address account); error TokenNotApproved(address token); error BitcornMinterAssetMustNotBeApprovedToken(address bitcornMinterAsset); error BitcornMustNotBeApprovedToken(address bitcorn); error TokenAlreadyApproved(address token); error InsufficientShares(address token, uint256 cachedShares, uint256 shares); error WithdrawalFeeAboveMax(uint256 fee); error SharesNotMultipleOfOneSatoshi(uint256 bitcornShares, uint256 oneSatoshiOfBitcornShares); error BelowOneSatoshiOfShares(uint256 shares, uint256 oneSatoshiOfBitcornShares); error InsufficientBitcornSharesToBridge(uint256 cachedShares, uint256 requiredShares); function pause() external; function unpause() external; function getGatewayRouter() external view returns (IGatewayRouter gatewayRouter); function sharesOf(address user, address token) external view returns (uint256); function totalShares(address token) external returns (uint256); function deposit(address token, uint256 assets) external returns (uint256 shares); function depositFor(address recipient, address token, uint256 assets) external returns (uint256 shares); function mintAndDepositBitcorn(uint256 assets) external returns (uint256 shares); function mintAndDepositBitcornFor(address recipient, uint256 assets) external returns (uint256 shares); function redeemToken(address token, uint256 shares) external returns (uint256 assets); function redeemBitcorn(uint256 shares) external returns (uint256 assets); function redeemAll() external returns ( address[] memory approvedTokens, uint256[] memory depositedAssets, uint256 bitcornShares, uint256 minterAssetReturned ); function enableBridge(address gatewayRouter, address erc20Inbox, address swapFacilityVault) external; function bridgeToken(address token, address recipient, uint256 maxGas, uint256 gasPriceBid, bytes calldata data) external; function bridgeAllTokens(address recipient, uint256 cost, uint256 maxGas, uint256 gasPriceBid, bytes calldata data) external; function addApprovedToken(address token) external; function getApprovedTokens() external view returns (address[] memory); function fromAssetDecimalsTo18Decimals(uint256 amount) external view returns (uint256); function from18DecimalsToAssetDecimals(uint256 amountIn18Decimals) external view returns (uint256); }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.2; /// @dev Interface of the ERC20 standard as defined in the EIP. /// @dev This includes the optional name, symbol, and decimals metadata. interface IERC20 { /// @dev Emitted when `value` tokens are moved from one account (`from`) to another (`to`). event Transfer(address indexed from, address indexed to, uint256 value); /// @dev Emitted when the allowance of a `spender` for an `owner` is set, where `value` /// is the new allowance. event Approval(address indexed owner, address indexed spender, uint256 value); /// @notice Returns the amount of tokens in existence. function totalSupply() external view returns (uint256); /// @notice Returns the amount of tokens owned by `account`. function balanceOf(address account) external view returns (uint256); /// @notice Moves `amount` tokens from the caller's account to `to`. function transfer(address to, uint256 amount) external returns (bool); /// @notice Returns the remaining number of tokens that `spender` is allowed /// to spend on behalf of `owner` function allowance(address owner, address spender) external view returns (uint256); /// @notice Sets `amount` as the allowance of `spender` over the caller's tokens. /// @dev Be aware of front-running risks: https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 function approve(address spender, uint256 amount) external returns (bool); /// @notice Moves `amount` tokens from `from` to `to` using the allowance mechanism. /// `amount` is then deducted from the caller's allowance. function transferFrom(address from, address to, uint256 amount) external returns (bool); /// @notice Returns the name of the token. function name() external view returns (string memory); /// @notice Returns the symbol of the token. function symbol() external view returns (string memory); /// @notice Returns the decimals places of the token. function decimals() external view returns (uint8); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (interfaces/draft-IERC1822.sol) pragma solidity ^0.8.0; /** * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified * proxy whose upgrades are fully controlled by the current implementation. */ interface IERC1822ProxiableUpgradeable { /** * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation * address. * * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this * function revert if invoked through a proxy. */ function proxiableUUID() external view returns (bytes32); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (proxy/ERC1967/ERC1967Upgrade.sol) pragma solidity ^0.8.2; import "../beacon/IBeaconUpgradeable.sol"; import "../../interfaces/IERC1967Upgradeable.sol"; import "../../interfaces/draft-IERC1822Upgradeable.sol"; import "../../utils/AddressUpgradeable.sol"; import "../../utils/StorageSlotUpgradeable.sol"; import {Initializable} from "../utils/Initializable.sol"; /** * @dev This abstract contract provides getters and event emitting update functions for * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots. * * _Available since v4.1._ */ abstract contract ERC1967UpgradeUpgradeable is Initializable, IERC1967Upgradeable { // This is the keccak-256 hash of "eip1967.proxy.rollback" subtracted by 1 bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143; /** * @dev Storage slot with the address of the current implementation. * This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1, and is * validated in the constructor. */ bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; function __ERC1967Upgrade_init() internal onlyInitializing { } function __ERC1967Upgrade_init_unchained() internal onlyInitializing { } /** * @dev Returns the current implementation address. */ function _getImplementation() internal view returns (address) { return StorageSlotUpgradeable.getAddressSlot(_IMPLEMENTATION_SLOT).value; } /** * @dev Stores a new address in the EIP1967 implementation slot. */ function _setImplementation(address newImplementation) private { require(AddressUpgradeable.isContract(newImplementation), "ERC1967: new implementation is not a contract"); StorageSlotUpgradeable.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation; } /** * @dev Perform implementation upgrade * * Emits an {Upgraded} event. */ function _upgradeTo(address newImplementation) internal { _setImplementation(newImplementation); emit Upgraded(newImplementation); } /** * @dev Perform implementation upgrade with additional setup call. * * Emits an {Upgraded} event. */ function _upgradeToAndCall(address newImplementation, bytes memory data, bool forceCall) internal { _upgradeTo(newImplementation); if (data.length > 0 || forceCall) { AddressUpgradeable.functionDelegateCall(newImplementation, data); } } /** * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call. * * Emits an {Upgraded} event. */ function _upgradeToAndCallUUPS(address newImplementation, bytes memory data, bool forceCall) internal { // Upgrades from old implementations will perform a rollback test. This test requires the new // implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing // this special case will break upgrade paths from old UUPS implementation to new ones. if (StorageSlotUpgradeable.getBooleanSlot(_ROLLBACK_SLOT).value) { _setImplementation(newImplementation); } else { try IERC1822ProxiableUpgradeable(newImplementation).proxiableUUID() returns (bytes32 slot) { require(slot == _IMPLEMENTATION_SLOT, "ERC1967Upgrade: unsupported proxiableUUID"); } catch { revert("ERC1967Upgrade: new implementation is not UUPS"); } _upgradeToAndCall(newImplementation, data, forceCall); } } /** * @dev Storage slot with the admin of the contract. * This is the keccak-256 hash of "eip1967.proxy.admin" subtracted by 1, and is * validated in the constructor. */ bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103; /** * @dev Returns the current admin. */ function _getAdmin() internal view returns (address) { return StorageSlotUpgradeable.getAddressSlot(_ADMIN_SLOT).value; } /** * @dev Stores a new address in the EIP1967 admin slot. */ function _setAdmin(address newAdmin) private { require(newAdmin != address(0), "ERC1967: new admin is the zero address"); StorageSlotUpgradeable.getAddressSlot(_ADMIN_SLOT).value = newAdmin; } /** * @dev Changes the admin of the proxy. * * Emits an {AdminChanged} event. */ function _changeAdmin(address newAdmin) internal { emit AdminChanged(_getAdmin(), newAdmin); _setAdmin(newAdmin); } /** * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy. * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor. */ bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50; /** * @dev Returns the current beacon. */ function _getBeacon() internal view returns (address) { return StorageSlotUpgradeable.getAddressSlot(_BEACON_SLOT).value; } /** * @dev Stores a new beacon in the EIP1967 beacon slot. */ function _setBeacon(address newBeacon) private { require(AddressUpgradeable.isContract(newBeacon), "ERC1967: new beacon is not a contract"); require( AddressUpgradeable.isContract(IBeaconUpgradeable(newBeacon).implementation()), "ERC1967: beacon implementation is not a contract" ); StorageSlotUpgradeable.getAddressSlot(_BEACON_SLOT).value = newBeacon; } /** * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that). * * Emits a {BeaconUpgraded} event. */ function _upgradeBeaconToAndCall(address newBeacon, bytes memory data, bool forceCall) internal { _setBeacon(newBeacon); emit BeaconUpgraded(newBeacon); if (data.length > 0 || forceCall) { AddressUpgradeable.functionDelegateCall(IBeaconUpgradeable(newBeacon).implementation(), data); } } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[50] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (proxy/utils/Initializable.sol) pragma solidity ^0.8.2; import "../../utils/AddressUpgradeable.sol"; /** * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect. * * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be * reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in * case an upgrade adds a module that needs to be initialized. * * For example: * * [.hljs-theme-light.nopadding] * ```solidity * contract MyToken is ERC20Upgradeable { * function initialize() initializer public { * __ERC20_init("MyToken", "MTK"); * } * } * * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable { * function initializeV2() reinitializer(2) public { * __ERC20Permit_init("MyToken"); * } * } * ``` * * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}. * * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity. * * [CAUTION] * ==== * Avoid leaving a contract uninitialized. * * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed: * * [.hljs-theme-light.nopadding] * ``` * /// @custom:oz-upgrades-unsafe-allow constructor * constructor() { * _disableInitializers(); * } * ``` * ==== */ abstract contract Initializable { /** * @dev Indicates that the contract has been initialized. * @custom:oz-retyped-from bool */ uint8 private _initialized; /** * @dev Indicates that the contract is in the process of being initialized. */ bool private _initializing; /** * @dev Triggered when the contract has been initialized or reinitialized. */ event Initialized(uint8 version); /** * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope, * `onlyInitializing` functions can be used to initialize parent contracts. * * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a * constructor. * * Emits an {Initialized} event. */ modifier initializer() { bool isTopLevelCall = !_initializing; require( (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1), "Initializable: contract is already initialized" ); _initialized = 1; if (isTopLevelCall) { _initializing = true; } _; if (isTopLevelCall) { _initializing = false; emit Initialized(1); } } /** * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be * used to initialize parent contracts. * * A reinitializer may be used after the original initialization step. This is essential to configure modules that * are added through upgrades and that require initialization. * * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer` * cannot be nested. If one is invoked in the context of another, execution will revert. * * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in * a contract, executing them in the right order is up to the developer or operator. * * WARNING: setting the version to 255 will prevent any future reinitialization. * * Emits an {Initialized} event. */ modifier reinitializer(uint8 version) { require(!_initializing && _initialized < version, "Initializable: contract is already initialized"); _initialized = version; _initializing = true; _; _initializing = false; emit Initialized(version); } /** * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the * {initializer} and {reinitializer} modifiers, directly or indirectly. */ modifier onlyInitializing() { require(_initializing, "Initializable: contract is not initializing"); _; } /** * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call. * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized * to any version. It is recommended to use this to lock implementation contracts that are designed to be called * through proxies. * * Emits an {Initialized} event the first time it is successfully executed. */ function _disableInitializers() internal virtual { require(!_initializing, "Initializable: contract is initializing"); if (_initialized != type(uint8).max) { _initialized = type(uint8).max; emit Initialized(type(uint8).max); } } /** * @dev Returns the highest version that has been initialized. See {reinitializer}. */ function _getInitializedVersion() internal view returns (uint8) { return _initialized; } /** * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}. */ function _isInitializing() internal view returns (bool) { return _initializing; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.4) (utils/Context.sol) pragma solidity ^0.8.0; import {Initializable} from "../proxy/utils/Initializable.sol"; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract ContextUpgradeable is Initializable { function __Context_init() internal onlyInitializing { } function __Context_init_unchained() internal onlyInitializing { } function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } function _contextSuffixLength() internal view virtual returns (uint256) { return 0; } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[50] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.4) (token/ERC20/extensions/IERC20Permit.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612]. * * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't * need to send a transaction, and thus is not required to hold Ether at all. * * ==== Security Considerations * * There are two important considerations concerning the use of `permit`. The first is that a valid permit signature * expresses an allowance, and it should not be assumed to convey additional meaning. In particular, it should not be * considered as an intention to spend the allowance in any specific way. The second is that because permits have * built-in replay protection and can be submitted by anyone, they can be frontrun. A protocol that uses permits should * take this into consideration and allow a `permit` call to fail. Combining these two aspects, a pattern that may be * generally recommended is: * * ```solidity * function doThingWithPermit(..., uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public { * try token.permit(msg.sender, address(this), value, deadline, v, r, s) {} catch {} * doThing(..., value); * } * * function doThing(..., uint256 value) public { * token.safeTransferFrom(msg.sender, address(this), value); * ... * } * ``` * * Observe that: 1) `msg.sender` is used as the owner, leaving no ambiguity as to the signer intent, and 2) the use of * `try/catch` allows the permit to fail and makes the code tolerant to frontrunning. (See also * {SafeERC20-safeTransferFrom}). * * Additionally, note that smart contract wallets (such as Argent or Safe) are not able to produce permit signatures, so * contracts should have entry points that don't rely on permit. */ interface IERC20PermitUpgradeable { /** * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens, * given ``owner``'s signed approval. * * IMPORTANT: The same issues {IERC20-approve} has related to transaction * ordering also apply here. * * Emits an {Approval} event. * * Requirements: * * - `spender` cannot be the zero address. * - `deadline` must be a timestamp in the future. * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner` * over the EIP712-formatted function arguments. * - the signature must use ``owner``'s current nonce (see {nonces}). * * For more information on the signature format, see the * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP * section]. * * CAUTION: See Security Considerations above. */ function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) external; /** * @dev Returns the current nonce for `owner`. This value must be * included whenever a signature is generated for {permit}. * * Every successful call to {permit} increases ``owner``'s nonce by one. This * prevents a signature from being used multiple times. */ function nonces(address owner) external view returns (uint256); /** * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}. */ // solhint-disable-next-line func-name-mixedcase function DOMAIN_SEPARATOR() external view returns (bytes32); }
// SPDX-License-Identifier: AGPL-3.0-only pragma solidity >=0.8.0; /// @notice Provides a flexible and updatable auth pattern which is completely separate from application logic. /// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/auth/Auth.sol) /// @author Modified from Dappsys (https://github.com/dapphub/ds-auth/blob/master/src/auth.sol) abstract contract Auth { event OwnershipTransferred(address indexed user, address indexed newOwner); event AuthorityUpdated(address indexed user, Authority indexed newAuthority); address public owner; Authority public authority; constructor(address _owner, Authority _authority) { owner = _owner; authority = _authority; emit OwnershipTransferred(msg.sender, _owner); emit AuthorityUpdated(msg.sender, _authority); } modifier requiresAuth() virtual { require(isAuthorized(msg.sender, msg.sig), "UNAUTHORIZED"); _; } function isAuthorized(address user, bytes4 functionSig) internal view virtual returns (bool) { Authority auth = authority; // Memoizing authority saves us a warm SLOAD, around 100 gas. // Checking if the caller is the owner only after calling the authority saves gas in most cases, but be // aware that this makes protected functions uncallable even to the owner if the authority is out of order. return (address(auth) != address(0) && auth.canCall(user, address(this), functionSig)) || user == owner; } function setAuthority(Authority newAuthority) public virtual { // We check if the caller is the owner first because we want to ensure they can // always swap out the authority even if it's reverting or using up a lot of gas. require(msg.sender == owner || authority.canCall(msg.sender, address(this), msg.sig)); authority = newAuthority; emit AuthorityUpdated(msg.sender, newAuthority); } function transferOwnership(address newOwner) public virtual requiresAuth { owner = newOwner; emit OwnershipTransferred(msg.sender, newOwner); } } /// @notice A generic interface for a contract which provides authorization data to an Auth instance. /// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/auth/Auth.sol) /// @author Modified from Dappsys (https://github.com/dapphub/ds-auth/blob/master/src/auth.sol) interface Authority { function canCall( address user, address target, bytes4 functionSig ) external view returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (interfaces/IERC20Metadata.sol) pragma solidity ^0.8.0; import "../token/ERC20/extensions/IERC20MetadataUpgradeable.sol";
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol) pragma solidity ^0.8.0; /** * @dev This is the interface that {BeaconProxy} expects of its beacon. */ interface IBeaconUpgradeable { /** * @dev Must return an address that can be used as a delegate call target. * * {BeaconProxy} will check that this address is a contract. */ function implementation() external view returns (address); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (interfaces/IERC1967.sol) pragma solidity ^0.8.0; /** * @dev ERC-1967: Proxy Storage Slots. This interface contains the events defined in the ERC. * * _Available since v4.8.3._ */ interface IERC1967Upgradeable { /** * @dev Emitted when the implementation is upgraded. */ event Upgraded(address indexed implementation); /** * @dev Emitted when the admin account has changed. */ event AdminChanged(address previousAdmin, address newAdmin); /** * @dev Emitted when the beacon is changed. */ event BeaconUpgraded(address indexed beacon); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (utils/StorageSlot.sol) // This file was procedurally generated from scripts/generate/templates/StorageSlot.js. pragma solidity ^0.8.0; /** * @dev Library for reading and writing primitive types to specific storage slots. * * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts. * This library helps with reading and writing to such slots without the need for inline assembly. * * The functions in this library return Slot structs that contain a `value` member that can be used to read or write. * * Example usage to set ERC1967 implementation slot: * ```solidity * contract ERC1967 { * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; * * function _getImplementation() internal view returns (address) { * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value; * } * * function _setImplementation(address newImplementation) internal { * require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract"); * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation; * } * } * ``` * * _Available since v4.1 for `address`, `bool`, `bytes32`, `uint256`._ * _Available since v4.9 for `string`, `bytes`._ */ library StorageSlotUpgradeable { struct AddressSlot { address value; } struct BooleanSlot { bool value; } struct Bytes32Slot { bytes32 value; } struct Uint256Slot { uint256 value; } struct StringSlot { string value; } struct BytesSlot { bytes value; } /** * @dev Returns an `AddressSlot` with member `value` located at `slot`. */ function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `BooleanSlot` with member `value` located at `slot`. */ function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `Bytes32Slot` with member `value` located at `slot`. */ function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `Uint256Slot` with member `value` located at `slot`. */ function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `StringSlot` with member `value` located at `slot`. */ function getStringSlot(bytes32 slot) internal pure returns (StringSlot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `StringSlot` representation of the string storage pointer `store`. */ function getStringSlot(string storage store) internal pure returns (StringSlot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := store.slot } } /** * @dev Returns an `BytesSlot` with member `value` located at `slot`. */ function getBytesSlot(bytes32 slot) internal pure returns (BytesSlot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `BytesSlot` representation of the bytes storage pointer `store`. */ function getBytesSlot(bytes storage store) internal pure returns (BytesSlot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := store.slot } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol) pragma solidity ^0.8.0; import "../IERC20Upgradeable.sol"; /** * @dev Interface for the optional metadata functions from the ERC20 standard. * * _Available since v4.1._ */ interface IERC20MetadataUpgradeable is IERC20Upgradeable { /** * @dev Returns the name of the token. */ function name() external view returns (string memory); /** * @dev Returns the symbol of the token. */ function symbol() external view returns (string memory); /** * @dev Returns the decimals places of the token. */ function decimals() external view returns (uint8); }
{ "remappings": [ "ds-test/=lib/forge-std/lib/ds-test/src/", "erc4626-tests/=lib/openzeppelin-contracts-upgradeable/lib/erc4626-tests/", "forge-std/=lib/forge-std/src/", "openzeppelin-contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/", "openzeppelin-contracts/=lib/openzeppelin-contracts/contracts/", "solmate/=lib/solmate/src/", "arbitrum-token-bridge/=lib/token-bridge-contracts/contracts/", "corn-standard-solidity/=lib/corn-standard-solidity/src/", "bitcorn-token/=lib/bitcorn-token/src/", "@arbitrum/=lib/token-bridge-contracts/node_modules/@arbitrum/", "@offchainlabs/=lib/token-bridge-contracts/node_modules/@offchainlabs/", "@openzeppelin/contracts-upgradeable/=lib/token-bridge-contracts/node_modules/@openzeppelin/contracts-upgradeable/", "@openzeppelin/contracts/=lib/token-bridge-contracts/node_modules/@openzeppelin/contracts/", "halmos-cheatcodes/=lib/bitcorn-token/lib/openzeppelin-contracts-upgradeable/lib/halmos-cheatcodes/src/", "openzeppelin/=lib/openzeppelin-contracts-upgradeable/contracts/", "token-bridge-contracts/=lib/token-bridge-contracts/" ], "optimizer": { "enabled": true, "runs": 200 }, "metadata": { "useLiteralContent": false, "bytecodeHash": "ipfs", "appendCBOR": true }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "evmVersion": "paris", "viaIR": false, "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[{"internalType":"address","name":"_bitcorn","type":"address"},{"internalType":"address","name":"_bitcornMinterAsset","type":"address"},{"internalType":"address","name":"_feeRecipient","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"uint256","name":"shares","type":"uint256"},{"internalType":"uint256","name":"oneSatoshiOfBitcornShares","type":"uint256"}],"name":"BelowOneSatoshiOfShares","type":"error"},{"inputs":[{"internalType":"address","name":"bitcornMinterAsset","type":"address"}],"name":"BitcornMinterAssetMustNotBeApprovedToken","type":"error"},{"inputs":[{"internalType":"address","name":"bitcorn","type":"address"}],"name":"BitcornMustNotBeApprovedToken","type":"error"},{"inputs":[],"name":"BridgeIsEnabled","type":"error"},{"inputs":[],"name":"BridgeIsNotSet","type":"error"},{"inputs":[],"name":"BridgeNotEnabled","type":"error"},{"inputs":[{"internalType":"uint256","name":"cachedShares","type":"uint256"},{"internalType":"uint256","name":"requiredShares","type":"uint256"}],"name":"InsufficientBitcornSharesToBridge","type":"error"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"cachedShares","type":"uint256"},{"internalType":"uint256","name":"shares","type":"uint256"}],"name":"InsufficientShares","type":"error"},{"inputs":[{"internalType":"uint256","name":"bitcornShares","type":"uint256"},{"internalType":"uint256","name":"oneSatoshiOfBitcornShares","type":"uint256"}],"name":"SharesNotMultipleOfOneSatoshi","type":"error"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"TokenAlreadyApproved","type":"error"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"TokenNotApproved","type":"error"},{"inputs":[{"internalType":"uint256","name":"fee","type":"uint256"}],"name":"WithdrawalFeeAboveMax","type":"error"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"ZeroDeposit","type":"error"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"ZeroShares","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"ZeroSharesForAnyToken","type":"error"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"ZeroWithdraw","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"previousAdmin","type":"address"},{"indexed":false,"internalType":"address","name":"newAdmin","type":"address"}],"name":"AdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"contract Authority","name":"newAuthority","type":"address"}],"name":"AuthorityUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"beacon","type":"address"}],"name":"BeaconUpgraded","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"gatewayRouter","type":"address"},{"indexed":false,"internalType":"address","name":"swapFacilityVault","type":"address"}],"name":"BridgeEnabled","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"version","type":"uint8"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"address","name":"recipient","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"maxGas","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"gasPriceBid","type":"uint256"},{"indexed":false,"internalType":"bytes","name":"data","type":"bytes"}],"name":"TokenBridged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"assets","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"shares","type":"uint256"}],"name":"TokenDeposited","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"assets","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"shares","type":"uint256"}],"name":"TokenWithdrawn","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"implementation","type":"address"}],"name":"Upgraded","type":"event"},{"inputs":[],"name":"BPS_DIVISOR","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MAX_WITHDRAWAL_FEE_BPS","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ONE_SATOSHI_OF_BITCOIN_SHARES","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"addApprovedToken","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"authority","outputs":[{"internalType":"contract Authority","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"authorityInitialized","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"bitcorn","outputs":[{"internalType":"contract IBitcorn","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"bitcornMinterAsset","outputs":[{"internalType":"contract IERC20Upgradeable","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"cost","type":"uint256"},{"internalType":"uint256","name":"maxGas","type":"uint256"},{"internalType":"uint256","name":"gasPriceBid","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"bridgeAllTokens","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"cost","type":"uint256"},{"internalType":"uint256","name":"maxGas","type":"uint256"},{"internalType":"uint256","name":"gasPriceBid","type":"uint256"}],"name":"bridgeBitcorn","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"maxGas","type":"uint256"},{"internalType":"uint256","name":"gasPriceBid","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"bridgeToken","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"assets","type":"uint256"}],"name":"deposit","outputs":[{"internalType":"uint256","name":"shares","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"assets","type":"uint256"}],"name":"depositFor","outputs":[{"internalType":"uint256","name":"shares","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"gatewayRouter","type":"address"},{"internalType":"address","name":"erc20Inbox","type":"address"},{"internalType":"address","name":"swapFacilityVault","type":"address"}],"name":"enableBridge","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"feeRecipient","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amountIn18Decimals","type":"uint256"}],"name":"from18DecimalsToAssetDecimals","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"fromAssetDecimalsTo18Decimals","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getApprovedTokens","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getERC20Inbox","outputs":[{"internalType":"contract IERC20Inbox","name":"erc20Inbox","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getGatewayRouter","outputs":[{"internalType":"contract IGatewayRouter","name":"gatewayRouter","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getSwapFacilityVault","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_authority","type":"address"},{"internalType":"address[]","name":"_initialApprovedTokens","type":"address[]"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"isBridgeEnabled","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"assets","type":"uint256"}],"name":"mintAndDepositBitcorn","outputs":[{"internalType":"uint256","name":"shares","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"assets","type":"uint256"}],"name":"mintAndDepositBitcornFor","outputs":[{"internalType":"uint256","name":"shares","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"pause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"proxiableUUID","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"redeemAll","outputs":[{"internalType":"address[]","name":"depositedTokens","type":"address[]"},{"internalType":"uint256[]","name":"assets","type":"uint256[]"},{"internalType":"uint256","name":"bitcornShares","type":"uint256"},{"internalType":"uint256","name":"minterAssetReturned","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"shares","type":"uint256"}],"name":"redeemBitcorn","outputs":[{"internalType":"uint256","name":"assets","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"shares","type":"uint256"}],"name":"redeemToken","outputs":[{"internalType":"uint256","name":"assets","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_fee","type":"uint256"}],"name":"setWithdrawalFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"},{"internalType":"address","name":"token","type":"address"}],"name":"sharesOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"to18ConversionFactor","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"totalShares","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"unpause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newImplementation","type":"address"}],"name":"upgradeTo","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newImplementation","type":"address"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"upgradeToAndCall","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"withdrawalFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"}]
Contract Creation Code
6101406040523060805260006101035534801561001b57600080fd5b506040516147dc3803806147dc83398101604081905261003a91610352565b61004261027b565b6002826001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015610082573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906100a69190610395565b60ff16101561010d5760405162461bcd60e51b815260206004820152602860248201527f4d696e74657220746f6b656e206d757374206265206174206c65617374203220604482015267646563696d616c7360c01b60648201526084015b60405180910390fd5b6012826001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa15801561014d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101719190610395565b60ff1611156101d05760405162461bcd60e51b815260206004820152602560248201527f4d696e74657220746f6b656e206d75737420313820646563696d616c73206f72604482015264206c65737360d81b6064820152608401610104565b6001600160a01b0380841660a052821660c08190526040805163313ce56760e01b8152905163313ce567916004808201926020929091908290030181865afa158015610220573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102449190610395565b61024f9060126103d5565b61025d9060ff16600a6104d8565b60e0819052610120526001600160a01b031661010052506104e49050565b600054610100900460ff16156102e35760405162461bcd60e51b815260206004820152602760248201527f496e697469616c697a61626c653a20636f6e747261637420697320696e697469604482015266616c697a696e6760c81b6064820152608401610104565b60005460ff90811614610334576000805460ff191660ff9081179091556040519081527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b565b80516001600160a01b038116811461034d57600080fd5b919050565b60008060006060848603121561036757600080fd5b61037084610336565b925061037e60208501610336565b915061038c60408501610336565b90509250925092565b6000602082840312156103a757600080fd5b815160ff811681146103b857600080fd5b9392505050565b634e487b7160e01b600052601160045260246000fd5b60ff82811682821603908111156103ee576103ee6103bf565b92915050565b600181815b8085111561042f578160001904821115610415576104156103bf565b8085161561042257918102915b93841c93908002906103f9565b509250929050565b600082610446575060016103ee565b81610453575060006103ee565b816001811461046957600281146104735761048f565b60019150506103ee565b60ff841115610484576104846103bf565b50506001821b6103ee565b5060208310610133831016604e8410600b84101617156104b2575081810a6103ee565b6104bc83836103f4565b80600019048211156104d0576104d06103bf565b029392505050565b60006103b88383610437565b60805160a05160c05160e05161010051610120516141596106836000396000818161047d01528181611c3601528181611c8401528181612692015281816126d2015281816127b1015281816127ed0152818161287801526128b80152600081816103e1015281816122260152612a420152600081816103ad015281816107840152610d3d01526000818161029a01528181610f6501528181610fa5015281816112d60152818161132401528181611dd901528181611ff501528181612a200152612a7601526000818161057801528181610cee01528181611353015281816113a1015281816114150152818161179201528181611bc601528181611d5801528181611f5901528181611fc30152818161201f015281816124e8015281816125320152818161262a015281816127390152818161278201528181612838015281816128f70152818161293201528181612a9f01528181612cf601528181612e1a01528181612f5801528181612f8f01526130cb0152600081816108d40152818161091401528181610b4301528181610b830152610c1601526141596000f3fe6080604052600436106102305760003560e01c8063789680f41161012e578063ac1e5025116100ab578063bdafe3511161006f578063bdafe351146106a5578063bf6b874e146106c5578063bf7e214f146106f2578063cd10534b14610710578063ce75d53e1461073057600080fd5b8063ac1e502514610610578063ae52fee514610630578063b3db428b14610650578063b6783edd14610670578063b9d64e9f1461068557600080fd5b80638bcefb6b116100f25780638bcefb6b14610566578063946d92041461059a578063976e89a6146105ba57806397bc1e1b146105cf5780639a1ce881146105ee57600080fd5b8063789680f4146104e5578063830cbbbd146105055780638456cb591461052557806387f0cf2e1461053a5780638bc7e8c41461054f57600080fd5b80633f4ba83a116101bc57806352d1902d1161018057806352d1902d1461043657806355ae90461461044b5780635833b17d1461046b5780635c975abb1461049f5780636afc0c5f146104c357600080fd5b80633f4ba83a146103865780634010f7771461039b57806346904840146103cf57806347e7ef24146104035780634f1ef2861461042357600080fd5b8063191fe1ed11610203578063191fe1ed146102f65780632f4350c21461030c5780633659cfe6146103315780633a76010c146103515780633d1698121461036657600080fd5b80630a7292f514610235578063101ab12c1461026857806313adf30b1461028857806315ec1f6f146102d4575b600080fd5b34801561024157600080fd5b5061025561025036600461382a565b610750565b6040519081526020015b60405180910390f35b34801561027457600080fd5b50610255610283366004613863565b61077d565b34801561029457600080fd5b506102bc7f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b03909116815260200161025f565b3480156102e057600080fd5b506102f46102ef36600461387c565b6107a9565b005b34801561030257600080fd5b5061025561271081565b34801561031857600080fd5b50610321610899565b60405161025f949392919061390c565b34801561033d57600080fd5b506102f461034c36600461396d565b6108ca565b34801561035d57600080fd5b506102bc6109a9565b34801561037257600080fd5b506102f46103813660046139d3565b6109dc565b34801561039257600080fd5b506102f4610a43565b3480156103a757600080fd5b506102557f000000000000000000000000000000000000000000000000000000000000000081565b3480156103db57600080fd5b506102bc7f000000000000000000000000000000000000000000000000000000000000000081565b34801561040f57600080fd5b5061025561041e366004613a46565b610a87565b6102f4610431366004613ae1565b610b39565b34801561044257600080fd5b50610255610c09565b34801561045757600080fd5b50610255610466366004613a46565b610cbd565b34801561047757600080fd5b506102557f000000000000000000000000000000000000000000000000000000000000000081565b3480156104ab57600080fd5b5060975460ff165b604051901515815260200161025f565b3480156104cf57600080fd5b506104d8610d25565b60405161025f9190613b74565b3480156104f157600080fd5b50610255610500366004613863565b610d36565b34801561051157600080fd5b50610255610520366004613a46565b610d62565b34801561053157600080fd5b506102f4610d77565b34801561054657600080fd5b506102bc610db9565b34801561055b57600080fd5b506102556101035481565b34801561057257600080fd5b506102bc7f000000000000000000000000000000000000000000000000000000000000000081565b3480156105a657600080fd5b506102f46105b5366004613b87565b610de4565b3480156105c657600080fd5b506102bc611024565b3480156105db57600080fd5b5060fb54600160a01b900460ff166104b3565b3480156105fa57600080fd5b50610102546104b390600160a01b900460ff1681565b34801561061c57600080fd5b506102f461062b366004613863565b61104f565b34801561063c57600080fd5b506102f461064b366004613c4e565b6110a9565b34801561065c57600080fd5b5061025561066b366004613c89565b61110c565b34801561067c57600080fd5b50610255600081565b34801561069157600080fd5b506102f46106a0366004613cca565b6111c5565b3480156106b157600080fd5b506102556106c0366004613863565b61121a565b3480156106d157600080fd5b506102556106e036600461396d565b60fd6020526000908152604090205481565b3480156106fe57600080fd5b5060fb546001600160a01b03166102bc565b34801561071c57600080fd5b506102f461072b36600461396d565b61123a565b34801561073c57600080fd5b5061025561074b366004613863565b6113e4565b6001600160a01b03808316600090815260fc60209081526040808320938516835292905220545b92915050565b60006107777f000000000000000000000000000000000000000000000000000000000000000083613d3e565b6107b161144c565b61010254600160a01b900460ff16156107dd5760405163078a044560e41b815260040160405180910390fd5b6107f3336000356001600160e01b0319166114a5565b6108185760405162461bcd60e51b815260040161080f90613d55565b60405180910390fd5b61082183611546565b61082a826115c3565b61083381611640565b610102805460ff60a01b1916600160a01b179055604080516001600160a01b038581168252831660208201527f5a86d8337e2ab9b072f4b8e732e04c1ae363e866aaa7e71c92470f4248fda6e5910160405180910390a1610894600160c955565b505050565b6060806000806108a761144c565b6108b0336116c4565b929650909450925090506108c4600160c955565b90919293565b6001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001630036109125760405162461bcd60e51b815260040161080f90613d81565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031661095b6000805160206140dd833981519152546001600160a01b031690565b6001600160a01b0316146109815760405162461bcd60e51b815260040161080f90613dcd565b61098a816118fd565b604080516000808252602082019092526109a69183919061192f565b50565b610102546000906001600160a01b0316806109d75760405163fb28a66360e01b815260040160405180910390fd5b919050565b6109e461144c565b6109ec611a9a565b61010254600160a01b900460ff16610a1757604051631517d53960e11b815260040160405180910390fd5b610a2086611ae0565b9550610a3133878787878787611b18565b610a3b600160c955565b505050505050565b610a59336000356001600160e01b0319166114a5565b610a755760405162461bcd60e51b815260040161080f90613d55565b610a7d611e0d565b610a85611e56565b565b6000610a9161144c565b610a99611a9a565b61010254600160a01b900460ff1615610ac55760405163078a044560e41b815260040160405180910390fd5b81600003610af15760405163d47ecbef60e01b81526001600160a01b038416600482015260240161080f565b610afa83611ea8565b610b22576040516343c90fad60e11b81526001600160a01b038416600482015260240161080f565b610b2d338484611eb5565b9050610777600160c955565b6001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000163003610b815760405162461bcd60e51b815260040161080f90613d81565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316610bca6000805160206140dd833981519152546001600160a01b031690565b6001600160a01b031614610bf05760405162461bcd60e51b815260040161080f90613dcd565b610bf9826118fd565b610c058282600161192f565b5050565b6000306001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001614610ca95760405162461bcd60e51b815260206004820152603860248201527f555550535570677261646561626c653a206d757374206e6f742062652063616c60448201527f6c6564207468726f7567682064656c656761746563616c6c0000000000000000606482015260840161080f565b506000805160206140dd8339815191525b90565b6000610cc761144c565b610ccf611a9a565b81600003610d1b5760405163d47ecbef60e01b81526001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016600482015260240161080f565b610b2d8383611f34565b6060610d3160fe61209a565b905090565b60006107777f000000000000000000000000000000000000000000000000000000000000000083613e2f565b6000610d6c61144c565b610b2d3384846120a7565b610d8d336000356001600160e01b0319166114a5565b610da95760405162461bcd60e51b815260040161080f90613d55565b610db1611a9a565b610a856122c0565b610100546001600160a01b031680610cba5760405163fb28a66360e01b815260040160405180910390fd5b600054610100900460ff1615808015610e045750600054600160ff909116105b80610e1e5750303b158015610e1e575060005460ff166001145b610e815760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b606482015260840161080f565b6000805460ff191660011790558015610ea4576000805461ff0019166101001790555b610eac6122fd565b610eb4612324565b610ebc612353565b6001600160a01b038316610f125760405162461bcd60e51b815260206004820181905260248201527f417574686f726974792063616e6e6f74206265206e756c6c2061646472657373604482015260640161080f565b610f1b83612382565b60005b8251811015610f5d57610f54838281518110610f3c57610f3c613e43565b602002602001015160fe61249390919063ffffffff16565b50600101610f1e565b50610f8960fe7f00000000000000000000000000000000000000000000000000000000000000006124a8565b15610fd25760405163139d04b360e11b81526001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016600482015260240161080f565b610fda6122c0565b8015610894576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a1505050565b610101546001600160a01b031680610cba5760405163fb28a66360e01b815260040160405180910390fd5b611065336000356001600160e01b0319166114a5565b6110815760405162461bcd60e51b815260040161080f90613d55565b80156110a357604051630c68acaf60e11b81526004810182905260240161080f565b61010355565b6110b161144c565b6110b9611a9a565b61010254600160a01b900460ff166110e457604051631517d53960e11b815260040160405180910390fd5b6110ed84611ae0565b93506110fc33858585856124ca565b611106600160c955565b50505050565b600061111661144c565b61111e611a9a565b61010254600160a01b900460ff161561114a5760405163078a044560e41b815260040160405180910390fd5b816000036111765760405163d47ecbef60e01b81526001600160a01b038416600482015260240161080f565b61117f83611ea8565b6111a7576040516343c90fad60e11b81526001600160a01b038416600482015260240161080f565b6111b2848484611eb5565b90506111be600160c955565b9392505050565b6111cd61144c565b6111d5611a9a565b61010254600160a01b900460ff1661120057604051631517d53960e11b815260040160405180910390fd5b61120985611ae0565b9450610a3133878787878787612587565b600061122461144c565b61122e338361271b565b90506109d7600160c955565b61124261144c565b611258336000356001600160e01b0319166114a5565b6112745760405162461bcd60e51b815260040161080f90613d55565b61010254600160a01b900460ff16156112a05760405163078a044560e41b815260040160405180910390fd5b6112ab60fe826124a8565b156112d457604051637664204760e01b81526001600160a01b038216600482015260240161080f565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316816001600160a01b0316036113515760405163139d04b360e11b81526001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016600482015260240161080f565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316816001600160a01b0316036113ce5760405163442b841360e11b81526001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016600482015260240161080f565b6113d960fe82612493565b506109a6600160c955565b60006113ee61144c565b6113f6611a9a565b816000036114425760405163d47ecbef60e01b81526001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016600482015260240161080f565b61122e3383611f34565b600260c9540361149e5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015260640161080f565b600260c955565b60fb546000906001600160a01b0316801580159061153e575060405163b700961360e01b81526001600160a01b0385811660048301523060248301526001600160e01b03198516604483015282169063b700961390606401602060405180830381865afa15801561151a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061153e9190613e59565b949350505050565b6000816001600160a01b03163b116115a05760405162461bcd60e51b815260206004820152601a60248201527f47617465776179526f7574657249734e6f74436f6e7472616374000000000000604482015260640161080f565b61010080546001600160a01b0319166001600160a01b0392909216919091179055565b6000816001600160a01b03163b1161161d5760405162461bcd60e51b815260206004820152601760248201527f4552433230496e626f7849734e6f74436f6e7472616374000000000000000000604482015260640161080f565b61010180546001600160a01b0319166001600160a01b0392909216919091179055565b6000816001600160a01b03163b1161169a5760405162461bcd60e51b815260206004820152601e60248201527f53776170466163696c6974795661756c7449734e6f74436f6e74726163740000604482015260640161080f565b61010280546001600160a01b0319166001600160a01b0392909216919091179055565b600160c955565b6060806000806000806116d5610d25565b9050606060006116e489612b1b565b90955090925090508067ffffffffffffffff81111561170557611705613a72565b60405190808252806020026020018201604052801561172e578160200160208202803683370190505b5097508067ffffffffffffffff81111561174a5761174a613a72565b604051908082528060200260200182016040528015611773578160200160208202803683370190505b506001600160a01b03808b16600090815260fc602090815260408083207f000000000000000000000000000000000000000000000000000000000000000090941683529290522054909750955085156117cb57600193505b836117f4576040516345937bd360e01b81526001600160a01b038a16600482015260240161080f565b851561180757611804898761271b565b94505b6000805b84518110156118f05783818151811061182657611826613e43565b6020026020010151600003156118e85784818151811061184857611848613e43565b60200260200101518a838151811061186257611862613e43565b60200260200101906001600160a01b031690816001600160a01b0316815250506118bf8b86838151811061189857611898613e43565b60200260200101518684815181106118b2576118b2613e43565b60200260200101516120a7565b8983815181106118d1576118d1613e43565b60209081029190910101526118e582613e7b565b91505b60010161180b565b5050505050509193509193565b611913336000356001600160e01b0319166114a5565b6109a65760405162461bcd60e51b815260040161080f90613d55565b7f4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd91435460ff16156119625761089483612c16565b826001600160a01b03166352d1902d6040518163ffffffff1660e01b8152600401602060405180830381865afa9250505080156119bc575060408051601f3d908101601f191682019092526119b991810190613e94565b60015b611a1f5760405162461bcd60e51b815260206004820152602e60248201527f45524331393637557067726164653a206e657720696d706c656d656e7461746960448201526d6f6e206973206e6f74205555505360901b606482015260840161080f565b6000805160206140dd8339815191528114611a8e5760405162461bcd60e51b815260206004820152602960248201527f45524331393637557067726164653a20756e737570706f727465642070726f786044820152681a58589b195555525160ba1b606482015260840161080f565b50610894838383612cb2565b60975460ff1615610a855760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b604482015260640161080f565b60006001600160a01b0382163b15801590611b115773111100000000000000000000000000000000111183016111be565b5090919050565b6000611b22610d25565b90506000815167ffffffffffffffff811115611b4057611b40613a72565b604051908082528060200260200182016040528015611b69578160200160208202803683370190505b509050600080611b788b612b1b565b9194509250905081611ba8576040516345937bd360e01b81526001600160a01b038c16600482015260240161080f565b6001600160a01b03808c16600090815260fc602090815260408083207f00000000000000000000000000000000000000000000000000000000000000009094168352929052908120549082611bfd8a8c613d3e565b611c079190613d3e565b905080821015611c3457604051635d2d8e3960e11b8152600481018390526024810182905260440161080f565b7f0000000000000000000000000000000000000000000000000000000000000000611c5f8a8c613d3e565b611c699190613ead565b15611cb057604051630481813960e21b8152600481018290527f0000000000000000000000000000000000000000000000000000000000000000602482015260440161080f565b505050506000611cbe610db9565b905060005b8351811015611d39576000838281518110611ce057611ce0613e43565b60200260200101511115611d3157611d31848281518110611d0357611d03613e43565b60200260200101518c858481518110611d1e57611d1e613e43565b6020026020010151858e8d8d8d8d612cd7565b600101611cc3565b506001600160a01b03808b16600090815260fc602090815260408083207f0000000000000000000000000000000000000000000000000000000000000000909416835292905220548015801590611da25750611d958789613d3e565b611d9f908a613ec1565b81115b15611e0057611db58b8a838d8c8c612f46565b61010254611e00906001600160a01b0316611dcf83610d36565b6001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169190613122565b5050505050505050505050565b60975460ff16610a855760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b604482015260640161080f565b611e5e611e0d565b6097805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b600061077760fe836124a8565b6000611ec2848484613185565b611ed76001600160a01b038416333085613215565b826001600160a01b0316846001600160a01b03167f080c225c8e9d9f966820ef915f5f555d575e9c3a188f1252d19e94aa2250f09d8485604051611f25929190918252602082015260400190565b60405180910390a35092915050565b600080611f408361077d565b60405163140e25ad60e31b8152600481018290529091507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169063a0712d6890602401600060405180830381600087803b158015611fa557600080fd5b505af1158015611fb9573d6000803e3d6000fd5b50505050611fe8847f000000000000000000000000000000000000000000000000000000000000000083613185565b61201d6001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016333086613215565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316846001600160a01b03167f080c225c8e9d9f966820ef915f5f555d575e9c3a188f1252d19e94aa2250f09d858460405161208b929190918252602082015260400190565b60405180910390a39392505050565b606060006111be8361324d565b60006120b283611ea8565b6120da576040516343c90fad60e11b81526001600160a01b038416600482015260240161080f565b8160000361210657604051639eea385960e01b81526001600160a01b038416600482015260240161080f565b6001600160a01b03808516600090815260fc602090815260408083209387168352929052908120549081900361215a5760405163e1fee18560e01b81526001600160a01b038516600482015260240161080f565b82811015612194576040516368b65f1160e01b81526001600160a01b0385166004820152602481018290526044810184905260640161080f565b826121a08686836132a9565b60975460ff161580156121b65750600061010354115b1561224d57600061271061010354836121cf9190613d3e565b6121d99190613e2f565b9050600061271061010354846121ef9190613d3e565b6121f99190613ead565b111561220b5761220881613e7b565b90505b6122158183613ed4565b915061224b6001600160a01b0387167f000000000000000000000000000000000000000000000000000000000000000083613122565b505b6122616001600160a01b0386168783613122565b846001600160a01b0316866001600160a01b03167f7a163cc3488948c84f02deddd608c9465235f04837413e5f1051007d0da746d283876040516122af929190918252602082015260400190565b60405180910390a395945050505050565b6122c8611a9a565b6097805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258611e8b3390565b600054610100900460ff16610a855760405162461bcd60e51b815260040161080f90613ee7565b600054610100900460ff1661234b5760405162461bcd60e51b815260040161080f90613ee7565b610a85613318565b600054610100900460ff1661237a5760405162461bcd60e51b815260040161080f90613ee7565b610a8561334b565b60fb546001600160a01b0316156123db5760405162461bcd60e51b815260206004820152601b60248201527f417574683a20617574686f72697479206973206e6f6e2d7a65726f0000000000604482015260640161080f565b60fb54600160a01b900460ff16156124415760405162461bcd60e51b815260206004820152602360248201527f417574683a20617574686f7269747920616c726561647920696e697469616c696044820152621e995960ea1b606482015260840161080f565b60fb80546001600160a81b0319166001600160a01b038316908117600160a01b1790915560405130907fa3396fd7f6e0a21b50e5089d2da70d5ac0a3bbbd1f617a93f134b7638998019890600090a350565b60006111be836001600160a01b038416613372565b6001600160a01b038116600090815260018301602052604081205415156111be565b6001600160a01b03808616600090815260fc602090815260408083207f00000000000000000000000000000000000000000000000000000000000000009094168352929052908120549081900361255f5760405163e1fee18560e01b81526001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016600482015260240161080f565b61256d868583888787612f46565b61010254610a3b906001600160a01b0316611dcf83610d36565b61259086611ea8565b6125b8576040516343c90fad60e11b81526001600160a01b038716600482015260240161080f565b6001600160a01b03808816600090815260fc60209081526040808320938a168352929052908120549081900361260c5760405163e1fee18560e01b81526001600160a01b038816600482015260240161080f565b6001600160a01b03808916600090815260fc602090815260408083207f0000000000000000000000000000000000000000000000000000000000000000909416835292905290812054906126608688613d3e565b90508082101561268d57604051635d2d8e3960e11b8152600481018390526024810182905260440161080f565b6126b77f000000000000000000000000000000000000000000000000000000000000000082613ead565b156126fe57604051630481813960e21b8152600481018290527f0000000000000000000000000000000000000000000000000000000000000000602482015260440161080f565b6000612708610db9565b9050611e008a8c86848d8d8d8d8d612cd7565b6001600160a01b03808316600090815260fc602090815260408083207f00000000000000000000000000000000000000000000000000000000000000009094168352929052908120548282036127af57604051639eea385960e01b81526001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016600482015260240161080f565b7f000000000000000000000000000000000000000000000000000000000000000083101561281957604051634015e6cd60e11b8152600481018490527f0000000000000000000000000000000000000000000000000000000000000000602482015260440161080f565b82811015612873576040516368b65f1160e01b81526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000166004820152602481018290526044810184905260640161080f565b61289d7f000000000000000000000000000000000000000000000000000000000000000084613ead565b156128e457604051630481813960e21b8152600481018490527f0000000000000000000000000000000000000000000000000000000000000000602482015260440161080f565b60006128ef84610d36565b905061291c857f0000000000000000000000000000000000000000000000000000000000000000866132a9565b604051630852cd8d60e31b8152600481018590527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906342966c6890602401600060405180830381600087803b15801561297e57600080fd5b505af1158015612992573d6000803e3d6000fd5b505050506129a260975460ff1690565b1580156129b25750600061010354115b15612a6957600061271061010354836129cb9190613d3e565b6129d59190613e2f565b9050600061271061010354846129eb9190613d3e565b6129f59190613ead565b1115612a0757612a0481613e7b565b90505b612a118183613ed4565b9150612a676001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000167f000000000000000000000000000000000000000000000000000000000000000083613122565b505b612a9d6001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000168683613122565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316856001600160a01b03167f7a163cc3488948c84f02deddd608c9465235f04837413e5f1051007d0da746d28387604051612b0b929190918252602082015260400190565b60405180910390a3949350505050565b60606000806000612b2a610d25565b9050805167ffffffffffffffff811115612b4657612b46613a72565b604051908082528060200260200182016040528015612b6f578160200160208202803683370190505b509350600092506000915060005b8151811015612c0d576000828281518110612b9a57612b9a613e43565b6020908102919091018101516001600160a01b03808a16600090815260fc84526040808220928416825291909352909120549091508015612c035780878481518110612be857612be8613e43565b602090810291909101015260019550612c0085613e7b565b94505b5050600101612b7d565b50509193909250565b6001600160a01b0381163b612c835760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b606482015260840161080f565b6000805160206140dd83398151915280546001600160a01b0319166001600160a01b0392909216919091179055565b612cbb836133c1565b600082511180612cc85750805b15610894576111068383613401565b6000612ce38486613d3e565b9050612cf0898b8a6132a9565b612d1b897f0000000000000000000000000000000000000000000000000000000000000000836132a9565b604051635ed004ff60e11b81526001600160a01b038b81166004830152612d9b919089169063bda009fe90602401602060405180830381865afa158015612d66573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612d8a9190613f32565b6001600160a01b038c16908a613426565b8015612e4157604051635ed004ff60e11b81526001600160a01b038b81166004830152612e41919089169063bda009fe90602401602060405180830381865afa158015612dec573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612e109190613f32565b6001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169083613426565b604051634fb1a07b60e01b81526001600160a01b03881690634fb1a07b90612e7b908d908a9081908e908c908c908c908c90600401613f78565b6000604051808303816000875af1158015612e9a573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052612ec29190810190613ff0565b50856001600160a01b0316896001600160a01b03168b6001600160a01b03167f4107daeebc39f62a9bcf7cba4f17fd343890688372f1aaeb5815ca1a215c929a8b89898989604051612f18959493929190614067565b60405180910390a461010254612f3a906001600160a01b0316611dcf83610d36565b50505050505050505050565b6000612f50611024565b9050612f7d877f0000000000000000000000000000000000000000000000000000000000000000876132a9565b61010154612fb8906001600160a01b037f00000000000000000000000000000000000000000000000000000000000000008116911687613426565b6001600160a01b03811663b9b9a68885612fd28587613d3e565b612fdc908a613ec1565b612fe69089613ed4565b6040516001600160e01b031960e085901b1681526001600160a01b0392831660048201526024810191909152604481018a905290871660648201819052608482015260a4810186905260c4810185905260e481018890526101206101048201526000610124820152610144016020604051808303816000875af1158015613071573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906130959190613e94565b5060408051868152602081018590529081018390526080606082018190526000908201526001600160a01b0380861691898216917f000000000000000000000000000000000000000000000000000000000000000016907f4107daeebc39f62a9bcf7cba4f17fd343890688372f1aaeb5815ca1a215c929a9060a00160405180910390a450505050505050565b6040516001600160a01b03831660248201526044810182905261089490849063a9059cbb60e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b03199093169290921790915261353b565b6001600160a01b03808416600090815260fc60209081526040808320938616835292905220546131b6908290613ec1565b6001600160a01b03808516600090815260fc6020908152604080832093871683529281528282209390935560fd9092529020546131f4908290613ec1565b6001600160a01b03909216600090815260fd60205260409020919091555050565b6040516001600160a01b03808516602483015283166044820152606481018290526111069085906323b872dd60e01b9060840161314e565b60608160000180548060200260200160405190810160405280929190818152602001828054801561329d57602002820191906000526020600020905b815481526020019060010190808311613289575b50505050509050919050565b6001600160a01b03808416600090815260fc60209081526040808320938616835292905220546132da908290613ed4565b6001600160a01b03808516600090815260fc6020908152604080832093871683529281528282209390935560fd9092529020546131f4908290613ed4565b600054610100900460ff1661333f5760405162461bcd60e51b815260040161080f90613ee7565b6097805460ff19169055565b600054610100900460ff166116bd5760405162461bcd60e51b815260040161080f90613ee7565b60008181526001830160205260408120546133b957508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610777565b506000610777565b6133ca81612c16565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b60606111be83836040518060600160405280602781526020016140fd60279139613610565b8015806134a05750604051636eb1769f60e11b81523060048201526001600160a01b03838116602483015284169063dd62ed3e90604401602060405180830381865afa15801561347a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061349e9190613e94565b155b61350b5760405162461bcd60e51b815260206004820152603660248201527f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60448201527520746f206e6f6e2d7a65726f20616c6c6f77616e636560501b606482015260840161080f565b6040516001600160a01b03831660248201526044810182905261089490849063095ea7b360e01b9060640161314e565b6000613590826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166136889092919063ffffffff16565b90508051600014806135b15750808060200190518101906135b19190613e59565b6108945760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b606482015260840161080f565b6060600080856001600160a01b03168560405161362d919061408d565b600060405180830381855af49150503d8060008114613668576040519150601f19603f3d011682016040523d82523d6000602084013e61366d565b606091505b509150915061367e86838387613697565b9695505050505050565b606061153e8484600085613710565b606083156137065782516000036136ff576001600160a01b0385163b6136ff5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015260640161080f565b508161153e565b61153e83836137eb565b6060824710156137715760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b606482015260840161080f565b600080866001600160a01b0316858760405161378d919061408d565b60006040518083038185875af1925050503d80600081146137ca576040519150601f19603f3d011682016040523d82523d6000602084013e6137cf565b606091505b50915091506137e087838387613697565b979650505050505050565b8151156137fb5781518083602001fd5b8060405162461bcd60e51b815260040161080f91906140a9565b6001600160a01b03811681146109a657600080fd5b6000806040838503121561383d57600080fd5b823561384881613815565b9150602083013561385881613815565b809150509250929050565b60006020828403121561387557600080fd5b5035919050565b60008060006060848603121561389157600080fd5b833561389c81613815565b925060208401356138ac81613815565b915060408401356138bc81613815565b809150509250925092565b60008151808452602080850194506020840160005b838110156139015781516001600160a01b0316875295820195908201906001016138dc565b509495945050505050565b60808152600061391f60808301876138c7565b82810360208481019190915286518083528782019282019060005b818110156139565784518352938301939183019160010161393a565b505060408501969096525050506060015292915050565b60006020828403121561397f57600080fd5b81356111be81613815565b60008083601f84011261399c57600080fd5b50813567ffffffffffffffff8111156139b457600080fd5b6020830191508360208285010111156139cc57600080fd5b9250929050565b60008060008060008060a087890312156139ec57600080fd5b86356139f781613815565b9550602087013594506040870135935060608701359250608087013567ffffffffffffffff811115613a2857600080fd5b613a3489828a0161398a565b979a9699509497509295939492505050565b60008060408385031215613a5957600080fd5b8235613a6481613815565b946020939093013593505050565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff81118282101715613ab157613ab1613a72565b604052919050565b600067ffffffffffffffff821115613ad357613ad3613a72565b50601f01601f191660200190565b60008060408385031215613af457600080fd5b8235613aff81613815565b9150602083013567ffffffffffffffff811115613b1b57600080fd5b8301601f81018513613b2c57600080fd5b8035613b3f613b3a82613ab9565b613a88565b818152866020838501011115613b5457600080fd5b816020840160208301376000602083830101528093505050509250929050565b6020815260006111be60208301846138c7565b60008060408385031215613b9a57600080fd5b8235613ba581613815565b915060208381013567ffffffffffffffff80821115613bc357600080fd5b818601915086601f830112613bd757600080fd5b813581811115613be957613be9613a72565b8060051b9150613bfa848301613a88565b8181529183018401918481019089841115613c1457600080fd5b938501935b83851015613c3e5784359250613c2e83613815565b8282529385019390850190613c19565b8096505050505050509250929050565b60008060008060808587031215613c6457600080fd5b8435613c6f81613815565b966020860135965060408601359560600135945092505050565b600080600060608486031215613c9e57600080fd5b8335613ca981613815565b92506020840135613cb981613815565b929592945050506040919091013590565b60008060008060008060a08789031215613ce357600080fd5b8635613cee81613815565b95506020870135613cfe81613815565b94506040870135935060608701359250608087013567ffffffffffffffff811115613a2857600080fd5b634e487b7160e01b600052601160045260246000fd5b808202811582820484141761077757610777613d28565b602080825260129082015271105d5d1a0e8815539055551213d49256915160721b604082015260600190565b6020808252602c908201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060408201526b19195b1959d85d1958d85b1b60a21b606082015260800190565b6020808252602c908201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060408201526b6163746976652070726f787960a01b606082015260800190565b634e487b7160e01b600052601260045260246000fd5b600082613e3e57613e3e613e19565b500490565b634e487b7160e01b600052603260045260246000fd5b600060208284031215613e6b57600080fd5b815180151581146111be57600080fd5b600060018201613e8d57613e8d613d28565b5060010190565b600060208284031215613ea657600080fd5b5051919050565b600082613ebc57613ebc613e19565b500690565b8082018082111561077757610777613d28565b8181038181111561077757610777613d28565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b600060208284031215613f4457600080fd5b81516111be81613815565b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b600060018060a01b03808b168352808a1660208401528089166040840152508660608301528560808301528460a083015260e060c0830152613fbe60e083018486613f4f565b9a9950505050505050505050565b60005b83811015613fe7578181015183820152602001613fcf565b50506000910152565b60006020828403121561400257600080fd5b815167ffffffffffffffff81111561401957600080fd5b8201601f8101841361402a57600080fd5b8051614038613b3a82613ab9565b81815285602083850101111561404d57600080fd5b61405e826020830160208601613fcc565b95945050505050565b8581528460208201528360408201526080606082015260006137e0608083018486613f4f565b6000825161409f818460208701613fcc565b9190910192915050565b60208152600082518060208401526140c8816040850160208701613fcc565b601f01601f1916919091016040019291505056fe360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220b62401ae009b59e687b18a3365b0b3659414a7b391ddb9e53190645a9d94dc8864736f6c6343000819003300000000000000000000000039eb270155c78cbe8cdad4050fd8b8512f806a210000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c599000000000000000000000000d437fc63d8e4a0cb5c3d086fee5033a53c6eefe3
Deployed Bytecode
0x6080604052600436106102305760003560e01c8063789680f41161012e578063ac1e5025116100ab578063bdafe3511161006f578063bdafe351146106a5578063bf6b874e146106c5578063bf7e214f146106f2578063cd10534b14610710578063ce75d53e1461073057600080fd5b8063ac1e502514610610578063ae52fee514610630578063b3db428b14610650578063b6783edd14610670578063b9d64e9f1461068557600080fd5b80638bcefb6b116100f25780638bcefb6b14610566578063946d92041461059a578063976e89a6146105ba57806397bc1e1b146105cf5780639a1ce881146105ee57600080fd5b8063789680f4146104e5578063830cbbbd146105055780638456cb591461052557806387f0cf2e1461053a5780638bc7e8c41461054f57600080fd5b80633f4ba83a116101bc57806352d1902d1161018057806352d1902d1461043657806355ae90461461044b5780635833b17d1461046b5780635c975abb1461049f5780636afc0c5f146104c357600080fd5b80633f4ba83a146103865780634010f7771461039b57806346904840146103cf57806347e7ef24146104035780634f1ef2861461042357600080fd5b8063191fe1ed11610203578063191fe1ed146102f65780632f4350c21461030c5780633659cfe6146103315780633a76010c146103515780633d1698121461036657600080fd5b80630a7292f514610235578063101ab12c1461026857806313adf30b1461028857806315ec1f6f146102d4575b600080fd5b34801561024157600080fd5b5061025561025036600461382a565b610750565b6040519081526020015b60405180910390f35b34801561027457600080fd5b50610255610283366004613863565b61077d565b34801561029457600080fd5b506102bc7f0000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c59981565b6040516001600160a01b03909116815260200161025f565b3480156102e057600080fd5b506102f46102ef36600461387c565b6107a9565b005b34801561030257600080fd5b5061025561271081565b34801561031857600080fd5b50610321610899565b60405161025f949392919061390c565b34801561033d57600080fd5b506102f461034c36600461396d565b6108ca565b34801561035d57600080fd5b506102bc6109a9565b34801561037257600080fd5b506102f46103813660046139d3565b6109dc565b34801561039257600080fd5b506102f4610a43565b3480156103a757600080fd5b506102557f00000000000000000000000000000000000000000000000000000002540be40081565b3480156103db57600080fd5b506102bc7f000000000000000000000000d437fc63d8e4a0cb5c3d086fee5033a53c6eefe381565b34801561040f57600080fd5b5061025561041e366004613a46565b610a87565b6102f4610431366004613ae1565b610b39565b34801561044257600080fd5b50610255610c09565b34801561045757600080fd5b50610255610466366004613a46565b610cbd565b34801561047757600080fd5b506102557f00000000000000000000000000000000000000000000000000000002540be40081565b3480156104ab57600080fd5b5060975460ff165b604051901515815260200161025f565b3480156104cf57600080fd5b506104d8610d25565b60405161025f9190613b74565b3480156104f157600080fd5b50610255610500366004613863565b610d36565b34801561051157600080fd5b50610255610520366004613a46565b610d62565b34801561053157600080fd5b506102f4610d77565b34801561054657600080fd5b506102bc610db9565b34801561055b57600080fd5b506102556101035481565b34801561057257600080fd5b506102bc7f00000000000000000000000039eb270155c78cbe8cdad4050fd8b8512f806a2181565b3480156105a657600080fd5b506102f46105b5366004613b87565b610de4565b3480156105c657600080fd5b506102bc611024565b3480156105db57600080fd5b5060fb54600160a01b900460ff166104b3565b3480156105fa57600080fd5b50610102546104b390600160a01b900460ff1681565b34801561061c57600080fd5b506102f461062b366004613863565b61104f565b34801561063c57600080fd5b506102f461064b366004613c4e565b6110a9565b34801561065c57600080fd5b5061025561066b366004613c89565b61110c565b34801561067c57600080fd5b50610255600081565b34801561069157600080fd5b506102f46106a0366004613cca565b6111c5565b3480156106b157600080fd5b506102556106c0366004613863565b61121a565b3480156106d157600080fd5b506102556106e036600461396d565b60fd6020526000908152604090205481565b3480156106fe57600080fd5b5060fb546001600160a01b03166102bc565b34801561071c57600080fd5b506102f461072b36600461396d565b61123a565b34801561073c57600080fd5b5061025561074b366004613863565b6113e4565b6001600160a01b03808316600090815260fc60209081526040808320938516835292905220545b92915050565b60006107777f00000000000000000000000000000000000000000000000000000002540be40083613d3e565b6107b161144c565b61010254600160a01b900460ff16156107dd5760405163078a044560e41b815260040160405180910390fd5b6107f3336000356001600160e01b0319166114a5565b6108185760405162461bcd60e51b815260040161080f90613d55565b60405180910390fd5b61082183611546565b61082a826115c3565b61083381611640565b610102805460ff60a01b1916600160a01b179055604080516001600160a01b038581168252831660208201527f5a86d8337e2ab9b072f4b8e732e04c1ae363e866aaa7e71c92470f4248fda6e5910160405180910390a1610894600160c955565b505050565b6060806000806108a761144c565b6108b0336116c4565b929650909450925090506108c4600160c955565b90919293565b6001600160a01b037f000000000000000000000000b1ffce57cac2fd215276037ace92ee1fd1f6a4a71630036109125760405162461bcd60e51b815260040161080f90613d81565b7f000000000000000000000000b1ffce57cac2fd215276037ace92ee1fd1f6a4a76001600160a01b031661095b6000805160206140dd833981519152546001600160a01b031690565b6001600160a01b0316146109815760405162461bcd60e51b815260040161080f90613dcd565b61098a816118fd565b604080516000808252602082019092526109a69183919061192f565b50565b610102546000906001600160a01b0316806109d75760405163fb28a66360e01b815260040160405180910390fd5b919050565b6109e461144c565b6109ec611a9a565b61010254600160a01b900460ff16610a1757604051631517d53960e11b815260040160405180910390fd5b610a2086611ae0565b9550610a3133878787878787611b18565b610a3b600160c955565b505050505050565b610a59336000356001600160e01b0319166114a5565b610a755760405162461bcd60e51b815260040161080f90613d55565b610a7d611e0d565b610a85611e56565b565b6000610a9161144c565b610a99611a9a565b61010254600160a01b900460ff1615610ac55760405163078a044560e41b815260040160405180910390fd5b81600003610af15760405163d47ecbef60e01b81526001600160a01b038416600482015260240161080f565b610afa83611ea8565b610b22576040516343c90fad60e11b81526001600160a01b038416600482015260240161080f565b610b2d338484611eb5565b9050610777600160c955565b6001600160a01b037f000000000000000000000000b1ffce57cac2fd215276037ace92ee1fd1f6a4a7163003610b815760405162461bcd60e51b815260040161080f90613d81565b7f000000000000000000000000b1ffce57cac2fd215276037ace92ee1fd1f6a4a76001600160a01b0316610bca6000805160206140dd833981519152546001600160a01b031690565b6001600160a01b031614610bf05760405162461bcd60e51b815260040161080f90613dcd565b610bf9826118fd565b610c058282600161192f565b5050565b6000306001600160a01b037f000000000000000000000000b1ffce57cac2fd215276037ace92ee1fd1f6a4a71614610ca95760405162461bcd60e51b815260206004820152603860248201527f555550535570677261646561626c653a206d757374206e6f742062652063616c60448201527f6c6564207468726f7567682064656c656761746563616c6c0000000000000000606482015260840161080f565b506000805160206140dd8339815191525b90565b6000610cc761144c565b610ccf611a9a565b81600003610d1b5760405163d47ecbef60e01b81526001600160a01b037f00000000000000000000000039eb270155c78cbe8cdad4050fd8b8512f806a2116600482015260240161080f565b610b2d8383611f34565b6060610d3160fe61209a565b905090565b60006107777f00000000000000000000000000000000000000000000000000000002540be40083613e2f565b6000610d6c61144c565b610b2d3384846120a7565b610d8d336000356001600160e01b0319166114a5565b610da95760405162461bcd60e51b815260040161080f90613d55565b610db1611a9a565b610a856122c0565b610100546001600160a01b031680610cba5760405163fb28a66360e01b815260040160405180910390fd5b600054610100900460ff1615808015610e045750600054600160ff909116105b80610e1e5750303b158015610e1e575060005460ff166001145b610e815760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b606482015260840161080f565b6000805460ff191660011790558015610ea4576000805461ff0019166101001790555b610eac6122fd565b610eb4612324565b610ebc612353565b6001600160a01b038316610f125760405162461bcd60e51b815260206004820181905260248201527f417574686f726974792063616e6e6f74206265206e756c6c2061646472657373604482015260640161080f565b610f1b83612382565b60005b8251811015610f5d57610f54838281518110610f3c57610f3c613e43565b602002602001015160fe61249390919063ffffffff16565b50600101610f1e565b50610f8960fe7f0000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c5996124a8565b15610fd25760405163139d04b360e11b81526001600160a01b037f0000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c59916600482015260240161080f565b610fda6122c0565b8015610894576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a1505050565b610101546001600160a01b031680610cba5760405163fb28a66360e01b815260040160405180910390fd5b611065336000356001600160e01b0319166114a5565b6110815760405162461bcd60e51b815260040161080f90613d55565b80156110a357604051630c68acaf60e11b81526004810182905260240161080f565b61010355565b6110b161144c565b6110b9611a9a565b61010254600160a01b900460ff166110e457604051631517d53960e11b815260040160405180910390fd5b6110ed84611ae0565b93506110fc33858585856124ca565b611106600160c955565b50505050565b600061111661144c565b61111e611a9a565b61010254600160a01b900460ff161561114a5760405163078a044560e41b815260040160405180910390fd5b816000036111765760405163d47ecbef60e01b81526001600160a01b038416600482015260240161080f565b61117f83611ea8565b6111a7576040516343c90fad60e11b81526001600160a01b038416600482015260240161080f565b6111b2848484611eb5565b90506111be600160c955565b9392505050565b6111cd61144c565b6111d5611a9a565b61010254600160a01b900460ff1661120057604051631517d53960e11b815260040160405180910390fd5b61120985611ae0565b9450610a3133878787878787612587565b600061122461144c565b61122e338361271b565b90506109d7600160c955565b61124261144c565b611258336000356001600160e01b0319166114a5565b6112745760405162461bcd60e51b815260040161080f90613d55565b61010254600160a01b900460ff16156112a05760405163078a044560e41b815260040160405180910390fd5b6112ab60fe826124a8565b156112d457604051637664204760e01b81526001600160a01b038216600482015260240161080f565b7f0000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c5996001600160a01b0316816001600160a01b0316036113515760405163139d04b360e11b81526001600160a01b037f0000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c59916600482015260240161080f565b7f00000000000000000000000039eb270155c78cbe8cdad4050fd8b8512f806a216001600160a01b0316816001600160a01b0316036113ce5760405163442b841360e11b81526001600160a01b037f00000000000000000000000039eb270155c78cbe8cdad4050fd8b8512f806a2116600482015260240161080f565b6113d960fe82612493565b506109a6600160c955565b60006113ee61144c565b6113f6611a9a565b816000036114425760405163d47ecbef60e01b81526001600160a01b037f00000000000000000000000039eb270155c78cbe8cdad4050fd8b8512f806a2116600482015260240161080f565b61122e3383611f34565b600260c9540361149e5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015260640161080f565b600260c955565b60fb546000906001600160a01b0316801580159061153e575060405163b700961360e01b81526001600160a01b0385811660048301523060248301526001600160e01b03198516604483015282169063b700961390606401602060405180830381865afa15801561151a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061153e9190613e59565b949350505050565b6000816001600160a01b03163b116115a05760405162461bcd60e51b815260206004820152601a60248201527f47617465776179526f7574657249734e6f74436f6e7472616374000000000000604482015260640161080f565b61010080546001600160a01b0319166001600160a01b0392909216919091179055565b6000816001600160a01b03163b1161161d5760405162461bcd60e51b815260206004820152601760248201527f4552433230496e626f7849734e6f74436f6e7472616374000000000000000000604482015260640161080f565b61010180546001600160a01b0319166001600160a01b0392909216919091179055565b6000816001600160a01b03163b1161169a5760405162461bcd60e51b815260206004820152601e60248201527f53776170466163696c6974795661756c7449734e6f74436f6e74726163740000604482015260640161080f565b61010280546001600160a01b0319166001600160a01b0392909216919091179055565b600160c955565b6060806000806000806116d5610d25565b9050606060006116e489612b1b565b90955090925090508067ffffffffffffffff81111561170557611705613a72565b60405190808252806020026020018201604052801561172e578160200160208202803683370190505b5097508067ffffffffffffffff81111561174a5761174a613a72565b604051908082528060200260200182016040528015611773578160200160208202803683370190505b506001600160a01b03808b16600090815260fc602090815260408083207f00000000000000000000000039eb270155c78cbe8cdad4050fd8b8512f806a2190941683529290522054909750955085156117cb57600193505b836117f4576040516345937bd360e01b81526001600160a01b038a16600482015260240161080f565b851561180757611804898761271b565b94505b6000805b84518110156118f05783818151811061182657611826613e43565b6020026020010151600003156118e85784818151811061184857611848613e43565b60200260200101518a838151811061186257611862613e43565b60200260200101906001600160a01b031690816001600160a01b0316815250506118bf8b86838151811061189857611898613e43565b60200260200101518684815181106118b2576118b2613e43565b60200260200101516120a7565b8983815181106118d1576118d1613e43565b60209081029190910101526118e582613e7b565b91505b60010161180b565b5050505050509193509193565b611913336000356001600160e01b0319166114a5565b6109a65760405162461bcd60e51b815260040161080f90613d55565b7f4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd91435460ff16156119625761089483612c16565b826001600160a01b03166352d1902d6040518163ffffffff1660e01b8152600401602060405180830381865afa9250505080156119bc575060408051601f3d908101601f191682019092526119b991810190613e94565b60015b611a1f5760405162461bcd60e51b815260206004820152602e60248201527f45524331393637557067726164653a206e657720696d706c656d656e7461746960448201526d6f6e206973206e6f74205555505360901b606482015260840161080f565b6000805160206140dd8339815191528114611a8e5760405162461bcd60e51b815260206004820152602960248201527f45524331393637557067726164653a20756e737570706f727465642070726f786044820152681a58589b195555525160ba1b606482015260840161080f565b50610894838383612cb2565b60975460ff1615610a855760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b604482015260640161080f565b60006001600160a01b0382163b15801590611b115773111100000000000000000000000000000000111183016111be565b5090919050565b6000611b22610d25565b90506000815167ffffffffffffffff811115611b4057611b40613a72565b604051908082528060200260200182016040528015611b69578160200160208202803683370190505b509050600080611b788b612b1b565b9194509250905081611ba8576040516345937bd360e01b81526001600160a01b038c16600482015260240161080f565b6001600160a01b03808c16600090815260fc602090815260408083207f00000000000000000000000039eb270155c78cbe8cdad4050fd8b8512f806a219094168352929052908120549082611bfd8a8c613d3e565b611c079190613d3e565b905080821015611c3457604051635d2d8e3960e11b8152600481018390526024810182905260440161080f565b7f00000000000000000000000000000000000000000000000000000002540be400611c5f8a8c613d3e565b611c699190613ead565b15611cb057604051630481813960e21b8152600481018290527f00000000000000000000000000000000000000000000000000000002540be400602482015260440161080f565b505050506000611cbe610db9565b905060005b8351811015611d39576000838281518110611ce057611ce0613e43565b60200260200101511115611d3157611d31848281518110611d0357611d03613e43565b60200260200101518c858481518110611d1e57611d1e613e43565b6020026020010151858e8d8d8d8d612cd7565b600101611cc3565b506001600160a01b03808b16600090815260fc602090815260408083207f00000000000000000000000039eb270155c78cbe8cdad4050fd8b8512f806a21909416835292905220548015801590611da25750611d958789613d3e565b611d9f908a613ec1565b81115b15611e0057611db58b8a838d8c8c612f46565b61010254611e00906001600160a01b0316611dcf83610d36565b6001600160a01b037f0000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c599169190613122565b5050505050505050505050565b60975460ff16610a855760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b604482015260640161080f565b611e5e611e0d565b6097805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b600061077760fe836124a8565b6000611ec2848484613185565b611ed76001600160a01b038416333085613215565b826001600160a01b0316846001600160a01b03167f080c225c8e9d9f966820ef915f5f555d575e9c3a188f1252d19e94aa2250f09d8485604051611f25929190918252602082015260400190565b60405180910390a35092915050565b600080611f408361077d565b60405163140e25ad60e31b8152600481018290529091507f00000000000000000000000039eb270155c78cbe8cdad4050fd8b8512f806a216001600160a01b03169063a0712d6890602401600060405180830381600087803b158015611fa557600080fd5b505af1158015611fb9573d6000803e3d6000fd5b50505050611fe8847f00000000000000000000000039eb270155c78cbe8cdad4050fd8b8512f806a2183613185565b61201d6001600160a01b037f0000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c59916333086613215565b7f00000000000000000000000039eb270155c78cbe8cdad4050fd8b8512f806a216001600160a01b0316846001600160a01b03167f080c225c8e9d9f966820ef915f5f555d575e9c3a188f1252d19e94aa2250f09d858460405161208b929190918252602082015260400190565b60405180910390a39392505050565b606060006111be8361324d565b60006120b283611ea8565b6120da576040516343c90fad60e11b81526001600160a01b038416600482015260240161080f565b8160000361210657604051639eea385960e01b81526001600160a01b038416600482015260240161080f565b6001600160a01b03808516600090815260fc602090815260408083209387168352929052908120549081900361215a5760405163e1fee18560e01b81526001600160a01b038516600482015260240161080f565b82811015612194576040516368b65f1160e01b81526001600160a01b0385166004820152602481018290526044810184905260640161080f565b826121a08686836132a9565b60975460ff161580156121b65750600061010354115b1561224d57600061271061010354836121cf9190613d3e565b6121d99190613e2f565b9050600061271061010354846121ef9190613d3e565b6121f99190613ead565b111561220b5761220881613e7b565b90505b6122158183613ed4565b915061224b6001600160a01b0387167f000000000000000000000000d437fc63d8e4a0cb5c3d086fee5033a53c6eefe383613122565b505b6122616001600160a01b0386168783613122565b846001600160a01b0316866001600160a01b03167f7a163cc3488948c84f02deddd608c9465235f04837413e5f1051007d0da746d283876040516122af929190918252602082015260400190565b60405180910390a395945050505050565b6122c8611a9a565b6097805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258611e8b3390565b600054610100900460ff16610a855760405162461bcd60e51b815260040161080f90613ee7565b600054610100900460ff1661234b5760405162461bcd60e51b815260040161080f90613ee7565b610a85613318565b600054610100900460ff1661237a5760405162461bcd60e51b815260040161080f90613ee7565b610a8561334b565b60fb546001600160a01b0316156123db5760405162461bcd60e51b815260206004820152601b60248201527f417574683a20617574686f72697479206973206e6f6e2d7a65726f0000000000604482015260640161080f565b60fb54600160a01b900460ff16156124415760405162461bcd60e51b815260206004820152602360248201527f417574683a20617574686f7269747920616c726561647920696e697469616c696044820152621e995960ea1b606482015260840161080f565b60fb80546001600160a81b0319166001600160a01b038316908117600160a01b1790915560405130907fa3396fd7f6e0a21b50e5089d2da70d5ac0a3bbbd1f617a93f134b7638998019890600090a350565b60006111be836001600160a01b038416613372565b6001600160a01b038116600090815260018301602052604081205415156111be565b6001600160a01b03808616600090815260fc602090815260408083207f00000000000000000000000039eb270155c78cbe8cdad4050fd8b8512f806a219094168352929052908120549081900361255f5760405163e1fee18560e01b81526001600160a01b037f00000000000000000000000039eb270155c78cbe8cdad4050fd8b8512f806a2116600482015260240161080f565b61256d868583888787612f46565b61010254610a3b906001600160a01b0316611dcf83610d36565b61259086611ea8565b6125b8576040516343c90fad60e11b81526001600160a01b038716600482015260240161080f565b6001600160a01b03808816600090815260fc60209081526040808320938a168352929052908120549081900361260c5760405163e1fee18560e01b81526001600160a01b038816600482015260240161080f565b6001600160a01b03808916600090815260fc602090815260408083207f00000000000000000000000039eb270155c78cbe8cdad4050fd8b8512f806a21909416835292905290812054906126608688613d3e565b90508082101561268d57604051635d2d8e3960e11b8152600481018390526024810182905260440161080f565b6126b77f00000000000000000000000000000000000000000000000000000002540be40082613ead565b156126fe57604051630481813960e21b8152600481018290527f00000000000000000000000000000000000000000000000000000002540be400602482015260440161080f565b6000612708610db9565b9050611e008a8c86848d8d8d8d8d612cd7565b6001600160a01b03808316600090815260fc602090815260408083207f00000000000000000000000039eb270155c78cbe8cdad4050fd8b8512f806a219094168352929052908120548282036127af57604051639eea385960e01b81526001600160a01b037f00000000000000000000000039eb270155c78cbe8cdad4050fd8b8512f806a2116600482015260240161080f565b7f00000000000000000000000000000000000000000000000000000002540be40083101561281957604051634015e6cd60e11b8152600481018490527f00000000000000000000000000000000000000000000000000000002540be400602482015260440161080f565b82811015612873576040516368b65f1160e01b81526001600160a01b037f00000000000000000000000039eb270155c78cbe8cdad4050fd8b8512f806a21166004820152602481018290526044810184905260640161080f565b61289d7f00000000000000000000000000000000000000000000000000000002540be40084613ead565b156128e457604051630481813960e21b8152600481018490527f00000000000000000000000000000000000000000000000000000002540be400602482015260440161080f565b60006128ef84610d36565b905061291c857f00000000000000000000000039eb270155c78cbe8cdad4050fd8b8512f806a21866132a9565b604051630852cd8d60e31b8152600481018590527f00000000000000000000000039eb270155c78cbe8cdad4050fd8b8512f806a216001600160a01b0316906342966c6890602401600060405180830381600087803b15801561297e57600080fd5b505af1158015612992573d6000803e3d6000fd5b505050506129a260975460ff1690565b1580156129b25750600061010354115b15612a6957600061271061010354836129cb9190613d3e565b6129d59190613e2f565b9050600061271061010354846129eb9190613d3e565b6129f59190613ead565b1115612a0757612a0481613e7b565b90505b612a118183613ed4565b9150612a676001600160a01b037f0000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c599167f000000000000000000000000d437fc63d8e4a0cb5c3d086fee5033a53c6eefe383613122565b505b612a9d6001600160a01b037f0000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c599168683613122565b7f00000000000000000000000039eb270155c78cbe8cdad4050fd8b8512f806a216001600160a01b0316856001600160a01b03167f7a163cc3488948c84f02deddd608c9465235f04837413e5f1051007d0da746d28387604051612b0b929190918252602082015260400190565b60405180910390a3949350505050565b60606000806000612b2a610d25565b9050805167ffffffffffffffff811115612b4657612b46613a72565b604051908082528060200260200182016040528015612b6f578160200160208202803683370190505b509350600092506000915060005b8151811015612c0d576000828281518110612b9a57612b9a613e43565b6020908102919091018101516001600160a01b03808a16600090815260fc84526040808220928416825291909352909120549091508015612c035780878481518110612be857612be8613e43565b602090810291909101015260019550612c0085613e7b565b94505b5050600101612b7d565b50509193909250565b6001600160a01b0381163b612c835760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b606482015260840161080f565b6000805160206140dd83398151915280546001600160a01b0319166001600160a01b0392909216919091179055565b612cbb836133c1565b600082511180612cc85750805b15610894576111068383613401565b6000612ce38486613d3e565b9050612cf0898b8a6132a9565b612d1b897f00000000000000000000000039eb270155c78cbe8cdad4050fd8b8512f806a21836132a9565b604051635ed004ff60e11b81526001600160a01b038b81166004830152612d9b919089169063bda009fe90602401602060405180830381865afa158015612d66573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612d8a9190613f32565b6001600160a01b038c16908a613426565b8015612e4157604051635ed004ff60e11b81526001600160a01b038b81166004830152612e41919089169063bda009fe90602401602060405180830381865afa158015612dec573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612e109190613f32565b6001600160a01b037f00000000000000000000000039eb270155c78cbe8cdad4050fd8b8512f806a21169083613426565b604051634fb1a07b60e01b81526001600160a01b03881690634fb1a07b90612e7b908d908a9081908e908c908c908c908c90600401613f78565b6000604051808303816000875af1158015612e9a573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052612ec29190810190613ff0565b50856001600160a01b0316896001600160a01b03168b6001600160a01b03167f4107daeebc39f62a9bcf7cba4f17fd343890688372f1aaeb5815ca1a215c929a8b89898989604051612f18959493929190614067565b60405180910390a461010254612f3a906001600160a01b0316611dcf83610d36565b50505050505050505050565b6000612f50611024565b9050612f7d877f00000000000000000000000039eb270155c78cbe8cdad4050fd8b8512f806a21876132a9565b61010154612fb8906001600160a01b037f00000000000000000000000039eb270155c78cbe8cdad4050fd8b8512f806a218116911687613426565b6001600160a01b03811663b9b9a68885612fd28587613d3e565b612fdc908a613ec1565b612fe69089613ed4565b6040516001600160e01b031960e085901b1681526001600160a01b0392831660048201526024810191909152604481018a905290871660648201819052608482015260a4810186905260c4810185905260e481018890526101206101048201526000610124820152610144016020604051808303816000875af1158015613071573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906130959190613e94565b5060408051868152602081018590529081018390526080606082018190526000908201526001600160a01b0380861691898216917f00000000000000000000000039eb270155c78cbe8cdad4050fd8b8512f806a2116907f4107daeebc39f62a9bcf7cba4f17fd343890688372f1aaeb5815ca1a215c929a9060a00160405180910390a450505050505050565b6040516001600160a01b03831660248201526044810182905261089490849063a9059cbb60e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b03199093169290921790915261353b565b6001600160a01b03808416600090815260fc60209081526040808320938616835292905220546131b6908290613ec1565b6001600160a01b03808516600090815260fc6020908152604080832093871683529281528282209390935560fd9092529020546131f4908290613ec1565b6001600160a01b03909216600090815260fd60205260409020919091555050565b6040516001600160a01b03808516602483015283166044820152606481018290526111069085906323b872dd60e01b9060840161314e565b60608160000180548060200260200160405190810160405280929190818152602001828054801561329d57602002820191906000526020600020905b815481526020019060010190808311613289575b50505050509050919050565b6001600160a01b03808416600090815260fc60209081526040808320938616835292905220546132da908290613ed4565b6001600160a01b03808516600090815260fc6020908152604080832093871683529281528282209390935560fd9092529020546131f4908290613ed4565b600054610100900460ff1661333f5760405162461bcd60e51b815260040161080f90613ee7565b6097805460ff19169055565b600054610100900460ff166116bd5760405162461bcd60e51b815260040161080f90613ee7565b60008181526001830160205260408120546133b957508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610777565b506000610777565b6133ca81612c16565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b60606111be83836040518060600160405280602781526020016140fd60279139613610565b8015806134a05750604051636eb1769f60e11b81523060048201526001600160a01b03838116602483015284169063dd62ed3e90604401602060405180830381865afa15801561347a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061349e9190613e94565b155b61350b5760405162461bcd60e51b815260206004820152603660248201527f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60448201527520746f206e6f6e2d7a65726f20616c6c6f77616e636560501b606482015260840161080f565b6040516001600160a01b03831660248201526044810182905261089490849063095ea7b360e01b9060640161314e565b6000613590826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166136889092919063ffffffff16565b90508051600014806135b15750808060200190518101906135b19190613e59565b6108945760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b606482015260840161080f565b6060600080856001600160a01b03168560405161362d919061408d565b600060405180830381855af49150503d8060008114613668576040519150601f19603f3d011682016040523d82523d6000602084013e61366d565b606091505b509150915061367e86838387613697565b9695505050505050565b606061153e8484600085613710565b606083156137065782516000036136ff576001600160a01b0385163b6136ff5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015260640161080f565b508161153e565b61153e83836137eb565b6060824710156137715760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b606482015260840161080f565b600080866001600160a01b0316858760405161378d919061408d565b60006040518083038185875af1925050503d80600081146137ca576040519150601f19603f3d011682016040523d82523d6000602084013e6137cf565b606091505b50915091506137e087838387613697565b979650505050505050565b8151156137fb5781518083602001fd5b8060405162461bcd60e51b815260040161080f91906140a9565b6001600160a01b03811681146109a657600080fd5b6000806040838503121561383d57600080fd5b823561384881613815565b9150602083013561385881613815565b809150509250929050565b60006020828403121561387557600080fd5b5035919050565b60008060006060848603121561389157600080fd5b833561389c81613815565b925060208401356138ac81613815565b915060408401356138bc81613815565b809150509250925092565b60008151808452602080850194506020840160005b838110156139015781516001600160a01b0316875295820195908201906001016138dc565b509495945050505050565b60808152600061391f60808301876138c7565b82810360208481019190915286518083528782019282019060005b818110156139565784518352938301939183019160010161393a565b505060408501969096525050506060015292915050565b60006020828403121561397f57600080fd5b81356111be81613815565b60008083601f84011261399c57600080fd5b50813567ffffffffffffffff8111156139b457600080fd5b6020830191508360208285010111156139cc57600080fd5b9250929050565b60008060008060008060a087890312156139ec57600080fd5b86356139f781613815565b9550602087013594506040870135935060608701359250608087013567ffffffffffffffff811115613a2857600080fd5b613a3489828a0161398a565b979a9699509497509295939492505050565b60008060408385031215613a5957600080fd5b8235613a6481613815565b946020939093013593505050565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff81118282101715613ab157613ab1613a72565b604052919050565b600067ffffffffffffffff821115613ad357613ad3613a72565b50601f01601f191660200190565b60008060408385031215613af457600080fd5b8235613aff81613815565b9150602083013567ffffffffffffffff811115613b1b57600080fd5b8301601f81018513613b2c57600080fd5b8035613b3f613b3a82613ab9565b613a88565b818152866020838501011115613b5457600080fd5b816020840160208301376000602083830101528093505050509250929050565b6020815260006111be60208301846138c7565b60008060408385031215613b9a57600080fd5b8235613ba581613815565b915060208381013567ffffffffffffffff80821115613bc357600080fd5b818601915086601f830112613bd757600080fd5b813581811115613be957613be9613a72565b8060051b9150613bfa848301613a88565b8181529183018401918481019089841115613c1457600080fd5b938501935b83851015613c3e5784359250613c2e83613815565b8282529385019390850190613c19565b8096505050505050509250929050565b60008060008060808587031215613c6457600080fd5b8435613c6f81613815565b966020860135965060408601359560600135945092505050565b600080600060608486031215613c9e57600080fd5b8335613ca981613815565b92506020840135613cb981613815565b929592945050506040919091013590565b60008060008060008060a08789031215613ce357600080fd5b8635613cee81613815565b95506020870135613cfe81613815565b94506040870135935060608701359250608087013567ffffffffffffffff811115613a2857600080fd5b634e487b7160e01b600052601160045260246000fd5b808202811582820484141761077757610777613d28565b602080825260129082015271105d5d1a0e8815539055551213d49256915160721b604082015260600190565b6020808252602c908201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060408201526b19195b1959d85d1958d85b1b60a21b606082015260800190565b6020808252602c908201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060408201526b6163746976652070726f787960a01b606082015260800190565b634e487b7160e01b600052601260045260246000fd5b600082613e3e57613e3e613e19565b500490565b634e487b7160e01b600052603260045260246000fd5b600060208284031215613e6b57600080fd5b815180151581146111be57600080fd5b600060018201613e8d57613e8d613d28565b5060010190565b600060208284031215613ea657600080fd5b5051919050565b600082613ebc57613ebc613e19565b500690565b8082018082111561077757610777613d28565b8181038181111561077757610777613d28565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b600060208284031215613f4457600080fd5b81516111be81613815565b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b600060018060a01b03808b168352808a1660208401528089166040840152508660608301528560808301528460a083015260e060c0830152613fbe60e083018486613f4f565b9a9950505050505050505050565b60005b83811015613fe7578181015183820152602001613fcf565b50506000910152565b60006020828403121561400257600080fd5b815167ffffffffffffffff81111561401957600080fd5b8201601f8101841361402a57600080fd5b8051614038613b3a82613ab9565b81815285602083850101111561404d57600080fd5b61405e826020830160208601613fcc565b95945050505050565b8581528460208201528360408201526080606082015260006137e0608083018486613f4f565b6000825161409f818460208701613fcc565b9190910192915050565b60208152600082518060208401526140c8816040850160208701613fcc565b601f01601f1916919091016040019291505056fe360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220b62401ae009b59e687b18a3365b0b3659414a7b391ddb9e53190645a9d94dc8864736f6c63430008190033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
00000000000000000000000039eb270155c78cbe8cdad4050fd8b8512f806a210000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c599000000000000000000000000d437fc63d8e4a0cb5c3d086fee5033a53c6eefe3
-----Decoded View---------------
Arg [0] : _bitcorn (address): 0x39eb270155C78cbE8cDad4050fd8b8512F806A21
Arg [1] : _bitcornMinterAsset (address): 0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599
Arg [2] : _feeRecipient (address): 0xD437fC63d8e4a0cb5C3D086FEE5033a53C6eEfe3
-----Encoded View---------------
3 Constructor Arguments found :
Arg [0] : 00000000000000000000000039eb270155c78cbe8cdad4050fd8b8512f806a21
Arg [1] : 0000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c599
Arg [2] : 000000000000000000000000d437fc63d8e4a0cb5c3d086fee5033a53c6eefe3
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 30 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.