Source Code
Overview
ETH Balance
0 ETH
Eth Value
$0.00Latest 1 internal transaction
Advanced mode:
| Parent Transaction Hash | Method | Block |
From
|
|
To
|
||
|---|---|---|---|---|---|---|---|
| 0x60e06040 | 20265589 | 625 days ago | Contract Creation | 0 ETH |
Loading...
Loading
Loading...
Loading
Cross-Chain Transactions
Loading...
Loading
Similar Match Source Code This contract matches the deployed Bytecode of the Source Code for Contract 0x78c61B1E...e76Acb52B The constructor portion of the code might be different and could alter the actual behaviour of the contract
Contract Name:
DelayedWithdraw
Compiler Version
v0.8.21+commit.d9974bed
Optimization Enabled:
Yes with 200 runs
Other Settings:
shanghai EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT
pragma solidity 0.8.21;
import {ERC20} from "@solmate/tokens/ERC20.sol";
import {WETH} from "@solmate/tokens/WETH.sol";
import {BoringVault} from "src/base/BoringVault.sol";
import {AccountantWithRateProviders} from "src/base/Roles/AccountantWithRateProviders.sol";
import {FixedPointMathLib} from "@solmate/utils/FixedPointMathLib.sol";
import {SafeTransferLib} from "@solmate/utils/SafeTransferLib.sol";
import {BeforeTransferHook} from "src/interfaces/BeforeTransferHook.sol";
import {Auth, Authority} from "@solmate/auth/Auth.sol";
import {ReentrancyGuard} from "@solmate/utils/ReentrancyGuard.sol";
import {IPausable} from "src/interfaces/IPausable.sol";
contract DelayedWithdraw is Auth, ReentrancyGuard, IPausable {
using SafeTransferLib for BoringVault;
using SafeTransferLib for ERC20;
using FixedPointMathLib for uint256;
// ========================================= STRUCTS =========================================
/**
* @param allowWithdraws Whether or not withdrawals are allowed for this asset.
* @param withdrawDelay The delay in seconds before a requested withdrawal can be completed.
* @param completionWindow The window in seconds that a withdrawal can be completed after the maturity.
* @param outstandingShares The total number of shares that are currently outstanding for an asset.
* @param withdrawFee The fee that is charged when a withdrawal is completed.
* @param maxLoss The maximum loss that can be incurred when completing a withdrawal, evaluating the
* exchange rate at time of withdraw, compared to time of completion.
*/
struct WithdrawAsset {
bool allowWithdraws;
uint32 withdrawDelay;
uint32 completionWindow;
uint128 outstandingShares;
uint16 withdrawFee;
uint16 maxLoss;
}
/**
* @param allowThirdPartyToComplete Whether or not a 3rd party can complete a withdraw on behalf of a user.
* @param maxLoss The maximum loss that can be incurred when completing a withdrawal,
* use zero for global WithdrawAsset.maxLoss.
* @param maturity The time at which the withdrawal can be completed.
* @param shares The number of shares that are requested to be withdrawn.
* @param exchangeRateAtTimeOfRequest The exchange rate at the time of the request.
*/
struct WithdrawRequest {
bool allowThirdPartyToComplete;
uint16 maxLoss;
uint40 maturity;
uint96 shares;
uint96 exchangeRateAtTimeOfRequest;
}
// ========================================= CONSTANTS =========================================
/**
* @notice The largest withdraw fee that can be set.
*/
uint16 internal constant MAX_WITHDRAW_FEE = 0.2e4;
/**
* @notice The largest max loss that can be set.
*/
uint16 internal constant MAX_LOSS = 0.5e4;
/**
* @notice The default completion window for a withdrawal asset.
*/
uint32 internal constant DEFAULT_COMPLETION_WINDOW = 7 days;
// ========================================= STATE =========================================
/**
* @notice The address that receives the fee when a withdrawal is completed.
*/
address public feeAddress;
/**
* @notice Used to pause calls to `requestWithdraw`, and `completeWithdraw`.
*/
bool public isPaused;
/**
* @notice Whether or not the contract should pull funds from the Boring Vault when completing a withdrawal,
* or use funds the BoringVault has previously sent to this contract.
*/
bool public pullFundsFromVault;
/**
* @notice The mapping of assets to their respective withdrawal settings.
*/
mapping(ERC20 => WithdrawAsset) public withdrawAssets;
/**
* @notice The mapping of users to withdraw asset to their withdrawal requests.
*/
mapping(address => mapping(ERC20 => WithdrawRequest)) public withdrawRequests;
//============================== ERRORS ===============================
error DelayedWithdraw__WithdrawFeeTooHigh();
error DelayedWithdraw__MaxLossTooLarge();
error DelayedWithdraw__AlreadySetup();
error DelayedWithdraw__WithdrawsNotAllowed();
error DelayedWithdraw__WithdrawNotMatured();
error DelayedWithdraw__NoSharesToWithdraw();
error DelayedWithdraw__MaxLossExceeded();
error DelayedWithdraw__BadAddress();
error DelayedWithdraw__ThirdPartyCompletionNotAllowed();
error DelayedWithdraw__RequestPastCompletionWindow();
error DelayedWithdraw__Paused();
error DelayedWithdraw__CallerNotBoringVault();
error DelayedWithdraw__CannotWithdrawBoringToken();
//============================== EVENTS ===============================
event WithdrawRequested(address indexed account, ERC20 indexed asset, uint96 shares, uint40 maturity);
event WithdrawCancelled(address indexed account, ERC20 indexed asset, uint96 shares);
event WithdrawCompleted(address indexed account, ERC20 indexed asset, uint256 shares, uint256 assets);
event FeeAddressSet(address newFeeAddress);
event SetupWithdrawalsInAsset(address indexed asset, uint64 withdrawDelay, uint16 withdrawFee, uint16 maxLoss);
event WithdrawDelayUpdated(address indexed asset, uint32 newWithdrawDelay);
event CompletionWindowUpdated(address indexed asset, uint32 newCompletionWindow);
event WithdrawFeeUpdated(address indexed asset, uint16 newWithdrawFee);
event MaxLossUpdated(address indexed asset, uint16 newMaxLoss);
event WithdrawalsStopped(address indexed asset);
event ThirdPartyCompletionChanged(address indexed account, ERC20 indexed asset, bool allowed);
event Paused();
event Unpaused();
event PullFundsFromVaultUpdated(bool _pullFundsFromVault);
//============================== IMMUTABLES ===============================
/**
* @notice The accountant contract that is used to get the exchange rate of assets.
*/
AccountantWithRateProviders internal immutable accountant;
/**
* @notice The BoringVault contract that users are withdrawing from.
*/
BoringVault internal immutable boringVault;
/**
* @notice Constant that represents 1 share.
*/
uint256 internal immutable ONE_SHARE;
constructor(address _owner, address _boringVault, address _accountant, address _feeAddress)
Auth(_owner, Authority(address(0)))
{
accountant = AccountantWithRateProviders(_accountant);
boringVault = BoringVault(payable(_boringVault));
ONE_SHARE = 10 ** boringVault.decimals();
if (_feeAddress == address(0)) revert DelayedWithdraw__BadAddress();
feeAddress = _feeAddress;
}
// ========================================= ADMIN FUNCTIONS =========================================
/**
* @notice Pause this contract, which prevents future calls to `manageVaultWithMerkleVerification`.
* @dev Callable by MULTISIG_ROLE.
*/
function pause() external requiresAuth {
isPaused = true;
emit Paused();
}
/**
* @notice Unpause this contract, which allows future calls to `manageVaultWithMerkleVerification`.
* @dev Callable by MULTISIG_ROLE.
*/
function unpause() external requiresAuth {
isPaused = false;
emit Unpaused();
}
/**
* @notice Stops withdrawals for a specific asset.
* @dev Callable by MULTISIG_ROLE.
*/
function stopWithdrawalsInAsset(ERC20 asset) external requiresAuth {
WithdrawAsset storage withdrawAsset = withdrawAssets[asset];
if (!withdrawAsset.allowWithdraws) revert DelayedWithdraw__WithdrawsNotAllowed();
withdrawAsset.allowWithdraws = false;
emit WithdrawalsStopped(address(asset));
}
/**
* @notice Sets up the withdrawal settings for a specific asset.
* @dev Callable by OWNER_ROLE.
*/
function setupWithdrawAsset(
ERC20 asset,
uint32 withdrawDelay,
uint32 completionWindow,
uint16 withdrawFee,
uint16 maxLoss
) external requiresAuth {
WithdrawAsset storage withdrawAsset = withdrawAssets[asset];
if (withdrawFee > MAX_WITHDRAW_FEE) revert DelayedWithdraw__WithdrawFeeTooHigh();
if (maxLoss > MAX_LOSS) revert DelayedWithdraw__MaxLossTooLarge();
if (withdrawAsset.allowWithdraws) revert DelayedWithdraw__AlreadySetup();
withdrawAsset.allowWithdraws = true;
withdrawAsset.withdrawDelay = withdrawDelay;
withdrawAsset.completionWindow = completionWindow;
withdrawAsset.withdrawFee = withdrawFee;
withdrawAsset.maxLoss = maxLoss;
emit SetupWithdrawalsInAsset(address(asset), withdrawDelay, withdrawFee, maxLoss);
}
/**
* @notice Changes the withdraw delay for a specific asset.
* @dev Callable by MULTISIG_ROLE.
*/
function changeWithdrawDelay(ERC20 asset, uint32 withdrawDelay) external requiresAuth {
WithdrawAsset storage withdrawAsset = withdrawAssets[asset];
if (!withdrawAsset.allowWithdraws) revert DelayedWithdraw__WithdrawsNotAllowed();
withdrawAsset.withdrawDelay = withdrawDelay;
emit WithdrawDelayUpdated(address(asset), withdrawDelay);
}
/**
* @notice Changes the completion window for a specific asset.
* @dev Callable by MULTISIG_ROLE.
*/
function changeCompletionWindow(ERC20 asset, uint32 completionWindow) external requiresAuth {
WithdrawAsset storage withdrawAsset = withdrawAssets[asset];
if (!withdrawAsset.allowWithdraws) revert DelayedWithdraw__WithdrawsNotAllowed();
withdrawAsset.completionWindow = completionWindow;
emit CompletionWindowUpdated(address(asset), completionWindow);
}
/**
* @notice Changes the withdraw fee for a specific asset.
* @dev Callable by OWNER_ROLE.
*/
function changeWithdrawFee(ERC20 asset, uint16 withdrawFee) external requiresAuth {
WithdrawAsset storage withdrawAsset = withdrawAssets[asset];
if (!withdrawAsset.allowWithdraws) revert DelayedWithdraw__WithdrawsNotAllowed();
if (withdrawFee > MAX_WITHDRAW_FEE) revert DelayedWithdraw__WithdrawFeeTooHigh();
withdrawAsset.withdrawFee = withdrawFee;
emit WithdrawFeeUpdated(address(asset), withdrawFee);
}
/**
* @notice Changes the max loss for a specific asset.
* @dev Callable by OWNER_ROLE.
* @dev Since maxLoss is a global value based off some withdraw asset, it is possible that a user
* creates a request, then the maxLoss is updated to some value the user is not comfortable with.
* In this case the user should cancel their request. However this is not always possible, so a
* better course of action would be if the maxLoss needs to be updated, the asset can be fully removed.
* Then all exisitng requests for that asset can be cancelled, and finally the maxLoss can be updated.
*/
function changeMaxLoss(ERC20 asset, uint16 maxLoss) external requiresAuth {
WithdrawAsset storage withdrawAsset = withdrawAssets[asset];
if (!withdrawAsset.allowWithdraws) revert DelayedWithdraw__WithdrawsNotAllowed();
if (maxLoss > MAX_LOSS) revert DelayedWithdraw__MaxLossTooLarge();
withdrawAsset.maxLoss = maxLoss;
emit MaxLossUpdated(address(asset), maxLoss);
}
/**
* @notice Changes the fee address.
* @dev Callable by STRATEGIST_MULTISIG_ROLE.
*/
function setFeeAddress(address _feeAddress) external requiresAuth {
if (_feeAddress == address(0)) revert DelayedWithdraw__BadAddress();
feeAddress = _feeAddress;
emit FeeAddressSet(_feeAddress);
}
/**
* @notice Cancels a user's withdrawal request.
* @dev Callable by MULTISIG_ROLE, and STRATEGIST_MULTISIG_ROLE.
*/
function cancelUserWithdraw(ERC20 asset, address user) external requiresAuth {
_cancelWithdraw(asset, user);
}
/**
* @notice Completes a user's withdrawal request.
* @dev Admins can complete requests even if they are outside the completion window.
* @dev Callable by MULTISIG_ROLE, and STRATEGIST_MULTISIG_ROLE.
*/
function completeUserWithdraw(ERC20 asset, address user) external requiresAuth returns (uint256 assetsOut) {
WithdrawAsset storage withdrawAsset = withdrawAssets[asset];
WithdrawRequest storage req = withdrawRequests[user][asset];
assetsOut = _completeWithdraw(asset, user, withdrawAsset, req);
}
/**
* @notice Changes the global setting for whether or not to pull funds from the vault when completing a withdrawal.
* @dev Callable by OWNER_ROLE.
*/
function setPullFundsFromVault(bool _pullFundsFromVault) external requiresAuth {
pullFundsFromVault = _pullFundsFromVault;
emit PullFundsFromVaultUpdated(_pullFundsFromVault);
}
/**
* @notice Withdraws a non boring token from the contract.
* @dev Callable by BoringVault.
* @dev Eventhough withdrawing the BoringVault share from this contract requires
* a malicious leaf in the merkle tree, we explicitly revert if `token`
* is the BoringVault.
* @dev For future reference if this function selector is ever changed, the
* associated function selector must be updated in `BaseDecoderAndSanitizer.sol`.
*/
function withdrawNonBoringToken(ERC20 token, uint256 amount) external {
if (msg.sender != address(boringVault)) revert DelayedWithdraw__CallerNotBoringVault();
if (address(token) == address(boringVault)) revert DelayedWithdraw__CannotWithdrawBoringToken();
if (amount == type(uint256).max) {
amount = token.balanceOf(address(this));
}
token.safeTransfer(address(boringVault), amount);
}
// ========================================= PUBLIC FUNCTIONS =========================================
/**
* @notice Allows a user to set whether or not a 3rd party can complete withdraws on behalf of them.
*/
function setAllowThirdPartyToComplete(ERC20 asset, bool allow) external requiresAuth {
withdrawRequests[msg.sender][asset].allowThirdPartyToComplete = allow;
emit ThirdPartyCompletionChanged(msg.sender, asset, allow);
}
/**
* @notice Requests a withdrawal of shares for a specific asset.
* @dev Publicly callable.
*/
function requestWithdraw(ERC20 asset, uint96 shares, uint16 maxLoss, bool allowThirdPartyToComplete)
external
requiresAuth
nonReentrant
{
if (isPaused) revert DelayedWithdraw__Paused();
WithdrawAsset storage withdrawAsset = withdrawAssets[asset];
if (!withdrawAsset.allowWithdraws) revert DelayedWithdraw__WithdrawsNotAllowed();
if (maxLoss > MAX_LOSS) revert DelayedWithdraw__MaxLossTooLarge();
boringVault.safeTransferFrom(msg.sender, address(this), shares);
withdrawAsset.outstandingShares += shares;
WithdrawRequest storage req = withdrawRequests[msg.sender][asset];
req.shares += shares;
uint40 maturity = uint40(block.timestamp + withdrawAsset.withdrawDelay);
req.maturity = maturity;
req.exchangeRateAtTimeOfRequest = uint96(accountant.getRateInQuoteSafe(asset));
req.maxLoss = maxLoss;
req.allowThirdPartyToComplete = allowThirdPartyToComplete;
emit WithdrawRequested(msg.sender, asset, shares, maturity);
}
/**
* @notice Cancels msg.sender's withdrawal request.
* @dev Publicly callable.
*/
function cancelWithdraw(ERC20 asset) external requiresAuth nonReentrant {
_cancelWithdraw(asset, msg.sender);
}
/**
* @notice Completes a user's withdrawal request.
* @dev Publicly callable.
*/
function completeWithdraw(ERC20 asset, address account)
external
requiresAuth
nonReentrant
returns (uint256 assetsOut)
{
if (isPaused) revert DelayedWithdraw__Paused();
WithdrawAsset storage withdrawAsset = withdrawAssets[asset];
WithdrawRequest storage req = withdrawRequests[account][asset];
uint32 completionWindow =
withdrawAsset.completionWindow > 0 ? withdrawAsset.completionWindow : DEFAULT_COMPLETION_WINDOW;
if (block.timestamp > (req.maturity + completionWindow)) revert DelayedWithdraw__RequestPastCompletionWindow();
if (msg.sender != account && !req.allowThirdPartyToComplete) {
revert DelayedWithdraw__ThirdPartyCompletionNotAllowed();
}
assetsOut = _completeWithdraw(asset, account, withdrawAsset, req);
}
// ========================================= VIEW FUNCTIONS =========================================
/**
* @notice Helper function to view the outstanding withdraw debt for a specific asset.
*/
function viewOutstandingDebt(ERC20 asset) public view returns (uint256 debt) {
uint256 rate = accountant.getRateInQuoteSafe(asset);
debt = rate.mulDivDown(withdrawAssets[asset].outstandingShares, ONE_SHARE);
}
/**
* @notice Helper function to view the outstanding withdraw debt for multiple assets.
*/
function viewOutstandingDebts(ERC20[] calldata assets) external view returns (uint256[] memory debts) {
debts = new uint256[](assets.length);
for (uint256 i = 0; i < assets.length; i++) {
debts[i] = viewOutstandingDebt(assets[i]);
}
}
// ========================================= INTERNAL FUNCTIONS =========================================
/**
* @notice Internal helper function that implements shared logic for cancelling a user's withdrawal request.
*/
function _cancelWithdraw(ERC20 asset, address account) internal {
WithdrawAsset storage withdrawAsset = withdrawAssets[asset];
// We do not check if `asset` is allowed, to handle edge cases where the asset is no longer allowed.
WithdrawRequest storage req = withdrawRequests[account][asset];
uint96 shares = req.shares;
if (shares == 0) revert DelayedWithdraw__NoSharesToWithdraw();
withdrawAsset.outstandingShares -= shares;
req.shares = 0;
boringVault.safeTransfer(account, shares);
emit WithdrawCancelled(account, asset, shares);
}
/**
* @notice Internal helper function that implements shared logic for completing a user's withdrawal request.
*/
function _completeWithdraw(
ERC20 asset,
address account,
WithdrawAsset storage withdrawAsset,
WithdrawRequest storage req
) internal returns (uint256 assetsOut) {
if (!withdrawAsset.allowWithdraws) revert DelayedWithdraw__WithdrawsNotAllowed();
if (block.timestamp < req.maturity) revert DelayedWithdraw__WithdrawNotMatured();
if (req.shares == 0) revert DelayedWithdraw__NoSharesToWithdraw();
uint256 currentExchangeRate = accountant.getRateInQuoteSafe(asset);
uint256 minRate = req.exchangeRateAtTimeOfRequest < currentExchangeRate
? req.exchangeRateAtTimeOfRequest
: currentExchangeRate;
uint256 maxRate = req.exchangeRateAtTimeOfRequest < currentExchangeRate
? currentExchangeRate
: req.exchangeRateAtTimeOfRequest;
// If user has set a maxLoss use that, otherwise use the global maxLoss.
uint16 maxLoss = req.maxLoss > 0 ? req.maxLoss : withdrawAsset.maxLoss;
// Make sure minRate * maxLoss is greater than or equal to maxRate.
if (minRate.mulDivDown(1e4 + maxLoss, 1e4) < maxRate) revert DelayedWithdraw__MaxLossExceeded();
uint256 shares = req.shares;
// Safe to cast shares to a uint128 since req.shares is constrained to be less than 2^96.
withdrawAsset.outstandingShares -= uint128(shares);
if (withdrawAsset.withdrawFee > 0) {
// Handle withdraw fee.
uint256 fee = uint256(shares).mulDivDown(withdrawAsset.withdrawFee, 1e4);
shares -= fee;
// Transfer fee to feeAddress.
boringVault.safeTransfer(feeAddress, fee);
}
// Calculate assets out.
assetsOut = shares.mulDivDown(minRate, ONE_SHARE);
req.shares = 0;
if (pullFundsFromVault) {
// Burn shares and transfer assets to user.
boringVault.exit(account, asset, assetsOut, address(this), shares);
} else {
// Burn shares.
boringVault.exit(account, asset, 0, address(this), shares);
// Transfer assets to user.
asset.safeTransfer(account, assetsOut);
}
emit WithdrawCompleted(account, asset, shares, assetsOut);
}
}// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity >=0.8.0;
/// @notice Modern and gas efficient ERC20 + EIP-2612 implementation.
/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/tokens/ERC20.sol)
/// @author Modified from Uniswap (https://github.com/Uniswap/uniswap-v2-core/blob/master/contracts/UniswapV2ERC20.sol)
/// @dev Do not manually set balances without updating totalSupply, as the sum of all user balances must not exceed it.
abstract contract ERC20 {
/*//////////////////////////////////////////////////////////////
EVENTS
//////////////////////////////////////////////////////////////*/
event Transfer(address indexed from, address indexed to, uint256 amount);
event Approval(address indexed owner, address indexed spender, uint256 amount);
/*//////////////////////////////////////////////////////////////
METADATA STORAGE
//////////////////////////////////////////////////////////////*/
string public name;
string public symbol;
uint8 public immutable decimals;
/*//////////////////////////////////////////////////////////////
ERC20 STORAGE
//////////////////////////////////////////////////////////////*/
uint256 public totalSupply;
mapping(address => uint256) public balanceOf;
mapping(address => mapping(address => uint256)) public allowance;
/*//////////////////////////////////////////////////////////////
EIP-2612 STORAGE
//////////////////////////////////////////////////////////////*/
uint256 internal immutable INITIAL_CHAIN_ID;
bytes32 internal immutable INITIAL_DOMAIN_SEPARATOR;
mapping(address => uint256) public nonces;
/*//////////////////////////////////////////////////////////////
CONSTRUCTOR
//////////////////////////////////////////////////////////////*/
constructor(
string memory _name,
string memory _symbol,
uint8 _decimals
) {
name = _name;
symbol = _symbol;
decimals = _decimals;
INITIAL_CHAIN_ID = block.chainid;
INITIAL_DOMAIN_SEPARATOR = computeDomainSeparator();
}
/*//////////////////////////////////////////////////////////////
ERC20 LOGIC
//////////////////////////////////////////////////////////////*/
function approve(address spender, uint256 amount) public virtual returns (bool) {
allowance[msg.sender][spender] = amount;
emit Approval(msg.sender, spender, amount);
return true;
}
function transfer(address to, uint256 amount) public virtual returns (bool) {
balanceOf[msg.sender] -= amount;
// Cannot overflow because the sum of all user
// balances can't exceed the max uint256 value.
unchecked {
balanceOf[to] += amount;
}
emit Transfer(msg.sender, to, amount);
return true;
}
function transferFrom(
address from,
address to,
uint256 amount
) public virtual returns (bool) {
uint256 allowed = allowance[from][msg.sender]; // Saves gas for limited approvals.
if (allowed != type(uint256).max) allowance[from][msg.sender] = allowed - amount;
balanceOf[from] -= amount;
// Cannot overflow because the sum of all user
// balances can't exceed the max uint256 value.
unchecked {
balanceOf[to] += amount;
}
emit Transfer(from, to, amount);
return true;
}
/*//////////////////////////////////////////////////////////////
EIP-2612 LOGIC
//////////////////////////////////////////////////////////////*/
function permit(
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) public virtual {
require(deadline >= block.timestamp, "PERMIT_DEADLINE_EXPIRED");
// Unchecked because the only math done is incrementing
// the owner's nonce which cannot realistically overflow.
unchecked {
address recoveredAddress = ecrecover(
keccak256(
abi.encodePacked(
"\x19\x01",
DOMAIN_SEPARATOR(),
keccak256(
abi.encode(
keccak256(
"Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)"
),
owner,
spender,
value,
nonces[owner]++,
deadline
)
)
)
),
v,
r,
s
);
require(recoveredAddress != address(0) && recoveredAddress == owner, "INVALID_SIGNER");
allowance[recoveredAddress][spender] = value;
}
emit Approval(owner, spender, value);
}
function DOMAIN_SEPARATOR() public view virtual returns (bytes32) {
return block.chainid == INITIAL_CHAIN_ID ? INITIAL_DOMAIN_SEPARATOR : computeDomainSeparator();
}
function computeDomainSeparator() internal view virtual returns (bytes32) {
return
keccak256(
abi.encode(
keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"),
keccak256(bytes(name)),
keccak256("1"),
block.chainid,
address(this)
)
);
}
/*//////////////////////////////////////////////////////////////
INTERNAL MINT/BURN LOGIC
//////////////////////////////////////////////////////////////*/
function _mint(address to, uint256 amount) internal virtual {
totalSupply += amount;
// Cannot overflow because the sum of all user
// balances can't exceed the max uint256 value.
unchecked {
balanceOf[to] += amount;
}
emit Transfer(address(0), to, amount);
}
function _burn(address from, uint256 amount) internal virtual {
balanceOf[from] -= amount;
// Cannot underflow because a user's balance
// will never be larger than the total supply.
unchecked {
totalSupply -= amount;
}
emit Transfer(from, address(0), amount);
}
}// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity >=0.8.0;
import {ERC20} from "./ERC20.sol";
import {SafeTransferLib} from "../utils/SafeTransferLib.sol";
/// @notice Minimalist and modern Wrapped Ether implementation.
/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/tokens/WETH.sol)
/// @author Inspired by WETH9 (https://github.com/dapphub/ds-weth/blob/master/src/weth9.sol)
contract WETH is ERC20("Wrapped Ether", "WETH", 18) {
using SafeTransferLib for address;
event Deposit(address indexed from, uint256 amount);
event Withdrawal(address indexed to, uint256 amount);
function deposit() public payable virtual {
_mint(msg.sender, msg.value);
emit Deposit(msg.sender, msg.value);
}
function withdraw(uint256 amount) public virtual {
_burn(msg.sender, amount);
emit Withdrawal(msg.sender, amount);
msg.sender.safeTransferETH(amount);
}
receive() external payable virtual {
deposit();
}
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.21;
import {Address} from "@openzeppelin/contracts/utils/Address.sol";
import {ERC721Holder} from "@openzeppelin/contracts/token/ERC721/utils/ERC721Holder.sol";
import {ERC1155Holder} from "@openzeppelin/contracts/token/ERC1155/utils/ERC1155Holder.sol";
import {FixedPointMathLib} from "@solmate/utils/FixedPointMathLib.sol";
import {SafeTransferLib} from "@solmate/utils/SafeTransferLib.sol";
import {ERC20} from "@solmate/tokens/ERC20.sol";
import {BeforeTransferHook} from "src/interfaces/BeforeTransferHook.sol";
import {Auth, Authority} from "@solmate/auth/Auth.sol";
contract BoringVault is ERC20, Auth, ERC721Holder, ERC1155Holder {
using Address for address;
using SafeTransferLib for ERC20;
using FixedPointMathLib for uint256;
// ========================================= STATE =========================================
/**
* @notice Contract responsbile for implementing `beforeTransfer`.
*/
BeforeTransferHook public hook;
//============================== EVENTS ===============================
event Enter(address indexed from, address indexed asset, uint256 amount, address indexed to, uint256 shares);
event Exit(address indexed to, address indexed asset, uint256 amount, address indexed from, uint256 shares);
//============================== CONSTRUCTOR ===============================
constructor(address _owner, string memory _name, string memory _symbol, uint8 _decimals)
ERC20(_name, _symbol, _decimals)
Auth(_owner, Authority(address(0)))
{}
//============================== MANAGE ===============================
/**
* @notice Allows manager to make an arbitrary function call from this contract.
* @dev Callable by MANAGER_ROLE.
*/
function manage(address target, bytes calldata data, uint256 value)
external
requiresAuth
returns (bytes memory result)
{
result = target.functionCallWithValue(data, value);
}
/**
* @notice Allows manager to make arbitrary function calls from this contract.
* @dev Callable by MANAGER_ROLE.
*/
function manage(address[] calldata targets, bytes[] calldata data, uint256[] calldata values)
external
requiresAuth
returns (bytes[] memory results)
{
uint256 targetsLength = targets.length;
results = new bytes[](targetsLength);
for (uint256 i; i < targetsLength; ++i) {
results[i] = targets[i].functionCallWithValue(data[i], values[i]);
}
}
//============================== ENTER ===============================
/**
* @notice Allows minter to mint shares, in exchange for assets.
* @dev If assetAmount is zero, no assets are transferred in.
* @dev Callable by MINTER_ROLE.
*/
function enter(address from, ERC20 asset, uint256 assetAmount, address to, uint256 shareAmount)
external
requiresAuth
{
// Transfer assets in
if (assetAmount > 0) asset.safeTransferFrom(from, address(this), assetAmount);
// Mint shares.
_mint(to, shareAmount);
emit Enter(from, address(asset), assetAmount, to, shareAmount);
}
//============================== EXIT ===============================
/**
* @notice Allows burner to burn shares, in exchange for assets.
* @dev If assetAmount is zero, no assets are transferred out.
* @dev Callable by BURNER_ROLE.
*/
function exit(address to, ERC20 asset, uint256 assetAmount, address from, uint256 shareAmount)
external
requiresAuth
{
// Burn shares.
_burn(from, shareAmount);
// Transfer assets out.
if (assetAmount > 0) asset.safeTransfer(to, assetAmount);
emit Exit(to, address(asset), assetAmount, from, shareAmount);
}
//============================== BEFORE TRANSFER HOOK ===============================
/**
* @notice Sets the share locker.
* @notice If set to zero address, the share locker logic is disabled.
* @dev Callable by OWNER_ROLE.
*/
function setBeforeTransferHook(address _hook) external requiresAuth {
hook = BeforeTransferHook(_hook);
}
/**
* @notice Call `beforeTransferHook` passing in `from` `to`, and `msg.sender`.
*/
function _callBeforeTransfer(address from, address to) internal view {
if (address(hook) != address(0)) hook.beforeTransfer(from, to, msg.sender);
}
function transfer(address to, uint256 amount) public override returns (bool) {
_callBeforeTransfer(msg.sender, to);
return super.transfer(to, amount);
}
function transferFrom(address from, address to, uint256 amount) public override returns (bool) {
_callBeforeTransfer(from, to);
return super.transferFrom(from, to, amount);
}
//============================== RECEIVE ===============================
receive() external payable {}
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.21;
import {FixedPointMathLib} from "@solmate/utils/FixedPointMathLib.sol";
import {IRateProvider} from "src/interfaces/IRateProvider.sol";
import {ERC20} from "@solmate/tokens/ERC20.sol";
import {SafeTransferLib} from "@solmate/utils/SafeTransferLib.sol";
import {BoringVault} from "src/base/BoringVault.sol";
import {Auth, Authority} from "@solmate/auth/Auth.sol";
import {IPausable} from "src/interfaces/IPausable.sol";
contract AccountantWithRateProviders is Auth, IRateProvider, IPausable {
using FixedPointMathLib for uint256;
using SafeTransferLib for ERC20;
// ========================================= STRUCTS =========================================
/**
* @param payoutAddress the address `claimFees` sends fees to
* @param highwaterMark the highest value of the BoringVault's share price
* @param feesOwedInBase total pending fees owed in terms of base
* @param totalSharesLastUpdate total amount of shares the last exchange rate update
* @param exchangeRate the current exchange rate in terms of base
* @param allowedExchangeRateChangeUpper the max allowed change to exchange rate from an update
* @param allowedExchangeRateChangeLower the min allowed change to exchange rate from an update
* @param lastUpdateTimestamp the block timestamp of the last exchange rate update
* @param isPaused whether or not this contract is paused
* @param minimumUpdateDelayInSeconds the minimum amount of time that must pass between
* exchange rate updates, such that the update won't trigger the contract to be paused
* @param managementFee the management fee
* @param performanceFee the performance fee
*/
struct AccountantState {
address payoutAddress;
uint96 highwaterMark;
uint128 feesOwedInBase;
uint128 totalSharesLastUpdate;
uint96 exchangeRate;
uint16 allowedExchangeRateChangeUpper;
uint16 allowedExchangeRateChangeLower;
uint64 lastUpdateTimestamp;
bool isPaused;
uint24 minimumUpdateDelayInSeconds;
uint16 managementFee;
uint16 performanceFee;
}
/**
* @param isPeggedToBase whether or not the asset is 1:1 with the base asset
* @param rateProvider the rate provider for this asset if `isPeggedToBase` is false
*/
struct RateProviderData {
bool isPeggedToBase;
IRateProvider rateProvider;
}
// ========================================= STATE =========================================
/**
* @notice Store the accountant state in 3 packed slots.
*/
AccountantState public accountantState;
/**
* @notice Maps ERC20s to their RateProviderData.
*/
mapping(ERC20 => RateProviderData) public rateProviderData;
//============================== ERRORS ===============================
error AccountantWithRateProviders__UpperBoundTooSmall();
error AccountantWithRateProviders__LowerBoundTooLarge();
error AccountantWithRateProviders__ManagementFeeTooLarge();
error AccountantWithRateProviders__PerformanceFeeTooLarge();
error AccountantWithRateProviders__Paused();
error AccountantWithRateProviders__ZeroFeesOwed();
error AccountantWithRateProviders__OnlyCallableByBoringVault();
error AccountantWithRateProviders__UpdateDelayTooLarge();
error AccountantWithRateProviders__ExchangeRateAboveHighwaterMark();
//============================== EVENTS ===============================
event Paused();
event Unpaused();
event DelayInSecondsUpdated(uint24 oldDelay, uint24 newDelay);
event UpperBoundUpdated(uint16 oldBound, uint16 newBound);
event LowerBoundUpdated(uint16 oldBound, uint16 newBound);
event ManagementFeeUpdated(uint16 oldFee, uint16 newFee);
event PerformanceFeeUpdated(uint16 oldFee, uint16 newFee);
event PayoutAddressUpdated(address oldPayout, address newPayout);
event RateProviderUpdated(address asset, bool isPegged, address rateProvider);
event ExchangeRateUpdated(uint96 oldRate, uint96 newRate, uint64 currentTime);
event FeesClaimed(address indexed feeAsset, uint256 amount);
event HighwaterMarkReset();
//============================== IMMUTABLES ===============================
/**
* @notice The base asset rates are provided in.
*/
ERC20 public immutable base;
/**
* @notice The decimals rates are provided in.
*/
uint8 public immutable decimals;
/**
* @notice The BoringVault this accountant is working with.
* Used to determine share supply for fee calculation.
*/
BoringVault public immutable vault;
/**
* @notice One share of the BoringVault.
*/
uint256 internal immutable ONE_SHARE;
constructor(
address _owner,
address _vault,
address payoutAddress,
uint96 startingExchangeRate,
address _base,
uint16 allowedExchangeRateChangeUpper,
uint16 allowedExchangeRateChangeLower,
uint24 minimumUpdateDelayInSeconds,
uint16 managementFee,
uint16 performanceFee
) Auth(_owner, Authority(address(0))) {
base = ERC20(_base);
decimals = ERC20(_base).decimals();
vault = BoringVault(payable(_vault));
ONE_SHARE = 10 ** vault.decimals();
accountantState = AccountantState({
payoutAddress: payoutAddress,
highwaterMark: startingExchangeRate,
feesOwedInBase: 0,
totalSharesLastUpdate: uint128(vault.totalSupply()),
exchangeRate: startingExchangeRate,
allowedExchangeRateChangeUpper: allowedExchangeRateChangeUpper,
allowedExchangeRateChangeLower: allowedExchangeRateChangeLower,
lastUpdateTimestamp: uint64(block.timestamp),
isPaused: false,
minimumUpdateDelayInSeconds: minimumUpdateDelayInSeconds,
managementFee: managementFee,
performanceFee: performanceFee
});
}
// ========================================= ADMIN FUNCTIONS =========================================
/**
* @notice Pause this contract, which prevents future calls to `updateExchangeRate`, and any safe rate
* calls will revert.
* @dev Callable by MULTISIG_ROLE.
*/
function pause() external requiresAuth {
accountantState.isPaused = true;
emit Paused();
}
/**
* @notice Unpause this contract, which allows future calls to `updateExchangeRate`, and any safe rate
* calls will stop reverting.
* @dev Callable by MULTISIG_ROLE.
*/
function unpause() external requiresAuth {
accountantState.isPaused = false;
emit Unpaused();
}
/**
* @notice Update the minimum time delay between `updateExchangeRate` calls.
* @dev There are no input requirements, as it is possible the admin would want
* the exchange rate updated as frequently as needed.
* @dev Callable by OWNER_ROLE.
*/
function updateDelay(uint24 minimumUpdateDelayInSeconds) external requiresAuth {
if (minimumUpdateDelayInSeconds > 14 days) revert AccountantWithRateProviders__UpdateDelayTooLarge();
uint24 oldDelay = accountantState.minimumUpdateDelayInSeconds;
accountantState.minimumUpdateDelayInSeconds = minimumUpdateDelayInSeconds;
emit DelayInSecondsUpdated(oldDelay, minimumUpdateDelayInSeconds);
}
/**
* @notice Update the allowed upper bound change of exchange rate between `updateExchangeRateCalls`.
* @dev Callable by OWNER_ROLE.
*/
function updateUpper(uint16 allowedExchangeRateChangeUpper) external requiresAuth {
if (allowedExchangeRateChangeUpper < 1e4) revert AccountantWithRateProviders__UpperBoundTooSmall();
uint16 oldBound = accountantState.allowedExchangeRateChangeUpper;
accountantState.allowedExchangeRateChangeUpper = allowedExchangeRateChangeUpper;
emit UpperBoundUpdated(oldBound, allowedExchangeRateChangeUpper);
}
/**
* @notice Update the allowed lower bound change of exchange rate between `updateExchangeRateCalls`.
* @dev Callable by OWNER_ROLE.
*/
function updateLower(uint16 allowedExchangeRateChangeLower) external requiresAuth {
if (allowedExchangeRateChangeLower > 1e4) revert AccountantWithRateProviders__LowerBoundTooLarge();
uint16 oldBound = accountantState.allowedExchangeRateChangeLower;
accountantState.allowedExchangeRateChangeLower = allowedExchangeRateChangeLower;
emit LowerBoundUpdated(oldBound, allowedExchangeRateChangeLower);
}
/**
* @notice Update the management fee to a new value.
* @dev Callable by OWNER_ROLE.
*/
function updateManagementFee(uint16 managementFee) external requiresAuth {
if (managementFee > 0.2e4) revert AccountantWithRateProviders__ManagementFeeTooLarge();
uint16 oldFee = accountantState.managementFee;
accountantState.managementFee = managementFee;
emit ManagementFeeUpdated(oldFee, managementFee);
}
/**
* @notice Update the performance fee to a new value.
* @dev Callable by OWNER_ROLE.
*/
function updatePerformanceFee(uint16 performanceFee) external requiresAuth {
if (performanceFee > 0.5e4) revert AccountantWithRateProviders__PerformanceFeeTooLarge();
uint16 oldFee = accountantState.performanceFee;
accountantState.performanceFee = performanceFee;
emit PerformanceFeeUpdated(oldFee, performanceFee);
}
/**
* @notice Update the payout address fees are sent to.
* @dev Callable by OWNER_ROLE.
*/
function updatePayoutAddress(address payoutAddress) external requiresAuth {
address oldPayout = accountantState.payoutAddress;
accountantState.payoutAddress = payoutAddress;
emit PayoutAddressUpdated(oldPayout, payoutAddress);
}
/**
* @notice Update the rate provider data for a specific `asset`.
* @dev Rate providers must return rates in terms of `base` or
* an asset pegged to base and they must use the same decimals
* as `asset`.
* @dev Callable by OWNER_ROLE.
*/
function setRateProviderData(ERC20 asset, bool isPeggedToBase, address rateProvider) external requiresAuth {
rateProviderData[asset] =
RateProviderData({isPeggedToBase: isPeggedToBase, rateProvider: IRateProvider(rateProvider)});
emit RateProviderUpdated(address(asset), isPeggedToBase, rateProvider);
}
/**
* @notice Reset the highwater mark to the current exchange rate.
* @dev Callable by OWNER_ROLE.
*/
function resetHighwaterMark() external requiresAuth {
AccountantState storage state = accountantState;
if (state.exchangeRate > state.highwaterMark) {
revert AccountantWithRateProviders__ExchangeRateAboveHighwaterMark();
}
uint64 currentTime = uint64(block.timestamp);
uint256 currentTotalShares = vault.totalSupply();
_calculateFeesOwed(state, state.exchangeRate, state.exchangeRate, currentTotalShares, currentTime);
state.totalSharesLastUpdate = uint128(currentTotalShares);
state.highwaterMark = accountantState.exchangeRate;
state.lastUpdateTimestamp = currentTime;
emit HighwaterMarkReset();
}
// ========================================= UPDATE EXCHANGE RATE/FEES FUNCTIONS =========================================
/**
* @notice Updates this contract exchangeRate.
* @dev If new exchange rate is outside of accepted bounds, or if not enough time has passed, this
* will pause the contract, and this function will NOT calculate fees owed.
* @dev Callable by UPDATE_EXCHANGE_RATE_ROLE.
*/
function updateExchangeRate(uint96 newExchangeRate) external requiresAuth {
AccountantState storage state = accountantState;
if (state.isPaused) revert AccountantWithRateProviders__Paused();
uint64 currentTime = uint64(block.timestamp);
uint256 currentExchangeRate = state.exchangeRate;
uint256 currentTotalShares = vault.totalSupply();
if (
currentTime < state.lastUpdateTimestamp + state.minimumUpdateDelayInSeconds
|| newExchangeRate > currentExchangeRate.mulDivDown(state.allowedExchangeRateChangeUpper, 1e4)
|| newExchangeRate < currentExchangeRate.mulDivDown(state.allowedExchangeRateChangeLower, 1e4)
) {
// Instead of reverting, pause the contract. This way the exchange rate updater is able to update the exchange rate
// to a better value, and pause it.
state.isPaused = true;
} else {
_calculateFeesOwed(state, newExchangeRate, currentExchangeRate, currentTotalShares, currentTime);
}
state.exchangeRate = newExchangeRate;
state.totalSharesLastUpdate = uint128(currentTotalShares);
state.lastUpdateTimestamp = currentTime;
emit ExchangeRateUpdated(uint96(currentExchangeRate), newExchangeRate, currentTime);
}
/**
* @notice Claim pending fees.
* @dev This function must be called by the BoringVault.
* @dev This function will lose precision if the exchange rate
* decimals is greater than the feeAsset's decimals.
*/
function claimFees(ERC20 feeAsset) external {
if (msg.sender != address(vault)) revert AccountantWithRateProviders__OnlyCallableByBoringVault();
AccountantState storage state = accountantState;
if (state.isPaused) revert AccountantWithRateProviders__Paused();
if (state.feesOwedInBase == 0) revert AccountantWithRateProviders__ZeroFeesOwed();
// Determine amount of fees owed in feeAsset.
uint256 feesOwedInFeeAsset;
RateProviderData memory data = rateProviderData[feeAsset];
if (address(feeAsset) == address(base)) {
feesOwedInFeeAsset = state.feesOwedInBase;
} else {
uint8 feeAssetDecimals = ERC20(feeAsset).decimals();
uint256 feesOwedInBaseUsingFeeAssetDecimals =
changeDecimals(state.feesOwedInBase, decimals, feeAssetDecimals);
if (data.isPeggedToBase) {
feesOwedInFeeAsset = feesOwedInBaseUsingFeeAssetDecimals;
} else {
uint256 rate = data.rateProvider.getRate();
feesOwedInFeeAsset = feesOwedInBaseUsingFeeAssetDecimals.mulDivDown(10 ** feeAssetDecimals, rate);
}
}
// Zero out fees owed.
state.feesOwedInBase = 0;
// Transfer fee asset to payout address.
feeAsset.safeTransferFrom(msg.sender, state.payoutAddress, feesOwedInFeeAsset);
emit FeesClaimed(address(feeAsset), feesOwedInFeeAsset);
}
// ========================================= RATE FUNCTIONS =========================================
/**
* @notice Get this BoringVault's current rate in the base.
*/
function getRate() public view returns (uint256 rate) {
rate = accountantState.exchangeRate;
}
/**
* @notice Get this BoringVault's current rate in the base.
* @dev Revert if paused.
*/
function getRateSafe() external view returns (uint256 rate) {
if (accountantState.isPaused) revert AccountantWithRateProviders__Paused();
rate = getRate();
}
/**
* @notice Get this BoringVault's current rate in the provided quote.
* @dev `quote` must have its RateProviderData set, else this will revert.
* @dev This function will lose precision if the exchange rate
* decimals is greater than the quote's decimals.
*/
function getRateInQuote(ERC20 quote) public view returns (uint256 rateInQuote) {
if (address(quote) == address(base)) {
rateInQuote = accountantState.exchangeRate;
} else {
RateProviderData memory data = rateProviderData[quote];
uint8 quoteDecimals = ERC20(quote).decimals();
uint256 exchangeRateInQuoteDecimals = changeDecimals(accountantState.exchangeRate, decimals, quoteDecimals);
if (data.isPeggedToBase) {
rateInQuote = exchangeRateInQuoteDecimals;
} else {
uint256 quoteRate = data.rateProvider.getRate();
uint256 oneQuote = 10 ** quoteDecimals;
rateInQuote = oneQuote.mulDivDown(exchangeRateInQuoteDecimals, quoteRate);
}
}
}
/**
* @notice Get this BoringVault's current rate in the provided quote.
* @dev `quote` must have its RateProviderData set, else this will revert.
* @dev Revert if paused.
*/
function getRateInQuoteSafe(ERC20 quote) external view returns (uint256 rateInQuote) {
if (accountantState.isPaused) revert AccountantWithRateProviders__Paused();
rateInQuote = getRateInQuote(quote);
}
// ========================================= INTERNAL HELPER FUNCTIONS =========================================
/**
* @notice Used to change the decimals of precision used for an amount.
*/
function changeDecimals(uint256 amount, uint8 fromDecimals, uint8 toDecimals) internal pure returns (uint256) {
if (fromDecimals == toDecimals) {
return amount;
} else if (fromDecimals < toDecimals) {
return amount * 10 ** (toDecimals - fromDecimals);
} else {
return amount / 10 ** (fromDecimals - toDecimals);
}
}
/**
* @notice Calculate fees owed in base.
* @dev This function will update the highwater mark if the new exchange rate is higher.
*/
function _calculateFeesOwed(
AccountantState storage state,
uint96 newExchangeRate,
uint256 currentExchangeRate,
uint256 currentTotalShares,
uint64 currentTime
) internal {
// Only update fees if we are not paused.
// Update fee accounting.
uint256 shareSupplyToUse = currentTotalShares;
// Use the minimum between current total supply and total supply for last update.
if (state.totalSharesLastUpdate < shareSupplyToUse) {
shareSupplyToUse = state.totalSharesLastUpdate;
}
// Determine management fees owned.
uint256 timeDelta = currentTime - state.lastUpdateTimestamp;
uint256 minimumAssets = newExchangeRate > currentExchangeRate
? shareSupplyToUse.mulDivDown(currentExchangeRate, ONE_SHARE)
: shareSupplyToUse.mulDivDown(newExchangeRate, ONE_SHARE);
uint256 managementFeesAnnual = minimumAssets.mulDivDown(state.managementFee, 1e4);
uint256 newFeesOwedInBase = managementFeesAnnual.mulDivDown(timeDelta, 365 days);
// Account for performance fees.
if (newExchangeRate > state.highwaterMark) {
if (state.performanceFee > 0) {
uint256 changeInExchangeRate = newExchangeRate - state.highwaterMark;
uint256 yieldEarned = changeInExchangeRate.mulDivDown(shareSupplyToUse, ONE_SHARE);
uint256 performanceFeesOwedInBase = yieldEarned.mulDivDown(state.performanceFee, 1e4);
newFeesOwedInBase += performanceFeesOwedInBase;
}
// Always update the highwater mark if the new exchange rate is higher.
// This way if we are not iniitiall taking performance fees, we can start taking them
// without back charging them on past performance.
state.highwaterMark = newExchangeRate;
}
state.feesOwedInBase += uint128(newFeesOwedInBase);
}
}// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity >=0.8.0;
/// @notice Arithmetic library with operations for fixed-point numbers.
/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/utils/FixedPointMathLib.sol)
/// @author Inspired by USM (https://github.com/usmfum/USM/blob/master/contracts/WadMath.sol)
library FixedPointMathLib {
/*//////////////////////////////////////////////////////////////
SIMPLIFIED FIXED POINT OPERATIONS
//////////////////////////////////////////////////////////////*/
uint256 internal constant MAX_UINT256 = 2**256 - 1;
uint256 internal constant WAD = 1e18; // The scalar of ETH and most ERC20s.
function mulWadDown(uint256 x, uint256 y) internal pure returns (uint256) {
return mulDivDown(x, y, WAD); // Equivalent to (x * y) / WAD rounded down.
}
function mulWadUp(uint256 x, uint256 y) internal pure returns (uint256) {
return mulDivUp(x, y, WAD); // Equivalent to (x * y) / WAD rounded up.
}
function divWadDown(uint256 x, uint256 y) internal pure returns (uint256) {
return mulDivDown(x, WAD, y); // Equivalent to (x * WAD) / y rounded down.
}
function divWadUp(uint256 x, uint256 y) internal pure returns (uint256) {
return mulDivUp(x, WAD, y); // Equivalent to (x * WAD) / y rounded up.
}
/*//////////////////////////////////////////////////////////////
LOW LEVEL FIXED POINT OPERATIONS
//////////////////////////////////////////////////////////////*/
function mulDivDown(
uint256 x,
uint256 y,
uint256 denominator
) internal pure returns (uint256 z) {
/// @solidity memory-safe-assembly
assembly {
// Equivalent to require(denominator != 0 && (y == 0 || x <= type(uint256).max / y))
if iszero(mul(denominator, iszero(mul(y, gt(x, div(MAX_UINT256, y)))))) {
revert(0, 0)
}
// Divide x * y by the denominator.
z := div(mul(x, y), denominator)
}
}
function mulDivUp(
uint256 x,
uint256 y,
uint256 denominator
) internal pure returns (uint256 z) {
/// @solidity memory-safe-assembly
assembly {
// Equivalent to require(denominator != 0 && (y == 0 || x <= type(uint256).max / y))
if iszero(mul(denominator, iszero(mul(y, gt(x, div(MAX_UINT256, y)))))) {
revert(0, 0)
}
// If x * y modulo the denominator is strictly greater than 0,
// 1 is added to round up the division of x * y by the denominator.
z := add(gt(mod(mul(x, y), denominator), 0), div(mul(x, y), denominator))
}
}
function rpow(
uint256 x,
uint256 n,
uint256 scalar
) internal pure returns (uint256 z) {
/// @solidity memory-safe-assembly
assembly {
switch x
case 0 {
switch n
case 0 {
// 0 ** 0 = 1
z := scalar
}
default {
// 0 ** n = 0
z := 0
}
}
default {
switch mod(n, 2)
case 0 {
// If n is even, store scalar in z for now.
z := scalar
}
default {
// If n is odd, store x in z for now.
z := x
}
// Shifting right by 1 is like dividing by 2.
let half := shr(1, scalar)
for {
// Shift n right by 1 before looping to halve it.
n := shr(1, n)
} n {
// Shift n right by 1 each iteration to halve it.
n := shr(1, n)
} {
// Revert immediately if x ** 2 would overflow.
// Equivalent to iszero(eq(div(xx, x), x)) here.
if shr(128, x) {
revert(0, 0)
}
// Store x squared.
let xx := mul(x, x)
// Round to the nearest number.
let xxRound := add(xx, half)
// Revert if xx + half overflowed.
if lt(xxRound, xx) {
revert(0, 0)
}
// Set x to scaled xxRound.
x := div(xxRound, scalar)
// If n is even:
if mod(n, 2) {
// Compute z * x.
let zx := mul(z, x)
// If z * x overflowed:
if iszero(eq(div(zx, x), z)) {
// Revert if x is non-zero.
if iszero(iszero(x)) {
revert(0, 0)
}
}
// Round to the nearest number.
let zxRound := add(zx, half)
// Revert if zx + half overflowed.
if lt(zxRound, zx) {
revert(0, 0)
}
// Return properly scaled zxRound.
z := div(zxRound, scalar)
}
}
}
}
}
/*//////////////////////////////////////////////////////////////
GENERAL NUMBER UTILITIES
//////////////////////////////////////////////////////////////*/
function sqrt(uint256 x) internal pure returns (uint256 z) {
/// @solidity memory-safe-assembly
assembly {
let y := x // We start y at x, which will help us make our initial estimate.
z := 181 // The "correct" value is 1, but this saves a multiplication later.
// This segment is to get a reasonable initial estimate for the Babylonian method. With a bad
// start, the correct # of bits increases ~linearly each iteration instead of ~quadratically.
// We check y >= 2^(k + 8) but shift right by k bits
// each branch to ensure that if x >= 256, then y >= 256.
if iszero(lt(y, 0x10000000000000000000000000000000000)) {
y := shr(128, y)
z := shl(64, z)
}
if iszero(lt(y, 0x1000000000000000000)) {
y := shr(64, y)
z := shl(32, z)
}
if iszero(lt(y, 0x10000000000)) {
y := shr(32, y)
z := shl(16, z)
}
if iszero(lt(y, 0x1000000)) {
y := shr(16, y)
z := shl(8, z)
}
// Goal was to get z*z*y within a small factor of x. More iterations could
// get y in a tighter range. Currently, we will have y in [256, 256*2^16).
// We ensured y >= 256 so that the relative difference between y and y+1 is small.
// That's not possible if x < 256 but we can just verify those cases exhaustively.
// Now, z*z*y <= x < z*z*(y+1), and y <= 2^(16+8), and either y >= 256, or x < 256.
// Correctness can be checked exhaustively for x < 256, so we assume y >= 256.
// Then z*sqrt(y) is within sqrt(257)/sqrt(256) of sqrt(x), or about 20bps.
// For s in the range [1/256, 256], the estimate f(s) = (181/1024) * (s+1) is in the range
// (1/2.84 * sqrt(s), 2.84 * sqrt(s)), with largest error when s = 1 and when s = 256 or 1/256.
// Since y is in [256, 256*2^16), let a = y/65536, so that a is in [1/256, 256). Then we can estimate
// sqrt(y) using sqrt(65536) * 181/1024 * (a + 1) = 181/4 * (y + 65536)/65536 = 181 * (y + 65536)/2^18.
// There is no overflow risk here since y < 2^136 after the first branch above.
z := shr(18, mul(z, add(y, 65536))) // A mul() is saved from starting z at 181.
// Given the worst case multiplicative error of 2.84 above, 7 iterations should be enough.
z := shr(1, add(z, div(x, z)))
z := shr(1, add(z, div(x, z)))
z := shr(1, add(z, div(x, z)))
z := shr(1, add(z, div(x, z)))
z := shr(1, add(z, div(x, z)))
z := shr(1, add(z, div(x, z)))
z := shr(1, add(z, div(x, z)))
// If x+1 is a perfect square, the Babylonian method cycles between
// floor(sqrt(x)) and ceil(sqrt(x)). This statement ensures we return floor.
// See: https://en.wikipedia.org/wiki/Integer_square_root#Using_only_integer_division
// Since the ceil is rare, we save gas on the assignment and repeat division in the rare case.
// If you don't care whether the floor or ceil square root is returned, you can remove this statement.
z := sub(z, lt(div(x, z), z))
}
}
function unsafeMod(uint256 x, uint256 y) internal pure returns (uint256 z) {
/// @solidity memory-safe-assembly
assembly {
// Mod x by y. Note this will return
// 0 instead of reverting if y is zero.
z := mod(x, y)
}
}
function unsafeDiv(uint256 x, uint256 y) internal pure returns (uint256 r) {
/// @solidity memory-safe-assembly
assembly {
// Divide x by y. Note this will return
// 0 instead of reverting if y is zero.
r := div(x, y)
}
}
function unsafeDivUp(uint256 x, uint256 y) internal pure returns (uint256 z) {
/// @solidity memory-safe-assembly
assembly {
// Add 1 to x * y if x % y > 0. Note this will
// return 0 instead of reverting if y is zero.
z := add(gt(mod(x, y), 0), div(x, y))
}
}
}// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity >=0.8.0;
import {ERC20} from "../tokens/ERC20.sol";
/// @notice Safe ETH and ERC20 transfer library that gracefully handles missing return values.
/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/utils/SafeTransferLib.sol)
/// @dev Use with caution! Some functions in this library knowingly create dirty bits at the destination of the free memory pointer.
/// @dev Note that none of the functions in this library check that a token has code at all! That responsibility is delegated to the caller.
library SafeTransferLib {
/*//////////////////////////////////////////////////////////////
ETH OPERATIONS
//////////////////////////////////////////////////////////////*/
function safeTransferETH(address to, uint256 amount) internal {
bool success;
/// @solidity memory-safe-assembly
assembly {
// Transfer the ETH and store if it succeeded or not.
success := call(gas(), to, amount, 0, 0, 0, 0)
}
require(success, "ETH_TRANSFER_FAILED");
}
/*//////////////////////////////////////////////////////////////
ERC20 OPERATIONS
//////////////////////////////////////////////////////////////*/
function safeTransferFrom(
ERC20 token,
address from,
address to,
uint256 amount
) internal {
bool success;
/// @solidity memory-safe-assembly
assembly {
// Get a pointer to some free memory.
let freeMemoryPointer := mload(0x40)
// Write the abi-encoded calldata into memory, beginning with the function selector.
mstore(freeMemoryPointer, 0x23b872dd00000000000000000000000000000000000000000000000000000000)
mstore(add(freeMemoryPointer, 4), and(from, 0xffffffffffffffffffffffffffffffffffffffff)) // Append and mask the "from" argument.
mstore(add(freeMemoryPointer, 36), and(to, 0xffffffffffffffffffffffffffffffffffffffff)) // Append and mask the "to" argument.
mstore(add(freeMemoryPointer, 68), amount) // Append the "amount" argument. Masking not required as it's a full 32 byte type.
success := and(
// Set success to whether the call reverted, if not we check it either
// returned exactly 1 (can't just be non-zero data), or had no return data.
or(and(eq(mload(0), 1), gt(returndatasize(), 31)), iszero(returndatasize())),
// We use 100 because the length of our calldata totals up like so: 4 + 32 * 3.
// We use 0 and 32 to copy up to 32 bytes of return data into the scratch space.
// Counterintuitively, this call must be positioned second to the or() call in the
// surrounding and() call or else returndatasize() will be zero during the computation.
call(gas(), token, 0, freeMemoryPointer, 100, 0, 32)
)
}
require(success, "TRANSFER_FROM_FAILED");
}
function safeTransfer(
ERC20 token,
address to,
uint256 amount
) internal {
bool success;
/// @solidity memory-safe-assembly
assembly {
// Get a pointer to some free memory.
let freeMemoryPointer := mload(0x40)
// Write the abi-encoded calldata into memory, beginning with the function selector.
mstore(freeMemoryPointer, 0xa9059cbb00000000000000000000000000000000000000000000000000000000)
mstore(add(freeMemoryPointer, 4), and(to, 0xffffffffffffffffffffffffffffffffffffffff)) // Append and mask the "to" argument.
mstore(add(freeMemoryPointer, 36), amount) // Append the "amount" argument. Masking not required as it's a full 32 byte type.
success := and(
// Set success to whether the call reverted, if not we check it either
// returned exactly 1 (can't just be non-zero data), or had no return data.
or(and(eq(mload(0), 1), gt(returndatasize(), 31)), iszero(returndatasize())),
// We use 68 because the length of our calldata totals up like so: 4 + 32 * 2.
// We use 0 and 32 to copy up to 32 bytes of return data into the scratch space.
// Counterintuitively, this call must be positioned second to the or() call in the
// surrounding and() call or else returndatasize() will be zero during the computation.
call(gas(), token, 0, freeMemoryPointer, 68, 0, 32)
)
}
require(success, "TRANSFER_FAILED");
}
function safeApprove(
ERC20 token,
address to,
uint256 amount
) internal {
bool success;
/// @solidity memory-safe-assembly
assembly {
// Get a pointer to some free memory.
let freeMemoryPointer := mload(0x40)
// Write the abi-encoded calldata into memory, beginning with the function selector.
mstore(freeMemoryPointer, 0x095ea7b300000000000000000000000000000000000000000000000000000000)
mstore(add(freeMemoryPointer, 4), and(to, 0xffffffffffffffffffffffffffffffffffffffff)) // Append and mask the "to" argument.
mstore(add(freeMemoryPointer, 36), amount) // Append the "amount" argument. Masking not required as it's a full 32 byte type.
success := and(
// Set success to whether the call reverted, if not we check it either
// returned exactly 1 (can't just be non-zero data), or had no return data.
or(and(eq(mload(0), 1), gt(returndatasize(), 31)), iszero(returndatasize())),
// We use 68 because the length of our calldata totals up like so: 4 + 32 * 2.
// We use 0 and 32 to copy up to 32 bytes of return data into the scratch space.
// Counterintuitively, this call must be positioned second to the or() call in the
// surrounding and() call or else returndatasize() will be zero during the computation.
call(gas(), token, 0, freeMemoryPointer, 68, 0, 32)
)
}
require(success, "APPROVE_FAILED");
}
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.21;
interface BeforeTransferHook {
function beforeTransfer(address from, address to, address operator) external view;
}// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity >=0.8.0;
/// @notice Provides a flexible and updatable auth pattern which is completely separate from application logic.
/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/auth/Auth.sol)
/// @author Modified from Dappsys (https://github.com/dapphub/ds-auth/blob/master/src/auth.sol)
abstract contract Auth {
event OwnershipTransferred(address indexed user, address indexed newOwner);
event AuthorityUpdated(address indexed user, Authority indexed newAuthority);
address public owner;
Authority public authority;
constructor(address _owner, Authority _authority) {
owner = _owner;
authority = _authority;
emit OwnershipTransferred(msg.sender, _owner);
emit AuthorityUpdated(msg.sender, _authority);
}
modifier requiresAuth() virtual {
require(isAuthorized(msg.sender, msg.sig), "UNAUTHORIZED");
_;
}
function isAuthorized(address user, bytes4 functionSig) internal view virtual returns (bool) {
Authority auth = authority; // Memoizing authority saves us a warm SLOAD, around 100 gas.
// Checking if the caller is the owner only after calling the authority saves gas in most cases, but be
// aware that this makes protected functions uncallable even to the owner if the authority is out of order.
return (address(auth) != address(0) && auth.canCall(user, address(this), functionSig)) || user == owner;
}
function setAuthority(Authority newAuthority) public virtual {
// We check if the caller is the owner first because we want to ensure they can
// always swap out the authority even if it's reverting or using up a lot of gas.
require(msg.sender == owner || authority.canCall(msg.sender, address(this), msg.sig));
authority = newAuthority;
emit AuthorityUpdated(msg.sender, newAuthority);
}
function transferOwnership(address newOwner) public virtual requiresAuth {
owner = newOwner;
emit OwnershipTransferred(msg.sender, newOwner);
}
}
/// @notice A generic interface for a contract which provides authorization data to an Auth instance.
/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/auth/Auth.sol)
/// @author Modified from Dappsys (https://github.com/dapphub/ds-auth/blob/master/src/auth.sol)
interface Authority {
function canCall(
address user,
address target,
bytes4 functionSig
) external view returns (bool);
}// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity >=0.8.0;
/// @notice Gas optimized reentrancy protection for smart contracts.
/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/utils/ReentrancyGuard.sol)
/// @author Modified from OpenZeppelin (https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/security/ReentrancyGuard.sol)
abstract contract ReentrancyGuard {
uint256 private locked = 1;
modifier nonReentrant() virtual {
require(locked == 1, "REENTRANCY");
locked = 2;
_;
locked = 1;
}
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.21;
interface IPausable {
function pause() external;
function unpause() external;
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/Address.sol)
pragma solidity ^0.8.20;
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev The ETH balance of the account is not enough to perform the operation.
*/
error AddressInsufficientBalance(address account);
/**
* @dev There's no code at `target` (it is not a contract).
*/
error AddressEmptyCode(address target);
/**
* @dev A call to an address target failed. The target may have reverted.
*/
error FailedInnerCall();
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
if (address(this).balance < amount) {
revert AddressInsufficientBalance(address(this));
}
(bool success, ) = recipient.call{value: amount}("");
if (!success) {
revert FailedInnerCall();
}
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason or custom error, it is bubbled
* up by this function (like regular Solidity function calls). However, if
* the call reverted with no returned reason, this function reverts with a
* {FailedInnerCall} error.
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
if (address(this).balance < value) {
revert AddressInsufficientBalance(address(this));
}
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResultFromTarget(target, success, returndata);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResultFromTarget(target, success, returndata);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResultFromTarget(target, success, returndata);
}
/**
* @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target
* was not a contract or bubbling up the revert reason (falling back to {FailedInnerCall}) in case of an
* unsuccessful call.
*/
function verifyCallResultFromTarget(
address target,
bool success,
bytes memory returndata
) internal view returns (bytes memory) {
if (!success) {
_revert(returndata);
} else {
// only check if target is a contract if the call was successful and the return data is empty
// otherwise we already know that it was a contract
if (returndata.length == 0 && target.code.length == 0) {
revert AddressEmptyCode(target);
}
return returndata;
}
}
/**
* @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the
* revert reason or with a default {FailedInnerCall} error.
*/
function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) {
if (!success) {
_revert(returndata);
} else {
return returndata;
}
}
/**
* @dev Reverts with returndata if present. Otherwise reverts with {FailedInnerCall}.
*/
function _revert(bytes memory returndata) private pure {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
/// @solidity memory-safe-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert FailedInnerCall();
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC721/utils/ERC721Holder.sol)
pragma solidity ^0.8.20;
import {IERC721Receiver} from "../IERC721Receiver.sol";
/**
* @dev Implementation of the {IERC721Receiver} interface.
*
* Accepts all token transfers.
* Make sure the contract is able to use its token with {IERC721-safeTransferFrom}, {IERC721-approve} or
* {IERC721-setApprovalForAll}.
*/
abstract contract ERC721Holder is IERC721Receiver {
/**
* @dev See {IERC721Receiver-onERC721Received}.
*
* Always returns `IERC721Receiver.onERC721Received.selector`.
*/
function onERC721Received(address, address, uint256, bytes memory) public virtual returns (bytes4) {
return this.onERC721Received.selector;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC1155/utils/ERC1155Holder.sol)
pragma solidity ^0.8.20;
import {IERC165, ERC165} from "../../../utils/introspection/ERC165.sol";
import {IERC1155Receiver} from "../IERC1155Receiver.sol";
/**
* @dev Simple implementation of `IERC1155Receiver` that will allow a contract to hold ERC1155 tokens.
*
* IMPORTANT: When inheriting this contract, you must include a way to use the received tokens, otherwise they will be
* stuck.
*/
abstract contract ERC1155Holder is ERC165, IERC1155Receiver {
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {
return interfaceId == type(IERC1155Receiver).interfaceId || super.supportsInterface(interfaceId);
}
function onERC1155Received(
address,
address,
uint256,
uint256,
bytes memory
) public virtual override returns (bytes4) {
return this.onERC1155Received.selector;
}
function onERC1155BatchReceived(
address,
address,
uint256[] memory,
uint256[] memory,
bytes memory
) public virtual override returns (bytes4) {
return this.onERC1155BatchReceived.selector;
}
}// SPDX-License-Identifier: GPL-3.0-or-later
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
pragma solidity ^0.8.0;
interface IRateProvider {
function getRate() external view returns (uint256);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC721/IERC721Receiver.sol)
pragma solidity ^0.8.20;
/**
* @title ERC721 token receiver interface
* @dev Interface for any contract that wants to support safeTransfers
* from ERC721 asset contracts.
*/
interface IERC721Receiver {
/**
* @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}
* by `operator` from `from`, this function is called.
*
* It must return its Solidity selector to confirm the token transfer.
* If any other value is returned or the interface is not implemented by the recipient, the transfer will be
* reverted.
*
* The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`.
*/
function onERC721Received(
address operator,
address from,
uint256 tokenId,
bytes calldata data
) external returns (bytes4);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/ERC165.sol)
pragma solidity ^0.8.20;
import {IERC165} from "./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);
* }
* ```
*/
abstract contract ERC165 is IERC165 {
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {
return interfaceId == type(IERC165).interfaceId;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC1155/IERC1155Receiver.sol)
pragma solidity ^0.8.20;
import {IERC165} from "../../utils/introspection/IERC165.sol";
/**
* @dev Interface that must be implemented by smart contracts in order to receive
* ERC-1155 token transfers.
*/
interface IERC1155Receiver is IERC165 {
/**
* @dev Handles the receipt of a single ERC1155 token type. This function is
* called at the end of a `safeTransferFrom` after the balance has been updated.
*
* NOTE: To accept the transfer, this must return
* `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))`
* (i.e. 0xf23a6e61, or its own function selector).
*
* @param operator The address which initiated the transfer (i.e. msg.sender)
* @param from The address which previously owned the token
* @param id The ID of the token being transferred
* @param value The amount of tokens being transferred
* @param data Additional data with no specified format
* @return `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))` if transfer is allowed
*/
function onERC1155Received(
address operator,
address from,
uint256 id,
uint256 value,
bytes calldata data
) external returns (bytes4);
/**
* @dev Handles the receipt of a multiple ERC1155 token types. This function
* is called at the end of a `safeBatchTransferFrom` after the balances have
* been updated.
*
* NOTE: To accept the transfer(s), this must return
* `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))`
* (i.e. 0xbc197c81, or its own function selector).
*
* @param operator The address which initiated the batch transfer (i.e. msg.sender)
* @param from The address which previously owned the token
* @param ids An array containing ids of each token being transferred (order and length must match values array)
* @param values An array containing amounts of each token being transferred (order and length must match ids array)
* @param data Additional data with no specified format
* @return `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))` if transfer is allowed
*/
function onERC1155BatchReceived(
address operator,
address from,
uint256[] calldata ids,
uint256[] calldata values,
bytes calldata data
) external returns (bytes4);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol)
pragma solidity ^0.8.20;
/**
* @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);
}{
"remappings": [
"@solmate/=lib/solmate/src/",
"@forge-std/=lib/forge-std/src/",
"@ds-test/=lib/forge-std/lib/ds-test/src/",
"ds-test/=lib/forge-std/lib/ds-test/src/",
"@openzeppelin/=lib/openzeppelin-contracts/",
"@ccip/=lib/ccip/",
"@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/",
"ccip/=lib/ccip/contracts/",
"erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/",
"forge-std/=lib/forge-std/src/",
"openzeppelin-contracts/=lib/openzeppelin-contracts/",
"solmate/=lib/solmate/src/"
],
"optimizer": {
"enabled": true,
"runs": 200
},
"metadata": {
"useLiteralContent": false,
"bytecodeHash": "ipfs",
"appendCBOR": true
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"evmVersion": "shanghai",
"viaIR": false,
"libraries": {}
}Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"address","name":"_boringVault","type":"address"},{"internalType":"address","name":"_accountant","type":"address"},{"internalType":"address","name":"_feeAddress","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"DelayedWithdraw__AlreadySetup","type":"error"},{"inputs":[],"name":"DelayedWithdraw__BadAddress","type":"error"},{"inputs":[],"name":"DelayedWithdraw__CallerNotBoringVault","type":"error"},{"inputs":[],"name":"DelayedWithdraw__CannotWithdrawBoringToken","type":"error"},{"inputs":[],"name":"DelayedWithdraw__MaxLossExceeded","type":"error"},{"inputs":[],"name":"DelayedWithdraw__MaxLossTooLarge","type":"error"},{"inputs":[],"name":"DelayedWithdraw__NoSharesToWithdraw","type":"error"},{"inputs":[],"name":"DelayedWithdraw__Paused","type":"error"},{"inputs":[],"name":"DelayedWithdraw__RequestPastCompletionWindow","type":"error"},{"inputs":[],"name":"DelayedWithdraw__ThirdPartyCompletionNotAllowed","type":"error"},{"inputs":[],"name":"DelayedWithdraw__WithdrawFeeTooHigh","type":"error"},{"inputs":[],"name":"DelayedWithdraw__WithdrawNotMatured","type":"error"},{"inputs":[],"name":"DelayedWithdraw__WithdrawsNotAllowed","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"contract Authority","name":"newAuthority","type":"address"}],"name":"AuthorityUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"asset","type":"address"},{"indexed":false,"internalType":"uint32","name":"newCompletionWindow","type":"uint32"}],"name":"CompletionWindowUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"newFeeAddress","type":"address"}],"name":"FeeAddressSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"asset","type":"address"},{"indexed":false,"internalType":"uint16","name":"newMaxLoss","type":"uint16"}],"name":"MaxLossUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bool","name":"_pullFundsFromVault","type":"bool"}],"name":"PullFundsFromVaultUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"asset","type":"address"},{"indexed":false,"internalType":"uint64","name":"withdrawDelay","type":"uint64"},{"indexed":false,"internalType":"uint16","name":"withdrawFee","type":"uint16"},{"indexed":false,"internalType":"uint16","name":"maxLoss","type":"uint16"}],"name":"SetupWithdrawalsInAsset","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"contract ERC20","name":"asset","type":"address"},{"indexed":false,"internalType":"bool","name":"allowed","type":"bool"}],"name":"ThirdPartyCompletionChanged","type":"event"},{"anonymous":false,"inputs":[],"name":"Unpaused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"contract ERC20","name":"asset","type":"address"},{"indexed":false,"internalType":"uint96","name":"shares","type":"uint96"}],"name":"WithdrawCancelled","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"contract ERC20","name":"asset","type":"address"},{"indexed":false,"internalType":"uint256","name":"shares","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"assets","type":"uint256"}],"name":"WithdrawCompleted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"asset","type":"address"},{"indexed":false,"internalType":"uint32","name":"newWithdrawDelay","type":"uint32"}],"name":"WithdrawDelayUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"asset","type":"address"},{"indexed":false,"internalType":"uint16","name":"newWithdrawFee","type":"uint16"}],"name":"WithdrawFeeUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"contract ERC20","name":"asset","type":"address"},{"indexed":false,"internalType":"uint96","name":"shares","type":"uint96"},{"indexed":false,"internalType":"uint40","name":"maturity","type":"uint40"}],"name":"WithdrawRequested","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"asset","type":"address"}],"name":"WithdrawalsStopped","type":"event"},{"inputs":[],"name":"authority","outputs":[{"internalType":"contract Authority","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract ERC20","name":"asset","type":"address"},{"internalType":"address","name":"user","type":"address"}],"name":"cancelUserWithdraw","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract ERC20","name":"asset","type":"address"}],"name":"cancelWithdraw","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract ERC20","name":"asset","type":"address"},{"internalType":"uint32","name":"completionWindow","type":"uint32"}],"name":"changeCompletionWindow","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract ERC20","name":"asset","type":"address"},{"internalType":"uint16","name":"maxLoss","type":"uint16"}],"name":"changeMaxLoss","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract ERC20","name":"asset","type":"address"},{"internalType":"uint32","name":"withdrawDelay","type":"uint32"}],"name":"changeWithdrawDelay","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract ERC20","name":"asset","type":"address"},{"internalType":"uint16","name":"withdrawFee","type":"uint16"}],"name":"changeWithdrawFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract ERC20","name":"asset","type":"address"},{"internalType":"address","name":"user","type":"address"}],"name":"completeUserWithdraw","outputs":[{"internalType":"uint256","name":"assetsOut","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract ERC20","name":"asset","type":"address"},{"internalType":"address","name":"account","type":"address"}],"name":"completeWithdraw","outputs":[{"internalType":"uint256","name":"assetsOut","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"feeAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"isPaused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"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":"pullFundsFromVault","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract ERC20","name":"asset","type":"address"},{"internalType":"uint96","name":"shares","type":"uint96"},{"internalType":"uint16","name":"maxLoss","type":"uint16"},{"internalType":"bool","name":"allowThirdPartyToComplete","type":"bool"}],"name":"requestWithdraw","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract ERC20","name":"asset","type":"address"},{"internalType":"bool","name":"allow","type":"bool"}],"name":"setAllowThirdPartyToComplete","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract Authority","name":"newAuthority","type":"address"}],"name":"setAuthority","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_feeAddress","type":"address"}],"name":"setFeeAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"_pullFundsFromVault","type":"bool"}],"name":"setPullFundsFromVault","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract ERC20","name":"asset","type":"address"},{"internalType":"uint32","name":"withdrawDelay","type":"uint32"},{"internalType":"uint32","name":"completionWindow","type":"uint32"},{"internalType":"uint16","name":"withdrawFee","type":"uint16"},{"internalType":"uint16","name":"maxLoss","type":"uint16"}],"name":"setupWithdrawAsset","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract ERC20","name":"asset","type":"address"}],"name":"stopWithdrawalsInAsset","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"unpause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract ERC20","name":"asset","type":"address"}],"name":"viewOutstandingDebt","outputs":[{"internalType":"uint256","name":"debt","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract ERC20[]","name":"assets","type":"address[]"}],"name":"viewOutstandingDebts","outputs":[{"internalType":"uint256[]","name":"debts","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract ERC20","name":"","type":"address"}],"name":"withdrawAssets","outputs":[{"internalType":"bool","name":"allowWithdraws","type":"bool"},{"internalType":"uint32","name":"withdrawDelay","type":"uint32"},{"internalType":"uint32","name":"completionWindow","type":"uint32"},{"internalType":"uint128","name":"outstandingShares","type":"uint128"},{"internalType":"uint16","name":"withdrawFee","type":"uint16"},{"internalType":"uint16","name":"maxLoss","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract ERC20","name":"token","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"withdrawNonBoringToken","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"contract ERC20","name":"","type":"address"}],"name":"withdrawRequests","outputs":[{"internalType":"bool","name":"allowThirdPartyToComplete","type":"bool"},{"internalType":"uint16","name":"maxLoss","type":"uint16"},{"internalType":"uint40","name":"maturity","type":"uint40"},{"internalType":"uint96","name":"shares","type":"uint96"},{"internalType":"uint96","name":"exchangeRateAtTimeOfRequest","type":"uint96"}],"stateMutability":"view","type":"function"}]Contract Creation Code
0x60e0604052600160025534801562000015575f80fd5b506040516200280e3803806200280e8339810160408190526200003891620001b7565b5f80546001600160a01b0386166001600160a01b031991821681178355600180549092169091556040518692919033907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908490a36040516001600160a01b0382169033907fa3396fd7f6e0a21b50e5089d2da70d5ac0a3bbbd1f617a93f134b76389980198905f90a350506001600160a01b03808316608052831660a08190526040805163313ce56760e01b8152905163313ce567916004808201926020929091908290030181865afa15801562000113573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019062000139919062000211565b6200014690600a62000349565b60c0526001600160a01b0381166200017157604051631e74ce7160e31b815260040160405180910390fd5b600380546001600160a01b0319166001600160a01b03929092169190911790555062000359915050565b80516001600160a01b0381168114620001b2575f80fd5b919050565b5f805f8060808587031215620001cb575f80fd5b620001d6856200019b565b9350620001e6602086016200019b565b9250620001f6604086016200019b565b915062000206606086016200019b565b905092959194509250565b5f6020828403121562000222575f80fd5b815160ff8116811462000233575f80fd5b9392505050565b634e487b7160e01b5f52601160045260245ffd5b600181815b808511156200028e57815f19048211156200027257620002726200023a565b808516156200028057918102915b93841c939080029062000253565b509250929050565b5f82620002a65750600162000343565b81620002b457505f62000343565b8160018114620002cd5760028114620002d857620002f8565b600191505062000343565b60ff841115620002ec57620002ec6200023a565b50506001821b62000343565b5060208310610133831016604e8410600b84101617156200031d575081810a62000343565b6200032983836200024e565b805f19048211156200033f576200033f6200023a565b0290505b92915050565b5f6200023360ff84168362000296565b60805160a05160c051612444620003ca5f395f81816108680152611ce701525f818161053b0152818161057a0152818161064a015281816112c40152818161197e01528181611cb501528181611d710152611e0701525f81816107cc015281816114010152611ac201526124445ff3fe608060405234801561000f575f80fd5b50600436106101bb575f3560e01c80638705fcd4116100f3578063b187bd2611610093578063bf7e214f1161006e578063bf7e214f146104e4578063d82bf6d6146104f7578063e99196291461050a578063f2fde38b1461051d575f80fd5b8063b187bd26146104aa578063b75fa7b3146104be578063bafc3dd6146104d1575f80fd5b80638da5cb5b116100ce5780638da5cb5b146103c8578063aa5a0ffd146103da578063b013c6c514610484578063b16944de14610497575f80fd5b80638705fcd41461037157806389089628146103845780638af46eb3146103a8575f80fd5b8063582f2eb61161015e578063692be6f111610139578063692be6f1146103305780637a9e5e4b146103435780637e6bf61f146103565780638456cb5914610369575f80fd5b8063582f2eb61461026657806365b5a00f1461027957806366b3c5241461031d575f80fd5b80633ac5427c116101995780633ac5427c146101fa5780633f4ba83a1461022057806341275358146102285780634953cdbe14610253575f80fd5b806309f0e0c2146101bf57806313cc759e146101d45780632f13a2f1146101e7575b5f80fd5b6101d26101cd366004611f85565b610530565b005b6101d26101e2366004611fc5565b610673565b6101d26101f5366004611ff8565b61076e565b61020d61020836600461202f565b6107a9565b6040519081526020015b60405180910390f35b6101d2610893565b60035461023b906001600160a01b031681565b6040516001600160a01b039091168152602001610217565b61020d610261366004611ff8565b6108fb565b6101d261027436600461205d565b610a7c565b6102db610287366004611ff8565b600560209081525f928352604080842090915290825290205460ff81169061ffff6101008204169064ffffffffff6301000000820416906001600160601b03600160401b8204811691600160a01b90041685565b60408051951515865261ffff909416602086015264ffffffffff909216928401929092526001600160601b03918216606084015216608082015260a001610217565b6101d261032b3660046120cd565b610c04565b6101d261033e36600461202f565b610ca0565b6101d261035136600461202f565b610d49565b61020d610364366004611ff8565b610e2d565b6101d2610ea2565b6101d261037f36600461202f565b610f10565b60035461039890600160a81b900460ff1681565b6040519015158152602001610217565b6103bb6103b63660046120f9565b610fbd565b6040516102179190612168565b5f5461023b906001600160a01b031681565b61043c6103e836600461202f565b60046020525f908152604090205460ff81169063ffffffff6101008204811691600160281b8104909116906001600160801b03600160481b8204169061ffff600160c81b8204811691600160d81b90041686565b60408051961515875263ffffffff958616602088015294909316938501939093526001600160801b0316606084015261ffff91821660808401521660a082015260c001610217565b6101d26104923660046121ab565b61106e565b6101d26104a5366004611fc5565b6110ec565b60035461039890600160a01b900460ff1681565b6101d26104cc3660046121c6565b6111d5565b6101d26104df366004612228565b61150c565b60015461023b906001600160a01b031681565b6101d2610505366004612228565b6115d4565b6101d261051836600461202f565b611696565b6101d261052b36600461202f565b6116ff565b336001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016146105785760405162a9803f60e41b815260040160405180910390fd5b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316826001600160a01b0316036105ca5760405163a6781bfd60e01b815260040160405180910390fd5b5f19810361063b576040516370a0823160e01b81523060048201526001600160a01b038316906370a0823190602401602060405180830381865afa158015610614573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906106389190612252565b90505b61066f6001600160a01b0383167f00000000000000000000000000000000000000000000000000000000000000008361177a565b5050565b610688335f356001600160e01b0319166117fd565b6106ad5760405162461bcd60e51b81526004016106a490612269565b60405180910390fd5b6001600160a01b0382165f908152600460205260409020805460ff166106e657604051631174ace960e11b815260040160405180910390fd5b6107d061ffff8316111561070d576040516332e4bb9360e11b815260040160405180910390fd5b805461ffff60c81b1916600160c81b61ffff84169081029190911782556040519081526001600160a01b038416907f8ccb18452db698466024883cfd6df6fee864c24ed64251ecf8ec814f372a2f2f906020015b60405180910390a2505050565b610783335f356001600160e01b0319166117fd565b61079f5760405162461bcd60e51b81526004016106a490612269565b61066f82826118a5565b604051634104b9ed60e11b81526001600160a01b0382811660048301525f9182917f0000000000000000000000000000000000000000000000000000000000000000169063820973da90602401602060405180830381865afa158015610811573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906108359190612252565b6001600160a01b0384165f9081526004602052604090205490915061088c908290600160481b90046001600160801b03167f0000000000000000000000000000000000000000000000000000000000000000611a01565b9392505050565b6108a8335f356001600160e01b0319166117fd565b6108c45760405162461bcd60e51b81526004016106a490612269565b6003805460ff60a01b191690556040517fa45f47fdea8a1efdd9029a5691c7f759c32b7c698632b563573e155625d16933905f90a1565b5f610911335f356001600160e01b0319166117fd565b61092d5760405162461bcd60e51b81526004016106a490612269565b60025460011461094f5760405162461bcd60e51b81526004016106a49061228f565b60028055600354600160a01b900460ff161561097e57604051632ebdcdd760e21b815260040160405180910390fd5b6001600160a01b038381165f8181526004602090815260408083209487168352600582528083209383529290529081208254909190600160281b900463ffffffff166109cd5762093a806109dd565b8254600160281b900463ffffffff165b8254909150610a019063ffffffff8316906301000000900464ffffffffff166122c7565b64ffffffffff16421115610a285760405163027123cd60e41b815260040160405180910390fd5b336001600160a01b03861614801590610a435750815460ff16155b15610a615760405163541250f760e01b815260040160405180910390fd5b610a6d86868585611a1c565b60016002559695505050505050565b610a91335f356001600160e01b0319166117fd565b610aad5760405162461bcd60e51b81526004016106a490612269565b6001600160a01b0385165f9081526004602052604090206107d061ffff84161115610aeb576040516332e4bb9360e11b815260040160405180910390fd5b61138861ffff83161115610b1257604051636e3d72c360e11b815260040160405180910390fd5b805460ff1615610b3557604051632e2f525d60e11b815260040160405180910390fd5b805461ffff838116600160d81b810261ffff60d81b19928716600160c81b810261ffff60c81b1963ffffffff8b8116600160281b02919091167affff00000000000000000000000000000000ffffffff000000000019918d16610100810264ffffffffff199099169890981760011791909116171793909316178455604080519384526020840192909252908201526001600160a01b038716907f2d9461084dada7ec1631fe3cdd1fa3827bd388fb673649af550f08e8d799e0359060600160405180910390a2505050505050565b610c19335f356001600160e01b0319166117fd565b610c355760405162461bcd60e51b81526004016106a490612269565b335f8181526005602090815260408083206001600160a01b03871680855290835292819020805460ff191686151590811790915590519081529192917f21620b27ba9eeb9c0fe4b328d9038784b90664af3e7f54617d2d3b14cd97c34e910160405180910390a35050565b610cb5335f356001600160e01b0319166117fd565b610cd15760405162461bcd60e51b81526004016106a490612269565b6001600160a01b0381165f908152600460205260409020805460ff16610d0a57604051631174ace960e11b815260040160405180910390fd5b805460ff191681556040516001600160a01b038316907fb03b41043f453253837c2a473842b2d0f3025250ef63df22a7ba259b7b47495f905f90a25050565b5f546001600160a01b0316331480610dda575060015460405163b700961360e01b81526001600160a01b039091169063b700961390610d9b90339030906001600160e01b03195f3516906004016122e5565b602060405180830381865afa158015610db6573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610dda9190612312565b610de2575f80fd5b600180546001600160a01b0319166001600160a01b03831690811790915560405133907fa3396fd7f6e0a21b50e5089d2da70d5ac0a3bbbd1f617a93f134b76389980198905f90a350565b5f610e43335f356001600160e01b0319166117fd565b610e5f5760405162461bcd60e51b81526004016106a490612269565b6001600160a01b038084165f81815260046020908152604080832094871683526005825280832093835292905220610e9985858484611a1c565b95945050505050565b610eb7335f356001600160e01b0319166117fd565b610ed35760405162461bcd60e51b81526004016106a490612269565b6003805460ff60a01b1916600160a01b1790556040517f9e87fac88ff661f02d44f95383c817fece4bce600a3dab7a54406878b965e752905f90a1565b610f25335f356001600160e01b0319166117fd565b610f415760405162461bcd60e51b81526004016106a490612269565b6001600160a01b038116610f6857604051631e74ce7160e31b815260040160405180910390fd5b600380546001600160a01b0319166001600160a01b0383169081179091556040519081527f679f4cc040076580bf118e3f2307b72842331922e8054b8cc292bb37f05e5b03906020015b60405180910390a150565b60608167ffffffffffffffff811115610fd857610fd861232d565b604051908082528060200260200182016040528015611001578160200160208202803683370190505b5090505f5b828110156110675761103884848381811061102357611023612341565b9050602002016020810190610208919061202f565b82828151811061104a5761104a612341565b60209081029190910101528061105f81612355565b915050611006565b5092915050565b611083335f356001600160e01b0319166117fd565b61109f5760405162461bcd60e51b81526004016106a490612269565b60038054821515600160a81b0260ff60a81b199091161790556040517f9bd1a4bfe91dd4368b87973b0759c3649648cf04d60c8de148d719c9d229332690610fb290831515815260200190565b611101335f356001600160e01b0319166117fd565b61111d5760405162461bcd60e51b81526004016106a490612269565b6001600160a01b0382165f908152600460205260409020805460ff1661115657604051631174ace960e11b815260040160405180910390fd5b61138861ffff8316111561117d57604051636e3d72c360e11b815260040160405180910390fd5b805461ffff60d81b1916600160d81b61ffff84169081029190911782556040519081526001600160a01b038416907fb6a1832c57da203cbc5d77b31512e2f9c661069e85fd0f9dec6f0c8b9ce24ef890602001610761565b6111ea335f356001600160e01b0319166117fd565b6112065760405162461bcd60e51b81526004016106a490612269565b6002546001146112285760405162461bcd60e51b81526004016106a49061228f565b60028055600354600160a01b900460ff161561125757604051632ebdcdd760e21b815260040160405180910390fd5b6001600160a01b0384165f908152600460205260409020805460ff1661129057604051631174ace960e11b815260040160405180910390fd5b61138861ffff841611156112b757604051636e3d72c360e11b815260040160405180910390fd5b6112f56001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001633306001600160601b038816611ed6565b80546001600160601b038516908290600990611322908490600160481b90046001600160801b031661236d565b82546001600160801b039182166101009390930a928302919092021990911617905550335f9081526005602090815260408083206001600160a01b0389168452909152902080548590829060089061138c9084906001600160601b03600160401b9091041661238d565b82546001600160601b0391821661010093840a908102920219161790915583545f92506113c19163ffffffff910416426123ad565b825467ffffffffff0000001916630100000064ffffffffff831602178355604051634104b9ed60e11b81526001600160a01b0389811660048301529192507f00000000000000000000000000000000000000000000000000000000000000009091169063820973da90602401602060405180830381865afa158015611448573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061146c9190612252565b825473ffffffffffffffffffffffffffffffffff0000ff16600160a01b6001600160601b039283160262ffff0019161761010061ffff8816021760ff191685151517835560408051918816825264ffffffffff831660208301526001600160a01b0389169133917f7c7bb9f0b469c21da4666496577565b8e0f6a5da9834e8d15b12603b260ca6c6910160405180910390a3505060016002555050505050565b611521335f356001600160e01b0319166117fd565b61153d5760405162461bcd60e51b81526004016106a490612269565b6001600160a01b0382165f908152600460205260409020805460ff1661157657604051631174ace960e11b815260040160405180910390fd5b805468ffffffff00000000001916600160281b63ffffffff84169081029190911782556040519081526001600160a01b038416907f01020e4692686f9ef8b89baf5b96d4af4713bdaaf269706540e1e894d959310990602001610761565b6115e9335f356001600160e01b0319166117fd565b6116055760405162461bcd60e51b81526004016106a490612269565b6001600160a01b0382165f908152600460205260409020805460ff1661163e57604051631174ace960e11b815260040160405180910390fd5b805464ffffffff00191661010063ffffffff84169081029190911782556040519081526001600160a01b038416907ff460eccc96794cc59e91dc95757a6579291d9b251377740e28b39b482290052a90602001610761565b6116ab335f356001600160e01b0319166117fd565b6116c75760405162461bcd60e51b81526004016106a490612269565b6002546001146116e95760405162461bcd60e51b81526004016106a49061228f565b600280556116f781336118a5565b506001600255565b611714335f356001600160e01b0319166117fd565b6117305760405162461bcd60e51b81526004016106a490612269565b5f80546001600160a01b0319166001600160a01b0383169081178255604051909133917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a350565b5f60405163a9059cbb60e01b81526001600160a01b038416600482015282602482015260205f6044835f895af13d15601f3d1160015f5114161716915050806117f75760405162461bcd60e51b815260206004820152600f60248201526e1514905394d1915497d19052531151608a1b60448201526064016106a4565b50505050565b6001545f906001600160a01b03168015801590611884575060405163b700961360e01b81526001600160a01b0382169063b700961390611845908790309088906004016122e5565b602060405180830381865afa158015611860573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906118849190612312565b8061189b57505f546001600160a01b038581169116145b9150505b92915050565b6001600160a01b038281165f81815260046020908152604080832094861683526005825280832093835292905290812080549091600160401b9091046001600160601b03169081900361190b576040516339333c7d60e21b815260040160405180910390fd5b82546001600160601b038216908490600990611938908490600160481b90046001600160801b03166123c0565b82546001600160801b039182166101009390930a92830291909202199091161790555081546bffffffffffffffffffffffff60401b191682556119ae6001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016856001600160601b03841661177a565b6040516001600160601b03821681526001600160a01b0380871691908616907fcb0f3204f6895f1e698cfa5f0cceed9d5e62b57fe0d8648a47fc3685a78e7e979060200160405180910390a35050505050565b5f825f190484118302158202611a15575f80fd5b5091020490565b81545f9060ff16611a4057604051631174ace960e11b815260040160405180910390fd5b81546301000000900464ffffffffff16421015611a70576040516314ea2dc560e21b815260040160405180910390fd5b8154600160401b90046001600160601b03165f03611aa1576040516339333c7d60e21b815260040160405180910390fd5b604051634104b9ed60e11b81526001600160a01b0386811660048301525f917f00000000000000000000000000000000000000000000000000000000000000009091169063820973da90602401602060405180830381865afa158015611b09573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611b2d9190612252565b83549091505f90600160a01b90046001600160601b03168211611b505781611b63565b8354600160a01b90046001600160601b03165b84549091505f90600160a01b90046001600160601b03168311611b97578454600160a01b90046001600160601b0316611b99565b825b85549091505f90610100900461ffff16611bbf578654600160d81b900461ffff16611bcb565b8554610100900461ffff165b905081611beb611bdd836127106123e0565b859061ffff16612710611a01565b1015611c0a57604051634f48837160e01b815260040160405180910390fd5b85548754600160401b9091046001600160601b03169081908990600990611c42908490600160481b90046001600160801b03166123c0565b82546001600160801b039182166101009390930a928302919092021990911617905550875461ffff600160c81b9091041615611ce05787545f90611c95908390600160c81b900461ffff16612710611a01565b9050611ca181836123fb565b600354909250611cde906001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000811691168361177a565b505b611d0b81857f0000000000000000000000000000000000000000000000000000000000000000611a01565b87546bffffffffffffffffffffffff60401b19168855600354909650600160a81b900460ff1615611dcd576040516318457e6160e01b81526001600160a01b038a811660048301528b8116602483015260448201889052306064830152608482018390527f000000000000000000000000000000000000000000000000000000000000000016906318457e619060a4015f604051808303815f87803b158015611db2575f80fd5b505af1158015611dc4573d5f803e3d5ffd5b50505050611e73565b6040516318457e6160e01b81526001600160a01b038a811660048301528b811660248301525f6044830152306064830152608482018390527f000000000000000000000000000000000000000000000000000000000000000016906318457e619060a4015f604051808303815f87803b158015611e48575f80fd5b505af1158015611e5a573d5f803e3d5ffd5b50611e73925050506001600160a01b038b168a8861177a565b896001600160a01b0316896001600160a01b03167fbf9c520fb583da9b8f434d2dfa27f8695602f498c937081299893335144e99a28389604051611ec1929190918252602082015260400190565b60405180910390a35050505050949350505050565b5f6040516323b872dd60e01b81526001600160a01b03851660048201526001600160a01b038416602482015282604482015260205f6064835f8a5af13d15601f3d1160015f511416171691505080611f675760405162461bcd60e51b81526020600482015260146024820152731514905394d1915497d19493d357d1905253115160621b60448201526064016106a4565b5050505050565b6001600160a01b0381168114611f82575f80fd5b50565b5f8060408385031215611f96575f80fd5b8235611fa181611f6e565b946020939093013593505050565b803561ffff81168114611fc0575f80fd5b919050565b5f8060408385031215611fd6575f80fd5b8235611fe181611f6e565b9150611fef60208401611faf565b90509250929050565b5f8060408385031215612009575f80fd5b823561201481611f6e565b9150602083013561202481611f6e565b809150509250929050565b5f6020828403121561203f575f80fd5b813561088c81611f6e565b803563ffffffff81168114611fc0575f80fd5b5f805f805f60a08688031215612071575f80fd5b853561207c81611f6e565b945061208a6020870161204a565b93506120986040870161204a565b92506120a660608701611faf565b91506120b460808701611faf565b90509295509295909350565b8015158114611f82575f80fd5b5f80604083850312156120de575f80fd5b82356120e981611f6e565b91506020830135612024816120c0565b5f806020838503121561210a575f80fd5b823567ffffffffffffffff80821115612121575f80fd5b818501915085601f830112612134575f80fd5b813581811115612142575f80fd5b8660208260051b8501011115612156575f80fd5b60209290920196919550909350505050565b602080825282518282018190525f9190848201906040850190845b8181101561219f57835183529284019291840191600101612183565b50909695505050505050565b5f602082840312156121bb575f80fd5b813561088c816120c0565b5f805f80608085870312156121d9575f80fd5b84356121e481611f6e565b935060208501356001600160601b03811681146121ff575f80fd5b925061220d60408601611faf565b9150606085013561221d816120c0565b939692955090935050565b5f8060408385031215612239575f80fd5b823561224481611f6e565b9150611fef6020840161204a565b5f60208284031215612262575f80fd5b5051919050565b6020808252600c908201526b15539055551213d49256915160a21b604082015260600190565b6020808252600a90820152695245454e5452414e435960b01b604082015260600190565b634e487b7160e01b5f52601160045260245ffd5b64ffffffffff818116838216019080821115611067576110676122b3565b6001600160a01b0393841681529190921660208201526001600160e01b0319909116604082015260600190565b5f60208284031215612322575f80fd5b815161088c816120c0565b634e487b7160e01b5f52604160045260245ffd5b634e487b7160e01b5f52603260045260245ffd5b5f60018201612366576123666122b3565b5060010190565b6001600160801b03818116838216019080821115611067576110676122b3565b6001600160601b03818116838216019080821115611067576110676122b3565b8082018082111561189f5761189f6122b3565b6001600160801b03828116828216039080821115611067576110676122b3565b61ffff818116838216019080821115611067576110676122b3565b8181038181111561189f5761189f6122b356fea26469706673582212205e3cd6918ebc483da71b611ae90d3565bfcb8f8e190f0be9cb175e2d6c043d2564736f6c634300081500330000000000000000000000000463e60c7ce10e57911ab7bd1667eaa21de3e79b00000000000000000000000086b5780b606940eb59a062aa85a07959518c016100000000000000000000000005a1552c5e18f5a0bb9571b5f2d6a4765ebda32b000000000000000000000000a9962a5bfbea6918e958dee0647e99fd7863b95a
Deployed Bytecode
0x608060405234801561000f575f80fd5b50600436106101bb575f3560e01c80638705fcd4116100f3578063b187bd2611610093578063bf7e214f1161006e578063bf7e214f146104e4578063d82bf6d6146104f7578063e99196291461050a578063f2fde38b1461051d575f80fd5b8063b187bd26146104aa578063b75fa7b3146104be578063bafc3dd6146104d1575f80fd5b80638da5cb5b116100ce5780638da5cb5b146103c8578063aa5a0ffd146103da578063b013c6c514610484578063b16944de14610497575f80fd5b80638705fcd41461037157806389089628146103845780638af46eb3146103a8575f80fd5b8063582f2eb61161015e578063692be6f111610139578063692be6f1146103305780637a9e5e4b146103435780637e6bf61f146103565780638456cb5914610369575f80fd5b8063582f2eb61461026657806365b5a00f1461027957806366b3c5241461031d575f80fd5b80633ac5427c116101995780633ac5427c146101fa5780633f4ba83a1461022057806341275358146102285780634953cdbe14610253575f80fd5b806309f0e0c2146101bf57806313cc759e146101d45780632f13a2f1146101e7575b5f80fd5b6101d26101cd366004611f85565b610530565b005b6101d26101e2366004611fc5565b610673565b6101d26101f5366004611ff8565b61076e565b61020d61020836600461202f565b6107a9565b6040519081526020015b60405180910390f35b6101d2610893565b60035461023b906001600160a01b031681565b6040516001600160a01b039091168152602001610217565b61020d610261366004611ff8565b6108fb565b6101d261027436600461205d565b610a7c565b6102db610287366004611ff8565b600560209081525f928352604080842090915290825290205460ff81169061ffff6101008204169064ffffffffff6301000000820416906001600160601b03600160401b8204811691600160a01b90041685565b60408051951515865261ffff909416602086015264ffffffffff909216928401929092526001600160601b03918216606084015216608082015260a001610217565b6101d261032b3660046120cd565b610c04565b6101d261033e36600461202f565b610ca0565b6101d261035136600461202f565b610d49565b61020d610364366004611ff8565b610e2d565b6101d2610ea2565b6101d261037f36600461202f565b610f10565b60035461039890600160a81b900460ff1681565b6040519015158152602001610217565b6103bb6103b63660046120f9565b610fbd565b6040516102179190612168565b5f5461023b906001600160a01b031681565b61043c6103e836600461202f565b60046020525f908152604090205460ff81169063ffffffff6101008204811691600160281b8104909116906001600160801b03600160481b8204169061ffff600160c81b8204811691600160d81b90041686565b60408051961515875263ffffffff958616602088015294909316938501939093526001600160801b0316606084015261ffff91821660808401521660a082015260c001610217565b6101d26104923660046121ab565b61106e565b6101d26104a5366004611fc5565b6110ec565b60035461039890600160a01b900460ff1681565b6101d26104cc3660046121c6565b6111d5565b6101d26104df366004612228565b61150c565b60015461023b906001600160a01b031681565b6101d2610505366004612228565b6115d4565b6101d261051836600461202f565b611696565b6101d261052b36600461202f565b6116ff565b336001600160a01b037f00000000000000000000000086b5780b606940eb59a062aa85a07959518c016116146105785760405162a9803f60e41b815260040160405180910390fd5b7f00000000000000000000000086b5780b606940eb59a062aa85a07959518c01616001600160a01b0316826001600160a01b0316036105ca5760405163a6781bfd60e01b815260040160405180910390fd5b5f19810361063b576040516370a0823160e01b81523060048201526001600160a01b038316906370a0823190602401602060405180830381865afa158015610614573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906106389190612252565b90505b61066f6001600160a01b0383167f00000000000000000000000086b5780b606940eb59a062aa85a07959518c01618361177a565b5050565b610688335f356001600160e01b0319166117fd565b6106ad5760405162461bcd60e51b81526004016106a490612269565b60405180910390fd5b6001600160a01b0382165f908152600460205260409020805460ff166106e657604051631174ace960e11b815260040160405180910390fd5b6107d061ffff8316111561070d576040516332e4bb9360e11b815260040160405180910390fd5b805461ffff60c81b1916600160c81b61ffff84169081029190911782556040519081526001600160a01b038416907f8ccb18452db698466024883cfd6df6fee864c24ed64251ecf8ec814f372a2f2f906020015b60405180910390a2505050565b610783335f356001600160e01b0319166117fd565b61079f5760405162461bcd60e51b81526004016106a490612269565b61066f82826118a5565b604051634104b9ed60e11b81526001600160a01b0382811660048301525f9182917f00000000000000000000000005a1552c5e18f5a0bb9571b5f2d6a4765ebda32b169063820973da90602401602060405180830381865afa158015610811573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906108359190612252565b6001600160a01b0384165f9081526004602052604090205490915061088c908290600160481b90046001600160801b03167f0000000000000000000000000000000000000000000000000de0b6b3a7640000611a01565b9392505050565b6108a8335f356001600160e01b0319166117fd565b6108c45760405162461bcd60e51b81526004016106a490612269565b6003805460ff60a01b191690556040517fa45f47fdea8a1efdd9029a5691c7f759c32b7c698632b563573e155625d16933905f90a1565b5f610911335f356001600160e01b0319166117fd565b61092d5760405162461bcd60e51b81526004016106a490612269565b60025460011461094f5760405162461bcd60e51b81526004016106a49061228f565b60028055600354600160a01b900460ff161561097e57604051632ebdcdd760e21b815260040160405180910390fd5b6001600160a01b038381165f8181526004602090815260408083209487168352600582528083209383529290529081208254909190600160281b900463ffffffff166109cd5762093a806109dd565b8254600160281b900463ffffffff165b8254909150610a019063ffffffff8316906301000000900464ffffffffff166122c7565b64ffffffffff16421115610a285760405163027123cd60e41b815260040160405180910390fd5b336001600160a01b03861614801590610a435750815460ff16155b15610a615760405163541250f760e01b815260040160405180910390fd5b610a6d86868585611a1c565b60016002559695505050505050565b610a91335f356001600160e01b0319166117fd565b610aad5760405162461bcd60e51b81526004016106a490612269565b6001600160a01b0385165f9081526004602052604090206107d061ffff84161115610aeb576040516332e4bb9360e11b815260040160405180910390fd5b61138861ffff83161115610b1257604051636e3d72c360e11b815260040160405180910390fd5b805460ff1615610b3557604051632e2f525d60e11b815260040160405180910390fd5b805461ffff838116600160d81b810261ffff60d81b19928716600160c81b810261ffff60c81b1963ffffffff8b8116600160281b02919091167affff00000000000000000000000000000000ffffffff000000000019918d16610100810264ffffffffff199099169890981760011791909116171793909316178455604080519384526020840192909252908201526001600160a01b038716907f2d9461084dada7ec1631fe3cdd1fa3827bd388fb673649af550f08e8d799e0359060600160405180910390a2505050505050565b610c19335f356001600160e01b0319166117fd565b610c355760405162461bcd60e51b81526004016106a490612269565b335f8181526005602090815260408083206001600160a01b03871680855290835292819020805460ff191686151590811790915590519081529192917f21620b27ba9eeb9c0fe4b328d9038784b90664af3e7f54617d2d3b14cd97c34e910160405180910390a35050565b610cb5335f356001600160e01b0319166117fd565b610cd15760405162461bcd60e51b81526004016106a490612269565b6001600160a01b0381165f908152600460205260409020805460ff16610d0a57604051631174ace960e11b815260040160405180910390fd5b805460ff191681556040516001600160a01b038316907fb03b41043f453253837c2a473842b2d0f3025250ef63df22a7ba259b7b47495f905f90a25050565b5f546001600160a01b0316331480610dda575060015460405163b700961360e01b81526001600160a01b039091169063b700961390610d9b90339030906001600160e01b03195f3516906004016122e5565b602060405180830381865afa158015610db6573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610dda9190612312565b610de2575f80fd5b600180546001600160a01b0319166001600160a01b03831690811790915560405133907fa3396fd7f6e0a21b50e5089d2da70d5ac0a3bbbd1f617a93f134b76389980198905f90a350565b5f610e43335f356001600160e01b0319166117fd565b610e5f5760405162461bcd60e51b81526004016106a490612269565b6001600160a01b038084165f81815260046020908152604080832094871683526005825280832093835292905220610e9985858484611a1c565b95945050505050565b610eb7335f356001600160e01b0319166117fd565b610ed35760405162461bcd60e51b81526004016106a490612269565b6003805460ff60a01b1916600160a01b1790556040517f9e87fac88ff661f02d44f95383c817fece4bce600a3dab7a54406878b965e752905f90a1565b610f25335f356001600160e01b0319166117fd565b610f415760405162461bcd60e51b81526004016106a490612269565b6001600160a01b038116610f6857604051631e74ce7160e31b815260040160405180910390fd5b600380546001600160a01b0319166001600160a01b0383169081179091556040519081527f679f4cc040076580bf118e3f2307b72842331922e8054b8cc292bb37f05e5b03906020015b60405180910390a150565b60608167ffffffffffffffff811115610fd857610fd861232d565b604051908082528060200260200182016040528015611001578160200160208202803683370190505b5090505f5b828110156110675761103884848381811061102357611023612341565b9050602002016020810190610208919061202f565b82828151811061104a5761104a612341565b60209081029190910101528061105f81612355565b915050611006565b5092915050565b611083335f356001600160e01b0319166117fd565b61109f5760405162461bcd60e51b81526004016106a490612269565b60038054821515600160a81b0260ff60a81b199091161790556040517f9bd1a4bfe91dd4368b87973b0759c3649648cf04d60c8de148d719c9d229332690610fb290831515815260200190565b611101335f356001600160e01b0319166117fd565b61111d5760405162461bcd60e51b81526004016106a490612269565b6001600160a01b0382165f908152600460205260409020805460ff1661115657604051631174ace960e11b815260040160405180910390fd5b61138861ffff8316111561117d57604051636e3d72c360e11b815260040160405180910390fd5b805461ffff60d81b1916600160d81b61ffff84169081029190911782556040519081526001600160a01b038416907fb6a1832c57da203cbc5d77b31512e2f9c661069e85fd0f9dec6f0c8b9ce24ef890602001610761565b6111ea335f356001600160e01b0319166117fd565b6112065760405162461bcd60e51b81526004016106a490612269565b6002546001146112285760405162461bcd60e51b81526004016106a49061228f565b60028055600354600160a01b900460ff161561125757604051632ebdcdd760e21b815260040160405180910390fd5b6001600160a01b0384165f908152600460205260409020805460ff1661129057604051631174ace960e11b815260040160405180910390fd5b61138861ffff841611156112b757604051636e3d72c360e11b815260040160405180910390fd5b6112f56001600160a01b037f00000000000000000000000086b5780b606940eb59a062aa85a07959518c01611633306001600160601b038816611ed6565b80546001600160601b038516908290600990611322908490600160481b90046001600160801b031661236d565b82546001600160801b039182166101009390930a928302919092021990911617905550335f9081526005602090815260408083206001600160a01b0389168452909152902080548590829060089061138c9084906001600160601b03600160401b9091041661238d565b82546001600160601b0391821661010093840a908102920219161790915583545f92506113c19163ffffffff910416426123ad565b825467ffffffffff0000001916630100000064ffffffffff831602178355604051634104b9ed60e11b81526001600160a01b0389811660048301529192507f00000000000000000000000005a1552c5e18f5a0bb9571b5f2d6a4765ebda32b9091169063820973da90602401602060405180830381865afa158015611448573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061146c9190612252565b825473ffffffffffffffffffffffffffffffffff0000ff16600160a01b6001600160601b039283160262ffff0019161761010061ffff8816021760ff191685151517835560408051918816825264ffffffffff831660208301526001600160a01b0389169133917f7c7bb9f0b469c21da4666496577565b8e0f6a5da9834e8d15b12603b260ca6c6910160405180910390a3505060016002555050505050565b611521335f356001600160e01b0319166117fd565b61153d5760405162461bcd60e51b81526004016106a490612269565b6001600160a01b0382165f908152600460205260409020805460ff1661157657604051631174ace960e11b815260040160405180910390fd5b805468ffffffff00000000001916600160281b63ffffffff84169081029190911782556040519081526001600160a01b038416907f01020e4692686f9ef8b89baf5b96d4af4713bdaaf269706540e1e894d959310990602001610761565b6115e9335f356001600160e01b0319166117fd565b6116055760405162461bcd60e51b81526004016106a490612269565b6001600160a01b0382165f908152600460205260409020805460ff1661163e57604051631174ace960e11b815260040160405180910390fd5b805464ffffffff00191661010063ffffffff84169081029190911782556040519081526001600160a01b038416907ff460eccc96794cc59e91dc95757a6579291d9b251377740e28b39b482290052a90602001610761565b6116ab335f356001600160e01b0319166117fd565b6116c75760405162461bcd60e51b81526004016106a490612269565b6002546001146116e95760405162461bcd60e51b81526004016106a49061228f565b600280556116f781336118a5565b506001600255565b611714335f356001600160e01b0319166117fd565b6117305760405162461bcd60e51b81526004016106a490612269565b5f80546001600160a01b0319166001600160a01b0383169081178255604051909133917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a350565b5f60405163a9059cbb60e01b81526001600160a01b038416600482015282602482015260205f6044835f895af13d15601f3d1160015f5114161716915050806117f75760405162461bcd60e51b815260206004820152600f60248201526e1514905394d1915497d19052531151608a1b60448201526064016106a4565b50505050565b6001545f906001600160a01b03168015801590611884575060405163b700961360e01b81526001600160a01b0382169063b700961390611845908790309088906004016122e5565b602060405180830381865afa158015611860573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906118849190612312565b8061189b57505f546001600160a01b038581169116145b9150505b92915050565b6001600160a01b038281165f81815260046020908152604080832094861683526005825280832093835292905290812080549091600160401b9091046001600160601b03169081900361190b576040516339333c7d60e21b815260040160405180910390fd5b82546001600160601b038216908490600990611938908490600160481b90046001600160801b03166123c0565b82546001600160801b039182166101009390930a92830291909202199091161790555081546bffffffffffffffffffffffff60401b191682556119ae6001600160a01b037f00000000000000000000000086b5780b606940eb59a062aa85a07959518c016116856001600160601b03841661177a565b6040516001600160601b03821681526001600160a01b0380871691908616907fcb0f3204f6895f1e698cfa5f0cceed9d5e62b57fe0d8648a47fc3685a78e7e979060200160405180910390a35050505050565b5f825f190484118302158202611a15575f80fd5b5091020490565b81545f9060ff16611a4057604051631174ace960e11b815260040160405180910390fd5b81546301000000900464ffffffffff16421015611a70576040516314ea2dc560e21b815260040160405180910390fd5b8154600160401b90046001600160601b03165f03611aa1576040516339333c7d60e21b815260040160405180910390fd5b604051634104b9ed60e11b81526001600160a01b0386811660048301525f917f00000000000000000000000005a1552c5e18f5a0bb9571b5f2d6a4765ebda32b9091169063820973da90602401602060405180830381865afa158015611b09573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611b2d9190612252565b83549091505f90600160a01b90046001600160601b03168211611b505781611b63565b8354600160a01b90046001600160601b03165b84549091505f90600160a01b90046001600160601b03168311611b97578454600160a01b90046001600160601b0316611b99565b825b85549091505f90610100900461ffff16611bbf578654600160d81b900461ffff16611bcb565b8554610100900461ffff165b905081611beb611bdd836127106123e0565b859061ffff16612710611a01565b1015611c0a57604051634f48837160e01b815260040160405180910390fd5b85548754600160401b9091046001600160601b03169081908990600990611c42908490600160481b90046001600160801b03166123c0565b82546001600160801b039182166101009390930a928302919092021990911617905550875461ffff600160c81b9091041615611ce05787545f90611c95908390600160c81b900461ffff16612710611a01565b9050611ca181836123fb565b600354909250611cde906001600160a01b037f00000000000000000000000086b5780b606940eb59a062aa85a07959518c0161811691168361177a565b505b611d0b81857f0000000000000000000000000000000000000000000000000de0b6b3a7640000611a01565b87546bffffffffffffffffffffffff60401b19168855600354909650600160a81b900460ff1615611dcd576040516318457e6160e01b81526001600160a01b038a811660048301528b8116602483015260448201889052306064830152608482018390527f00000000000000000000000086b5780b606940eb59a062aa85a07959518c016116906318457e619060a4015f604051808303815f87803b158015611db2575f80fd5b505af1158015611dc4573d5f803e3d5ffd5b50505050611e73565b6040516318457e6160e01b81526001600160a01b038a811660048301528b811660248301525f6044830152306064830152608482018390527f00000000000000000000000086b5780b606940eb59a062aa85a07959518c016116906318457e619060a4015f604051808303815f87803b158015611e48575f80fd5b505af1158015611e5a573d5f803e3d5ffd5b50611e73925050506001600160a01b038b168a8861177a565b896001600160a01b0316896001600160a01b03167fbf9c520fb583da9b8f434d2dfa27f8695602f498c937081299893335144e99a28389604051611ec1929190918252602082015260400190565b60405180910390a35050505050949350505050565b5f6040516323b872dd60e01b81526001600160a01b03851660048201526001600160a01b038416602482015282604482015260205f6064835f8a5af13d15601f3d1160015f511416171691505080611f675760405162461bcd60e51b81526020600482015260146024820152731514905394d1915497d19493d357d1905253115160621b60448201526064016106a4565b5050505050565b6001600160a01b0381168114611f82575f80fd5b50565b5f8060408385031215611f96575f80fd5b8235611fa181611f6e565b946020939093013593505050565b803561ffff81168114611fc0575f80fd5b919050565b5f8060408385031215611fd6575f80fd5b8235611fe181611f6e565b9150611fef60208401611faf565b90509250929050565b5f8060408385031215612009575f80fd5b823561201481611f6e565b9150602083013561202481611f6e565b809150509250929050565b5f6020828403121561203f575f80fd5b813561088c81611f6e565b803563ffffffff81168114611fc0575f80fd5b5f805f805f60a08688031215612071575f80fd5b853561207c81611f6e565b945061208a6020870161204a565b93506120986040870161204a565b92506120a660608701611faf565b91506120b460808701611faf565b90509295509295909350565b8015158114611f82575f80fd5b5f80604083850312156120de575f80fd5b82356120e981611f6e565b91506020830135612024816120c0565b5f806020838503121561210a575f80fd5b823567ffffffffffffffff80821115612121575f80fd5b818501915085601f830112612134575f80fd5b813581811115612142575f80fd5b8660208260051b8501011115612156575f80fd5b60209290920196919550909350505050565b602080825282518282018190525f9190848201906040850190845b8181101561219f57835183529284019291840191600101612183565b50909695505050505050565b5f602082840312156121bb575f80fd5b813561088c816120c0565b5f805f80608085870312156121d9575f80fd5b84356121e481611f6e565b935060208501356001600160601b03811681146121ff575f80fd5b925061220d60408601611faf565b9150606085013561221d816120c0565b939692955090935050565b5f8060408385031215612239575f80fd5b823561224481611f6e565b9150611fef6020840161204a565b5f60208284031215612262575f80fd5b5051919050565b6020808252600c908201526b15539055551213d49256915160a21b604082015260600190565b6020808252600a90820152695245454e5452414e435960b01b604082015260600190565b634e487b7160e01b5f52601160045260245ffd5b64ffffffffff818116838216019080821115611067576110676122b3565b6001600160a01b0393841681529190921660208201526001600160e01b0319909116604082015260600190565b5f60208284031215612322575f80fd5b815161088c816120c0565b634e487b7160e01b5f52604160045260245ffd5b634e487b7160e01b5f52603260045260245ffd5b5f60018201612366576123666122b3565b5060010190565b6001600160801b03818116838216019080821115611067576110676122b3565b6001600160601b03818116838216019080821115611067576110676122b3565b8082018082111561189f5761189f6122b3565b6001600160801b03828116828216039080821115611067576110676122b3565b61ffff818116838216019080821115611067576110676122b3565b8181038181111561189f5761189f6122b356fea26469706673582212205e3cd6918ebc483da71b611ae90d3565bfcb8f8e190f0be9cb175e2d6c043d2564736f6c63430008150033
Loading...
Loading
Loading...
Loading
Net Worth in USD
$0.00
Net Worth in ETH
0
Multichain Portfolio | 33 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.