Transaction Hash |
Method
|
Block
|
From
|
To
|
|||||
---|---|---|---|---|---|---|---|---|---|
0x9a0ce3792a68cfdb216d3adc9dfb2bcd175b6919fd413482099802ff41b7f7c5 | Request Withdraw | (pending) | 3 days ago | IN | 0 ETH | (Pending) | |||
Cancel Withdraw | 22651681 | 12 mins ago | IN | 0 ETH | 0.0000631 | ||||
Request Withdraw | 22651603 | 28 mins ago | IN | 0 ETH | 0.00013326 | ||||
Instant Withdraw | 22651585 | 31 mins ago | IN | 0 ETH | 0.00025902 | ||||
Request Withdraw | 22651585 | 31 mins ago | IN | 0 ETH | 0.00011923 | ||||
Instant Withdraw | 22651573 | 34 mins ago | IN | 0 ETH | 0.00040672 | ||||
Instant Withdraw | 22651552 | 38 mins ago | IN | 0 ETH | 0.0004013 | ||||
Instant Withdraw | 22651525 | 43 mins ago | IN | 0 ETH | 0.00042307 | ||||
Instant Withdraw | 22651518 | 45 mins ago | IN | 0 ETH | 0.00038673 | ||||
Cancel Withdraw | 22651505 | 47 mins ago | IN | 0 ETH | 0.00009542 | ||||
Cancel Withdraw | 22651498 | 49 mins ago | IN | 0 ETH | 0.00009697 | ||||
Instant Withdraw | 22651494 | 50 mins ago | IN | 0 ETH | 0.00044385 | ||||
Instant Withdraw | 22651493 | 50 mins ago | IN | 0 ETH | 0.00045058 | ||||
Cancel Withdraw | 22651489 | 51 mins ago | IN | 0 ETH | 0.00006907 | ||||
Instant Withdraw | 22651478 | 53 mins ago | IN | 0 ETH | 0.00046046 | ||||
Cancel Withdraw | 22651475 | 53 mins ago | IN | 0 ETH | 0.00010982 | ||||
Instant Withdraw | 22651474 | 54 mins ago | IN | 0 ETH | 0.00046039 | ||||
Instant Withdraw | 22651443 | 1 hr ago | IN | 0 ETH | 0.00048082 | ||||
Instant Withdraw | 22651429 | 1 hr ago | IN | 0 ETH | 0.00049743 | ||||
Cancel Withdraw | 22651428 | 1 hr ago | IN | 0 ETH | 0.00007417 | ||||
Instant Withdraw | 22651405 | 1 hr ago | IN | 0 ETH | 0.00049332 | ||||
Instant Withdraw | 22651385 | 1 hr ago | IN | 0 ETH | 0.00050473 | ||||
Instant Withdraw | 22651376 | 1 hr ago | IN | 0 ETH | 0.00047759 | ||||
Cancel Withdraw | 22651367 | 1 hr ago | IN | 0 ETH | 0.00006226 | ||||
Instant Withdraw | 22651362 | 1 hr ago | IN | 0 ETH | 0.00044175 |
Latest 25 internal transactions (View All)
Advanced mode:
Parent Transaction Hash | Method | Block |
From
|
To
|
|||
---|---|---|---|---|---|---|---|
Deposit | 22650098 | 5 hrs ago | 2.5 ETH | ||||
Transfer* | 22650098 | 5 hrs ago | 2.5 ETH | ||||
Deposit | 22647630 | 13 hrs ago | 0.001 ETH | ||||
Deposit | 22642975 | 29 hrs ago | 0.000028 ETH | ||||
Deposit | 22639479 | 41 hrs ago | 0.0001 ETH | ||||
Deposit | 22639240 | 41 hrs ago | 3,000 ETH | ||||
Transfer* | 22639240 | 41 hrs ago | 3,000 ETH | ||||
Deposit | 22635789 | 2 days ago | 3 ETH | ||||
Deposit | 22635481 | 2 days ago | 0.01 ETH | ||||
Deposit | 22635343 | 2 days ago | 33 ETH | ||||
Transfer* | 22635343 | 2 days ago | 33 ETH | ||||
Deposit | 22634777 | 2 days ago | 5 ETH | ||||
Deposit | 22634761 | 2 days ago | 5 ETH | ||||
Deposit | 22631496 | 2 days ago | 5.5 ETH | ||||
Transfer* | 22631496 | 2 days ago | 5.5 ETH | ||||
Deposit | 22629976 | 3 days ago | 0.85784326 ETH | ||||
Transfer* | 22629976 | 3 days ago | 0.85784326 ETH | ||||
Deposit | 22629790 | 3 days ago | 0.013 ETH | ||||
Deposit | 22628304 | 3 days ago | 0.18 ETH | ||||
Transfer* | 22628304 | 3 days ago | 0.18 ETH | ||||
Deposit | 22626465 | 3 days ago | 7 ETH | ||||
Transfer* | 22626465 | 3 days ago | 7 ETH | ||||
Deposit | 22626373 | 3 days ago | 4.8 ETH | ||||
Transfer* | 22626373 | 3 days ago | 4.8 ETH | ||||
Deposit | 22625464 | 3 days ago | 64 ETH |
Loading...
Loading
Contract Name:
StoneVault
Compiler Version
v0.8.21+commit.d9974bed
Optimization Enabled:
Yes with 10 runs
Other Settings:
shanghai EvmVersion, Audited
Contract Source Code (Solidity Standard Json-Input format)Audit Report
// SPDX-License-Identifier: MIT pragma solidity 0.8.21; import {ReentrancyGuard} from "@openzeppelin/contracts/security/ReentrancyGuard.sol"; import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol"; import {TransferHelper} from "@uniswap/v3-periphery/contracts/libraries/TransferHelper.sol"; import {Minter} from "./token/Minter.sol"; import {Stone} from "./token/Stone.sol"; import {AssetsVault} from "./AssetsVault.sol"; import {StrategyController} from "./strategies/StrategyController.sol"; import {VaultMath} from "./libraries/VaultMath.sol"; contract StoneVault is ReentrancyGuard, Ownable { uint256 internal constant MULTIPLIER = 1e18; uint256 internal constant ONE_HUNDRED_PERCENT = 1e6; uint256 internal constant MAXMIUM_FEE_RATE = ONE_HUNDRED_PERCENT / 100; // 1% uint256 internal constant MINIMUM_REBASE_INTERVAL = 7 * 24 * 60 * 60; uint256 public constant VERSION = 1; uint256 public rebaseTimeInterval = 24 * 60 * 60; address public immutable minter; address public immutable stone; address payable public immutable strategyController; address payable public immutable assetsVault; address public proposal; address public feeRecipient; uint256 public latestRoundID; uint256 public withdrawableAmountInPast; uint256 public withdrawingSharesInPast; uint256 public withdrawingSharesInRound; uint256 public withdrawFeeRate; uint256 public rebaseTime; mapping(uint256 => uint256) public roundPricePerShare; mapping(uint256 => uint256) public settlementTime; mapping(address => UserReceipt) public userReceipts; struct UserReceipt { uint256 withdrawRound; uint256 withdrawShares; uint256 withdrawableAmount; } event Deposit( address indexed account, uint256 amount, uint256 mint, uint256 round ); event InitiateWithdraw( address indexed account, uint256 shares, uint256 round ); event CancelWithdraw( address indexed account, uint256 amount, uint256 round ); event Withdrawn(address indexed account, uint256 amount, uint256 round); event WithdrawnFromStrategy( address indexed account, uint256 amount, uint256 actualAmount, uint256 round ); event RollToNextRound( uint256 round, uint256 vaultIn, uint256 vaultOut, uint256 sharePrice ); event StragetyAdded(address strategy); event StragetyDestroyed(address strategy); event StragetyCleared(address strategy); event PortfolioConfigUpdated(address[] strategies, uint256[] ratios); event FeeCharged(address indexed account, uint256 amount); event SetWithdrawFeeRate(uint256 oldRate, uint256 newRate); event SetFeeRecipient(address oldAddr, address newAddr); event SetRebaseInterval(uint256 interval); modifier onlyProposal() { require(proposal == msg.sender, "not proposal"); _; } constructor( address _minter, address _proposal, address payable _assetsVault, address[] memory _strategies, uint256[] memory _ratios ) { require( _minter != address(0) && _proposal != address(0) && _assetsVault != address(0), "ZERO ADDRESS" ); uint256 length = _strategies.length; for (uint256 i; i < length; i++) { require(_strategies[i] != address(0), "ZERO ADDRESS"); } minter = _minter; proposal = _proposal; assetsVault = _assetsVault; feeRecipient = msg.sender; StrategyController controller = new StrategyController( _assetsVault, _strategies, _ratios ); strategyController = payable(address(controller)); stone = Minter(_minter).stone(); roundPricePerShare[0] = MULTIPLIER; latestRoundID = 0; } function deposit() external payable nonReentrant returns (uint256 mintAmount) { mintAmount = _depositFor(msg.value, msg.sender); } function depositFor( address _user ) external payable nonReentrant returns (uint256 mintAmount) { mintAmount = _depositFor(msg.value, _user); } function _depositFor( uint256 _amount, address _user ) internal returns (uint256 mintAmount) { require(_amount != 0, "too small"); uint256 sharePrice; uint256 currSharePrice = currentSharePrice(); if (latestRoundID == 0) { sharePrice = MULTIPLIER; } else { uint256 latestSharePrice = roundPricePerShare[latestRoundID - 1]; sharePrice = latestSharePrice > currSharePrice ? latestSharePrice : currSharePrice; } mintAmount = (_amount * MULTIPLIER) / sharePrice; AssetsVault(assetsVault).deposit{value: address(this).balance}(); Minter(minter).mint(_user, mintAmount); emit Deposit(_user, _amount, mintAmount, latestRoundID); } function requestWithdraw(uint256 _shares) external nonReentrant { require(_shares != 0, "too small"); require(latestRoundID != 0, "should withdraw instantly"); Stone stoneToken = Stone(stone); Minter stoneMinter = Minter(minter); require(stoneToken.balanceOf(msg.sender) >= _shares, "exceed balance"); TransferHelper.safeTransferFrom( stone, msg.sender, address(this), _shares ); withdrawingSharesInRound = withdrawingSharesInRound + _shares; UserReceipt storage receipt = userReceipts[msg.sender]; if (receipt.withdrawRound == latestRoundID) { receipt.withdrawShares = receipt.withdrawShares + _shares; } else if (receipt.withdrawRound == 0) { receipt.withdrawShares = _shares; receipt.withdrawRound = latestRoundID; } else { // Withdraw previous round share first uint256 withdrawAmount = VaultMath.sharesToAsset( receipt.withdrawShares, roundPricePerShare[receipt.withdrawRound] ); stoneMinter.burn(address(this), receipt.withdrawShares); withdrawingSharesInPast = withdrawingSharesInPast - receipt.withdrawShares; receipt.withdrawShares = _shares; receipt.withdrawableAmount = receipt.withdrawableAmount + withdrawAmount; receipt.withdrawRound = latestRoundID; } emit InitiateWithdraw(msg.sender, _shares, latestRoundID); } function cancelWithdraw(uint256 _shares) external nonReentrant { require(_shares != 0, "too small"); UserReceipt storage receipt = userReceipts[msg.sender]; require(receipt.withdrawRound == latestRoundID, "no pending withdraw"); require(receipt.withdrawShares >= _shares, "exceed pending withdraw"); receipt.withdrawShares = receipt.withdrawShares - _shares; TransferHelper.safeTransfer(stone, msg.sender, _shares); if (receipt.withdrawShares == 0) { receipt.withdrawRound = 0; } withdrawingSharesInRound = withdrawingSharesInRound - _shares; emit CancelWithdraw(msg.sender, _shares, latestRoundID); } function instantWithdraw( uint256 _amount, uint256 _shares ) external nonReentrant returns (uint256 actualWithdrawn) { require(_amount != 0 || _shares != 0, "too small"); AssetsVault aVault = AssetsVault(assetsVault); Minter stoneMinter = Minter(minter); (uint256 idleAmount, ) = getVaultAvailableAmount(); if (_amount != 0) { UserReceipt storage receipt = userReceipts[msg.sender]; if ( receipt.withdrawRound != latestRoundID && receipt.withdrawRound != 0 ) { // Withdraw previous round share first uint256 withdrawAmount = VaultMath.sharesToAsset( receipt.withdrawShares, roundPricePerShare[receipt.withdrawRound] ); stoneMinter.burn(address(this), receipt.withdrawShares); withdrawingSharesInPast = withdrawingSharesInPast - receipt.withdrawShares; receipt.withdrawShares = 0; receipt.withdrawableAmount = receipt.withdrawableAmount + withdrawAmount; receipt.withdrawRound = 0; } require( receipt.withdrawableAmount >= _amount, "exceed withdrawable" ); receipt.withdrawableAmount = receipt.withdrawableAmount - _amount; withdrawableAmountInPast = withdrawableAmountInPast - _amount; actualWithdrawn = _amount; emit Withdrawn(msg.sender, _amount, latestRoundID); } if (_shares != 0) { uint256 sharePrice; if (latestRoundID == 0) { sharePrice = MULTIPLIER; } else { uint256 currSharePrice = currentSharePrice(); uint256 latestSharePrice = roundPricePerShare[ latestRoundID - 1 ]; sharePrice = latestSharePrice < currSharePrice ? latestSharePrice : currSharePrice; } uint256 ethAmount = VaultMath.sharesToAsset(_shares, sharePrice); stoneMinter.burn(msg.sender, _shares); if (ethAmount <= idleAmount) { actualWithdrawn = actualWithdrawn + ethAmount; emit Withdrawn(msg.sender, ethAmount, latestRoundID); } else { actualWithdrawn = actualWithdrawn + idleAmount; ethAmount = ethAmount - idleAmount; StrategyController controller = StrategyController( strategyController ); uint256 actualAmount = controller.forceWithdraw(ethAmount); actualWithdrawn = actualWithdrawn + actualAmount; emit WithdrawnFromStrategy( msg.sender, ethAmount, actualAmount, latestRoundID ); } } require(aVault.getBalance() >= actualWithdrawn, "still need wait"); uint256 withFee; if (withdrawFeeRate != 0) { withFee = (actualWithdrawn * withdrawFeeRate) / ONE_HUNDRED_PERCENT; aVault.withdraw(feeRecipient, withFee); emit FeeCharged(msg.sender, withFee); } aVault.withdraw(msg.sender, actualWithdrawn - withFee); } function rollToNextRound() external { require( block.timestamp > rebaseTime + rebaseTimeInterval, "already rebased" ); StrategyController controller = StrategyController(strategyController); AssetsVault aVault = AssetsVault(assetsVault); uint256 previewSharePrice = currentSharePrice(); uint256 vaultBalance = aVault.getBalance(); uint256 amountToWithdraw = VaultMath.sharesToAsset( withdrawingSharesInRound, previewSharePrice ); uint256 amountVaultNeed = withdrawableAmountInPast + amountToWithdraw; uint256 allPendingValue = controller.getAllStrategyPendingValue(); uint256 vaultIn; uint256 vaultOut; if (vaultBalance > amountVaultNeed) { vaultIn = vaultBalance - amountVaultNeed; } else if (vaultBalance + allPendingValue < amountVaultNeed) { vaultOut = amountVaultNeed - vaultBalance - allPendingValue; } controller.rebaseStrategies(vaultIn, vaultOut); uint256 newSharePrice = currentSharePrice(); roundPricePerShare[latestRoundID] = previewSharePrice < newSharePrice ? previewSharePrice : newSharePrice; settlementTime[latestRoundID] = block.timestamp; latestRoundID = latestRoundID + 1; withdrawingSharesInPast = withdrawingSharesInPast + withdrawingSharesInRound; withdrawableAmountInPast = withdrawableAmountInPast + VaultMath.sharesToAsset(withdrawingSharesInRound, newSharePrice); withdrawingSharesInRound = 0; rebaseTime = block.timestamp; emit RollToNextRound(latestRoundID, vaultIn, vaultOut, newSharePrice); } function addStrategy(address _strategy) external onlyProposal { StrategyController controller = StrategyController(strategyController); controller.addStrategy(_strategy); emit StragetyAdded(_strategy); } function destroyStrategy(address _strategy) external onlyOwner { StrategyController controller = StrategyController(strategyController); controller.destroyStrategy(_strategy); emit StragetyDestroyed(_strategy); } function clearStrategy(address _strategy) external onlyOwner { StrategyController controller = StrategyController(strategyController); controller.clearStrategy(_strategy); emit StragetyCleared(_strategy); } function updatePortfolioConfig( address[] memory _strategies, uint256[] memory _ratios ) external onlyProposal { StrategyController controller = StrategyController(strategyController); controller.setStrategies(_strategies, _ratios); emit PortfolioConfigUpdated(_strategies, _ratios); } function updateProposal(address _proposal) external onlyProposal { proposal = _proposal; } function migrateVault(address _vault) external onlyProposal { Minter(minter).setNewVault(_vault); AssetsVault(assetsVault).setNewVault(_vault); StrategyController(strategyController).setNewVault(_vault); } function currentSharePrice() public returns (uint256 price) { Stone stoneToken = Stone(stone); uint256 totalStone = stoneToken.totalSupply(); if ( latestRoundID == 0 || totalStone == 0 || totalStone == withdrawingSharesInPast ) { return MULTIPLIER; } uint256 etherAmount = AssetsVault(assetsVault).getBalance() + StrategyController(strategyController).getAllStrategiesValue() - withdrawableAmountInPast; uint256 activeShare = totalStone - withdrawingSharesInPast; return (etherAmount * MULTIPLIER) / activeShare; } function getVaultAvailableAmount() public returns (uint256 idleAmount, uint256 investedAmount) { AssetsVault vault = AssetsVault(assetsVault); if (vault.getBalance() > withdrawableAmountInPast) { idleAmount = vault.getBalance() - withdrawableAmountInPast; } investedAmount = StrategyController(strategyController) .getAllStrategyValidValue(); } function setWithdrawFeeRate(uint256 _withdrawFeeRate) external onlyOwner { require(_withdrawFeeRate <= MAXMIUM_FEE_RATE, "exceed maximum"); emit SetWithdrawFeeRate(withdrawFeeRate, _withdrawFeeRate); withdrawFeeRate = _withdrawFeeRate; } function setFeeRecipient(address _feeRecipient) external onlyOwner { require(_feeRecipient != address(0), "zero address"); emit SetFeeRecipient(feeRecipient, _feeRecipient); feeRecipient = _feeRecipient; } function setRebaseInterval(uint256 _interval) external onlyOwner { require(_interval <= MINIMUM_REBASE_INTERVAL, "invalid"); rebaseTimeInterval = _interval; emit SetRebaseInterval(rebaseTimeInterval); } receive() external payable {} }
// SPDX-License-Identifier: MIT pragma solidity 0.8.21; import "@layerzerolabs/solidity-examples/contracts/token/oft/extension/BasedOFT.sol"; import {Minter} from "./Minter.sol"; contract Stone is BasedOFT { uint256 public constant DAY_INTERVAL = 24 * 60 * 60; address public minter; uint16 public constant PT_FEED = 1; uint16 public constant PT_SET_ENABLE = 2; uint16 public constant PT_SET_CAP = 3; uint256 public cap; bool public enable = true; mapping(uint256 => uint256) public quota; event FeedToChain( uint16 indexed dstChainId, address indexed from, bytes toAddress, uint price ); event SetCapFor(uint16 indexed dstChainId, bytes toAddress, uint cap); event SetEnableFor(uint16 indexed dstChainId, bytes toAddress, bool flag); constructor( address _minter, address _layerZeroEndpoint, uint256 _cap ) BasedOFT("StakeStone Ether", "STONE", _layerZeroEndpoint) { minter = _minter; cap = _cap; } modifier onlyMinter() { require(msg.sender == minter, "NM"); _; } function mint(address _to, uint256 _amount) external onlyMinter { _mint(_to, _amount); } function burn(address _from, uint256 _amount) external onlyMinter { _burn(_from, _amount); } function sendFrom( address _from, uint16 _dstChainId, bytes calldata _toAddress, uint _amount, address payable _refundAddress, address _zroPaymentAddress, bytes calldata _adapterParams ) public payable override(IOFTCore, OFTCore) { require(enable, "invalid"); uint256 id; assembly { id := chainid() } require(id != _dstChainId, "same chain"); uint256 day = block.timestamp / DAY_INTERVAL; require(_amount + quota[day] <= cap, "Exceed cap"); quota[day] = quota[day] + _amount; super.sendFrom( _from, _dstChainId, _toAddress, _amount, _refundAddress, _zroPaymentAddress, _adapterParams ); } function updatePrice( uint16 _dstChainId, bytes memory _toAddress ) external payable returns (uint256 price) { require(enable, "invalid"); uint256 id; assembly { id := chainid() } require(id != _dstChainId, "same chain"); price = tokenPrice(); bytes memory lzPayload = abi.encode( PT_FEED, _toAddress, price, block.timestamp ); _lzSend( _dstChainId, lzPayload, payable(msg.sender), address(0), bytes(""), msg.value ); emit FeedToChain(_dstChainId, msg.sender, _toAddress, price); } function setEnableFor( uint16 _dstChainId, bool _flag, bytes memory _toAddress ) external payable onlyOwner { uint256 id; assembly { id := chainid() } if (_dstChainId == id) { enable = _flag; emit SetEnableFor( _dstChainId, abi.encodePacked(address(this)), enable ); return; } bytes memory lzPayload = abi.encode(PT_SET_ENABLE, _toAddress, _flag); _lzSend( _dstChainId, lzPayload, payable(msg.sender), address(0), bytes(""), msg.value ); emit SetEnableFor(_dstChainId, _toAddress, _flag); } function setCapFor( uint16 _dstChainId, uint256 _cap, bytes memory _toAddress ) external payable onlyOwner { uint256 id; assembly { id := chainid() } if (_dstChainId == id) { cap = _cap; emit SetCapFor(_dstChainId, abi.encodePacked(address(this)), cap); return; } bytes memory lzPayload = abi.encode(PT_SET_CAP, _toAddress, _cap); _lzSend( _dstChainId, lzPayload, payable(msg.sender), address(0), bytes(""), msg.value ); emit SetCapFor(_dstChainId, _toAddress, _cap); } function tokenPrice() public returns (uint256 price) { price = Minter(minter).getTokenPrice(); } function getQuota() external view returns (uint256) { uint256 amount = quota[block.timestamp / DAY_INTERVAL]; if (cap > amount && enable) { return cap - amount; } } }
// SPDX-License-Identifier: MIT pragma solidity 0.8.21; import {Stone} from "./Stone.sol"; import {StoneVault} from "../StoneVault.sol"; contract Minter { // TODO: governable upgrade address public stone; address payable public vault; modifier onlyVault() { require(msg.sender == vault, "not vault"); _; } constructor(address _stone, address payable _vault) { stone = _stone; vault = _vault; } function mint(address _to, uint256 _amount) external onlyVault { Stone(stone).mint(_to, _amount); } function burn(address _from, uint256 _amount) external onlyVault { Stone(stone).burn(_from, _amount); } function setNewVault(address _vault) external onlyVault { vault = payable(_vault); } function getTokenPrice() public returns (uint256 price) { price = StoneVault(vault).currentSharePrice(); } }
// SPDX-License-Identifier: MIT pragma solidity 0.8.21; import {EnumerableSet} from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol"; import {TransferHelper} from "@uniswap/v3-periphery/contracts/libraries/TransferHelper.sol"; import {Strategy} from "./Strategy.sol"; import {AssetsVault} from "../AssetsVault.sol"; contract StrategyController { using EnumerableSet for EnumerableSet.AddressSet; uint256 internal constant ONE_HUNDRED_PERCENT = 1e6; address public stoneVault; address payable public immutable assetsVault; EnumerableSet.AddressSet private strategies; mapping(address => uint256) public ratios; struct StrategyDiff { address strategy; bool isDeposit; uint256 amount; } modifier onlyVault() { require(stoneVault == msg.sender, "not vault"); _; } constructor( address payable _assetsVault, address[] memory _strategies, uint256[] memory _ratios ) { require(_assetsVault != address(0), "ZERO ADDRESS"); uint256 length = _strategies.length; for (uint256 i; i < length; i++) { require(_strategies[i] != address(0), "ZERO ADDRESS"); } stoneVault = msg.sender; assetsVault = _assetsVault; _initStrategies(_strategies, _ratios); } function onlyRebaseStrategies() external { _rebase(0, 0); } function forceWithdraw( uint256 _amount ) external onlyVault returns (uint256 actualAmount) { uint256 balanceBeforeRepay = address(this).balance; if (balanceBeforeRepay >= _amount) { _repayToVault(); actualAmount = balanceBeforeRepay; } else { actualAmount = _forceWithdraw(_amount - balanceBeforeRepay) + balanceBeforeRepay; } } function setStrategies( address[] memory _strategies, uint256[] memory _ratios ) external onlyVault { _setStrategies(_strategies, _ratios); } function addStrategy(address _strategy) external onlyVault { require(!strategies.contains(_strategy), "already exist"); strategies.add(_strategy); } function rebaseStrategies( uint256 _in, uint256 _out ) external payable onlyVault { _rebase(_in, _out); } function destroyStrategy(address _strategy) external onlyVault { _destoryStrategy(_strategy); } function _rebase(uint256 _in, uint256 _out) internal { require(_in == 0 || _out == 0, "only deposit or withdraw"); if (_in != 0) { AssetsVault(assetsVault).withdraw(address(this), _in); } uint256 total = getAllStrategyValidValue(); if (total < _out) { total = 0; } else { total = total + _in - _out; } uint256 length = strategies.length(); StrategyDiff[] memory diffs = new StrategyDiff[](length); uint256 head; uint256 tail = length - 1; for (uint i; i < length; i++) { address strategy = strategies.at(i); if (ratios[strategy] == 0) { _clearStrategy(strategy, true); continue; } uint256 newPosition = (total * ratios[strategy]) / ONE_HUNDRED_PERCENT; uint256 position = getStrategyValidValue(strategy); if (newPosition < position) { diffs[head] = StrategyDiff( strategy, false, position - newPosition ); head++; } else if (newPosition > position) { diffs[tail] = StrategyDiff( strategy, true, newPosition - position ); if (tail != 0) { tail--; } } } length = diffs.length; for (uint256 i; i < length; i++) { StrategyDiff memory diff = diffs[i]; if (diff.amount == 0) { continue; } if (diff.isDeposit) { if (address(this).balance < diff.amount) { diff.amount = address(this).balance; } _depositToStrategy(diff.strategy, diff.amount); } else { _withdrawFromStrategy(diff.strategy, diff.amount); } } _repayToVault(); } function _repayToVault() internal { if (address(this).balance != 0) { TransferHelper.safeTransferETH(assetsVault, address(this).balance); } } function _depositToStrategy(address _strategy, uint256 _amount) internal { Strategy(_strategy).deposit{value: _amount}(); } function _withdrawFromStrategy( address _strategy, uint256 _amount ) internal { Strategy(_strategy).withdraw(_amount); } function _forceWithdraw( uint256 _amount ) internal returns (uint256 actualAmount) { uint256 length = strategies.length(); for (uint i; i < length; i++) { address strategy = strategies.at(i); uint256 withAmount = (_amount * ratios[strategy]) / ONE_HUNDRED_PERCENT; if (withAmount != 0) { actualAmount = Strategy(strategy).instantWithdraw(withAmount) + actualAmount; } } _repayToVault(); } function getStrategyValue( address _strategy ) public returns (uint256 _value) { return Strategy(_strategy).getAllValue(); } function getStrategyValidValue( address _strategy ) public returns (uint256 _value) { return Strategy(_strategy).getInvestedValue(); } function getStrategyPendingValue( address _strategy ) public returns (uint256 _value) { return Strategy(_strategy).getPendingValue(); } function getAllStrategiesValue() public returns (uint256 _value) { uint256 length = strategies.length(); for (uint i; i < length; i++) { _value = _value + getStrategyValue(strategies.at(i)); } } function getAllStrategyValidValue() public returns (uint256 _value) { uint256 length = strategies.length(); for (uint i; i < length; i++) { _value = _value + getStrategyValidValue(strategies.at(i)); } } function getAllStrategyPendingValue() public returns (uint256 _value) { uint256 length = strategies.length(); for (uint i; i < length; i++) { _value = _value + getStrategyPendingValue(strategies.at(i)); } } function getStrategies() public view returns (address[] memory addrs, uint256[] memory portions) { uint256 length = strategies.length(); addrs = new address[](length); portions = new uint256[](length); for (uint256 i; i < length; i++) { address addr = strategies.at(i); addrs[i] = addr; portions[i] = ratios[addr]; } } function _initStrategies( address[] memory _strategies, uint256[] memory _ratios ) internal { require(_strategies.length == _ratios.length, "invalid length"); uint256 totalRatio; uint256 length = _strategies.length; for (uint i; i < length; i++) { strategies.add(_strategies[i]); ratios[_strategies[i]] = _ratios[i]; totalRatio = totalRatio + _ratios[i]; } require(totalRatio <= ONE_HUNDRED_PERCENT, "exceed 100%"); } function _setStrategies( address[] memory _strategies, uint256[] memory _ratios ) internal { uint256 length = _strategies.length; require(length == _ratios.length, "invalid length"); uint256 oldLength = strategies.length(); for (uint i; i < oldLength; i++) { ratios[strategies.at(i)] = 0; } uint256 totalRatio; for (uint i; i < length; i++) { require( Strategy(_strategies[i]).controller() == address(this), "controller mismatch" ); strategies.add(_strategies[i]); ratios[_strategies[i]] = _ratios[i]; totalRatio = totalRatio + _ratios[i]; } require(totalRatio <= ONE_HUNDRED_PERCENT, "exceed 100%"); } function clearStrategy(address _strategy) public onlyVault { _clearStrategy(_strategy, false); } function _clearStrategy(address _strategy, bool _isRebase) internal { Strategy(_strategy).clear(); if (!_isRebase) { _repayToVault(); } } function _destoryStrategy(address _strategy) internal { require(_couldDestroyStrategy(_strategy), "still active"); strategies.remove(_strategy); _repayToVault(); } function _couldDestroyStrategy( address _strategy ) internal returns (bool status) { return ratios[_strategy] == 0 && Strategy(_strategy).getAllValue() < 1e4; } function setNewVault(address _vault) external onlyVault { stoneVault = _vault; } receive() external payable {} }
// SPDX-License-Identifier: MIT pragma solidity 0.8.21; import {StrategyController} from "../strategies/StrategyController.sol"; abstract contract Strategy { address payable public immutable controller; address public governance; string public name; modifier onlyGovernance() { require(governance == msg.sender, "not governace"); _; } event TransferGovernance(address oldOwner, address newOwner); constructor(address payable _controller, string memory _name) { require(_controller != address(0), "ZERO ADDRESS"); governance = msg.sender; controller = _controller; name = _name; } modifier onlyController() { require(controller == msg.sender, "not controller"); _; } function deposit() public payable virtual onlyController {} function withdraw( uint256 _amount ) public virtual onlyController returns (uint256 actualAmount) {} function instantWithdraw( uint256 _amount ) public virtual onlyController returns (uint256 actualAmount) {} function clear() public virtual onlyController returns (uint256 amount) {} function execPendingRequest( uint256 _amount ) public virtual returns (uint256 amount) {} function getAllValue() public virtual returns (uint256 value) {} function getPendingValue() public virtual returns (uint256 value) {} function getInvestedValue() public virtual returns (uint256 value) {} function checkPendingStatus() public virtual returns (uint256 pending, uint256 executable) {} function setGovernance(address governance_) external onlyGovernance { emit TransferGovernance(governance, governance_); governance = governance_; } }
// SPDX-License-Identifier: MIT pragma solidity 0.8.21; library VaultMath { uint256 internal constant DECIMALS = 18; function assetToShares( uint256 _assetAmount, uint256 _assetPerShare ) internal pure returns (uint256) { require(_assetPerShare > 1, "Vault Lib: invalid assetPerShare"); return (_assetAmount * (10 ** DECIMALS)) / _assetPerShare; } function sharesToAsset( uint256 _shares, uint256 _assetPerShare ) internal pure returns (uint256) { require(_assetPerShare > 1, "Vault Lib: invalid assetPerShare"); return (_shares * _assetPerShare) / (10 ** DECIMALS); } }
// SPDX-License-Identifier: MIT pragma solidity 0.8.21; import {TransferHelper} from "@uniswap/v3-periphery/contracts/libraries/TransferHelper.sol"; contract AssetsVault { address public stoneVault; address public strategyController; modifier onlyPermit() { require( stoneVault == msg.sender || strategyController == msg.sender, "not permit" ); _; } constructor(address _stoneVault, address _strategyController) { require( _stoneVault != address(0) && _strategyController != address(0), "ZERO ADDRESS" ); stoneVault = _stoneVault; strategyController = _strategyController; } function deposit() external payable { require(msg.value != 0, "too small"); } function withdraw(address _to, uint256 _amount) external onlyPermit { TransferHelper.safeTransferETH(_to, _amount); } function setNewVault(address _vault) external onlyPermit { stoneVault = _vault; } function getBalance() external view returns (uint256 amount) { amount = address(this).balance; } receive() external payable {} }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.6.0; import '@openzeppelin/contracts/token/ERC20/IERC20.sol'; library TransferHelper { /// @notice Transfers tokens from the targeted address to the given destination /// @notice Errors with 'STF' if transfer fails /// @param token The contract address of the token to be transferred /// @param from The originating address from which the tokens will be transferred /// @param to The destination address of the transfer /// @param value The amount to be transferred function safeTransferFrom( address token, address from, address to, uint256 value ) internal { (bool success, bytes memory data) = token.call(abi.encodeWithSelector(IERC20.transferFrom.selector, from, to, value)); require(success && (data.length == 0 || abi.decode(data, (bool))), 'STF'); } /// @notice Transfers tokens from msg.sender to a recipient /// @dev Errors with ST if transfer fails /// @param token The contract address of the token which will be transferred /// @param to The recipient of the transfer /// @param value The value of the transfer function safeTransfer( address token, address to, uint256 value ) internal { (bool success, bytes memory data) = token.call(abi.encodeWithSelector(IERC20.transfer.selector, to, value)); require(success && (data.length == 0 || abi.decode(data, (bool))), 'ST'); } /// @notice Approves the stipulated contract to spend the given allowance in the given token /// @dev Errors with 'SA' if transfer fails /// @param token The contract address of the token to be approved /// @param to The target of the approval /// @param value The amount of the given token the target will be allowed to spend function safeApprove( address token, address to, uint256 value ) internal { (bool success, bytes memory data) = token.call(abi.encodeWithSelector(IERC20.approve.selector, to, value)); require(success && (data.length == 0 || abi.decode(data, (bool))), 'SA'); } /// @notice Transfers ETH to the recipient address /// @dev Fails with `STE` /// @param to The destination of the transfer /// @param value The value to be transferred function safeTransferETH(address to, uint256 value) internal { (bool success, ) = to.call{value: value}(new bytes(0)); require(success, 'STE'); } }
// 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 EnumerableSet { // 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 v4.4.1 (utils/introspection/IERC165.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol) pragma solidity ^0.8.0; import "./IERC165.sol"; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` * * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. */ abstract contract ERC165 is IERC165 { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165).interfaceId; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol) pragma solidity ^0.8.0; import "../IERC20.sol"; /** * @dev Interface for the optional metadata functions from the ERC20 standard. * * _Available since v4.1._ */ interface IERC20Metadata is IERC20 { /** * @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); }
// 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 IERC20 { /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); /** * @dev Returns the 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: MIT // OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/ERC20.sol) pragma solidity ^0.8.0; import "./IERC20.sol"; import "./extensions/IERC20Metadata.sol"; import "../../utils/Context.sol"; /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * The default value of {decimals} is 18. To change this, you should override * this function so it returns a different value. * * We have followed general OpenZeppelin Contracts guidelines: functions revert * instead returning `false` on failure. This behavior is nonetheless * conventional and does not conflict with the expectations of ERC20 * applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */ contract ERC20 is Context, IERC20, IERC20Metadata { mapping(address => uint256) private _balances; mapping(address => mapping(address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; /** * @dev Sets the values for {name} and {symbol}. * * All two of these values are immutable: they can only be set once during * construction. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev Returns the name of the token. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5.05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the default value returned by this function, unless * it's overridden. * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual override returns (uint8) { return 18; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `to` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address to, uint256 amount) public virtual override returns (bool) { address owner = _msgSender(); _transfer(owner, to, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on * `transferFrom`. This is semantically equivalent to an infinite approval. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { address owner = _msgSender(); _approve(owner, spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * NOTE: Does not update the allowance if the current allowance * is the maximum `uint256`. * * Requirements: * * - `from` and `to` cannot be the zero address. * - `from` must have a balance of at least `amount`. * - the caller must have allowance for ``from``'s tokens of at least * `amount`. */ function transferFrom(address from, address to, uint256 amount) public virtual override returns (bool) { address spender = _msgSender(); _spendAllowance(from, spender, amount); _transfer(from, to, amount); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { address owner = _msgSender(); _approve(owner, spender, allowance(owner, spender) + addedValue); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { address owner = _msgSender(); uint256 currentAllowance = allowance(owner, spender); require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); unchecked { _approve(owner, spender, currentAllowance - subtractedValue); } return true; } /** * @dev Moves `amount` of tokens from `from` to `to`. * * This internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `from` must have a balance of at least `amount`. */ function _transfer(address from, address to, uint256 amount) internal virtual { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(from, to, amount); uint256 fromBalance = _balances[from]; require(fromBalance >= amount, "ERC20: transfer amount exceeds balance"); unchecked { _balances[from] = fromBalance - amount; // Overflow not possible: the sum of all balances is capped by totalSupply, and the sum is preserved by // decrementing then incrementing. _balances[to] += amount; } emit Transfer(from, to, amount); _afterTokenTransfer(from, to, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply += amount; unchecked { // Overflow not possible: balance + amount is at most totalSupply + amount, which is checked above. _balances[account] += amount; } emit Transfer(address(0), account, amount); _afterTokenTransfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); uint256 accountBalance = _balances[account]; require(accountBalance >= amount, "ERC20: burn amount exceeds balance"); unchecked { _balances[account] = accountBalance - amount; // Overflow not possible: amount <= accountBalance <= totalSupply. _totalSupply -= amount; } emit Transfer(account, address(0), amount); _afterTokenTransfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Updates `owner` s allowance for `spender` based on spent `amount`. * * Does not update the allowance amount in case of infinite allowance. * Revert if not enough allowance is available. * * Might emit an {Approval} event. */ function _spendAllowance(address owner, address spender, uint256 amount) internal virtual { uint256 currentAllowance = allowance(owner, spender); if (currentAllowance != type(uint256).max) { require(currentAllowance >= amount, "ERC20: insufficient allowance"); unchecked { _approve(owner, spender, currentAllowance - amount); } } } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual {} /** * @dev Hook that is called after any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * has been transferred to `to`. * - when `from` is zero, `amount` tokens have been minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens have been burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _afterTokenTransfer(address from, address to, uint256 amount) internal virtual {} }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (security/ReentrancyGuard.sol) pragma solidity ^0.8.0; /** * @dev Contract module that helps prevent reentrant calls to a function. * * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier * available, which can be applied to functions to make sure there are no nested * (reentrant) calls to them. * * Note that because there is a single `nonReentrant` guard, functions marked as * `nonReentrant` may not call one another. This can be worked around by making * those functions `private`, and then adding `external` `nonReentrant` entry * points to them. * * TIP: If you would like to learn more about reentrancy and alternative ways * to protect against it, check out our blog post * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul]. */ abstract contract ReentrancyGuard { // Booleans are more expensive than uint256 or any type that takes up a full // word because each write operation emits an extra SLOAD to first read the // slot's contents, replace the bits taken up by the boolean, and then write // back. This is the compiler's defense against contract upgrades and // pointer aliasing, and it cannot be disabled. // The values being non-zero value makes deployment a bit more expensive, // but in exchange the refund on every call to nonReentrant will be lower in // amount. Since refunds are capped to a percentage of the total // transaction's gas, it is best to keep them low in cases like this one, to // increase the likelihood of the full refund coming into effect. uint256 private constant _NOT_ENTERED = 1; uint256 private constant _ENTERED = 2; uint256 private _status; constructor() { _status = _NOT_ENTERED; } /** * @dev Prevents a contract from calling itself, directly or indirectly. * Calling a `nonReentrant` function from another `nonReentrant` * function is not supported. It is possible to prevent this from happening * by making the `nonReentrant` function external, and 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; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (access/Ownable.sol) pragma solidity ^0.8.0; import "../utils/Context.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _transferOwnership(_msgSender()); } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { _checkOwner(); _; } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if the sender is not the owner. */ function _checkOwner() internal view virtual { require(owner() == _msgSender(), "Ownable: caller is not the owner"); } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby disabling any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _transferOwnership(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } }
// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity >=0.7.6; library ExcessivelySafeCall { uint256 constant LOW_28_MASK = 0x00000000ffffffffffffffffffffffffffffffffffffffffffffffffffffffff; /// @notice Use when you _really_ really _really_ don't trust the called /// contract. This prevents the called contract from causing reversion of /// the caller in as many ways as we can. /// @dev The main difference between this and a solidity low-level call is /// that we limit the number of bytes that the callee can cause to be /// copied to caller memory. This prevents stupid things like malicious /// contracts returning 10,000,000 bytes causing a local OOG when copying /// to memory. /// @param _target The address to call /// @param _gas The amount of gas to forward to the remote contract /// @param _maxCopy The maximum number of bytes of returndata to copy /// to memory. /// @param _calldata The data to send to the remote contract /// @return success and returndata, as `.call()`. Returndata is capped to /// `_maxCopy` bytes. function excessivelySafeCall( address _target, uint256 _gas, uint16 _maxCopy, bytes memory _calldata ) internal returns (bool, bytes memory) { // set up for assembly call uint256 _toCopy; bool _success; bytes memory _returnData = new bytes(_maxCopy); // dispatch message to recipient // by assembly calling "handle" function // we call via assembly to avoid memcopying a very large returndata // returned by a malicious contract assembly { _success := call( _gas, // gas _target, // recipient 0, // ether value add(_calldata, 0x20), // inloc mload(_calldata), // inlen 0, // outloc 0 // outlen ) // limit our copy to 256 bytes _toCopy := returndatasize() if gt(_toCopy, _maxCopy) { _toCopy := _maxCopy } // Store the length of the copied bytes mstore(_returnData, _toCopy) // copy the bytes from returndata[0:_toCopy] returndatacopy(add(_returnData, 0x20), 0, _toCopy) } return (_success, _returnData); } /// @notice Use when you _really_ really _really_ don't trust the called /// contract. This prevents the called contract from causing reversion of /// the caller in as many ways as we can. /// @dev The main difference between this and a solidity low-level call is /// that we limit the number of bytes that the callee can cause to be /// copied to caller memory. This prevents stupid things like malicious /// contracts returning 10,000,000 bytes causing a local OOG when copying /// to memory. /// @param _target The address to call /// @param _gas The amount of gas to forward to the remote contract /// @param _maxCopy The maximum number of bytes of returndata to copy /// to memory. /// @param _calldata The data to send to the remote contract /// @return success and returndata, as `.call()`. Returndata is capped to /// `_maxCopy` bytes. function excessivelySafeStaticCall( address _target, uint256 _gas, uint16 _maxCopy, bytes memory _calldata ) internal view returns (bool, bytes memory) { // set up for assembly call uint256 _toCopy; bool _success; bytes memory _returnData = new bytes(_maxCopy); // dispatch message to recipient // by assembly calling "handle" function // we call via assembly to avoid memcopying a very large returndata // returned by a malicious contract assembly { _success := staticcall( _gas, // gas _target, // recipient add(_calldata, 0x20), // inloc mload(_calldata), // inlen 0, // outloc 0 // outlen ) // limit our copy to 256 bytes _toCopy := returndatasize() if gt(_toCopy, _maxCopy) { _toCopy := _maxCopy } // Store the length of the copied bytes mstore(_returnData, _toCopy) // copy the bytes from returndata[0:_toCopy] returndatacopy(add(_returnData, 0x20), 0, _toCopy) } return (_success, _returnData); } /** * @notice Swaps function selectors in encoded contract calls * @dev Allows reuse of encoded calldata for functions with identical * argument types but different names. It simply swaps out the first 4 bytes * for the new selector. This function modifies memory in place, and should * only be used with caution. * @param _newSelector The new 4-byte selector * @param _buf The encoded contract args */ function swapSelector(bytes4 _newSelector, bytes memory _buf) internal pure { require(_buf.length >= 4); uint256 _mask = LOW_28_MASK; assembly { // load the first word of let _word := mload(add(_buf, 0x20)) // mask out the top 4 bytes // /x _word := and(_word, _mask) _word := or(_newSelector, _word) mstore(add(_buf, 0x20), _word) } } }
// SPDX-License-Identifier: Unlicense /* * @title Solidity Bytes Arrays Utils * @author Gonçalo Sá <[email protected]> * * @dev Bytes tightly packed arrays utility library for ethereum contracts written in Solidity. * The library lets you concatenate, slice and type cast bytes arrays both in memory and storage. */ pragma solidity >=0.8.0 <0.9.0; library BytesLib { function concat( bytes memory _preBytes, bytes memory _postBytes ) internal pure returns (bytes memory) { bytes memory tempBytes; assembly { // Get a location of some free memory and store it in tempBytes as // Solidity does for memory variables. tempBytes := mload(0x40) // Store the length of the first bytes array at the beginning of // the memory for tempBytes. let length := mload(_preBytes) mstore(tempBytes, length) // Maintain a memory counter for the current write location in the // temp bytes array by adding the 32 bytes for the array length to // the starting location. let mc := add(tempBytes, 0x20) // Stop copying when the memory counter reaches the length of the // first bytes array. let end := add(mc, length) for { // Initialize a copy counter to the start of the _preBytes data, // 32 bytes into its memory. let cc := add(_preBytes, 0x20) } lt(mc, end) { // Increase both counters by 32 bytes each iteration. mc := add(mc, 0x20) cc := add(cc, 0x20) } { // Write the _preBytes data into the tempBytes memory 32 bytes // at a time. mstore(mc, mload(cc)) } // Add the length of _postBytes to the current length of tempBytes // and store it as the new length in the first 32 bytes of the // tempBytes memory. length := mload(_postBytes) mstore(tempBytes, add(length, mload(tempBytes))) // Move the memory counter back from a multiple of 0x20 to the // actual end of the _preBytes data. mc := end // Stop copying when the memory counter reaches the new combined // length of the arrays. end := add(mc, length) for { let cc := add(_postBytes, 0x20) } lt(mc, end) { mc := add(mc, 0x20) cc := add(cc, 0x20) } { mstore(mc, mload(cc)) } // Update the free-memory pointer by padding our last write location // to 32 bytes: add 31 bytes to the end of tempBytes to move to the // next 32 byte block, then round down to the nearest multiple of // 32. If the sum of the length of the two arrays is zero then add // one before rounding down to leave a blank 32 bytes (the length block with 0). mstore(0x40, and( add(add(end, iszero(add(length, mload(_preBytes)))), 31), not(31) // Round down to the nearest 32 bytes. )) } return tempBytes; } function concatStorage(bytes storage _preBytes, bytes memory _postBytes) internal { assembly { // Read the first 32 bytes of _preBytes storage, which is the length // of the array. (We don't need to use the offset into the slot // because arrays use the entire slot.) let fslot := sload(_preBytes.slot) // Arrays of 31 bytes or less have an even value in their slot, // while longer arrays have an odd value. The actual length is // the slot divided by two for odd values, and the lowest order // byte divided by two for even values. // If the slot is even, bitwise and the slot with 255 and divide by // two to get the length. If the slot is odd, bitwise and the slot // with -1 and divide by two. let slength := div(and(fslot, sub(mul(0x100, iszero(and(fslot, 1))), 1)), 2) let mlength := mload(_postBytes) let newlength := add(slength, mlength) // slength can contain both the length and contents of the array // if length < 32 bytes so let's prepare for that // v. http://solidity.readthedocs.io/en/latest/miscellaneous.html#layout-of-state-variables-in-storage switch add(lt(slength, 32), lt(newlength, 32)) case 2 { // Since the new array still fits in the slot, we just need to // update the contents of the slot. // uint256(bytes_storage) = uint256(bytes_storage) + uint256(bytes_memory) + new_length sstore( _preBytes.slot, // all the modifications to the slot are inside this // next block add( // we can just add to the slot contents because the // bytes we want to change are the LSBs fslot, add( mul( div( // load the bytes from memory mload(add(_postBytes, 0x20)), // zero all bytes to the right exp(0x100, sub(32, mlength)) ), // and now shift left the number of bytes to // leave space for the length in the slot exp(0x100, sub(32, newlength)) ), // increase length by the double of the memory // bytes length mul(mlength, 2) ) ) ) } case 1 { // The stored value fits in the slot, but the combined value // will exceed it. // get the keccak hash to get the contents of the array mstore(0x0, _preBytes.slot) let sc := add(keccak256(0x0, 0x20), div(slength, 32)) // save new length sstore(_preBytes.slot, add(mul(newlength, 2), 1)) // The contents of the _postBytes array start 32 bytes into // the structure. Our first read should obtain the `submod` // bytes that can fit into the unused space in the last word // of the stored array. To get this, we read 32 bytes starting // from `submod`, so the data we read overlaps with the array // contents by `submod` bytes. Masking the lowest-order // `submod` bytes allows us to add that value directly to the // stored value. let submod := sub(32, slength) let mc := add(_postBytes, submod) let end := add(_postBytes, mlength) let mask := sub(exp(0x100, submod), 1) sstore( sc, add( and( fslot, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00 ), and(mload(mc), mask) ) ) for { mc := add(mc, 0x20) sc := add(sc, 1) } lt(mc, end) { sc := add(sc, 1) mc := add(mc, 0x20) } { sstore(sc, mload(mc)) } mask := exp(0x100, sub(mc, end)) sstore(sc, mul(div(mload(mc), mask), mask)) } default { // get the keccak hash to get the contents of the array mstore(0x0, _preBytes.slot) // Start copying to the last used word of the stored array. let sc := add(keccak256(0x0, 0x20), div(slength, 32)) // save new length sstore(_preBytes.slot, add(mul(newlength, 2), 1)) // Copy over the first `submod` bytes of the new data as in // case 1 above. let slengthmod := mod(slength, 32) let mlengthmod := mod(mlength, 32) let submod := sub(32, slengthmod) let mc := add(_postBytes, submod) let end := add(_postBytes, mlength) let mask := sub(exp(0x100, submod), 1) sstore(sc, add(sload(sc), and(mload(mc), mask))) for { sc := add(sc, 1) mc := add(mc, 0x20) } lt(mc, end) { sc := add(sc, 1) mc := add(mc, 0x20) } { sstore(sc, mload(mc)) } mask := exp(0x100, sub(mc, end)) sstore(sc, mul(div(mload(mc), mask), mask)) } } } function slice( bytes memory _bytes, uint256 _start, uint256 _length ) internal pure returns (bytes memory) { require(_length + 31 >= _length, "slice_overflow"); require(_bytes.length >= _start + _length, "slice_outOfBounds"); bytes memory tempBytes; assembly { switch iszero(_length) case 0 { // Get a location of some free memory and store it in tempBytes as // Solidity does for memory variables. tempBytes := mload(0x40) // The first word of the slice result is potentially a partial // word read from the original array. To read it, we calculate // the length of that partial word and start copying that many // bytes into the array. The first word we copy will start with // data we don't care about, but the last `lengthmod` bytes will // land at the beginning of the contents of the new array. When // we're done copying, we overwrite the full first word with // the actual length of the slice. let lengthmod := and(_length, 31) // The multiplication in the next line is necessary // because when slicing multiples of 32 bytes (lengthmod == 0) // the following copy loop was copying the origin's length // and then ending prematurely not copying everything it should. let mc := add(add(tempBytes, lengthmod), mul(0x20, iszero(lengthmod))) let end := add(mc, _length) for { // The multiplication in the next line has the same exact purpose // as the one above. let cc := add(add(add(_bytes, lengthmod), mul(0x20, iszero(lengthmod))), _start) } lt(mc, end) { mc := add(mc, 0x20) cc := add(cc, 0x20) } { mstore(mc, mload(cc)) } mstore(tempBytes, _length) //update free-memory pointer //allocating the array padded to 32 bytes like the compiler does now mstore(0x40, and(add(mc, 31), not(31))) } //if we want a zero-length slice let's just return a zero-length array default { tempBytes := mload(0x40) //zero out the 32 bytes slice we are about to return //we need to do it because Solidity does not garbage collect mstore(tempBytes, 0) mstore(0x40, add(tempBytes, 0x20)) } } return tempBytes; } function toAddress(bytes memory _bytes, uint256 _start) internal pure returns (address) { require(_bytes.length >= _start + 20, "toAddress_outOfBounds"); address tempAddress; assembly { tempAddress := div(mload(add(add(_bytes, 0x20), _start)), 0x1000000000000000000000000) } return tempAddress; } function toUint8(bytes memory _bytes, uint256 _start) internal pure returns (uint8) { require(_bytes.length >= _start + 1 , "toUint8_outOfBounds"); uint8 tempUint; assembly { tempUint := mload(add(add(_bytes, 0x1), _start)) } return tempUint; } function toUint16(bytes memory _bytes, uint256 _start) internal pure returns (uint16) { require(_bytes.length >= _start + 2, "toUint16_outOfBounds"); uint16 tempUint; assembly { tempUint := mload(add(add(_bytes, 0x2), _start)) } return tempUint; } function toUint32(bytes memory _bytes, uint256 _start) internal pure returns (uint32) { require(_bytes.length >= _start + 4, "toUint32_outOfBounds"); uint32 tempUint; assembly { tempUint := mload(add(add(_bytes, 0x4), _start)) } return tempUint; } function toUint64(bytes memory _bytes, uint256 _start) internal pure returns (uint64) { require(_bytes.length >= _start + 8, "toUint64_outOfBounds"); uint64 tempUint; assembly { tempUint := mload(add(add(_bytes, 0x8), _start)) } return tempUint; } function toUint96(bytes memory _bytes, uint256 _start) internal pure returns (uint96) { require(_bytes.length >= _start + 12, "toUint96_outOfBounds"); uint96 tempUint; assembly { tempUint := mload(add(add(_bytes, 0xc), _start)) } return tempUint; } function toUint128(bytes memory _bytes, uint256 _start) internal pure returns (uint128) { require(_bytes.length >= _start + 16, "toUint128_outOfBounds"); uint128 tempUint; assembly { tempUint := mload(add(add(_bytes, 0x10), _start)) } return tempUint; } function toUint256(bytes memory _bytes, uint256 _start) internal pure returns (uint256) { require(_bytes.length >= _start + 32, "toUint256_outOfBounds"); uint256 tempUint; assembly { tempUint := mload(add(add(_bytes, 0x20), _start)) } return tempUint; } function toBytes32(bytes memory _bytes, uint256 _start) internal pure returns (bytes32) { require(_bytes.length >= _start + 32, "toBytes32_outOfBounds"); bytes32 tempBytes32; assembly { tempBytes32 := mload(add(add(_bytes, 0x20), _start)) } return tempBytes32; } function equal(bytes memory _preBytes, bytes memory _postBytes) internal pure returns (bool) { bool success = true; assembly { let length := mload(_preBytes) // if lengths don't match the arrays are not equal switch eq(length, mload(_postBytes)) case 1 { // cb is a circuit breaker in the for loop since there's // no said feature for inline assembly loops // cb = 1 - don't breaker // cb = 0 - break let cb := 1 let mc := add(_preBytes, 0x20) let end := add(mc, length) for { let cc := add(_postBytes, 0x20) // the next line is the loop condition: // while(uint256(mc < end) + cb == 2) } eq(add(lt(mc, end), cb), 2) { mc := add(mc, 0x20) cc := add(cc, 0x20) } { // if any of these checks fails then arrays are not equal if iszero(eq(mload(mc), mload(cc))) { // unsuccess: success := 0 cb := 0 } } } default { // unsuccess: success := 0 } } return success; } function equalStorage( bytes storage _preBytes, bytes memory _postBytes ) internal view returns (bool) { bool success = true; assembly { // we know _preBytes_offset is 0 let fslot := sload(_preBytes.slot) // Decode the length of the stored array like in concatStorage(). let slength := div(and(fslot, sub(mul(0x100, iszero(and(fslot, 1))), 1)), 2) let mlength := mload(_postBytes) // if lengths don't match the arrays are not equal switch eq(slength, mlength) case 1 { // slength can contain both the length and contents of the array // if length < 32 bytes so let's prepare for that // v. http://solidity.readthedocs.io/en/latest/miscellaneous.html#layout-of-state-variables-in-storage if iszero(iszero(slength)) { switch lt(slength, 32) case 1 { // blank the last byte which is the length fslot := mul(div(fslot, 0x100), 0x100) if iszero(eq(fslot, mload(add(_postBytes, 0x20)))) { // unsuccess: success := 0 } } default { // cb is a circuit breaker in the for loop since there's // no said feature for inline assembly loops // cb = 1 - don't breaker // cb = 0 - break let cb := 1 // get the keccak hash to get the contents of the array mstore(0x0, _preBytes.slot) let sc := keccak256(0x0, 0x20) let mc := add(_postBytes, 0x20) let end := add(mc, mlength) // the next line is the loop condition: // while(uint256(mc < end) + cb == 2) for {} eq(add(lt(mc, end), cb), 2) { sc := add(sc, 1) mc := add(mc, 0x20) } { if iszero(eq(sload(sc), mload(mc))) { // unsuccess: success := 0 cb := 0 } } } } } default { // unsuccess: success := 0 } } return success; } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../OFT.sol"; contract BasedOFT is OFT { constructor(string memory _name, string memory _symbol, address _lzEndpoint) OFT(_name, _symbol, _lzEndpoint) {} function circulatingSupply() public view virtual override returns (uint) { unchecked { return totalSupply() - balanceOf(address(this)); } } function _debitFrom(address _from, uint16, bytes memory, uint _amount) internal virtual override returns(uint) { address spender = _msgSender(); if (_from != spender) _spendAllowance(_from, spender, _amount); _transfer(_from, address(this), _amount); return _amount; } function _creditTo(uint16, address _toAddress, uint _amount) internal virtual override returns(uint) { _transfer(address(this), _toAddress, _amount); return _amount; } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../../lzApp/NonblockingLzApp.sol"; import "./IOFTCore.sol"; import "@openzeppelin/contracts/utils/introspection/ERC165.sol"; abstract contract OFTCore is NonblockingLzApp, ERC165, IOFTCore { using BytesLib for bytes; uint public constant NO_EXTRA_GAS = 0; // packet type uint16 public constant PT_SEND = 0; bool public useCustomAdapterParams; constructor(address _lzEndpoint) NonblockingLzApp(_lzEndpoint) {} function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IOFTCore).interfaceId || super.supportsInterface(interfaceId); } function estimateSendFee(uint16 _dstChainId, bytes calldata _toAddress, uint _amount, bool _useZro, bytes calldata _adapterParams) public view virtual override returns (uint nativeFee, uint zroFee) { // mock the payload for sendFrom() bytes memory payload = abi.encode(PT_SEND, _toAddress, _amount); return lzEndpoint.estimateFees(_dstChainId, address(this), payload, _useZro, _adapterParams); } function sendFrom(address _from, uint16 _dstChainId, bytes calldata _toAddress, uint _amount, address payable _refundAddress, address _zroPaymentAddress, bytes calldata _adapterParams) public payable virtual override { _send(_from, _dstChainId, _toAddress, _amount, _refundAddress, _zroPaymentAddress, _adapterParams); } function setUseCustomAdapterParams(bool _useCustomAdapterParams) public virtual onlyOwner { useCustomAdapterParams = _useCustomAdapterParams; emit SetUseCustomAdapterParams(_useCustomAdapterParams); } function _nonblockingLzReceive(uint16 _srcChainId, bytes memory _srcAddress, uint64 _nonce, bytes memory _payload) internal virtual override { uint16 packetType; assembly { packetType := mload(add(_payload, 32)) } if (packetType == PT_SEND) { _sendAck(_srcChainId, _srcAddress, _nonce, _payload); } else { revert("OFTCore: unknown packet type"); } } function _send(address _from, uint16 _dstChainId, bytes memory _toAddress, uint _amount, address payable _refundAddress, address _zroPaymentAddress, bytes memory _adapterParams) internal virtual { _checkAdapterParams(_dstChainId, PT_SEND, _adapterParams, NO_EXTRA_GAS); uint amount = _debitFrom(_from, _dstChainId, _toAddress, _amount); bytes memory lzPayload = abi.encode(PT_SEND, _toAddress, amount); _lzSend(_dstChainId, lzPayload, _refundAddress, _zroPaymentAddress, _adapterParams, msg.value); emit SendToChain(_dstChainId, _from, _toAddress, amount); } function _sendAck(uint16 _srcChainId, bytes memory, uint64, bytes memory _payload) internal virtual { (, bytes memory toAddressBytes, uint amount) = abi.decode(_payload, (uint16, bytes, uint)); address to = toAddressBytes.toAddress(0); amount = _creditTo(_srcChainId, to, amount); emit ReceiveFromChain(_srcChainId, to, amount); } function _checkAdapterParams(uint16 _dstChainId, uint16 _pkType, bytes memory _adapterParams, uint _extraGas) internal virtual { if (useCustomAdapterParams) { _checkGasLimit(_dstChainId, _pkType, _adapterParams, _extraGas); } else { require(_adapterParams.length == 0, "OFTCore: _adapterParams must be empty."); } } function _debitFrom(address _from, uint16 _dstChainId, bytes memory _toAddress, uint _amount) internal virtual returns(uint); function _creditTo(uint16 _srcChainId, address _toAddress, uint _amount) internal virtual returns(uint); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import "@openzeppelin/contracts/utils/introspection/IERC165.sol"; import "./IOFT.sol"; import "./OFTCore.sol"; // override decimal() function is needed contract OFT is OFTCore, ERC20, IOFT { constructor(string memory _name, string memory _symbol, address _lzEndpoint) ERC20(_name, _symbol) OFTCore(_lzEndpoint) {} function supportsInterface(bytes4 interfaceId) public view virtual override(OFTCore, IERC165) returns (bool) { return interfaceId == type(IOFT).interfaceId || interfaceId == type(IERC20).interfaceId || super.supportsInterface(interfaceId); } function token() public view virtual override returns (address) { return address(this); } function circulatingSupply() public view virtual override returns (uint) { return totalSupply(); } function _debitFrom(address _from, uint16, bytes memory, uint _amount) internal virtual override returns(uint) { address spender = _msgSender(); if (_from != spender) _spendAllowance(_from, spender, _amount); _burn(_from, _amount); return _amount; } function _creditTo(uint16, address _toAddress, uint _amount) internal virtual override returns(uint) { _mint(_toAddress, _amount); return _amount; } }
// SPDX-License-Identifier: MIT pragma solidity >=0.5.0; import "@openzeppelin/contracts/utils/introspection/IERC165.sol"; /** * @dev Interface of the IOFT core standard */ interface IOFTCore is IERC165 { /** * @dev estimate send token `_tokenId` to (`_dstChainId`, `_toAddress`) * _dstChainId - L0 defined chain id to send tokens too * _toAddress - dynamic bytes array which contains the address to whom you are sending tokens to on the dstChain * _amount - amount of the tokens to transfer * _useZro - indicates to use zro to pay L0 fees * _adapterParam - flexible bytes array to indicate messaging adapter services in L0 */ function estimateSendFee(uint16 _dstChainId, bytes calldata _toAddress, uint _amount, bool _useZro, bytes calldata _adapterParams) external view returns (uint nativeFee, uint zroFee); /** * @dev send `_amount` amount of token to (`_dstChainId`, `_toAddress`) from `_from` * `_from` the owner of token * `_dstChainId` the destination chain identifier * `_toAddress` can be any size depending on the `dstChainId`. * `_amount` the quantity of tokens in wei * `_refundAddress` the address LayerZero refunds if too much message fee is sent * `_zroPaymentAddress` set to address(0x0) if not paying in ZRO (LayerZero Token) * `_adapterParams` is a flexible bytes array to indicate messaging adapter services */ function sendFrom(address _from, uint16 _dstChainId, bytes calldata _toAddress, uint _amount, address payable _refundAddress, address _zroPaymentAddress, bytes calldata _adapterParams) external payable; /** * @dev returns the circulating amount of tokens on current chain */ function circulatingSupply() external view returns (uint); /** * @dev returns the address of the ERC20 token */ function token() external view returns (address); /** * @dev Emitted when `_amount` tokens are moved from the `_sender` to (`_dstChainId`, `_toAddress`) * `_nonce` is the outbound nonce */ event SendToChain(uint16 indexed _dstChainId, address indexed _from, bytes _toAddress, uint _amount); /** * @dev Emitted when `_amount` tokens are received from `_srcChainId` into the `_toAddress` on the local chain. * `_nonce` is the inbound nonce. */ event ReceiveFromChain(uint16 indexed _srcChainId, address indexed _to, uint _amount); event SetUseCustomAdapterParams(bool _useCustomAdapterParams); }
// SPDX-License-Identifier: MIT pragma solidity >=0.5.0; import "./IOFTCore.sol"; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; /** * @dev Interface of the OFT standard */ interface IOFT is IOFTCore, IERC20 { }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./LzApp.sol"; import "../util/ExcessivelySafeCall.sol"; /* * the default LayerZero messaging behaviour is blocking, i.e. any failed message will block the channel * this abstract class try-catch all fail messages and store locally for future retry. hence, non-blocking * NOTE: if the srcAddress is not configured properly, it will still block the message pathway from (srcChainId, srcAddress) */ abstract contract NonblockingLzApp is LzApp { using ExcessivelySafeCall for address; constructor(address _endpoint) LzApp(_endpoint) {} mapping(uint16 => mapping(bytes => mapping(uint64 => bytes32))) public failedMessages; event MessageFailed(uint16 _srcChainId, bytes _srcAddress, uint64 _nonce, bytes _payload, bytes _reason); event RetryMessageSuccess(uint16 _srcChainId, bytes _srcAddress, uint64 _nonce, bytes32 _payloadHash); // overriding the virtual function in LzReceiver function _blockingLzReceive(uint16 _srcChainId, bytes memory _srcAddress, uint64 _nonce, bytes memory _payload) internal virtual override { (bool success, bytes memory reason) = address(this).excessivelySafeCall(gasleft(), 150, abi.encodeWithSelector(this.nonblockingLzReceive.selector, _srcChainId, _srcAddress, _nonce, _payload)); // try-catch all errors/exceptions if (!success) { _storeFailedMessage(_srcChainId, _srcAddress, _nonce, _payload, reason); } } function _storeFailedMessage(uint16 _srcChainId, bytes memory _srcAddress, uint64 _nonce, bytes memory _payload, bytes memory _reason) internal virtual { failedMessages[_srcChainId][_srcAddress][_nonce] = keccak256(_payload); emit MessageFailed(_srcChainId, _srcAddress, _nonce, _payload, _reason); } function nonblockingLzReceive(uint16 _srcChainId, bytes calldata _srcAddress, uint64 _nonce, bytes calldata _payload) public virtual { // only internal transaction require(_msgSender() == address(this), "NonblockingLzApp: caller must be LzApp"); _nonblockingLzReceive(_srcChainId, _srcAddress, _nonce, _payload); } //@notice override this function function _nonblockingLzReceive(uint16 _srcChainId, bytes memory _srcAddress, uint64 _nonce, bytes memory _payload) internal virtual; function retryMessage(uint16 _srcChainId, bytes calldata _srcAddress, uint64 _nonce, bytes calldata _payload) public payable virtual { // assert there is message to retry bytes32 payloadHash = failedMessages[_srcChainId][_srcAddress][_nonce]; require(payloadHash != bytes32(0), "NonblockingLzApp: no stored message"); require(keccak256(_payload) == payloadHash, "NonblockingLzApp: invalid payload"); // clear the stored message failedMessages[_srcChainId][_srcAddress][_nonce] = bytes32(0); // execute the message. revert if it fails again _nonblockingLzReceive(_srcChainId, _srcAddress, _nonce, _payload); emit RetryMessageSuccess(_srcChainId, _srcAddress, _nonce, payloadHash); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@openzeppelin/contracts/access/Ownable.sol"; import "../interfaces/ILayerZeroReceiver.sol"; import "../interfaces/ILayerZeroUserApplicationConfig.sol"; import "../interfaces/ILayerZeroEndpoint.sol"; import "../util/BytesLib.sol"; /* * a generic LzReceiver implementation */ abstract contract LzApp is Ownable, ILayerZeroReceiver, ILayerZeroUserApplicationConfig { using BytesLib for bytes; // ua can not send payload larger than this by default, but it can be changed by the ua owner uint constant public DEFAULT_PAYLOAD_SIZE_LIMIT = 10000; ILayerZeroEndpoint public immutable lzEndpoint; mapping(uint16 => bytes) public trustedRemoteLookup; mapping(uint16 => mapping(uint16 => uint)) public minDstGasLookup; mapping(uint16 => uint) public payloadSizeLimitLookup; address public precrime; event SetPrecrime(address precrime); event SetTrustedRemote(uint16 _remoteChainId, bytes _path); event SetTrustedRemoteAddress(uint16 _remoteChainId, bytes _remoteAddress); event SetMinDstGas(uint16 _dstChainId, uint16 _type, uint _minDstGas); constructor(address _endpoint) { lzEndpoint = ILayerZeroEndpoint(_endpoint); } function lzReceive(uint16 _srcChainId, bytes calldata _srcAddress, uint64 _nonce, bytes calldata _payload) public virtual override { // lzReceive must be called by the endpoint for security require(_msgSender() == address(lzEndpoint), "LzApp: invalid endpoint caller"); bytes memory trustedRemote = trustedRemoteLookup[_srcChainId]; // if will still block the message pathway from (srcChainId, srcAddress). should not receive message from untrusted remote. require(_srcAddress.length == trustedRemote.length && trustedRemote.length > 0 && keccak256(_srcAddress) == keccak256(trustedRemote), "LzApp: invalid source sending contract"); _blockingLzReceive(_srcChainId, _srcAddress, _nonce, _payload); } // abstract function - the default behaviour of LayerZero is blocking. See: NonblockingLzApp if you dont need to enforce ordered messaging function _blockingLzReceive(uint16 _srcChainId, bytes memory _srcAddress, uint64 _nonce, bytes memory _payload) internal virtual; function _lzSend(uint16 _dstChainId, bytes memory _payload, address payable _refundAddress, address _zroPaymentAddress, bytes memory _adapterParams, uint _nativeFee) internal virtual { bytes memory trustedRemote = trustedRemoteLookup[_dstChainId]; require(trustedRemote.length != 0, "LzApp: destination chain is not a trusted source"); _checkPayloadSize(_dstChainId, _payload.length); lzEndpoint.send{value: _nativeFee}(_dstChainId, trustedRemote, _payload, _refundAddress, _zroPaymentAddress, _adapterParams); } function _checkGasLimit(uint16 _dstChainId, uint16 _type, bytes memory _adapterParams, uint _extraGas) internal view virtual { uint providedGasLimit = _getGasLimit(_adapterParams); uint minGasLimit = minDstGasLookup[_dstChainId][_type] + _extraGas; require(minGasLimit > 0, "LzApp: minGasLimit not set"); require(providedGasLimit >= minGasLimit, "LzApp: gas limit is too low"); } function _getGasLimit(bytes memory _adapterParams) internal pure virtual returns (uint gasLimit) { require(_adapterParams.length >= 34, "LzApp: invalid adapterParams"); assembly { gasLimit := mload(add(_adapterParams, 34)) } } function _checkPayloadSize(uint16 _dstChainId, uint _payloadSize) internal view virtual { uint payloadSizeLimit = payloadSizeLimitLookup[_dstChainId]; if (payloadSizeLimit == 0) { // use default if not set payloadSizeLimit = DEFAULT_PAYLOAD_SIZE_LIMIT; } require(_payloadSize <= payloadSizeLimit, "LzApp: payload size is too large"); } //---------------------------UserApplication config---------------------------------------- function getConfig(uint16 _version, uint16 _chainId, address, uint _configType) external view returns (bytes memory) { return lzEndpoint.getConfig(_version, _chainId, address(this), _configType); } // generic config for LayerZero user Application function setConfig(uint16 _version, uint16 _chainId, uint _configType, bytes calldata _config) external override onlyOwner { lzEndpoint.setConfig(_version, _chainId, _configType, _config); } function setSendVersion(uint16 _version) external override onlyOwner { lzEndpoint.setSendVersion(_version); } function setReceiveVersion(uint16 _version) external override onlyOwner { lzEndpoint.setReceiveVersion(_version); } function forceResumeReceive(uint16 _srcChainId, bytes calldata _srcAddress) external override onlyOwner { lzEndpoint.forceResumeReceive(_srcChainId, _srcAddress); } // _path = abi.encodePacked(remoteAddress, localAddress) // this function set the trusted path for the cross-chain communication function setTrustedRemote(uint16 _remoteChainId, bytes calldata _path) external onlyOwner { trustedRemoteLookup[_remoteChainId] = _path; emit SetTrustedRemote(_remoteChainId, _path); } function setTrustedRemoteAddress(uint16 _remoteChainId, bytes calldata _remoteAddress) external onlyOwner { trustedRemoteLookup[_remoteChainId] = abi.encodePacked(_remoteAddress, address(this)); emit SetTrustedRemoteAddress(_remoteChainId, _remoteAddress); } function getTrustedRemoteAddress(uint16 _remoteChainId) external view returns (bytes memory) { bytes memory path = trustedRemoteLookup[_remoteChainId]; require(path.length != 0, "LzApp: no trusted path record"); return path.slice(0, path.length - 20); // the last 20 bytes should be address(this) } function setPrecrime(address _precrime) external onlyOwner { precrime = _precrime; emit SetPrecrime(_precrime); } function setMinDstGas(uint16 _dstChainId, uint16 _packetType, uint _minGas) external onlyOwner { require(_minGas > 0, "LzApp: invalid minGas"); minDstGasLookup[_dstChainId][_packetType] = _minGas; emit SetMinDstGas(_dstChainId, _packetType, _minGas); } // if the size is 0, it means default size limit function setPayloadSizeLimit(uint16 _dstChainId, uint _size) external onlyOwner { payloadSizeLimitLookup[_dstChainId] = _size; } //--------------------------- VIEW FUNCTION ---------------------------------------- function isTrustedRemote(uint16 _srcChainId, bytes calldata _srcAddress) external view returns (bool) { bytes memory trustedSource = trustedRemoteLookup[_srcChainId]; return keccak256(trustedSource) == keccak256(_srcAddress); } }
// SPDX-License-Identifier: MIT pragma solidity >=0.5.0; interface ILayerZeroUserApplicationConfig { // @notice set the configuration of the LayerZero messaging library of the specified version // @param _version - messaging library version // @param _chainId - the chainId for the pending config change // @param _configType - type of configuration. every messaging library has its own convention. // @param _config - configuration in the bytes. can encode arbitrary content. function setConfig(uint16 _version, uint16 _chainId, uint _configType, bytes calldata _config) external; // @notice set the send() LayerZero messaging library version to _version // @param _version - new messaging library version function setSendVersion(uint16 _version) external; // @notice set the lzReceive() LayerZero messaging library version to _version // @param _version - new messaging library version function setReceiveVersion(uint16 _version) external; // @notice Only when the UA needs to resume the message flow in blocking mode and clear the stored payload // @param _srcChainId - the chainId of the source chain // @param _srcAddress - the contract address of the source contract at the source chain function forceResumeReceive(uint16 _srcChainId, bytes calldata _srcAddress) external; }
// SPDX-License-Identifier: MIT pragma solidity >=0.5.0; interface ILayerZeroReceiver { // @notice LayerZero endpoint will invoke this function to deliver the message on the destination // @param _srcChainId - the source endpoint identifier // @param _srcAddress - the source sending contract address from the source chain // @param _nonce - the ordered message nonce // @param _payload - the signed payload is the UA bytes has encoded to be sent function lzReceive(uint16 _srcChainId, bytes calldata _srcAddress, uint64 _nonce, bytes calldata _payload) external; }
// SPDX-License-Identifier: MIT pragma solidity >=0.5.0; import "./ILayerZeroUserApplicationConfig.sol"; interface ILayerZeroEndpoint is ILayerZeroUserApplicationConfig { // @notice send a LayerZero message to the specified address at a LayerZero endpoint. // @param _dstChainId - the destination chain identifier // @param _destination - the address on destination chain (in bytes). address length/format may vary by chains // @param _payload - a custom bytes payload to send to the destination contract // @param _refundAddress - if the source transaction is cheaper than the amount of value passed, refund the additional amount to this address // @param _zroPaymentAddress - the address of the ZRO token holder who would pay for the transaction // @param _adapterParams - parameters for custom functionality. e.g. receive airdropped native gas from the relayer on destination function send(uint16 _dstChainId, bytes calldata _destination, bytes calldata _payload, address payable _refundAddress, address _zroPaymentAddress, bytes calldata _adapterParams) external payable; // @notice used by the messaging library to publish verified payload // @param _srcChainId - the source chain identifier // @param _srcAddress - the source contract (as bytes) at the source chain // @param _dstAddress - the address on destination chain // @param _nonce - the unbound message ordering nonce // @param _gasLimit - the gas limit for external contract execution // @param _payload - verified payload to send to the destination contract function receivePayload(uint16 _srcChainId, bytes calldata _srcAddress, address _dstAddress, uint64 _nonce, uint _gasLimit, bytes calldata _payload) external; // @notice get the inboundNonce of a lzApp from a source chain which could be EVM or non-EVM chain // @param _srcChainId - the source chain identifier // @param _srcAddress - the source chain contract address function getInboundNonce(uint16 _srcChainId, bytes calldata _srcAddress) external view returns (uint64); // @notice get the outboundNonce from this source chain which, consequently, is always an EVM // @param _srcAddress - the source chain contract address function getOutboundNonce(uint16 _dstChainId, address _srcAddress) external view returns (uint64); // @notice gets a quote in source native gas, for the amount that send() requires to pay for message delivery // @param _dstChainId - the destination chain identifier // @param _userApplication - the user app address on this EVM chain // @param _payload - the custom message to send over LayerZero // @param _payInZRO - if false, user app pays the protocol fee in native token // @param _adapterParam - parameters for the adapter service, e.g. send some dust native token to dstChain function estimateFees(uint16 _dstChainId, address _userApplication, bytes calldata _payload, bool _payInZRO, bytes calldata _adapterParam) external view returns (uint nativeFee, uint zroFee); // @notice get this Endpoint's immutable source identifier function getChainId() external view returns (uint16); // @notice the interface to retry failed message on this Endpoint destination // @param _srcChainId - the source chain identifier // @param _srcAddress - the source chain contract address // @param _payload - the payload to be retried function retryPayload(uint16 _srcChainId, bytes calldata _srcAddress, bytes calldata _payload) external; // @notice query if any STORED payload (message blocking) at the endpoint. // @param _srcChainId - the source chain identifier // @param _srcAddress - the source chain contract address function hasStoredPayload(uint16 _srcChainId, bytes calldata _srcAddress) external view returns (bool); // @notice query if the _libraryAddress is valid for sending msgs. // @param _userApplication - the user app address on this EVM chain function getSendLibraryAddress(address _userApplication) external view returns (address); // @notice query if the _libraryAddress is valid for receiving msgs. // @param _userApplication - the user app address on this EVM chain function getReceiveLibraryAddress(address _userApplication) external view returns (address); // @notice query if the non-reentrancy guard for send() is on // @return true if the guard is on. false otherwise function isSendingPayload() external view returns (bool); // @notice query if the non-reentrancy guard for receive() is on // @return true if the guard is on. false otherwise function isReceivingPayload() external view returns (bool); // @notice get the configuration of the LayerZero messaging library of the specified version // @param _version - messaging library version // @param _chainId - the chainId for the pending config change // @param _userApplication - the contract address of the user application // @param _configType - type of configuration. every messaging library has its own convention. function getConfig(uint16 _version, uint16 _chainId, address _userApplication, uint _configType) external view returns (bytes memory); // @notice get the send() LayerZero messaging library version // @param _userApplication - the contract address of the user application function getSendVersion(address _userApplication) external view returns (uint16); // @notice get the lzReceive() LayerZero messaging library version // @param _userApplication - the contract address of the user application function getReceiveVersion(address _userApplication) external view returns (uint16); }
{ "remappings": [], "optimizer": { "enabled": true, "runs": 10 }, "evmVersion": "shanghai", "libraries": {}, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } } }
Contract Security Audit
- Quantstamp - July 13th, 2024 - Security Audit Report
Contract ABI
API[{"inputs":[{"internalType":"address","name":"_minter","type":"address"},{"internalType":"address","name":"_proposal","type":"address"},{"internalType":"address payable","name":"_assetsVault","type":"address"},{"internalType":"address[]","name":"_strategies","type":"address[]"},{"internalType":"uint256[]","name":"_ratios","type":"uint256[]"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"round","type":"uint256"}],"name":"CancelWithdraw","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"mint","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"round","type":"uint256"}],"name":"Deposit","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"FeeCharged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"uint256","name":"shares","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"round","type":"uint256"}],"name":"InitiateWithdraw","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address[]","name":"strategies","type":"address[]"},{"indexed":false,"internalType":"uint256[]","name":"ratios","type":"uint256[]"}],"name":"PortfolioConfigUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"round","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"vaultIn","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"vaultOut","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"sharePrice","type":"uint256"}],"name":"RollToNextRound","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"oldAddr","type":"address"},{"indexed":false,"internalType":"address","name":"newAddr","type":"address"}],"name":"SetFeeRecipient","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"interval","type":"uint256"}],"name":"SetRebaseInterval","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"oldRate","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newRate","type":"uint256"}],"name":"SetWithdrawFeeRate","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"strategy","type":"address"}],"name":"StragetyAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"strategy","type":"address"}],"name":"StragetyCleared","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"strategy","type":"address"}],"name":"StragetyDestroyed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"round","type":"uint256"}],"name":"Withdrawn","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"actualAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"round","type":"uint256"}],"name":"WithdrawnFromStrategy","type":"event"},{"inputs":[],"name":"VERSION","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_strategy","type":"address"}],"name":"addStrategy","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"assetsVault","outputs":[{"internalType":"address payable","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_shares","type":"uint256"}],"name":"cancelWithdraw","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_strategy","type":"address"}],"name":"clearStrategy","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"currentSharePrice","outputs":[{"internalType":"uint256","name":"price","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"deposit","outputs":[{"internalType":"uint256","name":"mintAmount","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"}],"name":"depositFor","outputs":[{"internalType":"uint256","name":"mintAmount","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"_strategy","type":"address"}],"name":"destroyStrategy","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"feeRecipient","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getVaultAvailableAmount","outputs":[{"internalType":"uint256","name":"idleAmount","type":"uint256"},{"internalType":"uint256","name":"investedAmount","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"uint256","name":"_shares","type":"uint256"}],"name":"instantWithdraw","outputs":[{"internalType":"uint256","name":"actualWithdrawn","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"latestRoundID","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_vault","type":"address"}],"name":"migrateVault","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"minter","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"proposal","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"rebaseTime","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"rebaseTimeInterval","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_shares","type":"uint256"}],"name":"requestWithdraw","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"rollToNextRound","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"roundPricePerShare","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_feeRecipient","type":"address"}],"name":"setFeeRecipient","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_interval","type":"uint256"}],"name":"setRebaseInterval","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_withdrawFeeRate","type":"uint256"}],"name":"setWithdrawFeeRate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"settlementTime","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"stone","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"strategyController","outputs":[{"internalType":"address payable","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"_strategies","type":"address[]"},{"internalType":"uint256[]","name":"_ratios","type":"uint256[]"}],"name":"updatePortfolioConfig","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_proposal","type":"address"}],"name":"updateProposal","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"userReceipts","outputs":[{"internalType":"uint256","name":"withdrawRound","type":"uint256"},{"internalType":"uint256","name":"withdrawShares","type":"uint256"},{"internalType":"uint256","name":"withdrawableAmount","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"withdrawFeeRate","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"withdrawableAmountInPast","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"withdrawingSharesInPast","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"withdrawingSharesInRound","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"stateMutability":"payable","type":"receive"}]
Contract Creation Code
6101006040526201518060025534801562000018575f80fd5b5060405162004d2538038062004d258339810160408190526200003b91620003b3565b60015f556200004a3362000260565b6001600160a01b038516158015906200006b57506001600160a01b03841615155b80156200008057506001600160a01b03831615155b620000a85760405162461bcd60e51b81526004016200009f90620004bf565b60405180910390fd5b81515f5b818110156200011a575f6001600160a01b0316848281518110620000d457620000d4620004e5565b60200260200101516001600160a01b031603620001055760405162461bcd60e51b81526004016200009f90620004bf565b806200011181620004f9565b915050620000ac565b506001600160a01b03808716608052600380548783166001600160a01b03199182161790915590851660e05260048054909116331790556040515f908590859085906200016790620002b1565b62000175939291906200051e565b604051809103905ff0801580156200018f573d5f803e3d5ffd5b509050806001600160a01b031660c0816001600160a01b031681525050866001600160a01b0316630167eb856040518163ffffffff1660e01b8152600401602060405180830381865afa158015620001e9573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906200020f9190620005b4565b6001600160a01b031660a05250505f808052600b602052670de0b6b3a76400007fdf7de25b7f1fd6d0b5205f0e18f1f35bd7b8d84cce336588d184533ce43a6f765560055550620005d99350505050565b600180546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0905f90a35050565b611d1f806200300683390190565b6001600160a01b0381168114620002d4575f80fd5b50565b634e487b7160e01b5f52604160045260245ffd5b604051601f8201601f191681016001600160401b0381118282101715620003165762000316620002d7565b604052919050565b5f6001600160401b03821115620003395762000339620002d7565b5060051b60200190565b5f82601f83011262000353575f80fd5b815160206200036c62000366836200031e565b620002eb565b82815260059290921b840181019181810190868411156200038b575f80fd5b8286015b84811015620003a857805183529183019183016200038f565b509695505050505050565b5f805f805f60a08688031215620003c8575f80fd5b8551620003d581620002bf565b80955050602080870151620003ea81620002bf565b6040880151909550620003fd81620002bf565b60608801519094506001600160401b03808211156200041a575f80fd5b818901915089601f8301126200042e575f80fd5b81516200043f62000366826200031e565b81815260059190911b8301840190848101908c8311156200045e575f80fd5b938501935b82851015620004895784516200047981620002bf565b8252938501939085019062000463565b60808c01519097509450505080831115620004a2575f80fd5b5050620004b28882890162000343565b9150509295509295909350565b6020808252600c908201526b5a45524f204144445245535360a01b604082015260600190565b634e487b7160e01b5f52603260045260245ffd5b5f600182016200051757634e487b7160e01b5f52601160045260245ffd5b5060010190565b6001600160a01b0384811682526060602080840182905285519184018290525f92868201929091906080860190855b818110156200056d5785518516835294830194918301916001016200054d565b505085810360408701528651808252908201935091508086015f5b83811015620005a65781518552938201939082019060010162000588565b509298975050505050505050565b5f60208284031215620005c5575f80fd5b8151620005d281620002bf565b9392505050565b60805160a05160c05160e051612958620006ae5f395f81816104390152818161087f01528181610a9d01528181610bdb015281816112d601528181611630015261230401525f81816101c701528181610720015281816108f801528181610a1c01528181610bba01528181610e9301528181611236015281816113d2015281816119400152611e3a01525f81816102100152818161096301528181610fb101528181611097015261154c01525f81816102430152818161080801528181610fd301528181611651015261238601526129585ff3fe6080604052600436106101ab575f3560e01c8062258d6b146101b65780630167eb85146101ff5780630754617214610232578063096015b014610265578063223e54791461028657806324f3082a146102a55780632712b539146102c857806328a79576146102e75780633c49fc0f146102fb57806346904840146103265780635069fb571461034557806351b77fb31461035957806360e760d51461036e578063715018a6146103835780637155133614610397578063717dd445146103ac578063745400c9146103cb578063753ec103146103ea578063768aac5d146104095780637b0c1f291461042857806382f1631f1461045b57806387153eb11461047d5780638da5cb5b146104a85780639f01f7ba146104bc578063a4786f3d146104db578063aa67c91914610524578063b18f2e9114610537578063d0e30db014610556578063e74b981b1461055e578063e8ac623a1461057d578063ea99e6891461059c578063ef037fb9146105b1578063f2fde38b146105d0578063f76339dc146105ef578063fccbebf514610604578063fe73511714610623578063ffa1ad7414610638575f80fd5b366101b257005b5f80fd5b3480156101c1575f80fd5b506101e97f000000000000000000000000000000000000000000000000000000000000000081565b6040516101f6919061243c565b60405180910390f35b34801561020a575f80fd5b506101e97f000000000000000000000000000000000000000000000000000000000000000081565b34801561023d575f80fd5b506101e97f000000000000000000000000000000000000000000000000000000000000000081565b348015610270575f80fd5b5061028461027f366004612450565b61064c565b005b348015610291575f80fd5b506102846102a036600461247d565b6106e7565b3480156102b0575f80fd5b506102ba600a5481565b6040519081526020016101f6565b3480156102d3575f80fd5b506102846102e236600461247d565b6107c7565b3480156102f2575f80fd5b506102ba61095f565b348015610306575f80fd5b506102ba610315366004612450565b600c6020525f908152604090205481565b348015610331575f80fd5b506004546101e9906001600160a01b031681565b348015610350575f80fd5b50610284610b68565b348015610364575f80fd5b506102ba60075481565b348015610379575f80fd5b506102ba60085481565b34801561038e575f80fd5b50610284610e69565b3480156103a2575f80fd5b506102ba60025481565b3480156103b7575f80fd5b506102846103c636600461247d565b610e7c565b3480156103d6575f80fd5b506102846103e5366004612450565b610f2e565b3480156103f5575f80fd5b506003546101e9906001600160a01b031681565b348015610414575f80fd5b5061028461042336600461247d565b61121f565b348015610433575f80fd5b506101e97f000000000000000000000000000000000000000000000000000000000000000081565b348015610466575f80fd5b5061046f6112d1565b6040516101f6929190612496565b348015610488575f80fd5b506102ba610497366004612450565b600b6020525f908152604090205481565b3480156104b3575f80fd5b506101e9611458565b3480156104c7575f80fd5b506102846104d6366004612450565b611467565b3480156104e6575f80fd5b506105156104f536600461247d565b600d6020525f908152604090208054600182015460029092015490919083565b6040516101f6939291906124a4565b6102ba61053236600461247d565b6115d9565b348015610542575f80fd5b506102ba6105513660046124ba565b6115fc565b6102ba611be8565b348015610569575f80fd5b5061028461057836600461247d565b611c09565b348015610588575f80fd5b5061028461059736600461247d565b611cbf565b3480156105a7575f80fd5b506102ba60095481565b3480156105bc575f80fd5b506102846105cb366004612450565b611d0b565b3480156105db575f80fd5b506102846105ea36600461247d565b611d8b565b3480156105fa575f80fd5b506102ba60055481565b34801561060f575f80fd5b5061028461061e3660046125a8565b611e01565b34801561062e575f80fd5b506102ba60065481565b348015610643575f80fd5b506102ba600181565b610654611ee6565b6106626064620f4240612675565b8111156106a75760405162461bcd60e51b815260206004820152600e60248201526d657863656564206d6178696d756d60901b60448201526064015b60405180910390fd5b7f4b3c5e4d7a59d85563d40eacdce201f42b27dd0f184fc2aef47c140a9775617d600954826040516106da929190612496565b60405180910390a1600955565b6003546001600160a01b031633146107115760405162461bcd60e51b815260040161069e90612694565b60405163223e547960e01b81527f0000000000000000000000000000000000000000000000000000000000000000906001600160a01b0382169063223e54799061075f90859060040161243c565b5f604051808303815f87803b158015610776575f80fd5b505af1158015610788573d5f803e3d5ffd5b505050507f75ccacf0275778be70cc58a56b78401d8e60a7c1e153fd4338738dd08f26605e826040516107bb919061243c565b60405180910390a15050565b6003546001600160a01b031633146107f15760405162461bcd60e51b815260040161069e90612694565b604051630e7b77f760e41b81526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169063e7b77f709061083d90849060040161243c565b5f604051808303815f87803b158015610854575f80fd5b505af1158015610866573d5f803e3d5ffd5b5050604051630e7b77f760e41b81526001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016925063e7b77f7091506108b690849060040161243c565b5f604051808303815f87803b1580156108cd575f80fd5b505af11580156108df573d5f803e3d5ffd5b5050604051630e7b77f760e41b81526001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016925063e7b77f70915061092f90849060040161243c565b5f604051808303815f87803b158015610946575f80fd5b505af1158015610958573d5f803e3d5ffd5b5050505050565b5f807f000000000000000000000000000000000000000000000000000000000000000090505f816001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156109c1573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906109e591906126ba565b90506005545f14806109f5575080155b80610a01575060075481145b15610a1657670de0b6b3a76400009250505090565b5f6006547f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316639d241e7a6040518163ffffffff1660e01b81526004016020604051808303815f875af1158015610a77573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610a9b91906126ba565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166312065fe06040518163ffffffff1660e01b8152600401602060405180830381865afa158015610af7573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610b1b91906126ba565b610b2591906126d1565b610b2f91906126e4565b90505f60075483610b4091906126e4565b905080610b55670de0b6b3a7640000846126f7565b610b5f9190612675565b94505050505090565b600254600a54610b7891906126d1565b4211610bb85760405162461bcd60e51b815260206004820152600f60248201526e185b1c9958591e481c9958985cd959608a1b604482015260640161069e565b7f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000005f610c0361095f565b90505f826001600160a01b03166312065fe06040518163ffffffff1660e01b8152600401602060405180830381865afa158015610c42573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610c6691906126ba565b90505f610c7560085484611f45565b90505f81600654610c8691906126d1565b90505f866001600160a01b031663f41d7a186040518163ffffffff1660e01b81526004016020604051808303815f875af1158015610cc6573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610cea91906126ba565b90505f8083861115610d0757610d0084876126e4565b9150610d30565b83610d1284886126d1565b1015610d305782610d2387866126e4565b610d2d91906126e4565b90505b604051630ecc3e7160e21b81526001600160a01b038a1690633b30f9c490610d5e9085908590600401612496565b5f604051808303815f87803b158015610d75575f80fd5b505af1158015610d87573d5f803e3d5ffd5b505050505f610d9461095f565b9050808810610da35780610da5565b875b600580545f908152600b602090815260408083209490945582548252600c90529190912042905554610dd89060016126d1565b600555600854600754610deb91906126d1565b600755600854610dfb9082611f45565b600654610e0891906126d1565b6006555f60085542600a5560055460408051918252602082018590528101839052606081018290527fd2792f2bd70f462289b37051570ea123ec2faa689d0966f04ea499497c47aea49060800160405180910390a150505050505050505050565b610e71611ee6565b610e7a5f611fbd565b565b610e84611ee6565b60405163717dd44560e01b81527f0000000000000000000000000000000000000000000000000000000000000000906001600160a01b0382169063717dd44590610ed290859060040161243c565b5f604051808303815f87803b158015610ee9575f80fd5b505af1158015610efb573d5f803e3d5ffd5b505050507feed65fb1c2451c54bb6eb3a6f3fe2fbe77ffd432b1f447c171237f36b8947202826040516107bb919061243c565b610f3661200e565b805f03610f555760405162461bcd60e51b815260040161069e9061270e565b6005545f03610fa25760405162461bcd60e51b815260206004820152601960248201527873686f756c6420776974686472617720696e7374616e746c7960381b604482015260640161069e565b6040516370a0823160e01b81527f0000000000000000000000000000000000000000000000000000000000000000907f00000000000000000000000000000000000000000000000000000000000000009083906001600160a01b038416906370a082319061101490339060040161243c565b602060405180830381865afa15801561102f573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061105391906126ba565b10156110925760405162461bcd60e51b815260206004820152600e60248201526d6578636565642062616c616e636560901b604482015260640161069e565b6110be7f0000000000000000000000000000000000000000000000000000000000000000333086612065565b826008546110cc91906126d1565b600855335f908152600d60205260409020600554815403611101578381600101546110f791906126d1565b60018201556111d3565b80545f0361111a576001810184905560055481556111d3565b600181015481545f908152600b6020526040812054909161113a91611f45565b6001830154604051632770a7eb60e21b81529192506001600160a01b03851691639dc29fac9161116f91309190600401612731565b5f604051808303815f87803b158015611186575f80fd5b505af1158015611198573d5f803e3d5ffd5b50505060018301546007546111ad92506126e4565b6007556001820185905560028201546111c79082906126d1565b60028301555060055481555b60055460405133917f0c53c82ad07e2d592d88ece3b066777dd60f1118e2a081b380efc4358f0d9e2a91611208918891612496565b60405180910390a250505061121c60015f55565b50565b611227611ee6565b60405163768aac5d60e01b81527f0000000000000000000000000000000000000000000000000000000000000000906001600160a01b0382169063768aac5d9061127590859060040161243c565b5f604051808303815f87803b15801561128c575f80fd5b505af115801561129e573d5f803e3d5ffd5b505050507f700c330a34830acb29f2b4927829f605fae4e5b7197df45a7973d246039e1e01826040516107bb919061243c565b5f805f7f00000000000000000000000000000000000000000000000000000000000000009050600654816001600160a01b03166312065fe06040518163ffffffff1660e01b8152600401602060405180830381865afa158015611336573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061135a91906126ba565b11156113d057600654816001600160a01b03166312065fe06040518163ffffffff1660e01b8152600401602060405180830381865afa15801561139f573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906113c391906126ba565b6113cd91906126e4565b92505b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663f837df256040518163ffffffff1660e01b81526004016020604051808303815f875af115801561142d573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061145191906126ba565b9150509091565b6001546001600160a01b031690565b61146f61200e565b805f0361148e5760405162461bcd60e51b815260040161069e9061270e565b335f908152600d602052604090206005548154146114e45760405162461bcd60e51b81526020600482015260136024820152726e6f2070656e64696e6720776974686472617760681b604482015260640161069e565b81816001015410156115325760405162461bcd60e51b81526020600482015260176024820152766578636565642070656e64696e6720776974686472617760481b604482015260640161069e565b81816001015461154291906126e4565b60018201556115727f0000000000000000000000000000000000000000000000000000000000000000338461216a565b80600101545f03611581575f81555b8160085461158f91906126e4565b60085560055460405133917f39e2e01794006bc1f63835af5c05db790beca4bfb40de3f02cc3ddf22dccc0fb916115c7918691612496565b60405180910390a25061121c60015f55565b5f6115e261200e565b6115ec3483612268565b90506115f760015f55565b919050565b5f61160561200e565b8215158061161257508115155b61162e5760405162461bcd60e51b815260040161069e9061270e565b7f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000005f6116796112d1565b50905085156117fd57335f908152600d602052604090206005548154148015906116a35750805415155b1561175e57600181015481545f908152600b602052604081205490916116c891611f45565b6001830154604051632770a7eb60e21b81529192506001600160a01b03861691639dc29fac916116fd91309190600401612731565b5f604051808303815f87803b158015611714575f80fd5b505af1158015611726573d5f803e3d5ffd5b505050600183015460075461173b92506126e4565b6007555f600183015560028201546117549082906126d1565b6002830155505f81555b86816002015410156117a85760405162461bcd60e51b815260206004820152601360248201527265786365656420776974686472617761626c6560681b604482015260640161069e565b8681600201546117b891906126e4565b60028201556006546117cb9088906126e4565b60065560055460405188965033915f80516020612903833981519152916117f3918991612496565b60405180910390a2505b8415611a11575f6005545f0361181c5750670de0b6b3a764000061185e565b5f61182561095f565b90505f600b5f600160055461183a91906126e4565b81526020019081526020015f205490508181106118575781611859565b805b925050505b5f6118698783611f45565b604051632770a7eb60e21b81529091506001600160a01b03851690639dc29fac9061189a9033908b90600401612731565b5f604051808303815f87803b1580156118b1575f80fd5b505af11580156118c3573d5f803e3d5ffd5b50505050828111611911576118d881876126d1565b9550336001600160a01b03165f8051602061290383398151915282600554604051611904929190612496565b60405180910390a2611a0e565b61191b83876126d1565b955061192783826126e4565b604051630fcc56f760e01b8152600481018290529091507f0000000000000000000000000000000000000000000000000000000000000000905f906001600160a01b03831690630fcc56f7906024016020604051808303815f875af1158015611992573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906119b691906126ba565b90506119c281896126d1565b9750336001600160a01b03167f1b84e2f0660a601edc93ceed0d08fa5e9b3cbe4e2450c262f2ea8531d2c52e958483600554604051611a03939291906124a4565b60405180910390a250505b50505b83836001600160a01b03166312065fe06040518163ffffffff1660e01b8152600401602060405180830381865afa158015611a4e573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611a7291906126ba565b1015611ab25760405162461bcd60e51b815260206004820152600f60248201526e1cdd1a5b1b081b995959081dd85a5d608a1b604482015260640161069e565b5f6009545f14611b7157620f424060095486611ace91906126f7565b611ad89190612675565b6004805460405163f3fef3a360e01b81529293506001600160a01b038088169363f3fef3a393611b0e9390921691869101612731565b5f604051808303815f87803b158015611b25575f80fd5b505af1158015611b37573d5f803e3d5ffd5b50506040518381523392507f55bb3cade9d43b798a4fe5ffdd05024b2d7870df53920673bfc7e68047cd0ab1915060200160405180910390a25b6001600160a01b03841663f3fef3a333611b8b84896126e4565b6040518363ffffffff1660e01b8152600401611ba8929190612731565b5f604051808303815f87803b158015611bbf575f80fd5b505af1158015611bd1573d5f803e3d5ffd5b5050505050505050611be260015f55565b92915050565b5f611bf161200e565b611bfb3433612268565b9050611c0660015f55565b90565b611c11611ee6565b6001600160a01b038116611c565760405162461bcd60e51b815260206004820152600c60248201526b7a65726f206164647265737360a01b604482015260640161069e565b600454604080516001600160a01b03928316815291831660208301527fd9d6b85b6d670cd443496fc6d03390f739bbff47f96a8e33fb0cdd52ad26f5c2910160405180910390a1600480546001600160a01b0319166001600160a01b0392909216919091179055565b6003546001600160a01b03163314611ce95760405162461bcd60e51b815260040161069e90612694565b600380546001600160a01b0319166001600160a01b0392909216919091179055565b611d13611ee6565b62093a80811115611d505760405162461bcd60e51b81526020600482015260076024820152661a5b9d985b1a5960ca1b604482015260640161069e565b60028190556040518181527f73b75c75399b0450cd07a0e5188f0e06ce9e484fea18044b25e0326feb8e0e2a9060200160405180910390a150565b611d93611ee6565b6001600160a01b038116611df85760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b606482015260840161069e565b61121c81611fbd565b6003546001600160a01b03163314611e2b5760405162461bcd60e51b815260040161069e90612694565b604051633fea70a760e01b81527f0000000000000000000000000000000000000000000000000000000000000000906001600160a01b03821690633fea70a790611e7b908690869060040161274a565b5f604051808303815f87803b158015611e92575f80fd5b505af1158015611ea4573d5f803e3d5ffd5b505050507fb08ed47ad81ee926c18b77f6be44a5d49bf687355a669936e1f02cfe4e2c84f78383604051611ed992919061274a565b60405180910390a1505050565b33611eef611458565b6001600160a01b031614610e7a5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161069e565b5f60018211611f965760405162461bcd60e51b815260206004820181905260248201527f5661756c74204c69623a20696e76616c69642061737365745065725368617265604482015260640161069e565b611fa26012600a6128ac565b611fac83856126f7565b611fb69190612675565b9392505050565b600180546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0905f90a35050565b60025f540361205f5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015260640161069e565b60025f55565b604080516001600160a01b0385811660248301528481166044830152606480830185905283518084039091018152608490920183526020820180516001600160e01b03166323b872dd60e01b17905291515f928392908816916120c891906128b7565b5f604051808303815f865af19150503d805f8114612101576040519150601f19603f3d011682016040523d82523d5f602084013e612106565b606091505b509150915081801561213057508051158061213057508080602001905181019061213091906128e3565b6121625760405162461bcd60e51b815260206004820152600360248201526229aa2360e91b604482015260640161069e565b505050505050565b5f80846001600160a01b031663a9059cbb60e01b8585604051602401612191929190612731565b60408051601f198184030181529181526020820180516001600160e01b03166001600160e01b03199094169390931790925290516121cf91906128b7565b5f604051808303815f865af19150503d805f8114612208576040519150601f19603f3d011682016040523d82523d5f602084013e61220d565b606091505b509150915081801561223757508051158061223757508080602001905181019061223791906128e3565b6109585760405162461bcd60e51b815260206004820152600260248201526114d560f21b604482015260640161069e565b5f825f036122885760405162461bcd60e51b815260040161069e9061270e565b5f8061229261095f565b90506005545f036122ad57670de0b6b3a764000091506122e3565b5f600b5f60016005546122c091906126e4565b81526020019081526020015f205490508181116122dd57816122df565b805b9250505b816122f6670de0b6b3a7640000876126f7565b6123009190612675565b92507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663d0e30db0476040518263ffffffff1660e01b81526004015f604051808303818588803b15801561235b575f80fd5b505af115801561236d573d5f803e3d5ffd5b50506040516340c10f1960e01b81526001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001693506340c10f1992506123c0915087908790600401612731565b5f604051808303815f87803b1580156123d7575f80fd5b505af11580156123e9573d5f803e3d5ffd5b50505050836001600160a01b03167f36af321ec8d3c75236829c5317affd40ddb308863a1236d2d277a4025cccee1e868560055460405161242c939291906124a4565b60405180910390a2505092915050565b6001600160a01b0391909116815260200190565b5f60208284031215612460575f80fd5b5035919050565b80356001600160a01b03811681146115f7575f80fd5b5f6020828403121561248d575f80fd5b611fb682612467565b918252602082015260400190565b9283526020830191909152604082015260600190565b5f80604083850312156124cb575f80fd5b50508035926020909101359150565b634e487b7160e01b5f52604160045260245ffd5b604051601f8201601f191681016001600160401b0381118282101715612516576125166124da565b604052919050565b5f6001600160401b03821115612536576125366124da565b5060051b60200190565b5f82601f83011261254f575f80fd5b8135602061256461255f8361251e565b6124ee565b82815260059290921b84018101918181019086841115612582575f80fd5b8286015b8481101561259d5780358352918301918301612586565b509695505050505050565b5f80604083850312156125b9575f80fd5b82356001600160401b03808211156125cf575f80fd5b818501915085601f8301126125e2575f80fd5b813560206125f261255f8361251e565b82815260059290921b84018101918181019089841115612610575f80fd5b948201945b838610156126355761262686612467565b82529482019490820190612615565b9650508601359250508082111561264a575f80fd5b5061265785828601612540565b9150509250929050565b634e487b7160e01b5f52601160045260245ffd5b5f8261268f57634e487b7160e01b5f52601260045260245ffd5b500490565b6020808252600c908201526b1b9bdd081c1c9bdc1bdcd85b60a21b604082015260600190565b5f602082840312156126ca575f80fd5b5051919050565b80820180821115611be257611be2612661565b81810381811115611be257611be2612661565b8082028115828204841417611be257611be2612661565b6020808252600990820152681d1bdbc81cdb585b1b60ba1b604082015260600190565b6001600160a01b03929092168252602082015260400190565b604080825283519082018190525f906020906060840190828701845b8281101561278b5781516001600160a01b031684529284019290840190600101612766565b505050838103828501528451808252858301918301905f5b818110156127bf578351835292840192918401916001016127a3565b5090979650505050505050565b600181815b8085111561280657815f19048211156127ec576127ec612661565b808516156127f957918102915b93841c93908002906127d1565b509250929050565b5f8261281c57506001611be2565b8161282857505f611be2565b816001811461283e576002811461284857612864565b6001915050611be2565b60ff84111561285957612859612661565b50506001821b611be2565b5060208310610133831016604e8410600b8410161715612887575081810a611be2565b61289183836127cc565b805f19048211156128a4576128a4612661565b029392505050565b5f611fb6838361280e565b5f82515f5b818110156128d657602081860181015185830152016128bc565b505f920191825250919050565b5f602082840312156128f3575f80fd5b81518015158114611fb6575f80fdfe92ccf450a286a957af52509bc1c9939d1a6a481783e142e41e2499f0bb66ebc6a2646970667358221220589edafabb62e4e2222be100a867ae28cb8024a70f3b12ceec8fc29df5b0aeaa64736f6c6343000815003360a060405234801562000010575f80fd5b5060405162001d1f38038062001d1f8339810160408190526200003391620003df565b6001600160a01b038316620000655760405162461bcd60e51b81526004016200005c90620004c0565b60405180910390fd5b81515f5b81811015620000d7575f6001600160a01b0316848281518110620000915762000091620004e6565b60200260200101516001600160a01b031603620000c25760405162461bcd60e51b81526004016200005c90620004c0565b80620000ce816200050e565b91505062000069565b505f80546001600160a01b031916331790556001600160a01b0384166080526200010283836200010c565b505050506200053f565b8051825114620001505760405162461bcd60e51b815260206004820152600e60248201526d0d2dcecc2d8d2c840d8cadccee8d60931b60448201526064016200005c565b81515f90815b81811015620002335762000191858281518110620001785762000178620004e6565b602002602001015160016200027d60201b90919060201c565b50838181518110620001a757620001a7620004e6565b602002602001015160035f878481518110620001c757620001c7620004e6565b60200260200101516001600160a01b03166001600160a01b031681526020019081526020015f2081905550838181518110620002075762000207620004e6565b6020026020010151836200021c919062000529565b9250806200022a816200050e565b91505062000156565b50620f4240821115620002775760405162461bcd60e51b815260206004820152600b60248201526a657863656564203130302560a81b60448201526064016200005c565b50505050565b5f62000293836001600160a01b0384166200029c565b90505b92915050565b5f818152600183016020526040812054620002e357508154600181810184555f84815260208082209093018490558454848252828601909352604090209190915562000296565b505f62000296565b6001600160a01b038116811462000300575f80fd5b50565b634e487b7160e01b5f52604160045260245ffd5b604051601f8201601f191681016001600160401b038111828210171562000342576200034262000303565b604052919050565b5f6001600160401b0382111562000365576200036562000303565b5060051b60200190565b5f82601f8301126200037f575f80fd5b815160206200039862000392836200034a565b62000317565b82815260059290921b84018101918181019086841115620003b7575f80fd5b8286015b84811015620003d45780518352918301918301620003bb565b509695505050505050565b5f805f60608486031215620003f2575f80fd5b8351620003ff81620002eb565b602085810151919450906001600160401b03808211156200041e575f80fd5b818701915087601f83011262000432575f80fd5b81516200044362000392826200034a565b81815260059190911b8301840190848101908a83111562000462575f80fd5b938501935b828510156200048d5784516200047d81620002eb565b8252938501939085019062000467565b60408a01519097509450505080831115620004a6575f80fd5b5050620004b6868287016200036f565b9150509250925092565b6020808252600c908201526b5a45524f204144445245535360a01b604082015260600190565b634e487b7160e01b5f52603260045260245ffd5b634e487b7160e01b5f52601160045260245ffd5b5f60018201620005225762000522620004fa565b5060010190565b80820180821115620002965762000296620004fa565b6080516117b9620005665f395f81816101e50152818161083c01526109fa01526117b95ff3fe6080604052600436106100db575f3560e01c80630fcc56f7146100e6578063223e54791461011857806324c71ece146101395780633b30f9c4146101645780633fea70a714610177578063717dd44514610196578063768aac5d146101b55780637b0c1f29146101d457806397663b741461021f5780639841ab00146102335780639d241e7a14610252578063b49a60bb14610266578063ba93ec2914610288578063e7b77f70146102a6578063f111a5c3146102c5578063f25ddb62146102e4578063f41d7a1814610303578063f837df2514610317575f80fd5b366100e257005b5f80fd5b3480156100f1575f80fd5b506101056101003660046113cc565b61032b565b6040519081526020015b60405180910390f35b348015610123575f80fd5b506101376101323660046113f7565b61039c565b005b348015610144575f80fd5b506101056101533660046113f7565b60036020525f908152604090205481565b610137610172366004611412565b61041c565b348015610182575f80fd5b50610137610191366004611500565b61044f565b3480156101a1575f80fd5b506101376101b03660046113f7565b610482565b3480156101c0575f80fd5b506101376101cf3660046113f7565b6104b7565b3480156101df575f80fd5b506102077f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b03909116815260200161010f565b34801561022a575f80fd5b506101376104ea565b34801561023e575f80fd5b5061010561024d3660046113f7565b6104f6565b34801561025d575f80fd5b5061010561055e565b348015610271575f80fd5b5061027a6105a7565b60405161010f9291906115bb565b348015610293575f80fd5b505f54610207906001600160a01b031681565b3480156102b1575f80fd5b506101376102c03660046113f7565b6106e4565b3480156102d0575f80fd5b506101056102df3660046113f7565b61072e565b3480156102ef575f80fd5b506101056102fe3660046113f7565b61076b565b34801561030e575f80fd5b506101056107a9565b348015610322575f80fd5b506101056107ed565b5f80546001600160a01b0316331461035e5760405162461bcd60e51b81526004016103559061163d565b60405180910390fd5b478281106103765761036e610831565b809150610396565b806103896103848286611674565b610861565b6103939190611687565b91505b50919050565b5f546001600160a01b031633146103c55760405162461bcd60e51b81526004016103559061163d565b6103d0600182610957565b1561040d5760405162461bcd60e51b815260206004820152600d60248201526c185b1c9958591e48195e1a5cdd609a1b6044820152606401610355565b610418600182610972565b5050565b5f546001600160a01b031633146104455760405162461bcd60e51b81526004016103559061163d565b6104188282610986565b5f546001600160a01b031633146104785760405162461bcd60e51b81526004016103559061163d565b6104188282610d1b565b5f546001600160a01b031633146104ab5760405162461bcd60e51b81526004016103559061163d565b6104b481610f94565b50565b5f546001600160a01b031633146104e05760405162461bcd60e51b81526004016103559061163d565b6104b4815f610fec565b6104f45f80610986565b565b5f816001600160a01b0316637654f7ab6040518163ffffffff1660e01b81526004016020604051808303815f875af1158015610534573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610558919061169a565b92915050565b5f8061056a600161105b565b90505f5b818110156105a25761058461024d600183611064565b61058e9084611687565b92508061059a816116b1565b91505061056e565b505090565b6060805f6105b5600161105b565b9050806001600160401b038111156105cf576105cf611432565b6040519080825280602002602001820160405280156105f8578160200160208202803683370190505b509250806001600160401b0381111561061357610613611432565b60405190808252806020026020018201604052801561063c578160200160208202803683370190505b5091505f5b818110156106de575f610655600183611064565b90508085838151811061066a5761066a6116c9565b60200260200101906001600160a01b031690816001600160a01b03168152505060035f826001600160a01b03166001600160a01b031681526020019081526020015f20548483815181106106c0576106c06116c9565b602090810291909101015250806106d6816116b1565b915050610641565b50509091565b5f546001600160a01b0316331461070d5760405162461bcd60e51b81526004016103559061163d565b5f80546001600160a01b0319166001600160a01b0392909216919091179055565b5f816001600160a01b0316621a55976040518163ffffffff1660e01b81526004016020604051808303815f875af1158015610534573d5f803e3d5ffd5b5f816001600160a01b0316636c23ab4c6040518163ffffffff1660e01b81526004016020604051808303815f875af1158015610534573d5f803e3d5ffd5b5f806107b5600161105b565b90505f5b818110156105a2576107cf6102df600183611064565b6107d99084611687565b9250806107e5816116b1565b9150506107b9565b5f806107f9600161105b565b90505f5b818110156105a2576108136102fe600183611064565b61081d9084611687565b925080610829816116b1565b9150506107fd565b47156104f4576104f47f00000000000000000000000000000000000000000000000000000000000000004761106f565b5f8061086d600161105b565b90505f5b8181101561094e575f610885600183611064565b6001600160a01b0381165f9081526003602052604081205491925090620f4240906108b090886116dd565b6108ba91906116f4565b9050801561093957604051637ec95ff960e11b81526004810182905285906001600160a01b0384169063fd92bff2906024016020604051808303815f875af1158015610908573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061092c919061169a565b6109369190611687565b94505b50508080610946906116b1565b915050610871565b50610396610831565b5f61096b836001600160a01b038416611113565b9392505050565b5f61096b836001600160a01b03841661112a565b811580610991575080155b6109d85760405162461bcd60e51b81526020600482015260186024820152776f6e6c79206465706f736974206f7220776974686472617760401b6044820152606401610355565b8115610a5a5760405163f3fef3a360e01b8152306004820152602481018390527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169063f3fef3a3906044015f604051808303815f87803b158015610a43575f80fd5b505af1158015610a55573d5f803e3d5ffd5b505050505b5f610a636107ed565b905081811015610a7457505f610a8c565b81610a7f8483611687565b610a899190611674565b90505b5f610a97600161105b565b90505f816001600160401b03811115610ab257610ab2611432565b604051908082528060200260200182016040528015610afb57816020015b604080516060810182525f80825260208083018290529282015282525f19909201910181610ad05790505b5090505f80610b0b600185611674565b90505f5b84811015610c74575f610b23600183611064565b6001600160a01b0381165f9081526003602052604081205491925003610b5457610b4e816001610fec565b50610c62565b6001600160a01b0381165f90815260036020526040812054620f424090610b7b908a6116dd565b610b8591906116f4565b90505f610b918361076b565b905080821015610bf757604080516060810182526001600160a01b03851681525f6020820152908101610bc48484611674565b815250878781518110610bd957610bd96116c9565b60200260200101819052508580610bef906116b1565b965050610c5e565b80821115610c5e57604080516060810182526001600160a01b038516815260016020820152908101610c298385611674565b815250878681518110610c3e57610c3e6116c9565b6020026020010181905250845f14610c5e5784610c5a81611713565b9550505b5050505b80610c6c816116b1565b915050610b0f565b50825193505f5b84811015610d09575f848281518110610c9657610c966116c9565b6020026020010151905080604001515f03610cb15750610cf7565b806020015115610ce4578060400151471015610cce574760408201525b610cdf815f01518260400151611171565b610cf5565b610cf5815f015182604001516111bc565b505b80610d01816116b1565b915050610c7b565b50610d12610831565b50505050505050565b815181518114610d5e5760405162461bcd60e51b815260206004820152600e60248201526d0d2dcecc2d8d2c840d8cadccee8d60931b6044820152606401610355565b5f610d69600161105b565b90505f5b81811015610daf575f600381610d84600185611064565b6001600160a01b0316815260208101919091526040015f205580610da7816116b1565b915050610d6d565b505f805b83811015610f4b57306001600160a01b0316868281518110610dd757610dd76116c9565b60200260200101516001600160a01b031663f77c47916040518163ffffffff1660e01b8152600401602060405180830381865afa158015610e1a573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610e3e9190611728565b6001600160a01b031614610e8a5760405162461bcd60e51b81526020600482015260136024820152720c6dedce8e4ded8d8cae440dad2e6dac2e8c6d606b1b6044820152606401610355565b610eb7868281518110610e9f57610e9f6116c9565b6020026020010151600161097290919063ffffffff16565b50848181518110610eca57610eca6116c9565b602002602001015160035f888481518110610ee757610ee76116c9565b60200260200101516001600160a01b03166001600160a01b031681526020019081526020015f2081905550848181518110610f2457610f246116c9565b602002602001015182610f379190611687565b915080610f43816116b1565b915050610db3565b50620f4240811115610f8d5760405162461bcd60e51b815260206004820152600b60248201526a657863656564203130302560a81b6044820152606401610355565b5050505050565b610f9d81611224565b610fd85760405162461bcd60e51b815260206004820152600c60248201526b7374696c6c2061637469766560a01b6044820152606401610355565b610fe36001826112af565b506104b4610831565b816001600160a01b03166352efea6e6040518163ffffffff1660e01b81526004016020604051808303815f875af1158015611029573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061104d919061169a565b508061041857610418610831565b5f610558825490565b5f61096b83836112c3565b604080515f808252602082019092526001600160a01b0384169083906040516110989190611743565b5f6040518083038185875af1925050503d805f81146110d2576040519150601f19603f3d011682016040523d82523d5f602084013e6110d7565b606091505b505090508061110e5760405162461bcd60e51b815260206004820152600360248201526253544560e81b6044820152606401610355565b505050565b5f9081526001919091016020526040902054151590565b5f6111358383611113565b61116a57508154600181810184555f848152602080822090930184905584548482528286019093526040902091909155610558565b505f610558565b816001600160a01b031663d0e30db0826040518263ffffffff1660e01b81526004015f604051808303818588803b1580156111aa575f80fd5b505af1158015610d12573d5f803e3d5ffd5b604051632e1a7d4d60e01b8152600481018290526001600160a01b03831690632e1a7d4d906024016020604051808303815f875af1158015611200573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061110e919061169a565b6001600160a01b0381165f908152600360205260408120541580156105585750612710826001600160a01b0316637654f7ab6040518163ffffffff1660e01b81526004016020604051808303815f875af1158015611284573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906112a8919061169a565b1092915050565b5f61096b836001600160a01b0384166112e9565b5f825f0182815481106112d8576112d86116c9565b905f5260205f200154905092915050565b5f81815260018301602052604081205480156113c3575f61130b600183611674565b85549091505f9061131e90600190611674565b905081811461137d575f865f01828154811061133c5761133c6116c9565b905f5260205f200154905080875f01848154811061135c5761135c6116c9565b5f918252602080832090910192909255918252600188019052604090208390555b855486908061138e5761138e61176f565b600190038181905f5260205f20015f90559055856001015f8681526020019081526020015f205f905560019350505050610558565b5f915050610558565b5f602082840312156113dc575f80fd5b5035919050565b6001600160a01b03811681146104b4575f80fd5b5f60208284031215611407575f80fd5b813561096b816113e3565b5f8060408385031215611423575f80fd5b50508035926020909101359150565b634e487b7160e01b5f52604160045260245ffd5b604051601f8201601f191681016001600160401b038111828210171561146e5761146e611432565b604052919050565b5f6001600160401b0382111561148e5761148e611432565b5060051b60200190565b5f82601f8301126114a7575f80fd5b813560206114bc6114b783611476565b611446565b82815260059290921b840181019181810190868411156114da575f80fd5b8286015b848110156114f557803583529183019183016114de565b509695505050505050565b5f8060408385031215611511575f80fd5b82356001600160401b0380821115611527575f80fd5b818501915085601f83011261153a575f80fd5b8135602061154a6114b783611476565b82815260059290921b84018101918181019089841115611568575f80fd5b948201945b8386101561158f578535611580816113e3565b8252948201949082019061156d565b965050860135925050808211156115a4575f80fd5b506115b185828601611498565b9150509250929050565b604080825283519082018190525f906020906060840190828701845b828110156115fc5781516001600160a01b0316845292840192908401906001016115d7565b505050838103828501528451808252858301918301905f5b8181101561163057835183529284019291840191600101611614565b5090979650505050505050565b6020808252600990820152681b9bdd081d985d5b1d60ba1b604082015260600190565b634e487b7160e01b5f52601160045260245ffd5b8181038181111561055857610558611660565b8082018082111561055857610558611660565b5f602082840312156116aa575f80fd5b5051919050565b5f600182016116c2576116c2611660565b5060010190565b634e487b7160e01b5f52603260045260245ffd5b808202811582820484141761055857610558611660565b5f8261170e57634e487b7160e01b5f52601260045260245ffd5b500490565b5f8161172157611721611660565b505f190190565b5f60208284031215611738575f80fd5b815161096b816113e3565b5f82515f5b818110156117625760208186018101518583015201611748565b505f920191825250919050565b634e487b7160e01b5f52603160045260245ffdfea2646970667358221220c3b133e34d49b8d48a24baaba288593e602faa536b943886e53af085ebcbe5ec64736f6c63430008150033000000000000000000000000ec306e46549a7e8f4fce823d3058f2d134133b170000000000000000000000003aa0670e24cb122e1d5307ed74b0c44d619aff9b0000000000000000000000009485711f11b17f73f2ccc8561bcae05bdc7e9ad900000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000001400000000000000000000000000000000000000000000000000000000000000004000000000000000000000000363d200e54fe86985790f4e210df9bfb142342020000000000000000000000009221fbe66be06f43dcbda3fc17cdd66ef1b236f9000000000000000000000000a66723d951f15423ef2c9c11edcb821e38301836000000000000000000000000856edf1b835ea02bf11b16f041df5a13ef1ec3d10000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000c35000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000061a800000000000000000000000000000000000000000000000000000000000086470
Deployed Bytecode
0x6080604052600436106101ab575f3560e01c8062258d6b146101b65780630167eb85146101ff5780630754617214610232578063096015b014610265578063223e54791461028657806324f3082a146102a55780632712b539146102c857806328a79576146102e75780633c49fc0f146102fb57806346904840146103265780635069fb571461034557806351b77fb31461035957806360e760d51461036e578063715018a6146103835780637155133614610397578063717dd445146103ac578063745400c9146103cb578063753ec103146103ea578063768aac5d146104095780637b0c1f291461042857806382f1631f1461045b57806387153eb11461047d5780638da5cb5b146104a85780639f01f7ba146104bc578063a4786f3d146104db578063aa67c91914610524578063b18f2e9114610537578063d0e30db014610556578063e74b981b1461055e578063e8ac623a1461057d578063ea99e6891461059c578063ef037fb9146105b1578063f2fde38b146105d0578063f76339dc146105ef578063fccbebf514610604578063fe73511714610623578063ffa1ad7414610638575f80fd5b366101b257005b5f80fd5b3480156101c1575f80fd5b506101e97f000000000000000000000000396abf9ff46e21694f4ef01ca77c6d7893a017b281565b6040516101f6919061243c565b60405180910390f35b34801561020a575f80fd5b506101e97f0000000000000000000000007122985656e38bdc0302db86685bb972b145bd3c81565b34801561023d575f80fd5b506101e97f000000000000000000000000ec306e46549a7e8f4fce823d3058f2d134133b1781565b348015610270575f80fd5b5061028461027f366004612450565b61064c565b005b348015610291575f80fd5b506102846102a036600461247d565b6106e7565b3480156102b0575f80fd5b506102ba600a5481565b6040519081526020016101f6565b3480156102d3575f80fd5b506102846102e236600461247d565b6107c7565b3480156102f2575f80fd5b506102ba61095f565b348015610306575f80fd5b506102ba610315366004612450565b600c6020525f908152604090205481565b348015610331575f80fd5b506004546101e9906001600160a01b031681565b348015610350575f80fd5b50610284610b68565b348015610364575f80fd5b506102ba60075481565b348015610379575f80fd5b506102ba60085481565b34801561038e575f80fd5b50610284610e69565b3480156103a2575f80fd5b506102ba60025481565b3480156103b7575f80fd5b506102846103c636600461247d565b610e7c565b3480156103d6575f80fd5b506102846103e5366004612450565b610f2e565b3480156103f5575f80fd5b506003546101e9906001600160a01b031681565b348015610414575f80fd5b5061028461042336600461247d565b61121f565b348015610433575f80fd5b506101e97f0000000000000000000000009485711f11b17f73f2ccc8561bcae05bdc7e9ad981565b348015610466575f80fd5b5061046f6112d1565b6040516101f6929190612496565b348015610488575f80fd5b506102ba610497366004612450565b600b6020525f908152604090205481565b3480156104b3575f80fd5b506101e9611458565b3480156104c7575f80fd5b506102846104d6366004612450565b611467565b3480156104e6575f80fd5b506105156104f536600461247d565b600d6020525f908152604090208054600182015460029092015490919083565b6040516101f6939291906124a4565b6102ba61053236600461247d565b6115d9565b348015610542575f80fd5b506102ba6105513660046124ba565b6115fc565b6102ba611be8565b348015610569575f80fd5b5061028461057836600461247d565b611c09565b348015610588575f80fd5b5061028461059736600461247d565b611cbf565b3480156105a7575f80fd5b506102ba60095481565b3480156105bc575f80fd5b506102846105cb366004612450565b611d0b565b3480156105db575f80fd5b506102846105ea36600461247d565b611d8b565b3480156105fa575f80fd5b506102ba60055481565b34801561060f575f80fd5b5061028461061e3660046125a8565b611e01565b34801561062e575f80fd5b506102ba60065481565b348015610643575f80fd5b506102ba600181565b610654611ee6565b6106626064620f4240612675565b8111156106a75760405162461bcd60e51b815260206004820152600e60248201526d657863656564206d6178696d756d60901b60448201526064015b60405180910390fd5b7f4b3c5e4d7a59d85563d40eacdce201f42b27dd0f184fc2aef47c140a9775617d600954826040516106da929190612496565b60405180910390a1600955565b6003546001600160a01b031633146107115760405162461bcd60e51b815260040161069e90612694565b60405163223e547960e01b81527f000000000000000000000000396abf9ff46e21694f4ef01ca77c6d7893a017b2906001600160a01b0382169063223e54799061075f90859060040161243c565b5f604051808303815f87803b158015610776575f80fd5b505af1158015610788573d5f803e3d5ffd5b505050507f75ccacf0275778be70cc58a56b78401d8e60a7c1e153fd4338738dd08f26605e826040516107bb919061243c565b60405180910390a15050565b6003546001600160a01b031633146107f15760405162461bcd60e51b815260040161069e90612694565b604051630e7b77f760e41b81526001600160a01b037f000000000000000000000000ec306e46549a7e8f4fce823d3058f2d134133b17169063e7b77f709061083d90849060040161243c565b5f604051808303815f87803b158015610854575f80fd5b505af1158015610866573d5f803e3d5ffd5b5050604051630e7b77f760e41b81526001600160a01b037f0000000000000000000000009485711f11b17f73f2ccc8561bcae05bdc7e9ad916925063e7b77f7091506108b690849060040161243c565b5f604051808303815f87803b1580156108cd575f80fd5b505af11580156108df573d5f803e3d5ffd5b5050604051630e7b77f760e41b81526001600160a01b037f000000000000000000000000396abf9ff46e21694f4ef01ca77c6d7893a017b216925063e7b77f70915061092f90849060040161243c565b5f604051808303815f87803b158015610946575f80fd5b505af1158015610958573d5f803e3d5ffd5b5050505050565b5f807f0000000000000000000000007122985656e38bdc0302db86685bb972b145bd3c90505f816001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156109c1573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906109e591906126ba565b90506005545f14806109f5575080155b80610a01575060075481145b15610a1657670de0b6b3a76400009250505090565b5f6006547f000000000000000000000000396abf9ff46e21694f4ef01ca77c6d7893a017b26001600160a01b0316639d241e7a6040518163ffffffff1660e01b81526004016020604051808303815f875af1158015610a77573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610a9b91906126ba565b7f0000000000000000000000009485711f11b17f73f2ccc8561bcae05bdc7e9ad96001600160a01b03166312065fe06040518163ffffffff1660e01b8152600401602060405180830381865afa158015610af7573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610b1b91906126ba565b610b2591906126d1565b610b2f91906126e4565b90505f60075483610b4091906126e4565b905080610b55670de0b6b3a7640000846126f7565b610b5f9190612675565b94505050505090565b600254600a54610b7891906126d1565b4211610bb85760405162461bcd60e51b815260206004820152600f60248201526e185b1c9958591e481c9958985cd959608a1b604482015260640161069e565b7f000000000000000000000000396abf9ff46e21694f4ef01ca77c6d7893a017b27f0000000000000000000000009485711f11b17f73f2ccc8561bcae05bdc7e9ad95f610c0361095f565b90505f826001600160a01b03166312065fe06040518163ffffffff1660e01b8152600401602060405180830381865afa158015610c42573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610c6691906126ba565b90505f610c7560085484611f45565b90505f81600654610c8691906126d1565b90505f866001600160a01b031663f41d7a186040518163ffffffff1660e01b81526004016020604051808303815f875af1158015610cc6573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610cea91906126ba565b90505f8083861115610d0757610d0084876126e4565b9150610d30565b83610d1284886126d1565b1015610d305782610d2387866126e4565b610d2d91906126e4565b90505b604051630ecc3e7160e21b81526001600160a01b038a1690633b30f9c490610d5e9085908590600401612496565b5f604051808303815f87803b158015610d75575f80fd5b505af1158015610d87573d5f803e3d5ffd5b505050505f610d9461095f565b9050808810610da35780610da5565b875b600580545f908152600b602090815260408083209490945582548252600c90529190912042905554610dd89060016126d1565b600555600854600754610deb91906126d1565b600755600854610dfb9082611f45565b600654610e0891906126d1565b6006555f60085542600a5560055460408051918252602082018590528101839052606081018290527fd2792f2bd70f462289b37051570ea123ec2faa689d0966f04ea499497c47aea49060800160405180910390a150505050505050505050565b610e71611ee6565b610e7a5f611fbd565b565b610e84611ee6565b60405163717dd44560e01b81527f000000000000000000000000396abf9ff46e21694f4ef01ca77c6d7893a017b2906001600160a01b0382169063717dd44590610ed290859060040161243c565b5f604051808303815f87803b158015610ee9575f80fd5b505af1158015610efb573d5f803e3d5ffd5b505050507feed65fb1c2451c54bb6eb3a6f3fe2fbe77ffd432b1f447c171237f36b8947202826040516107bb919061243c565b610f3661200e565b805f03610f555760405162461bcd60e51b815260040161069e9061270e565b6005545f03610fa25760405162461bcd60e51b815260206004820152601960248201527873686f756c6420776974686472617720696e7374616e746c7960381b604482015260640161069e565b6040516370a0823160e01b81527f0000000000000000000000007122985656e38bdc0302db86685bb972b145bd3c907f000000000000000000000000ec306e46549a7e8f4fce823d3058f2d134133b179083906001600160a01b038416906370a082319061101490339060040161243c565b602060405180830381865afa15801561102f573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061105391906126ba565b10156110925760405162461bcd60e51b815260206004820152600e60248201526d6578636565642062616c616e636560901b604482015260640161069e565b6110be7f0000000000000000000000007122985656e38bdc0302db86685bb972b145bd3c333086612065565b826008546110cc91906126d1565b600855335f908152600d60205260409020600554815403611101578381600101546110f791906126d1565b60018201556111d3565b80545f0361111a576001810184905560055481556111d3565b600181015481545f908152600b6020526040812054909161113a91611f45565b6001830154604051632770a7eb60e21b81529192506001600160a01b03851691639dc29fac9161116f91309190600401612731565b5f604051808303815f87803b158015611186575f80fd5b505af1158015611198573d5f803e3d5ffd5b50505060018301546007546111ad92506126e4565b6007556001820185905560028201546111c79082906126d1565b60028301555060055481555b60055460405133917f0c53c82ad07e2d592d88ece3b066777dd60f1118e2a081b380efc4358f0d9e2a91611208918891612496565b60405180910390a250505061121c60015f55565b50565b611227611ee6565b60405163768aac5d60e01b81527f000000000000000000000000396abf9ff46e21694f4ef01ca77c6d7893a017b2906001600160a01b0382169063768aac5d9061127590859060040161243c565b5f604051808303815f87803b15801561128c575f80fd5b505af115801561129e573d5f803e3d5ffd5b505050507f700c330a34830acb29f2b4927829f605fae4e5b7197df45a7973d246039e1e01826040516107bb919061243c565b5f805f7f0000000000000000000000009485711f11b17f73f2ccc8561bcae05bdc7e9ad99050600654816001600160a01b03166312065fe06040518163ffffffff1660e01b8152600401602060405180830381865afa158015611336573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061135a91906126ba565b11156113d057600654816001600160a01b03166312065fe06040518163ffffffff1660e01b8152600401602060405180830381865afa15801561139f573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906113c391906126ba565b6113cd91906126e4565b92505b7f000000000000000000000000396abf9ff46e21694f4ef01ca77c6d7893a017b26001600160a01b031663f837df256040518163ffffffff1660e01b81526004016020604051808303815f875af115801561142d573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061145191906126ba565b9150509091565b6001546001600160a01b031690565b61146f61200e565b805f0361148e5760405162461bcd60e51b815260040161069e9061270e565b335f908152600d602052604090206005548154146114e45760405162461bcd60e51b81526020600482015260136024820152726e6f2070656e64696e6720776974686472617760681b604482015260640161069e565b81816001015410156115325760405162461bcd60e51b81526020600482015260176024820152766578636565642070656e64696e6720776974686472617760481b604482015260640161069e565b81816001015461154291906126e4565b60018201556115727f0000000000000000000000007122985656e38bdc0302db86685bb972b145bd3c338461216a565b80600101545f03611581575f81555b8160085461158f91906126e4565b60085560055460405133917f39e2e01794006bc1f63835af5c05db790beca4bfb40de3f02cc3ddf22dccc0fb916115c7918691612496565b60405180910390a25061121c60015f55565b5f6115e261200e565b6115ec3483612268565b90506115f760015f55565b919050565b5f61160561200e565b8215158061161257508115155b61162e5760405162461bcd60e51b815260040161069e9061270e565b7f0000000000000000000000009485711f11b17f73f2ccc8561bcae05bdc7e9ad97f000000000000000000000000ec306e46549a7e8f4fce823d3058f2d134133b175f6116796112d1565b50905085156117fd57335f908152600d602052604090206005548154148015906116a35750805415155b1561175e57600181015481545f908152600b602052604081205490916116c891611f45565b6001830154604051632770a7eb60e21b81529192506001600160a01b03861691639dc29fac916116fd91309190600401612731565b5f604051808303815f87803b158015611714575f80fd5b505af1158015611726573d5f803e3d5ffd5b505050600183015460075461173b92506126e4565b6007555f600183015560028201546117549082906126d1565b6002830155505f81555b86816002015410156117a85760405162461bcd60e51b815260206004820152601360248201527265786365656420776974686472617761626c6560681b604482015260640161069e565b8681600201546117b891906126e4565b60028201556006546117cb9088906126e4565b60065560055460405188965033915f80516020612903833981519152916117f3918991612496565b60405180910390a2505b8415611a11575f6005545f0361181c5750670de0b6b3a764000061185e565b5f61182561095f565b90505f600b5f600160055461183a91906126e4565b81526020019081526020015f205490508181106118575781611859565b805b925050505b5f6118698783611f45565b604051632770a7eb60e21b81529091506001600160a01b03851690639dc29fac9061189a9033908b90600401612731565b5f604051808303815f87803b1580156118b1575f80fd5b505af11580156118c3573d5f803e3d5ffd5b50505050828111611911576118d881876126d1565b9550336001600160a01b03165f8051602061290383398151915282600554604051611904929190612496565b60405180910390a2611a0e565b61191b83876126d1565b955061192783826126e4565b604051630fcc56f760e01b8152600481018290529091507f000000000000000000000000396abf9ff46e21694f4ef01ca77c6d7893a017b2905f906001600160a01b03831690630fcc56f7906024016020604051808303815f875af1158015611992573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906119b691906126ba565b90506119c281896126d1565b9750336001600160a01b03167f1b84e2f0660a601edc93ceed0d08fa5e9b3cbe4e2450c262f2ea8531d2c52e958483600554604051611a03939291906124a4565b60405180910390a250505b50505b83836001600160a01b03166312065fe06040518163ffffffff1660e01b8152600401602060405180830381865afa158015611a4e573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611a7291906126ba565b1015611ab25760405162461bcd60e51b815260206004820152600f60248201526e1cdd1a5b1b081b995959081dd85a5d608a1b604482015260640161069e565b5f6009545f14611b7157620f424060095486611ace91906126f7565b611ad89190612675565b6004805460405163f3fef3a360e01b81529293506001600160a01b038088169363f3fef3a393611b0e9390921691869101612731565b5f604051808303815f87803b158015611b25575f80fd5b505af1158015611b37573d5f803e3d5ffd5b50506040518381523392507f55bb3cade9d43b798a4fe5ffdd05024b2d7870df53920673bfc7e68047cd0ab1915060200160405180910390a25b6001600160a01b03841663f3fef3a333611b8b84896126e4565b6040518363ffffffff1660e01b8152600401611ba8929190612731565b5f604051808303815f87803b158015611bbf575f80fd5b505af1158015611bd1573d5f803e3d5ffd5b5050505050505050611be260015f55565b92915050565b5f611bf161200e565b611bfb3433612268565b9050611c0660015f55565b90565b611c11611ee6565b6001600160a01b038116611c565760405162461bcd60e51b815260206004820152600c60248201526b7a65726f206164647265737360a01b604482015260640161069e565b600454604080516001600160a01b03928316815291831660208301527fd9d6b85b6d670cd443496fc6d03390f739bbff47f96a8e33fb0cdd52ad26f5c2910160405180910390a1600480546001600160a01b0319166001600160a01b0392909216919091179055565b6003546001600160a01b03163314611ce95760405162461bcd60e51b815260040161069e90612694565b600380546001600160a01b0319166001600160a01b0392909216919091179055565b611d13611ee6565b62093a80811115611d505760405162461bcd60e51b81526020600482015260076024820152661a5b9d985b1a5960ca1b604482015260640161069e565b60028190556040518181527f73b75c75399b0450cd07a0e5188f0e06ce9e484fea18044b25e0326feb8e0e2a9060200160405180910390a150565b611d93611ee6565b6001600160a01b038116611df85760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b606482015260840161069e565b61121c81611fbd565b6003546001600160a01b03163314611e2b5760405162461bcd60e51b815260040161069e90612694565b604051633fea70a760e01b81527f000000000000000000000000396abf9ff46e21694f4ef01ca77c6d7893a017b2906001600160a01b03821690633fea70a790611e7b908690869060040161274a565b5f604051808303815f87803b158015611e92575f80fd5b505af1158015611ea4573d5f803e3d5ffd5b505050507fb08ed47ad81ee926c18b77f6be44a5d49bf687355a669936e1f02cfe4e2c84f78383604051611ed992919061274a565b60405180910390a1505050565b33611eef611458565b6001600160a01b031614610e7a5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161069e565b5f60018211611f965760405162461bcd60e51b815260206004820181905260248201527f5661756c74204c69623a20696e76616c69642061737365745065725368617265604482015260640161069e565b611fa26012600a6128ac565b611fac83856126f7565b611fb69190612675565b9392505050565b600180546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0905f90a35050565b60025f540361205f5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015260640161069e565b60025f55565b604080516001600160a01b0385811660248301528481166044830152606480830185905283518084039091018152608490920183526020820180516001600160e01b03166323b872dd60e01b17905291515f928392908816916120c891906128b7565b5f604051808303815f865af19150503d805f8114612101576040519150601f19603f3d011682016040523d82523d5f602084013e612106565b606091505b509150915081801561213057508051158061213057508080602001905181019061213091906128e3565b6121625760405162461bcd60e51b815260206004820152600360248201526229aa2360e91b604482015260640161069e565b505050505050565b5f80846001600160a01b031663a9059cbb60e01b8585604051602401612191929190612731565b60408051601f198184030181529181526020820180516001600160e01b03166001600160e01b03199094169390931790925290516121cf91906128b7565b5f604051808303815f865af19150503d805f8114612208576040519150601f19603f3d011682016040523d82523d5f602084013e61220d565b606091505b509150915081801561223757508051158061223757508080602001905181019061223791906128e3565b6109585760405162461bcd60e51b815260206004820152600260248201526114d560f21b604482015260640161069e565b5f825f036122885760405162461bcd60e51b815260040161069e9061270e565b5f8061229261095f565b90506005545f036122ad57670de0b6b3a764000091506122e3565b5f600b5f60016005546122c091906126e4565b81526020019081526020015f205490508181116122dd57816122df565b805b9250505b816122f6670de0b6b3a7640000876126f7565b6123009190612675565b92507f0000000000000000000000009485711f11b17f73f2ccc8561bcae05bdc7e9ad96001600160a01b031663d0e30db0476040518263ffffffff1660e01b81526004015f604051808303818588803b15801561235b575f80fd5b505af115801561236d573d5f803e3d5ffd5b50506040516340c10f1960e01b81526001600160a01b037f000000000000000000000000ec306e46549a7e8f4fce823d3058f2d134133b171693506340c10f1992506123c0915087908790600401612731565b5f604051808303815f87803b1580156123d7575f80fd5b505af11580156123e9573d5f803e3d5ffd5b50505050836001600160a01b03167f36af321ec8d3c75236829c5317affd40ddb308863a1236d2d277a4025cccee1e868560055460405161242c939291906124a4565b60405180910390a2505092915050565b6001600160a01b0391909116815260200190565b5f60208284031215612460575f80fd5b5035919050565b80356001600160a01b03811681146115f7575f80fd5b5f6020828403121561248d575f80fd5b611fb682612467565b918252602082015260400190565b9283526020830191909152604082015260600190565b5f80604083850312156124cb575f80fd5b50508035926020909101359150565b634e487b7160e01b5f52604160045260245ffd5b604051601f8201601f191681016001600160401b0381118282101715612516576125166124da565b604052919050565b5f6001600160401b03821115612536576125366124da565b5060051b60200190565b5f82601f83011261254f575f80fd5b8135602061256461255f8361251e565b6124ee565b82815260059290921b84018101918181019086841115612582575f80fd5b8286015b8481101561259d5780358352918301918301612586565b509695505050505050565b5f80604083850312156125b9575f80fd5b82356001600160401b03808211156125cf575f80fd5b818501915085601f8301126125e2575f80fd5b813560206125f261255f8361251e565b82815260059290921b84018101918181019089841115612610575f80fd5b948201945b838610156126355761262686612467565b82529482019490820190612615565b9650508601359250508082111561264a575f80fd5b5061265785828601612540565b9150509250929050565b634e487b7160e01b5f52601160045260245ffd5b5f8261268f57634e487b7160e01b5f52601260045260245ffd5b500490565b6020808252600c908201526b1b9bdd081c1c9bdc1bdcd85b60a21b604082015260600190565b5f602082840312156126ca575f80fd5b5051919050565b80820180821115611be257611be2612661565b81810381811115611be257611be2612661565b8082028115828204841417611be257611be2612661565b6020808252600990820152681d1bdbc81cdb585b1b60ba1b604082015260600190565b6001600160a01b03929092168252602082015260400190565b604080825283519082018190525f906020906060840190828701845b8281101561278b5781516001600160a01b031684529284019290840190600101612766565b505050838103828501528451808252858301918301905f5b818110156127bf578351835292840192918401916001016127a3565b5090979650505050505050565b600181815b8085111561280657815f19048211156127ec576127ec612661565b808516156127f957918102915b93841c93908002906127d1565b509250929050565b5f8261281c57506001611be2565b8161282857505f611be2565b816001811461283e576002811461284857612864565b6001915050611be2565b60ff84111561285957612859612661565b50506001821b611be2565b5060208310610133831016604e8410600b8410161715612887575081810a611be2565b61289183836127cc565b805f19048211156128a4576128a4612661565b029392505050565b5f611fb6838361280e565b5f82515f5b818110156128d657602081860181015185830152016128bc565b505f920191825250919050565b5f602082840312156128f3575f80fd5b81518015158114611fb6575f80fdfe92ccf450a286a957af52509bc1c9939d1a6a481783e142e41e2499f0bb66ebc6a2646970667358221220589edafabb62e4e2222be100a867ae28cb8024a70f3b12ceec8fc29df5b0aeaa64736f6c63430008150033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
000000000000000000000000ec306e46549a7e8f4fce823d3058f2d134133b170000000000000000000000003aa0670e24cb122e1d5307ed74b0c44d619aff9b0000000000000000000000009485711f11b17f73f2ccc8561bcae05bdc7e9ad900000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000001400000000000000000000000000000000000000000000000000000000000000004000000000000000000000000363d200e54fe86985790f4e210df9bfb142342020000000000000000000000009221fbe66be06f43dcbda3fc17cdd66ef1b236f9000000000000000000000000a66723d951f15423ef2c9c11edcb821e38301836000000000000000000000000856edf1b835ea02bf11b16f041df5a13ef1ec3d10000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000c35000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000061a800000000000000000000000000000000000000000000000000000000000086470
-----Decoded View---------------
Arg [0] : _minter (address): 0xEc306E46549A7E8f4fCE823D3058f2D134133B17
Arg [1] : _proposal (address): 0x3aa0670E24Cb122e1d5307Ed74b0c44d619aFF9b
Arg [2] : _assetsVault (address): 0x9485711f11B17f73f2CCc8561bcae05BDc7E9ad9
Arg [3] : _strategies (address[]): 0x363D200E54FE86985790f4E210dF9BfB14234202,0x9221FbE66Be06F43dCBda3FC17CdD66ef1b236f9,0xa66723D951F15423Ef2C9C11edcb821E38301836,0x856EdF1B835ea02Bf11B16F041DF5A13Ef1EC3d1
Arg [4] : _ratios (uint256[]): 50000,0,400000,550000
-----Encoded View---------------
15 Constructor Arguments found :
Arg [0] : 000000000000000000000000ec306e46549a7e8f4fce823d3058f2d134133b17
Arg [1] : 0000000000000000000000003aa0670e24cb122e1d5307ed74b0c44d619aff9b
Arg [2] : 0000000000000000000000009485711f11b17f73f2ccc8561bcae05bdc7e9ad9
Arg [3] : 00000000000000000000000000000000000000000000000000000000000000a0
Arg [4] : 0000000000000000000000000000000000000000000000000000000000000140
Arg [5] : 0000000000000000000000000000000000000000000000000000000000000004
Arg [6] : 000000000000000000000000363d200e54fe86985790f4e210df9bfb14234202
Arg [7] : 0000000000000000000000009221fbe66be06f43dcbda3fc17cdd66ef1b236f9
Arg [8] : 000000000000000000000000a66723d951f15423ef2c9c11edcb821e38301836
Arg [9] : 000000000000000000000000856edf1b835ea02bf11b16f041df5a13ef1ec3d1
Arg [10] : 0000000000000000000000000000000000000000000000000000000000000004
Arg [11] : 000000000000000000000000000000000000000000000000000000000000c350
Arg [12] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [13] : 0000000000000000000000000000000000000000000000000000000000061a80
Arg [14] : 0000000000000000000000000000000000000000000000000000000000086470
Loading...
Loading
Loading...
Loading
Loading...
Loading
[ Download: CSV Export ]
[ 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.