Source Code
Latest 25 from a total of 138 transactions
| Transaction Hash |
Method
|
Block
|
From
|
|
To
|
||||
|---|---|---|---|---|---|---|---|---|---|
| Submit | 21166087 | 457 days ago | IN | 0 ETH | 0.08597267 | ||||
| Submit | 21150642 | 459 days ago | IN | 0 ETH | 0.03070343 | ||||
| Submit | 21137751 | 461 days ago | IN | 0 ETH | 0.04432287 | ||||
| Submit | 21114831 | 464 days ago | IN | 0 ETH | 0.01418091 | ||||
| Submit | 21107662 | 465 days ago | IN | 0 ETH | 0.02298428 | ||||
| Submit | 21100500 | 466 days ago | IN | 0 ETH | 0.01009488 | ||||
| Submit | 21071834 | 470 days ago | IN | 0 ETH | 0.03236929 | ||||
| Submit | 21050344 | 473 days ago | IN | 0 ETH | 0.01149421 | ||||
| Submit | 20978670 | 483 days ago | IN | 0 ETH | 0.04777718 | ||||
| Submit | 20885539 | 496 days ago | IN | 0 ETH | 0.0217188 | ||||
| Submit | 20792351 | 509 days ago | IN | 0 ETH | 0.04942589 | ||||
| Submit | 20620577 | 533 days ago | IN | 0 ETH | 0.00430621 | ||||
| Submit | 20601820 | 536 days ago | IN | 0 ETH | 0.00098472 | ||||
| Submit | 20563226 | 541 days ago | IN | 0 ETH | 0.00660521 | ||||
| Submit | 20491595 | 551 days ago | IN | 0 ETH | 0.01040173 | ||||
| Submit | 20470074 | 554 days ago | IN | 0 ETH | 0.02053647 | ||||
| Submit | 20462912 | 555 days ago | IN | 0 ETH | 0.10048761 | ||||
| Submit | 20455732 | 556 days ago | IN | 0 ETH | 0.0035172 | ||||
| Submit | 20434266 | 559 days ago | IN | 0 ETH | 0.01821644 | ||||
| Submit | 20413352 | 562 days ago | IN | 0 ETH | 0.0056332 | ||||
| Submit | 20385974 | 566 days ago | IN | 0 ETH | 0.00582072 | ||||
| Submit | 20384118 | 566 days ago | IN | 0 ETH | 0.01159425 | ||||
| Submit | 20326795 | 574 days ago | IN | 0 ETH | 0.01456694 | ||||
| Submit | 20241332 | 586 days ago | IN | 0 ETH | 0.00766339 | ||||
| Submit | 20226688 | 588 days ago | IN | 0 ETH | 0.01188661 |
Latest 1 internal transaction
Advanced mode:
| Parent Transaction Hash | Method | Block |
From
|
|
To
|
||
|---|---|---|---|---|---|---|---|
| 0x61014060 | 18193147 | 873 days ago | Contract Creation | 0 ETH |
Loading...
Loading
Loading...
Loading
Cross-Chain Transactions
Loading...
Loading
Contract Name:
AeraVaultV2
Compiler Version
v0.8.21+commit.d9974bed
Optimization Enabled:
Yes with 200 runs
Other Settings:
paris EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.21;
import "@openzeppelin/ERC165.sol";
import "@openzeppelin/ERC165Checker.sol";
import "@openzeppelin/IERC4626.sol";
import "@openzeppelin/Math.sol";
import "@openzeppelin/Ownable2Step.sol";
import "@openzeppelin/Pausable.sol";
import "@openzeppelin/ReentrancyGuard.sol";
import "@openzeppelin/SafeERC20.sol";
import "./interfaces/IAeraV2Factory.sol";
import "./interfaces/IHooks.sol";
import "./interfaces/IVault.sol";
import {ONE} from "./Constants.sol";
/// @title AeraVaultV2.
/// @notice Aera Vault V2 Vault contract.
contract AeraVaultV2 is
IVault,
ERC165,
Ownable2Step,
Pausable,
ReentrancyGuard
{
using SafeERC20 for IERC20;
/// @notice Largest possible fee earned proportion per one second.
/// @dev 0.0000001% per second, i.e. 3.1536% per year.
/// 0.0000001% * (365 * 24 * 60 * 60) = 3.1536%
/// or 3.16224% per year in leap years.
uint256 private constant _MAX_FEE = 10 ** 9;
/// @notice Number of decimals for fee token.
uint256 private immutable _feeTokenDecimals;
/// @notice Number of decimals for numeraire token.
uint256 private immutable _numeraireTokenDecimals;
/// @notice Fee token used by asset registry.
IERC20 private immutable _feeToken;
/// @notice Fee per second in 18 decimal fixed point format.
uint256 public immutable fee;
/// @notice Asset registry address.
IAssetRegistry public immutable assetRegistry;
/// @notice The address of wrapped native token.
address public immutable wrappedNativeToken;
/// STORAGE ///
/// @notice Hooks module address.
IHooks public hooks;
/// @notice Guardian address.
address public guardian;
/// @notice Fee recipient address.
address public feeRecipient;
/// @notice True if vault has been finalized.
bool public finalized;
/// @notice Last measured value of assets in vault.
uint256 public lastValue;
/// @notice Last spot price of fee token.
uint256 public lastFeeTokenPrice;
/// @notice Fee earned amount for each prior fee recipient.
mapping(address => uint256) public fees;
/// @notice Total fee earned and unclaimed amount by all fee recipients.
uint256 public feeTotal;
/// @notice Last timestamp when fee index was reserved.
uint256 public lastFeeCheckpoint;
/// MODIFIERS ///
/// @dev Throws if called by any account other than the owner or guardian.
modifier onlyOwnerOrGuardian() {
if (msg.sender != owner() && msg.sender != guardian) {
revert Aera__CallerIsNotOwnerAndGuardian();
}
_;
}
/// @dev Throws if called by any account other than the guardian.
modifier onlyGuardian() {
if (msg.sender != guardian) {
revert Aera__CallerIsNotGuardian();
}
_;
}
/// @dev Throws if called after the vault is finalized.
modifier whenNotFinalized() {
if (finalized) {
revert Aera__VaultIsFinalized();
}
_;
}
/// @dev Throws if hooks is not set
modifier whenHooksSet() {
if (address(hooks) == address(0)) {
revert Aera__HooksIsZeroAddress();
}
_;
}
/// @dev Calculate current guardian fees.
modifier reserveFees() {
_reserveFees();
_;
}
/// @dev Check insolvency of fee token was not made worse.
modifier checkReservedFees() {
uint256 prevFeeTokenBalance =
IERC20(_feeToken).balanceOf(address(this));
_;
_checkReservedFees(prevFeeTokenBalance);
}
/// FUNCTIONS ///
constructor() Ownable() ReentrancyGuard() {
(
address owner_,
address assetRegistry_,
address hooks_,
address guardian_,
address feeRecipient_,
uint256 fee_
) = IAeraV2Factory(msg.sender).parameters();
// Requirements: check provided addresses.
_checkAssetRegistryAddress(assetRegistry_);
_checkHooksAddress(hooks_);
_checkGuardianAddress(guardian_, owner_);
_checkFeeRecipientAddress(feeRecipient_, owner_);
// Requirements: check that initial owner is not zero address.
if (owner_ == address(0)) {
revert Aera__InitialOwnerIsZeroAddress();
}
// Requirements: check if fee is within bounds.
if (fee_ > _MAX_FEE) {
revert Aera__FeeIsAboveMax(fee_, _MAX_FEE);
}
// Effects: initialize vault state.
wrappedNativeToken = IAeraV2Factory(msg.sender).wrappedNativeToken();
assetRegistry = IAssetRegistry(assetRegistry_);
hooks = IHooks(hooks_);
guardian = guardian_;
feeRecipient = feeRecipient_;
fee = fee_;
lastFeeCheckpoint = block.timestamp;
// Effects: cache numeraire and fee token decimals.
_feeToken = IAssetRegistry(assetRegistry_).feeToken();
_feeTokenDecimals = IERC20Metadata(address(_feeToken)).decimals();
_numeraireTokenDecimals =
IERC20Metadata(address(assetRegistry.numeraireToken())).decimals();
// Effects: set new owner.
_transferOwnership(owner_);
// Effects: pause vault.
_pause();
// Log setting of asset registry.
emit SetAssetRegistry(assetRegistry_);
// Log new hooks address.
emit SetHooks(hooks_);
// Log the current guardian and fee recipient.
emit SetGuardianAndFeeRecipient(guardian_, feeRecipient_);
}
/// @inheritdoc IVault
function deposit(AssetValue[] calldata amounts)
external
override
nonReentrant
onlyOwner
whenHooksSet
whenNotFinalized
reserveFees
{
// Hooks: before transferring assets.
hooks.beforeDeposit(amounts);
// Requirements: check that provided amounts are sorted by asset and unique.
_checkAmountsSorted(amounts);
IAssetRegistry.AssetInformation[] memory assets =
assetRegistry.assets();
uint256 numAmounts = amounts.length;
AssetValue memory assetValue;
bool isRegistered;
for (uint256 i = 0; i < numAmounts;) {
assetValue = amounts[i];
(isRegistered,) = _isAssetRegistered(assetValue.asset, assets);
// Requirements: check that deposited assets are registered.
if (!isRegistered) {
revert Aera__AssetIsNotRegistered(assetValue.asset);
}
// Interactions: transfer asset from owner to vault.
assetValue.asset.safeTransferFrom(
msg.sender, address(this), assetValue.value
);
unchecked {
i++; // gas savings
}
// Log deposit for this asset.
emit Deposit(msg.sender, assetValue.asset, assetValue.value);
}
// Hooks: after transferring assets.
hooks.afterDeposit(amounts);
}
/// @inheritdoc IVault
function withdraw(AssetValue[] calldata amounts)
external
override
nonReentrant
onlyOwner
whenHooksSet
whenNotFinalized
reserveFees
{
IAssetRegistry.AssetInformation[] memory assets =
assetRegistry.assets();
// Requirements: check the withdraw request.
_checkWithdrawRequest(assets, amounts);
// Requirements: check that provided amounts are sorted by asset and unique.
_checkAmountsSorted(amounts);
// Hooks: before transferring assets.
hooks.beforeWithdraw(amounts);
uint256 numAmounts = amounts.length;
AssetValue memory assetValue;
for (uint256 i = 0; i < numAmounts;) {
assetValue = amounts[i];
if (assetValue.value == 0) {
unchecked {
i++; // gas savings
}
continue;
}
// Interactions: withdraw assets.
assetValue.asset.safeTransfer(msg.sender, assetValue.value);
// Log withdrawal for this asset.
emit Withdraw(msg.sender, assetValue.asset, assetValue.value);
unchecked {
i++; // gas savings
}
}
// Hooks: after transferring assets.
hooks.afterWithdraw(amounts);
}
/// @inheritdoc IVault
function setGuardianAndFeeRecipient(
address newGuardian,
address newFeeRecipient
) external override onlyOwner whenNotFinalized reserveFees {
// Requirements: check guardian and fee recipient addresses.
_checkGuardianAddress(newGuardian, msg.sender);
_checkFeeRecipientAddress(newFeeRecipient, msg.sender);
// Effects: update guardian and fee recipient addresses.
guardian = newGuardian;
feeRecipient = newFeeRecipient;
// Log new guardian and fee recipient addresses.
emit SetGuardianAndFeeRecipient(newGuardian, newFeeRecipient);
}
/// @inheritdoc IVault
function setHooks(address newHooks)
external
override
nonReentrant
onlyOwner
whenNotFinalized
reserveFees
{
// Requirements: validate hooks address.
_checkHooksAddress(newHooks);
// Effects: decommission old hooks contract.
if (address(hooks) != address(0)) {
hooks.decommission();
}
// Effects: set new hooks address.
hooks = IHooks(newHooks);
// Log new hooks address.
emit SetHooks(newHooks);
}
/// @inheritdoc IVault
/// @dev reserveFees modifier is not used to avoid reverts.
function execute(Operation calldata operation)
external
override
nonReentrant
onlyOwner
{
// Requirements: check that the target contract is not hooks.
if (operation.target == address(hooks)) {
revert Aera__ExecuteTargetIsHooksAddress();
}
// Requirements: check that the target contract is not vault itself.
if (operation.target == address(this)) {
revert Aera__ExecuteTargetIsVaultAddress();
}
// Interactions: execute operation.
(bool success, bytes memory result) =
operation.target.call{value: operation.value}(operation.data);
// Invariants: check that the operation was successful.
if (!success) {
revert Aera__ExecutionFailed(result);
}
// Log that the operation was executed.
emit Executed(msg.sender, operation);
}
/// @inheritdoc IVault
function finalize()
external
override
nonReentrant
onlyOwner
whenHooksSet
whenNotFinalized
reserveFees
{
// Hooks: before finalizing.
hooks.beforeFinalize();
// Effects: mark the vault as finalized.
finalized = true;
IAssetRegistry.AssetInformation[] memory assets =
assetRegistry.assets();
AssetValue[] memory assetAmounts = _getHoldings(assets);
uint256 numAssetAmounts = assetAmounts.length;
for (uint256 i = 0; i < numAssetAmounts;) {
// Effects: transfer registered assets to owner.
// Excludes reserved fee tokens and native token (e.g., ETH).
if (assetAmounts[i].value > 0) {
assetAmounts[i].asset.safeTransfer(
msg.sender, assetAmounts[i].value
);
}
unchecked {
i++; // gas savings
}
}
// Hooks: after finalizing.
hooks.afterFinalize();
// Log finalization.
emit Finalized(msg.sender, assetAmounts);
}
/// @inheritdoc IVault
function pause()
external
override
nonReentrant
onlyOwnerOrGuardian
whenNotFinalized
reserveFees
{
// Requirements and Effects: checks contract is unpaused and pauses it.
_pause();
}
/// @inheritdoc IVault
function resume()
external
override
onlyOwner
whenHooksSet
whenNotFinalized
{
// Effects: start a new fee checkpoint.
lastFeeCheckpoint = block.timestamp;
// Requirements and Effects: checks contract is paused and unpauses it.
_unpause();
}
/// @inheritdoc IVault
function submit(Operation[] calldata operations)
external
override
nonReentrant
onlyGuardian
whenHooksSet
whenNotFinalized
whenNotPaused
reserveFees
checkReservedFees
{
// Hooks: before executing operations.
hooks.beforeSubmit(operations);
uint256 numOperations = operations.length;
Operation calldata operation;
bytes4 selector;
bool success;
bytes memory result;
address hooksAddress = address(hooks);
for (uint256 i = 0; i < numOperations;) {
operation = operations[i];
selector = bytes4(operation.data[0:4]);
// Requirements: validate that it doesn't transfer asset from owner.
if (
selector == IERC20.transferFrom.selector
&& abi.decode(operation.data[4:], (address)) == owner()
) {
revert Aera__SubmitTransfersAssetFromOwner();
}
// Requirements: check that operation is not trying to redeem ERC4626 shares from owner.
// This could occur if the owner had a pre-existing allowance introduced during deposit.
if (
selector == IERC4626.withdraw.selector
|| selector == IERC4626.redeem.selector
) {
(,, address assetOwner) =
abi.decode(operation.data[4:], (uint256, address, address));
if (assetOwner == owner()) {
revert Aera__SubmitRedeemERC4626AssetFromOwner();
}
}
// Requirements: check that the target contract is not hooks.
if (operation.target == hooksAddress) {
revert Aera__SubmitTargetIsHooksAddress(i);
}
// Requirements: check that the target contract is not vault itself.
if (operation.target == address(this)) {
revert Aera__SubmitTargetIsVaultAddress();
}
// Interactions: execute operation.
(success, result) =
operation.target.call{value: operation.value}(operation.data);
// Invariants: confirm that operation succeeded.
if (!success) {
revert Aera__SubmissionFailed(i, result);
}
unchecked {
i++; // gas savings
}
}
if (address(this).balance > 0) {
wrappedNativeToken.call{value: address(this).balance}("");
}
// Hooks: after executing operations.
hooks.afterSubmit(operations);
// Log submission.
emit Submitted(guardian, operations);
}
/// @inheritdoc IVault
function claim() external override nonReentrant reserveFees {
uint256 reservedFee = fees[msg.sender];
// Requirements: check that there are fees to claim.
if (reservedFee == 0) {
revert Aera__NoClaimableFeesForCaller(msg.sender);
}
uint256 availableFee =
Math.min(_feeToken.balanceOf(address(this)), reservedFee);
// Requirements: check that fees are available to claim.
if (availableFee == 0) {
revert Aera__NoAvailableFeesForCaller(msg.sender);
}
// Effects: update fee total.
feeTotal -= availableFee;
reservedFee -= availableFee;
// Effects: update leftover fee.
fees[msg.sender] = reservedFee;
// Interactions: transfer fee to caller.
_feeToken.safeTransfer(msg.sender, availableFee);
// Log the claim.
emit Claimed(msg.sender, availableFee, reservedFee, feeTotal);
}
/// @inheritdoc IVault
function holdings() external view override returns (AssetValue[] memory) {
IAssetRegistry.AssetInformation[] memory assets =
assetRegistry.assets();
return _getHoldings(assets);
}
/// @inheritdoc IVault
function value() external view override returns (uint256 vaultValue) {
IAssetRegistry.AssetPriceReading[] memory erc20SpotPrices =
assetRegistry.spotPrices();
(vaultValue,) = _value(erc20SpotPrices);
}
/// @inheritdoc IERC165
function supportsInterface(bytes4 interfaceId)
public
view
override
returns (bool)
{
return interfaceId == type(IVault).interfaceId
|| super.supportsInterface(interfaceId);
}
/// @inheritdoc Ownable
function renounceOwnership() public view override onlyOwner {
revert Aera__CannotRenounceOwnership();
}
/// @inheritdoc Ownable2Step
function transferOwnership(address newOwner) public override onlyOwner {
// Requirements: check that new owner is disaffiliated from existing roles.
if (newOwner == guardian) {
revert Aera__GuardianIsOwner();
}
if (newOwner == feeRecipient) {
revert Aera__FeeRecipientIsOwner();
}
// Effects: initiate ownership transfer.
super.transferOwnership(newOwner);
}
/// @notice Only accept native token from the wrapped native token contract
/// when burning wrapped native tokens.
receive() external payable {
// Requirements: verify that the sender is wrapped native token.
if (msg.sender != wrappedNativeToken) {
revert Aera__NotWrappedNativeTokenContract();
}
}
/// INTERNAL FUNCTIONS ///
/// @notice Calculate guardian fee index.
/// @return feeIndex Guardian fee index.
function _getFeeIndex() internal view returns (uint256 feeIndex) {
if (block.timestamp > lastFeeCheckpoint) {
unchecked {
feeIndex = block.timestamp - lastFeeCheckpoint;
}
}
return feeIndex;
}
/// @notice Calculate current guardian fees.
function _reserveFees() internal {
// Requirements: check if fees are being accrued.
if (fee == 0 || paused() || finalized) {
return;
}
uint256 feeIndex = _getFeeIndex();
// Requirements: check if fees have been accruing.
if (feeIndex == 0) {
return;
}
// Calculate vault value using oracle or backup value if oracle is reverting.
try assetRegistry.spotPrices() returns (
IAssetRegistry.AssetPriceReading[] memory erc20SpotPrices
) {
(lastValue, lastFeeTokenPrice) = _value(erc20SpotPrices);
} catch (bytes memory reason) {
// Check if there is a clear reason for the revert.
if (reason.length == 0) {
revert Aera__SpotPricesReverted();
}
emit SpotPricesReverted(reason);
}
// Requirements: check that fee token has a positive price.
if (lastFeeTokenPrice == 0) {
emit NoFeesReserved(lastFeeCheckpoint, lastValue, feeTotal);
return;
}
// Calculate new fee for current fee recipient.
// It calculates the fee in fee token decimals.
uint256 newFee = lastValue * feeIndex * fee;
if (_numeraireTokenDecimals < _feeTokenDecimals) {
newFee =
newFee * (10 ** (_feeTokenDecimals - _numeraireTokenDecimals));
} else if (_numeraireTokenDecimals > _feeTokenDecimals) {
newFee =
newFee / (10 ** (_numeraireTokenDecimals - _feeTokenDecimals));
}
newFee /= lastFeeTokenPrice;
if (newFee == 0) {
return;
}
// Move fee checkpoint only if fee is nonzero
lastFeeCheckpoint = block.timestamp;
// Effects: accrue fee to fee recipient and remember new fee total.
fees[feeRecipient] += newFee;
feeTotal += newFee;
// Log fee reservation.
emit FeesReserved(
feeRecipient,
newFee,
lastFeeCheckpoint,
lastValue,
lastFeeTokenPrice,
feeTotal
);
}
/// @notice Get current total value of assets in vault and price of fee token.
/// @dev It calculates the value in Numeraire token decimals.
/// @param erc20SpotPrices Spot prices of ERC20 assets.
/// @return vaultValue Current total value.
/// @return feeTokenPrice Fee token price.
function _value(IAssetRegistry.AssetPriceReading[] memory erc20SpotPrices)
internal
view
returns (uint256 vaultValue, uint256 feeTokenPrice)
{
IAssetRegistry.AssetInformation[] memory assets =
assetRegistry.assets();
AssetValue[] memory assetAmounts = _getHoldings(assets);
(uint256[] memory spotPrices, uint256[] memory assetUnits) =
_getSpotPricesAndUnits(assets, erc20SpotPrices);
uint256 numAssets = assets.length;
uint256 balance;
for (uint256 i = 0; i < numAssets;) {
if (assets[i].isERC4626) {
balance = IERC4626(address(assets[i].asset)).convertToAssets(
assetAmounts[i].value
);
} else {
balance = assetAmounts[i].value;
}
if (assets[i].asset == _feeToken) {
feeTokenPrice = spotPrices[i];
}
vaultValue += (balance * spotPrices[i]) / assetUnits[i];
unchecked {
i++; // gas savings
}
}
uint256 numeraireUnit = 10 ** _numeraireTokenDecimals;
if (numeraireUnit != ONE) {
vaultValue = vaultValue * numeraireUnit / ONE;
}
}
/// @notice Check that assets in provided amounts are sorted and unique.
/// @param amounts Struct details for assets and amounts to withdraw.
function _checkAmountsSorted(AssetValue[] memory amounts) internal pure {
uint256 numAssets = amounts.length;
for (uint256 i = 1; i < numAssets;) {
if (amounts[i - 1].asset >= amounts[i].asset) {
revert Aera__AmountsOrderIsIncorrect(i);
}
unchecked {
i++; // gas savings
}
}
}
/// @notice Check request to withdraw.
/// @param assets Struct details for asset information from asset registry.
/// @param amounts Struct details for assets and amounts to withdraw.
function _checkWithdrawRequest(
IAssetRegistry.AssetInformation[] memory assets,
AssetValue[] memory amounts
) internal view {
uint256 numAmounts = amounts.length;
AssetValue[] memory assetAmounts = _getHoldings(assets);
bool isRegistered;
AssetValue memory assetValue;
uint256 assetIndex;
for (uint256 i = 0; i < numAmounts;) {
assetValue = amounts[i];
(isRegistered, assetIndex) =
_isAssetRegistered(assetValue.asset, assets);
if (!isRegistered) {
revert Aera__AssetIsNotRegistered(assetValue.asset);
}
if (assetAmounts[assetIndex].value < assetValue.value) {
revert Aera__AmountExceedsAvailable(
assetValue.asset,
assetValue.value,
assetAmounts[assetIndex].value
);
}
unchecked {
i++; // gas savings
}
}
}
/// @notice Get spot prices and units of requested assets.
/// @dev Spot prices are scaled to 18 decimals.
/// @param assets Registered assets in asset registry and their information.
/// @param erc20SpotPrices Struct details for spot prices of ERC20 assets.
/// @return spotPrices Spot prices of assets.
/// @return assetUnits Units of assets.
function _getSpotPricesAndUnits(
IAssetRegistry.AssetInformation[] memory assets,
IAssetRegistry.AssetPriceReading[] memory erc20SpotPrices
)
internal
view
returns (uint256[] memory spotPrices, uint256[] memory assetUnits)
{
uint256 numAssets = assets.length;
uint256 numERC20SpotPrices = erc20SpotPrices.length;
spotPrices = new uint256[](numAssets);
assetUnits = new uint256[](numAssets);
IAssetRegistry.AssetInformation memory asset;
for (uint256 i = 0; i < numAssets;) {
asset = assets[i];
IERC20 assetToFind = (
asset.isERC4626
? IERC20(IERC4626(address(asset.asset)).asset())
: asset.asset
);
uint256 j = 0;
for (; j < numERC20SpotPrices;) {
if (assetToFind == erc20SpotPrices[j].asset) {
break;
}
unchecked {
j++; // gas savings
}
}
spotPrices[i] = erc20SpotPrices[j].spotPrice;
assetUnits[i] =
10 ** IERC20Metadata(address(assetToFind)).decimals();
unchecked {
i++; // gas savings
}
}
}
/// @notice Get total amount of assets in vault.
/// @param assets Struct details for registered assets in asset registry.
/// @return assetAmounts Amount of assets.
function _getHoldings(IAssetRegistry.AssetInformation[] memory assets)
internal
view
returns (AssetValue[] memory assetAmounts)
{
uint256 numAssets = assets.length;
assetAmounts = new AssetValue[](numAssets);
IAssetRegistry.AssetInformation memory assetInfo;
for (uint256 i = 0; i < numAssets;) {
assetInfo = assets[i];
assetAmounts[i] = AssetValue({
asset: assetInfo.asset,
value: assetInfo.asset.balanceOf(address(this))
});
if (assetInfo.asset == _feeToken) {
assetAmounts[i].value -=
Math.min(feeTotal, assetAmounts[i].value);
}
unchecked {
i++; //gas savings
}
}
}
/// @notice Check if balance of fee becomes insolvent or becomes more insolvent.
/// @param prevFeeTokenBalance Balance of fee token before action.
function _checkReservedFees(uint256 prevFeeTokenBalance) internal view {
uint256 feeTokenBalance = IERC20(_feeToken).balanceOf(address(this));
if (
feeTokenBalance < feeTotal && feeTokenBalance < prevFeeTokenBalance
) {
revert Aera__CannotUseReservedFees();
}
}
/// @notice Check if the address can be a guardian.
/// @param newGuardian Address to check.
/// @param owner_ Owner address.
function _checkGuardianAddress(
address newGuardian,
address owner_
) internal pure {
if (newGuardian == address(0)) {
revert Aera__GuardianIsZeroAddress();
}
if (newGuardian == owner_) {
revert Aera__GuardianIsOwner();
}
}
/// @notice Check if the address can be a fee recipient.
/// @param newFeeRecipient Address to check.
/// @param owner_ Owner address.
function _checkFeeRecipientAddress(
address newFeeRecipient,
address owner_
) internal pure {
if (newFeeRecipient == address(0)) {
revert Aera__FeeRecipientIsZeroAddress();
}
if (newFeeRecipient == owner_) {
revert Aera__FeeRecipientIsOwner();
}
}
/// @notice Check if the address can be an asset registry.
/// @param newAssetRegistry Address to check.
function _checkAssetRegistryAddress(address newAssetRegistry)
internal
view
{
if (newAssetRegistry == address(0)) {
revert Aera__AssetRegistryIsZeroAddress();
}
if (
!ERC165Checker.supportsInterface(
newAssetRegistry, type(IAssetRegistry).interfaceId
)
) {
revert Aera__AssetRegistryIsNotValid(newAssetRegistry);
}
if (IAssetRegistry(newAssetRegistry).vault() != address(this)) {
revert Aera__AssetRegistryHasInvalidVault();
}
}
/// @notice Check if the address can be a hooks contract.
/// @param newHooks Address to check.
function _checkHooksAddress(address newHooks) internal view {
if (newHooks == address(0)) {
revert Aera__HooksIsZeroAddress();
}
if (
!ERC165Checker.supportsInterface(newHooks, type(IHooks).interfaceId)
) {
revert Aera__HooksIsNotValid(newHooks);
}
if (IHooks(newHooks).vault() != address(this)) {
revert Aera__HooksHasInvalidVault();
}
}
/// @notice Check whether asset is registered to asset registry or not.
/// @param asset Asset to check.
/// @param registeredAssets Array of registered assets.
/// @return isRegistered True if asset is registered.
/// @return index Index of asset in asset registry.
function _isAssetRegistered(
IERC20 asset,
IAssetRegistry.AssetInformation[] memory registeredAssets
) internal pure returns (bool isRegistered, uint256 index) {
uint256 numAssets = registeredAssets.length;
for (uint256 i = 0; i < numAssets;) {
if (registeredAssets[i].asset < asset) {
unchecked {
i++; // gas savings
}
continue;
}
if (registeredAssets[i].asset == asset) {
return (true, i);
}
break;
}
}
}// 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 (last updated v4.9.0) (utils/introspection/ERC165Checker.sol)
pragma solidity ^0.8.0;
import "./IERC165.sol";
/**
* @dev Library used to query support of an interface declared via {IERC165}.
*
* Note that these functions return the actual result of the query: they do not
* `revert` if an interface is not supported. It is up to the caller to decide
* what to do in these cases.
*/
library ERC165Checker {
// As per the EIP-165 spec, no interface should ever match 0xffffffff
bytes4 private constant _INTERFACE_ID_INVALID = 0xffffffff;
/**
* @dev Returns true if `account` supports the {IERC165} interface.
*/
function supportsERC165(address account) internal view returns (bool) {
// Any contract that implements ERC165 must explicitly indicate support of
// InterfaceId_ERC165 and explicitly indicate non-support of InterfaceId_Invalid
return
supportsERC165InterfaceUnchecked(account, type(IERC165).interfaceId) &&
!supportsERC165InterfaceUnchecked(account, _INTERFACE_ID_INVALID);
}
/**
* @dev Returns true if `account` supports the interface defined by
* `interfaceId`. Support for {IERC165} itself is queried automatically.
*
* See {IERC165-supportsInterface}.
*/
function supportsInterface(address account, bytes4 interfaceId) internal view returns (bool) {
// query support of both ERC165 as per the spec and support of _interfaceId
return supportsERC165(account) && supportsERC165InterfaceUnchecked(account, interfaceId);
}
/**
* @dev Returns a boolean array where each value corresponds to the
* interfaces passed in and whether they're supported or not. This allows
* you to batch check interfaces for a contract where your expectation
* is that some interfaces may not be supported.
*
* See {IERC165-supportsInterface}.
*
* _Available since v3.4._
*/
function getSupportedInterfaces(
address account,
bytes4[] memory interfaceIds
) internal view returns (bool[] memory) {
// an array of booleans corresponding to interfaceIds and whether they're supported or not
bool[] memory interfaceIdsSupported = new bool[](interfaceIds.length);
// query support of ERC165 itself
if (supportsERC165(account)) {
// query support of each interface in interfaceIds
for (uint256 i = 0; i < interfaceIds.length; i++) {
interfaceIdsSupported[i] = supportsERC165InterfaceUnchecked(account, interfaceIds[i]);
}
}
return interfaceIdsSupported;
}
/**
* @dev Returns true if `account` supports all the interfaces defined in
* `interfaceIds`. Support for {IERC165} itself is queried automatically.
*
* Batch-querying can lead to gas savings by skipping repeated checks for
* {IERC165} support.
*
* See {IERC165-supportsInterface}.
*/
function supportsAllInterfaces(address account, bytes4[] memory interfaceIds) internal view returns (bool) {
// query support of ERC165 itself
if (!supportsERC165(account)) {
return false;
}
// query support of each interface in interfaceIds
for (uint256 i = 0; i < interfaceIds.length; i++) {
if (!supportsERC165InterfaceUnchecked(account, interfaceIds[i])) {
return false;
}
}
// all interfaces supported
return true;
}
/**
* @notice Query if a contract implements an interface, does not check ERC165 support
* @param account The address of the contract to query for support of an interface
* @param interfaceId The interface identifier, as specified in ERC-165
* @return true if the contract at account indicates support of the interface with
* identifier interfaceId, false otherwise
* @dev Assumes that account contains a contract that supports ERC165, otherwise
* the behavior of this method is undefined. This precondition can be checked
* with {supportsERC165}.
*
* Some precompiled contracts will falsely indicate support for a given interface, so caution
* should be exercised when using this function.
*
* Interface identification is specified in ERC-165.
*/
function supportsERC165InterfaceUnchecked(address account, bytes4 interfaceId) internal view returns (bool) {
// prepare call
bytes memory encodedParams = abi.encodeWithSelector(IERC165.supportsInterface.selector, interfaceId);
// perform static call
bool success;
uint256 returnSize;
uint256 returnValue;
assembly {
success := staticcall(30000, account, add(encodedParams, 0x20), mload(encodedParams), 0x00, 0x20)
returnSize := returndatasize()
returnValue := mload(0x00)
}
return success && returnSize >= 0x20 && returnValue > 0;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (interfaces/IERC4626.sol)
pragma solidity ^0.8.0;
import "./IERC20.sol";
import "./IERC20Metadata.sol";
/**
* @dev Interface of the ERC4626 "Tokenized Vault Standard", as defined in
* https://eips.ethereum.org/EIPS/eip-4626[ERC-4626].
*
* _Available since v4.7._
*/
interface IERC4626 is IERC20, IERC20Metadata {
event Deposit(address indexed sender, address indexed owner, uint256 assets, uint256 shares);
event Withdraw(
address indexed sender,
address indexed receiver,
address indexed owner,
uint256 assets,
uint256 shares
);
/**
* @dev Returns the address of the underlying token used for the Vault for accounting, depositing, and withdrawing.
*
* - MUST be an ERC-20 token contract.
* - MUST NOT revert.
*/
function asset() external view returns (address assetTokenAddress);
/**
* @dev Returns the total amount of the underlying asset that is “managed” by Vault.
*
* - SHOULD include any compounding that occurs from yield.
* - MUST be inclusive of any fees that are charged against assets in the Vault.
* - MUST NOT revert.
*/
function totalAssets() external view returns (uint256 totalManagedAssets);
/**
* @dev Returns the amount of shares that the Vault would exchange for the amount of assets provided, in an ideal
* scenario where all the conditions are met.
*
* - MUST NOT be inclusive of any fees that are charged against assets in the Vault.
* - MUST NOT show any variations depending on the caller.
* - MUST NOT reflect slippage or other on-chain conditions, when performing the actual exchange.
* - MUST NOT revert.
*
* NOTE: This calculation MAY NOT reflect the “per-user” price-per-share, and instead should reflect the
* “average-user’s” price-per-share, meaning what the average user should expect to see when exchanging to and
* from.
*/
function convertToShares(uint256 assets) external view returns (uint256 shares);
/**
* @dev Returns the amount of assets that the Vault would exchange for the amount of shares provided, in an ideal
* scenario where all the conditions are met.
*
* - MUST NOT be inclusive of any fees that are charged against assets in the Vault.
* - MUST NOT show any variations depending on the caller.
* - MUST NOT reflect slippage or other on-chain conditions, when performing the actual exchange.
* - MUST NOT revert.
*
* NOTE: This calculation MAY NOT reflect the “per-user” price-per-share, and instead should reflect the
* “average-user’s” price-per-share, meaning what the average user should expect to see when exchanging to and
* from.
*/
function convertToAssets(uint256 shares) external view returns (uint256 assets);
/**
* @dev Returns the maximum amount of the underlying asset that can be deposited into the Vault for the receiver,
* through a deposit call.
*
* - MUST return a limited value if receiver is subject to some deposit limit.
* - MUST return 2 ** 256 - 1 if there is no limit on the maximum amount of assets that may be deposited.
* - MUST NOT revert.
*/
function maxDeposit(address receiver) external view returns (uint256 maxAssets);
/**
* @dev Allows an on-chain or off-chain user to simulate the effects of their deposit at the current block, given
* current on-chain conditions.
*
* - MUST return as close to and no more than the exact amount of Vault shares that would be minted in a deposit
* call in the same transaction. I.e. deposit should return the same or more shares as previewDeposit if called
* in the same transaction.
* - MUST NOT account for deposit limits like those returned from maxDeposit and should always act as though the
* deposit would be accepted, regardless if the user has enough tokens approved, etc.
* - MUST be inclusive of deposit fees. Integrators should be aware of the existence of deposit fees.
* - MUST NOT revert.
*
* NOTE: any unfavorable discrepancy between convertToShares and previewDeposit SHOULD be considered slippage in
* share price or some other type of condition, meaning the depositor will lose assets by depositing.
*/
function previewDeposit(uint256 assets) external view returns (uint256 shares);
/**
* @dev Mints shares Vault shares to receiver by depositing exactly amount of underlying tokens.
*
* - MUST emit the Deposit event.
* - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the
* deposit execution, and are accounted for during deposit.
* - MUST revert if all of assets cannot be deposited (due to deposit limit being reached, slippage, the user not
* approving enough underlying tokens to the Vault contract, etc).
*
* NOTE: most implementations will require pre-approval of the Vault with the Vault’s underlying asset token.
*/
function deposit(uint256 assets, address receiver) external returns (uint256 shares);
/**
* @dev Returns the maximum amount of the Vault shares that can be minted for the receiver, through a mint call.
* - MUST return a limited value if receiver is subject to some mint limit.
* - MUST return 2 ** 256 - 1 if there is no limit on the maximum amount of shares that may be minted.
* - MUST NOT revert.
*/
function maxMint(address receiver) external view returns (uint256 maxShares);
/**
* @dev Allows an on-chain or off-chain user to simulate the effects of their mint at the current block, given
* current on-chain conditions.
*
* - MUST return as close to and no fewer than the exact amount of assets that would be deposited in a mint call
* in the same transaction. I.e. mint should return the same or fewer assets as previewMint if called in the
* same transaction.
* - MUST NOT account for mint limits like those returned from maxMint and should always act as though the mint
* would be accepted, regardless if the user has enough tokens approved, etc.
* - MUST be inclusive of deposit fees. Integrators should be aware of the existence of deposit fees.
* - MUST NOT revert.
*
* NOTE: any unfavorable discrepancy between convertToAssets and previewMint SHOULD be considered slippage in
* share price or some other type of condition, meaning the depositor will lose assets by minting.
*/
function previewMint(uint256 shares) external view returns (uint256 assets);
/**
* @dev Mints exactly shares Vault shares to receiver by depositing amount of underlying tokens.
*
* - MUST emit the Deposit event.
* - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the mint
* execution, and are accounted for during mint.
* - MUST revert if all of shares cannot be minted (due to deposit limit being reached, slippage, the user not
* approving enough underlying tokens to the Vault contract, etc).
*
* NOTE: most implementations will require pre-approval of the Vault with the Vault’s underlying asset token.
*/
function mint(uint256 shares, address receiver) external returns (uint256 assets);
/**
* @dev Returns the maximum amount of the underlying asset that can be withdrawn from the owner balance in the
* Vault, through a withdraw call.
*
* - MUST return a limited value if owner is subject to some withdrawal limit or timelock.
* - MUST NOT revert.
*/
function maxWithdraw(address owner) external view returns (uint256 maxAssets);
/**
* @dev Allows an on-chain or off-chain user to simulate the effects of their withdrawal at the current block,
* given current on-chain conditions.
*
* - MUST return as close to and no fewer than the exact amount of Vault shares that would be burned in a withdraw
* call in the same transaction. I.e. withdraw should return the same or fewer shares as previewWithdraw if
* called
* in the same transaction.
* - MUST NOT account for withdrawal limits like those returned from maxWithdraw and should always act as though
* the withdrawal would be accepted, regardless if the user has enough shares, etc.
* - MUST be inclusive of withdrawal fees. Integrators should be aware of the existence of withdrawal fees.
* - MUST NOT revert.
*
* NOTE: any unfavorable discrepancy between convertToShares and previewWithdraw SHOULD be considered slippage in
* share price or some other type of condition, meaning the depositor will lose assets by depositing.
*/
function previewWithdraw(uint256 assets) external view returns (uint256 shares);
/**
* @dev Burns shares from owner and sends exactly assets of underlying tokens to receiver.
*
* - MUST emit the Withdraw event.
* - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the
* withdraw execution, and are accounted for during withdraw.
* - MUST revert if all of assets cannot be withdrawn (due to withdrawal limit being reached, slippage, the owner
* not having enough shares, etc).
*
* Note that some implementations will require pre-requesting to the Vault before a withdrawal may be performed.
* Those methods should be performed separately.
*/
function withdraw(uint256 assets, address receiver, address owner) external returns (uint256 shares);
/**
* @dev Returns the maximum amount of Vault shares that can be redeemed from the owner balance in the Vault,
* through a redeem call.
*
* - MUST return a limited value if owner is subject to some withdrawal limit or timelock.
* - MUST return balanceOf(owner) if owner is not subject to any withdrawal limit or timelock.
* - MUST NOT revert.
*/
function maxRedeem(address owner) external view returns (uint256 maxShares);
/**
* @dev Allows an on-chain or off-chain user to simulate the effects of their redeemption at the current block,
* given current on-chain conditions.
*
* - MUST return as close to and no more than the exact amount of assets that would be withdrawn in a redeem call
* in the same transaction. I.e. redeem should return the same or more assets as previewRedeem if called in the
* same transaction.
* - MUST NOT account for redemption limits like those returned from maxRedeem and should always act as though the
* redemption would be accepted, regardless if the user has enough shares, etc.
* - MUST be inclusive of withdrawal fees. Integrators should be aware of the existence of withdrawal fees.
* - MUST NOT revert.
*
* NOTE: any unfavorable discrepancy between convertToAssets and previewRedeem SHOULD be considered slippage in
* share price or some other type of condition, meaning the depositor will lose assets by redeeming.
*/
function previewRedeem(uint256 shares) external view returns (uint256 assets);
/**
* @dev Burns exactly shares from owner and sends assets of underlying tokens to receiver.
*
* - MUST emit the Withdraw event.
* - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the
* redeem execution, and are accounted for during redeem.
* - MUST revert if all of shares cannot be redeemed (due to withdrawal limit being reached, slippage, the owner
* not having enough shares, etc).
*
* NOTE: some implementations will require pre-requesting to the Vault before a withdrawal may be performed.
* Those methods should be performed separately.
*/
function redeem(uint256 shares, address receiver, address owner) external returns (uint256 assets);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/math/Math.sol)
pragma solidity ^0.8.0;
/**
* @dev Standard math utilities missing in the Solidity language.
*/
library Math {
enum Rounding {
Down, // Toward negative infinity
Up, // Toward infinity
Zero // Toward zero
}
/**
* @dev Returns the largest of two numbers.
*/
function max(uint256 a, uint256 b) internal pure returns (uint256) {
return a > b ? a : b;
}
/**
* @dev Returns the smallest of two numbers.
*/
function min(uint256 a, uint256 b) internal pure returns (uint256) {
return a < b ? a : b;
}
/**
* @dev Returns the average of two numbers. The result is rounded towards
* zero.
*/
function average(uint256 a, uint256 b) internal pure returns (uint256) {
// (a + b) / 2 can overflow.
return (a & b) + (a ^ b) / 2;
}
/**
* @dev Returns the ceiling of the division of two numbers.
*
* This differs from standard division with `/` in that it rounds up instead
* of rounding down.
*/
function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
// (a + b - 1) / b can overflow on addition, so we distribute.
return a == 0 ? 0 : (a - 1) / b + 1;
}
/**
* @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0
* @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)
* with further edits by Uniswap Labs also under MIT license.
*/
function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) {
unchecked {
// 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use
// use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256
// variables such that product = prod1 * 2^256 + prod0.
uint256 prod0; // Least significant 256 bits of the product
uint256 prod1; // Most significant 256 bits of the product
assembly {
let mm := mulmod(x, y, not(0))
prod0 := mul(x, y)
prod1 := sub(sub(mm, prod0), lt(mm, prod0))
}
// Handle non-overflow cases, 256 by 256 division.
if (prod1 == 0) {
// Solidity will revert if denominator == 0, unlike the div opcode on its own.
// The surrounding unchecked block does not change this fact.
// See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic.
return prod0 / denominator;
}
// Make sure the result is less than 2^256. Also prevents denominator == 0.
require(denominator > prod1, "Math: mulDiv overflow");
///////////////////////////////////////////////
// 512 by 256 division.
///////////////////////////////////////////////
// Make division exact by subtracting the remainder from [prod1 prod0].
uint256 remainder;
assembly {
// Compute remainder using mulmod.
remainder := mulmod(x, y, denominator)
// Subtract 256 bit number from 512 bit number.
prod1 := sub(prod1, gt(remainder, prod0))
prod0 := sub(prod0, remainder)
}
// Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.
// See https://cs.stackexchange.com/q/138556/92363.
// Does not overflow because the denominator cannot be zero at this stage in the function.
uint256 twos = denominator & (~denominator + 1);
assembly {
// Divide denominator by twos.
denominator := div(denominator, twos)
// Divide [prod1 prod0] by twos.
prod0 := div(prod0, twos)
// Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.
twos := add(div(sub(0, twos), twos), 1)
}
// Shift in bits from prod1 into prod0.
prod0 |= prod1 * twos;
// Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such
// that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for
// four bits. That is, denominator * inv = 1 mod 2^4.
uint256 inverse = (3 * denominator) ^ 2;
// Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works
// in modular arithmetic, doubling the correct bits in each step.
inverse *= 2 - denominator * inverse; // inverse mod 2^8
inverse *= 2 - denominator * inverse; // inverse mod 2^16
inverse *= 2 - denominator * inverse; // inverse mod 2^32
inverse *= 2 - denominator * inverse; // inverse mod 2^64
inverse *= 2 - denominator * inverse; // inverse mod 2^128
inverse *= 2 - denominator * inverse; // inverse mod 2^256
// Because the division is now exact we can divide by multiplying with the modular inverse of denominator.
// This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is
// less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1
// is no longer required.
result = prod0 * inverse;
return result;
}
}
/**
* @notice Calculates x * y / denominator with full precision, following the selected rounding direction.
*/
function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) {
uint256 result = mulDiv(x, y, denominator);
if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {
result += 1;
}
return result;
}
/**
* @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down.
*
* Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11).
*/
function sqrt(uint256 a) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
// For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.
//
// We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have
// `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.
//
// This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`
// → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`
// → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`
//
// Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.
uint256 result = 1 << (log2(a) >> 1);
// At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,
// since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at
// every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision
// into the expected uint128 result.
unchecked {
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
return min(result, a / result);
}
}
/**
* @notice Calculates sqrt(a), following the selected rounding direction.
*/
function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = sqrt(a);
return result + (rounding == Rounding.Up && result * result < a ? 1 : 0);
}
}
/**
* @dev Return the log in base 2, rounded down, of a positive value.
* Returns 0 if given 0.
*/
function log2(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >> 128 > 0) {
value >>= 128;
result += 128;
}
if (value >> 64 > 0) {
value >>= 64;
result += 64;
}
if (value >> 32 > 0) {
value >>= 32;
result += 32;
}
if (value >> 16 > 0) {
value >>= 16;
result += 16;
}
if (value >> 8 > 0) {
value >>= 8;
result += 8;
}
if (value >> 4 > 0) {
value >>= 4;
result += 4;
}
if (value >> 2 > 0) {
value >>= 2;
result += 2;
}
if (value >> 1 > 0) {
result += 1;
}
}
return result;
}
/**
* @dev Return the log in base 2, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log2(value);
return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0);
}
}
/**
* @dev Return the log in base 10, rounded down, of a positive value.
* Returns 0 if given 0.
*/
function log10(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >= 10 ** 64) {
value /= 10 ** 64;
result += 64;
}
if (value >= 10 ** 32) {
value /= 10 ** 32;
result += 32;
}
if (value >= 10 ** 16) {
value /= 10 ** 16;
result += 16;
}
if (value >= 10 ** 8) {
value /= 10 ** 8;
result += 8;
}
if (value >= 10 ** 4) {
value /= 10 ** 4;
result += 4;
}
if (value >= 10 ** 2) {
value /= 10 ** 2;
result += 2;
}
if (value >= 10 ** 1) {
result += 1;
}
}
return result;
}
/**
* @dev Return the log in base 10, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log10(value);
return result + (rounding == Rounding.Up && 10 ** result < value ? 1 : 0);
}
}
/**
* @dev Return the log in base 256, rounded down, of a positive value.
* Returns 0 if given 0.
*
* Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.
*/
function log256(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >> 128 > 0) {
value >>= 128;
result += 16;
}
if (value >> 64 > 0) {
value >>= 64;
result += 8;
}
if (value >> 32 > 0) {
value >>= 32;
result += 4;
}
if (value >> 16 > 0) {
value >>= 16;
result += 2;
}
if (value >> 8 > 0) {
result += 1;
}
}
return result;
}
/**
* @dev Return the log in base 256, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log256(value);
return result + (rounding == Rounding.Up && 1 << (result << 3) < value ? 1 : 0);
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (access/Ownable2Step.sol)
pragma solidity ^0.8.0;
import "./Ownable.sol";
/**
* @dev Contract module which provides 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} and {acceptOwnership}.
*
* This module is used through inheritance. It will make available all functions
* from parent (Ownable).
*/
abstract contract Ownable2Step is Ownable {
address private _pendingOwner;
event OwnershipTransferStarted(address indexed previousOwner, address indexed newOwner);
/**
* @dev Returns the address of the pending owner.
*/
function pendingOwner() public view virtual returns (address) {
return _pendingOwner;
}
/**
* @dev Starts the ownership transfer of the contract to a new account. Replaces the pending transfer if there is one.
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual override onlyOwner {
_pendingOwner = newOwner;
emit OwnershipTransferStarted(owner(), newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`) and deletes any pending owner.
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual override {
delete _pendingOwner;
super._transferOwnership(newOwner);
}
/**
* @dev The new owner accepts the ownership transfer.
*/
function acceptOwnership() public virtual {
address sender = _msgSender();
require(pendingOwner() == sender, "Ownable2Step: caller is not the new owner");
_transferOwnership(sender);
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (security/Pausable.sol)
pragma solidity ^0.8.0;
import "./Context.sol";
/**
* @dev Contract module which allows children to implement an emergency stop
* mechanism that can be triggered by an authorized account.
*
* This module is used through inheritance. It will make available the
* modifiers `whenNotPaused` and `whenPaused`, which can be applied to
* the functions of your contract. Note that they will not be pausable by
* simply including this module, only once the modifiers are put in place.
*/
abstract contract Pausable is Context {
/**
* @dev Emitted when the pause is triggered by `account`.
*/
event Paused(address account);
/**
* @dev Emitted when the pause is lifted by `account`.
*/
event Unpaused(address account);
bool private _paused;
/**
* @dev Initializes the contract in unpaused state.
*/
constructor() {
_paused = false;
}
/**
* @dev Modifier to make a function callable only when the contract is not paused.
*
* Requirements:
*
* - The contract must not be paused.
*/
modifier whenNotPaused() {
_requireNotPaused();
_;
}
/**
* @dev Modifier to make a function callable only when the contract is paused.
*
* Requirements:
*
* - The contract must be paused.
*/
modifier whenPaused() {
_requirePaused();
_;
}
/**
* @dev Returns true if the contract is paused, and false otherwise.
*/
function paused() public view virtual returns (bool) {
return _paused;
}
/**
* @dev Throws if the contract is paused.
*/
function _requireNotPaused() internal view virtual {
require(!paused(), "Pausable: paused");
}
/**
* @dev Throws if the contract is not paused.
*/
function _requirePaused() internal view virtual {
require(paused(), "Pausable: not paused");
}
/**
* @dev Triggers stopped state.
*
* Requirements:
*
* - The contract must not be paused.
*/
function _pause() internal virtual whenNotPaused {
_paused = true;
emit Paused(_msgSender());
}
/**
* @dev Returns to normal state.
*
* Requirements:
*
* - The contract must be paused.
*/
function _unpause() internal virtual whenPaused {
_paused = false;
emit Unpaused(_msgSender());
}
}// 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) (token/ERC20/utils/SafeERC20.sol)
pragma solidity ^0.8.0;
import "./IERC20.sol";
import "./IERC20Permit.sol";
import "./Address.sol";
/**
* @title SafeERC20
* @dev Wrappers around ERC20 operations that throw on failure (when the token
* contract returns false). Tokens that return no value (and instead revert or
* throw on failure) are also supported, non-reverting calls are assumed to be
* successful.
* To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
* which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
*/
library SafeERC20 {
using Address for address;
/**
* @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*/
function safeTransfer(IERC20 token, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
}
/**
* @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the
* calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.
*/
function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
}
/**
* @dev Deprecated. This function has issues similar to the ones found in
* {IERC20-approve}, and its usage is discouraged.
*
* Whenever possible, use {safeIncreaseAllowance} and
* {safeDecreaseAllowance} instead.
*/
function safeApprove(IERC20 token, address spender, uint256 value) internal {
// safeApprove should only be called when setting an initial allowance,
// or when resetting it to zero. To increase and decrease it, use
// 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
require(
(value == 0) || (token.allowance(address(this), spender) == 0),
"SafeERC20: approve from non-zero to non-zero allowance"
);
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
}
/**
* @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*/
function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
uint256 oldAllowance = token.allowance(address(this), spender);
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance + value));
}
/**
* @dev Decrease the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*/
function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal {
unchecked {
uint256 oldAllowance = token.allowance(address(this), spender);
require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance - value));
}
}
/**
* @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful. Compatible with tokens that require the approval to be set to
* 0 before setting it to a non-zero value.
*/
function forceApprove(IERC20 token, address spender, uint256 value) internal {
bytes memory approvalCall = abi.encodeWithSelector(token.approve.selector, spender, value);
if (!_callOptionalReturnBool(token, approvalCall)) {
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, 0));
_callOptionalReturn(token, approvalCall);
}
}
/**
* @dev Use a ERC-2612 signature to set the `owner` approval toward `spender` on `token`.
* Revert on invalid signature.
*/
function safePermit(
IERC20Permit token,
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) internal {
uint256 nonceBefore = token.nonces(owner);
token.permit(owner, spender, value, deadline, v, r, s);
uint256 nonceAfter = token.nonces(owner);
require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed");
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*/
function _callOptionalReturn(IERC20 token, bytes memory data) private {
// We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
// we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that
// the target address contains contract code and also asserts for success in the low-level call.
bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
require(returndata.length == 0 || abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*
* This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead.
*/
function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {
// We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
// we're implementing it ourselves. We cannot use {Address-functionCall} here since this should return false
// and not revert is the subcall reverts.
(bool success, bytes memory returndata) = address(token).call(data);
return
success && (returndata.length == 0 || abi.decode(returndata, (bool))) && Address.isContract(address(token));
}
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.21;
import {
AssetRegistryParameters,
HooksParameters,
VaultParameters
} from "../Types.sol";
/// @title IAeraV2Factory
/// @notice Interface for the V2 vault factory.
interface IAeraV2Factory {
/// @notice Create V2 vault.
/// @param saltInput The salt input value to generate salt.
/// @param description Vault description.
/// @param vaultParameters Struct details for vault deployment.
/// @param assetRegistryParameters Struct details for asset registry deployment.
/// @param hooksParameters Struct details for hooks deployment.
/// @return deployedVault The address of deployed vault.
/// @return deployedAssetRegistry The address of deployed asset registry.
/// @return deployedHooks The address of deployed hooks.
function create(
bytes32 saltInput,
string calldata description,
VaultParameters calldata vaultParameters,
AssetRegistryParameters memory assetRegistryParameters,
HooksParameters memory hooksParameters
)
external
returns (
address deployedVault,
address deployedAssetRegistry,
address deployedHooks
);
/// @notice Calculate deployment address of V2 vault.
/// @param saltInput The salt input value to generate salt.
/// @param description Vault description.
/// @param vaultParameters Struct details for vault deployment.
function computeVaultAddress(
bytes32 saltInput,
string calldata description,
VaultParameters calldata vaultParameters
) external view returns (address);
/// @notice Returns the address of wrapped native token.
function wrappedNativeToken() external view returns (address);
/// @notice Returns vault parameters for vault deployment.
/// @return owner Initial owner address.
/// @return assetRegistry Asset registry address.
/// @return hooks Hooks address.
/// @return guardian Guardian address.
/// @return feeRecipient Fee recipient address.
/// @return fee Fees accrued per second, denoted in 18 decimal fixed point format.
function parameters()
external
view
returns (
address owner,
address assetRegistry,
address hooks,
address guardian,
address feeRecipient,
uint256 fee
);
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.21;
import {AssetValue, Operation} from "../Types.sol";
/// @title IHooks
/// @notice Interface for the hooks module.
interface IHooks {
/// @notice Get address of vault.
/// @return vault Vault address.
function vault() external view returns (address vault);
/// @notice Hook that runs before deposit.
/// @param amounts Struct details for assets and amounts to deposit.
/// @dev MUST revert if not called by vault.
function beforeDeposit(AssetValue[] memory amounts) external;
/// @notice Hook that runs after deposit.
/// @param amounts Struct details for assets and amounts to deposit.
/// @dev MUST revert if not called by vault.
function afterDeposit(AssetValue[] memory amounts) external;
/// @notice Hook that runs before withdraw.
/// @param amounts Struct details for assets and amounts to withdraw.
/// @dev MUST revert if not called by vault.
function beforeWithdraw(AssetValue[] memory amounts) external;
/// @notice Hook that runs after withdraw.
/// @param amounts Struct details for assets and amounts to withdraw.
/// @dev MUST revert if not called by vault.
function afterWithdraw(AssetValue[] memory amounts) external;
/// @notice Hook that runs before submit.
/// @param operations Array of struct details for target and calldata to submit.
/// @dev MUST revert if not called by vault.
function beforeSubmit(Operation[] memory operations) external;
/// @notice Hook that runs after submit.
/// @param operations Array of struct details for target and calldata to submit.
/// @dev MUST revert if not called by vault.
function afterSubmit(Operation[] memory operations) external;
/// @notice Hook that runs before finalize.
/// @dev MUST revert if not called by vault.
function beforeFinalize() external;
/// @notice Hook that runs after finalize.
/// @dev MUST revert if not called by vault.
function afterFinalize() external;
/// @notice Take hooks out of use.
function decommission() external;
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.21;
import "@openzeppelin/IERC20.sol";
import "./IAssetRegistry.sol";
import "./IVaultEvents.sol";
import "./IHooks.sol";
/// @title IVault
/// @notice Interface for the vault.
/// @dev Any implementation MUST also implement Ownable2Step.
interface IVault is IVaultEvents {
/// ERRORS ///
error Aera__AssetRegistryIsZeroAddress();
error Aera__AssetRegistryIsNotValid(address assetRegistry);
error Aera__AssetRegistryHasInvalidVault();
error Aera__HooksIsZeroAddress();
error Aera__HooksIsNotValid(address hooks);
error Aera__HooksHasInvalidVault();
error Aera__GuardianIsZeroAddress();
error Aera__GuardianIsOwner();
error Aera__InitialOwnerIsZeroAddress();
error Aera__FeeRecipientIsZeroAddress();
error Aera__ExecuteTargetIsHooksAddress();
error Aera__ExecuteTargetIsVaultAddress();
error Aera__SubmitTransfersAssetFromOwner();
error Aera__SubmitRedeemERC4626AssetFromOwner();
error Aera__SubmitTargetIsVaultAddress();
error Aera__SubmitTargetIsHooksAddress(uint256 index);
error Aera__FeeRecipientIsOwner();
error Aera__FeeIsAboveMax(uint256 actual, uint256 max);
error Aera__CallerIsNotOwnerAndGuardian();
error Aera__CallerIsNotGuardian();
error Aera__AssetIsNotRegistered(IERC20 asset);
error Aera__AmountExceedsAvailable(
IERC20 asset, uint256 amount, uint256 available
);
error Aera__ExecutionFailed(bytes result);
error Aera__VaultIsFinalized();
error Aera__SubmissionFailed(uint256 index, bytes result);
error Aera__CannotUseReservedFees();
error Aera__SpotPricesReverted();
error Aera__AmountsOrderIsIncorrect(uint256 index);
error Aera__NoAvailableFeesForCaller(address caller);
error Aera__NoClaimableFeesForCaller(address caller);
error Aera__NotWrappedNativeTokenContract();
error Aera__CannotRenounceOwnership();
/// FUNCTIONS ///
/// @notice Deposit assets.
/// @param amounts Assets and amounts to deposit.
/// @dev MUST revert if not called by owner.
function deposit(AssetValue[] memory amounts) external;
/// @notice Withdraw assets.
/// @param amounts Assets and amounts to withdraw.
/// @dev MUST revert if not called by owner.
function withdraw(AssetValue[] memory amounts) external;
/// @notice Set current guardian and fee recipient.
/// @param guardian New guardian address.
/// @param feeRecipient New fee recipient address.
/// @dev MUST revert if not called by owner.
function setGuardianAndFeeRecipient(
address guardian,
address feeRecipient
) external;
/// @notice Sets the current hooks module.
/// @param hooks New hooks module address.
/// @dev MUST revert if not called by owner.
function setHooks(address hooks) external;
/// @notice Execute a transaction via the vault.
/// @dev Execution still should work when vault is finalized.
/// @param operation Struct details for target and calldata to execute.
/// @dev MUST revert if not called by owner.
function execute(Operation memory operation) external;
/// @notice Terminate the vault and return all funds to owner.
/// @dev MUST revert if not called by owner.
function finalize() external;
/// @notice Stops the guardian from submission and halts fee accrual.
/// @dev MUST revert if not called by owner or guardian.
function pause() external;
/// @notice Resume fee accrual and guardian submissions.
/// @dev MUST revert if not called by owner.
function resume() external;
/// @notice Submit a series of transactions for execution via the vault.
/// @param operations Sequence of operations to execute.
/// @dev MUST revert if not called by guardian.
function submit(Operation[] memory operations) external;
/// @notice Claim fees on behalf of a current or previous fee recipient.
function claim() external;
/// @notice Get the current guardian.
/// @return guardian Address of guardian.
function guardian() external view returns (address guardian);
/// @notice Get the current fee recipient.
/// @return feeRecipient Address of fee recipient.
function feeRecipient() external view returns (address feeRecipient);
/// @notice Get the current asset registry.
/// @return assetRegistry Address of asset registry.
function assetRegistry()
external
view
returns (IAssetRegistry assetRegistry);
/// @notice Get the current hooks module address.
/// @return hooks Address of hooks module.
function hooks() external view returns (IHooks hooks);
/// @notice Get fee per second.
/// @return fee Fee per second in 18 decimal fixed point format.
function fee() external view returns (uint256 fee);
/// @notice Get current balances of all assets.
/// @return assetAmounts Amounts of registered assets.
function holdings()
external
view
returns (AssetValue[] memory assetAmounts);
/// @notice Get current total value of assets in vault.
/// @return value Current total value.
function value() external view returns (uint256 value);
}// SPDX-License-Identifier: BUSL-1.1 pragma solidity 0.8.21; // Constants.sol // // This file defines the constants used across several contracts in V2. /// @dev Fixed point multiplier. uint256 constant ONE = 1e18;
// 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 (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 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) (access/Ownable.sol)
pragma solidity ^0.8.0;
import "./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
// 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 (last updated v4.9.0) (token/ERC20/extensions/IERC20Permit.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
* https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
*
* Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
* presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't
* need to send a transaction, and thus is not required to hold Ether at all.
*/
interface IERC20Permit {
/**
* @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,
* given ``owner``'s signed approval.
*
* IMPORTANT: The same issues {IERC20-approve} has related to transaction
* ordering also apply here.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `deadline` must be a timestamp in the future.
* - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`
* over the EIP712-formatted function arguments.
* - the signature must use ``owner``'s current nonce (see {nonces}).
*
* For more information on the signature format, see the
* https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP
* section].
*/
function permit(
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) external;
/**
* @dev Returns the current nonce for `owner`. This value must be
* included whenever a signature is generated for {permit}.
*
* Every successful call to {permit} increases ``owner``'s nonce by one. This
* prevents a signature from being used multiple times.
*/
function nonces(address owner) external view returns (uint256);
/**
* @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.
*/
// solhint-disable-next-line func-name-mixedcase
function DOMAIN_SEPARATOR() external view returns (bytes32);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol)
pragma solidity ^0.8.1;
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
*
* Furthermore, `isContract` will also return true if the target contract within
* the same transaction is already scheduled for destruction by `SELFDESTRUCT`,
* which only has an effect at the end of a transaction.
* ====
*
* [IMPORTANT]
* ====
* You shouldn't rely on `isContract` to protect against flash loan attacks!
*
* Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
* like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
* constructor.
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize/address.code.length, which returns 0
// for contracts in construction, since the code is only stored at the end
// of the constructor execution.
return account.code.length > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.8.0/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory errorMessage
) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(
address target,
bytes memory data,
string memory errorMessage
) internal view returns (bytes memory) {
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling
* the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.
*
* _Available since v4.8._
*/
function verifyCallResultFromTarget(
address target,
bool success,
bytes memory returndata,
string memory errorMessage
) internal view returns (bytes memory) {
if (success) {
if (returndata.length == 0) {
// only check isContract if the call was successful and the return data is empty
// otherwise we already know that it was a contract
require(isContract(target), "Address: call to non-contract");
}
return returndata;
} else {
_revert(returndata, errorMessage);
}
}
/**
* @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the
* revert reason or using the provided one.
*
* _Available since v4.3._
*/
function verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) internal pure returns (bytes memory) {
if (success) {
return returndata;
} else {
_revert(returndata, errorMessage);
}
}
function _revert(bytes memory returndata, string memory errorMessage) private pure {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
/// @solidity memory-safe-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.21;
import "@openzeppelin/IERC20.sol";
import "./interfaces/IAssetRegistry.sol";
// Types.sol
//
// This file defines the types used in V2.
/// @notice Combination of contract address and sighash to be used in allowlist.
/// @dev It's packed as follows:
/// [target 160 bits] [selector 32 bits] [<empty> 64 bits]
type TargetSighash is bytes32;
/// @notice Struct encapulating an asset and an associated value.
/// @param asset Asset address.
/// @param value The associated value for this asset (e.g., amount or price).
struct AssetValue {
IERC20 asset;
uint256 value;
}
/// @notice Execution details for a vault operation.
/// @param target Target contract address.
/// @param value Native token amount.
/// @param data Calldata.
struct Operation {
address target;
uint256 value;
bytes data;
}
/// @notice Contract address and sighash struct to be used in the public interface.
struct TargetSighashData {
address target;
bytes4 selector;
}
/// @notice Parameters for vault deployment.
/// @param owner Initial owner address.
/// @param assetRegistry Asset registry address.
/// @param hooks Hooks address.
/// @param guardian Guardian address.
/// @param feeRecipient Fee recipient address.
/// @param fee Fees accrued per second, denoted in 18 decimal fixed point format.
struct Parameters {
address owner;
address assetRegistry;
address hooks;
address guardian;
address feeRecipient;
uint256 fee;
}
/// @notice Vault parameters for vault deployment.
/// @param owner Initial owner address.
/// @param guardian Guardian address.
/// @param feeRecipient Fee recipient address.
/// @param fee Fees accrued per second, denoted in 18 decimal fixed point format.
struct VaultParameters {
address owner;
address guardian;
address feeRecipient;
uint256 fee;
}
/// @notice Asset registry parameters for asset registry deployment.
/// @param factory Asset registry factory address.
/// @param owner Initial owner address.
/// @param assets Initial list of registered assets.
/// @param numeraireToken Numeraire token address.
/// @param feeToken Fee token address.
/// @param sequencer Sequencer Uptime Feed address for L2.
struct AssetRegistryParameters {
address factory;
address owner;
IAssetRegistry.AssetInformation[] assets;
IERC20 numeraireToken;
IERC20 feeToken;
AggregatorV2V3Interface sequencer;
}
/// @notice Hooks parameters for hooks deployment.
/// @param factory Hooks factory address.
/// @param owner Initial owner address.
/// @param minDailyValue The fraction of value that the vault has to retain per day
/// in the course of submissions.
/// @param targetSighashAllowlist Array of target contract and sighash combinations to allow.
struct HooksParameters {
address factory;
address owner;
uint256 minDailyValue;
TargetSighashData[] targetSighashAllowlist;
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.21;
import "@chainlink/interfaces/AggregatorV2V3Interface.sol";
import "@openzeppelin/IERC20.sol";
/// @title IAssetRegistry
/// @notice Asset registry interface.
/// @dev Any implementation MUST also implement Ownable2Step and ERC165.
interface IAssetRegistry {
/// @param asset Asset address.
/// @param heartbeat Frequency of oracle price updates.
/// @param isERC4626 True if yield-bearing asset, false if just an ERC20 asset.
/// @param oracle If applicable, oracle address for asset.
struct AssetInformation {
IERC20 asset;
uint256 heartbeat;
bool isERC4626;
AggregatorV2V3Interface oracle;
}
/// @param asset Asset address.
/// @param spotPrice Spot price of an asset in Numeraire token terms.
struct AssetPriceReading {
IERC20 asset;
uint256 spotPrice;
}
/// @notice Get address of vault.
/// @return vault Address of vault.
function vault() external view returns (address vault);
/// @notice Get a list of all registered assets.
/// @return assets List of assets.
/// @dev MUST return assets in an order sorted by address.
function assets()
external
view
returns (AssetInformation[] memory assets);
/// @notice Get address of fee token.
/// @return feeToken Address of fee token.
/// @dev Represented as an address for efficiency reasons.
/// @dev MUST be present in assets array.
function feeToken() external view returns (IERC20 feeToken);
/// @notice Get the index of the Numeraire token in the assets array.
/// @return numeraireToken Numeraire token address.
/// @dev Represented as an index for efficiency reasons.
/// @dev MUST be a number between 0 (inclusive) and the length of assets array (exclusive).
function numeraireToken() external view returns (IERC20 numeraireToken);
/// @notice Calculate spot prices of non-ERC4626 assets.
/// @return spotPrices Spot prices of non-ERC4626 assets in 18 decimals.
/// @dev MUST return assets in the same order as in assets but with ERC4626 assets filtered out.
/// @dev MUST also include Numeraire token (spot price = 1).
/// @dev MAY revert if oracle prices for any asset are unreliable at the time.
function spotPrices()
external
view
returns (AssetPriceReading[] memory spotPrices);
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.21;
import "@openzeppelin/IERC20.sol";
import {AssetValue, Operation} from "../Types.sol";
/// @title Interface for vault events.
interface IVaultEvents {
/// @notice Emitted when deposit is called.
/// @param owner Owner address.
/// @param asset Deposited asset.
/// @param amount Deposited asset amount.
event Deposit(address indexed owner, IERC20 indexed asset, uint256 amount);
/// @notice Emitted when withdraw is called.
/// @param owner Owner address.
/// @param asset Withdrawn asset.
/// @param amount Withdrawn asset amount.
event Withdraw(
address indexed owner, IERC20 indexed asset, uint256 amount
);
/// @notice Emitted when guardian is set.
/// @param guardian Address of new guardian.
/// @param feeRecipient Address of new fee recipient.
event SetGuardianAndFeeRecipient(
address indexed guardian, address indexed feeRecipient
);
/// @notice Emitted when asset registry is set.
/// @param assetRegistry Address of new asset registry.
event SetAssetRegistry(address assetRegistry);
/// @notice Emitted when hooks is set.
/// @param hooks Address of new hooks.
event SetHooks(address hooks);
/// @notice Emitted when execute is called.
/// @param owner Owner address.
/// @param operation Struct details for target and calldata.
event Executed(address indexed owner, Operation operation);
/// @notice Emitted when vault is finalized.
/// @param owner Owner address.
/// @param withdrawnAmounts Struct details for withdrawn assets and amounts (sent to owner).
event Finalized(address indexed owner, AssetValue[] withdrawnAmounts);
/// @notice Emitted when submit is called.
/// @param guardian Guardian address.
/// @param operations Array of struct details for targets and calldatas.
event Submitted(address indexed guardian, Operation[] operations);
/// @notice Emitted when guardian fees are claimed.
/// @param feeRecipient Fee recipient address.
/// @param claimedFee Claimed amount of fee token.
/// @param unclaimedFee Unclaimed amount of fee token (unclaimed because Vault does not have enough balance of feeToken).
/// @param feeTotal New total reserved fee value.
event Claimed(
address indexed feeRecipient,
uint256 claimedFee,
uint256 unclaimedFee,
uint256 feeTotal
);
/// @notice Emitted when new fees are reserved for recipient.
/// @param feeRecipient Fee recipient address.
/// @param newFee Fee amount reserved.
/// @param lastFeeCheckpoint Updated fee checkpoint.
/// @param lastValue Last registered vault value.
/// @param lastFeeTokenPrice Last registered fee token price.
/// @param feeTotal New total reserved fee value.
event FeesReserved(
address indexed feeRecipient,
uint256 newFee,
uint256 lastFeeCheckpoint,
uint256 lastValue,
uint256 lastFeeTokenPrice,
uint256 feeTotal
);
/// @notice Emitted when no fees are reserved.
/// @param lastFeeCheckpoint Updated fee checkpoint.
/// @param lastValue Last registered vault value.
/// @param feeTotal New total reserved fee value.
event NoFeesReserved(
uint256 lastFeeCheckpoint,
uint256 lastValue,
uint256 feeTotal
);
/// @notice Emitted when the call to get spot prices from the asset registry reverts.
/// @param reason Revert reason.
event SpotPricesReverted(bytes reason);
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "./AggregatorInterface.sol";
import "./AggregatorV3Interface.sol";
interface AggregatorV2V3Interface is AggregatorInterface, AggregatorV3Interface {}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
interface AggregatorInterface {
function latestAnswer() external view returns (int256);
function latestTimestamp() external view returns (uint256);
function latestRound() external view returns (uint256);
function getAnswer(uint256 roundId) external view returns (int256);
function getTimestamp(uint256 roundId) external view returns (uint256);
event AnswerUpdated(int256 indexed current, uint256 indexed roundId, uint256 updatedAt);
event NewRound(uint256 indexed roundId, address indexed startedBy, uint256 startedAt);
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
interface AggregatorV3Interface {
function decimals() external view returns (uint8);
function description() external view returns (string memory);
function version() external view returns (uint256);
// getRoundData and latestRoundData should both raise "No data present"
// if they do not have data to report, instead of returning unset values
// which could be misinterpreted as actual reported values.
function getRoundData(uint80 _roundId)
external
view
returns (
uint80 roundId,
int256 answer,
uint256 startedAt,
uint256 updatedAt,
uint80 answeredInRound
);
function latestRoundData()
external
view
returns (
uint80 roundId,
int256 answer,
uint256 startedAt,
uint256 updatedAt,
uint80 answeredInRound
);
}{
"remappings": [
"src/=src/",
"test/=test/",
"@chainlink/=src/v2/dependencies/chainlink/",
"@openzeppelin/=src/v2/dependencies/openzeppelin/",
"@uniswap/v3-periphery/=lib/v3-periphery/",
"@uniswap/v3-core/=lib/v3-core/",
"@openzeppelintest/=test/v2/dependencies/openzeppelin/",
"@aave-v3-core/=lib/aave-vault/lib/aave-v3-core/contracts/",
"@aave-v3-periphery/=lib/aave-vault/lib/aave-v3-periphery/contracts/",
"@openzeppelin-upgradeable/=lib/aave-vault/lib/openzeppelin-contracts-upgradeable/contracts/",
"aave-v3-core/=lib/aave-vault/lib/aave-v3-core/",
"aave-v3-periphery/=lib/aave-vault/lib/aave-v3-periphery/contracts/",
"aave-vault/=lib/aave-vault/",
"ds-test/=lib/forge-std/lib/ds-test/src/",
"erc4626-tests/=lib/aave-vault/lib/erc4626-tests/",
"forge-std/=lib/forge-std/src/",
"openzeppelin-contracts-upgradeable/=lib/aave-vault/lib/openzeppelin-contracts-upgradeable/",
"openzeppelin-contracts/=lib/aave-vault/lib/openzeppelin-contracts/",
"solmate/=lib/solmate/src/",
"uniswap/=lib/uniswap/",
"v3-core/=lib/v3-core/",
"v3-periphery/=lib/v3-periphery/contracts/"
],
"optimizer": {
"enabled": true,
"runs": 200
},
"metadata": {
"useLiteralContent": false,
"bytecodeHash": "ipfs",
"appendCBOR": true
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"evmVersion": "paris",
"libraries": {}
}Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"contract IERC20","name":"asset","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"available","type":"uint256"}],"name":"Aera__AmountExceedsAvailable","type":"error"},{"inputs":[{"internalType":"uint256","name":"index","type":"uint256"}],"name":"Aera__AmountsOrderIsIncorrect","type":"error"},{"inputs":[{"internalType":"contract IERC20","name":"asset","type":"address"}],"name":"Aera__AssetIsNotRegistered","type":"error"},{"inputs":[],"name":"Aera__AssetRegistryHasInvalidVault","type":"error"},{"inputs":[{"internalType":"address","name":"assetRegistry","type":"address"}],"name":"Aera__AssetRegistryIsNotValid","type":"error"},{"inputs":[],"name":"Aera__AssetRegistryIsZeroAddress","type":"error"},{"inputs":[],"name":"Aera__CallerIsNotGuardian","type":"error"},{"inputs":[],"name":"Aera__CallerIsNotOwnerAndGuardian","type":"error"},{"inputs":[],"name":"Aera__CannotRenounceOwnership","type":"error"},{"inputs":[],"name":"Aera__CannotUseReservedFees","type":"error"},{"inputs":[],"name":"Aera__ExecuteTargetIsHooksAddress","type":"error"},{"inputs":[],"name":"Aera__ExecuteTargetIsVaultAddress","type":"error"},{"inputs":[{"internalType":"bytes","name":"result","type":"bytes"}],"name":"Aera__ExecutionFailed","type":"error"},{"inputs":[{"internalType":"uint256","name":"actual","type":"uint256"},{"internalType":"uint256","name":"max","type":"uint256"}],"name":"Aera__FeeIsAboveMax","type":"error"},{"inputs":[],"name":"Aera__FeeRecipientIsOwner","type":"error"},{"inputs":[],"name":"Aera__FeeRecipientIsZeroAddress","type":"error"},{"inputs":[],"name":"Aera__GuardianIsOwner","type":"error"},{"inputs":[],"name":"Aera__GuardianIsZeroAddress","type":"error"},{"inputs":[],"name":"Aera__HooksHasInvalidVault","type":"error"},{"inputs":[{"internalType":"address","name":"hooks","type":"address"}],"name":"Aera__HooksIsNotValid","type":"error"},{"inputs":[],"name":"Aera__HooksIsZeroAddress","type":"error"},{"inputs":[],"name":"Aera__InitialOwnerIsZeroAddress","type":"error"},{"inputs":[{"internalType":"address","name":"caller","type":"address"}],"name":"Aera__NoAvailableFeesForCaller","type":"error"},{"inputs":[{"internalType":"address","name":"caller","type":"address"}],"name":"Aera__NoClaimableFeesForCaller","type":"error"},{"inputs":[],"name":"Aera__NotWrappedNativeTokenContract","type":"error"},{"inputs":[],"name":"Aera__SpotPricesReverted","type":"error"},{"inputs":[{"internalType":"uint256","name":"index","type":"uint256"},{"internalType":"bytes","name":"result","type":"bytes"}],"name":"Aera__SubmissionFailed","type":"error"},{"inputs":[],"name":"Aera__SubmitRedeemERC4626AssetFromOwner","type":"error"},{"inputs":[{"internalType":"uint256","name":"index","type":"uint256"}],"name":"Aera__SubmitTargetIsHooksAddress","type":"error"},{"inputs":[],"name":"Aera__SubmitTargetIsVaultAddress","type":"error"},{"inputs":[],"name":"Aera__SubmitTransfersAssetFromOwner","type":"error"},{"inputs":[],"name":"Aera__VaultIsFinalized","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"feeRecipient","type":"address"},{"indexed":false,"internalType":"uint256","name":"claimedFee","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"unclaimedFee","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"feeTotal","type":"uint256"}],"name":"Claimed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"contract IERC20","name":"asset","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Deposit","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"components":[{"internalType":"address","name":"target","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"indexed":false,"internalType":"struct Operation","name":"operation","type":"tuple"}],"name":"Executed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"feeRecipient","type":"address"},{"indexed":false,"internalType":"uint256","name":"newFee","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"lastFeeCheckpoint","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"lastValue","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"lastFeeTokenPrice","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"feeTotal","type":"uint256"}],"name":"FeesReserved","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"components":[{"internalType":"contract IERC20","name":"asset","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"}],"indexed":false,"internalType":"struct AssetValue[]","name":"withdrawnAmounts","type":"tuple[]"}],"name":"Finalized","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"lastFeeCheckpoint","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"lastValue","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"feeTotal","type":"uint256"}],"name":"NoFeesReserved","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferStarted","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":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"assetRegistry","type":"address"}],"name":"SetAssetRegistry","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"guardian","type":"address"},{"indexed":true,"internalType":"address","name":"feeRecipient","type":"address"}],"name":"SetGuardianAndFeeRecipient","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"hooks","type":"address"}],"name":"SetHooks","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes","name":"reason","type":"bytes"}],"name":"SpotPricesReverted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"guardian","type":"address"},{"components":[{"internalType":"address","name":"target","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"indexed":false,"internalType":"struct Operation[]","name":"operations","type":"tuple[]"}],"name":"Submitted","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"contract IERC20","name":"asset","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Withdraw","type":"event"},{"inputs":[],"name":"acceptOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"assetRegistry","outputs":[{"internalType":"contract IAssetRegistry","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"claim","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"contract IERC20","name":"asset","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"}],"internalType":"struct AssetValue[]","name":"amounts","type":"tuple[]"}],"name":"deposit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"target","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"internalType":"struct Operation","name":"operation","type":"tuple"}],"name":"execute","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"fee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"feeRecipient","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"feeTotal","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"fees","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"finalize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"finalized","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"guardian","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"holdings","outputs":[{"components":[{"internalType":"contract IERC20","name":"asset","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"}],"internalType":"struct AssetValue[]","name":"","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"hooks","outputs":[{"internalType":"contract IHooks","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lastFeeCheckpoint","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lastFeeTokenPrice","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lastValue","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pendingOwner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[],"name":"resume","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newGuardian","type":"address"},{"internalType":"address","name":"newFeeRecipient","type":"address"}],"name":"setGuardianAndFeeRecipient","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newHooks","type":"address"}],"name":"setHooks","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"target","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"internalType":"struct Operation[]","name":"operations","type":"tuple[]"}],"name":"submit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"value","outputs":[{"internalType":"uint256","name":"vaultValue","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"contract IERC20","name":"asset","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"}],"internalType":"struct AssetValue[]","name":"amounts","type":"tuple[]"}],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"wrappedNativeToken","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"stateMutability":"payable","type":"receive"}]Contract Creation Code
6101406040523480156200001257600080fd5b506200001e336200047c565b6001805460ff60a01b1916815560025560408051630890357360e41b8152905160009182918291829182918291339163890357309160048083019260c09291908290030181865afa15801562000078573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200009e919062000959565b955095509550955095509550620000bb856200049a60201b60201c565b620000c68462000596565b620000d2838762000692565b620000de8287620006f1565b6001600160a01b038616620001065760405163d2ee83c360e01b815260040160405180910390fd5b633b9aca008111156200013e57604051631456a87760e21b815260048101829052633b9aca0060248201526044015b60405180910390fd5b336001600160a01b03166317fcb39b6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156200017d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620001a39190620009e1565b6001600160a01b0390811661012052858116610100819052600380546001600160a01b0319908116888516179091556004805482168785161781556005805490921693861693909317905560e083905242600a556040805163647846a560e01b81529051919263647846a59282820192602092908290030181865afa15801562000231573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620002579190620009e1565b6001600160a01b031660c08190526040805163313ce56760e01b8152905163313ce567916004808201926020929091908290030181865afa158015620002a1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620002c7919062000a01565b60ff1660808181525050610100516001600160a01b0316631fb6c52d6040518163ffffffff1660e01b8152600401602060405180830381865afa15801562000313573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620003399190620009e1565b6001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa15801562000377573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200039d919062000a01565b60ff1660a052620003ae866200047c565b620003b86200074c565b6040516001600160a01b03861681527f2b417d4c687f11e50e49a2de8cea18b32ac1c28f0d98430e342383d88e8b2dbc9060200160405180910390a16040516001600160a01b03851681527fdb0670e174c4203280e70166db52920a0ddc53923128a7e0e964c5350de54f1f9060200160405180910390a1816001600160a01b0316836001600160a01b03167fef48f1577712f3f29564778f489f620f33b22e71b98872465e95c0794b76952f60405160405180910390a350505050505062000a26565b600180546001600160a01b03191690556200049781620007af565b50565b6001600160a01b038116620004c257604051630362550b60e41b815260040160405180910390fd5b620004d581631c64cd8f60e01b620007ff565b620004ff57604051632e5904f560e21b81526001600160a01b038216600482015260240162000135565b306001600160a01b0316816001600160a01b031663fbfa77cf6040518163ffffffff1660e01b8152600401602060405180830381865afa15801562000548573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200056e9190620009e1565b6001600160a01b0316146200049757604051636fbc13d760e01b815260040160405180910390fd5b6001600160a01b038116620005be5760405163097e401760e11b815260040160405180910390fd5b620005d18163755e756360e01b620007ff565b620005fb57604051638537fbfb60e01b81526001600160a01b038216600482015260240162000135565b306001600160a01b0316816001600160a01b031663fbfa77cf6040518163ffffffff1660e01b8152600401602060405180830381865afa15801562000644573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200066a9190620009e1565b6001600160a01b031614620004975760405163af82684960e01b815260040160405180910390fd5b6001600160a01b038216620006ba5760405163c93c257960e01b815260040160405180910390fd5b806001600160a01b0316826001600160a01b031603620006ed57604051631eeea85b60e21b815260040160405180910390fd5b5050565b6001600160a01b038216620007195760405163048dc2c760e21b815260040160405180910390fd5b806001600160a01b0316826001600160a01b031603620006ed57604051635515a0d760e11b815260040160405180910390fd5b6200075662000827565b6001805460ff60a01b1916600160a01b1790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258620007923390565b6040516001600160a01b03909116815260200160405180910390a1565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b60006200080c836200087f565b8015620008205750620008208383620008b8565b9392505050565b6200083b600154600160a01b900460ff1690565b156200087d5760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b604482015260640162000135565b565b600062000894826301ffc9a760e01b620008b8565b8015620008b25750620008b0826001600160e01b0319620008b8565b155b92915050565b604080516001600160e01b03198316602480830191909152825180830390910181526044909101909152602080820180516001600160e01b03166301ffc9a760e01b178152825160009392849283928392918391908a617530fa92503d915060005190508280156200092b575060208210155b8015620009385750600081115b979650505050505050565b6001600160a01b03811681146200049757600080fd5b60008060008060008060c087890312156200097357600080fd5b8651620009808162000943565b6020880151909650620009938162000943565b6040880151909550620009a68162000943565b6060880151909450620009b98162000943565b6080880151909350620009cc8162000943565b8092505060a087015190509295509295509295565b600060208284031215620009f457600080fd5b8151620008208162000943565b60006020828403121562000a1457600080fd5b815160ff811681146200082057600080fd5b60805160a05160c05160e0516101005161012051613e6462000b17600039600081816101ec0152818161028d01526110330152600081816104ba015281816106c40152818161085e01528181611292015281816117e3015281816118e801528181611e0701526121aa01526000818161052f015281816121420152612322015260008181610a9701528181610b6a01528181610c9b01528181611fb0015281816126e001526128670152600081816120860152818161237e015281816123a80152818161242c015261247701526000818161235d015281816123c90152818161240b01526124560152613e646000f3fe6080604052600436106101dc5760003560e01c806369eb50ef11610102578063cd7033c411610095578063ecdbb2b311610064578063ecdbb2b314610591578063f2fde38b146105b1578063faaebd21146105d1578063fb63daa1146105fe57600080fd5b8063cd7033c4146104fd578063ddca3f431461051d578063e30c397814610551578063e79bf13b1461056f57600080fd5b80638456cb59116100d15780638456cb59146104755780638da5cb5b1461048a578063979d7e86146104a8578063b3f05b97146104dc57600080fd5b806369eb50ef14610415578063715018a614610435578063779b3c001461044a57806379ba50971461046057600080fd5b8063452a93201161017a5780634e8bc852116101495780634e8bc8521461039657806359e97475146103b65780635c1c6dcd146103d65780635c975abb146103f657600080fd5b8063452a93201461032c578063469048401461034c5780634bb278f31461036c5780634e71d92d1461038157600080fd5b80632575e80b116101b65780632575e80b146102c757806337bfc1ef146102eb5780633fa4f24514610301578063431838341461031657600080fd5b806301ffc9a714610231578063046f7da21461026657806317fcb39b1461027b57600080fd5b3661022c57336001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000161461022a57604051632b41e87560e11b815260040160405180910390fd5b005b600080fd5b34801561023d57600080fd5b5061025161024c36600461348a565b61061e565b60405190151581526020015b60405180910390f35b34801561027257600080fd5b5061022a610655565b34801561028757600080fd5b506102af7f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b03909116815260200161025d565b3480156102d357600080fd5b506102dd60075481565b60405190815260200161025d565b3480156102f757600080fd5b506102dd60095481565b34801561030d57600080fd5b506102dd6106bf565b34801561032257600080fd5b506102dd60065481565b34801561033857600080fd5b506004546102af906001600160a01b031681565b34801561035857600080fd5b506005546102af906001600160a01b031681565b34801561037857600080fd5b5061022a61075a565b34801561038d57600080fd5b5061022a610a2b565b3480156103a257600080fd5b5061022a6103b13660046134b4565b610bec565b3480156103c257600080fd5b5061022a6103d1366004613528565b611163565b3480156103e257600080fd5b5061022a6103f136600461358a565b611492565b34801561040257600080fd5b50600154600160a01b900460ff16610251565b34801561042157600080fd5b5061022a6104303660046135d9565b611607565b34801561044157600080fd5b5061022a6116b4565b34801561045657600080fd5b506102dd600a5481565b34801561046c57600080fd5b5061022a6116d5565b34801561048157600080fd5b5061022a61174c565b34801561049657600080fd5b506000546001600160a01b03166102af565b3480156104b457600080fd5b506102af7f000000000000000000000000000000000000000000000000000000000000000081565b3480156104e857600080fd5b5060055461025190600160a01b900460ff1681565b34801561050957600080fd5b506003546102af906001600160a01b031681565b34801561052957600080fd5b506102dd7f000000000000000000000000000000000000000000000000000000000000000081565b34801561055d57600080fd5b506001546001600160a01b03166102af565b34801561057b57600080fd5b506105846117dd565b60405161025d9190613612565b34801561059d57600080fd5b5061022a6105ac366004613528565b611878565b3480156105bd57600080fd5b5061022a6105cc36600461366a565b611bc1565b3480156105dd57600080fd5b506102dd6105ec36600461366a565b60086020526000908152604090205481565b34801561060a57600080fd5b5061022a61061936600461366a565b611c30565b60006001600160e01b0319821663ec75542d60e01b148061064f57506301ffc9a760e01b6001600160e01b03198316145b92915050565b61065d611d51565b6003546001600160a01b03166106865760405163097e401760e11b815260040160405180910390fd5b600554600160a01b900460ff16156106b15760405163b3a5458960e01b815260040160405180910390fd5b42600a556106bd611dab565b565b6000807f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663edf94acd6040518163ffffffff1660e01b8152600401600060405180830381865afa158015610720573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610748919081019061373a565b905061075381611e00565b5092915050565b6107626120e9565b61076a611d51565b6003546001600160a01b03166107935760405163097e401760e11b815260040160405180910390fd5b600554600160a01b900460ff16156107be5760405163b3a5458960e01b815260040160405180910390fd5b6107c6612140565b600360009054906101000a90046001600160a01b03166001600160a01b031663bfd31dc46040518163ffffffff1660e01b8152600401600060405180830381600087803b15801561081657600080fd5b505af115801561082a573d6000803e3d6000fd5b50506005805460ff60a01b1916600160a01b1790555050604080516371a9730560e01b815290516000916001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016916371a973059160048082019286929091908290030181865afa1580156108a9573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526108d19190810190613807565b905060006108de82612585565b805190915060005b81811015610974576000838281518110610902576109026138df565b602002602001015160200151111561096c5761096c3384838151811061092a5761092a6138df565b602002602001015160200151858481518110610948576109486138df565b6020026020010151600001516001600160a01b03166127829092919063ffffffff16565b6001016108e6565b50600360009054906101000a90046001600160a01b03166001600160a01b031663683acef06040518163ffffffff1660e01b8152600401600060405180830381600087803b1580156109c557600080fd5b505af11580156109d9573d6000803e3d6000fd5b50505050336001600160a01b03167f11ca3c8bf5b555e9fe7f80a815f6c9a090ccc14a0d37f7016e89b8e4e4b8fd9683604051610a169190613612565b60405180910390a25050506106bd6001600255565b610a336120e9565b610a3b612140565b3360009081526008602052604081205490819003610a7357604051631094e2c960e11b81523360048201526024015b60405180910390fd5b6040516370a0823160e01b8152306004820152600090610b08906001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016906370a0823190602401602060405180830381865afa158015610ade573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b0291906138f5565b836127ea565b905080600003610b2d57604051631afe748d60e31b8152336004820152602401610a6a565b8060096000828254610b3f9190613924565b90915550610b4f90508183613924565b336000818152600860205260409020829055909250610b99907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169083612782565b60095460408051838152602081018590529081019190915233907f9cdcf2f7714cca3508c7f0110b04a90a80a3a8dd0e35de99689db74d28c5383e9060600160405180910390a250506106bd6001600255565b610bf46120e9565b6004546001600160a01b03163314610c1f5760405163f5185ed160e01b815260040160405180910390fd5b6003546001600160a01b0316610c485760405163097e401760e11b815260040160405180910390fd5b600554600160a01b900460ff1615610c735760405163b3a5458960e01b815260040160405180910390fd5b610c7b612802565b610c83612140565b6040516370a0823160e01b81523060048201526000907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906370a0823190602401602060405180830381865afa158015610cea573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d0e91906138f5565b600354604051631940324760e11b81529192506001600160a01b031690633280648e90610d4190869086906004016139d0565b600060405180830381600087803b158015610d5b57600080fd5b505af1158015610d6f573d6000803e3d6000fd5b505060035484925036915060009081906060906001600160a01b0316825b8681101561101f57898982818110610da757610da76138df565b9050602002810190610db99190613a42565b9550610dc86040870187613a62565b610dd791600491600091613aa8565b610de091613ad2565b94506001600160e01b031985166323b872dd60e01b148015610e3c57506000546001600160a01b0316610e166040880188613a62565b610e24916004908290613aa8565b810190610e31919061366a565b6001600160a01b0316145b15610e5a57604051633793335760e01b815260040160405180910390fd5b6001600160e01b03198516632d182be560e21b1480610e8957506001600160e01b03198516635d043b2960e11b145b15610f01576000610e9d6040880188613a62565b610eab916004908290613aa8565b810190610eb89190613b02565b92505050610ece6000546001600160a01b031690565b6001600160a01b0316816001600160a01b031603610eff5760405163110cf89f60e11b815260040160405180910390fd5b505b6001600160a01b038216610f18602088018861366a565b6001600160a01b031603610f4257604051630dd70d7b60e31b815260048101829052602401610a6a565b30610f50602088018861366a565b6001600160a01b031603610f7757604051636829be6f60e01b815260040160405180910390fd5b610f84602087018761366a565b6001600160a01b03166020870135610f9f6040890189613a62565b604051610fad929190613b44565b60006040518083038185875af1925050503d8060008114610fea576040519150601f19603f3d011682016040523d82523d6000602084013e610fef565b606091505b50909450925083611017578083604051630923be2760e21b8152600401610a6a929190613ba4565b600101610d8d565b504715611098576040516001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016904790600081818185875af1925050503d806000811461108f576040519150601f19603f3d011682016040523d82523d6000602084013e611094565b606091505b5050505b60035460405163a0e38c8160e01b81526001600160a01b039091169063a0e38c81906110ca908c908c906004016139d0565b600060405180830381600087803b1580156110e457600080fd5b505af11580156110f8573d6000803e3d6000fd5b50506004546040516001600160a01b0390911692507f83175f8c84aa4e36267d4380f6880279b38aab5493b1c7a5db6bf5ffc3d27245915061113d908c908c906139d0565b60405180910390a25050505050506111548161284f565b5061115f6001600255565b5050565b61116b6120e9565b611173611d51565b6003546001600160a01b031661119c5760405163097e401760e11b815260040160405180910390fd5b600554600160a01b900460ff16156111c75760405163b3a5458960e01b815260040160405180910390fd5b6111cf612140565b60035460405163162146fb60e01b81526001600160a01b039091169063162146fb906112019085908590600401613bbd565b600060405180830381600087803b15801561121b57600080fd5b505af115801561122f573d6000803e3d6000fd5b5050505061128e8282808060200260200160405190810160405280939291908181526020016000905b828210156112845761127560408302860136819003810190613c16565b81526020019060010190611258565b505050505061290a565b60007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166371a973056040518163ffffffff1660e01b8152600401600060405180830381865afa1580156112ee573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526113169190810190613807565b905081611333604080518082019091526000808252602082015290565b6000805b8381101561141f57868682818110611351576113516138df565b9050604002018036038101906113679190613c16565b9250611377836000015186612999565b509150816113a65782516040516362d0df2960e11b81526001600160a01b039091166004820152602401610a6a565b602083015183516113c6916001600160a01b039091169033903090612a36565b825160208401516040516001909301926001600160a01b039092169133917f5548c837ab068cf56a2c2479df0882a4922fd203edb7517321831d95078c5f629161141291815260200190565b60405180910390a3611337565b506003546040516305e81cb760e31b81526001600160a01b0390911690632f40e5b8906114529089908990600401613bbd565b600060405180830381600087803b15801561146c57600080fd5b505af1158015611480573d6000803e3d6000fd5b505050505050505061115f6001600255565b61149a6120e9565b6114a2611d51565b6003546001600160a01b03166114bb602083018361366a565b6001600160a01b0316036114e25760405163b06c99f160e01b815260040160405180910390fd5b306114f0602083018361366a565b6001600160a01b03160361151757604051631ed6262760e11b815260040160405180910390fd5b600080611527602084018461366a565b6001600160a01b031660208401356115426040860186613a62565b604051611550929190613b44565b60006040518083038185875af1925050503d806000811461158d576040519150601f19603f3d011682016040523d82523d6000602084013e611592565b606091505b5091509150816115b75780604051630393e72d60e21b8152600401610a6a9190613c50565b336001600160a01b03167f581f7fcb4603641e147a9f037fab064116f10ab9f195b7de511aac72fb3a4532846040516115f09190613c63565b60405180910390a250506116046001600255565b50565b61160f611d51565b600554600160a01b900460ff161561163a5760405163b3a5458960e01b815260040160405180910390fd5b611642612140565b61164c8233612a74565b6116568133612acd565b600480546001600160a01b03199081166001600160a01b03858116918217909355600580549092169284169283179091556040517fef48f1577712f3f29564778f489f620f33b22e71b98872465e95c0794b76952f90600090a35050565b6116bc611d51565b60405163e55b23a560e01b815260040160405180910390fd5b60015433906001600160a01b031681146117435760405162461bcd60e51b815260206004820152602960248201527f4f776e61626c6532537465703a2063616c6c6572206973206e6f7420746865206044820152683732bb9037bbb732b960b91b6064820152608401610a6a565b61160481612b26565b6117546120e9565b6000546001600160a01b0316331480159061177a57506004546001600160a01b03163314155b1561179857604051630831dddf60e41b815260040160405180910390fd5b600554600160a01b900460ff16156117c35760405163b3a5458960e01b815260040160405180910390fd5b6117cb612140565b6117d3612b3f565b6106bd6001600255565b606060007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166371a973056040518163ffffffff1660e01b8152600401600060405180830381865afa15801561183f573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526118679190810190613807565b905061187281612585565b91505090565b6118806120e9565b611888611d51565b6003546001600160a01b03166118b15760405163097e401760e11b815260040160405180910390fd5b600554600160a01b900460ff16156118dc5760405163b3a5458960e01b815260040160405180910390fd5b6118e4612140565b60007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166371a973056040518163ffffffff1660e01b8152600401600060405180830381865afa158015611944573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261196c9190810190613807565b90506119ca818484808060200260200160405190810160405280939291908181526020016000905b828210156119c0576119b160408302860136819003810190613c16565b81526020019060010190611994565b5050505050612b82565b611a1b8383808060200260200160405190810160405280939291908181526020016000905b8282101561128457611a0c60408302860136819003810190613c16565b815260200190600101906119ef565b60035460405163b998927560e01b81526001600160a01b039091169063b998927590611a4d9086908690600401613bbd565b600060405180830381600087803b158015611a6757600080fd5b505af1158015611a7b573d6000803e3d6000fd5b50849250611a8b91506134739050565b60005b82811015611b4f57858582818110611aa857611aa86138df565b905060400201803603810190611abe9190613c16565b91508160200151600003611ad457600101611a8e565b60208201518251611af2916001600160a01b03909116903390612782565b81600001516001600160a01b0316336001600160a01b03167f9b1bfa7fa9ee420a16e124f794c35ac9f90472acc99140eb2f6447c714cad8eb8460200151604051611b3f91815260200190565b60405180910390a3600101611a8e565b50600354604051631a68c25760e11b81526001600160a01b03909116906334d184ae90611b829088908890600401613bbd565b600060405180830381600087803b158015611b9c57600080fd5b505af1158015611bb0573d6000803e3d6000fd5b5050505050505061115f6001600255565b611bc9611d51565b6004546001600160a01b0390811690821603611bf857604051631eeea85b60e21b815260040160405180910390fd5b6005546001600160a01b0390811690821603611c2757604051635515a0d760e11b815260040160405180910390fd5b61160481612cab565b611c386120e9565b611c40611d51565b600554600160a01b900460ff1615611c6b5760405163b3a5458960e01b815260040160405180910390fd5b611c73612140565b611c7c81612d1c565b6003546001600160a01b031615611cf657600360009054906101000a90046001600160a01b03166001600160a01b0316637f068c0f6040518163ffffffff1660e01b8152600401600060405180830381600087803b158015611cdd57600080fd5b505af1158015611cf1573d6000803e3d6000fd5b505050505b600380546001600160a01b0319166001600160a01b0383169081179091556040519081527fdb0670e174c4203280e70166db52920a0ddc53923128a7e0e964c5350de54f1f9060200160405180910390a16116046001600255565b6000546001600160a01b031633146106bd5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610a6a565b611db3612e0f565b6001805460ff60a01b191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b60008060007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166371a973056040518163ffffffff1660e01b8152600401600060405180830381865afa158015611e63573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052611e8b9190810190613807565b90506000611e9882612585565b9050600080611ea78488612e5f565b855191935091506000805b8281101561207e57868181518110611ecc57611ecc6138df565b60200260200101516040015115611f8d57868181518110611eef57611eef6138df565b6020026020010151600001516001600160a01b03166307a2d13a878381518110611f1b57611f1b6138df565b6020026020010151602001516040518263ffffffff1660e01b8152600401611f4591815260200190565b602060405180830381865afa158015611f62573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f8691906138f5565b9150611fae565b858181518110611f9f57611f9f6138df565b60200260200101516020015191505b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316878281518110611fea57611fea6138df565b6020026020010151600001516001600160a01b03160361202157848181518110612016576120166138df565b602002602001015197505b838181518110612033576120336138df565b602002602001015185828151811061204d5761204d6138df565b6020026020010151836120609190613c76565b61206a9190613c8d565b612074908a613caf565b9850600101611eb2565b5060006120ac7f0000000000000000000000000000000000000000000000000000000000000000600a613da6565b9050670de0b6b3a764000081146120dd57670de0b6b3a76400006120d0828b613c76565b6120da9190613c8d565b98505b50505050505050915091565b600280540361213a5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610a6a565b60028055565b7f000000000000000000000000000000000000000000000000000000000000000015806121765750600154600160a01b900460ff165b8061218a5750600554600160a01b900460ff165b1561219157565b600061219b6130e0565b9050806000036121a85750565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663edf94acd6040518163ffffffff1660e01b8152600401600060405180830381865afa92505050801561222757506040513d6000823e601f3d908101601f19168201604052612224919081019061373a565b60015b6122b9573d808015612255576040519150601f19603f3d011682016040523d82523d6000602084013e61225a565b606091505b50805160000361227c57604051621ce69d60e51b815260040160405180910390fd5b7f5d801530a4e94131b234f165923bd70de2c3e71c9891f090501832eb5ddf3d7c816040516122ab9190613c50565b60405180910390a1506122ca565b6122c281611e00565b600755600655505b60075460000361231e57600a5460065460095460408051938452602084019290925282820152517fb3da20cbb4a87f41036953a90dfa636fa7b5ad4d642283f4d8cf45be61a79d889181900360600190a150565b60007f00000000000000000000000000000000000000000000000000000000000000008260065461234f9190613c76565b6123599190613c76565b90507f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000001015612409576123ed7f00000000000000000000000000000000000000000000000000000000000000007f0000000000000000000000000000000000000000000000000000000000000000613924565b6123f890600a613da6565b6124029082613c76565b90506124b3565b7f00000000000000000000000000000000000000000000000000000000000000007f000000000000000000000000000000000000000000000000000000000000000011156124b35761249b7f00000000000000000000000000000000000000000000000000000000000000007f0000000000000000000000000000000000000000000000000000000000000000613924565b6124a690600a613da6565b6124b09082613c8d565b90505b6007546124c09082613c8d565b9050806000036124ce575050565b42600a556005546001600160a01b0316600090815260086020526040812080548392906124fc908490613caf565b9250508190555080600960008282546125159190613caf565b9091555050600554600a54600654600754600954604080518781526020810195909552840192909252606083015260808201526001600160a01b03909116907fc80de135628ee55c4963b1bf37e23eb2d7325f1d92417e120e02bcea56b9bed99060a00160405180910390a25050565b8051606090806001600160401b038111156125a2576125a2613687565b6040519080825280602002602001820160405280156125e757816020015b60408051808201909152600080825260208201528152602001906001900390816125c05790505b50915061261460408051608081018252600080825260208201819052918101829052606081019190915290565b60005b8281101561277a57848181518110612631576126316138df565b60209081029190910181015160408051808201825282516001600160a01b039081168252835192516370a0823160e01b815230600482015293965090938401929116906370a0823190602401602060405180830381865afa15801561269a573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126be91906138f5565b8152508482815181106126d3576126d36138df565b60200260200101819052507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031682600001516001600160a01b03160361277257612744600954858381518110612733576127336138df565b6020026020010151602001516127ea565b848281518110612756576127566138df565b602002602001015160200181815161276e9190613924565b9052505b600101612617565b505050919050565b6040516001600160a01b0383166024820152604481018290526127e590849063a9059cbb60e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b0319909316929092179091526130f6565b505050565b60008183106127f957816127fb565b825b9392505050565b600154600160a01b900460ff16156106bd5760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b6044820152606401610a6a565b6040516370a0823160e01b81523060048201526000907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906370a0823190602401602060405180830381865afa1580156128b6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128da91906138f5565b9050600954811080156128ec57508181105b1561115f576040516358a6588560e01b815260040160405180910390fd5b805160015b818110156127e557828181518110612929576129296138df565b6020026020010151600001516001600160a01b03168360018361294c9190613924565b8151811061295c5761295c6138df565b6020026020010151600001516001600160a01b0316106129915760405162a0ef3760e11b815260048101829052602401610a6a565b60010161290f565b80516000908190815b81811015612a2c57856001600160a01b03168582815181106129c6576129c66138df565b6020026020010151600001516001600160a01b031610156129e9576001016129a2565b856001600160a01b0316858281518110612a0557612a056138df565b6020026020010151600001516001600160a01b031603612a2c57600193509150612a2f9050565b50505b9250929050565b6040516001600160a01b0380851660248301528316604482015260648101829052612a6e9085906323b872dd60e01b906084016127ae565b50505050565b6001600160a01b038216612a9b5760405163c93c257960e01b815260040160405180910390fd5b806001600160a01b0316826001600160a01b03160361115f57604051631eeea85b60e21b815260040160405180910390fd5b6001600160a01b038216612af45760405163048dc2c760e21b815260040160405180910390fd5b806001600160a01b0316826001600160a01b03160361115f57604051635515a0d760e11b815260040160405180910390fd5b600180546001600160a01b0319169055611604816131cb565b612b47612802565b6001805460ff60a01b1916600160a01b1790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258611de33390565b80516000612b8f84612585565b90506000612bad604080518082019091526000808252602082015290565b6000805b85811015612ca157868181518110612bcb57612bcb6138df565b60200260200101519250612be3836000015189612999565b909450915083612c145782516040516362d0df2960e11b81526001600160a01b039091166004820152602401610a6a565b8260200151858381518110612c2b57612c2b6138df565b6020026020010151602001511015612c995782600001518360200151868481518110612c5957612c596138df565b602090810291909101810151015160405163258269c360e21b81526001600160a01b03909316600484015260248301919091526044820152606401610a6a565b600101612bb1565b5050505050505050565b612cb3611d51565b600180546001600160a01b0383166001600160a01b03199091168117909155612ce46000546001600160a01b031690565b6001600160a01b03167f38d16b8cac22d99fc7c124b9cd0de2d3fa1faef420bfe791d8c362d765e2270060405160405180910390a350565b6001600160a01b038116612d435760405163097e401760e11b815260040160405180910390fd5b612d548163755e756360e01b61321b565b612d7c57604051638537fbfb60e01b81526001600160a01b0382166004820152602401610a6a565b306001600160a01b0316816001600160a01b031663fbfa77cf6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612dc4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612de89190613db2565b6001600160a01b0316146116045760405163af82684960e01b815260040160405180910390fd5b600154600160a01b900460ff166106bd5760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b6044820152606401610a6a565b815181516060918291816001600160401b03811115612e8057612e80613687565b604051908082528060200260200182016040528015612ea9578160200160208202803683370190505b509350816001600160401b03811115612ec457612ec4613687565b604051908082528060200260200182016040528015612eed578160200160208202803683370190505b509250612f1a60408051608081018252600080825260208201819052918101829052606081019190915290565b60005b838110156130d557878181518110612f3757612f376138df565b6020026020010151915060008260400151612f53578251612fb9565b82600001516001600160a01b03166338d52e0f6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612f95573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612fb99190613db2565b905060005b8481101561300557888181518110612fd857612fd86138df565b6020026020010151600001516001600160a01b0316826001600160a01b0316031561300557600101612fbe565b888181518110613017576130176138df565b602002602001015160200151888481518110613035576130356138df565b602002602001018181525050816001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa15801561307f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906130a39190613dcf565b6130ae90600a613df2565b8784815181106130c0576130c06138df565b60209081029190910101525050600101612f1d565b505050509250929050565b6000600a544211156130f35750600a5442035b90565b600061314b826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166132379092919063ffffffff16565b905080516000148061316c57508080602001905181019061316c9190613e01565b6127e55760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610a6a565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b60006132268361324e565b80156127fb57506127fb8383613281565b6060613246848460008561330a565b949350505050565b6000613261826301ffc9a760e01b613281565b801561064f575061327a826001600160e01b0319613281565b1592915050565b604080516001600160e01b03198316602480830191909152825180830390910181526044909101909152602080820180516001600160e01b03166301ffc9a760e01b178152825160009392849283928392918391908a617530fa92503d915060005190508280156132f3575060208210155b80156132ff5750600081115b979650505050505050565b60608247101561336b5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401610a6a565b600080866001600160a01b031685876040516133879190613e1c565b60006040518083038185875af1925050503d80600081146133c4576040519150601f19603f3d011682016040523d82523d6000602084013e6133c9565b606091505b50915091506132ff878383876060831561344457825160000361343d576001600160a01b0385163b61343d5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610a6a565b5081613246565b61324683838151156134595781518083602001fd5b8060405162461bcd60e51b8152600401610a6a9190613c50565b604080518082019091526000808252602082015290565b60006020828403121561349c57600080fd5b81356001600160e01b0319811681146127fb57600080fd5b600080602083850312156134c757600080fd5b82356001600160401b03808211156134de57600080fd5b818501915085601f8301126134f257600080fd5b81358181111561350157600080fd5b8660208260051b850101111561351657600080fd5b60209290920196919550909350505050565b6000806020838503121561353b57600080fd5b82356001600160401b038082111561355257600080fd5b818501915085601f83011261356657600080fd5b81358181111561357557600080fd5b8660208260061b850101111561351657600080fd5b60006020828403121561359c57600080fd5b81356001600160401b038111156135b257600080fd5b8201606081850312156127fb57600080fd5b6001600160a01b038116811461160457600080fd5b600080604083850312156135ec57600080fd5b82356135f7816135c4565b91506020830135613607816135c4565b809150509250929050565b602080825282518282018190526000919060409081850190868401855b8281101561365d57815180516001600160a01b0316855286015186850152928401929085019060010161362f565b5091979650505050505050565b60006020828403121561367c57600080fd5b81356127fb816135c4565b634e487b7160e01b600052604160045260246000fd5b604080519081016001600160401b03811182821017156136bf576136bf613687565b60405290565b604051608081016001600160401b03811182821017156136bf576136bf613687565b604051601f8201601f191681016001600160401b038111828210171561370f5761370f613687565b604052919050565b60006001600160401b0382111561373057613730613687565b5060051b60200190565b6000602080838503121561374d57600080fd5b82516001600160401b0381111561376357600080fd5b8301601f8101851361377457600080fd5b805161378761378282613717565b6136e7565b81815260069190911b820183019083810190878311156137a657600080fd5b928401925b828410156132ff57604084890312156137c45760008081fd5b6137cc61369d565b84516137d7816135c4565b815284860151868201528252604090930192908401906137ab565b8051801515811461380257600080fd5b919050565b6000602080838503121561381a57600080fd5b82516001600160401b0381111561383057600080fd5b8301601f8101851361384157600080fd5b805161384f61378282613717565b81815260079190911b8201830190838101908783111561386e57600080fd5b928401925b828410156132ff576080848903121561388c5760008081fd5b6138946136c5565b845161389f816135c4565b8152848601518682015260406138b68187016137f2565b908201526060858101516138c9816135c4565b9082015282526080939093019290840190613873565b634e487b7160e01b600052603260045260246000fd5b60006020828403121561390757600080fd5b5051919050565b634e487b7160e01b600052601160045260246000fd5b8181038181111561064f5761064f61390e565b60008135613944816135c4565b6001600160a01b0316835260208281013590840152604082013536839003601e1901811261397157600080fd5b82016020810190356001600160401b0381111561398d57600080fd5b80360382131561399c57600080fd5b60606040860152806060860152808260808701376000608082870101526080601f19601f8301168601019250505092915050565b60208082528181018390526000906040600585901b840181019084018684805b88811015613a3457878503603f190184528235368b9003605e19018112613a15578283fd5b613a21868c8301613937565b95505092850192918501916001016139f0565b509298975050505050505050565b60008235605e19833603018112613a5857600080fd5b9190910192915050565b6000808335601e19843603018112613a7957600080fd5b8301803591506001600160401b03821115613a9357600080fd5b602001915036819003821315612a2f57600080fd5b60008085851115613ab857600080fd5b83861115613ac557600080fd5b5050820193919092039150565b6001600160e01b03198135818116916004851015613afa5780818660040360031b1b83161692505b505092915050565b600080600060608486031215613b1757600080fd5b833592506020840135613b29816135c4565b91506040840135613b39816135c4565b809150509250925092565b8183823760009101908152919050565b60005b83811015613b6f578181015183820152602001613b57565b50506000910152565b60008151808452613b90816020860160208601613b54565b601f01601f19169290920160200192915050565b8281526040602082015260006132466040830184613b78565b6020808252818101839052600090604080840186845b87811015613c09578135613be6816135c4565b6001600160a01b0316835281850135858401529183019190830190600101613bd3565b5090979650505050505050565b600060408284031215613c2857600080fd5b613c3061369d565b8235613c3b816135c4565b81526020928301359281019290925250919050565b6020815260006127fb6020830184613b78565b6020815260006127fb6020830184613937565b808202811582820484141761064f5761064f61390e565b600082613caa57634e487b7160e01b600052601260045260246000fd5b500490565b8082018082111561064f5761064f61390e565b600181815b80851115613cfd578160001904821115613ce357613ce361390e565b80851615613cf057918102915b93841c9390800290613cc7565b509250929050565b600082613d145750600161064f565b81613d215750600061064f565b8160018114613d375760028114613d4157613d5d565b600191505061064f565b60ff841115613d5257613d5261390e565b50506001821b61064f565b5060208310610133831016604e8410600b8410161715613d80575081810a61064f565b613d8a8383613cc2565b8060001904821115613d9e57613d9e61390e565b029392505050565b60006127fb8383613d05565b600060208284031215613dc457600080fd5b81516127fb816135c4565b600060208284031215613de157600080fd5b815160ff811681146127fb57600080fd5b60006127fb60ff841683613d05565b600060208284031215613e1357600080fd5b6127fb826137f2565b60008251613a58818460208701613b5456fea26469706673582212202bae90f05dafd7dd747f40b271f25b0697316f60bce8b6dce464dbc01a42072264736f6c63430008150033
Deployed Bytecode
0x6080604052600436106101dc5760003560e01c806369eb50ef11610102578063cd7033c411610095578063ecdbb2b311610064578063ecdbb2b314610591578063f2fde38b146105b1578063faaebd21146105d1578063fb63daa1146105fe57600080fd5b8063cd7033c4146104fd578063ddca3f431461051d578063e30c397814610551578063e79bf13b1461056f57600080fd5b80638456cb59116100d15780638456cb59146104755780638da5cb5b1461048a578063979d7e86146104a8578063b3f05b97146104dc57600080fd5b806369eb50ef14610415578063715018a614610435578063779b3c001461044a57806379ba50971461046057600080fd5b8063452a93201161017a5780634e8bc852116101495780634e8bc8521461039657806359e97475146103b65780635c1c6dcd146103d65780635c975abb146103f657600080fd5b8063452a93201461032c578063469048401461034c5780634bb278f31461036c5780634e71d92d1461038157600080fd5b80632575e80b116101b65780632575e80b146102c757806337bfc1ef146102eb5780633fa4f24514610301578063431838341461031657600080fd5b806301ffc9a714610231578063046f7da21461026657806317fcb39b1461027b57600080fd5b3661022c57336001600160a01b037f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2161461022a57604051632b41e87560e11b815260040160405180910390fd5b005b600080fd5b34801561023d57600080fd5b5061025161024c36600461348a565b61061e565b60405190151581526020015b60405180910390f35b34801561027257600080fd5b5061022a610655565b34801561028757600080fd5b506102af7f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc281565b6040516001600160a01b03909116815260200161025d565b3480156102d357600080fd5b506102dd60075481565b60405190815260200161025d565b3480156102f757600080fd5b506102dd60095481565b34801561030d57600080fd5b506102dd6106bf565b34801561032257600080fd5b506102dd60065481565b34801561033857600080fd5b506004546102af906001600160a01b031681565b34801561035857600080fd5b506005546102af906001600160a01b031681565b34801561037857600080fd5b5061022a61075a565b34801561038d57600080fd5b5061022a610a2b565b3480156103a257600080fd5b5061022a6103b13660046134b4565b610bec565b3480156103c257600080fd5b5061022a6103d1366004613528565b611163565b3480156103e257600080fd5b5061022a6103f136600461358a565b611492565b34801561040257600080fd5b50600154600160a01b900460ff16610251565b34801561042157600080fd5b5061022a6104303660046135d9565b611607565b34801561044157600080fd5b5061022a6116b4565b34801561045657600080fd5b506102dd600a5481565b34801561046c57600080fd5b5061022a6116d5565b34801561048157600080fd5b5061022a61174c565b34801561049657600080fd5b506000546001600160a01b03166102af565b3480156104b457600080fd5b506102af7f000000000000000000000000148dfb85a90ff55ad3dfdaa345febf494a2e23d981565b3480156104e857600080fd5b5060055461025190600160a01b900460ff1681565b34801561050957600080fd5b506003546102af906001600160a01b031681565b34801561052957600080fd5b506102dd7f000000000000000000000000000000000000000000000000000000000000000081565b34801561055d57600080fd5b506001546001600160a01b03166102af565b34801561057b57600080fd5b506105846117dd565b60405161025d9190613612565b34801561059d57600080fd5b5061022a6105ac366004613528565b611878565b3480156105bd57600080fd5b5061022a6105cc36600461366a565b611bc1565b3480156105dd57600080fd5b506102dd6105ec36600461366a565b60086020526000908152604090205481565b34801561060a57600080fd5b5061022a61061936600461366a565b611c30565b60006001600160e01b0319821663ec75542d60e01b148061064f57506301ffc9a760e01b6001600160e01b03198316145b92915050565b61065d611d51565b6003546001600160a01b03166106865760405163097e401760e11b815260040160405180910390fd5b600554600160a01b900460ff16156106b15760405163b3a5458960e01b815260040160405180910390fd5b42600a556106bd611dab565b565b6000807f000000000000000000000000148dfb85a90ff55ad3dfdaa345febf494a2e23d96001600160a01b031663edf94acd6040518163ffffffff1660e01b8152600401600060405180830381865afa158015610720573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610748919081019061373a565b905061075381611e00565b5092915050565b6107626120e9565b61076a611d51565b6003546001600160a01b03166107935760405163097e401760e11b815260040160405180910390fd5b600554600160a01b900460ff16156107be5760405163b3a5458960e01b815260040160405180910390fd5b6107c6612140565b600360009054906101000a90046001600160a01b03166001600160a01b031663bfd31dc46040518163ffffffff1660e01b8152600401600060405180830381600087803b15801561081657600080fd5b505af115801561082a573d6000803e3d6000fd5b50506005805460ff60a01b1916600160a01b1790555050604080516371a9730560e01b815290516000916001600160a01b037f000000000000000000000000148dfb85a90ff55ad3dfdaa345febf494a2e23d916916371a973059160048082019286929091908290030181865afa1580156108a9573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526108d19190810190613807565b905060006108de82612585565b805190915060005b81811015610974576000838281518110610902576109026138df565b602002602001015160200151111561096c5761096c3384838151811061092a5761092a6138df565b602002602001015160200151858481518110610948576109486138df565b6020026020010151600001516001600160a01b03166127829092919063ffffffff16565b6001016108e6565b50600360009054906101000a90046001600160a01b03166001600160a01b031663683acef06040518163ffffffff1660e01b8152600401600060405180830381600087803b1580156109c557600080fd5b505af11580156109d9573d6000803e3d6000fd5b50505050336001600160a01b03167f11ca3c8bf5b555e9fe7f80a815f6c9a090ccc14a0d37f7016e89b8e4e4b8fd9683604051610a169190613612565b60405180910390a25050506106bd6001600255565b610a336120e9565b610a3b612140565b3360009081526008602052604081205490819003610a7357604051631094e2c960e11b81523360048201526024015b60405180910390fd5b6040516370a0823160e01b8152306004820152600090610b08906001600160a01b037f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc216906370a0823190602401602060405180830381865afa158015610ade573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b0291906138f5565b836127ea565b905080600003610b2d57604051631afe748d60e31b8152336004820152602401610a6a565b8060096000828254610b3f9190613924565b90915550610b4f90508183613924565b336000818152600860205260409020829055909250610b99907f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b03169083612782565b60095460408051838152602081018590529081019190915233907f9cdcf2f7714cca3508c7f0110b04a90a80a3a8dd0e35de99689db74d28c5383e9060600160405180910390a250506106bd6001600255565b610bf46120e9565b6004546001600160a01b03163314610c1f5760405163f5185ed160e01b815260040160405180910390fd5b6003546001600160a01b0316610c485760405163097e401760e11b815260040160405180910390fd5b600554600160a01b900460ff1615610c735760405163b3a5458960e01b815260040160405180910390fd5b610c7b612802565b610c83612140565b6040516370a0823160e01b81523060048201526000907f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b0316906370a0823190602401602060405180830381865afa158015610cea573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d0e91906138f5565b600354604051631940324760e11b81529192506001600160a01b031690633280648e90610d4190869086906004016139d0565b600060405180830381600087803b158015610d5b57600080fd5b505af1158015610d6f573d6000803e3d6000fd5b505060035484925036915060009081906060906001600160a01b0316825b8681101561101f57898982818110610da757610da76138df565b9050602002810190610db99190613a42565b9550610dc86040870187613a62565b610dd791600491600091613aa8565b610de091613ad2565b94506001600160e01b031985166323b872dd60e01b148015610e3c57506000546001600160a01b0316610e166040880188613a62565b610e24916004908290613aa8565b810190610e31919061366a565b6001600160a01b0316145b15610e5a57604051633793335760e01b815260040160405180910390fd5b6001600160e01b03198516632d182be560e21b1480610e8957506001600160e01b03198516635d043b2960e11b145b15610f01576000610e9d6040880188613a62565b610eab916004908290613aa8565b810190610eb89190613b02565b92505050610ece6000546001600160a01b031690565b6001600160a01b0316816001600160a01b031603610eff5760405163110cf89f60e11b815260040160405180910390fd5b505b6001600160a01b038216610f18602088018861366a565b6001600160a01b031603610f4257604051630dd70d7b60e31b815260048101829052602401610a6a565b30610f50602088018861366a565b6001600160a01b031603610f7757604051636829be6f60e01b815260040160405180910390fd5b610f84602087018761366a565b6001600160a01b03166020870135610f9f6040890189613a62565b604051610fad929190613b44565b60006040518083038185875af1925050503d8060008114610fea576040519150601f19603f3d011682016040523d82523d6000602084013e610fef565b606091505b50909450925083611017578083604051630923be2760e21b8152600401610a6a929190613ba4565b600101610d8d565b504715611098576040516001600160a01b037f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc216904790600081818185875af1925050503d806000811461108f576040519150601f19603f3d011682016040523d82523d6000602084013e611094565b606091505b5050505b60035460405163a0e38c8160e01b81526001600160a01b039091169063a0e38c81906110ca908c908c906004016139d0565b600060405180830381600087803b1580156110e457600080fd5b505af11580156110f8573d6000803e3d6000fd5b50506004546040516001600160a01b0390911692507f83175f8c84aa4e36267d4380f6880279b38aab5493b1c7a5db6bf5ffc3d27245915061113d908c908c906139d0565b60405180910390a25050505050506111548161284f565b5061115f6001600255565b5050565b61116b6120e9565b611173611d51565b6003546001600160a01b031661119c5760405163097e401760e11b815260040160405180910390fd5b600554600160a01b900460ff16156111c75760405163b3a5458960e01b815260040160405180910390fd5b6111cf612140565b60035460405163162146fb60e01b81526001600160a01b039091169063162146fb906112019085908590600401613bbd565b600060405180830381600087803b15801561121b57600080fd5b505af115801561122f573d6000803e3d6000fd5b5050505061128e8282808060200260200160405190810160405280939291908181526020016000905b828210156112845761127560408302860136819003810190613c16565b81526020019060010190611258565b505050505061290a565b60007f000000000000000000000000148dfb85a90ff55ad3dfdaa345febf494a2e23d96001600160a01b03166371a973056040518163ffffffff1660e01b8152600401600060405180830381865afa1580156112ee573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526113169190810190613807565b905081611333604080518082019091526000808252602082015290565b6000805b8381101561141f57868682818110611351576113516138df565b9050604002018036038101906113679190613c16565b9250611377836000015186612999565b509150816113a65782516040516362d0df2960e11b81526001600160a01b039091166004820152602401610a6a565b602083015183516113c6916001600160a01b039091169033903090612a36565b825160208401516040516001909301926001600160a01b039092169133917f5548c837ab068cf56a2c2479df0882a4922fd203edb7517321831d95078c5f629161141291815260200190565b60405180910390a3611337565b506003546040516305e81cb760e31b81526001600160a01b0390911690632f40e5b8906114529089908990600401613bbd565b600060405180830381600087803b15801561146c57600080fd5b505af1158015611480573d6000803e3d6000fd5b505050505050505061115f6001600255565b61149a6120e9565b6114a2611d51565b6003546001600160a01b03166114bb602083018361366a565b6001600160a01b0316036114e25760405163b06c99f160e01b815260040160405180910390fd5b306114f0602083018361366a565b6001600160a01b03160361151757604051631ed6262760e11b815260040160405180910390fd5b600080611527602084018461366a565b6001600160a01b031660208401356115426040860186613a62565b604051611550929190613b44565b60006040518083038185875af1925050503d806000811461158d576040519150601f19603f3d011682016040523d82523d6000602084013e611592565b606091505b5091509150816115b75780604051630393e72d60e21b8152600401610a6a9190613c50565b336001600160a01b03167f581f7fcb4603641e147a9f037fab064116f10ab9f195b7de511aac72fb3a4532846040516115f09190613c63565b60405180910390a250506116046001600255565b50565b61160f611d51565b600554600160a01b900460ff161561163a5760405163b3a5458960e01b815260040160405180910390fd5b611642612140565b61164c8233612a74565b6116568133612acd565b600480546001600160a01b03199081166001600160a01b03858116918217909355600580549092169284169283179091556040517fef48f1577712f3f29564778f489f620f33b22e71b98872465e95c0794b76952f90600090a35050565b6116bc611d51565b60405163e55b23a560e01b815260040160405180910390fd5b60015433906001600160a01b031681146117435760405162461bcd60e51b815260206004820152602960248201527f4f776e61626c6532537465703a2063616c6c6572206973206e6f7420746865206044820152683732bb9037bbb732b960b91b6064820152608401610a6a565b61160481612b26565b6117546120e9565b6000546001600160a01b0316331480159061177a57506004546001600160a01b03163314155b1561179857604051630831dddf60e41b815260040160405180910390fd5b600554600160a01b900460ff16156117c35760405163b3a5458960e01b815260040160405180910390fd5b6117cb612140565b6117d3612b3f565b6106bd6001600255565b606060007f000000000000000000000000148dfb85a90ff55ad3dfdaa345febf494a2e23d96001600160a01b03166371a973056040518163ffffffff1660e01b8152600401600060405180830381865afa15801561183f573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526118679190810190613807565b905061187281612585565b91505090565b6118806120e9565b611888611d51565b6003546001600160a01b03166118b15760405163097e401760e11b815260040160405180910390fd5b600554600160a01b900460ff16156118dc5760405163b3a5458960e01b815260040160405180910390fd5b6118e4612140565b60007f000000000000000000000000148dfb85a90ff55ad3dfdaa345febf494a2e23d96001600160a01b03166371a973056040518163ffffffff1660e01b8152600401600060405180830381865afa158015611944573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261196c9190810190613807565b90506119ca818484808060200260200160405190810160405280939291908181526020016000905b828210156119c0576119b160408302860136819003810190613c16565b81526020019060010190611994565b5050505050612b82565b611a1b8383808060200260200160405190810160405280939291908181526020016000905b8282101561128457611a0c60408302860136819003810190613c16565b815260200190600101906119ef565b60035460405163b998927560e01b81526001600160a01b039091169063b998927590611a4d9086908690600401613bbd565b600060405180830381600087803b158015611a6757600080fd5b505af1158015611a7b573d6000803e3d6000fd5b50849250611a8b91506134739050565b60005b82811015611b4f57858582818110611aa857611aa86138df565b905060400201803603810190611abe9190613c16565b91508160200151600003611ad457600101611a8e565b60208201518251611af2916001600160a01b03909116903390612782565b81600001516001600160a01b0316336001600160a01b03167f9b1bfa7fa9ee420a16e124f794c35ac9f90472acc99140eb2f6447c714cad8eb8460200151604051611b3f91815260200190565b60405180910390a3600101611a8e565b50600354604051631a68c25760e11b81526001600160a01b03909116906334d184ae90611b829088908890600401613bbd565b600060405180830381600087803b158015611b9c57600080fd5b505af1158015611bb0573d6000803e3d6000fd5b5050505050505061115f6001600255565b611bc9611d51565b6004546001600160a01b0390811690821603611bf857604051631eeea85b60e21b815260040160405180910390fd5b6005546001600160a01b0390811690821603611c2757604051635515a0d760e11b815260040160405180910390fd5b61160481612cab565b611c386120e9565b611c40611d51565b600554600160a01b900460ff1615611c6b5760405163b3a5458960e01b815260040160405180910390fd5b611c73612140565b611c7c81612d1c565b6003546001600160a01b031615611cf657600360009054906101000a90046001600160a01b03166001600160a01b0316637f068c0f6040518163ffffffff1660e01b8152600401600060405180830381600087803b158015611cdd57600080fd5b505af1158015611cf1573d6000803e3d6000fd5b505050505b600380546001600160a01b0319166001600160a01b0383169081179091556040519081527fdb0670e174c4203280e70166db52920a0ddc53923128a7e0e964c5350de54f1f9060200160405180910390a16116046001600255565b6000546001600160a01b031633146106bd5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610a6a565b611db3612e0f565b6001805460ff60a01b191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b60008060007f000000000000000000000000148dfb85a90ff55ad3dfdaa345febf494a2e23d96001600160a01b03166371a973056040518163ffffffff1660e01b8152600401600060405180830381865afa158015611e63573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052611e8b9190810190613807565b90506000611e9882612585565b9050600080611ea78488612e5f565b855191935091506000805b8281101561207e57868181518110611ecc57611ecc6138df565b60200260200101516040015115611f8d57868181518110611eef57611eef6138df565b6020026020010151600001516001600160a01b03166307a2d13a878381518110611f1b57611f1b6138df565b6020026020010151602001516040518263ffffffff1660e01b8152600401611f4591815260200190565b602060405180830381865afa158015611f62573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f8691906138f5565b9150611fae565b858181518110611f9f57611f9f6138df565b60200260200101516020015191505b7f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b0316878281518110611fea57611fea6138df565b6020026020010151600001516001600160a01b03160361202157848181518110612016576120166138df565b602002602001015197505b838181518110612033576120336138df565b602002602001015185828151811061204d5761204d6138df565b6020026020010151836120609190613c76565b61206a9190613c8d565b612074908a613caf565b9850600101611eb2565b5060006120ac7f0000000000000000000000000000000000000000000000000000000000000012600a613da6565b9050670de0b6b3a764000081146120dd57670de0b6b3a76400006120d0828b613c76565b6120da9190613c8d565b98505b50505050505050915091565b600280540361213a5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610a6a565b60028055565b7f000000000000000000000000000000000000000000000000000000000000000015806121765750600154600160a01b900460ff165b8061218a5750600554600160a01b900460ff165b1561219157565b600061219b6130e0565b9050806000036121a85750565b7f000000000000000000000000148dfb85a90ff55ad3dfdaa345febf494a2e23d96001600160a01b031663edf94acd6040518163ffffffff1660e01b8152600401600060405180830381865afa92505050801561222757506040513d6000823e601f3d908101601f19168201604052612224919081019061373a565b60015b6122b9573d808015612255576040519150601f19603f3d011682016040523d82523d6000602084013e61225a565b606091505b50805160000361227c57604051621ce69d60e51b815260040160405180910390fd5b7f5d801530a4e94131b234f165923bd70de2c3e71c9891f090501832eb5ddf3d7c816040516122ab9190613c50565b60405180910390a1506122ca565b6122c281611e00565b600755600655505b60075460000361231e57600a5460065460095460408051938452602084019290925282820152517fb3da20cbb4a87f41036953a90dfa636fa7b5ad4d642283f4d8cf45be61a79d889181900360600190a150565b60007f00000000000000000000000000000000000000000000000000000000000000008260065461234f9190613c76565b6123599190613c76565b90507f00000000000000000000000000000000000000000000000000000000000000127f00000000000000000000000000000000000000000000000000000000000000121015612409576123ed7f00000000000000000000000000000000000000000000000000000000000000127f0000000000000000000000000000000000000000000000000000000000000012613924565b6123f890600a613da6565b6124029082613c76565b90506124b3565b7f00000000000000000000000000000000000000000000000000000000000000127f000000000000000000000000000000000000000000000000000000000000001211156124b35761249b7f00000000000000000000000000000000000000000000000000000000000000127f0000000000000000000000000000000000000000000000000000000000000012613924565b6124a690600a613da6565b6124b09082613c8d565b90505b6007546124c09082613c8d565b9050806000036124ce575050565b42600a556005546001600160a01b0316600090815260086020526040812080548392906124fc908490613caf565b9250508190555080600960008282546125159190613caf565b9091555050600554600a54600654600754600954604080518781526020810195909552840192909252606083015260808201526001600160a01b03909116907fc80de135628ee55c4963b1bf37e23eb2d7325f1d92417e120e02bcea56b9bed99060a00160405180910390a25050565b8051606090806001600160401b038111156125a2576125a2613687565b6040519080825280602002602001820160405280156125e757816020015b60408051808201909152600080825260208201528152602001906001900390816125c05790505b50915061261460408051608081018252600080825260208201819052918101829052606081019190915290565b60005b8281101561277a57848181518110612631576126316138df565b60209081029190910181015160408051808201825282516001600160a01b039081168252835192516370a0823160e01b815230600482015293965090938401929116906370a0823190602401602060405180830381865afa15801561269a573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126be91906138f5565b8152508482815181106126d3576126d36138df565b60200260200101819052507f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b031682600001516001600160a01b03160361277257612744600954858381518110612733576127336138df565b6020026020010151602001516127ea565b848281518110612756576127566138df565b602002602001015160200181815161276e9190613924565b9052505b600101612617565b505050919050565b6040516001600160a01b0383166024820152604481018290526127e590849063a9059cbb60e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b0319909316929092179091526130f6565b505050565b60008183106127f957816127fb565b825b9392505050565b600154600160a01b900460ff16156106bd5760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b6044820152606401610a6a565b6040516370a0823160e01b81523060048201526000907f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b0316906370a0823190602401602060405180830381865afa1580156128b6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128da91906138f5565b9050600954811080156128ec57508181105b1561115f576040516358a6588560e01b815260040160405180910390fd5b805160015b818110156127e557828181518110612929576129296138df565b6020026020010151600001516001600160a01b03168360018361294c9190613924565b8151811061295c5761295c6138df565b6020026020010151600001516001600160a01b0316106129915760405162a0ef3760e11b815260048101829052602401610a6a565b60010161290f565b80516000908190815b81811015612a2c57856001600160a01b03168582815181106129c6576129c66138df565b6020026020010151600001516001600160a01b031610156129e9576001016129a2565b856001600160a01b0316858281518110612a0557612a056138df565b6020026020010151600001516001600160a01b031603612a2c57600193509150612a2f9050565b50505b9250929050565b6040516001600160a01b0380851660248301528316604482015260648101829052612a6e9085906323b872dd60e01b906084016127ae565b50505050565b6001600160a01b038216612a9b5760405163c93c257960e01b815260040160405180910390fd5b806001600160a01b0316826001600160a01b03160361115f57604051631eeea85b60e21b815260040160405180910390fd5b6001600160a01b038216612af45760405163048dc2c760e21b815260040160405180910390fd5b806001600160a01b0316826001600160a01b03160361115f57604051635515a0d760e11b815260040160405180910390fd5b600180546001600160a01b0319169055611604816131cb565b612b47612802565b6001805460ff60a01b1916600160a01b1790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258611de33390565b80516000612b8f84612585565b90506000612bad604080518082019091526000808252602082015290565b6000805b85811015612ca157868181518110612bcb57612bcb6138df565b60200260200101519250612be3836000015189612999565b909450915083612c145782516040516362d0df2960e11b81526001600160a01b039091166004820152602401610a6a565b8260200151858381518110612c2b57612c2b6138df565b6020026020010151602001511015612c995782600001518360200151868481518110612c5957612c596138df565b602090810291909101810151015160405163258269c360e21b81526001600160a01b03909316600484015260248301919091526044820152606401610a6a565b600101612bb1565b5050505050505050565b612cb3611d51565b600180546001600160a01b0383166001600160a01b03199091168117909155612ce46000546001600160a01b031690565b6001600160a01b03167f38d16b8cac22d99fc7c124b9cd0de2d3fa1faef420bfe791d8c362d765e2270060405160405180910390a350565b6001600160a01b038116612d435760405163097e401760e11b815260040160405180910390fd5b612d548163755e756360e01b61321b565b612d7c57604051638537fbfb60e01b81526001600160a01b0382166004820152602401610a6a565b306001600160a01b0316816001600160a01b031663fbfa77cf6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612dc4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612de89190613db2565b6001600160a01b0316146116045760405163af82684960e01b815260040160405180910390fd5b600154600160a01b900460ff166106bd5760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b6044820152606401610a6a565b815181516060918291816001600160401b03811115612e8057612e80613687565b604051908082528060200260200182016040528015612ea9578160200160208202803683370190505b509350816001600160401b03811115612ec457612ec4613687565b604051908082528060200260200182016040528015612eed578160200160208202803683370190505b509250612f1a60408051608081018252600080825260208201819052918101829052606081019190915290565b60005b838110156130d557878181518110612f3757612f376138df565b6020026020010151915060008260400151612f53578251612fb9565b82600001516001600160a01b03166338d52e0f6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612f95573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612fb99190613db2565b905060005b8481101561300557888181518110612fd857612fd86138df565b6020026020010151600001516001600160a01b0316826001600160a01b0316031561300557600101612fbe565b888181518110613017576130176138df565b602002602001015160200151888481518110613035576130356138df565b602002602001018181525050816001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa15801561307f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906130a39190613dcf565b6130ae90600a613df2565b8784815181106130c0576130c06138df565b60209081029190910101525050600101612f1d565b505050509250929050565b6000600a544211156130f35750600a5442035b90565b600061314b826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166132379092919063ffffffff16565b905080516000148061316c57508080602001905181019061316c9190613e01565b6127e55760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610a6a565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b60006132268361324e565b80156127fb57506127fb8383613281565b6060613246848460008561330a565b949350505050565b6000613261826301ffc9a760e01b613281565b801561064f575061327a826001600160e01b0319613281565b1592915050565b604080516001600160e01b03198316602480830191909152825180830390910181526044909101909152602080820180516001600160e01b03166301ffc9a760e01b178152825160009392849283928392918391908a617530fa92503d915060005190508280156132f3575060208210155b80156132ff5750600081115b979650505050505050565b60608247101561336b5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401610a6a565b600080866001600160a01b031685876040516133879190613e1c565b60006040518083038185875af1925050503d80600081146133c4576040519150601f19603f3d011682016040523d82523d6000602084013e6133c9565b606091505b50915091506132ff878383876060831561344457825160000361343d576001600160a01b0385163b61343d5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610a6a565b5081613246565b61324683838151156134595781518083602001fd5b8060405162461bcd60e51b8152600401610a6a9190613c50565b604080518082019091526000808252602082015290565b60006020828403121561349c57600080fd5b81356001600160e01b0319811681146127fb57600080fd5b600080602083850312156134c757600080fd5b82356001600160401b03808211156134de57600080fd5b818501915085601f8301126134f257600080fd5b81358181111561350157600080fd5b8660208260051b850101111561351657600080fd5b60209290920196919550909350505050565b6000806020838503121561353b57600080fd5b82356001600160401b038082111561355257600080fd5b818501915085601f83011261356657600080fd5b81358181111561357557600080fd5b8660208260061b850101111561351657600080fd5b60006020828403121561359c57600080fd5b81356001600160401b038111156135b257600080fd5b8201606081850312156127fb57600080fd5b6001600160a01b038116811461160457600080fd5b600080604083850312156135ec57600080fd5b82356135f7816135c4565b91506020830135613607816135c4565b809150509250929050565b602080825282518282018190526000919060409081850190868401855b8281101561365d57815180516001600160a01b0316855286015186850152928401929085019060010161362f565b5091979650505050505050565b60006020828403121561367c57600080fd5b81356127fb816135c4565b634e487b7160e01b600052604160045260246000fd5b604080519081016001600160401b03811182821017156136bf576136bf613687565b60405290565b604051608081016001600160401b03811182821017156136bf576136bf613687565b604051601f8201601f191681016001600160401b038111828210171561370f5761370f613687565b604052919050565b60006001600160401b0382111561373057613730613687565b5060051b60200190565b6000602080838503121561374d57600080fd5b82516001600160401b0381111561376357600080fd5b8301601f8101851361377457600080fd5b805161378761378282613717565b6136e7565b81815260069190911b820183019083810190878311156137a657600080fd5b928401925b828410156132ff57604084890312156137c45760008081fd5b6137cc61369d565b84516137d7816135c4565b815284860151868201528252604090930192908401906137ab565b8051801515811461380257600080fd5b919050565b6000602080838503121561381a57600080fd5b82516001600160401b0381111561383057600080fd5b8301601f8101851361384157600080fd5b805161384f61378282613717565b81815260079190911b8201830190838101908783111561386e57600080fd5b928401925b828410156132ff576080848903121561388c5760008081fd5b6138946136c5565b845161389f816135c4565b8152848601518682015260406138b68187016137f2565b908201526060858101516138c9816135c4565b9082015282526080939093019290840190613873565b634e487b7160e01b600052603260045260246000fd5b60006020828403121561390757600080fd5b5051919050565b634e487b7160e01b600052601160045260246000fd5b8181038181111561064f5761064f61390e565b60008135613944816135c4565b6001600160a01b0316835260208281013590840152604082013536839003601e1901811261397157600080fd5b82016020810190356001600160401b0381111561398d57600080fd5b80360382131561399c57600080fd5b60606040860152806060860152808260808701376000608082870101526080601f19601f8301168601019250505092915050565b60208082528181018390526000906040600585901b840181019084018684805b88811015613a3457878503603f190184528235368b9003605e19018112613a15578283fd5b613a21868c8301613937565b95505092850192918501916001016139f0565b509298975050505050505050565b60008235605e19833603018112613a5857600080fd5b9190910192915050565b6000808335601e19843603018112613a7957600080fd5b8301803591506001600160401b03821115613a9357600080fd5b602001915036819003821315612a2f57600080fd5b60008085851115613ab857600080fd5b83861115613ac557600080fd5b5050820193919092039150565b6001600160e01b03198135818116916004851015613afa5780818660040360031b1b83161692505b505092915050565b600080600060608486031215613b1757600080fd5b833592506020840135613b29816135c4565b91506040840135613b39816135c4565b809150509250925092565b8183823760009101908152919050565b60005b83811015613b6f578181015183820152602001613b57565b50506000910152565b60008151808452613b90816020860160208601613b54565b601f01601f19169290920160200192915050565b8281526040602082015260006132466040830184613b78565b6020808252818101839052600090604080840186845b87811015613c09578135613be6816135c4565b6001600160a01b0316835281850135858401529183019190830190600101613bd3565b5090979650505050505050565b600060408284031215613c2857600080fd5b613c3061369d565b8235613c3b816135c4565b81526020928301359281019290925250919050565b6020815260006127fb6020830184613b78565b6020815260006127fb6020830184613937565b808202811582820484141761064f5761064f61390e565b600082613caa57634e487b7160e01b600052601260045260246000fd5b500490565b8082018082111561064f5761064f61390e565b600181815b80851115613cfd578160001904821115613ce357613ce361390e565b80851615613cf057918102915b93841c9390800290613cc7565b509250929050565b600082613d145750600161064f565b81613d215750600061064f565b8160018114613d375760028114613d4157613d5d565b600191505061064f565b60ff841115613d5257613d5261390e565b50506001821b61064f565b5060208310610133831016604e8410600b8410161715613d80575081810a61064f565b613d8a8383613cc2565b8060001904821115613d9e57613d9e61390e565b029392505050565b60006127fb8383613d05565b600060208284031215613dc457600080fd5b81516127fb816135c4565b600060208284031215613de157600080fd5b815160ff811681146127fb57600080fd5b60006127fb60ff841683613d05565b600060208284031215613e1357600080fd5b6127fb826137f2565b60008251613a58818460208701613b5456fea26469706673582212202bae90f05dafd7dd747f40b271f25b0697316f60bce8b6dce464dbc01a42072264736f6c63430008150033
Loading...
Loading
Loading...
Loading
Net Worth in USD
$0.00
Net Worth in ETH
0
Multichain Portfolio | 34 Chains
| Chain | Token | Portfolio % | Price | Amount | Value |
|---|
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.