More Info
Private Name Tags
ContractCreator
TokenTracker
Latest 25 from a total of 118 transactions
| Transaction Hash |
|
Block
|
From
|
To
|
|||||
|---|---|---|---|---|---|---|---|---|---|
| Claim Rewards | 43807160 | 24 days ago | IN | 0 ETH | 0.00000051 | ||||
| Claim Rewards | 43545281 | 30 days ago | IN | 0 ETH | 0.00000052 | ||||
| Claim Rewards | 43415399 | 33 days ago | IN | 0 ETH | 0.00000051 | ||||
| Claim Rewards | 43201633 | 38 days ago | IN | 0 ETH | 0.0000005 | ||||
| Claim Rewards | 42857813 | 46 days ago | IN | 0 ETH | 0.0000005 | ||||
| Claim Rewards | 42684170 | 50 days ago | IN | 0 ETH | 0.00000083 | ||||
| Claim Rewards | 42513661 | 54 days ago | IN | 0 ETH | 0.0000005 | ||||
| Claim Rewards | 42334104 | 58 days ago | IN | 0 ETH | 0.00000186 | ||||
| Claim Rewards | 42167097 | 62 days ago | IN | 0 ETH | 0.0000003 | ||||
| Claim Rewards | 42018614 | 65 days ago | IN | 0 ETH | 0.00000143 | ||||
| Claim Rewards | 41989623 | 66 days ago | IN | 0 ETH | 0.00000037 | ||||
| Claim Rewards | 41819122 | 70 days ago | IN | 0 ETH | 0.00000037 | ||||
| Claim Rewards | 41654963 | 73 days ago | IN | 0 ETH | 0.0000005 | ||||
| Claim Rewards | 41511461 | 77 days ago | IN | 0 ETH | 0.00000053 | ||||
| Claim Rewards | 41429158 | 79 days ago | IN | 0 ETH | 0.00000056 | ||||
| Claim Rewards | 41301875 | 82 days ago | IN | 0 ETH | 0.00000095 | ||||
| Claim Rewards | 41125731 | 86 days ago | IN | 0 ETH | 0.00000036 | ||||
| Claim Rewards | 40950441 | 90 days ago | IN | 0 ETH | 0.00000026 | ||||
| Claim Rewards | 40780614 | 94 days ago | IN | 0 ETH | 0.00000058 | ||||
| Claim Rewards | 40601312 | 98 days ago | IN | 0 ETH | 0.00000035 | ||||
| Claim Rewards | 40419108 | 102 days ago | IN | 0 ETH | 0.00000057 | ||||
| Claim Rewards | 40124917 | 109 days ago | IN | 0 ETH | 0.00000007 | ||||
| Claim Rewards | 40007970 | 112 days ago | IN | 0 ETH | 0.00000004 | ||||
| Claim Rewards | 39964438 | 113 days ago | IN | 0 ETH | 0.00000005 | ||||
| Claim Rewards | 39680828 | 119 days ago | IN | 0 ETH | 0.00000009 |
Latest 25 internal transactions (View All)
| Parent Transaction Hash | Block | From | To | |||
|---|---|---|---|---|---|---|
| 37007249 | 181 days ago | 0.02115525 ETH | ||||
| 37007249 | 181 days ago | 0.02115525 ETH | ||||
| 36920017 | 183 days ago | 0.02683837 ETH | ||||
| 36920017 | 183 days ago | 0.02683837 ETH | ||||
| 36833470 | 185 days ago | 0.027566 ETH | ||||
| 36833470 | 185 days ago | 0.027566 ETH | ||||
| 36746858 | 187 days ago | 0.03338812 ETH | ||||
| 36746858 | 187 days ago | 0.03338812 ETH | ||||
| 36660160 | 189 days ago | 0.02586751 ETH | ||||
| 36660160 | 189 days ago | 0.02586751 ETH | ||||
| 36573495 | 191 days ago | 0.06778343 ETH | ||||
| 36573495 | 191 days ago | 0.06778343 ETH | ||||
| 36400384 | 195 days ago | 0.03684853 ETH | ||||
| 36400384 | 195 days ago | 0.03684853 ETH | ||||
| 36313974 | 197 days ago | 0.04244063 ETH | ||||
| 36313974 | 197 days ago | 0.04244063 ETH | ||||
| 36226565 | 199 days ago | 0.06962947 ETH | ||||
| 36226565 | 199 days ago | 0.06962947 ETH | ||||
| 36139684 | 201 days ago | 0.03781376 ETH | ||||
| 36139684 | 201 days ago | 0.03781376 ETH | ||||
| 36053265 | 203 days ago | 0.02522731 ETH | ||||
| 36053265 | 203 days ago | 0.02522731 ETH | ||||
| 35965761 | 205 days ago | 0.04843743 ETH | ||||
| 35965761 | 205 days ago | 0.04843743 ETH | ||||
| 35879278 | 207 days ago | 0.16150615 ETH |
Cross-Chain Transactions
Loading...
Loading
Contract Name:
FluidLenderBase
Compiler Version
v0.8.28+commit.7893614a
Optimization Enabled:
Yes with 200 runs
Other Settings:
cancun EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: AGPL-3.0
pragma solidity 0.8.28;
import {Base4626Compounder, ERC20, SafeERC20} from "@periphery/Bases/4626Compounder/Base4626Compounder.sol";
import {Auction} from "@periphery/Auctions/Auction.sol";
import {ISwapRouter} from "@slipstream/periphery/interfaces/ISwapRouter.sol";
import {IWETH} from "src/interfaces/IWETH.sol";
import {IMerkleRewards} from "src/interfaces/FluidInterfaces.sol";
import {IFluidDex} from "src/interfaces/FluidInterfaces.sol";
contract FluidLenderBase is Base4626Compounder {
using SafeERC20 for ERC20;
/// @notice Address for our reward token auction
address public auction;
/// @notice Whether to sell rewards using auction or Uniswap V3
bool public useAuction;
/// @notice True if strategy deposits are open to any address
bool public openDeposits;
/// @notice Tick spacing for WETH to USDC swaps on Slipstream
int24 public wethToUsdcSwapTickSpacing;
/// @notice Tick spacing for USDC to asset swaps on Slipstream
int24 public usdcToAssetSwapTickSpacing;
/// @notice Set this so we don't try and sell dust
uint256 public minAmountToSell;
/// @notice Mapping of addresses and whether they are allowed to deposit to this strategy
mapping(address => bool) public allowed;
/// @notice Address for Fluid's FLUID-WETH DEX pair
IFluidDex public constant FLUID_DEX =
IFluidDex(0xdE632C3a214D5f14C1d8ddF0b92F8BCd188fee45);
/// @notice Aerodrome's Slipstream (aka UniV3/CL) router
ISwapRouter public constant SLIPSTREAM_ROUTER =
ISwapRouter(0xBE6D8f0d05cC4be24d5167a3eF062215bE6D18a5);
/// @notice Address for Fluid's merkle claim
/// @dev This is the same on Base and Arbitrum
IMerkleRewards public merkleClaim =
IMerkleRewards(0x94312a608246Cecfce6811Db84B3Ef4B2619054E);
/// @notice FLUID token address
/// @dev This is the same on Base and Arbitrum
ERC20 public constant FLUID =
ERC20(0x61E030A56D33e8260FdD81f03B162A79Fe3449Cd);
/// @notice WETH token address
ERC20 public constant WETH =
ERC20(0x4200000000000000000000000000000000000006);
/// @notice USDC token address
ERC20 public constant USDC =
ERC20(0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913);
/// @notice Dust threshold used to prevent tiny deposits
uint256 public constant DUST = 1_000;
/**
* @param _asset Underlying asset to use for this strategy.
* @param _name Name to use for this strategy.
* @param _vault ERC4626 vault token to use.
*/
constructor(
address _asset,
string memory _name,
address _vault
) Base4626Compounder(_asset, _name, _vault) {
FLUID.forceApprove(address(FLUID_DEX), type(uint256).max);
// default to 100 tick spacing for WETH-USDC
if (address(asset) != address(WETH)) {
WETH.forceApprove(address(SLIPSTREAM_ROUTER), type(uint256).max);
wethToUsdcSwapTickSpacing = 100;
}
// default to 50 tick spacing for USDC-EURC
if (address(asset) != address(USDC)) {
USDC.forceApprove(address(SLIPSTREAM_ROUTER), type(uint256).max);
usdcToAssetSwapTickSpacing = 50;
}
minAmountToSell = 100e18; // 100 FLUID = 600 USD
}
/* ========== VIEW FUNCTIONS ========== */
function balanceOfRewards() public view returns (uint256) {
return FLUID.balanceOf(address(this));
}
function availableDepositLimit(
address _receiver
) public view override returns (uint256) {
if (openDeposits || allowed[_receiver]) {
// Return the max amount the vault will allow for deposits.
return vault.maxDeposit(address(this));
} else {
return 0;
}
}
/* ========== MUTATIVE FUNCTIONS ========== */
/// @notice Manually sell any accumulated rewards above minAmountToSell.
function manualRewardSell() external onlyKeepers {
_claimAndSellRewards();
}
/**
* @notice Claim rewards from the merkle distributor
* @dev All values should be pulled from Fluid's API.
* @param _recipient Recipient of rewards, must be msg.sender.
* @param _cumulativeAmount Total amount of rewards to claim.
* @param _positionType Type that our Fluid position is (lending, vault, etc).
* @param _positionId ID of our strategy's position.
* @param _cycle Current rewards cycle.
* @param _merkleProof Merkle proof data.
* @param _metadata Any extra metadata for the claim. Must match exactly from API.
*/
function claimRewards(
address _recipient,
uint256 _cumulativeAmount,
uint8 _positionType,
bytes32 _positionId,
uint256 _cycle,
bytes32[] calldata _merkleProof,
bytes memory _metadata
) external {
merkleClaim.claim(
_recipient,
_cumulativeAmount,
_positionType,
_positionId,
_cycle,
_merkleProof,
_metadata
);
}
function _claimAndSellRewards() internal override {
// use Fluid DEX and Aerodrome to sell FLUID to underlying
uint256 balance = balanceOfRewards();
if (balance > minAmountToSell && !useAuction) {
_sellFluidToWeth(balance);
if (address(asset) != address(WETH)) {
_sellWethToAsset();
}
}
balance = balanceOfAsset();
if (!TokenizedStrategy.isShutdown()) {
// no need to waste gas on depositing dust
if (balance > DUST) {
_deployFunds(balance);
}
}
}
function _sellFluidToWeth(uint256 _fluidToSell) internal {
FLUID_DEX.swapIn(true, _fluidToSell, 0, address(this));
}
function _sellWethToAsset() internal {
uint256 wethBalance = WETH.balanceOf(address(this));
if (wethBalance > DUST) {
SLIPSTREAM_ROUTER.exactInputSingle(
getSwapRouterInput(address(WETH), wethBalance)
);
}
if (address(asset) == address(USDC) || usdcToAssetSwapTickSpacing == 0)
return;
uint256 usdcBalance = USDC.balanceOf(address(this));
if (usdcBalance > DUST) {
SLIPSTREAM_ROUTER.exactInputSingle(
getSwapRouterInput(address(USDC), usdcBalance)
);
}
}
/**
* @notice Handles native ETH received by the contract and automatically wraps to WETH
* @dev Fluid's DEX returns ETH, not WETH
*/
receive() external payable {
if (address(this).balance != 0) {
IWETH(address(WETH)).deposit{value: address(this).balance}();
}
}
/**
* @notice Kick an auction for a given token.
* @param _token The token that is being sold.
*/
function kickAuction(
address _token
) external onlyKeepers returns (uint256) {
return _kickAuction(_token);
}
function _kickAuction(address _from) internal virtual returns (uint256) {
require(
_from != address(asset) && _from != address(vault),
"cannot kick"
);
uint256 _balance = ERC20(_from).balanceOf(address(this));
ERC20(_from).safeTransfer(auction, _balance);
return Auction(auction).kick(_from);
}
/**
* @notice Creates swap parameters for Slipstream router
* @param _tokenIn Address of input token (WETH or USDC)
* @param _amountIn Amount of input tokens to swap
* @return Swap parameters struct for Slipstream router
*/
function getSwapRouterInput(
address _tokenIn,
uint256 _amountIn
) internal view returns (ISwapRouter.ExactInputSingleParams memory) {
return
ISwapRouter.ExactInputSingleParams({
tokenIn: _tokenIn,
tokenOut: _tokenIn == address(WETH)
? address(USDC)
: address(asset),
tickSpacing: _tokenIn == address(WETH)
? wethToUsdcSwapTickSpacing
: usdcToAssetSwapTickSpacing,
recipient: address(this),
deadline: block.timestamp,
amountIn: _amountIn,
amountOutMinimum: 0,
sqrtPriceLimitX96: 0
});
}
/* ========== SETTERS ========== */
/**
* @notice Set the minimum amount of rewardsToken to sell.
* @dev Can only be called by management.
* @param _minAmountToSell minimum amount to sell in wei.
*/
function setMinAmountToSell(
uint256 _minAmountToSell
) external onlyManagement {
minAmountToSell = _minAmountToSell;
}
/**
* @notice Use to update our auction address.
* @dev Can only be called by management.
* @param _auction Address of new auction.
*/
function setAuction(address _auction) external onlyManagement {
if (_auction != address(0)) {
require(
Auction(_auction).want() == address(asset) ||
Auction(_auction).want() == address(vault),
"wrong want"
);
require(
Auction(_auction).receiver() == address(this),
"wrong receiver"
);
}
auction = _auction;
}
/**
* @notice Set whether to use auction or UniV3 for rewards selling.
* @dev Can only be called by management.
* @param _useAuction Use auction to sell rewards (true) or UniV3 (false).
*/
function setUseAuction(bool _useAuction) external onlyManagement {
if (_useAuction) require(auction != address(0), "!auction");
useAuction = _useAuction;
}
/// @notice Sets tick spacing for WETH -> USDC swap
/// @param _wethToUsdcSwapTickSpacing Tick spacing
/// @dev Only callable by management
function setWethToUsdcSwapTickSpacing(
int24 _wethToUsdcSwapTickSpacing
) external onlyManagement {
wethToUsdcSwapTickSpacing = _wethToUsdcSwapTickSpacing;
}
/// @notice Sets tick spacing for USDC -> Asset swap
/// @param _usdcToAssetSwapTickSpacing Tick spacing
/// @dev Only callable by management
function setUsdcToAssetSwapTickSpacing(
int24 _usdcToAssetSwapTickSpacing
) external onlyManagement {
usdcToAssetSwapTickSpacing = _usdcToAssetSwapTickSpacing;
}
/**
* @notice Set the address for our merkle claim if it changes.
* @dev Can only be called by management.
* @param _merkleClaim Address of the merkle claim contract to use.
*/
function setMerkleClaim(address _merkleClaim) external onlyManagement {
require(_merkleClaim != address(0), "!zero");
merkleClaim = IMerkleRewards(_merkleClaim);
}
/**
* @notice Set whether deposits are open to anyone or restricted to our allowed mapping.
* @dev Can only be called by management.
* @param _openDeposits Allow deposits from anyone (true) or use mapping (false).
*/
function setOpenDeposits(bool _openDeposits) external onlyManagement {
openDeposits = _openDeposits;
}
/**
* @notice Set whether an address can deposit to the strategy or not.
* @dev Can only be called by management.
* @param _depositor Address to set mapping for.
* @param _allowed Whether the address is allowed to deposit to the strategy.
*/
function setAllowed(
address _depositor,
bool _allowed
) external onlyManagement {
allowed[_depositor] = _allowed;
}
}// SPDX-License-Identifier: AGPL-3.0
pragma solidity >=0.8.18;
// We use the Tokenized Strategy interface.
import {IStrategy} from "@tokenized-strategy/interfaces/IStrategy.sol";
import {BaseHealthCheck, ERC20} from "../HealthCheck/BaseHealthCheck.sol";
import {Math} from "@openzeppelin/contracts/utils/math/Math.sol";
import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
/**
* @title Base4626Compounder
* @dev Can be used to make a simple strategy that compounds
* rewards for any 4626 vault.
*/
contract Base4626Compounder is BaseHealthCheck {
using SafeERC20 for ERC20;
IStrategy public immutable vault;
constructor(
address _asset,
string memory _name,
address _vault
) BaseHealthCheck(_asset, _name) {
require(IStrategy(_vault).asset() == _asset, "wrong vault");
vault = IStrategy(_vault);
asset.forceApprove(_vault, type(uint256).max);
}
/*//////////////////////////////////////////////////////////////
NEEDED TO BE OVERRIDDEN BY STRATEGIST
//////////////////////////////////////////////////////////////*/
/**
* @dev Should deploy up to '_amount' of 'asset' in the yield source.
*
* This function is called at the end of a {deposit} or {mint}
* call. Meaning that unless a whitelist is implemented it will
* be entirely permissionless and thus can be sandwiched or otherwise
* manipulated.
*
* @param _amount The amount of 'asset' that the strategy should attempt
* to deposit in the yield source.
*/
function _deployFunds(uint256 _amount) internal virtual override {
vault.deposit(_amount, address(this));
_stake();
}
/**
* @dev Will attempt to free the '_amount' of 'asset'.
*
* The amount of 'asset' that is already loose has already
* been accounted for.
*
* This function is called during {withdraw} and {redeem} calls.
* Meaning that unless a whitelist is implemented it will be
* entirely permissionless and thus can be sandwiched or otherwise
* manipulated.
*
* Should not rely on asset.balanceOf(address(this)) calls other than
* for diff accounting purposes.
*
* Any difference between `_amount` and what is actually freed will be
* counted as a loss and passed on to the withdrawer. This means
* care should be taken in times of illiquidity. It may be better to revert
* if withdraws are simply illiquid so not to realize incorrect losses.
*
* @param _amount, The amount of 'asset' to be freed.
*/
function _freeFunds(uint256 _amount) internal virtual override {
// Use previewWithdraw to round up.
uint256 shares = vault.previewWithdraw(_amount);
uint256 vaultBalance = balanceOfVault();
if (shares > vaultBalance) {
unchecked {
_unStake(shares - vaultBalance);
}
shares = Math.min(shares, balanceOfVault());
}
vault.redeem(shares, address(this), address(this));
}
/**
* @dev Internal function to harvest all rewards, redeploy any idle
* funds and return an accurate accounting of all funds currently
* held by the Strategy.
*
* This should do any needed harvesting, rewards selling, accrual,
* redepositing etc. to get the most accurate view of current assets.
*
* NOTE: All applicable assets including loose assets should be
* accounted for in this function.
*
* Care should be taken when relying on oracles or swap values rather
* than actual amounts as all Strategy profit/loss accounting will
* be done based on this returned value.
*
* This can still be called post a shutdown, a strategist can check
* `TokenizedStrategy.isShutdown()` to decide if funds should be
* redeployed or simply realize any profits/losses.
*
* @return _totalAssets A trusted and accurate account for the total
* amount of 'asset' the strategy currently holds including idle funds.
*/
function _harvestAndReport()
internal
virtual
override
returns (uint256 _totalAssets)
{
// Claim and sell any rewards.
_claimAndSellRewards();
// Return total balance
_totalAssets = balanceOfAsset() + valueOfVault();
}
/**
* @dev Override to stake loose vault tokens after they
* are deposited to the `vault`.
*/
function _stake() internal virtual {}
/**
* @dev If vault tokens are staked, override to unstake them before
* any withdraw or redeems.
* @param _amount The amount of vault tokens to unstake.
*/
function _unStake(uint256 _amount) internal virtual {}
/**
* @dev Called during reports to do any harvesting of rewards needed.
*/
function _claimAndSellRewards() internal virtual {}
/**
* @notice Return the current loose balance of this strategies `asset`.
*/
function balanceOfAsset() public view virtual returns (uint256) {
return asset.balanceOf(address(this));
}
/**
* @notice Return the current balance of the strategies vault shares.
*/
function balanceOfVault() public view virtual returns (uint256) {
return vault.balanceOf(address(this));
}
/**
* @notice If the vaults tokens are staked. To override and return the
* amount of vault tokens the strategy has staked.
*/
function balanceOfStake() public view virtual returns (uint256) {}
/**
* @notice The full value denominated in `asset` of the strategies vault
* tokens held both in the contract and staked.
*/
function valueOfVault() public view virtual returns (uint256) {
return vault.convertToAssets(balanceOfVault() + balanceOfStake());
}
/**
* @notice The max amount of `asset` than can be redeemed from the vault.
* @dev If the vault tokens are staked this needs to include the
* vault.maxRedeem(stakingContract) to be accurate.
*
* NOTE: This should use vault.convertToAssets(vault.maxRedeem(address));
* rather than vault.maxWithdraw(address);
*/
function vaultsMaxWithdraw() public view virtual returns (uint256) {
return vault.convertToAssets(vault.maxRedeem(address(this)));
}
/**
* @notice Gets the max amount of `asset` that an address can deposit.
* @dev Defaults to an unlimited amount for any address. But can
* be overridden by strategists.
*
* This function will be called before any deposit or mints to enforce
* any limits desired by the strategist. This can be used for either a
* traditional deposit limit or for implementing a whitelist etc.
*
* EX:
* if(isAllowed[_owner]) return super.availableDepositLimit(_owner);
*
* This does not need to take into account any conversion rates
* from shares to assets. But should know that any non max uint256
* amounts may be converted to shares. So it is recommended to keep
* custom amounts low enough as not to cause overflow when multiplied
* by `totalSupply`.
*
* @param . The address that is depositing into the strategy.
* @return . The available amount the `_owner` can deposit in terms of `asset`
*/
function availableDepositLimit(
address
) public view virtual override returns (uint256) {
// Return the max amount the vault will allow for deposits.
return vault.maxDeposit(address(this));
}
/**
* @notice Gets the max amount of `asset` that can be withdrawn.
* @dev Defaults to an unlimited amount for any address. But can
* be overridden by strategists.
*
* This function will be called before any withdraw or redeem to enforce
* any limits desired by the strategist. This can be used for illiquid
* or sandwichable strategies. It should never be lower than `totalIdle`.
*
* EX:
* return TokenIzedStrategy.totalIdle();
*
* This does not need to take into account the `_owner`'s share balance
* or conversion rates from shares to assets.
*
* @param . The address that is withdrawing from the strategy.
* @return . The available amount that can be withdrawn in terms of `asset`
*/
function availableWithdrawLimit(
address
) public view virtual override returns (uint256) {
// Return the loose balance of asset and the max we can withdraw from the vault
return balanceOfAsset() + vaultsMaxWithdraw();
}
/**
* @dev Optional function for a strategist to override that will
* allow management to manually withdraw deployed funds from the
* yield source if a strategy is shutdown.
*
* This should attempt to free `_amount`, noting that `_amount` may
* be more than is currently deployed.
*
* NOTE: This will not realize any profits or losses. A separate
* {report} will be needed in order to record any profit/loss. If
* a report may need to be called after a shutdown it is important
* to check if the strategy is shutdown during {_harvestAndReport}
* so that it does not simply re-deploy all funds that had been freed.
*
* EX:
* if(freeAsset > 0 && !TokenizedStrategy.isShutdown()) {
* depositFunds...
* }
*
* @param _amount The amount of asset to attempt to free.
*/
function _emergencyWithdraw(uint256 _amount) internal virtual override {
_freeFunds(Math.min(_amount, vaultsMaxWithdraw()));
}
}// SPDX-License-Identifier: AGPL-3.0
pragma solidity >=0.8.18;
import {Maths} from "../libraries/Maths.sol";
import {ITaker} from "../interfaces/ITaker.sol";
import {GPv2Order} from "../libraries/GPv2Order.sol";
import {Governance2Step} from "../utils/Governance2Step.sol";
import {ERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import {ReentrancyGuard} from "@openzeppelin/contracts/security/ReentrancyGuard.sol";
interface ICowSettlement {
function domainSeparator() external view returns (bytes32);
}
/**
* @title Auction
* @author yearn.fi
* @notice General use dutch auction contract for token sales.
*/
contract Auction is Governance2Step, ReentrancyGuard {
using GPv2Order for GPv2Order.Data;
using SafeERC20 for ERC20;
/// @notice Emitted when a new auction is enabled
event AuctionEnabled(address indexed from, address indexed to);
/// @notice Emitted when an auction is disabled.
event AuctionDisabled(address indexed from, address indexed to);
/// @notice Emitted when auction has been kicked.
event AuctionKicked(address indexed from, uint256 available);
/// @notice Emitted when the starting price is updated.
event UpdatedStartingPrice(uint256 startingPrice);
/// @dev Store address and scaler in one slot.
struct TokenInfo {
address tokenAddress;
uint96 scaler;
}
/// @notice Store all the auction specific information.
struct AuctionInfo {
uint64 kicked;
uint64 scaler;
uint128 initialAvailable;
}
uint256 internal constant WAD = 1e18;
/// @notice Used for the price decay.
uint256 internal constant MINUTE_HALF_LIFE =
0.988514020352896135_356867505 * 1e27; // 0.5^(1/60)
address internal constant COW_SETTLEMENT =
0x9008D19f58AAbD9eD0D60971565AA8510560ab41;
address internal constant VAULT_RELAYER =
0xC92E8bdf79f0507f65a392b0ab4667716BFE0110;
bytes32 internal immutable COW_DOMAIN_SEPARATOR;
/// @notice Struct to hold the info for `want`.
TokenInfo internal wantInfo;
/// @notice The address that will receive the funds in the auction.
address public receiver;
/// @notice The amount to start the auction at.
uint256 public startingPrice;
/// @notice The time that each auction lasts.
uint256 public auctionLength;
/// @notice Mapping from `from` token to its struct.
mapping(address => AuctionInfo) public auctions;
/// @notice Array of all the enabled auction for this contract.
address[] public enabledAuctions;
constructor() Governance2Step(msg.sender) {
bytes32 domainSeparator;
if (COW_SETTLEMENT.code.length > 0) {
domainSeparator = ICowSettlement(COW_SETTLEMENT).domainSeparator();
} else {
domainSeparator = bytes32(0);
}
COW_DOMAIN_SEPARATOR = domainSeparator;
}
/**
* @notice Initializes the Auction contract with initial parameters.
* @param _want Address this auction is selling to.
* @param _receiver Address that will receive the funds from the auction.
* @param _governance Address of the contract governance.
* @param _auctionLength Duration of each auction in seconds.
* @param _startingPrice Starting price for each auction.
*/
function initialize(
address _want,
address _receiver,
address _governance,
uint256 _auctionLength,
uint256 _startingPrice
) public virtual {
require(auctionLength == 0, "initialized");
require(_want != address(0), "ZERO ADDRESS");
require(_auctionLength != 0, "length");
require(_startingPrice != 0, "starting price");
require(_receiver != address(0), "receiver");
// Cannot have more than 18 decimals.
uint256 decimals = ERC20(_want).decimals();
require(decimals <= 18, "unsupported decimals");
// Set variables
wantInfo = TokenInfo({
tokenAddress: _want,
scaler: uint96(WAD / 10 ** decimals)
});
receiver = _receiver;
governance = _governance;
auctionLength = _auctionLength;
startingPrice = _startingPrice;
emit UpdatedStartingPrice(_startingPrice);
}
/*//////////////////////////////////////////////////////////////
VIEW METHODS
//////////////////////////////////////////////////////////////*/
/**
* @notice Get the address of this auctions want token.
* @return . The want token.
*/
function want() public view virtual returns (address) {
return wantInfo.tokenAddress;
}
/**
* @notice Get the available amount for the auction.
* @param _from The address of the token to be auctioned.
* @return . The available amount for the auction.
*/
function available(address _from) public view virtual returns (uint256) {
if (!isActive(_from)) return 0;
return
Maths.min(
auctions[_from].initialAvailable,
ERC20(_from).balanceOf(address(this))
);
}
/**
* @notice Get the kicked timestamp for the auction.
* @param _from The address of the token to be auctioned.
* @return . The kicked timestamp for the auction.
*/
function kicked(address _from) external view virtual returns (uint256) {
return auctions[_from].kicked;
}
/**
* @notice Check if the auction is active.
* @param _from The address of the token to be auctioned.
* @return . Whether the auction is active.
*/
function isActive(address _from) public view virtual returns (bool) {
return auctions[_from].kicked + auctionLength >= block.timestamp;
}
/**
* @notice Get all the enabled auctions.
*/
function getAllEnabledAuctions()
external
view
virtual
returns (address[] memory)
{
return enabledAuctions;
}
/**
* @notice Get the pending amount available for the next auction.
* @dev Defaults to the auctions balance of the from token if no hook.
* @param _from The address of the token to be auctioned.
* @return uint256 The amount that can be kicked into the auction.
*/
function kickable(address _from) external view virtual returns (uint256) {
// If not enough time has passed then `kickable` is 0.
if (isActive(_from)) return 0;
// Use the full balance of this contract.
return ERC20(_from).balanceOf(address(this));
}
/**
* @notice Gets the amount of `want` needed to buy the available amount of `from`.
* @param _from The address of the token to be auctioned.
* @return . The amount of `want` needed to fulfill the take amount.
*/
function getAmountNeeded(
address _from
) external view virtual returns (uint256) {
return
_getAmountNeeded(
auctions[_from],
available(_from),
block.timestamp
);
}
/**
* @notice Gets the amount of `want` needed to buy a specific amount of `from`.
* @param _from The address of the token to be auctioned.
* @param _amountToTake The amount of `from` to take in the auction.
* @return . The amount of `want` needed to fulfill the take amount.
*/
function getAmountNeeded(
address _from,
uint256 _amountToTake
) external view virtual returns (uint256) {
return
_getAmountNeeded(auctions[_from], _amountToTake, block.timestamp);
}
/**
* @notice Gets the amount of `want` needed to buy a specific amount of `from` at a specific timestamp.
* @param _from The address of the token to be auctioned.
* @param _amountToTake The amount `from` to take in the auction.
* @param _timestamp The specific timestamp for calculating the amount needed.
* @return . The amount of `want` needed to fulfill the take amount.
*/
function getAmountNeeded(
address _from,
uint256 _amountToTake,
uint256 _timestamp
) external view virtual returns (uint256) {
return _getAmountNeeded(auctions[_from], _amountToTake, _timestamp);
}
/**
* @dev Return the amount of `want` needed to buy `_amountToTake`.
*/
function _getAmountNeeded(
AuctionInfo memory _auction,
uint256 _amountToTake,
uint256 _timestamp
) internal view virtual returns (uint256) {
return
// Scale _amountToTake to 1e18
(_amountToTake *
_auction.scaler *
// Price is always 1e18
_price(
_auction.kicked,
_auction.initialAvailable * _auction.scaler,
_timestamp
)) /
1e18 /
// Scale back down to want.
wantInfo.scaler;
}
/**
* @notice Gets the price of the auction at the current timestamp.
* @param _from The address of the token to be auctioned.
* @return . The price of the auction.
*/
function price(address _from) external view virtual returns (uint256) {
return price(_from, block.timestamp);
}
/**
* @notice Gets the price of the auction at a specific timestamp.
* @param _from The address of the token to be auctioned.
* @param _timestamp The specific timestamp for calculating the price.
* @return . The price of the auction.
*/
function price(
address _from,
uint256 _timestamp
) public view virtual returns (uint256) {
// Get unscaled price and scale it down.
return
_price(
auctions[_from].kicked,
auctions[_from].initialAvailable * auctions[_from].scaler,
_timestamp
) / wantInfo.scaler;
}
/**
* @dev Internal function to calculate the scaled price based on auction parameters.
* @param _kicked The timestamp the auction was kicked.
* @param _available The initial available amount scaled 1e18.
* @param _timestamp The specific timestamp for calculating the price.
* @return . The calculated price scaled to 1e18.
*/
function _price(
uint256 _kicked,
uint256 _available,
uint256 _timestamp
) internal view virtual returns (uint256) {
if (_available == 0) return 0;
uint256 secondsElapsed = _timestamp - _kicked;
if (secondsElapsed > auctionLength) return 0;
// Exponential step decay from https://github.com/ajna-finance/ajna-core/blob/master/src/libraries/helpers/PoolHelper.sol
uint256 hoursComponent = 1e27 >> (secondsElapsed / 3600);
uint256 minutesComponent = Maths.rpow(
MINUTE_HALF_LIFE,
(secondsElapsed % 3600) / 60
);
uint256 initialPrice = Maths.wdiv(startingPrice * 1e18, _available);
return
(initialPrice * Maths.rmul(hoursComponent, minutesComponent)) /
1e27;
}
/*//////////////////////////////////////////////////////////////
SETTERS
//////////////////////////////////////////////////////////////*/
/**
* @notice Enables a new auction.
* @param _from The address of the token to be auctioned.
*/
function enable(address _from) external virtual onlyGovernance {
address _want = want();
require(_from != address(0) && _from != _want, "ZERO ADDRESS");
require(auctions[_from].scaler == 0, "already enabled");
// Cannot have more than 18 decimals.
uint256 decimals = ERC20(_from).decimals();
require(decimals <= 18, "unsupported decimals");
// Store all needed info.
auctions[_from].scaler = uint64(WAD / 10 ** decimals);
ERC20(_from).forceApprove(VAULT_RELAYER, type(uint256).max);
// Add to the array.
enabledAuctions.push(_from);
emit AuctionEnabled(_from, _want);
}
/**
* @notice Disables an existing auction.
* @dev Only callable by governance.
* @param _from The address of the token being sold.
*/
function disable(address _from) external virtual {
disable(_from, 0);
}
/**
* @notice Disables an existing auction.
* @dev Only callable by governance.
* @param _from The address of the token being sold.
* @param _index The index the auctionId is at in the array.
*/
function disable(
address _from,
uint256 _index
) public virtual onlyGovernance {
// Make sure the auction was enabled.
require(auctions[_from].scaler != 0, "not enabled");
// Remove the struct.
delete auctions[_from];
ERC20(_from).forceApprove(VAULT_RELAYER, 0);
// Remove the auction ID from the array.
address[] memory _enabledAuctions = enabledAuctions;
if (_enabledAuctions[_index] != _from) {
// If the _index given is not the id find it.
for (uint256 i = 0; i < _enabledAuctions.length; ++i) {
if (_enabledAuctions[i] == _from) {
_index = i;
break;
}
}
}
// Move the id to the last spot if not there.
if (_index < _enabledAuctions.length - 1) {
_enabledAuctions[_index] = _enabledAuctions[
_enabledAuctions.length - 1
];
// Update the array.
enabledAuctions = _enabledAuctions;
}
// Pop the id off the array.
enabledAuctions.pop();
emit AuctionDisabled(_from, want());
}
/**
* @notice Sets the starting price for the auction.
* @param _startingPrice The new starting price for the auction.
*/
function setStartingPrice(
uint256 _startingPrice
) external virtual onlyGovernance {
require(_startingPrice != 0, "starting price");
// Don't change the price when an auction is active.
address[] memory _enabledAuctions = enabledAuctions;
for (uint256 i = 0; i < _enabledAuctions.length; ++i) {
require(!isActive(_enabledAuctions[i]), "active auction");
}
startingPrice = _startingPrice;
emit UpdatedStartingPrice(_startingPrice);
}
/*//////////////////////////////////////////////////////////////
PARTICIPATE IN AUCTION
//////////////////////////////////////////////////////////////*/
/**
* @notice Kicks off an auction, updating its status and making funds available for bidding.
* @param _from The address of the token to be auctioned.
* @return _available The available amount for bidding on in the auction.
*/
function kick(
address _from
) external virtual nonReentrant returns (uint256 _available) {
require(auctions[_from].scaler != 0, "not enabled");
require(
block.timestamp > auctions[_from].kicked + auctionLength,
"too soon"
);
// Just use current balance.
_available = ERC20(_from).balanceOf(address(this));
require(_available != 0, "nothing to kick");
// Update the auctions status.
auctions[_from].kicked = uint64(block.timestamp);
auctions[_from].initialAvailable = uint128(_available);
emit AuctionKicked(_from, _available);
}
/**
* @notice Take the token being sold in a live auction.
* @dev Defaults to taking the full amount and sending to the msg sender.
* @param _from The address of the token to be auctioned.
* @return . The amount of fromToken taken in the auction.
*/
function take(address _from) external virtual returns (uint256) {
return _take(_from, type(uint256).max, msg.sender, new bytes(0));
}
/**
* @notice Take the token being sold in a live auction with a specified maximum amount.
* @dev Will send the funds to the msg sender.
* @param _from The address of the token to be auctioned.
* @param _maxAmount The maximum amount of fromToken to take in the auction.
* @return . The amount of fromToken taken in the auction.
*/
function take(
address _from,
uint256 _maxAmount
) external virtual returns (uint256) {
return _take(_from, _maxAmount, msg.sender, new bytes(0));
}
/**
* @notice Take the token being sold in a live auction.
* @param _from The address of the token to be auctioned.
* @param _maxAmount The maximum amount of fromToken to take in the auction.
* @param _receiver The address that will receive the fromToken.
* @return _amountTaken The amount of fromToken taken in the auction.
*/
function take(
address _from,
uint256 _maxAmount,
address _receiver
) external virtual returns (uint256) {
return _take(_from, _maxAmount, _receiver, new bytes(0));
}
/**
* @notice Take the token being sold in a live auction.
* @param _from The address of the token to be auctioned.
* @param _maxAmount The maximum amount of fromToken to take in the auction.
* @param _receiver The address that will receive the fromToken.
* @param _data The data signify the callback should be used and sent with it.
* @return _amountTaken The amount of fromToken taken in the auction.
*/
function take(
address _from,
uint256 _maxAmount,
address _receiver,
bytes calldata _data
) external virtual returns (uint256) {
return _take(_from, _maxAmount, _receiver, _data);
}
/// @dev Implements the take of the auction.
function _take(
address _from,
uint256 _maxAmount,
address _receiver,
bytes memory _data
) internal virtual nonReentrant returns (uint256 _amountTaken) {
AuctionInfo memory auction = auctions[_from];
// Make sure the auction is active.
require(
auction.kicked + auctionLength >= block.timestamp,
"not kicked"
);
// Max amount that can be taken.
uint256 _available = available(_from);
_amountTaken = _available > _maxAmount ? _maxAmount : _available;
// Get the amount needed
uint256 needed = _getAmountNeeded(
auction,
_amountTaken,
block.timestamp
);
require(needed != 0, "zero needed");
// Send `from`.
ERC20(_from).safeTransfer(_receiver, _amountTaken);
// If the caller has specified data.
if (_data.length != 0) {
// Do the callback.
ITaker(_receiver).auctionTakeCallback(
_from,
msg.sender,
_amountTaken,
needed,
_data
);
}
// Cache the want address.
address _want = want();
// Pull `want`.
ERC20(_want).safeTransferFrom(msg.sender, receiver, needed);
}
/// @dev Validates a COW order signature.
function isValidSignature(
bytes32 _hash,
bytes calldata signature
) external view returns (bytes4) {
// Make sure `_take` has not already been entered.
require(!_reentrancyGuardEntered(), "ReentrancyGuard: reentrant call");
// Decode the signature to get the order.
GPv2Order.Data memory order = abi.decode(signature, (GPv2Order.Data));
AuctionInfo memory auction = auctions[address(order.sellToken)];
// Get the current amount needed for the auction.
uint256 paymentAmount = _getAmountNeeded(
auction,
order.sellAmount,
block.timestamp
);
// Verify the order details.
require(_hash == order.hash(COW_DOMAIN_SEPARATOR), "bad order");
require(paymentAmount != 0, "zero amount");
require(available(address(order.sellToken)) != 0, "zero available");
require(order.feeAmount == 0, "fee");
require(order.partiallyFillable, "partial fill");
require(order.validTo < auction.kicked + auctionLength, "expired");
require(order.appData == bytes32(0), "app data");
require(order.buyAmount >= paymentAmount, "bad price");
require(address(order.buyToken) == want(), "bad token");
require(order.receiver == receiver, "bad receiver");
require(order.sellAmount <= auction.initialAvailable, "bad amount");
// If all checks pass, return the magic value
return this.isValidSignature.selector;
}
/**
* @notice Allows the auction to be stopped if the full amount is taken.
* @param _from The address of the token to be auctioned.
*/
function settle(address _from) external virtual {
require(isActive(_from), "!active");
require(ERC20(_from).balanceOf(address(this)) == 0, "!empty");
auctions[_from].kicked = uint64(0);
}
function sweep(address _token) external virtual onlyGovernance {
ERC20(_token).safeTransfer(
msg.sender,
ERC20(_token).balanceOf(address(this))
);
}
}// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.7.5;
pragma abicoder v2;
import "../../core/interfaces/callback/ICLSwapCallback.sol";
/// @title Router token swapping functionality
/// @notice Functions for swapping tokens via CL
interface ISwapRouter is ICLSwapCallback {
struct ExactInputSingleParams {
address tokenIn;
address tokenOut;
int24 tickSpacing;
address recipient;
uint256 deadline;
uint256 amountIn;
uint256 amountOutMinimum;
uint160 sqrtPriceLimitX96;
}
/// @notice Swaps `amountIn` of one token for as much as possible of another token
/// @param params The parameters necessary for the swap, encoded as `ExactInputSingleParams` in calldata
/// @return amountOut The amount of the received token
function exactInputSingle(ExactInputSingleParams calldata params) external payable returns (uint256 amountOut);
struct ExactInputParams {
bytes path;
address recipient;
uint256 deadline;
uint256 amountIn;
uint256 amountOutMinimum;
}
/// @notice Swaps `amountIn` of one token for as much as possible of another along the specified path
/// @param params The parameters necessary for the multi-hop swap, encoded as `ExactInputParams` in calldata
/// @return amountOut The amount of the received token
function exactInput(ExactInputParams calldata params) external payable returns (uint256 amountOut);
struct ExactOutputSingleParams {
address tokenIn;
address tokenOut;
int24 tickSpacing;
address recipient;
uint256 deadline;
uint256 amountOut;
uint256 amountInMaximum;
uint160 sqrtPriceLimitX96;
}
/// @notice Swaps as little as possible of one token for `amountOut` of another token
/// @param params The parameters necessary for the swap, encoded as `ExactOutputSingleParams` in calldata
/// @return amountIn The amount of the input token
function exactOutputSingle(ExactOutputSingleParams calldata params) external payable returns (uint256 amountIn);
struct ExactOutputParams {
bytes path;
address recipient;
uint256 deadline;
uint256 amountOut;
uint256 amountInMaximum;
}
/// @notice Swaps as little as possible of one token for `amountOut` of another along the specified path (reversed)
/// @param params The parameters necessary for the multi-hop swap, encoded as `ExactOutputParams` in calldata
/// @return amountIn The amount of the input token
function exactOutput(ExactOutputParams calldata params) external payable returns (uint256 amountIn);
}// SPDX-License-Identifier: AGPL-3.0
pragma solidity 0.8.28;
interface IWETH {
function deposit() external payable;
function transfer(address to, uint256 value) external returns (bool);
function withdraw(uint256) external;
}// SPDX-License-Identifier: AGPL-3.0
pragma solidity 0.8.28;
import {FluidStructs} from "src/libraries/FluidStructs.sol";
interface IMerkleRewards {
function claim(
address recipient_,
uint256 cumulativeAmount_,
uint8 positionType_,
bytes32 positionId_,
uint256 cycle_,
bytes32[] calldata merkleProof_,
bytes memory metadata_
) external;
}
interface ILendingResolver {
function getFTokenDetails(
address fToken_
) external view returns (FluidStructs.FTokenDetails memory fTokenDetails_);
}
interface ILiquidtyResolver {
function getOverallTokenData(
address token_
)
external
view
returns (FluidStructs.OverallTokenData memory overallTokenData_);
}
interface IDexResolver {
function getDexVariablesRaw(address dex_) external view returns (uint256);
}
interface IFluidDex {
function swapIn(
bool swap0to1_,
uint256 amountIn_,
uint256 amountOutMin_,
address to_
) external returns (uint256);
}// SPDX-License-Identifier: AGPL-3.0
pragma solidity >=0.8.18;
import {ITokenizedStrategy} from "./ITokenizedStrategy.sol";
import {IBaseStrategy} from "./IBaseStrategy.sol";
interface IStrategy is IBaseStrategy, ITokenizedStrategy {}// SPDX-License-Identifier: AGPL-3.0
pragma solidity >=0.8.18;
import {BaseStrategy, ERC20} from "@tokenized-strategy/BaseStrategy.sol";
/**
* @title Base Health Check
* @author Yearn.finance
* @notice This contract can be inherited by any Yearn
* V3 strategy wishing to implement a health check during
* the `report` function in order to prevent any unexpected
* behavior from being permanently recorded as well as the
* `checkHealth` modifier.
*
* A strategist simply needs to inherit this contract. Set
* the limit ratios to the desired amounts and then
* override `_harvestAndReport()` just as they otherwise
* would. If the profit or loss that would be recorded is
* outside the acceptable bounds the tx will revert.
*
* The healthcheck does not prevent a strategy from reporting
* losses, but rather can make sure manual intervention is
* needed before reporting an unexpected loss or profit.
*/
abstract contract BaseHealthCheck is BaseStrategy {
// Can be used to determine if a healthcheck should be called.
// Defaults to true;
bool public doHealthCheck = true;
uint256 internal constant MAX_BPS = 10_000;
// Default profit limit to 100%.
uint16 private _profitLimitRatio = uint16(MAX_BPS);
// Defaults loss limit to 0.
uint16 private _lossLimitRatio;
constructor(
address _asset,
string memory _name
) BaseStrategy(_asset, _name) {}
/**
* @notice Returns the current profit limit ratio.
* @dev Use a getter function to keep the variable private.
* @return . The current profit limit ratio.
*/
function profitLimitRatio() public view returns (uint256) {
return _profitLimitRatio;
}
/**
* @notice Returns the current loss limit ratio.
* @dev Use a getter function to keep the variable private.
* @return . The current loss limit ratio.
*/
function lossLimitRatio() public view returns (uint256) {
return _lossLimitRatio;
}
/**
* @notice Set the `profitLimitRatio`.
* @dev Denominated in basis points. I.E. 1_000 == 10%.
* @param _newProfitLimitRatio The mew profit limit ratio.
*/
function setProfitLimitRatio(
uint256 _newProfitLimitRatio
) external onlyManagement {
_setProfitLimitRatio(_newProfitLimitRatio);
}
/**
* @dev Internally set the profit limit ratio. Denominated
* in basis points. I.E. 1_000 == 10%.
* @param _newProfitLimitRatio The mew profit limit ratio.
*/
function _setProfitLimitRatio(uint256 _newProfitLimitRatio) internal {
require(_newProfitLimitRatio > 0, "!zero profit");
require(_newProfitLimitRatio <= type(uint16).max, "!too high");
_profitLimitRatio = uint16(_newProfitLimitRatio);
}
/**
* @notice Set the `lossLimitRatio`.
* @dev Denominated in basis points. I.E. 1_000 == 10%.
* @param _newLossLimitRatio The new loss limit ratio.
*/
function setLossLimitRatio(
uint256 _newLossLimitRatio
) external onlyManagement {
_setLossLimitRatio(_newLossLimitRatio);
}
/**
* @dev Internally set the loss limit ratio. Denominated
* in basis points. I.E. 1_000 == 10%.
* @param _newLossLimitRatio The new loss limit ratio.
*/
function _setLossLimitRatio(uint256 _newLossLimitRatio) internal {
require(_newLossLimitRatio < MAX_BPS, "!loss limit");
_lossLimitRatio = uint16(_newLossLimitRatio);
}
/**
* @notice Turns the healthcheck on and off.
* @dev If turned off the next report will auto turn it back on.
* @param _doHealthCheck Bool if healthCheck should be done.
*/
function setDoHealthCheck(bool _doHealthCheck) public onlyManagement {
doHealthCheck = _doHealthCheck;
}
/**
* @notice OVerrides the default {harvestAndReport} to include a healthcheck.
* @return _totalAssets New totalAssets post report.
*/
function harvestAndReport()
external
override
onlySelf
returns (uint256 _totalAssets)
{
// Let the strategy report.
_totalAssets = _harvestAndReport();
// Run the healthcheck on the amount returned.
_executeHealthCheck(_totalAssets);
}
/**
* @dev To be called during a report to make sure the profit
* or loss being recorded is within the acceptable bound.
*
* @param _newTotalAssets The amount that will be reported.
*/
function _executeHealthCheck(uint256 _newTotalAssets) internal virtual {
if (!doHealthCheck) {
doHealthCheck = true;
return;
}
// Get the current total assets from the implementation.
uint256 currentTotalAssets = TokenizedStrategy.totalAssets();
if (_newTotalAssets > currentTotalAssets) {
require(
((_newTotalAssets - currentTotalAssets) <=
(currentTotalAssets * uint256(_profitLimitRatio)) /
MAX_BPS),
"healthCheck"
);
} else if (currentTotalAssets > _newTotalAssets) {
require(
(currentTotalAssets - _newTotalAssets <=
((currentTotalAssets * uint256(_lossLimitRatio)) /
MAX_BPS)),
"healthCheck"
);
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/math/Math.sol)
pragma solidity ^0.8.0;
/**
* @dev Standard math utilities missing in the Solidity language.
*/
library Math {
enum Rounding {
Down, // Toward negative infinity
Up, // Toward infinity
Zero // Toward zero
}
/**
* @dev Returns the largest of two numbers.
*/
function max(uint256 a, uint256 b) internal pure returns (uint256) {
return a > b ? a : b;
}
/**
* @dev Returns the smallest of two numbers.
*/
function min(uint256 a, uint256 b) internal pure returns (uint256) {
return a < b ? a : b;
}
/**
* @dev Returns the average of two numbers. The result is rounded towards
* zero.
*/
function average(uint256 a, uint256 b) internal pure returns (uint256) {
// (a + b) / 2 can overflow.
return (a & b) + (a ^ b) / 2;
}
/**
* @dev Returns the ceiling of the division of two numbers.
*
* This differs from standard division with `/` in that it rounds up instead
* of rounding down.
*/
function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
// (a + b - 1) / b can overflow on addition, so we distribute.
return a == 0 ? 0 : (a - 1) / b + 1;
}
/**
* @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0
* @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)
* with further edits by Uniswap Labs also under MIT license.
*/
function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) {
unchecked {
// 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use
// use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256
// variables such that product = prod1 * 2^256 + prod0.
uint256 prod0; // Least significant 256 bits of the product
uint256 prod1; // Most significant 256 bits of the product
assembly {
let mm := mulmod(x, y, not(0))
prod0 := mul(x, y)
prod1 := sub(sub(mm, prod0), lt(mm, prod0))
}
// Handle non-overflow cases, 256 by 256 division.
if (prod1 == 0) {
// Solidity will revert if denominator == 0, unlike the div opcode on its own.
// The surrounding unchecked block does not change this fact.
// See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic.
return prod0 / denominator;
}
// Make sure the result is less than 2^256. Also prevents denominator == 0.
require(denominator > prod1, "Math: mulDiv overflow");
///////////////////////////////////////////////
// 512 by 256 division.
///////////////////////////////////////////////
// Make division exact by subtracting the remainder from [prod1 prod0].
uint256 remainder;
assembly {
// Compute remainder using mulmod.
remainder := mulmod(x, y, denominator)
// Subtract 256 bit number from 512 bit number.
prod1 := sub(prod1, gt(remainder, prod0))
prod0 := sub(prod0, remainder)
}
// Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.
// See https://cs.stackexchange.com/q/138556/92363.
// Does not overflow because the denominator cannot be zero at this stage in the function.
uint256 twos = denominator & (~denominator + 1);
assembly {
// Divide denominator by twos.
denominator := div(denominator, twos)
// Divide [prod1 prod0] by twos.
prod0 := div(prod0, twos)
// Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.
twos := add(div(sub(0, twos), twos), 1)
}
// Shift in bits from prod1 into prod0.
prod0 |= prod1 * twos;
// Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such
// that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for
// four bits. That is, denominator * inv = 1 mod 2^4.
uint256 inverse = (3 * denominator) ^ 2;
// Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works
// in modular arithmetic, doubling the correct bits in each step.
inverse *= 2 - denominator * inverse; // inverse mod 2^8
inverse *= 2 - denominator * inverse; // inverse mod 2^16
inverse *= 2 - denominator * inverse; // inverse mod 2^32
inverse *= 2 - denominator * inverse; // inverse mod 2^64
inverse *= 2 - denominator * inverse; // inverse mod 2^128
inverse *= 2 - denominator * inverse; // inverse mod 2^256
// Because the division is now exact we can divide by multiplying with the modular inverse of denominator.
// This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is
// less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1
// is no longer required.
result = prod0 * inverse;
return result;
}
}
/**
* @notice Calculates x * y / denominator with full precision, following the selected rounding direction.
*/
function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) {
uint256 result = mulDiv(x, y, denominator);
if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {
result += 1;
}
return result;
}
/**
* @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down.
*
* Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11).
*/
function sqrt(uint256 a) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
// For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.
//
// We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have
// `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.
//
// This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`
// → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`
// → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`
//
// Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.
uint256 result = 1 << (log2(a) >> 1);
// At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,
// since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at
// every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision
// into the expected uint128 result.
unchecked {
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
return min(result, a / result);
}
}
/**
* @notice Calculates sqrt(a), following the selected rounding direction.
*/
function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = sqrt(a);
return result + (rounding == Rounding.Up && result * result < a ? 1 : 0);
}
}
/**
* @dev Return the log in base 2, rounded down, of a positive value.
* Returns 0 if given 0.
*/
function log2(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >> 128 > 0) {
value >>= 128;
result += 128;
}
if (value >> 64 > 0) {
value >>= 64;
result += 64;
}
if (value >> 32 > 0) {
value >>= 32;
result += 32;
}
if (value >> 16 > 0) {
value >>= 16;
result += 16;
}
if (value >> 8 > 0) {
value >>= 8;
result += 8;
}
if (value >> 4 > 0) {
value >>= 4;
result += 4;
}
if (value >> 2 > 0) {
value >>= 2;
result += 2;
}
if (value >> 1 > 0) {
result += 1;
}
}
return result;
}
/**
* @dev Return the log in base 2, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log2(value);
return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0);
}
}
/**
* @dev Return the log in base 10, rounded down, of a positive value.
* Returns 0 if given 0.
*/
function log10(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >= 10 ** 64) {
value /= 10 ** 64;
result += 64;
}
if (value >= 10 ** 32) {
value /= 10 ** 32;
result += 32;
}
if (value >= 10 ** 16) {
value /= 10 ** 16;
result += 16;
}
if (value >= 10 ** 8) {
value /= 10 ** 8;
result += 8;
}
if (value >= 10 ** 4) {
value /= 10 ** 4;
result += 4;
}
if (value >= 10 ** 2) {
value /= 10 ** 2;
result += 2;
}
if (value >= 10 ** 1) {
result += 1;
}
}
return result;
}
/**
* @dev Return the log in base 10, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log10(value);
return result + (rounding == Rounding.Up && 10 ** result < value ? 1 : 0);
}
}
/**
* @dev Return the log in base 256, rounded down, of a positive value.
* Returns 0 if given 0.
*
* Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.
*/
function log256(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >> 128 > 0) {
value >>= 128;
result += 16;
}
if (value >> 64 > 0) {
value >>= 64;
result += 8;
}
if (value >> 32 > 0) {
value >>= 32;
result += 4;
}
if (value >> 16 > 0) {
value >>= 16;
result += 2;
}
if (value >> 8 > 0) {
result += 1;
}
}
return result;
}
/**
* @dev Return the log in base 256, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log256(value);
return result + (rounding == Rounding.Up && 1 << (result << 3) < value ? 1 : 0);
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.3) (token/ERC20/utils/SafeERC20.sol)
pragma solidity ^0.8.0;
import "../IERC20.sol";
import "../extensions/IERC20Permit.sol";
import "../../../utils/Address.sol";
/**
* @title SafeERC20
* @dev Wrappers around ERC20 operations that throw on failure (when the token
* contract returns false). Tokens that return no value (and instead revert or
* throw on failure) are also supported, non-reverting calls are assumed to be
* successful.
* To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
* which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
*/
library SafeERC20 {
using Address for address;
/**
* @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*/
function safeTransfer(IERC20 token, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
}
/**
* @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the
* calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.
*/
function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
}
/**
* @dev Deprecated. This function has issues similar to the ones found in
* {IERC20-approve}, and its usage is discouraged.
*
* Whenever possible, use {safeIncreaseAllowance} and
* {safeDecreaseAllowance} instead.
*/
function safeApprove(IERC20 token, address spender, uint256 value) internal {
// safeApprove should only be called when setting an initial allowance,
// or when resetting it to zero. To increase and decrease it, use
// 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
require(
(value == 0) || (token.allowance(address(this), spender) == 0),
"SafeERC20: approve from non-zero to non-zero allowance"
);
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
}
/**
* @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*/
function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
uint256 oldAllowance = token.allowance(address(this), spender);
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance + value));
}
/**
* @dev Decrease the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*/
function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal {
unchecked {
uint256 oldAllowance = token.allowance(address(this), spender);
require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance - value));
}
}
/**
* @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval
* to be set to zero before setting it to a non-zero value, such as USDT.
*/
function forceApprove(IERC20 token, address spender, uint256 value) internal {
bytes memory approvalCall = abi.encodeWithSelector(token.approve.selector, spender, value);
if (!_callOptionalReturnBool(token, approvalCall)) {
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, 0));
_callOptionalReturn(token, approvalCall);
}
}
/**
* @dev Use a ERC-2612 signature to set the `owner` approval toward `spender` on `token`.
* Revert on invalid signature.
*/
function safePermit(
IERC20Permit token,
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) internal {
uint256 nonceBefore = token.nonces(owner);
token.permit(owner, spender, value, deadline, v, r, s);
uint256 nonceAfter = token.nonces(owner);
require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed");
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*/
function _callOptionalReturn(IERC20 token, bytes memory data) private {
// We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
// we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that
// the target address contains contract code and also asserts for success in the low-level call.
bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
require(returndata.length == 0 || abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*
* This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead.
*/
function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {
// We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
// we're implementing it ourselves. We cannot use {Address-functionCall} here since this should return false
// and not revert is the subcall reverts.
(bool success, bytes memory returndata) = address(token).call(data);
return
success && (returndata.length == 0 || abi.decode(returndata, (bool))) && Address.isContract(address(token));
}
}// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity >=0.8.18;
// Math library from https://github.com/ajna-finance/ajna-core/blob/master/src/libraries/internal/Maths.sol
/**
@title Maths library
@notice Internal library containing common maths.
*/
library Maths {
uint256 internal constant WAD = 1e18;
uint256 internal constant RAY = 1e27;
function wmul(uint256 x, uint256 y) internal pure returns (uint256) {
return (x * y + WAD / 2) / WAD;
}
function floorWmul(uint256 x, uint256 y) internal pure returns (uint256) {
return (x * y) / WAD;
}
function ceilWmul(uint256 x, uint256 y) internal pure returns (uint256) {
return (x * y + WAD - 1) / WAD;
}
function wdiv(uint256 x, uint256 y) internal pure returns (uint256) {
return (x * WAD + y / 2) / y;
}
function floorWdiv(uint256 x, uint256 y) internal pure returns (uint256) {
return (x * WAD) / y;
}
function ceilWdiv(uint256 x, uint256 y) internal pure returns (uint256) {
return (x * WAD + y - 1) / y;
}
function ceilDiv(uint256 x, uint256 y) internal pure returns (uint256) {
return (x + y - 1) / y;
}
function max(uint256 x, uint256 y) internal pure returns (uint256) {
return x >= y ? x : y;
}
function min(uint256 x, uint256 y) internal pure returns (uint256) {
return x <= y ? x : y;
}
function wad(uint256 x) internal pure returns (uint256) {
return x * WAD;
}
function rmul(uint256 x, uint256 y) internal pure returns (uint256) {
return (x * y + RAY / 2) / RAY;
}
function rpow(uint256 x, uint256 n) internal pure returns (uint256 z) {
z = n % 2 != 0 ? x : RAY;
for (n /= 2; n != 0; n /= 2) {
x = rmul(x, x);
if (n % 2 != 0) {
z = rmul(z, x);
}
}
}
/*************************/
/*** Integer Functions ***/
/*************************/
function maxInt(int256 x, int256 y) internal pure returns (int256) {
return x >= y ? x : y;
}
function minInt(int256 x, int256 y) internal pure returns (int256) {
return x <= y ? x : y;
}
}// SPDX-License-Identifier: AGPL-3.0
pragma solidity >=0.8.18;
interface ITaker {
function auctionTakeCallback(
address _from,
address _sender,
uint256 _amountTaken,
uint256 _amountNeeded,
bytes calldata _data
) external;
}// SPDX-License-Identifier: LGPL-3.0-or-later
pragma solidity ^0.8.0;
import {ERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
/// @title Gnosis Protocol v2 Order Library
/// @author Gnosis Developers
library GPv2Order {
/// @dev The complete data for a Gnosis Protocol order. This struct contains
/// all order parameters that are signed for submitting to GP.
struct Data {
ERC20 sellToken;
ERC20 buyToken;
address receiver;
uint256 sellAmount;
uint256 buyAmount;
uint32 validTo;
bytes32 appData;
uint256 feeAmount;
bytes32 kind;
bool partiallyFillable;
bytes32 sellTokenBalance;
bytes32 buyTokenBalance;
}
/// @dev The order EIP-712 type hash for the [`GPv2Order.Data`] struct.
///
/// This value is pre-computed from the following expression:
/// ```
/// keccak256(
/// "Order(" +
/// "address sellToken," +
/// "address buyToken," +
/// "address receiver," +
/// "uint256 sellAmount," +
/// "uint256 buyAmount," +
/// "uint32 validTo," +
/// "bytes32 appData," +
/// "uint256 feeAmount," +
/// "string kind," +
/// "bool partiallyFillable" +
/// "string sellTokenBalance" +
/// "string buyTokenBalance" +
/// ")"
/// )
/// ```
bytes32 internal constant TYPE_HASH =
hex"d5a25ba2e97094ad7d83dc28a6572da797d6b3e7fc6663bd93efb789fc17e489";
/// @dev The marker value for a sell order for computing the order struct
/// hash. This allows the EIP-712 compatible wallets to display a
/// descriptive string for the order kind (instead of 0 or 1).
///
/// This value is pre-computed from the following expression:
/// ```
/// keccak256("sell")
/// ```
bytes32 internal constant KIND_SELL =
hex"f3b277728b3fee749481eb3e0b3b48980dbbab78658fc419025cb16eee346775";
/// @dev The OrderKind marker value for a buy order for computing the order
/// struct hash.
///
/// This value is pre-computed from the following expression:
/// ```
/// keccak256("buy")
/// ```
bytes32 internal constant KIND_BUY =
hex"6ed88e868af0a1983e3886d5f3e95a2fafbd6c3450bc229e27342283dc429ccc";
/// @dev The TokenBalance marker value for using direct ERC20 balances for
/// computing the order struct hash.
///
/// This value is pre-computed from the following expression:
/// ```
/// keccak256("erc20")
/// ```
bytes32 internal constant BALANCE_ERC20 =
hex"5a28e9363bb942b639270062aa6bb295f434bcdfc42c97267bf003f272060dc9";
/// @dev The TokenBalance marker value for using Balancer Vault external
/// balances (in order to re-use Vault ERC20 approvals) for computing the
/// order struct hash.
///
/// This value is pre-computed from the following expression:
/// ```
/// keccak256("external")
/// ```
bytes32 internal constant BALANCE_EXTERNAL =
hex"abee3b73373acd583a130924aad6dc38cfdc44ba0555ba94ce2ff63980ea0632";
/// @dev The TokenBalance marker value for using Balancer Vault internal
/// balances for computing the order struct hash.
///
/// This value is pre-computed from the following expression:
/// ```
/// keccak256("internal")
/// ```
bytes32 internal constant BALANCE_INTERNAL =
hex"4ac99ace14ee0a5ef932dc609df0943ab7ac16b7583634612f8dc35a4289a6ce";
/// @dev Marker address used to indicate that the receiver of the trade
/// proceeds should the owner of the order.
///
/// This is chosen to be `address(0)` for gas efficiency as it is expected
/// to be the most common case.
address internal constant RECEIVER_SAME_AS_OWNER = address(0);
/// @dev The byte length of an order unique identifier.
uint256 internal constant UID_LENGTH = 56;
/// @dev Returns the actual receiver for an order. This function checks
/// whether or not the [`receiver`] field uses the marker value to indicate
/// it is the same as the order owner.
///
/// @return receiver The actual receiver of trade proceeds.
function actualReceiver(
Data memory order,
address owner
) internal pure returns (address receiver) {
if (order.receiver == RECEIVER_SAME_AS_OWNER) {
receiver = owner;
} else {
receiver = order.receiver;
}
}
/// @dev Return the EIP-712 signing hash for the specified order.
///
/// @param order The order to compute the EIP-712 signing hash for.
/// @param domainSeparator The EIP-712 domain separator to use.
/// @return orderDigest The 32 byte EIP-712 struct hash.
function hash(
Data memory order,
bytes32 domainSeparator
) internal pure returns (bytes32 orderDigest) {
bytes32 structHash;
// NOTE: Compute the EIP-712 order struct hash in place. As suggested
// in the EIP proposal, noting that the order struct has 10 fields, and
// including the type hash `(12 + 1) * 32 = 416` bytes to hash.
// <https://github.com/ethereum/EIPs/blob/master/EIPS/eip-712.md#rationale-for-encodedata>
// solhint-disable-next-line no-inline-assembly
assembly {
let dataStart := sub(order, 32)
let temp := mload(dataStart)
mstore(dataStart, TYPE_HASH)
structHash := keccak256(dataStart, 416)
mstore(dataStart, temp)
}
// NOTE: Now that we have the struct hash, compute the EIP-712 signing
// hash using scratch memory past the free memory pointer. The signing
// hash is computed from `"\x19\x01" || domainSeparator || structHash`.
// <https://docs.soliditylang.org/en/v0.7.6/internals/layout_in_memory.html#layout-in-memory>
// <https://github.com/ethereum/EIPs/blob/master/EIPS/eip-712.md#specification>
// solhint-disable-next-line no-inline-assembly
assembly {
let freeMemoryPointer := mload(0x40)
mstore(freeMemoryPointer, "\x19\x01")
mstore(add(freeMemoryPointer, 2), domainSeparator)
mstore(add(freeMemoryPointer, 34), structHash)
orderDigest := keccak256(freeMemoryPointer, 66)
}
}
/// @dev Packs order UID parameters into the specified memory location. The
/// result is equivalent to `abi.encodePacked(...)` with the difference that
/// it allows re-using the memory for packing the order UID.
///
/// This function reverts if the order UID buffer is not the correct size.
///
/// @param orderUid The buffer pack the order UID parameters into.
/// @param orderDigest The EIP-712 struct digest derived from the order
/// parameters.
/// @param owner The address of the user who owns this order.
/// @param validTo The epoch time at which the order will stop being valid.
function packOrderUidParams(
bytes memory orderUid,
bytes32 orderDigest,
address owner,
uint32 validTo
) internal pure {
require(orderUid.length == UID_LENGTH, "GPv2: uid buffer overflow");
// NOTE: Write the order UID to the allocated memory buffer. The order
// parameters are written to memory in **reverse order** as memory
// operations write 32-bytes at a time and we want to use a packed
// encoding. This means, for example, that after writing the value of
// `owner` to bytes `20:52`, writing the `orderDigest` to bytes `0:32`
// will **overwrite** bytes `20:32`. This is desirable as addresses are
// only 20 bytes and `20:32` should be `0`s:
//
// | 1111111111222222222233333333334444444444555555
// byte | 01234567890123456789012345678901234567890123456789012345
// -------+---------------------------------------------------------
// field | [.........orderDigest..........][......owner.......][vT]
// -------+---------------------------------------------------------
// mstore | [000000000000000000000000000.vT]
// | [00000000000.......owner.......]
// | [.........orderDigest..........]
//
// Additionally, since Solidity `bytes memory` are length prefixed,
// 32 needs to be added to all the offsets.
//
// solhint-disable-next-line no-inline-assembly
assembly {
mstore(add(orderUid, 56), validTo)
mstore(add(orderUid, 52), owner)
mstore(add(orderUid, 32), orderDigest)
}
}
/// @dev Extracts specific order information from the standardized unique
/// order id of the protocol.
///
/// @param orderUid The unique identifier used to represent an order in
/// the protocol. This uid is the packed concatenation of the order digest,
/// the validTo order parameter and the address of the user who created the
/// order. It is used by the user to interface with the contract directly,
/// and not by calls that are triggered by the solvers.
/// @return orderDigest The EIP-712 signing digest derived from the order
/// parameters.
/// @return owner The address of the user who owns this order.
/// @return validTo The epoch time at which the order will stop being valid.
function extractOrderUidParams(
bytes calldata orderUid
)
internal
pure
returns (bytes32 orderDigest, address owner, uint32 validTo)
{
require(orderUid.length == UID_LENGTH, "GPv2: invalid uid");
// Use assembly to efficiently decode packed calldata.
// solhint-disable-next-line no-inline-assembly
assembly {
orderDigest := calldataload(orderUid.offset)
owner := shr(96, calldataload(add(orderUid.offset, 32)))
validTo := shr(224, calldataload(add(orderUid.offset, 52)))
}
}
}// SPDX-License-Identifier: AGPL-3.0
pragma solidity >=0.8.18;
import {Governance} from "./Governance.sol";
contract Governance2Step is Governance {
/// @notice Emitted when the pending governance address is set.
event UpdatePendingGovernance(address indexed newPendingGovernance);
/// @notice Address that is set to take over governance.
address public pendingGovernance;
constructor(address _governance) Governance(_governance) {}
/**
* @notice Sets a new address as the `pendingGovernance` of the contract.
* @dev Throws if the caller is not current governance.
* @param _newGovernance The new governance address.
*/
function transferGovernance(
address _newGovernance
) external virtual override onlyGovernance {
require(_newGovernance != address(0), "ZERO ADDRESS");
pendingGovernance = _newGovernance;
emit UpdatePendingGovernance(_newGovernance);
}
/**
* @notice Allows the `pendingGovernance` to accept the role.
*/
function acceptGovernance() external virtual {
require(msg.sender == pendingGovernance, "!pending governance");
emit GovernanceTransferred(governance, msg.sender);
governance = msg.sender;
pendingGovernance = address(0);
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/ERC20.sol)
pragma solidity ^0.8.0;
import "./IERC20.sol";
import "./extensions/IERC20Metadata.sol";
import "../../utils/Context.sol";
/**
* @dev Implementation of the {IERC20} interface.
*
* This implementation is agnostic to the way tokens are created. This means
* that a supply mechanism has to be added in a derived contract using {_mint}.
* For a generic mechanism see {ERC20PresetMinterPauser}.
*
* TIP: For a detailed writeup see our guide
* https://forum.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How
* to implement supply mechanisms].
*
* The default value of {decimals} is 18. To change this, you should override
* this function so it returns a different value.
*
* We have followed general OpenZeppelin Contracts guidelines: functions revert
* instead returning `false` on failure. This behavior is nonetheless
* conventional and does not conflict with the expectations of ERC20
* applications.
*
* Additionally, an {Approval} event is emitted on calls to {transferFrom}.
* This allows applications to reconstruct the allowance for all accounts just
* by listening to said events. Other implementations of the EIP may not emit
* these events, as it isn't required by the specification.
*
* Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
* functions have been added to mitigate the well-known issues around setting
* allowances. See {IERC20-approve}.
*/
contract ERC20 is Context, IERC20, IERC20Metadata {
mapping(address => uint256) private _balances;
mapping(address => mapping(address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
/**
* @dev Sets the values for {name} and {symbol}.
*
* All two of these values are immutable: they can only be set once during
* construction.
*/
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
/**
* @dev Returns the name of the token.
*/
function name() public view virtual override returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5.05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the default value returned by this function, unless
* it's overridden.
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view virtual override returns (uint8) {
return 18;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view virtual override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view virtual override returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address to, uint256 amount) public virtual override returns (bool) {
address owner = _msgSender();
_transfer(owner, to, amount);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on
* `transferFrom`. This is semantically equivalent to an infinite approval.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public virtual override returns (bool) {
address owner = _msgSender();
_approve(owner, spender, amount);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20}.
*
* NOTE: Does not update the allowance if the current allowance
* is the maximum `uint256`.
*
* Requirements:
*
* - `from` and `to` cannot be the zero address.
* - `from` must have a balance of at least `amount`.
* - the caller must have allowance for ``from``'s tokens of at least
* `amount`.
*/
function transferFrom(address from, address to, uint256 amount) public virtual override returns (bool) {
address spender = _msgSender();
_spendAllowance(from, spender, amount);
_transfer(from, to, amount);
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
address owner = _msgSender();
_approve(owner, spender, allowance(owner, spender) + addedValue);
return true;
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
address owner = _msgSender();
uint256 currentAllowance = allowance(owner, spender);
require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
unchecked {
_approve(owner, spender, currentAllowance - subtractedValue);
}
return true;
}
/**
* @dev Moves `amount` of tokens from `from` to `to`.
*
* This internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `from` must have a balance of at least `amount`.
*/
function _transfer(address from, address to, uint256 amount) internal virtual {
require(from != address(0), "ERC20: transfer from the zero address");
require(to != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(from, to, amount);
uint256 fromBalance = _balances[from];
require(fromBalance >= amount, "ERC20: transfer amount exceeds balance");
unchecked {
_balances[from] = fromBalance - amount;
// Overflow not possible: the sum of all balances is capped by totalSupply, and the sum is preserved by
// decrementing then incrementing.
_balances[to] += amount;
}
emit Transfer(from, to, amount);
_afterTokenTransfer(from, to, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply += amount;
unchecked {
// Overflow not possible: balance + amount is at most totalSupply + amount, which is checked above.
_balances[account] += amount;
}
emit Transfer(address(0), account, amount);
_afterTokenTransfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
uint256 accountBalance = _balances[account];
require(accountBalance >= amount, "ERC20: burn amount exceeds balance");
unchecked {
_balances[account] = accountBalance - amount;
// Overflow not possible: amount <= accountBalance <= totalSupply.
_totalSupply -= amount;
}
emit Transfer(account, address(0), amount);
_afterTokenTransfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
*
* This internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/**
* @dev Updates `owner` s allowance for `spender` based on spent `amount`.
*
* Does not update the allowance amount in case of infinite allowance.
* Revert if not enough allowance is available.
*
* Might emit an {Approval} event.
*/
function _spendAllowance(address owner, address spender, uint256 amount) internal virtual {
uint256 currentAllowance = allowance(owner, spender);
if (currentAllowance != type(uint256).max) {
require(currentAllowance >= amount, "ERC20: insufficient allowance");
unchecked {
_approve(owner, spender, currentAllowance - amount);
}
}
}
/**
* @dev Hook that is called before any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* will be transferred to `to`.
* - when `from` is zero, `amount` tokens will be minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual {}
/**
* @dev Hook that is called after any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* has been transferred to `to`.
* - when `from` is zero, `amount` tokens have been minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens have been burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _afterTokenTransfer(address from, address to, uint256 amount) internal virtual {}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (security/ReentrancyGuard.sol)
pragma solidity ^0.8.0;
/**
* @dev Contract module that helps prevent reentrant calls to a function.
*
* Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
* available, which can be applied to functions to make sure there are no nested
* (reentrant) calls to them.
*
* Note that because there is a single `nonReentrant` guard, functions marked as
* `nonReentrant` may not call one another. This can be worked around by making
* those functions `private`, and then adding `external` `nonReentrant` entry
* points to them.
*
* TIP: If you would like to learn more about reentrancy and alternative ways
* to protect against it, check out our blog post
* https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
*/
abstract contract ReentrancyGuard {
// Booleans are more expensive than uint256 or any type that takes up a full
// word because each write operation emits an extra SLOAD to first read the
// slot's contents, replace the bits taken up by the boolean, and then write
// back. This is the compiler's defense against contract upgrades and
// pointer aliasing, and it cannot be disabled.
// The values being non-zero value makes deployment a bit more expensive,
// but in exchange the refund on every call to nonReentrant will be lower in
// amount. Since refunds are capped to a percentage of the total
// transaction's gas, it is best to keep them low in cases like this one, to
// increase the likelihood of the full refund coming into effect.
uint256 private constant _NOT_ENTERED = 1;
uint256 private constant _ENTERED = 2;
uint256 private _status;
constructor() {
_status = _NOT_ENTERED;
}
/**
* @dev Prevents a contract from calling itself, directly or indirectly.
* Calling a `nonReentrant` function from another `nonReentrant`
* function is not supported. It is possible to prevent this from happening
* by making the `nonReentrant` function external, and making it call a
* `private` function that does the actual work.
*/
modifier nonReentrant() {
_nonReentrantBefore();
_;
_nonReentrantAfter();
}
function _nonReentrantBefore() private {
// On the first call to nonReentrant, _status will be _NOT_ENTERED
require(_status != _ENTERED, "ReentrancyGuard: reentrant call");
// Any calls to nonReentrant after this point will fail
_status = _ENTERED;
}
function _nonReentrantAfter() private {
// By storing the original value once again, a refund is triggered (see
// https://eips.ethereum.org/EIPS/eip-2200)
_status = _NOT_ENTERED;
}
/**
* @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a
* `nonReentrant` function in the call stack.
*/
function _reentrancyGuardEntered() internal view returns (bool) {
return _status == _ENTERED;
}
}// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;
/// @title Callback for ICLPoolActions#swap
/// @notice Any contract that calls ICLPoolActions#swap must implement this interface
interface ICLSwapCallback {
/// @notice Called to `msg.sender` after executing a swap via ICLPool#swap.
/// @dev In the implementation you must pay the pool tokens owed for the swap.
/// The caller of this method must be checked to be a CLPool deployed by the canonical CLFactory.
/// amount0Delta and amount1Delta can both be 0 if no tokens were swapped.
/// @param amount0Delta The amount of token0 that was sent (negative) or must be received (positive) by the pool by
/// the end of the swap. If positive, the callback must send that amount of token0 to the pool.
/// @param amount1Delta The amount of token1 that was sent (negative) or must be received (positive) by the pool by
/// the end of the swap. If positive, the callback must send that amount of token1 to the pool.
/// @param data Any data passed through by the caller via the ICLPoolActions#swap call
function uniswapV3SwapCallback(int256 amount0Delta, int256 amount1Delta, bytes calldata data) external;
}// SPDX-License-Identifier: AGPL-3.0
pragma solidity 0.8.28;
abstract contract FluidStructs {
struct UserSupplyData {
bool modeWithInterest; // true if mode = with interest, false = without interest
uint256 supply; // user supply amount
// the withdrawal limit (e.g. if 10% is the limit, and 100M is supplied, it would be 90M)
uint256 withdrawalLimit;
uint256 lastUpdateTimestamp;
uint256 expandPercent; // withdrawal limit expand percent in 1e2
uint256 expandDuration; // withdrawal limit expand duration in seconds
uint256 baseWithdrawalLimit;
// the current actual max withdrawable amount (e.g. if 10% is the limit, and 100M is supplied, it would be 10M)
uint256 withdrawableUntilLimit;
uint256 withdrawable; // actual currently withdrawable amount (supply - withdrawal Limit) & considering balance
}
struct FTokenDetails {
address tokenAddress;
bool eip2612Deposits;
bool isNativeUnderlying;
string name;
string symbol;
uint256 decimals;
address asset;
uint256 totalAssets;
uint256 totalSupply;
uint256 convertToShares;
uint256 convertToAssets;
// additional yield from rewards, if active
uint256 rewardsRate;
// yield at Liquidity
uint256 supplyRate;
// difference between fToken assets & actual deposit at Liquidity. (supplyAtLiquidity - totalAssets).
// if negative, rewards must be funded to guarantee withdrawal is possible for all users. This happens
// by executing rebalance().
int256 rebalanceDifference;
// liquidity related data such as supply amount, limits, expansion etc.
UserSupplyData liquidityUserSupplyData;
}
struct OverallTokenData {
uint256 borrowRate;
uint256 supplyRate;
uint256 fee; // revenue fee
uint256 lastStoredUtilization;
uint256 storageUpdateThreshold;
uint256 lastUpdateTimestamp;
uint256 supplyExchangePrice;
uint256 borrowExchangePrice;
uint256 supplyRawInterest;
uint256 supplyInterestFree;
uint256 borrowRawInterest;
uint256 borrowInterestFree;
uint256 totalSupply;
uint256 totalBorrow;
uint256 revenue;
uint256 maxUtilization; // maximum allowed utilization
RateData rateData;
}
struct RateData {
uint256 version;
RateDataV1Params rateDataV1;
RateDataV2Params rateDataV2;
}
/// @notice struct to set borrow rate data for version 1
struct RateDataV1Params {
///
/// @param token for rate data
address token;
///
/// @param kink in borrow rate. in 1e2: 100% = 10_000; 1% = 100
/// utilization below kink usually means slow increase in rate, once utilization is above kink borrow rate increases fast
uint256 kink;
///
/// @param rateAtUtilizationZero desired borrow rate when utilization is zero. in 1e2: 100% = 10_000; 1% = 100
/// i.e. constant minimum borrow rate
/// e.g. at utilization = 0.01% rate could still be at least 4% (rateAtUtilizationZero would be 400 then)
uint256 rateAtUtilizationZero;
///
/// @param rateAtUtilizationKink borrow rate when utilization is at kink. in 1e2: 100% = 10_000; 1% = 100
/// e.g. when rate should be 7% at kink then rateAtUtilizationKink would be 700
uint256 rateAtUtilizationKink;
///
/// @param rateAtUtilizationMax borrow rate when utilization is maximum at 100%. in 1e2: 100% = 10_000; 1% = 100
/// e.g. when rate should be 125% at 100% then rateAtUtilizationMax would be 12_500
uint256 rateAtUtilizationMax;
}
/// @notice struct to set borrow rate data for version 2
struct RateDataV2Params {
///
/// @param token for rate data
address token;
///
/// @param kink1 first kink in borrow rate. in 1e2: 100% = 10_000; 1% = 100
/// utilization below kink 1 usually means slow increase in rate, once utilization is above kink 1 borrow rate increases faster
uint256 kink1;
///
/// @param kink2 second kink in borrow rate. in 1e2: 100% = 10_000; 1% = 100
/// utilization below kink 2 usually means slow / medium increase in rate, once utilization is above kink 2 borrow rate increases fast
uint256 kink2;
///
/// @param rateAtUtilizationZero desired borrow rate when utilization is zero. in 1e2: 100% = 10_000; 1% = 100
/// i.e. constant minimum borrow rate
/// e.g. at utilization = 0.01% rate could still be at least 4% (rateAtUtilizationZero would be 400 then)
uint256 rateAtUtilizationZero;
///
/// @param rateAtUtilizationKink1 desired borrow rate when utilization is at first kink. in 1e2: 100% = 10_000; 1% = 100
/// e.g. when rate should be 7% at first kink then rateAtUtilizationKink would be 700
uint256 rateAtUtilizationKink1;
///
/// @param rateAtUtilizationKink2 desired borrow rate when utilization is at second kink. in 1e2: 100% = 10_000; 1% = 100
/// e.g. when rate should be 7% at second kink then rateAtUtilizationKink would be 1_200
uint256 rateAtUtilizationKink2;
///
/// @param rateAtUtilizationMax desired borrow rate when utilization is maximum at 100%. in 1e2: 100% = 10_000; 1% = 100
/// e.g. when rate should be 125% at 100% then rateAtUtilizationMax would be 12_500
uint256 rateAtUtilizationMax;
}
}// SPDX-License-Identifier: AGPL-3.0
pragma solidity >=0.8.18;
import {ERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import {IERC4626} from "@openzeppelin/contracts/interfaces/IERC4626.sol";
import {IERC20Permit} from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Permit.sol";
// Interface that implements the 4626 standard and the implementation functions
interface ITokenizedStrategy is IERC4626, IERC20Permit {
/*//////////////////////////////////////////////////////////////
EVENTS
//////////////////////////////////////////////////////////////*/
event StrategyShutdown();
event NewTokenizedStrategy(
address indexed strategy,
address indexed asset,
string apiVersion
);
event Reported(
uint256 profit,
uint256 loss,
uint256 protocolFees,
uint256 performanceFees
);
event UpdatePerformanceFeeRecipient(
address indexed newPerformanceFeeRecipient
);
event UpdateKeeper(address indexed newKeeper);
event UpdatePerformanceFee(uint16 newPerformanceFee);
event UpdateManagement(address indexed newManagement);
event UpdateEmergencyAdmin(address indexed newEmergencyAdmin);
event UpdateProfitMaxUnlockTime(uint256 newProfitMaxUnlockTime);
event UpdatePendingManagement(address indexed newPendingManagement);
/*//////////////////////////////////////////////////////////////
INITIALIZATION
//////////////////////////////////////////////////////////////*/
function initialize(
address _asset,
string memory _name,
address _management,
address _performanceFeeRecipient,
address _keeper
) external;
/*//////////////////////////////////////////////////////////////
NON-STANDARD 4626 OPTIONS
//////////////////////////////////////////////////////////////*/
function withdraw(
uint256 assets,
address receiver,
address owner,
uint256 maxLoss
) external returns (uint256);
function redeem(
uint256 shares,
address receiver,
address owner,
uint256 maxLoss
) external returns (uint256);
function maxWithdraw(
address owner,
uint256 /*maxLoss*/
) external view returns (uint256);
function maxRedeem(
address owner,
uint256 /*maxLoss*/
) external view returns (uint256);
/*//////////////////////////////////////////////////////////////
MODIFIER HELPERS
//////////////////////////////////////////////////////////////*/
function requireManagement(address _sender) external view;
function requireKeeperOrManagement(address _sender) external view;
function requireEmergencyAuthorized(address _sender) external view;
/*//////////////////////////////////////////////////////////////
KEEPERS FUNCTIONS
//////////////////////////////////////////////////////////////*/
function tend() external;
function report() external returns (uint256 _profit, uint256 _loss);
/*//////////////////////////////////////////////////////////////
CONSTANTS
//////////////////////////////////////////////////////////////*/
function MAX_FEE() external view returns (uint16);
function FACTORY() external view returns (address);
/*//////////////////////////////////////////////////////////////
GETTERS
//////////////////////////////////////////////////////////////*/
function apiVersion() external view returns (string memory);
function pricePerShare() external view returns (uint256);
function management() external view returns (address);
function pendingManagement() external view returns (address);
function keeper() external view returns (address);
function emergencyAdmin() external view returns (address);
function performanceFee() external view returns (uint16);
function performanceFeeRecipient() external view returns (address);
function fullProfitUnlockDate() external view returns (uint256);
function profitUnlockingRate() external view returns (uint256);
function profitMaxUnlockTime() external view returns (uint256);
function lastReport() external view returns (uint256);
function isShutdown() external view returns (bool);
function unlockedShares() external view returns (uint256);
/*//////////////////////////////////////////////////////////////
SETTERS
//////////////////////////////////////////////////////////////*/
function setPendingManagement(address) external;
function acceptManagement() external;
function setKeeper(address _keeper) external;
function setEmergencyAdmin(address _emergencyAdmin) external;
function setPerformanceFee(uint16 _performanceFee) external;
function setPerformanceFeeRecipient(
address _performanceFeeRecipient
) external;
function setProfitMaxUnlockTime(uint256 _profitMaxUnlockTime) external;
function setName(string calldata _newName) external;
function shutdownStrategy() external;
function emergencyWithdraw(uint256 _amount) external;
}// SPDX-License-Identifier: AGPL-3.0
pragma solidity >=0.8.18;
interface IBaseStrategy {
function tokenizedStrategyAddress() external view returns (address);
/*//////////////////////////////////////////////////////////////
IMMUTABLE FUNCTIONS
//////////////////////////////////////////////////////////////*/
function availableDepositLimit(
address _owner
) external view returns (uint256);
function availableWithdrawLimit(
address _owner
) external view returns (uint256);
function deployFunds(uint256 _assets) external;
function freeFunds(uint256 _amount) external;
function harvestAndReport() external returns (uint256);
function tendThis(uint256 _totalIdle) external;
function shutdownWithdraw(uint256 _amount) external;
function tendTrigger() external view returns (bool, bytes memory);
}// SPDX-License-Identifier: AGPL-3.0
pragma solidity >=0.8.18;
import {ERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
// TokenizedStrategy interface used for internal view delegateCalls.
import {ITokenizedStrategy} from "./interfaces/ITokenizedStrategy.sol";
/**
* @title YearnV3 Base Strategy
* @author yearn.finance
* @notice
* BaseStrategy implements all of the required functionality to
* seamlessly integrate with the `TokenizedStrategy` implementation contract
* allowing anyone to easily build a fully permissionless ERC-4626 compliant
* Vault by inheriting this contract and overriding three simple functions.
* It utilizes an immutable proxy pattern that allows the BaseStrategy
* to remain simple and small. All standard logic is held within the
* `TokenizedStrategy` and is reused over any n strategies all using the
* `fallback` function to delegatecall the implementation so that strategists
* can only be concerned with writing their strategy specific code.
*
* This contract should be inherited and the three main abstract methods
* `_deployFunds`, `_freeFunds` and `_harvestAndReport` implemented to adapt
* the Strategy to the particular needs it has to generate yield. There are
* other optional methods that can be implemented to further customize
* the strategy if desired.
*
* All default storage for the strategy is controlled and updated by the
* `TokenizedStrategy`. The implementation holds a storage struct that
* contains all needed global variables in a manual storage slot. This
* means strategists can feel free to implement their own custom storage
* variables as they need with no concern of collisions. All global variables
* can be viewed within the Strategy by a simple call using the
* `TokenizedStrategy` variable. IE: TokenizedStrategy.globalVariable();.
*/
abstract contract BaseStrategy {
/*//////////////////////////////////////////////////////////////
MODIFIERS
//////////////////////////////////////////////////////////////*/
/**
* @dev Used on TokenizedStrategy callback functions to make sure it is post
* a delegateCall from this address to the TokenizedStrategy.
*/
modifier onlySelf() {
_onlySelf();
_;
}
/**
* @dev Use to assure that the call is coming from the strategies management.
*/
modifier onlyManagement() {
TokenizedStrategy.requireManagement(msg.sender);
_;
}
/**
* @dev Use to assure that the call is coming from either the strategies
* management or the keeper.
*/
modifier onlyKeepers() {
TokenizedStrategy.requireKeeperOrManagement(msg.sender);
_;
}
/**
* @dev Use to assure that the call is coming from either the strategies
* management or the emergency admin.
*/
modifier onlyEmergencyAuthorized() {
TokenizedStrategy.requireEmergencyAuthorized(msg.sender);
_;
}
/**
* @dev Require that the msg.sender is this address.
*/
function _onlySelf() internal view {
require(msg.sender == address(this), "!self");
}
/*//////////////////////////////////////////////////////////////
CONSTANTS
//////////////////////////////////////////////////////////////*/
/**
* @dev This is the address of the TokenizedStrategy implementation
* contract that will be used by all strategies to handle the
* accounting, logic, storage etc.
*
* Any external calls to the that don't hit one of the functions
* defined in this base or the strategy will end up being forwarded
* through the fallback function, which will delegateCall this address.
*
* This address should be the same for every strategy, never be adjusted
* and always be checked before any integration with the Strategy.
*/
address public constant tokenizedStrategyAddress =
0xD377919FA87120584B21279a491F82D5265A139c;
/*//////////////////////////////////////////////////////////////
IMMUTABLES
//////////////////////////////////////////////////////////////*/
/**
* @dev Underlying asset the Strategy is earning yield on.
* Stored here for cheap retrievals within the strategy.
*/
ERC20 internal immutable asset;
/**
* @dev This variable is set to address(this) during initialization of each strategy.
*
* This can be used to retrieve storage data within the strategy
* contract as if it were a linked library.
*
* i.e. uint256 totalAssets = TokenizedStrategy.totalAssets()
*
* Using address(this) will mean any calls using this variable will lead
* to a call to itself. Which will hit the fallback function and
* delegateCall that to the actual TokenizedStrategy.
*/
ITokenizedStrategy internal immutable TokenizedStrategy;
/**
* @notice Used to initialize the strategy on deployment.
*
* This will set the `TokenizedStrategy` variable for easy
* internal view calls to the implementation. As well as
* initializing the default storage variables based on the
* parameters and using the deployer for the permissioned roles.
*
* @param _asset Address of the underlying asset.
* @param _name Name the strategy will use.
*/
constructor(address _asset, string memory _name) {
asset = ERC20(_asset);
// Set instance of the implementation for internal use.
TokenizedStrategy = ITokenizedStrategy(address(this));
// Initialize the strategy's storage variables.
_delegateCall(
abi.encodeCall(
ITokenizedStrategy.initialize,
(_asset, _name, msg.sender, msg.sender, msg.sender)
)
);
// Store the tokenizedStrategyAddress at the standard implementation
// address storage slot so etherscan picks up the interface. This gets
// stored on initialization and never updated.
assembly {
sstore(
// keccak256('eip1967.proxy.implementation' - 1)
0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc,
tokenizedStrategyAddress
)
}
}
/*//////////////////////////////////////////////////////////////
NEEDED TO BE OVERRIDDEN BY STRATEGIST
//////////////////////////////////////////////////////////////*/
/**
* @dev Can deploy up to '_amount' of 'asset' in the yield source.
*
* This function is called at the end of a {deposit} or {mint}
* call. Meaning that unless a whitelist is implemented it will
* be entirely permissionless and thus can be sandwiched or otherwise
* manipulated.
*
* @param _amount The amount of 'asset' that the strategy can attempt
* to deposit in the yield source.
*/
function _deployFunds(uint256 _amount) internal virtual;
/**
* @dev Should attempt to free the '_amount' of 'asset'.
*
* NOTE: The amount of 'asset' that is already loose has already
* been accounted for.
*
* This function is called during {withdraw} and {redeem} calls.
* Meaning that unless a whitelist is implemented it will be
* entirely permissionless and thus can be sandwiched or otherwise
* manipulated.
*
* Should not rely on asset.balanceOf(address(this)) calls other than
* for diff accounting purposes.
*
* Any difference between `_amount` and what is actually freed will be
* counted as a loss and passed on to the withdrawer. This means
* care should be taken in times of illiquidity. It may be better to revert
* if withdraws are simply illiquid so not to realize incorrect losses.
*
* @param _amount, The amount of 'asset' to be freed.
*/
function _freeFunds(uint256 _amount) internal virtual;
/**
* @dev Internal function to harvest all rewards, redeploy any idle
* funds and return an accurate accounting of all funds currently
* held by the Strategy.
*
* This should do any needed harvesting, rewards selling, accrual,
* redepositing etc. to get the most accurate view of current assets.
*
* NOTE: All applicable assets including loose assets should be
* accounted for in this function.
*
* Care should be taken when relying on oracles or swap values rather
* than actual amounts as all Strategy profit/loss accounting will
* be done based on this returned value.
*
* This can still be called post a shutdown, a strategist can check
* `TokenizedStrategy.isShutdown()` to decide if funds should be
* redeployed or simply realize any profits/losses.
*
* @return _totalAssets A trusted and accurate account for the total
* amount of 'asset' the strategy currently holds including idle funds.
*/
function _harvestAndReport()
internal
virtual
returns (uint256 _totalAssets);
/*//////////////////////////////////////////////////////////////
OPTIONAL TO OVERRIDE BY STRATEGIST
//////////////////////////////////////////////////////////////*/
/**
* @dev Optional function for strategist to override that can
* be called in between reports.
*
* If '_tend' is used tendTrigger() will also need to be overridden.
*
* This call can only be called by a permissioned role so may be
* through protected relays.
*
* This can be used to harvest and compound rewards, deposit idle funds,
* perform needed position maintenance or anything else that doesn't need
* a full report for.
*
* EX: A strategy that can not deposit funds without getting
* sandwiched can use the tend when a certain threshold
* of idle to totalAssets has been reached.
*
* This will have no effect on PPS of the strategy till report() is called.
*
* @param _totalIdle The current amount of idle funds that are available to deploy.
*/
function _tend(uint256 _totalIdle) internal virtual {}
/**
* @dev Optional trigger to override if tend() will be used by the strategy.
* This must be implemented if the strategy hopes to invoke _tend().
*
* @return . Should return true if tend() should be called by keeper or false if not.
*/
function _tendTrigger() internal view virtual returns (bool) {
return false;
}
/**
* @notice Returns if tend() should be called by a keeper.
*
* @return . Should return true if tend() should be called by keeper or false if not.
* @return . Calldata for the tend call.
*/
function tendTrigger() external view virtual returns (bool, bytes memory) {
return (
// Return the status of the tend trigger.
_tendTrigger(),
// And the needed calldata either way.
abi.encodeWithSelector(ITokenizedStrategy.tend.selector)
);
}
/**
* @notice Gets the max amount of `asset` that an address can deposit.
* @dev Defaults to an unlimited amount for any address. But can
* be overridden by strategists.
*
* This function will be called before any deposit or mints to enforce
* any limits desired by the strategist. This can be used for either a
* traditional deposit limit or for implementing a whitelist etc.
*
* EX:
* if(isAllowed[_owner]) return super.availableDepositLimit(_owner);
*
* This does not need to take into account any conversion rates
* from shares to assets. But should know that any non max uint256
* amounts may be converted to shares. So it is recommended to keep
* custom amounts low enough as not to cause overflow when multiplied
* by `totalSupply`.
*
* @param . The address that is depositing into the strategy.
* @return . The available amount the `_owner` can deposit in terms of `asset`
*/
function availableDepositLimit(
address /*_owner*/
) public view virtual returns (uint256) {
return type(uint256).max;
}
/**
* @notice Gets the max amount of `asset` that can be withdrawn.
* @dev Defaults to an unlimited amount for any address. But can
* be overridden by strategists.
*
* This function will be called before any withdraw or redeem to enforce
* any limits desired by the strategist. This can be used for illiquid
* or sandwichable strategies. It should never be lower than `totalIdle`.
*
* EX:
* return TokenIzedStrategy.totalIdle();
*
* This does not need to take into account the `_owner`'s share balance
* or conversion rates from shares to assets.
*
* @param . The address that is withdrawing from the strategy.
* @return . The available amount that can be withdrawn in terms of `asset`
*/
function availableWithdrawLimit(
address /*_owner*/
) public view virtual returns (uint256) {
return type(uint256).max;
}
/**
* @dev Optional function for a strategist to override that will
* allow management to manually withdraw deployed funds from the
* yield source if a strategy is shutdown.
*
* This should attempt to free `_amount`, noting that `_amount` may
* be more than is currently deployed.
*
* NOTE: This will not realize any profits or losses. A separate
* {report} will be needed in order to record any profit/loss. If
* a report may need to be called after a shutdown it is important
* to check if the strategy is shutdown during {_harvestAndReport}
* so that it does not simply re-deploy all funds that had been freed.
*
* EX:
* if(freeAsset > 0 && !TokenizedStrategy.isShutdown()) {
* depositFunds...
* }
*
* @param _amount The amount of asset to attempt to free.
*/
function _emergencyWithdraw(uint256 _amount) internal virtual {}
/*//////////////////////////////////////////////////////////////
TokenizedStrategy HOOKS
//////////////////////////////////////////////////////////////*/
/**
* @notice Can deploy up to '_amount' of 'asset' in yield source.
* @dev Callback for the TokenizedStrategy to call during a {deposit}
* or {mint} to tell the strategy it can deploy funds.
*
* Since this can only be called after a {deposit} or {mint}
* delegateCall to the TokenizedStrategy msg.sender == address(this).
*
* Unless a whitelist is implemented this will be entirely permissionless
* and thus can be sandwiched or otherwise manipulated.
*
* @param _amount The amount of 'asset' that the strategy can
* attempt to deposit in the yield source.
*/
function deployFunds(uint256 _amount) external virtual onlySelf {
_deployFunds(_amount);
}
/**
* @notice Should attempt to free the '_amount' of 'asset'.
* @dev Callback for the TokenizedStrategy to call during a withdraw
* or redeem to free the needed funds to service the withdraw.
*
* This can only be called after a 'withdraw' or 'redeem' delegateCall
* to the TokenizedStrategy so msg.sender == address(this).
*
* @param _amount The amount of 'asset' that the strategy should attempt to free up.
*/
function freeFunds(uint256 _amount) external virtual onlySelf {
_freeFunds(_amount);
}
/**
* @notice Returns the accurate amount of all funds currently
* held by the Strategy.
* @dev Callback for the TokenizedStrategy to call during a report to
* get an accurate accounting of assets the strategy controls.
*
* This can only be called after a report() delegateCall to the
* TokenizedStrategy so msg.sender == address(this).
*
* @return . A trusted and accurate account for the total amount
* of 'asset' the strategy currently holds including idle funds.
*/
function harvestAndReport() external virtual onlySelf returns (uint256) {
return _harvestAndReport();
}
/**
* @notice Will call the internal '_tend' when a keeper tends the strategy.
* @dev Callback for the TokenizedStrategy to initiate a _tend call in the strategy.
*
* This can only be called after a tend() delegateCall to the TokenizedStrategy
* so msg.sender == address(this).
*
* We name the function `tendThis` so that `tend` calls are forwarded to
* the TokenizedStrategy.
* @param _totalIdle The amount of current idle funds that can be
* deployed during the tend
*/
function tendThis(uint256 _totalIdle) external virtual onlySelf {
_tend(_totalIdle);
}
/**
* @notice Will call the internal '_emergencyWithdraw' function.
* @dev Callback for the TokenizedStrategy during an emergency withdraw.
*
* This can only be called after a emergencyWithdraw() delegateCall to
* the TokenizedStrategy so msg.sender == address(this).
*
* We name the function `shutdownWithdraw` so that `emergencyWithdraw`
* calls are forwarded to the TokenizedStrategy.
*
* @param _amount The amount of asset to attempt to free.
*/
function shutdownWithdraw(uint256 _amount) external virtual onlySelf {
_emergencyWithdraw(_amount);
}
/**
* @dev Function used to delegate call the TokenizedStrategy with
* certain `_calldata` and return any return values.
*
* This is used to setup the initial storage of the strategy, and
* can be used by strategist to forward any other call to the
* TokenizedStrategy implementation.
*
* @param _calldata The abi encoded calldata to use in delegatecall.
* @return . The return value if the call was successful in bytes.
*/
function _delegateCall(
bytes memory _calldata
) internal returns (bytes memory) {
// Delegate call the tokenized strategy with provided calldata.
(bool success, bytes memory result) = tokenizedStrategyAddress
.delegatecall(_calldata);
// If the call reverted. Return the error.
if (!success) {
assembly {
let ptr := mload(0x40)
let size := returndatasize()
returndatacopy(ptr, 0, size)
revert(ptr, size)
}
}
// Return the result.
return result;
}
/**
* @dev Execute a function on the TokenizedStrategy and return any value.
*
* This fallback function will be executed when any of the standard functions
* defined in the TokenizedStrategy are called since they wont be defined in
* this contract.
*
* It will delegatecall the TokenizedStrategy implementation with the exact
* calldata and return any relevant values.
*
*/
fallback() external {
// load our target address
address _tokenizedStrategyAddress = tokenizedStrategyAddress;
// Execute external function using delegatecall and return any value.
assembly {
// Copy function selector and any arguments.
calldatacopy(0, 0, calldatasize())
// Execute function delegatecall.
let result := delegatecall(
gas(),
_tokenizedStrategyAddress,
0,
calldatasize(),
0,
0
)
// Get any return value
returndatacopy(0, 0, returndatasize())
// Return any return value or error back to the caller
switch result
case 0 {
revert(0, returndatasize())
}
default {
return(0, returndatasize())
}
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `to`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address to, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `from` to `to` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address from, address to, uint256 amount) external returns (bool);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.4) (token/ERC20/extensions/IERC20Permit.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
* https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
*
* Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
* presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't
* need to send a transaction, and thus is not required to hold Ether at all.
*
* ==== Security Considerations
*
* There are two important considerations concerning the use of `permit`. The first is that a valid permit signature
* expresses an allowance, and it should not be assumed to convey additional meaning. In particular, it should not be
* considered as an intention to spend the allowance in any specific way. The second is that because permits have
* built-in replay protection and can be submitted by anyone, they can be frontrun. A protocol that uses permits should
* take this into consideration and allow a `permit` call to fail. Combining these two aspects, a pattern that may be
* generally recommended is:
*
* ```solidity
* function doThingWithPermit(..., uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public {
* try token.permit(msg.sender, address(this), value, deadline, v, r, s) {} catch {}
* doThing(..., value);
* }
*
* function doThing(..., uint256 value) public {
* token.safeTransferFrom(msg.sender, address(this), value);
* ...
* }
* ```
*
* Observe that: 1) `msg.sender` is used as the owner, leaving no ambiguity as to the signer intent, and 2) the use of
* `try/catch` allows the permit to fail and makes the code tolerant to frontrunning. (See also
* {SafeERC20-safeTransferFrom}).
*
* Additionally, note that smart contract wallets (such as Argent or Safe) are not able to produce permit signatures, so
* contracts should have entry points that don't rely on permit.
*/
interface IERC20Permit {
/**
* @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,
* given ``owner``'s signed approval.
*
* IMPORTANT: The same issues {IERC20-approve} has related to transaction
* ordering also apply here.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `deadline` must be a timestamp in the future.
* - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`
* over the EIP712-formatted function arguments.
* - the signature must use ``owner``'s current nonce (see {nonces}).
*
* For more information on the signature format, see the
* https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP
* section].
*
* CAUTION: See Security Considerations above.
*/
function permit(
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) external;
/**
* @dev Returns the current nonce for `owner`. This value must be
* included whenever a signature is generated for {permit}.
*
* Every successful call to {permit} increases ``owner``'s nonce by one. This
* prevents a signature from being used multiple times.
*/
function nonces(address owner) external view returns (uint256);
/**
* @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.
*/
// solhint-disable-next-line func-name-mixedcase
function DOMAIN_SEPARATOR() external view returns (bytes32);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol)
pragma solidity ^0.8.1;
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
*
* Furthermore, `isContract` will also return true if the target contract within
* the same transaction is already scheduled for destruction by `SELFDESTRUCT`,
* which only has an effect at the end of a transaction.
* ====
*
* [IMPORTANT]
* ====
* You shouldn't rely on `isContract` to protect against flash loan attacks!
*
* Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
* like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
* constructor.
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize/address.code.length, which returns 0
// for contracts in construction, since the code is only stored at the end
// of the constructor execution.
return account.code.length > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.8.0/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory errorMessage
) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(
address target,
bytes memory data,
string memory errorMessage
) internal view returns (bytes memory) {
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling
* the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.
*
* _Available since v4.8._
*/
function verifyCallResultFromTarget(
address target,
bool success,
bytes memory returndata,
string memory errorMessage
) internal view returns (bytes memory) {
if (success) {
if (returndata.length == 0) {
// only check isContract if the call was successful and the return data is empty
// otherwise we already know that it was a contract
require(isContract(target), "Address: call to non-contract");
}
return returndata;
} else {
_revert(returndata, errorMessage);
}
}
/**
* @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the
* revert reason or using the provided one.
*
* _Available since v4.3._
*/
function verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) internal pure returns (bytes memory) {
if (success) {
return returndata;
} else {
_revert(returndata, errorMessage);
}
}
function _revert(bytes memory returndata, string memory errorMessage) private pure {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
/// @solidity memory-safe-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}// SPDX-License-Identifier: AGPL-3.0
pragma solidity >=0.8.18;
contract Governance {
/// @notice Emitted when the governance address is updated.
event GovernanceTransferred(
address indexed previousGovernance,
address indexed newGovernance
);
modifier onlyGovernance() {
_checkGovernance();
_;
}
/// @notice Checks if the msg sender is the governance.
function _checkGovernance() internal view virtual {
require(governance == msg.sender, "!governance");
}
/// @notice Address that can set the default base fee and provider
address public governance;
constructor(address _governance) {
governance = _governance;
emit GovernanceTransferred(address(0), _governance);
}
/**
* @notice Sets a new address as the governance of the contract.
* @dev Throws if the caller is not current governance.
* @param _newGovernance The new governance address.
*/
function transferGovernance(
address _newGovernance
) external virtual onlyGovernance {
require(_newGovernance != address(0), "ZERO ADDRESS");
address oldGovernance = governance;
governance = _newGovernance;
emit GovernanceTransferred(oldGovernance, _newGovernance);
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)
pragma solidity ^0.8.0;
import "../IERC20.sol";
/**
* @dev Interface for the optional metadata functions from the ERC20 standard.
*
* _Available since v4.1._
*/
interface IERC20Metadata is IERC20 {
/**
* @dev Returns the name of the token.
*/
function name() external view returns (string memory);
/**
* @dev Returns the symbol of the token.
*/
function symbol() external view returns (string memory);
/**
* @dev Returns the decimals places of the token.
*/
function decimals() external view returns (uint8);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.4) (utils/Context.sol)
pragma solidity ^0.8.0;
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
function _contextSuffixLength() internal view virtual returns (uint256) {
return 0;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (interfaces/IERC4626.sol)
pragma solidity ^0.8.0;
import "../token/ERC20/IERC20.sol";
import "../token/ERC20/extensions/IERC20Metadata.sol";
/**
* @dev Interface of the ERC4626 "Tokenized Vault Standard", as defined in
* https://eips.ethereum.org/EIPS/eip-4626[ERC-4626].
*
* _Available since v4.7._
*/
interface IERC4626 is IERC20, IERC20Metadata {
event Deposit(address indexed sender, address indexed owner, uint256 assets, uint256 shares);
event Withdraw(
address indexed sender,
address indexed receiver,
address indexed owner,
uint256 assets,
uint256 shares
);
/**
* @dev Returns the address of the underlying token used for the Vault for accounting, depositing, and withdrawing.
*
* - MUST be an ERC-20 token contract.
* - MUST NOT revert.
*/
function asset() external view returns (address assetTokenAddress);
/**
* @dev Returns the total amount of the underlying asset that is “managed” by Vault.
*
* - SHOULD include any compounding that occurs from yield.
* - MUST be inclusive of any fees that are charged against assets in the Vault.
* - MUST NOT revert.
*/
function totalAssets() external view returns (uint256 totalManagedAssets);
/**
* @dev Returns the amount of shares that the Vault would exchange for the amount of assets provided, in an ideal
* scenario where all the conditions are met.
*
* - MUST NOT be inclusive of any fees that are charged against assets in the Vault.
* - MUST NOT show any variations depending on the caller.
* - MUST NOT reflect slippage or other on-chain conditions, when performing the actual exchange.
* - MUST NOT revert.
*
* NOTE: This calculation MAY NOT reflect the “per-user” price-per-share, and instead should reflect the
* “average-user’s” price-per-share, meaning what the average user should expect to see when exchanging to and
* from.
*/
function convertToShares(uint256 assets) external view returns (uint256 shares);
/**
* @dev Returns the amount of assets that the Vault would exchange for the amount of shares provided, in an ideal
* scenario where all the conditions are met.
*
* - MUST NOT be inclusive of any fees that are charged against assets in the Vault.
* - MUST NOT show any variations depending on the caller.
* - MUST NOT reflect slippage or other on-chain conditions, when performing the actual exchange.
* - MUST NOT revert.
*
* NOTE: This calculation MAY NOT reflect the “per-user” price-per-share, and instead should reflect the
* “average-user’s” price-per-share, meaning what the average user should expect to see when exchanging to and
* from.
*/
function convertToAssets(uint256 shares) external view returns (uint256 assets);
/**
* @dev Returns the maximum amount of the underlying asset that can be deposited into the Vault for the receiver,
* through a deposit call.
*
* - MUST return a limited value if receiver is subject to some deposit limit.
* - MUST return 2 ** 256 - 1 if there is no limit on the maximum amount of assets that may be deposited.
* - MUST NOT revert.
*/
function maxDeposit(address receiver) external view returns (uint256 maxAssets);
/**
* @dev Allows an on-chain or off-chain user to simulate the effects of their deposit at the current block, given
* current on-chain conditions.
*
* - MUST return as close to and no more than the exact amount of Vault shares that would be minted in a deposit
* call in the same transaction. I.e. deposit should return the same or more shares as previewDeposit if called
* in the same transaction.
* - MUST NOT account for deposit limits like those returned from maxDeposit and should always act as though the
* deposit would be accepted, regardless if the user has enough tokens approved, etc.
* - MUST be inclusive of deposit fees. Integrators should be aware of the existence of deposit fees.
* - MUST NOT revert.
*
* NOTE: any unfavorable discrepancy between convertToShares and previewDeposit SHOULD be considered slippage in
* share price or some other type of condition, meaning the depositor will lose assets by depositing.
*/
function previewDeposit(uint256 assets) external view returns (uint256 shares);
/**
* @dev Mints shares Vault shares to receiver by depositing exactly amount of underlying tokens.
*
* - MUST emit the Deposit event.
* - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the
* deposit execution, and are accounted for during deposit.
* - MUST revert if all of assets cannot be deposited (due to deposit limit being reached, slippage, the user not
* approving enough underlying tokens to the Vault contract, etc).
*
* NOTE: most implementations will require pre-approval of the Vault with the Vault’s underlying asset token.
*/
function deposit(uint256 assets, address receiver) external returns (uint256 shares);
/**
* @dev Returns the maximum amount of the Vault shares that can be minted for the receiver, through a mint call.
* - MUST return a limited value if receiver is subject to some mint limit.
* - MUST return 2 ** 256 - 1 if there is no limit on the maximum amount of shares that may be minted.
* - MUST NOT revert.
*/
function maxMint(address receiver) external view returns (uint256 maxShares);
/**
* @dev Allows an on-chain or off-chain user to simulate the effects of their mint at the current block, given
* current on-chain conditions.
*
* - MUST return as close to and no fewer than the exact amount of assets that would be deposited in a mint call
* in the same transaction. I.e. mint should return the same or fewer assets as previewMint if called in the
* same transaction.
* - MUST NOT account for mint limits like those returned from maxMint and should always act as though the mint
* would be accepted, regardless if the user has enough tokens approved, etc.
* - MUST be inclusive of deposit fees. Integrators should be aware of the existence of deposit fees.
* - MUST NOT revert.
*
* NOTE: any unfavorable discrepancy between convertToAssets and previewMint SHOULD be considered slippage in
* share price or some other type of condition, meaning the depositor will lose assets by minting.
*/
function previewMint(uint256 shares) external view returns (uint256 assets);
/**
* @dev Mints exactly shares Vault shares to receiver by depositing amount of underlying tokens.
*
* - MUST emit the Deposit event.
* - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the mint
* execution, and are accounted for during mint.
* - MUST revert if all of shares cannot be minted (due to deposit limit being reached, slippage, the user not
* approving enough underlying tokens to the Vault contract, etc).
*
* NOTE: most implementations will require pre-approval of the Vault with the Vault’s underlying asset token.
*/
function mint(uint256 shares, address receiver) external returns (uint256 assets);
/**
* @dev Returns the maximum amount of the underlying asset that can be withdrawn from the owner balance in the
* Vault, through a withdraw call.
*
* - MUST return a limited value if owner is subject to some withdrawal limit or timelock.
* - MUST NOT revert.
*/
function maxWithdraw(address owner) external view returns (uint256 maxAssets);
/**
* @dev Allows an on-chain or off-chain user to simulate the effects of their withdrawal at the current block,
* given current on-chain conditions.
*
* - MUST return as close to and no fewer than the exact amount of Vault shares that would be burned in a withdraw
* call in the same transaction. I.e. withdraw should return the same or fewer shares as previewWithdraw if
* called
* in the same transaction.
* - MUST NOT account for withdrawal limits like those returned from maxWithdraw and should always act as though
* the withdrawal would be accepted, regardless if the user has enough shares, etc.
* - MUST be inclusive of withdrawal fees. Integrators should be aware of the existence of withdrawal fees.
* - MUST NOT revert.
*
* NOTE: any unfavorable discrepancy between convertToShares and previewWithdraw SHOULD be considered slippage in
* share price or some other type of condition, meaning the depositor will lose assets by depositing.
*/
function previewWithdraw(uint256 assets) external view returns (uint256 shares);
/**
* @dev Burns shares from owner and sends exactly assets of underlying tokens to receiver.
*
* - MUST emit the Withdraw event.
* - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the
* withdraw execution, and are accounted for during withdraw.
* - MUST revert if all of assets cannot be withdrawn (due to withdrawal limit being reached, slippage, the owner
* not having enough shares, etc).
*
* Note that some implementations will require pre-requesting to the Vault before a withdrawal may be performed.
* Those methods should be performed separately.
*/
function withdraw(uint256 assets, address receiver, address owner) external returns (uint256 shares);
/**
* @dev Returns the maximum amount of Vault shares that can be redeemed from the owner balance in the Vault,
* through a redeem call.
*
* - MUST return a limited value if owner is subject to some withdrawal limit or timelock.
* - MUST return balanceOf(owner) if owner is not subject to any withdrawal limit or timelock.
* - MUST NOT revert.
*/
function maxRedeem(address owner) external view returns (uint256 maxShares);
/**
* @dev Allows an on-chain or off-chain user to simulate the effects of their redeemption at the current block,
* given current on-chain conditions.
*
* - MUST return as close to and no more than the exact amount of assets that would be withdrawn in a redeem call
* in the same transaction. I.e. redeem should return the same or more assets as previewRedeem if called in the
* same transaction.
* - MUST NOT account for redemption limits like those returned from maxRedeem and should always act as though the
* redemption would be accepted, regardless if the user has enough shares, etc.
* - MUST be inclusive of withdrawal fees. Integrators should be aware of the existence of withdrawal fees.
* - MUST NOT revert.
*
* NOTE: any unfavorable discrepancy between convertToAssets and previewRedeem SHOULD be considered slippage in
* share price or some other type of condition, meaning the depositor will lose assets by redeeming.
*/
function previewRedeem(uint256 shares) external view returns (uint256 assets);
/**
* @dev Burns exactly shares from owner and sends assets of underlying tokens to receiver.
*
* - MUST emit the Withdraw event.
* - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the
* redeem execution, and are accounted for during redeem.
* - MUST revert if all of shares cannot be redeemed (due to withdrawal limit being reached, slippage, the owner
* not having enough shares, etc).
*
* NOTE: some implementations will require pre-requesting to the Vault before a withdrawal may be performed.
* Those methods should be performed separately.
*/
function redeem(uint256 shares, address receiver, address owner) external returns (uint256 assets);
}{
"remappings": [
"@openzeppelin/=lib/openzeppelin-contracts/",
"forge-std/=lib/forge-std/src/",
"@tokenized-strategy/=lib/tokenized-strategy/src/",
"@periphery/=lib/tokenized-strategy-periphery/src/",
"@uniswap-v3-core/=lib/v3-core/contracts/",
"@slipstream/=lib/slipstream/contracts/",
"@ensdomains/=lib/slipstream/node_modules/@ensdomains/",
"@nomad-xyz/=lib/slipstream/lib/ExcessivelySafeCall/",
"@solidity-parser/=lib/slipstream/node_modules/solhint/node_modules/@solidity-parser/",
"@uniswap/=lib/slipstream/lib/solidity-lib/",
"@yearn-vaults/=lib/tokenized-strategy-periphery/lib/yearn-vaults-v3/contracts/",
"ExcessivelySafeCall/=lib/slipstream/lib/ExcessivelySafeCall/src/",
"base64-sol/=lib/slipstream/lib/base64/",
"base64/=lib/slipstream/lib/base64/",
"ds-test/=lib/tokenized-strategy-periphery/lib/forge-std/lib/ds-test/src/",
"erc4626-tests/=lib/tokenized-strategy/lib/erc4626-tests/",
"hardhat/=lib/slipstream/node_modules/hardhat/",
"openzeppelin-contracts/=lib/openzeppelin-contracts/",
"openzeppelin/=lib/openzeppelin-contracts/contracts/",
"slipstream/=lib/slipstream/",
"solidity-lib/=lib/slipstream/lib/solidity-lib/contracts/",
"tokenized-strategy-periphery/=lib/tokenized-strategy-periphery/",
"tokenized-strategy/=lib/tokenized-strategy/",
"v3-core/=lib/v3-core/contracts/",
"yearn-vaults-v3/=lib/tokenized-strategy-periphery/lib/yearn-vaults-v3/"
],
"optimizer": {
"enabled": true,
"runs": 200
},
"metadata": {
"useLiteralContent": false,
"bytecodeHash": "ipfs",
"appendCBOR": true
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"evmVersion": "cancun",
"viaIR": false
}Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"inputs":[{"internalType":"address","name":"_asset","type":"address"},{"internalType":"string","name":"_name","type":"string"},{"internalType":"address","name":"_vault","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"stateMutability":"nonpayable","type":"fallback"},{"inputs":[],"name":"DUST","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"FLUID","outputs":[{"internalType":"contract ERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"FLUID_DEX","outputs":[{"internalType":"contract IFluidDex","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"SLIPSTREAM_ROUTER","outputs":[{"internalType":"contract ISwapRouter","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"USDC","outputs":[{"internalType":"contract ERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"WETH","outputs":[{"internalType":"contract ERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"allowed","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"auction","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_receiver","type":"address"}],"name":"availableDepositLimit","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"availableWithdrawLimit","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"balanceOfAsset","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"balanceOfRewards","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"balanceOfStake","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"balanceOfVault","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_recipient","type":"address"},{"internalType":"uint256","name":"_cumulativeAmount","type":"uint256"},{"internalType":"uint8","name":"_positionType","type":"uint8"},{"internalType":"bytes32","name":"_positionId","type":"bytes32"},{"internalType":"uint256","name":"_cycle","type":"uint256"},{"internalType":"bytes32[]","name":"_merkleProof","type":"bytes32[]"},{"internalType":"bytes","name":"_metadata","type":"bytes"}],"name":"claimRewards","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"deployFunds","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"doHealthCheck","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"freeFunds","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"harvestAndReport","outputs":[{"internalType":"uint256","name":"_totalAssets","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_token","type":"address"}],"name":"kickAuction","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"lossLimitRatio","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"manualRewardSell","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"merkleClaim","outputs":[{"internalType":"contract IMerkleRewards","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"minAmountToSell","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"openDeposits","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"profitLimitRatio","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_depositor","type":"address"},{"internalType":"bool","name":"_allowed","type":"bool"}],"name":"setAllowed","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_auction","type":"address"}],"name":"setAuction","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"_doHealthCheck","type":"bool"}],"name":"setDoHealthCheck","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_newLossLimitRatio","type":"uint256"}],"name":"setLossLimitRatio","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_merkleClaim","type":"address"}],"name":"setMerkleClaim","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_minAmountToSell","type":"uint256"}],"name":"setMinAmountToSell","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"_openDeposits","type":"bool"}],"name":"setOpenDeposits","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_newProfitLimitRatio","type":"uint256"}],"name":"setProfitLimitRatio","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"int24","name":"_usdcToAssetSwapTickSpacing","type":"int24"}],"name":"setUsdcToAssetSwapTickSpacing","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"_useAuction","type":"bool"}],"name":"setUseAuction","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"int24","name":"_wethToUsdcSwapTickSpacing","type":"int24"}],"name":"setWethToUsdcSwapTickSpacing","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"shutdownWithdraw","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_totalIdle","type":"uint256"}],"name":"tendThis","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"tendTrigger","outputs":[{"internalType":"bool","name":"","type":"bool"},{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"tokenizedStrategyAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"usdcToAssetSwapTickSpacing","outputs":[{"internalType":"int24","name":"","type":"int24"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"useAuction","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"valueOfVault","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"vault","outputs":[{"internalType":"contract IStrategy","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"vaultsMaxWithdraw","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"wethToUsdcSwapTickSpacing","outputs":[{"internalType":"int24","name":"","type":"int24"}],"stateMutability":"view","type":"function"},{"stateMutability":"payable","type":"receive"}]Contract Creation Code
60e06040525f80546227100162ffffff19909116179055600480546001600160a01b0319167394312a608246cecfce6811db84b3ef4b2619054e179055348015610047575f5ffd5b506040516133783803806133788339810160408190526100669161078c565b6001600160a01b0383166080523060a05260405183908390839083908390829082906100d5906100a2908490849033908190819060240161088b565b60408051601f198184030181529190526020810180516001600160e01b03908116634b839d7360e11b1790915261030916565b5073d377919fa87120584b21279a491f82d5265a139c7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5550505050826001600160a01b0316816001600160a01b03166338d52e0f6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610157573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061017b91906108d8565b6001600160a01b0316146101c45760405162461bcd60e51b815260206004820152600b60248201526a1ddc9bdb99c81d985d5b1d60aa1b60448201526064015b60405180910390fd5b6001600160a01b0380821660c0526080516101e29116825f19610393565b5061021b91507361e030a56d33e8260fdd81f03b162a79fe3449cd905073de632c3a214d5f14c1d8ddf0b92f8bcd188fee455f19610393565b6080516001600160a01b03167342000000000000000000000000000000000000061461028a5761027573420000000000000000000000000000000000000673be6d8f0d05cc4be24d5167a3ef062215be6d18a55f19610393565b5f805462ffffff60d81b1916601960da1b1790555b6080516001600160a01b031673833589fcd6edb6e08f4c7c32d4f71b54bda02913146102f4576102e473833589fcd6edb6e08f4c7c32d4f71b54bda0291373be6d8f0d05cc4be24d5167a3ef062215be6d18a55f19610393565b6001805462ffffff191660321790555b505068056bc75e2d6310000060025550610938565b60605f5f73d377919fa87120584b21279a491f82d5265a139c6001600160a01b03168460405161033991906108f1565b5f60405180830381855af49150503d805f8114610371576040519150601f19603f3d011682016040523d82523d5f602084013e610376565b606091505b50915091508161038c576040513d805f833e8082fd5b9392505050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b0390811663095ea7b360e01b179091526103eb908590839061046116565b61045b576040516001600160a01b03841660248201525f604482015261045190859063095ea7b360e01b9060640160408051808303601f190181529190526020810180516001600160e01b0319939093166001600160e01b039384161790529061050216565b61045b8482610502565b50505050565b5f5f5f846001600160a01b03168460405161047c91906108f1565b5f604051808303815f865af19150503d805f81146104b5576040519150601f19603f3d011682016040523d82523d5f602084013e6104ba565b606091505b50915091508180156104e45750805115806104e45750808060200190518101906104e49190610907565b80156104f957506001600160a01b0385163b15155b95945050505050565b6040805180820190915260208082527f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564908201525f9061054e906001600160a01b0385169084906105d2565b905080515f148061056e57508080602001905181019061056e9190610907565b6105cd5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b60648201526084016101bb565b505050565b60606105e084845f856105e8565b949350505050565b6060824710156106495760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b60648201526084016101bb565b5f5f866001600160a01b0316858760405161066491906108f1565b5f6040518083038185875af1925050503d805f811461069e576040519150601f19603f3d011682016040523d82523d5f602084013e6106a3565b606091505b5090925090506106b5878383876106c0565b979650505050505050565b6060831561072e5782515f03610727576001600160a01b0385163b6107275760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016101bb565b50816105e0565b6105e083838151156107435781518083602001fd5b8060405162461bcd60e51b81526004016101bb9190610926565b80516001600160a01b0381168114610773575f5ffd5b919050565b634e487b7160e01b5f52604160045260245ffd5b5f5f5f6060848603121561079e575f5ffd5b6107a78461075d565b60208501519093506001600160401b038111156107c2575f5ffd5b8401601f810186136107d2575f5ffd5b80516001600160401b038111156107eb576107eb610778565b604051601f8201601f19908116603f011681016001600160401b038111828210171561081957610819610778565b604052818152828201602001881015610830575f5ffd5b8160208401602083015e5f602083830101528094505050506108546040850161075d565b90509250925092565b5f81518084528060208401602086015e5f602082860101526020601f19601f83011685010191505092915050565b6001600160a01b038616815260a0602082018190525f906108ae9083018761085d565b6001600160a01b039586166040840152938516606083015250921660809092019190915292915050565b5f602082840312156108e8575f5ffd5b61038c8261075d565b5f82518060208501845e5f920191825250919050565b5f60208284031215610917575f5ffd5b8151801515811461038c575f5ffd5b602081525f61038c602083018461085d565b60805160a05160c051612952610a265f395f81816108bc01528181610c8c01528181610dbf01528181610f3701528181610f810152818161115d015281816117fe015281816118bb01528181611ab90152611c6401525f81816109cb01528181610a4801528181610b2c01528181610bbb01528181610eb901528181610fce015281816110540152818161131c015281816113980152818161142f0152818161150301528181611591015281816116240152818161171a015261197101525f8181610e6d015281816110c3015281816116d101528181611c2701528181611f4c015261218c01526129525ff3fe60806040526004361061028a575f3560e01c806384d78a3811610159578063d19a3bb8116100c0578063edcc528b11610079578063edcc528b14610846578063f6e2aa3b14610865578063fae035f31461088c578063fbfa77cf146108ab578063fc7f71b6146108de578063fde813a8146108fd576102ef565b8063d19a3bb814610775578063d63a8e111461079c578063d6968601146107ca578063dbcf7237146107e9578063e752c44a14610808578063ec676a2514610827576102ef565b8063a39591f311610112578063a39591f3146106c3578063ac00ff26146106d7578063ad5c4648146106f6578063b0915e9114610710578063b8c6f57914610737578063c3f81cc514610756576102ef565b806384d78a381461060457806389a3027114610623578063950b3d731461064a5780639994673d146106695780639d7fb70c1461067d578063a1e7bf0a1461069c576102ef565b806349317f1d116101fd57806370f2fd52116101b657806370f2fd521461054957806373adb21414610568578063772c815e1461057c578063797bf343146105955780637d969932146105a95780637d9f6db5146105c7576102ef565b806349317f1d1461047c5780634a5d0943146104905780634e0cd799146104ac578063503160d9146104c15780635d265d3f146104e05780636718835f14610521576102ef565b806320aa49ae1161024f57806320aa49ae146103cf578063286a876b146103ee5780632d49be91146104005780633d6cb5751461041f5780634697f05d1461043e57806346aa2f121461045d576102ef565b806284fc3c1461032e57806304bd46291461035557806317df92161461037457806318144367146103885780631b059f161461039d576102ef565b366102ef5747156102ed576006602160991b016001600160a01b031663d0e30db0476040518263ffffffff1660e01b81526004015f604051808303818588803b1580156102d5575f5ffd5b505af11580156102e7573d5f5f3e3d5ffd5b50505050505b005b3480156102fa575f5ffd5b5073d377919fa87120584b21279a491f82d5265a139c365f80375f5f365f845af43d5f5f3e80801561032a573d5ff35b3d5ffd5b348015610339575f5ffd5b5061034261091c565b6040519081526020015b60405180910390f35b348015610360575f5ffd5b5061034261036f3660046124ab565b610995565b34801561037f575f5ffd5b506102ed6109b6565b348015610393575f5ffd5b5061034260025481565b3480156103a8575f5ffd5b505f546103bc90600160d81b900460020b81565b60405160029190910b815260200161034c565b3480156103da575f5ffd5b506102ed6103e93660046124d3565b610a33565b3480156103f9575f5ffd5b505f610342565b34801561040b575f5ffd5b506102ed61041a3660046124ee565b610b17565b34801561042a575f5ffd5b506102ed6104393660046124ee565b610b92565b348015610449575f5ffd5b506102ed610458366004612505565b610ba6565b348015610468575f5ffd5b506103426104773660046124ab565b610c43565b348015610487575f5ffd5b50610342610d04565b34801561049b575f5ffd5b505f54610100900461ffff16610342565b3480156104b7575f5ffd5b506103426103e881565b3480156104cc575f5ffd5b506102ed6104db3660046124ee565b610d23565b3480156104eb575f5ffd5b5060408051600481526024810182526020810180516001600160e01b031663440368a360e01b179052905161034c915f9161256a565b34801561052c575f5ffd5b505f546105399060ff1681565b604051901515815260200161034c565b348015610554575f5ffd5b506102ed61056336600461266b565b610d34565b348015610573575f5ffd5b50610342610da8565b348015610587575f5ffd5b506001546103bc9060020b81565b3480156105a0575f5ffd5b50610342610e56565b3480156105b4575f5ffd5b505f546301000000900461ffff16610342565b3480156105d2575f5ffd5b505f546105ec90600160281b90046001600160a01b031681565b6040516001600160a01b03909116815260200161034c565b34801561060f575f5ffd5b505f5461053990600160c81b900460ff1681565b34801561062e575f5ffd5b506105ec73833589fcd6edb6e08f4c7c32d4f71b54bda0291381565b348015610655575f5ffd5b506102ed6106643660046124ee565b610ea4565b348015610674575f5ffd5b50610342610f20565b348015610688575f5ffd5b506102ed6106973660046124ee565b610f6e565b3480156106a7575f5ffd5b506105ec73de632c3a214d5f14c1d8ddf0b92f8bcd188fee4581565b3480156106ce575f5ffd5b50610342610f76565b3480156106e2575f5ffd5b506102ed6106f13660046124d3565b610fb9565b348015610701575f5ffd5b506105ec6006602160991b0181565b34801561071b575f5ffd5b506105ec73be6d8f0d05cc4be24d5167a3ef062215be6d18a581565b348015610742575f5ffd5b506102ed6107513660046124ab565b61103f565b348015610761575f5ffd5b505f5461053990600160d01b900460ff1681565b348015610780575f5ffd5b506105ec73d377919fa87120584b21279a491f82d5265a139c81565b3480156107a7575f5ffd5b506105396107b63660046124ab565b60036020525f908152604090205460ff1681565b3480156107d5575f5ffd5b506102ed6107e43660046124ee565b611307565b3480156107f4575f5ffd5b506102ed610803366004612719565b611383565b348015610813575f5ffd5b506004546105ec906001600160a01b031681565b348015610832575f5ffd5b506102ed6108413660046124ab565b61141a565b348015610851575f5ffd5b506102ed610860366004612719565b6114ee565b348015610870575f5ffd5b506105ec7361e030a56d33e8260fdd81f03b162a79fe3449cd81565b348015610897575f5ffd5b506102ed6108a63660046124d3565b61157c565b3480156108b6575f5ffd5b506105ec7f000000000000000000000000000000000000000000000000000000000000000081565b3480156108e9575f5ffd5b506103426108f83660046124ab565b61160d565b348015610908575f5ffd5b506102ed6109173660046124ee565b61168b565b6040516370a0823160e01b81523060048201525f907361e030a56d33e8260fdd81f03b162a79fe3449cd906370a08231906024015b602060405180830381865afa15801561096c573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906109909190612739565b905090565b5f61099e610da8565b6109a6610e56565b6109b09190612764565b92915050565b60405163d43fdcf760e01b81523360048201527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169063d43fdcf7906024015f6040518083038186803b158015610a13575f5ffd5b505afa158015610a25573d5f5f3e3d5ffd5b50505050610a3161169c565b565b6040516348e4a64960e01b81523360048201527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906348e4a649906024015f6040518083038186803b158015610a90575f5ffd5b505afa158015610aa2573d5f5f3e3d5ffd5b505050508015610afa575f54600160281b90046001600160a01b0316610afa5760405162461bcd60e51b815260206004820152600860248201526710b0bab1ba34b7b760c11b60448201526064015b60405180910390fd5b5f8054911515600160c81b0260ff60c81b19909216919091179055565b6040516348e4a64960e01b81523360048201527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906348e4a649906024015f6040518083038186803b158015610b74575f5ffd5b505afa158015610b86573d5f5f3e3d5ffd5b50505060029190915550565b610b9a6117af565b610ba3816117e6565b50565b6040516348e4a64960e01b81523360048201527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906348e4a649906024015f6040518083038186803b158015610c03575f5ffd5b505afa158015610c15573d5f5f3e3d5ffd5b505050506001600160a01b03919091165f908152600360205260409020805460ff1916911515919091179055565b5f8054600160d01b900460ff1680610c7257506001600160a01b0382165f9081526003602052604090205460ff165b15610cfd5760405163402d267d60e01b81523060048201527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169063402d267d90602401602060405180830381865afa158015610cd9573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906109b09190612739565b505f919050565b5f610d0d6117af565b610d15611933565b9050610d2081611956565b90565b610d2b6117af565b610ba381611a9d565b60048054604051632f9404f760e21b81526001600160a01b039091169163be5013dc91610d71918c918c918c918c918c918c918c918c9101612777565b5f604051808303815f87803b158015610d88575f5ffd5b505af1158015610d9a573d5f5f3e3d5ffd5b505050505050505050505050565b604051636c82bbbf60e11b81523060048201525f907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906307a2d13a90829063d905777e90602401602060405180830381865afa158015610e14573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610e389190612739565b6040518263ffffffff1660e01b815260040161095191815260200190565b6040516370a0823160e01b81523060048201525f907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906370a0823190602401610951565b6040516348e4a64960e01b81523360048201527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906348e4a649906024015f6040518083038186803b158015610f01575f5ffd5b505afa158015610f13573d5f5f3e3d5ffd5b50505050610ba381611b2b565b6040516370a0823160e01b81523060048201525f907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906370a0823190602401610951565b610ba36117af565b5f6001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000166307a2d13a82610faf610f20565b610e389190612764565b6040516348e4a64960e01b81523360048201527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906348e4a649906024015f6040518083038186803b158015611016575f5ffd5b505afa158015611028573d5f5f3e3d5ffd5b50505f805460ff1916931515939093179092555050565b6040516348e4a64960e01b81523360048201527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906348e4a649906024015f6040518083038186803b15801561109c575f5ffd5b505afa1580156110ae573d5f5f3e3d5ffd5b505050506001600160a01b038116156112da577f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316816001600160a01b0316631f1fcd516040518163ffffffff1660e01b8152600401602060405180830381865afa158015611127573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061114b91906127fa565b6001600160a01b031614806111f057507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316816001600160a01b0316631f1fcd516040518163ffffffff1660e01b8152600401602060405180830381865afa1580156111c1573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906111e591906127fa565b6001600160a01b0316145b6112295760405162461bcd60e51b815260206004820152600a6024820152691ddc9bdb99c81dd85b9d60b21b6044820152606401610af1565b306001600160a01b0316816001600160a01b031663f7260d3e6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561126f573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061129391906127fa565b6001600160a01b0316146112da5760405162461bcd60e51b815260206004820152600e60248201526d3bb937b733903932b1b2b4bb32b960911b6044820152606401610af1565b5f80546001600160a01b03909216600160281b0265010000000000600160c81b0319909216919091179055565b6040516348e4a64960e01b81523360048201527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906348e4a649906024015f6040518083038186803b158015611364575f5ffd5b505afa158015611376573d5f5f3e3d5ffd5b50505050610ba381611bc4565b6040516348e4a64960e01b81523360048201527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906348e4a649906024015f6040518083038186803b1580156113e0575f5ffd5b505afa1580156113f2573d5f5f3e3d5ffd5b50505f805462ffffff909416600160d81b0262ffffff60d81b19909416939093179092555050565b6040516348e4a64960e01b81523360048201527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906348e4a649906024015f6040518083038186803b158015611477575f5ffd5b505afa158015611489573d5f5f3e3d5ffd5b5050506001600160a01b03821690506114cc5760405162461bcd60e51b8152602060048201526005602482015264217a65726f60d81b6044820152606401610af1565b600480546001600160a01b0319166001600160a01b0392909216919091179055565b6040516348e4a64960e01b81523360048201527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906348e4a649906024015f6040518083038186803b15801561154b575f5ffd5b505afa15801561155d573d5f5f3e3d5ffd5b50506001805462ffffff191662ffffff94909416939093179092555050565b6040516348e4a64960e01b81523360048201527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906348e4a649906024015f6040518083038186803b1580156115d9575f5ffd5b505afa1580156115eb573d5f5f3e3d5ffd5b50505f8054931515600160d01b0260ff60d01b19909416939093179092555050565b60405163d43fdcf760e01b81523360048201525f907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169063d43fdcf7906024015f6040518083038186803b15801561166c575f5ffd5b505afa15801561167e573d5f5f3e3d5ffd5b505050506109b082611c24565b6116936117af565b610ba381611dd9565b5f6116a561091c565b9050600254811180156116c157505f54600160c81b900460ff16155b1561170e576116cf81611ded565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166006602160991b011461170e5761170e611e4f565b611716610e56565b90507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663bf86d6906040518163ffffffff1660e01b8152600401602060405180830381865afa158015611774573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906117989190612815565b610ba3576103e8811115610ba357610ba381611a9d565b333014610a315760405162461bcd60e51b815260206004820152600560248201526410b9b2b63360d91b6044820152606401610af1565b604051630a28a47760e01b8152600481018290525f907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031690630a28a47790602401602060405180830381865afa15801561184b573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061186f9190612739565b90505f61187a610f20565b9050808211156118985761189582611890610f20565b6120b8565b91505b604051635d043b2960e11b815260048101839052306024820181905260448201527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169063ba087652906064016020604051808303815f875af1158015611909573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061192d9190612739565b50505050565b5f61193c61169c565b611944610f76565b61194c610e56565b6109909190612764565b5f5460ff1661196e57505f805460ff19166001179055565b5f7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166301e1d1146040518163ffffffff1660e01b8152600401602060405180830381865afa1580156119cb573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906119ef9190612739565b905080821115611a66575f5461271090611a1290610100900461ffff1683612830565b611a1c9190612847565b611a268284612866565b1115611a625760405162461bcd60e51b815260206004820152600b60248201526a6865616c7468436865636b60a81b6044820152606401610af1565b5050565b81811115611a62575f5461271090611a89906301000000900461ffff1683612830565b611a939190612847565b611a268383612866565b604051636e553f6560e01b8152600481018290523060248201527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031690636e553f65906044016020604051808303815f875af1158015611b07573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611a629190612739565b5f8111611b695760405162461bcd60e51b815260206004820152600c60248201526b085e995c9bc81c1c9bd99a5d60a21b6044820152606401610af1565b61ffff811115611ba75760405162461bcd60e51b8152602060048201526009602482015268042e8dede40d0d2ced60bb1b6044820152606401610af1565b5f805461ffff9092166101000262ffff0019909216919091179055565b6127108110611c035760405162461bcd60e51b815260206004820152600b60248201526a085b1bdcdcc81b1a5b5a5d60aa1b6044820152606401610af1565b5f805461ffff90921663010000000264ffff00000019909216919091179055565b5f7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316826001600160a01b031614158015611c9957507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316826001600160a01b031614155b611cd35760405162461bcd60e51b815260206004820152600b60248201526a63616e6e6f74206b69636b60a81b6044820152606401610af1565b6040516370a0823160e01b81523060048201525f906001600160a01b038416906370a0823190602401602060405180830381865afa158015611d17573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611d3b9190612739565b5f54909150611d5e906001600160a01b0385811691600160281b900416836120cd565b5f546040516396c5517560e01b81526001600160a01b038581166004830152600160281b909204909116906396c55175906024016020604051808303815f875af1158015611dae573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611dd29190612739565b9392505050565b610ba3611de882611890610da8565b6117e6565b6040516313346fd560e11b815260016004820152602481018290525f604482015230606482015273de632c3a214d5f14c1d8ddf0b92f8bcd188fee4590632668dfaa906084016020604051808303815f875af1158015611b07573d5f5f3e3d5ffd5b6040516370a0823160e01b81523060048201525f906006602160991b01906370a0823190602401602060405180830381865afa158015611e91573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611eb59190612739565b90506103e8811115611f4a5773be6d8f0d05cc4be24d5167a3ef062215be6d18a563a026383e611eec6006602160991b018461211f565b6040518263ffffffff1660e01b8152600401611f089190612879565b6020604051808303815f875af1158015611f24573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611f489190612739565b505b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031673833589fcd6edb6e08f4c7c32d4f71b54bda029131480611f98575060015460020b155b15611fa05750565b6040516370a0823160e01b81523060048201525f9073833589fcd6edb6e08f4c7c32d4f71b54bda02913906370a0823190602401602060405180830381865afa158015611fef573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906120139190612739565b90506103e8811115611a625773be6d8f0d05cc4be24d5167a3ef062215be6d18a563a026383e61205773833589fcd6edb6e08f4c7c32d4f71b54bda029138461211f565b6040518263ffffffff1660e01b81526004016120739190612879565b6020604051808303815f875af115801561208f573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906120b39190612739565b505050565b5f8183106120c65781611dd2565b5090919050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b1790526120b390849061223a565b60408051610100810182525f80825260208201819052918101829052606081018290526080810182905260a0810182905260c0810182905260e08101919091526040805161010081019091526001600160a01b03841680825260208201906006602160991b01146121b0577f00000000000000000000000000000000000000000000000000000000000000006121c6565b73833589fcd6edb6e08f4c7c32d4f71b54bda029135b6001600160a01b031681526020016006602160991b016001600160a01b0316856001600160a01b0316146121ff5760015460020b61220c565b5f54600160d81b900460020b5b60020b8152306020820152426040820152606081018490525f6080820181905260a090910152905092915050565b5f61228e826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b031661230d9092919063ffffffff16565b905080515f14806122ae5750808060200190518101906122ae9190612815565b6120b35760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610af1565b606061231b84845f85612323565b949350505050565b6060824710156123845760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401610af1565b5f5f866001600160a01b0316858760405161239f91906128f4565b5f6040518083038185875af1925050503d805f81146123d9576040519150601f19603f3d011682016040523d82523d5f602084013e6123de565b606091505b50915091506123ef878383876123fa565b979650505050505050565b606083156124685782515f03612461576001600160a01b0385163b6124615760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610af1565b508161231b565b61231b838381511561247d5781518083602001fd5b8060405162461bcd60e51b8152600401610af1919061290a565b6001600160a01b0381168114610ba3575f5ffd5b5f602082840312156124bb575f5ffd5b8135611dd281612497565b8015158114610ba3575f5ffd5b5f602082840312156124e3575f5ffd5b8135611dd2816124c6565b5f602082840312156124fe575f5ffd5b5035919050565b5f5f60408385031215612516575f5ffd5b823561252181612497565b91506020830135612531816124c6565b809150509250929050565b5f81518084528060208401602086015e5f602082860101526020601f19601f83011685010191505092915050565b8215158152604060208201525f61231b604083018461253c565b5f5f83601f840112612594575f5ffd5b50813567ffffffffffffffff8111156125ab575f5ffd5b6020830191508360208260051b85010111156125c5575f5ffd5b9250929050565b634e487b7160e01b5f52604160045260245ffd5b5f82601f8301126125ef575f5ffd5b813567ffffffffffffffff811115612609576126096125cc565b604051601f8201601f19908116603f0116810167ffffffffffffffff81118282101715612638576126386125cc565b60405281815283820160200185101561264f575f5ffd5b816020850160208301375f918101602001919091529392505050565b5f5f5f5f5f5f5f5f60e0898b031215612682575f5ffd5b883561268d81612497565b975060208901359650604089013560ff811681146126a9575f5ffd5b9550606089013594506080890135935060a089013567ffffffffffffffff8111156126d2575f5ffd5b6126de8b828c01612584565b90945092505060c089013567ffffffffffffffff8111156126fd575f5ffd5b6127098b828c016125e0565b9150509295985092959890939650565b5f60208284031215612729575f5ffd5b81358060020b8114611dd2575f5ffd5b5f60208284031215612749575f5ffd5b5051919050565b634e487b7160e01b5f52601160045260245ffd5b808201808211156109b0576109b0612750565b6001600160a01b03891681526020810188905260ff87166040820152606081018690526080810185905260e060a0820181905281018390525f6001600160fb1b038411156127c3575f5ffd5b8360051b8086610100850137820182810361010090810160c08501526127eb9082018561253c565b9b9a5050505050505050505050565b5f6020828403121561280a575f5ffd5b8151611dd281612497565b5f60208284031215612825575f5ffd5b8151611dd2816124c6565b80820281158282048414176109b0576109b0612750565b5f8261286157634e487b7160e01b5f52601260045260245ffd5b500490565b818103818111156109b0576109b0612750565b81516001600160a01b03908116825260208084015182169083015260408084015160020b9083015260608084015191821690830152610100820190506080830151608083015260a083015160a083015260c083015160c083015260e08301516128ed60e08401826001600160a01b03169052565b5092915050565b5f82518060208501845e5f920191825250919050565b602081525f611dd2602083018461253c56fea2646970667358221220c695e5b10e9e01fbd756dccfaf85ef735d5b0237caa2acc6ff3196a8d9ecbf9364736f6c634300081c0033000000000000000000000000833589fcd6edb6e08f4c7c32d4f71b54bda029130000000000000000000000000000000000000000000000000000000000000060000000000000000000000000f42f5795d9ac7e9d757db633d693cd548cfd916900000000000000000000000000000000000000000000000000000000000000115553444320466c756964204c656e646572000000000000000000000000000000
Deployed Bytecode
0x60806040526004361061028a575f3560e01c806384d78a3811610159578063d19a3bb8116100c0578063edcc528b11610079578063edcc528b14610846578063f6e2aa3b14610865578063fae035f31461088c578063fbfa77cf146108ab578063fc7f71b6146108de578063fde813a8146108fd576102ef565b8063d19a3bb814610775578063d63a8e111461079c578063d6968601146107ca578063dbcf7237146107e9578063e752c44a14610808578063ec676a2514610827576102ef565b8063a39591f311610112578063a39591f3146106c3578063ac00ff26146106d7578063ad5c4648146106f6578063b0915e9114610710578063b8c6f57914610737578063c3f81cc514610756576102ef565b806384d78a381461060457806389a3027114610623578063950b3d731461064a5780639994673d146106695780639d7fb70c1461067d578063a1e7bf0a1461069c576102ef565b806349317f1d116101fd57806370f2fd52116101b657806370f2fd521461054957806373adb21414610568578063772c815e1461057c578063797bf343146105955780637d969932146105a95780637d9f6db5146105c7576102ef565b806349317f1d1461047c5780634a5d0943146104905780634e0cd799146104ac578063503160d9146104c15780635d265d3f146104e05780636718835f14610521576102ef565b806320aa49ae1161024f57806320aa49ae146103cf578063286a876b146103ee5780632d49be91146104005780633d6cb5751461041f5780634697f05d1461043e57806346aa2f121461045d576102ef565b806284fc3c1461032e57806304bd46291461035557806317df92161461037457806318144367146103885780631b059f161461039d576102ef565b366102ef5747156102ed576006602160991b016001600160a01b031663d0e30db0476040518263ffffffff1660e01b81526004015f604051808303818588803b1580156102d5575f5ffd5b505af11580156102e7573d5f5f3e3d5ffd5b50505050505b005b3480156102fa575f5ffd5b5073d377919fa87120584b21279a491f82d5265a139c365f80375f5f365f845af43d5f5f3e80801561032a573d5ff35b3d5ffd5b348015610339575f5ffd5b5061034261091c565b6040519081526020015b60405180910390f35b348015610360575f5ffd5b5061034261036f3660046124ab565b610995565b34801561037f575f5ffd5b506102ed6109b6565b348015610393575f5ffd5b5061034260025481565b3480156103a8575f5ffd5b505f546103bc90600160d81b900460020b81565b60405160029190910b815260200161034c565b3480156103da575f5ffd5b506102ed6103e93660046124d3565b610a33565b3480156103f9575f5ffd5b505f610342565b34801561040b575f5ffd5b506102ed61041a3660046124ee565b610b17565b34801561042a575f5ffd5b506102ed6104393660046124ee565b610b92565b348015610449575f5ffd5b506102ed610458366004612505565b610ba6565b348015610468575f5ffd5b506103426104773660046124ab565b610c43565b348015610487575f5ffd5b50610342610d04565b34801561049b575f5ffd5b505f54610100900461ffff16610342565b3480156104b7575f5ffd5b506103426103e881565b3480156104cc575f5ffd5b506102ed6104db3660046124ee565b610d23565b3480156104eb575f5ffd5b5060408051600481526024810182526020810180516001600160e01b031663440368a360e01b179052905161034c915f9161256a565b34801561052c575f5ffd5b505f546105399060ff1681565b604051901515815260200161034c565b348015610554575f5ffd5b506102ed61056336600461266b565b610d34565b348015610573575f5ffd5b50610342610da8565b348015610587575f5ffd5b506001546103bc9060020b81565b3480156105a0575f5ffd5b50610342610e56565b3480156105b4575f5ffd5b505f546301000000900461ffff16610342565b3480156105d2575f5ffd5b505f546105ec90600160281b90046001600160a01b031681565b6040516001600160a01b03909116815260200161034c565b34801561060f575f5ffd5b505f5461053990600160c81b900460ff1681565b34801561062e575f5ffd5b506105ec73833589fcd6edb6e08f4c7c32d4f71b54bda0291381565b348015610655575f5ffd5b506102ed6106643660046124ee565b610ea4565b348015610674575f5ffd5b50610342610f20565b348015610688575f5ffd5b506102ed6106973660046124ee565b610f6e565b3480156106a7575f5ffd5b506105ec73de632c3a214d5f14c1d8ddf0b92f8bcd188fee4581565b3480156106ce575f5ffd5b50610342610f76565b3480156106e2575f5ffd5b506102ed6106f13660046124d3565b610fb9565b348015610701575f5ffd5b506105ec6006602160991b0181565b34801561071b575f5ffd5b506105ec73be6d8f0d05cc4be24d5167a3ef062215be6d18a581565b348015610742575f5ffd5b506102ed6107513660046124ab565b61103f565b348015610761575f5ffd5b505f5461053990600160d01b900460ff1681565b348015610780575f5ffd5b506105ec73d377919fa87120584b21279a491f82d5265a139c81565b3480156107a7575f5ffd5b506105396107b63660046124ab565b60036020525f908152604090205460ff1681565b3480156107d5575f5ffd5b506102ed6107e43660046124ee565b611307565b3480156107f4575f5ffd5b506102ed610803366004612719565b611383565b348015610813575f5ffd5b506004546105ec906001600160a01b031681565b348015610832575f5ffd5b506102ed6108413660046124ab565b61141a565b348015610851575f5ffd5b506102ed610860366004612719565b6114ee565b348015610870575f5ffd5b506105ec7361e030a56d33e8260fdd81f03b162a79fe3449cd81565b348015610897575f5ffd5b506102ed6108a63660046124d3565b61157c565b3480156108b6575f5ffd5b506105ec7f000000000000000000000000f42f5795d9ac7e9d757db633d693cd548cfd916981565b3480156108e9575f5ffd5b506103426108f83660046124ab565b61160d565b348015610908575f5ffd5b506102ed6109173660046124ee565b61168b565b6040516370a0823160e01b81523060048201525f907361e030a56d33e8260fdd81f03b162a79fe3449cd906370a08231906024015b602060405180830381865afa15801561096c573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906109909190612739565b905090565b5f61099e610da8565b6109a6610e56565b6109b09190612764565b92915050565b60405163d43fdcf760e01b81523360048201527f00000000000000000000000070fffbacb53ef74903ac074aae769414a70970d16001600160a01b03169063d43fdcf7906024015f6040518083038186803b158015610a13575f5ffd5b505afa158015610a25573d5f5f3e3d5ffd5b50505050610a3161169c565b565b6040516348e4a64960e01b81523360048201527f00000000000000000000000070fffbacb53ef74903ac074aae769414a70970d16001600160a01b0316906348e4a649906024015f6040518083038186803b158015610a90575f5ffd5b505afa158015610aa2573d5f5f3e3d5ffd5b505050508015610afa575f54600160281b90046001600160a01b0316610afa5760405162461bcd60e51b815260206004820152600860248201526710b0bab1ba34b7b760c11b60448201526064015b60405180910390fd5b5f8054911515600160c81b0260ff60c81b19909216919091179055565b6040516348e4a64960e01b81523360048201527f00000000000000000000000070fffbacb53ef74903ac074aae769414a70970d16001600160a01b0316906348e4a649906024015f6040518083038186803b158015610b74575f5ffd5b505afa158015610b86573d5f5f3e3d5ffd5b50505060029190915550565b610b9a6117af565b610ba3816117e6565b50565b6040516348e4a64960e01b81523360048201527f00000000000000000000000070fffbacb53ef74903ac074aae769414a70970d16001600160a01b0316906348e4a649906024015f6040518083038186803b158015610c03575f5ffd5b505afa158015610c15573d5f5f3e3d5ffd5b505050506001600160a01b03919091165f908152600360205260409020805460ff1916911515919091179055565b5f8054600160d01b900460ff1680610c7257506001600160a01b0382165f9081526003602052604090205460ff165b15610cfd5760405163402d267d60e01b81523060048201527f000000000000000000000000f42f5795d9ac7e9d757db633d693cd548cfd91696001600160a01b03169063402d267d90602401602060405180830381865afa158015610cd9573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906109b09190612739565b505f919050565b5f610d0d6117af565b610d15611933565b9050610d2081611956565b90565b610d2b6117af565b610ba381611a9d565b60048054604051632f9404f760e21b81526001600160a01b039091169163be5013dc91610d71918c918c918c918c918c918c918c918c9101612777565b5f604051808303815f87803b158015610d88575f5ffd5b505af1158015610d9a573d5f5f3e3d5ffd5b505050505050505050505050565b604051636c82bbbf60e11b81523060048201525f907f000000000000000000000000f42f5795d9ac7e9d757db633d693cd548cfd91696001600160a01b0316906307a2d13a90829063d905777e90602401602060405180830381865afa158015610e14573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610e389190612739565b6040518263ffffffff1660e01b815260040161095191815260200190565b6040516370a0823160e01b81523060048201525f907f000000000000000000000000833589fcd6edb6e08f4c7c32d4f71b54bda029136001600160a01b0316906370a0823190602401610951565b6040516348e4a64960e01b81523360048201527f00000000000000000000000070fffbacb53ef74903ac074aae769414a70970d16001600160a01b0316906348e4a649906024015f6040518083038186803b158015610f01575f5ffd5b505afa158015610f13573d5f5f3e3d5ffd5b50505050610ba381611b2b565b6040516370a0823160e01b81523060048201525f907f000000000000000000000000f42f5795d9ac7e9d757db633d693cd548cfd91696001600160a01b0316906370a0823190602401610951565b610ba36117af565b5f6001600160a01b037f000000000000000000000000f42f5795d9ac7e9d757db633d693cd548cfd9169166307a2d13a82610faf610f20565b610e389190612764565b6040516348e4a64960e01b81523360048201527f00000000000000000000000070fffbacb53ef74903ac074aae769414a70970d16001600160a01b0316906348e4a649906024015f6040518083038186803b158015611016575f5ffd5b505afa158015611028573d5f5f3e3d5ffd5b50505f805460ff1916931515939093179092555050565b6040516348e4a64960e01b81523360048201527f00000000000000000000000070fffbacb53ef74903ac074aae769414a70970d16001600160a01b0316906348e4a649906024015f6040518083038186803b15801561109c575f5ffd5b505afa1580156110ae573d5f5f3e3d5ffd5b505050506001600160a01b038116156112da577f000000000000000000000000833589fcd6edb6e08f4c7c32d4f71b54bda029136001600160a01b0316816001600160a01b0316631f1fcd516040518163ffffffff1660e01b8152600401602060405180830381865afa158015611127573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061114b91906127fa565b6001600160a01b031614806111f057507f000000000000000000000000f42f5795d9ac7e9d757db633d693cd548cfd91696001600160a01b0316816001600160a01b0316631f1fcd516040518163ffffffff1660e01b8152600401602060405180830381865afa1580156111c1573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906111e591906127fa565b6001600160a01b0316145b6112295760405162461bcd60e51b815260206004820152600a6024820152691ddc9bdb99c81dd85b9d60b21b6044820152606401610af1565b306001600160a01b0316816001600160a01b031663f7260d3e6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561126f573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061129391906127fa565b6001600160a01b0316146112da5760405162461bcd60e51b815260206004820152600e60248201526d3bb937b733903932b1b2b4bb32b960911b6044820152606401610af1565b5f80546001600160a01b03909216600160281b0265010000000000600160c81b0319909216919091179055565b6040516348e4a64960e01b81523360048201527f00000000000000000000000070fffbacb53ef74903ac074aae769414a70970d16001600160a01b0316906348e4a649906024015f6040518083038186803b158015611364575f5ffd5b505afa158015611376573d5f5f3e3d5ffd5b50505050610ba381611bc4565b6040516348e4a64960e01b81523360048201527f00000000000000000000000070fffbacb53ef74903ac074aae769414a70970d16001600160a01b0316906348e4a649906024015f6040518083038186803b1580156113e0575f5ffd5b505afa1580156113f2573d5f5f3e3d5ffd5b50505f805462ffffff909416600160d81b0262ffffff60d81b19909416939093179092555050565b6040516348e4a64960e01b81523360048201527f00000000000000000000000070fffbacb53ef74903ac074aae769414a70970d16001600160a01b0316906348e4a649906024015f6040518083038186803b158015611477575f5ffd5b505afa158015611489573d5f5f3e3d5ffd5b5050506001600160a01b03821690506114cc5760405162461bcd60e51b8152602060048201526005602482015264217a65726f60d81b6044820152606401610af1565b600480546001600160a01b0319166001600160a01b0392909216919091179055565b6040516348e4a64960e01b81523360048201527f00000000000000000000000070fffbacb53ef74903ac074aae769414a70970d16001600160a01b0316906348e4a649906024015f6040518083038186803b15801561154b575f5ffd5b505afa15801561155d573d5f5f3e3d5ffd5b50506001805462ffffff191662ffffff94909416939093179092555050565b6040516348e4a64960e01b81523360048201527f00000000000000000000000070fffbacb53ef74903ac074aae769414a70970d16001600160a01b0316906348e4a649906024015f6040518083038186803b1580156115d9575f5ffd5b505afa1580156115eb573d5f5f3e3d5ffd5b50505f8054931515600160d01b0260ff60d01b19909416939093179092555050565b60405163d43fdcf760e01b81523360048201525f907f00000000000000000000000070fffbacb53ef74903ac074aae769414a70970d16001600160a01b03169063d43fdcf7906024015f6040518083038186803b15801561166c575f5ffd5b505afa15801561167e573d5f5f3e3d5ffd5b505050506109b082611c24565b6116936117af565b610ba381611dd9565b5f6116a561091c565b9050600254811180156116c157505f54600160c81b900460ff16155b1561170e576116cf81611ded565b7f000000000000000000000000833589fcd6edb6e08f4c7c32d4f71b54bda029136001600160a01b03166006602160991b011461170e5761170e611e4f565b611716610e56565b90507f00000000000000000000000070fffbacb53ef74903ac074aae769414a70970d16001600160a01b031663bf86d6906040518163ffffffff1660e01b8152600401602060405180830381865afa158015611774573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906117989190612815565b610ba3576103e8811115610ba357610ba381611a9d565b333014610a315760405162461bcd60e51b815260206004820152600560248201526410b9b2b63360d91b6044820152606401610af1565b604051630a28a47760e01b8152600481018290525f907f000000000000000000000000f42f5795d9ac7e9d757db633d693cd548cfd91696001600160a01b031690630a28a47790602401602060405180830381865afa15801561184b573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061186f9190612739565b90505f61187a610f20565b9050808211156118985761189582611890610f20565b6120b8565b91505b604051635d043b2960e11b815260048101839052306024820181905260448201527f000000000000000000000000f42f5795d9ac7e9d757db633d693cd548cfd91696001600160a01b03169063ba087652906064016020604051808303815f875af1158015611909573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061192d9190612739565b50505050565b5f61193c61169c565b611944610f76565b61194c610e56565b6109909190612764565b5f5460ff1661196e57505f805460ff19166001179055565b5f7f00000000000000000000000070fffbacb53ef74903ac074aae769414a70970d16001600160a01b03166301e1d1146040518163ffffffff1660e01b8152600401602060405180830381865afa1580156119cb573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906119ef9190612739565b905080821115611a66575f5461271090611a1290610100900461ffff1683612830565b611a1c9190612847565b611a268284612866565b1115611a625760405162461bcd60e51b815260206004820152600b60248201526a6865616c7468436865636b60a81b6044820152606401610af1565b5050565b81811115611a62575f5461271090611a89906301000000900461ffff1683612830565b611a939190612847565b611a268383612866565b604051636e553f6560e01b8152600481018290523060248201527f000000000000000000000000f42f5795d9ac7e9d757db633d693cd548cfd91696001600160a01b031690636e553f65906044016020604051808303815f875af1158015611b07573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611a629190612739565b5f8111611b695760405162461bcd60e51b815260206004820152600c60248201526b085e995c9bc81c1c9bd99a5d60a21b6044820152606401610af1565b61ffff811115611ba75760405162461bcd60e51b8152602060048201526009602482015268042e8dede40d0d2ced60bb1b6044820152606401610af1565b5f805461ffff9092166101000262ffff0019909216919091179055565b6127108110611c035760405162461bcd60e51b815260206004820152600b60248201526a085b1bdcdcc81b1a5b5a5d60aa1b6044820152606401610af1565b5f805461ffff90921663010000000264ffff00000019909216919091179055565b5f7f000000000000000000000000833589fcd6edb6e08f4c7c32d4f71b54bda029136001600160a01b0316826001600160a01b031614158015611c9957507f000000000000000000000000f42f5795d9ac7e9d757db633d693cd548cfd91696001600160a01b0316826001600160a01b031614155b611cd35760405162461bcd60e51b815260206004820152600b60248201526a63616e6e6f74206b69636b60a81b6044820152606401610af1565b6040516370a0823160e01b81523060048201525f906001600160a01b038416906370a0823190602401602060405180830381865afa158015611d17573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611d3b9190612739565b5f54909150611d5e906001600160a01b0385811691600160281b900416836120cd565b5f546040516396c5517560e01b81526001600160a01b038581166004830152600160281b909204909116906396c55175906024016020604051808303815f875af1158015611dae573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611dd29190612739565b9392505050565b610ba3611de882611890610da8565b6117e6565b6040516313346fd560e11b815260016004820152602481018290525f604482015230606482015273de632c3a214d5f14c1d8ddf0b92f8bcd188fee4590632668dfaa906084016020604051808303815f875af1158015611b07573d5f5f3e3d5ffd5b6040516370a0823160e01b81523060048201525f906006602160991b01906370a0823190602401602060405180830381865afa158015611e91573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611eb59190612739565b90506103e8811115611f4a5773be6d8f0d05cc4be24d5167a3ef062215be6d18a563a026383e611eec6006602160991b018461211f565b6040518263ffffffff1660e01b8152600401611f089190612879565b6020604051808303815f875af1158015611f24573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611f489190612739565b505b7f000000000000000000000000833589fcd6edb6e08f4c7c32d4f71b54bda029136001600160a01b031673833589fcd6edb6e08f4c7c32d4f71b54bda029131480611f98575060015460020b155b15611fa05750565b6040516370a0823160e01b81523060048201525f9073833589fcd6edb6e08f4c7c32d4f71b54bda02913906370a0823190602401602060405180830381865afa158015611fef573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906120139190612739565b90506103e8811115611a625773be6d8f0d05cc4be24d5167a3ef062215be6d18a563a026383e61205773833589fcd6edb6e08f4c7c32d4f71b54bda029138461211f565b6040518263ffffffff1660e01b81526004016120739190612879565b6020604051808303815f875af115801561208f573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906120b39190612739565b505050565b5f8183106120c65781611dd2565b5090919050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b1790526120b390849061223a565b60408051610100810182525f80825260208201819052918101829052606081018290526080810182905260a0810182905260c0810182905260e08101919091526040805161010081019091526001600160a01b03841680825260208201906006602160991b01146121b0577f000000000000000000000000833589fcd6edb6e08f4c7c32d4f71b54bda029136121c6565b73833589fcd6edb6e08f4c7c32d4f71b54bda029135b6001600160a01b031681526020016006602160991b016001600160a01b0316856001600160a01b0316146121ff5760015460020b61220c565b5f54600160d81b900460020b5b60020b8152306020820152426040820152606081018490525f6080820181905260a090910152905092915050565b5f61228e826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b031661230d9092919063ffffffff16565b905080515f14806122ae5750808060200190518101906122ae9190612815565b6120b35760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610af1565b606061231b84845f85612323565b949350505050565b6060824710156123845760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401610af1565b5f5f866001600160a01b0316858760405161239f91906128f4565b5f6040518083038185875af1925050503d805f81146123d9576040519150601f19603f3d011682016040523d82523d5f602084013e6123de565b606091505b50915091506123ef878383876123fa565b979650505050505050565b606083156124685782515f03612461576001600160a01b0385163b6124615760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610af1565b508161231b565b61231b838381511561247d5781518083602001fd5b8060405162461bcd60e51b8152600401610af1919061290a565b6001600160a01b0381168114610ba3575f5ffd5b5f602082840312156124bb575f5ffd5b8135611dd281612497565b8015158114610ba3575f5ffd5b5f602082840312156124e3575f5ffd5b8135611dd2816124c6565b5f602082840312156124fe575f5ffd5b5035919050565b5f5f60408385031215612516575f5ffd5b823561252181612497565b91506020830135612531816124c6565b809150509250929050565b5f81518084528060208401602086015e5f602082860101526020601f19601f83011685010191505092915050565b8215158152604060208201525f61231b604083018461253c565b5f5f83601f840112612594575f5ffd5b50813567ffffffffffffffff8111156125ab575f5ffd5b6020830191508360208260051b85010111156125c5575f5ffd5b9250929050565b634e487b7160e01b5f52604160045260245ffd5b5f82601f8301126125ef575f5ffd5b813567ffffffffffffffff811115612609576126096125cc565b604051601f8201601f19908116603f0116810167ffffffffffffffff81118282101715612638576126386125cc565b60405281815283820160200185101561264f575f5ffd5b816020850160208301375f918101602001919091529392505050565b5f5f5f5f5f5f5f5f60e0898b031215612682575f5ffd5b883561268d81612497565b975060208901359650604089013560ff811681146126a9575f5ffd5b9550606089013594506080890135935060a089013567ffffffffffffffff8111156126d2575f5ffd5b6126de8b828c01612584565b90945092505060c089013567ffffffffffffffff8111156126fd575f5ffd5b6127098b828c016125e0565b9150509295985092959890939650565b5f60208284031215612729575f5ffd5b81358060020b8114611dd2575f5ffd5b5f60208284031215612749575f5ffd5b5051919050565b634e487b7160e01b5f52601160045260245ffd5b808201808211156109b0576109b0612750565b6001600160a01b03891681526020810188905260ff87166040820152606081018690526080810185905260e060a0820181905281018390525f6001600160fb1b038411156127c3575f5ffd5b8360051b8086610100850137820182810361010090810160c08501526127eb9082018561253c565b9b9a5050505050505050505050565b5f6020828403121561280a575f5ffd5b8151611dd281612497565b5f60208284031215612825575f5ffd5b8151611dd2816124c6565b80820281158282048414176109b0576109b0612750565b5f8261286157634e487b7160e01b5f52601260045260245ffd5b500490565b818103818111156109b0576109b0612750565b81516001600160a01b03908116825260208084015182169083015260408084015160020b9083015260608084015191821690830152610100820190506080830151608083015260a083015160a083015260c083015160c083015260e08301516128ed60e08401826001600160a01b03169052565b5092915050565b5f82518060208501845e5f920191825250919050565b602081525f611dd2602083018461253c56fea2646970667358221220c695e5b10e9e01fbd756dccfaf85ef735d5b0237caa2acc6ff3196a8d9ecbf9364736f6c634300081c0033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
000000000000000000000000833589fcd6edb6e08f4c7c32d4f71b54bda029130000000000000000000000000000000000000000000000000000000000000060000000000000000000000000f42f5795d9ac7e9d757db633d693cd548cfd916900000000000000000000000000000000000000000000000000000000000000115553444320466c756964204c656e646572000000000000000000000000000000
-----Decoded View---------------
Arg [0] : _asset (address): 0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913
Arg [1] : _name (string): USDC Fluid Lender
Arg [2] : _vault (address): 0xf42f5795D9ac7e9D757dB633D693cD548Cfd9169
-----Encoded View---------------
5 Constructor Arguments found :
Arg [0] : 000000000000000000000000833589fcd6edb6e08f4c7c32d4f71b54bda02913
Arg [1] : 0000000000000000000000000000000000000000000000000000000000000060
Arg [2] : 000000000000000000000000f42f5795d9ac7e9d757db633d693cd548cfd9169
Arg [3] : 0000000000000000000000000000000000000000000000000000000000000011
Arg [4] : 5553444320466c756964204c656e646572000000000000000000000000000000
Loading...
Loading
Loading...
Loading
Loading...
Loading
Net Worth in USD
$0.00
Net Worth in ETH
0
Multichain Portfolio | 32 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.