Verified contractPartialUNLICENSED
ftYieldWrapperV2
Address0xb44a9c40efc05eb014effeac3cbed6a31f8cb87f
- Balance
0 ETH
- Transactions
8
- Compiler
solc 0.8.30
- Same code
1 more contract
Details
- Compiler
- solc 0.8.30+commit.73712a01
- Language
- solidity
- Optimization
- Yes, 200 runs
- EVM version
- cancun
- Via IR
- yes
- License
- UNLICENSED
- Match
- Partialcreation code: yes, runtime code: yes
- Verified on Sourcify
- Created in block
- 24,501,008
- Creation transaction
- 0x102c1e8f1d…412405b718
- Main copy (most transactions)
- 0x6aaf8456…e87e837d
19 files
- contracts/wrapper/ftYieldWrapperV2.solmain33.55 KB
- contracts/cb/ICircuitBreakerV2.sol12.64 KB
- contracts/cb/IHealthcheck.sol907 B
- contracts/cb/ProtectedContract.sol5.59 KB
- contracts/interfaces/IftYieldWrapperV2.sol1.95 KB
- lib/ft-common-contracts/contracts/interfaces/IStrategy.sol2.31 KB
- lib/openzeppelin-contracts/contracts/interfaces/IERC1363.sol4.45 KB
- lib/openzeppelin-contracts/contracts/interfaces/IERC165.sol193 B
- lib/openzeppelin-contracts/contracts/interfaces/IERC20.sol182 B
- lib/openzeppelin-contracts/contracts/interfaces/draft-IERC6093.sol6.54 KB
- lib/openzeppelin-contracts/contracts/token/ERC20/ERC20.sol10.8 KB
- lib/openzeppelin-contracts/contracts/token/ERC20/IERC20.sol2.78 KB
- lib/openzeppelin-contracts/contracts/token/ERC20/extensions/IERC20Metadata.sol684 B
- lib/openzeppelin-contracts/contracts/token/ERC20/utils/SafeERC20.sol13.31 KB
- lib/openzeppelin-contracts/contracts/utils/Context.sol963 B
- lib/openzeppelin-contracts/contracts/utils/ReentrancyGuardTransient.sol2.85 KB
- lib/openzeppelin-contracts/contracts/utils/StorageSlot.sol4.18 KB
- lib/openzeppelin-contracts/contracts/utils/TransientSlot.sol5.08 KB
- lib/openzeppelin-contracts/contracts/utils/introspection/IERC165.sol871 B
contracts/wrapper/ftYieldWrapperV2.sol
// SPDX-License-Identifier: UNLICENSED
// Copyright (c) 2025 Flying Tulip Inc. All rights reserved.
pragma solidity ^0.8.30;
import {ERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import {
IERC20Metadata,
IERC20
} from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import {ReentrancyGuardTransient} from "@openzeppelin/contracts/utils/ReentrancyGuardTransient.sol";
import {IStrategy, IStrategyWithQueue} from "@ft-common/interfaces/IStrategy.sol";
import {IftYieldWrapperV2} from "../interfaces/IftYieldWrapperV2.sol";
import {ProtectedContract} from "../cb/ProtectedContract.sol";
import {ICircuitBreakerV2} from "../cb/ICircuitBreakerV2.sol";
/// @title ftYieldWrapperV2
/// @notice Single-asset wrapper with CircuitBreakerV2 integration
/// @dev Replaces V1 CB integration with ProtectedContract mixin (fail-close pattern).
/// Fee-on-transfer (FOT) and rebasing tokens are NOT supported.
///
/// Key differences from V1:
/// - Uses ProtectedContract mixin for CB V2 integration
/// - Fail-close pattern: CB errors revert (no try/catch bypass)
/// - Deferred settlement: Large withdrawals may be queued in CB for later execution
/// - Withdrawals burn shares immediately; tokens go to user or CB (if queued)
contract ftYieldWrapperV2 is IftYieldWrapperV2, ERC20, ReentrancyGuardTransient, ProtectedContract {
using SafeERC20 for IERC20;
using SafeERC20 for IERC20Metadata;
uint256 public deployed; // default to 0
address public immutable token;
address public yieldClaimer;
address public pendingYieldClaimer;
address public strategyManager;
address public pendingStrategyManager;
address public treasury;
address public pendingTreasury;
address public subYieldClaimer;
address public putManager;
address public depositor;
IStrategy[] public strategies;
mapping(address strategy => uint256 deployed) public deployedToStrategy;
// must be submitted by strategyManager
address public pendingStrategy;
uint256 public delayStrategy;
/// @notice Timelock delay between setStrategy and confirmStrategy. Defaults to 0; set via setStrategyDelay.
uint256 public strategyDelayConfig;
/// @notice Minimum deposit amount. Defaults to 0 (no minimum). Set via setMinDepositAmount.
uint256 public minDepositAmount;
event Deployed(address strategy, uint256 allocation);
event YieldClaimed(address yieldClaimer, address token, uint256 amount);
event Deposit(address owner, uint256 amount);
event Withdraw(address owner, uint256 amount);
event WithdrawUnderlying(address owner, uint256 amount);
event QueuedToWrapper(address strategyManager, address strategy, uint256 amount);
event WithdrawToWrapper(address strategyManager, address strategy, uint256 amount);
event PendingYieldClaimer(address yieldClaimer, address pendingYieldClaimer);
event PendingStrategyManager(address strategyManager, address pendingStrategyManager);
event PendingTreasury(address treasury, address pendingTreasuy);
event PendingStrategy(address strategyManager, address pendingStrategy);
event UpdateYieldClaimer(address newYieldClaimer);
event UpdateStrategyManager(address newStrategyManager);
event UpdateTreasury(address newTreasury);
event UpdateSubYieldClaimer(address yieldClaimer, address subYieldClaimer);
event UpdatePutManager(address newPutManager);
event UpdateDepositor(address newDepositor);
event UpdateStrategyDelayConfig(uint256 newDelay);
event UpdateMinDepositAmount(uint256 newMinDepositAmount);
event AddedStrategy(address strategyManager, address strategy);
event RemovedStrategy(address strategyManager, address strategy);
event StrategiesReordered(address[] newOrder);
event YieldSwept(address caller, address token, uint256 amount);
/// @notice Emitted when a withdrawal is queued due to circuit breaker rate limiting
/// @param caller The address that initiated the withdrawal
/// @param recipient The address that will receive tokens after settlement
/// @param amount The amount queued
/// @param queueId The CB queue entry ID for claiming after settlement
event WithdrawQueued(
address indexed caller, address indexed recipient, uint256 amount, uint256 queueId
);
error ftYieldWrapperInsufficientLiquidity();
error ftYieldWrapperNotYieldClaimer();
error ftYieldWrapperNotYieldClaimers();
error ftYieldWrapperDelayNotExpired();
error ftYieldWrapperNotStrategyManager();
error ftYieldWrapperZeroAddress();
error ftYieldWrapperNotSetter();
error ftYieldWrapperNotConfirmer();
error ftYieldWrapperNotYieldClaimConfirmer();
error ftYieldWrapperSettingUnchanged();
error ftYieldWrapperNotStrategy();
error ftYieldWrapperNoYield();
error ftYieldWrapperInvalidStrategyIndex();
error ftYieldWrapperInvalidStrategiesOrder();
error ftYieldWrapperNotPutManagerOrDepositor();
error ftYieldWrapperFeeOnTransferUnsupported();
error ftYieldWrapperBelowMinDeposit(uint256 amount, uint256 minimum);
modifier onlyYieldClaimer() {
if (msg.sender != yieldClaimer) revert ftYieldWrapperNotYieldClaimer();
_;
}
modifier onlyStrategyManager() {
if (msg.sender != strategyManager) {
revert ftYieldWrapperNotStrategyManager();
}
_;
}
modifier onlyYieldClaimers() {
if (msg.sender != yieldClaimer && msg.sender != subYieldClaimer) {
revert ftYieldWrapperNotYieldClaimers();
}
_;
}
modifier onlyPutManagerOrDepositor() {
if (msg.sender != putManager && msg.sender != depositor) {
revert ftYieldWrapperNotPutManagerOrDepositor();
}
_;
}
/// @notice Creates a new yield wrapper for the given token
/// @dev Name and symbol default to "Flying Tulip {token.name()}" / "ft{token.symbol()}"
/// if empty strings are passed. Use custom names for engine-specific wrappers,
/// e.g., "FT_PmintUSDT" for PermissionedMint's USDT wrapper.
/// @param _token The underlying token address
/// @param _yieldClaimer Address that can claim yield and execute strategy calls
/// @param _strategyManager Address that can add/remove strategies and configure depositor
/// @param _treasury Address that receives claimed yield
/// @param _name Custom ERC20 name (empty string = auto-generate)
/// @param _symbol Custom ERC20 symbol (empty string = auto-generate)
constructor(
address _token,
address _yieldClaimer,
address _strategyManager,
address _treasury,
string memory _name,
string memory _symbol
)
ERC20(
bytes(_name).length > 0
? _name
: string.concat("Flying Tulip ", IERC20Metadata(_token).name()),
bytes(_symbol).length > 0
? _symbol
: string.concat("ft", IERC20Metadata(_token).symbol())
)
{
if (_token == address(0x0)) revert ftYieldWrapperZeroAddress();
if (_yieldClaimer == address(0x0)) revert ftYieldWrapperZeroAddress();
if (_strategyManager == address(0x0)) {
revert ftYieldWrapperZeroAddress();
}
if (_treasury == address(0x0)) revert ftYieldWrapperZeroAddress();
token = _token;
yieldClaimer = _yieldClaimer;
strategyManager = _strategyManager;
treasury = _treasury;
// putManager defaults to 0x0
// depositor defaults to 0x0
emit Transfer(address(0x0), address(this), 0);
}
// ===== ProtectedContract Overrides =====
function circuitBreaker()
public
view
override(IftYieldWrapperV2, ProtectedContract)
returns (address)
{
return _getCircuitBreaker();
}
/// @dev Returns the wrapper's TVL normalized to underlying decimals for CB rate limiting.
/// Assumes each strategy reports `valueOfCapital()` in its `positionToken()` units.
/// Converts each strategy leg from position-token decimals to underlying-token decimals
/// so CB preTvl and outflow accounting share a consistent unit basis.
/// For AaveStrategy this conversion is a no-op because token/aToken decimals are equal.
function _getTvl(address) internal view override returns (uint256 tvl) {
tvl = IERC20(token).balanceOf(address(this));
uint8 underlyingDec = IERC20Metadata(token).decimals();
uint256 len = strategies.length;
for (uint256 i = 0; i < len; i++) {
uint256 v = strategies[i].valueOfCapital();
uint8 posDec = IERC20Metadata(strategies[i].positionToken()).decimals();
if (posDec != underlyingDec) {
v = (v * 10 ** underlyingDec) / (10 ** posDec);
}
tvl += v;
}
}
// ===== Circuit Breaker Configuration =====
/// @notice Set or disable the circuit breaker (V2)
/// @dev Only callable by strategy manager. Set to address(0) to disable.
/// @param _circuitBreaker Address of circuit breaker V2, or address(0) to disable
function setCircuitBreaker(address _circuitBreaker) external onlyStrategyManager {
_setCircuitBreaker(_circuitBreaker);
}
// ===== Admin Functions =====
function setYieldClaimer(address _yieldClaimer) external onlyYieldClaimer {
if (_yieldClaimer == address(0x0)) revert ftYieldWrapperZeroAddress();
pendingYieldClaimer = _yieldClaimer;
emit PendingYieldClaimer(yieldClaimer, pendingYieldClaimer);
}
function setSubYieldClaimer(address _subYieldClaimer) external onlyYieldClaimer {
if (_subYieldClaimer == address(0x0)) {
revert ftYieldWrapperZeroAddress();
}
subYieldClaimer = _subYieldClaimer;
emit UpdateSubYieldClaimer(yieldClaimer, subYieldClaimer);
}
function confirmYieldClaimer() external {
if (msg.sender != treasury && msg.sender != strategyManager) {
revert ftYieldWrapperNotYieldClaimConfirmer();
}
if (pendingYieldClaimer == address(0x0)) {
revert ftYieldWrapperZeroAddress();
}
if (yieldClaimer == pendingYieldClaimer) {
revert ftYieldWrapperSettingUnchanged();
}
yieldClaimer = pendingYieldClaimer;
pendingYieldClaimer = address(0x0);
emit UpdateYieldClaimer(yieldClaimer);
}
function setStrategyManager(address _strategyManager) external onlyStrategyManager {
if (_strategyManager == address(0x0)) {
revert ftYieldWrapperZeroAddress();
}
pendingStrategyManager = _strategyManager;
emit PendingStrategyManager(strategyManager, pendingStrategyManager);
}
function confirmStrategyManager() external {
if (msg.sender != treasury && msg.sender != yieldClaimer) {
revert ftYieldWrapperNotConfirmer();
}
if (pendingStrategyManager == address(0x0)) {
revert ftYieldWrapperZeroAddress();
}
if (strategyManager == pendingStrategyManager) {
revert ftYieldWrapperSettingUnchanged();
}
strategyManager = pendingStrategyManager;
pendingStrategyManager = address(0x0);
emit UpdateStrategyManager(strategyManager);
}
function setTreasury(address _treasury) external {
if (msg.sender != treasury) revert ftYieldWrapperNotSetter();
if (_treasury == address(0x0)) revert ftYieldWrapperZeroAddress();
pendingTreasury = _treasury;
emit PendingTreasury(treasury, pendingTreasury);
}
function confirmTreasury() external {
if (msg.sender != strategyManager && msg.sender != yieldClaimer) {
revert ftYieldWrapperNotConfirmer();
}
if (pendingTreasury == address(0x0)) revert ftYieldWrapperZeroAddress();
if (treasury == pendingTreasury) {
revert ftYieldWrapperSettingUnchanged();
}
treasury = pendingTreasury;
pendingTreasury = address(0x0);
emit UpdateTreasury(treasury);
}
function setPutManager(address _putManager) external onlyStrategyManager {
if (_putManager == address(0x0)) revert ftYieldWrapperZeroAddress();
putManager = _putManager;
emit UpdatePutManager(_putManager);
}
function setDepositor(address _depositor) external onlyStrategyManager {
if (_depositor == address(0x0)) revert ftYieldWrapperZeroAddress();
depositor = _depositor;
emit UpdateDepositor(_depositor);
}
/// @notice Sets the minimum deposit amount. Use 0 to allow any amount.
/// @param _minDepositAmount The new minimum deposit amount in underlying token units
function setMinDepositAmount(uint256 _minDepositAmount) external onlyStrategyManager {
minDepositAmount = _minDepositAmount;
emit UpdateMinDepositAmount(_minDepositAmount);
}
function setStrategyDelay(uint256 _delay) external {
if (msg.sender != treasury) revert ftYieldWrapperNotConfirmer();
strategyDelayConfig = _delay;
emit UpdateStrategyDelayConfig(_delay);
}
// ===== Strategy Management =====
function setStrategy(address _strategy) external onlyStrategyManager {
if (_strategy == address(0x0)) revert ftYieldWrapperZeroAddress();
if (isStrategy(_strategy) || IStrategy(_strategy).token() != token) {
revert ftYieldWrapperNotStrategy();
}
uint256 effectiveTime = block.timestamp + strategyDelayConfig;
pendingStrategy = _strategy;
delayStrategy = effectiveTime;
emit PendingStrategy(strategyManager, pendingStrategy);
}
function confirmStrategy() external {
if (msg.sender != treasury) revert ftYieldWrapperNotConfirmer();
if (pendingStrategy == address(0x0)) revert ftYieldWrapperZeroAddress();
if (delayStrategy > block.timestamp) revert ftYieldWrapperDelayNotExpired();
strategies.push(IStrategy(pendingStrategy));
emit AddedStrategy(strategyManager, pendingStrategy);
// Ensure strategy wrapper pointer is set (no-op if already this wrapper)
try IStrategy(pendingStrategy).setftYieldWrapper(address(this)) {}
catch {
// strategies are expected to support this; ignore to avoid bricking
}
pendingStrategy = address(0x0);
delayStrategy = 0;
emit PendingStrategy(strategyManager, pendingStrategy);
}
/// @notice Remove a strategy whose wrapper share balance is zero.
function removeStrategy(uint256 index) external onlyStrategyManager {
uint256 len = strategies.length;
if (index >= len) {
revert ftYieldWrapperInvalidStrategyIndex();
}
IStrategy s = strategies[index];
if (deployedToStrategy[address(s)] != 0) {
revert ftYieldWrapperNotStrategy();
}
address removed = address(s);
// swap & pop
if (index != len - 1) {
strategies[index] = strategies[len - 1];
}
strategies.pop();
emit RemovedStrategy(msg.sender, removed);
}
function isStrategy(address _strategy) public view returns (bool) {
uint256 strategiesLength = strategies.length;
for (uint256 i = 0; i < strategiesLength; i++) {
if (address(strategies[i]) == _strategy) return true;
}
return false;
}
function setStrategiesOrder(address[] calldata _newOrder) external onlyStrategyManager {
uint256 currentLength = strategies.length;
if (_newOrder.length != currentLength) {
revert ftYieldWrapperInvalidStrategiesOrder();
}
for (uint256 i = 0; i < currentLength; i++) {
if (!isStrategy(_newOrder[i])) {
revert ftYieldWrapperInvalidStrategiesOrder();
}
for (uint256 j = i + 1; j < currentLength; j++) {
if (_newOrder[i] == _newOrder[j]) {
revert ftYieldWrapperInvalidStrategiesOrder();
}
}
}
for (uint256 i = 0; i < currentLength; i++) {
strategies[i] = IStrategy(_newOrder[i]);
}
emit StrategiesReordered(_newOrder);
}
// ===== Yield Management =====
function claimYield(address _strategy) external onlyYieldClaimers returns (uint256 _yield) {
if (!isStrategy(_strategy)) revert ftYieldWrapperNotStrategy();
_yield = IStrategy(_strategy).claimYield(treasury);
if (_yield == 0) revert ftYieldWrapperNoYield();
emit YieldClaimed(msg.sender, address(token), _yield);
}
function claimYields() external onlyYieldClaimers returns (uint256 _yield) {
uint256 strategiesLength = strategies.length;
address _treasury = treasury;
for (uint256 i = 0; i < strategiesLength; i++) {
_yield += IStrategy(strategies[i]).claimYield(_treasury);
}
if (_yield == 0) revert ftYieldWrapperNoYield();
emit YieldClaimed(msg.sender, address(token), _yield);
}
function sweepIdleYield() external nonReentrant onlyYieldClaimers returns (uint256 amount) {
uint256 idleBalance = IERC20(token).balanceOf(address(this));
uint256 liabilities = totalSupply();
if (idleBalance <= liabilities) revert ftYieldWrapperNoYield();
amount = idleBalance - liabilities;
IERC20(token).safeTransfer(treasury, amount);
emit YieldSwept(msg.sender, address(token), amount);
}
function execute(
address _strategy,
address to,
uint256 value,
bytes calldata data
)
external
onlyYieldClaimers
returns (bool success, bytes memory result)
{
if (!isStrategy(_strategy)) revert ftYieldWrapperNotStrategy();
return IStrategy(_strategy).execute(to, value, data);
}
// ===== View Functions =====
function numberOfStrategies() external view returns (uint256) {
return strategies.length;
}
function capital() external view returns (uint256) {
return totalSupply();
}
function valueOfCapital() public view returns (uint256 _capital) {
_capital = IERC20(token).balanceOf(address(this));
uint256 strategiesLength = strategies.length;
for (uint256 i = 0; i < strategiesLength; i++) {
_capital += strategies[i].valueOfCapital();
}
}
function yield() public view returns (uint256) {
uint256 _capital = valueOfCapital();
uint256 _totalSupply = totalSupply();
return (_capital > _totalSupply) ? (_capital - _totalSupply) : 0;
}
function availableToWithdraw(address strategy) public view returns (uint256 liquidity) {
if (!isStrategy(strategy)) return 0;
uint256 shares;
try IStrategy(strategy).balanceOf(address(this)) returns (uint256 sb) {
shares = sb;
} catch {
return 0;
}
try IStrategy(strategy).maxAbleToWithdraw(shares) returns (uint256 m) {
liquidity = m;
} catch {
return 0;
}
}
function availableToWithdraw() public view returns (uint256 liquidity) {
liquidity = IERC20(token).balanceOf(address(this));
uint256 strategiesLength = strategies.length;
for (uint256 i = 0; i < strategiesLength; i++) {
uint256 shares;
try strategies[i].balanceOf(address(this)) returns (uint256 sb) {
shares = sb;
} catch {
shares = 0;
}
if (shares != 0) {
try strategies[i].maxAbleToWithdraw(shares) returns (uint256 m) {
liquidity += m;
} catch {
// treat as zero
}
}
}
}
function canWithdraw(uint256 amount) external view returns (bool) {
return (availableToWithdraw() >= amount);
}
function maxAbleToWithdraw(uint256 amount) external view returns (uint256) {
uint256 _liquidity = availableToWithdraw();
return _liquidity > amount ? amount : _liquidity;
}
function availableToDeposit() external view returns (uint256) {
return IERC20(token).balanceOf(address(this));
}
// ===== Core Deposit/Withdraw Functions =====
/// @notice Deposit underlying tokens into the wrapper and receive wrapper tokens
/// @dev Records inflow with circuit breaker (fail-close pattern).
/// Fee-on-transfer tokens are NOT supported and will revert.
/// @param amount The amount of underlying tokens to deposit
function deposit(uint256 amount) external nonReentrant onlyPutManagerOrDepositor {
if (amount == 0) revert ftYieldWrapperInsufficientLiquidity();
uint256 _minDeposit = minDepositAmount;
if (_minDeposit != 0 && amount < _minDeposit) {
revert ftYieldWrapperBelowMinDeposit(amount, _minDeposit);
}
// Record inflow with circuit breaker (fail-close: will revert if CB errors)
// preTvl normalized to underlying decimals for consistent CB accounting
uint256 preTvl = _getTvl(token);
uint256 balBefore = IERC20(token).balanceOf(address(this));
IERC20(token).safeTransferFrom(msg.sender, address(this), amount);
if (IERC20(token).balanceOf(address(this)) != balBefore + amount) {
revert ftYieldWrapperFeeOnTransferUnsupported();
}
// Record inflow after successful transfer
_recordInflow(token, amount, preTvl);
_mint(msg.sender, amount);
emit Deposit(msg.sender, amount);
}
/// @notice Withdraw underlying tokens from the wrapper
/// @dev Uses protected transfer (fail-close pattern). Large withdrawals may be queued
/// in the circuit breaker for later settlement. Shares are burned immediately.
///
/// If withdrawal is queued:
/// - Shares are burned immediately
/// - Tokens are transferred to circuit breaker
/// - User must call CB.executeQueued(queueId) after settlement delay
///
/// @param amount The amount of underlying tokens to withdraw
/// @param to The recipient address (receives tokens immediately or after CB settlement)
/// @return queueId The CB queue entry ID if the withdrawal was queued, 0 if immediate
function withdraw(
uint256 amount,
address to
)
external
nonReentrant
onlyPutManagerOrDepositor
returns (uint256 queueId)
{
return _withdrawReturningQueueId(amount, to);
}
function _withdrawReturningQueueId(
uint256 amount,
address to
)
internal
returns (uint256 queueId)
{
if (to == address(0)) revert ftYieldWrapperZeroAddress();
if (amount == 0) revert ftYieldWrapperInsufficientLiquidity();
uint256 initialTarget = amount;
uint256 remaining = amount;
// 1) Use idle underlying on the wrapper first
uint256 idle = IERC20(token).balanceOf(address(this));
if (idle != 0) {
uint256 toTake = idle > remaining ? remaining : idle;
remaining -= toTake;
}
// 2) Drain strategies in order
uint256 _strategiesLength = strategies.length;
for (uint256 i = 0; i < _strategiesLength && remaining != 0; i++) {
uint256 shareBal;
try strategies[i].balanceOf(address(this)) returns (uint256 sb) {
shareBal = sb;
} catch {
continue;
}
if (shareBal == 0) {
continue;
}
uint256 avail;
try strategies[i].maxAbleToWithdraw(shareBal) returns (uint256 m) {
avail = m;
} catch {
continue;
}
if (avail == 0) {
continue;
}
uint256 toRequest = avail > remaining ? remaining : avail;
try strategies[i].withdraw(toRequest) returns (uint256 received) {
if (received != 0) {
uint256 currentDeployed = deployedToStrategy[address(strategies[i])];
uint256 toReduce = received > currentDeployed ? currentDeployed : received;
deployedToStrategy[address(strategies[i])] -= toReduce;
if (toReduce > deployed) {
deployed = 0;
} else {
deployed -= toReduce;
}
if (received > remaining) {
remaining = 0;
} else {
remaining -= received;
}
}
} catch {
// Skip failing strategies and continue
}
}
uint256 totalDelivered = initialTarget - remaining;
if (remaining != 0) {
revert ftYieldWrapperInsufficientLiquidity();
}
// Burn shares immediately (before transfer)
if (totalDelivered != 0) {
_burn(msg.sender, totalDelivered);
}
// Protected transfer: may be immediate or queued
// If CB not set: immediate transfer to `to`
// If CB set, within limit: immediate transfer to `to`
// If CB set, exceeds limit: transfer to CB, user claims later
queueId = _protectedTransfer(token, to, totalDelivered);
if (queueId > 0) {
emit WithdrawQueued(msg.sender, to, totalDelivered, queueId);
} else {
emit Withdraw(msg.sender, totalDelivered);
}
}
/// @dev Circuit breaker rate limits all position-token outflows against a single aggregate
/// bucket keyed by the wrapper's underlying `token`, preventing bypass via multiple
/// strategies. Large withdrawals may be queued in the CB for later settlement.
///
/// Assumes position tokens have an approximately 1:1 economic relationship with the
/// underlying token. The limiter consumes `limiterAmount` in underlying decimals, while
/// queue settlement transfers `got` in position-token decimals.
///
/// Strategy integration invariant:
/// - `valueOfCapital()` MUST be returned in `positionToken()` units.
/// - `withdrawUnderlying()` MUST return the actual `positionToken()` amount transferred.
///
/// Flow: Pull position tokens to wrapper -> protectedTransferWithLimiter to user/CB
///
/// Use case: When strategies cannot liquidate to underlying (e.g., paused).
///
/// @param amount The amount (in underlying/share terms) to withdraw
/// @param to The recipient address for position tokens
/// @return queueIds Compact array of CB queue entry IDs for withdrawals that were queued.
/// Only contains non-zero IDs; empty if all transfers were immediate.
function withdrawUnderlying(
uint256 amount,
address to
)
external
nonReentrant
onlyPutManagerOrDepositor
returns (uint256[] memory queueIds)
{
if (to == address(0)) revert ftYieldWrapperZeroAddress();
if (amount == 0) revert ftYieldWrapperInsufficientLiquidity();
// Capture preTvl BEFORE pulling position tokens from strategies.
// Normalized to underlying decimals for consistent CB rate-limit accounting.
uint256 preTvl = _getTvl(token);
uint256 initialTarget = amount;
uint256 remaining = amount;
uint256 _strategiesLength = strategies.length;
queueIds = new uint256[](_strategiesLength);
uint256 n; // write pointer for compact queueIds
for (uint256 i = 0; i < _strategiesLength && remaining != 0; ++i) {
uint256 shareBal = strategies[i].balanceOf(address(this));
if (shareBal == 0) continue;
// Track "asked" amount, not "got" - these are share/yield tokens
uint256 toExit = shareBal > remaining ? remaining : shareBal;
try strategies[i].withdrawUnderlying(toExit) returns (uint256 got) {
if (got != 0) {
// Update deployed tracking based on asked amount (share accounting)
uint256 currentDeployed = deployedToStrategy[address(strategies[i])];
uint256 toReduce = toExit > currentDeployed ? currentDeployed : toExit;
deployedToStrategy[address(strategies[i])] -= toReduce;
if (toReduce > deployed) {
deployed = 0;
} else {
deployed -= toReduce;
}
remaining -= toExit;
// Position tokens now in wrapper - send via protectedTransferWithTvl
// Use preTvl captured before internal token movements
address positionToken = strategies[i].positionToken();
// Normalize got to underlying decimals for rate-limit accounting.
// The actual transfer uses got (position-token decimals).
uint256 limiterAmount = got;
uint8 posDecimals = IERC20Metadata(positionToken).decimals();
uint8 underlyingDecimals = IERC20Metadata(token).decimals();
if (posDecimals != underlyingDecimals) {
limiterAmount = (got * 10 ** underlyingDecimals) / (10 ** posDecimals);
}
uint256 queueId = _protectedTransferWithTvlAndLimiter(
positionToken, to, got, preTvl, token, limiterAmount
);
if (queueId > 0) {
queueIds[n++] = queueId;
emit WithdrawQueued(msg.sender, to, got, queueId);
}
}
} catch {
// strategy doesn't support exit-in-position-token or failed; skip
}
}
// Truncate queueIds to only the `n` non-zero entries that were written.
// Memory arrays have fixed length; this overwrites the length slot in-place
// so the ABI encoder only returns the filled entries (empty array if n == 0).
assembly { mstore(queueIds, n) }
uint256 totalDelivered = initialTarget - remaining;
if (remaining != 0) {
revert ftYieldWrapperInsufficientLiquidity();
}
if (totalDelivered != 0) {
_burn(msg.sender, totalDelivered);
}
emit WithdrawUnderlying(msg.sender, totalDelivered);
}
// ===== Strategy Capital Management =====
function deploy(address strategy, uint256 amount) external nonReentrant onlyYieldClaimer {
if (!isStrategy(strategy)) revert ftYieldWrapperNotStrategy();
if (IERC20(token).balanceOf(address(this)) < amount) {
revert ftYieldWrapperInsufficientLiquidity();
}
IERC20(token).forceApprove(address(strategy), amount);
IStrategy(strategy).deposit(amount);
deployedToStrategy[strategy] += amount;
deployed += amount;
emit Deployed(strategy, amount);
}
function forceWithdrawToWrapper(
address strategy,
uint256 amount
)
external
nonReentrant
onlyYieldClaimer
{
if (!isStrategy(strategy)) revert ftYieldWrapperNotStrategy();
uint256 _withdrawn = IStrategy(strategy).withdraw(amount);
uint256 currentDeployed = deployedToStrategy[strategy];
uint256 toReduce = _withdrawn > currentDeployed ? currentDeployed : _withdrawn;
deployedToStrategy[strategy] -= toReduce;
if (toReduce > deployed) {
deployed = 0;
} else {
deployed -= toReduce;
}
emit WithdrawToWrapper(msg.sender, strategy, _withdrawn);
}
function withdrawQueued(
address strategy,
uint256 amount
)
external
nonReentrant
onlyYieldClaimer
returns (uint256 id)
{
if (!isStrategy(strategy)) revert ftYieldWrapperNotStrategy();
id = IStrategyWithQueue(strategy).withdrawQueued(amount);
emit QueuedToWrapper(msg.sender, strategy, amount);
}
function claimQueued(
address strategy,
uint256 id
)
external
nonReentrant
onlyYieldClaimer
returns (uint256 received)
{
if (!isStrategy(strategy)) revert ftYieldWrapperNotStrategy();
received = IStrategyWithQueue(strategy).claimQueued(id);
uint256 currentDeployed = deployedToStrategy[strategy];
uint256 toReduce = received > currentDeployed ? currentDeployed : received;
deployedToStrategy[strategy] -= toReduce;
if (toReduce > deployed) {
deployed = 0;
} else {
deployed -= toReduce;
}
emit WithdrawToWrapper(msg.sender, strategy, received);
}
function decimals() public view override(ERC20, IERC20Metadata) returns (uint8) {
return IERC20Metadata(token).decimals();
}
}
contracts/cb/ICircuitBreakerV2.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.30;
import {IHealthcheck} from "./IHealthcheck.sol";
/// @title ICircuitBreakerV2
/// @notice Rate limiter with deferred settlement for protocol outflows
/// @dev Fee-on-transfer (FOT) and rebasing tokens are NOT supported.
/// Using such tokens will result in incorrect accounting and potential loss of funds.
interface ICircuitBreakerV2 {
// ===== Enums =====
enum QueueStatus {
Pending,
Paused
}
// ===== Structs =====
struct QueuedOutflow {
address token;
uint40 queuedAt;
uint40 settlesAt;
QueueStatus status;
address recipient;
uint64 recoveryEpoch;
uint256 amount;
}
struct LimiterConfig {
uint64 maxDrawRateWad;
uint48 mainWindow;
uint48 elasticWindow;
}
struct AssetHealth {
uint256 mainBuffer;
uint256 mainBufferCap;
uint256 elasticBuffer;
uint256 totalCapacity;
uint256 pendingOutflows;
uint256 utilizationBps;
bool isPaused;
}
// ===== Events =====
event Inflow(address indexed asset, uint256 amount, uint256 newTvl);
event OutflowImmediate(address indexed asset, address indexed to, uint256 amount);
event OutflowQueued(
uint256 indexed queueId,
address indexed asset,
address indexed recipient,
uint256 amount,
uint256 settlesAt
);
event OutflowLimiterContext(
uint256 indexed queueId, address indexed limiterAsset, address indexed transferToken
);
event OutflowExecuted(
uint256 indexed queueId, address indexed recipient, address indexed asset, uint256 amount
);
event OutflowPaused(uint256 indexed queueId, address indexed recipient);
event OutflowResumed(uint256 indexed queueId, address indexed recipient);
event OutflowSpedUp(uint256 indexed queueId, address indexed recipient, uint256 newSettlesAt);
event ConfigUpdated(address indexed asset, LimiterConfig config);
event DelayUpdated(uint256 newDelay);
event Paused(address indexed by);
event Unpaused();
event AssetPaused(address indexed asset, address indexed by);
event AssetUnpaused(address indexed asset);
event EmergencyRecovery(
address indexed asset, address indexed to, uint256 amount, uint64 newEpoch
);
event ProtectedContractUpdated(address indexed contract_, bool enabled);
event GuardianUpdated(address indexed newGuardian);
event EmergencyOverride(address indexed contract_, address indexed asset, uint256 amount);
event HealthcheckUpdated(address indexed newHealthcheck);
event OperatorUpdated(address indexed newOperator);
event RecipientWhitelistUpdated(address indexed recipient, bool enabled);
event ScopedLimiterUpdated(address indexed contract_, bool enabled);
event AssetTracked(address indexed asset);
// ===== Errors =====
error NotProtectedContract();
error NotScopedContract();
error NotAdmin();
error NotAdminOrGuardian();
error NotOperatorOrOwner();
error GloballyPaused();
error NotPaused();
error AssetPausedError(address asset);
error QueueNotFound(uint256 queueId);
error QueueNotSettled(uint256 queueId, uint256 settlesAt);
error QueueInvalidated(uint256 queueId, uint64 queueEpoch, uint64 currentEpoch);
error InvalidStatus(uint256 queueId, QueueStatus current, QueueStatus expected);
error InvalidConfig();
error ZeroAddress();
error ZeroAmount();
error HealthcheckFailed(uint256 queueId);
error InvalidSettleTime(uint256 queueId, uint256 currentSettlesAt, uint256 requestedSettlesAt);
error NoChange();
// ===== Core =====
function recordInflow(address asset, uint256 amount, uint256 preTvl) external;
function attemptOutflow(
address asset,
address to,
uint256 amount,
uint256 preTvl
)
external
returns (bool immediate, uint256 queueId);
/// @notice Rate-limit by `limiterAsset` but queue/transfer `transferToken`
/// @dev Use when the token being transferred differs from the rate-limit bucket key.
/// E.g., wrapper withdrawUnderlying uses the wrapper's `token` as limiter but
/// transfers individual strategy `positionToken`s.
/// `limiterAmount` is used for rate-limit accounting (in limiterAsset decimals).
/// `transferAmount` is stored in the queue and used for settlement transfers
/// (in transferToken decimals). They differ when decimals mismatch.
/// @param limiterAsset Asset address used for rate-limit state (bucket key)
/// @param transferToken Token actually transferred / queued
/// @param to Recipient
/// @param limiterAmount Amount in limiterAsset decimals for rate-limit accounting
/// @param transferAmount Amount in transferToken decimals for queue storage and settlement
/// @param preTvl TVL before the outflow (in limiterAsset decimals for consistent buffer sizing)
function attemptOutflowWithLimiter(
address limiterAsset,
address transferToken,
address to,
uint256 limiterAmount,
uint256 transferAmount,
uint256 preTvl
)
external
returns (bool immediate, uint256 queueId);
// ===== Settlement =====
function executeQueued(uint256 queueId) external;
function executeQueuedBatch(uint256[] calldata queueIds) external;
// ===== Views =====
function getQueueIdsByRecipient(address recipient)
external
view
returns (uint256[] memory queueIds);
function getQueuedByRecipient(
address recipient,
uint256 offset,
uint256 limit
)
external
view
returns (QueuedOutflow[] memory outflows);
function getQueued(uint256 queueId) external view returns (QueuedOutflow memory);
function isSettled(uint256 queueId) external view returns (bool);
function timeUntilSettled(uint256 queueId) external view returns (uint256 remaining);
function getAssetHealth(
address asset,
uint256 currentTvl
)
external
view
returns (AssetHealth memory health);
function withdrawalCapacity(address asset, uint256 currentTvl) external view returns (uint256);
/// @notice Check if an outflow would be immediate or queued (without recording)
/// @dev Use this for flows that cannot be queued (e.g., position token withdrawals)
/// @param asset The asset being withdrawn
/// @param amount The amount to check
/// @param currentTvl The current TVL for capacity calculation
/// @return wouldBeImmediate True if withdrawal would be immediate, false if would be queued
/// @return availableCapacity Current available withdrawal capacity
function checkOutflow(
address asset,
uint256 amount,
uint256 currentTvl
)
external
view
returns (bool wouldBeImmediate, uint256 availableCapacity);
/// @notice Get asset health for a specific contract's limiter state
/// @dev Falls back to shared state if contract is not scoped
function getAssetHealth(
address contract_,
address asset,
uint256 currentTvl
)
external
view
returns (AssetHealth memory health);
/// @notice Get withdrawal capacity for a specific contract's limiter state
/// @dev Falls back to shared state if contract is not scoped
function withdrawalCapacity(
address contract_,
address asset,
uint256 currentTvl
)
external
view
returns (uint256);
/// @notice Check if outflow would be immediate for a specific contract's limiter state
/// @dev Falls back to shared state if contract is not scoped
function checkOutflow(
address contract_,
address asset,
uint256 amount,
uint256 currentTvl
)
external
view
returns (bool wouldBeImmediate, uint256 availableCapacity);
function pendingOutflows(address asset) external view returns (uint256);
function settlementDelay() external view returns (uint256);
function paused() external view returns (bool);
function nextQueueId() external view returns (uint256);
function assetRecoveryEpoch(address asset) external view returns (uint64);
// ===== Enumeration Views =====
/// @notice Check if an address is a registered protected contract
function isProtectedContract(address contract_) external view returns (bool);
/// @notice Get all registered protected contracts
function getProtectedContracts() external view returns (address[] memory);
/// @notice Get count of registered protected contracts
function protectedContractCount() external view returns (uint256);
/// @notice Check if an asset has been tracked (had inflows/outflows)
function isTrackedAsset(address asset) external view returns (bool);
/// @notice Get all tracked assets
function getTrackedAssets() external view returns (address[] memory);
/// @notice Get count of tracked assets
function trackedAssetCount() external view returns (uint256);
/// @notice Check if a contract has scoped limiter state
function isScopedLimiter(address contract_) external view returns (bool);
/// @notice Check if an address is a whitelisted recipient
function isWhitelistedRecipient(address recipient) external view returns (bool);
/// @notice Get all whitelisted recipients
function getWhitelistedRecipients() external view returns (address[] memory);
/// @notice Get count of whitelisted recipients
function whitelistedRecipientCount() external view returns (uint256);
/// @notice Get comprehensive system status for monitoring dashboards
function getSystemStatus()
external
view
returns (
bool active,
address admin,
address guardianAddr,
uint256 delay,
uint256 numProtectedContracts,
uint256 numTrackedAssets,
uint256 numQueuedOutflows
);
// ===== Admin =====
function unpause() external;
function unpauseAsset(address asset) external;
/// @notice Speed up a queued outflow by reducing its settlement time
/// @param queueId The queue ID to speed up
/// @param newSettleDelay The new delay from now (0 = instant, settlesAt = block.timestamp)
/// @dev Reverts if newSettleDelay would result in a later settlesAt than current
function speedUp(uint256 queueId, uint256 newSettleDelay) external;
function resumeQueued(uint256 queueId) external;
function emergencyRecover(address asset, address to) external;
/// @notice Temporarily increase elastic buffer capacity to allow a specific withdrawal
/// @dev Writing lastUpdated discards pending main-buffer replenishment. Accepted: capacity
/// loss is conservative, `speedUp` is preferred for unblocking queued outflows, and
/// replenishment resumes on the next inflow/outflow.
/// @param asset The asset to increase capacity for
/// @param amount The amount to add to elastic buffer capacity
function emergencyOverride(address asset, uint256 amount) external;
/// @notice Temporarily increase elastic buffer capacity for a scoped contract's state
/// @dev Only works for contracts with scoped limiter enabled. Reverts if not registered or not scoped.
function emergencyOverrideScoped(address contract_, address asset, uint256 amount) external;
function setScopedLimiter(address contract_, bool enabled) external;
function setDelay(uint256 newDelay) external;
function setConfig(address asset, LimiterConfig calldata config) external;
function setDefaultConfig(LimiterConfig calldata config) external;
function setProtectedContract(address contract_, bool enabled) external;
function setGuardian(address newGuardian) external;
function setHealthcheck(address healthcheck_) external;
function setOperator(address operator_) external;
function setWhitelistedRecipient(address recipient, bool enabled) external;
// ===== Admin/Guardian =====
function pause() external;
function pauseAsset(address asset) external;
function pauseQueued(uint256 queueId) external;
// ===== Roles =====
function guardian() external view returns (address);
function healthcheck() external view returns (IHealthcheck);
function operator() external view returns (address);
}
contracts/cb/IHealthcheck.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.30;
/// @title IHealthcheck
/// @notice Simple interface for system health verification at withdrawal execution
/// @dev Implementations define their own invariants specific to their system
interface IHealthcheck {
/// @notice Check if a queued withdrawal should be allowed to execute
/// @param queueId The queue entry ID being executed
/// @param token The token being withdrawn
/// @param recipient The withdrawal recipient
/// @param amount The withdrawal amount
/// @return healthy True if system invariants pass, false to block withdrawal
/// @dev MUST NOT revert under normal conditions - reverts block all withdrawals
function isHealthy(
uint256 queueId,
address token,
address recipient,
uint256 amount
)
external
view
returns (bool healthy);
}
contracts/cb/ProtectedContract.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.30;
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import {StorageSlot} from "@openzeppelin/contracts/utils/StorageSlot.sol";
import {ICircuitBreakerV2} from "./ICircuitBreakerV2.sol";
/// @title ProtectedContract
/// @notice Mixin for circuit breaker protected contracts (both upgradeable and non-upgradeable).
/// @dev Uses unstructured storage for the circuit breaker address, making it safe for:
/// - Non-upgradeable contracts (standard inheritance)
/// - Upgradeable contracts (no storage layout conflicts)
///
/// Fee-on-transfer (FOT) and rebasing tokens are NOT supported.
/// Using such tokens will result in incorrect accounting and potential loss of funds.
abstract contract ProtectedContract {
using SafeERC20 for IERC20;
// ===== Unstructured Storage =====
/// @dev keccak256("ft.circuitbreakerv2.storage.ProtectedContract.circuitBreaker") - 1
bytes32 internal constant _CIRCUIT_BREAKER_SLOT =
0x88194fc1127942401ead32f70ac4b1816d514a0e878b86370156febc2984ee85;
/// @notice Returns the circuit breaker address
/// @dev Virtual to allow overriding when inheriting from interfaces that declare circuitBreaker()
function circuitBreaker() public view virtual returns (address) {
return _getCircuitBreaker();
}
/// @dev Internal getter for circuit breaker address. Use in overrides to avoid duplicating storage access.
function _getCircuitBreaker() internal view returns (address) {
return StorageSlot.getAddressSlot(_CIRCUIT_BREAKER_SLOT).value;
}
// ===== Events =====
event CircuitBreakerUpdated(address indexed newCircuitBreaker);
event OutflowQueued(
uint256 indexed queueId, address indexed token, address indexed to, uint256 amount
);
// ===== Internal =====
function _setCircuitBreaker(address cb_) internal virtual {
StorageSlot.getAddressSlot(_CIRCUIT_BREAKER_SLOT).value = cb_;
emit CircuitBreakerUpdated(cb_);
}
function _recordInflow(address _token, uint256 _amount, uint256 _preTvl) internal {
address cb = circuitBreaker();
if (cb == address(0)) {
return;
}
ICircuitBreakerV2(cb).recordInflow(_token, _amount, _preTvl);
}
function _protectedTransfer(
address _token,
address _to,
uint256 _amount
)
internal
returns (uint256 queueId)
{
if (circuitBreaker() == address(0)) {
IERC20(_token).safeTransfer(_to, _amount);
return 0;
}
return _protectedTransferWithTvl(_token, _to, _amount, _getTvl(_token));
}
/// @notice Transfer with explicit preTvl for rate limiting
/// @dev Use when TVL must be captured before internal token movements
function _protectedTransferWithTvl(
address _token,
address _to,
uint256 _amount,
uint256 _preTvl
)
internal
returns (uint256 queueId)
{
address cb = circuitBreaker();
if (cb == address(0)) {
IERC20(_token).safeTransfer(_to, _amount);
return 0;
}
(bool immediate, uint256 _queueId) =
ICircuitBreakerV2(cb).attemptOutflow(_token, _to, _amount, _preTvl);
if (immediate) {
IERC20(_token).safeTransfer(_to, _amount);
return 0;
} else {
IERC20(_token).safeTransfer(cb, _amount);
emit OutflowQueued(_queueId, _token, _to, _amount);
return _queueId;
}
}
/// @notice Transfer with explicit preTvl and a separate limiter asset for rate limiting
/// @dev Use when the token being transferred differs from the rate-limit bucket key.
/// E.g., wrapper withdrawUnderlying uses the wrapper's `token` as limiter but
/// transfers individual strategy `positionToken`s.
/// @param _transferToken Token actually transferred
/// @param _to Recipient
/// @param _amount Amount of _transferToken to transfer
/// @param _preTvl TVL before the outflow (for capacity calculation)
/// @param _limiterAsset Asset used for rate-limit state (bucket key)
/// @param _limiterAmount Amount in _limiterAsset decimals for rate-limit accounting.
/// When position-token decimals differ from underlying, the caller must normalize.
function _protectedTransferWithTvlAndLimiter(
address _transferToken,
address _to,
uint256 _amount,
uint256 _preTvl,
address _limiterAsset,
uint256 _limiterAmount
)
internal
returns (uint256 queueId)
{
address cb = circuitBreaker();
if (cb == address(0)) {
IERC20(_transferToken).safeTransfer(_to, _amount);
return 0;
}
(bool immediate, uint256 _queueId) = ICircuitBreakerV2(cb)
.attemptOutflowWithLimiter(
_limiterAsset, _transferToken, _to, _limiterAmount, _amount, _preTvl
);
if (immediate) {
IERC20(_transferToken).safeTransfer(_to, _amount);
return 0;
} else {
IERC20(_transferToken).safeTransfer(cb, _amount);
emit OutflowQueued(_queueId, _transferToken, _to, _amount);
return _queueId;
}
}
// ===== Virtual =====
function _getTvl(address _token) internal view virtual returns (uint256);
}
contracts/interfaces/IftYieldWrapperV2.sol
// SPDX-License-Identifier: UNLICENSED
// Copyright (c) 2025 Flying Tulip Inc. All rights reserved.
pragma solidity ^0.8.30;
import {IERC20Metadata} from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
/// @title IftYieldWrapperV2
/// @notice Extended wrapper interface that surfaces queue IDs from withdrawals.
/// @dev Standalone interface — does NOT extend IftYieldWrapper because adding
/// return values to withdraw/withdrawUnderlying would create conflicting
/// selectors (Solidity treats return types as part of override resolution).
/// At the EVM level, function selectors are identical (return types don't
/// affect them), so existing callers using IftYieldWrapper-typed variables
/// continue to work at runtime.
interface IftYieldWrapperV2 is IERC20Metadata {
function token() external view returns (address);
function deposit(uint256 amount) external;
function canWithdraw(uint256 amount) external view returns (bool);
function maxAbleToWithdraw(uint256 amount) external view returns (uint256);
/// @notice Withdraw underlying tokens from the wrapper
/// @param amount The amount of underlying tokens to withdraw
/// @param to The recipient address
/// @return queueId The CB queue entry ID (0 if transfer was immediate)
function withdraw(uint256 amount, address to) external returns (uint256 queueId);
/// @notice Withdraw position tokens directly from strategies
/// @param amount The amount (in share terms) to withdraw
/// @param to The recipient address
/// @return queueIds Per-strategy CB queue entry IDs (0 if immediate or strategy skipped)
function withdrawUnderlying(
uint256 amount,
address to
)
external
returns (uint256[] memory queueIds);
function circuitBreaker() external view returns (address);
function setCircuitBreaker(address _circuitBreaker) external;
}
lib/ft-common-contracts/contracts/interfaces/IStrategy.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.30;
import {IERC20Metadata} from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
interface IStrategy is IERC20Metadata {
event YieldClaimed(address yieldClaimer, address treasury, address token, uint256 amount);
event Deposit(address owner, uint256 amount);
event Withdraw(address owner, uint256 amount);
event WithdrawUnderlying(address owner, uint256 amount);
event UpdateftYieldWrapper(address newftYieldWrapper);
error StrategyNotYieldWrapper();
error StrategyZeroAddress();
error StrategyAmountZero();
error StrategyInsufficientLiquidity();
error StrategyCantInteractWithCoreAssets();
error StrategyCapitalMustNotChange();
function token() external view returns (address);
function valueOfCapital() external view returns (uint256);
function setftYieldWrapper(address _ftYieldWrapper) external;
function capital() external view returns (uint256);
function yield() external view returns (uint256);
function claimYield(address treasury) external returns (uint256);
function execute(
address to,
uint256 value,
bytes calldata data
)
external
returns (bool success, bytes memory result);
function availableToWithdraw() external view returns (uint256);
function maxAbleToWithdraw(uint256 amount) external view returns (uint256);
function withdraw(uint256 amount) external returns (uint256);
function deposit(uint256 amount) external;
/// @dev Address of the strategy's position token (e.g., aToken, stETH, etc)
function positionToken() external view returns (address);
/// @dev Burns wrapper's strategy shares and transfers `amount` of the position token to `to`.
/// Must return the actual amount sent (should be == amount for 1:1 strategies).
function withdrawUnderlying(uint256 amount) external returns (uint256 received);
}
interface IStrategyWithQueue is IStrategy {
event WithdrawQueued(address owner, uint256 amount, uint256 id);
event WithdrawClaimed(address owner, uint256 amount, uint256 id);
function withdrawQueued(uint256 amount) external returns (uint256 id);
function claimQueued(uint256 id) external returns (uint256 received);
}
lib/openzeppelin-contracts/contracts/interfaces/IERC1363.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (interfaces/IERC1363.sol)
pragma solidity >=0.6.2;
import {IERC20} from "./IERC20.sol";
import {IERC165} from "./IERC165.sol";
/**
* @title IERC1363
* @dev Interface of the ERC-1363 standard as defined in the https://eips.ethereum.org/EIPS/eip-1363[ERC-1363].
*
* Defines an extension interface for ERC-20 tokens that supports executing code on a recipient contract
* after `transfer` or `transferFrom`, or code on a spender contract after `approve`, in a single transaction.
*/
interface IERC1363 is IERC20, IERC165 {
/*
* Note: the ERC-165 identifier for this interface is 0xb0202a11.
* 0xb0202a11 ===
* bytes4(keccak256('transferAndCall(address,uint256)')) ^
* bytes4(keccak256('transferAndCall(address,uint256,bytes)')) ^
* bytes4(keccak256('transferFromAndCall(address,address,uint256)')) ^
* bytes4(keccak256('transferFromAndCall(address,address,uint256,bytes)')) ^
* bytes4(keccak256('approveAndCall(address,uint256)')) ^
* bytes4(keccak256('approveAndCall(address,uint256,bytes)'))
*/
/**
* @dev Moves a `value` amount of tokens from the caller's account to `to`
* and then calls {IERC1363Receiver-onTransferReceived} on `to`.
* @param to The address which you want to transfer to.
* @param value The amount of tokens to be transferred.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function transferAndCall(address to, uint256 value) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from the caller's account to `to`
* and then calls {IERC1363Receiver-onTransferReceived} on `to`.
* @param to The address which you want to transfer to.
* @param value The amount of tokens to be transferred.
* @param data Additional data with no specified format, sent in call to `to`.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function transferAndCall(address to, uint256 value, bytes calldata data) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from `from` to `to` using the allowance mechanism
* and then calls {IERC1363Receiver-onTransferReceived} on `to`.
* @param from The address which you want to send tokens from.
* @param to The address which you want to transfer to.
* @param value The amount of tokens to be transferred.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function transferFromAndCall(address from, address to, uint256 value) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from `from` to `to` using the allowance mechanism
* and then calls {IERC1363Receiver-onTransferReceived} on `to`.
* @param from The address which you want to send tokens from.
* @param to The address which you want to transfer to.
* @param value The amount of tokens to be transferred.
* @param data Additional data with no specified format, sent in call to `to`.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function transferFromAndCall(address from, address to, uint256 value, bytes calldata data) external returns (bool);
/**
* @dev Sets a `value` amount of tokens as the allowance of `spender` over the
* caller's tokens and then calls {IERC1363Spender-onApprovalReceived} on `spender`.
* @param spender The address which will spend the funds.
* @param value The amount of tokens to be spent.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function approveAndCall(address spender, uint256 value) external returns (bool);
/**
* @dev Sets a `value` amount of tokens as the allowance of `spender` over the
* caller's tokens and then calls {IERC1363Spender-onApprovalReceived} on `spender`.
* @param spender The address which will spend the funds.
* @param value The amount of tokens to be spent.
* @param data Additional data with no specified format, sent in call to `spender`.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function approveAndCall(address spender, uint256 value, bytes calldata data) external returns (bool);
}
lib/openzeppelin-contracts/contracts/interfaces/IERC165.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (interfaces/IERC165.sol)
pragma solidity >=0.4.16;
import {IERC165} from "../utils/introspection/IERC165.sol";
lib/openzeppelin-contracts/contracts/interfaces/IERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (interfaces/IERC20.sol)
pragma solidity >=0.4.16;
import {IERC20} from "../token/ERC20/IERC20.sol";
lib/openzeppelin-contracts/contracts/interfaces/draft-IERC6093.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.5.0) (interfaces/draft-IERC6093.sol)
pragma solidity >=0.8.4;
/**
* @dev Standard ERC-20 Errors
* Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC-20 tokens.
*/
interface IERC20Errors {
/**
* @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers.
* @param sender Address whose tokens are being transferred.
* @param balance Current balance for the interacting account.
* @param needed Minimum amount required to perform a transfer.
*/
error ERC20InsufficientBalance(address sender, uint256 balance, uint256 needed);
/**
* @dev Indicates a failure with the token `sender`. Used in transfers.
* @param sender Address whose tokens are being transferred.
*/
error ERC20InvalidSender(address sender);
/**
* @dev Indicates a failure with the token `receiver`. Used in transfers.
* @param receiver Address to which tokens are being transferred.
*/
error ERC20InvalidReceiver(address receiver);
/**
* @dev Indicates a failure with the `spender`’s `allowance`. Used in transfers.
* @param spender Address that may be allowed to operate on tokens without being their owner.
* @param allowance Amount of tokens a `spender` is allowed to operate with.
* @param needed Minimum amount required to perform a transfer.
*/
error ERC20InsufficientAllowance(address spender, uint256 allowance, uint256 needed);
/**
* @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.
* @param approver Address initiating an approval operation.
*/
error ERC20InvalidApprover(address approver);
/**
* @dev Indicates a failure with the `spender` to be approved. Used in approvals.
* @param spender Address that may be allowed to operate on tokens without being their owner.
*/
error ERC20InvalidSpender(address spender);
}
/**
* @dev Standard ERC-721 Errors
* Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC-721 tokens.
*/
interface IERC721Errors {
/**
* @dev Indicates that an address can't be an owner. For example, `address(0)` is a forbidden owner in ERC-721.
* Used in balance queries.
* @param owner Address of the current owner of a token.
*/
error ERC721InvalidOwner(address owner);
/**
* @dev Indicates a `tokenId` whose `owner` is the zero address.
* @param tokenId Identifier number of a token.
*/
error ERC721NonexistentToken(uint256 tokenId);
/**
* @dev Indicates an error related to the ownership over a particular token. Used in transfers.
* @param sender Address whose tokens are being transferred.
* @param tokenId Identifier number of a token.
* @param owner Address of the current owner of a token.
*/
error ERC721IncorrectOwner(address sender, uint256 tokenId, address owner);
/**
* @dev Indicates a failure with the token `sender`. Used in transfers.
* @param sender Address whose tokens are being transferred.
*/
error ERC721InvalidSender(address sender);
/**
* @dev Indicates a failure with the token `receiver`. Used in transfers.
* @param receiver Address to which tokens are being transferred.
*/
error ERC721InvalidReceiver(address receiver);
/**
* @dev Indicates a failure with the `operator`’s approval. Used in transfers.
* @param operator Address that may be allowed to operate on tokens without being their owner.
* @param tokenId Identifier number of a token.
*/
error ERC721InsufficientApproval(address operator, uint256 tokenId);
/**
* @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.
* @param approver Address initiating an approval operation.
*/
error ERC721InvalidApprover(address approver);
/**
* @dev Indicates a failure with the `operator` to be approved. Used in approvals.
* @param operator Address that may be allowed to operate on tokens without being their owner.
*/
error ERC721InvalidOperator(address operator);
}
/**
* @dev Standard ERC-1155 Errors
* Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC-1155 tokens.
*/
interface IERC1155Errors {
/**
* @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers.
* @param sender Address whose tokens are being transferred.
* @param balance Current balance for the interacting account.
* @param needed Minimum amount required to perform a transfer.
* @param tokenId Identifier number of a token.
*/
error ERC1155InsufficientBalance(address sender, uint256 balance, uint256 needed, uint256 tokenId);
/**
* @dev Indicates a failure with the token `sender`. Used in transfers.
* @param sender Address whose tokens are being transferred.
*/
error ERC1155InvalidSender(address sender);
/**
* @dev Indicates a failure with the token `receiver`. Used in transfers.
* @param receiver Address to which tokens are being transferred.
*/
error ERC1155InvalidReceiver(address receiver);
/**
* @dev Indicates a failure with the `operator`’s approval. Used in transfers.
* @param operator Address that may be allowed to operate on tokens without being their owner.
* @param owner Address of the current owner of a token.
*/
error ERC1155MissingApprovalForAll(address operator, address owner);
/**
* @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.
* @param approver Address initiating an approval operation.
*/
error ERC1155InvalidApprover(address approver);
/**
* @dev Indicates a failure with the `operator` to be approved. Used in approvals.
* @param operator Address that may be allowed to operate on tokens without being their owner.
*/
error ERC1155InvalidOperator(address operator);
/**
* @dev Indicates an array length mismatch between ids and values in a safeBatchTransferFrom operation.
* Used in batch transfers.
* @param idsLength Length of the array of token identifiers
* @param valuesLength Length of the array of token amounts
*/
error ERC1155InvalidArrayLength(uint256 idsLength, uint256 valuesLength);
}
lib/openzeppelin-contracts/contracts/token/ERC20/ERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.5.0) (token/ERC20/ERC20.sol)
pragma solidity ^0.8.20;
import {IERC20} from "./IERC20.sol";
import {IERC20Metadata} from "./extensions/IERC20Metadata.sol";
import {Context} from "../../utils/Context.sol";
import {IERC20Errors} from "../../interfaces/draft-IERC6093.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}.
*
* 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 ERC-20
* applications.
*/
abstract contract ERC20 is Context, IERC20, IERC20Metadata, IERC20Errors {
mapping(address account => uint256) private _balances;
mapping(address account => mapping(address spender => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
/**
* @dev Sets the values for {name} and {symbol}.
*
* Both 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 returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view virtual 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 returns (uint8) {
return 18;
}
/// @inheritdoc IERC20
function totalSupply() public view virtual returns (uint256) {
return _totalSupply;
}
/// @inheritdoc IERC20
function balanceOf(address account) public view virtual 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 `value`.
*/
function transfer(address to, uint256 value) public virtual returns (bool) {
address owner = _msgSender();
_transfer(owner, to, value);
return true;
}
/// @inheritdoc IERC20
function allowance(address owner, address spender) public view virtual returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* NOTE: If `value` 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 value) public virtual returns (bool) {
address owner = _msgSender();
_approve(owner, spender, value);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Skips emitting an {Approval} event indicating an allowance update. This is not
* required by the ERC. See {xref-ERC20-_approve-address-address-uint256-bool-}[_approve].
*
* 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 `value`.
* - the caller must have allowance for ``from``'s tokens of at least
* `value`.
*/
function transferFrom(address from, address to, uint256 value) public virtual returns (bool) {
address spender = _msgSender();
_spendAllowance(from, spender, value);
_transfer(from, to, value);
return true;
}
/**
* @dev Moves a `value` 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.
*
* NOTE: This function is not virtual, {_update} should be overridden instead.
*/
function _transfer(address from, address to, uint256 value) internal {
if (from == address(0)) {
revert ERC20InvalidSender(address(0));
}
if (to == address(0)) {
revert ERC20InvalidReceiver(address(0));
}
_update(from, to, value);
}
/**
* @dev Transfers a `value` amount of tokens from `from` to `to`, or alternatively mints (or burns) if `from`
* (or `to`) is the zero address. All customizations to transfers, mints, and burns should be done by overriding
* this function.
*
* Emits a {Transfer} event.
*/
function _update(address from, address to, uint256 value) internal virtual {
if (from == address(0)) {
// Overflow check required: The rest of the code assumes that totalSupply never overflows
_totalSupply += value;
} else {
uint256 fromBalance = _balances[from];
if (fromBalance < value) {
revert ERC20InsufficientBalance(from, fromBalance, value);
}
unchecked {
// Overflow not possible: value <= fromBalance <= totalSupply.
_balances[from] = fromBalance - value;
}
}
if (to == address(0)) {
unchecked {
// Overflow not possible: value <= totalSupply or value <= fromBalance <= totalSupply.
_totalSupply -= value;
}
} else {
unchecked {
// Overflow not possible: balance + value is at most totalSupply, which we know fits into a uint256.
_balances[to] += value;
}
}
emit Transfer(from, to, value);
}
/**
* @dev Creates a `value` amount of tokens and assigns them to `account`, by transferring it from address(0).
* Relies on the `_update` mechanism
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* NOTE: This function is not virtual, {_update} should be overridden instead.
*/
function _mint(address account, uint256 value) internal {
if (account == address(0)) {
revert ERC20InvalidReceiver(address(0));
}
_update(address(0), account, value);
}
/**
* @dev Destroys a `value` amount of tokens from `account`, lowering the total supply.
* Relies on the `_update` mechanism.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* NOTE: This function is not virtual, {_update} should be overridden instead
*/
function _burn(address account, uint256 value) internal {
if (account == address(0)) {
revert ERC20InvalidSender(address(0));
}
_update(account, address(0), value);
}
/**
* @dev Sets `value` 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.
*
* Overrides to this logic should be done to the variant with an additional `bool emitEvent` argument.
*/
function _approve(address owner, address spender, uint256 value) internal {
_approve(owner, spender, value, true);
}
/**
* @dev Variant of {_approve} with an optional flag to enable or disable the {Approval} event.
*
* By default (when calling {_approve}) the flag is set to true. On the other hand, approval changes made by
* `_spendAllowance` during the `transferFrom` operation sets the flag to false. This saves gas by not emitting any
* `Approval` event during `transferFrom` operations.
*
* Anyone who wishes to continue emitting `Approval` events on the `transferFrom` operation can force the flag to
* true using the following override:
*
* ```solidity
* function _approve(address owner, address spender, uint256 value, bool) internal virtual override {
* super._approve(owner, spender, value, true);
* }
* ```
*
* Requirements are the same as {_approve}.
*/
function _approve(address owner, address spender, uint256 value, bool emitEvent) internal virtual {
if (owner == address(0)) {
revert ERC20InvalidApprover(address(0));
}
if (spender == address(0)) {
revert ERC20InvalidSpender(address(0));
}
_allowances[owner][spender] = value;
if (emitEvent) {
emit Approval(owner, spender, value);
}
}
/**
* @dev Updates `owner`'s allowance for `spender` based on spent `value`.
*
* Does not update the allowance value in case of infinite allowance.
* Revert if not enough allowance is available.
*
* Does not emit an {Approval} event.
*/
function _spendAllowance(address owner, address spender, uint256 value) internal virtual {
uint256 currentAllowance = allowance(owner, spender);
if (currentAllowance < type(uint256).max) {
if (currentAllowance < value) {
revert ERC20InsufficientAllowance(spender, currentAllowance, value);
}
unchecked {
_approve(owner, spender, currentAllowance - value, false);
}
}
}
}
lib/openzeppelin-contracts/contracts/token/ERC20/IERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (token/ERC20/IERC20.sol)
pragma solidity >=0.4.16;
/**
* @dev Interface of the ERC-20 standard as defined in the ERC.
*/
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 value of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the value of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves a `value` amount of 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 value) 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 a `value` amount of tokens 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 value) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from `from` to `to` using the
* allowance mechanism. `value` 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 value) external returns (bool);
}
lib/openzeppelin-contracts/contracts/token/ERC20/extensions/IERC20Metadata.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (token/ERC20/extensions/IERC20Metadata.sol)
pragma solidity >=0.6.2;
import {IERC20} from "../IERC20.sol";
/**
* @dev Interface for the optional metadata functions from the ERC-20 standard.
*/
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);
}
lib/openzeppelin-contracts/contracts/token/ERC20/utils/SafeERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.5.0) (token/ERC20/utils/SafeERC20.sol)
pragma solidity ^0.8.20;
import {IERC20} from "../IERC20.sol";
import {IERC1363} from "../../../interfaces/IERC1363.sol";
/**
* @title SafeERC20
* @dev Wrappers around ERC-20 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 {
/**
* @dev An operation with an ERC-20 token failed.
*/
error SafeERC20FailedOperation(address token);
/**
* @dev Indicates a failed `decreaseAllowance` request.
*/
error SafeERC20FailedDecreaseAllowance(address spender, uint256 currentAllowance, uint256 requestedDecrease);
/**
* @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 {
if (!_safeTransfer(token, to, value, true)) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @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 {
if (!_safeTransferFrom(token, from, to, value, true)) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @dev Variant of {safeTransfer} that returns a bool instead of reverting if the operation is not successful.
*/
function trySafeTransfer(IERC20 token, address to, uint256 value) internal returns (bool) {
return _safeTransfer(token, to, value, false);
}
/**
* @dev Variant of {safeTransferFrom} that returns a bool instead of reverting if the operation is not successful.
*/
function trySafeTransferFrom(IERC20 token, address from, address to, uint256 value) internal returns (bool) {
return _safeTransferFrom(token, from, to, value, false);
}
/**
* @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*
* IMPORTANT: If the token implements ERC-7674 (ERC-20 with temporary allowance), and if the "client"
* smart contract uses ERC-7674 to set temporary allowances, then the "client" smart contract should avoid using
* this function. Performing a {safeIncreaseAllowance} or {safeDecreaseAllowance} operation on a token contract
* that has a non-zero temporary allowance (for that particular owner-spender) will result in unexpected behavior.
*/
function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
uint256 oldAllowance = token.allowance(address(this), spender);
forceApprove(token, spender, oldAllowance + value);
}
/**
* @dev Decrease the calling contract's allowance toward `spender` by `requestedDecrease`. If `token` returns no
* value, non-reverting calls are assumed to be successful.
*
* IMPORTANT: If the token implements ERC-7674 (ERC-20 with temporary allowance), and if the "client"
* smart contract uses ERC-7674 to set temporary allowances, then the "client" smart contract should avoid using
* this function. Performing a {safeIncreaseAllowance} or {safeDecreaseAllowance} operation on a token contract
* that has a non-zero temporary allowance (for that particular owner-spender) will result in unexpected behavior.
*/
function safeDecreaseAllowance(IERC20 token, address spender, uint256 requestedDecrease) internal {
unchecked {
uint256 currentAllowance = token.allowance(address(this), spender);
if (currentAllowance < requestedDecrease) {
revert SafeERC20FailedDecreaseAllowance(spender, currentAllowance, requestedDecrease);
}
forceApprove(token, spender, currentAllowance - requestedDecrease);
}
}
/**
* @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.
*
* NOTE: If the token implements ERC-7674, this function will not modify any temporary allowance. This function
* only sets the "standard" allowance. Any temporary allowance will remain active, in addition to the value being
* set here.
*/
function forceApprove(IERC20 token, address spender, uint256 value) internal {
if (!_safeApprove(token, spender, value, false)) {
if (!_safeApprove(token, spender, 0, true)) revert SafeERC20FailedOperation(address(token));
if (!_safeApprove(token, spender, value, true)) revert SafeERC20FailedOperation(address(token));
}
}
/**
* @dev Performs an {ERC1363} transferAndCall, with a fallback to the simple {ERC20} transfer if the target has no
* code. This can be used to implement an {ERC721}-like safe transfer that relies on {ERC1363} checks when
* targeting contracts.
*
* Reverts if the returned value is other than `true`.
*/
function transferAndCallRelaxed(IERC1363 token, address to, uint256 value, bytes memory data) internal {
if (to.code.length == 0) {
safeTransfer(token, to, value);
} else if (!token.transferAndCall(to, value, data)) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @dev Performs an {ERC1363} transferFromAndCall, with a fallback to the simple {ERC20} transferFrom if the target
* has no code. This can be used to implement an {ERC721}-like safe transfer that relies on {ERC1363} checks when
* targeting contracts.
*
* Reverts if the returned value is other than `true`.
*/
function transferFromAndCallRelaxed(
IERC1363 token,
address from,
address to,
uint256 value,
bytes memory data
) internal {
if (to.code.length == 0) {
safeTransferFrom(token, from, to, value);
} else if (!token.transferFromAndCall(from, to, value, data)) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @dev Performs an {ERC1363} approveAndCall, with a fallback to the simple {ERC20} approve if the target has no
* code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when
* targeting contracts.
*
* NOTE: When the recipient address (`to`) has no code (i.e. is an EOA), this function behaves as {forceApprove}.
* Oppositely, when the recipient address (`to`) has code, this function only attempts to call {ERC1363-approveAndCall}
* once without retrying, and relies on the returned value to be true.
*
* Reverts if the returned value is other than `true`.
*/
function approveAndCallRelaxed(IERC1363 token, address to, uint256 value, bytes memory data) internal {
if (to.code.length == 0) {
forceApprove(token, to, value);
} else if (!token.approveAndCall(to, value, data)) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @dev Imitates a Solidity `token.transfer(to, value)` call, 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 to The recipient of the tokens
* @param value The amount of token to transfer
* @param bubble Behavior switch if the transfer call reverts: bubble the revert reason or return a false boolean.
*/
function _safeTransfer(IERC20 token, address to, uint256 value, bool bubble) private returns (bool success) {
bytes4 selector = IERC20.transfer.selector;
assembly ("memory-safe") {
let fmp := mload(0x40)
mstore(0x00, selector)
mstore(0x04, and(to, shr(96, not(0))))
mstore(0x24, value)
success := call(gas(), token, 0, 0x00, 0x44, 0x00, 0x20)
// if call success and return is true, all is good.
// otherwise (not success or return is not true), we need to perform further checks
if iszero(and(success, eq(mload(0x00), 1))) {
// if the call was a failure and bubble is enabled, bubble the error
if and(iszero(success), bubble) {
returndatacopy(fmp, 0x00, returndatasize())
revert(fmp, returndatasize())
}
// if the return value is not true, then the call is only successful if:
// - the token address has code
// - the returndata is empty
success := and(success, and(iszero(returndatasize()), gt(extcodesize(token), 0)))
}
mstore(0x40, fmp)
}
}
/**
* @dev Imitates a Solidity `token.transferFrom(from, to, value)` call, 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 from The sender of the tokens
* @param to The recipient of the tokens
* @param value The amount of token to transfer
* @param bubble Behavior switch if the transfer call reverts: bubble the revert reason or return a false boolean.
*/
function _safeTransferFrom(
IERC20 token,
address from,
address to,
uint256 value,
bool bubble
) private returns (bool success) {
bytes4 selector = IERC20.transferFrom.selector;
assembly ("memory-safe") {
let fmp := mload(0x40)
mstore(0x00, selector)
mstore(0x04, and(from, shr(96, not(0))))
mstore(0x24, and(to, shr(96, not(0))))
mstore(0x44, value)
success := call(gas(), token, 0, 0x00, 0x64, 0x00, 0x20)
// if call success and return is true, all is good.
// otherwise (not success or return is not true), we need to perform further checks
if iszero(and(success, eq(mload(0x00), 1))) {
// if the call was a failure and bubble is enabled, bubble the error
if and(iszero(success), bubble) {
returndatacopy(fmp, 0x00, returndatasize())
revert(fmp, returndatasize())
}
// if the return value is not true, then the call is only successful if:
// - the token address has code
// - the returndata is empty
success := and(success, and(iszero(returndatasize()), gt(extcodesize(token), 0)))
}
mstore(0x40, fmp)
mstore(0x60, 0)
}
}
/**
* @dev Imitates a Solidity `token.approve(spender, value)` call, 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 spender The spender of the tokens
* @param value The amount of token to transfer
* @param bubble Behavior switch if the transfer call reverts: bubble the revert reason or return a false boolean.
*/
function _safeApprove(IERC20 token, address spender, uint256 value, bool bubble) private returns (bool success) {
bytes4 selector = IERC20.approve.selector;
assembly ("memory-safe") {
let fmp := mload(0x40)
mstore(0x00, selector)
mstore(0x04, and(spender, shr(96, not(0))))
mstore(0x24, value)
success := call(gas(), token, 0, 0x00, 0x44, 0x00, 0x20)
// if call success and return is true, all is good.
// otherwise (not success or return is not true), we need to perform further checks
if iszero(and(success, eq(mload(0x00), 1))) {
// if the call was a failure and bubble is enabled, bubble the error
if and(iszero(success), bubble) {
returndatacopy(fmp, 0x00, returndatasize())
revert(fmp, returndatasize())
}
// if the return value is not true, then the call is only successful if:
// - the token address has code
// - the returndata is empty
success := and(success, and(iszero(returndatasize()), gt(extcodesize(token), 0)))
}
mstore(0x40, fmp)
}
}
}
lib/openzeppelin-contracts/contracts/utils/Context.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)
pragma solidity ^0.8.20;
/**
* @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;
}
}
lib/openzeppelin-contracts/contracts/utils/ReentrancyGuardTransient.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.5.0) (utils/ReentrancyGuardTransient.sol)
pragma solidity ^0.8.24;
import {TransientSlot} from "./TransientSlot.sol";
/**
* @dev Variant of {ReentrancyGuard} that uses transient storage.
*
* NOTE: This variant only works on networks where EIP-1153 is available.
*
* _Available since v5.1._
*
* @custom:stateless
*/
abstract contract ReentrancyGuardTransient {
using TransientSlot for *;
// keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.ReentrancyGuard")) - 1)) & ~bytes32(uint256(0xff))
bytes32 private constant REENTRANCY_GUARD_STORAGE =
0x9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f00;
/**
* @dev Unauthorized reentrant call.
*/
error ReentrancyGuardReentrantCall();
/**
* @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();
}
/**
* @dev A `view` only version of {nonReentrant}. Use to block view functions
* from being called, preventing reading from inconsistent contract state.
*
* CAUTION: This is a "view" modifier and does not change the reentrancy
* status. Use it only on view functions. For payable or non-payable functions,
* use the standard {nonReentrant} modifier instead.
*/
modifier nonReentrantView() {
_nonReentrantBeforeView();
_;
}
function _nonReentrantBeforeView() private view {
if (_reentrancyGuardEntered()) {
revert ReentrancyGuardReentrantCall();
}
}
function _nonReentrantBefore() private {
// On the first call to nonReentrant, REENTRANCY_GUARD_STORAGE.asBoolean().tload() will be false
_nonReentrantBeforeView();
// Any calls to nonReentrant after this point will fail
_reentrancyGuardStorageSlot().asBoolean().tstore(true);
}
function _nonReentrantAfter() private {
_reentrancyGuardStorageSlot().asBoolean().tstore(false);
}
/**
* @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 _reentrancyGuardStorageSlot().asBoolean().tload();
}
function _reentrancyGuardStorageSlot() internal pure virtual returns (bytes32) {
return REENTRANCY_GUARD_STORAGE;
}
}
lib/openzeppelin-contracts/contracts/utils/StorageSlot.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/StorageSlot.sol)
// This file was procedurally generated from scripts/generate/templates/StorageSlot.js.
pragma solidity ^0.8.20;
/**
* @dev Library for reading and writing primitive types to specific storage slots.
*
* Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.
* This library helps with reading and writing to such slots without the need for inline assembly.
*
* The functions in this library return Slot structs that contain a `value` member that can be used to read or write.
*
* Example usage to set ERC-1967 implementation slot:
* ```solidity
* contract ERC1967 {
* // Define the slot. Alternatively, use the SlotDerivation library to derive the slot.
* bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
*
* function _getImplementation() internal view returns (address) {
* return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;
* }
*
* function _setImplementation(address newImplementation) internal {
* require(newImplementation.code.length > 0);
* StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
* }
* }
* ```
*
* TIP: Consider using this library along with {SlotDerivation}.
*/
library StorageSlot {
struct AddressSlot {
address value;
}
struct BooleanSlot {
bool value;
}
struct Bytes32Slot {
bytes32 value;
}
struct Uint256Slot {
uint256 value;
}
struct Int256Slot {
int256 value;
}
struct StringSlot {
string value;
}
struct BytesSlot {
bytes value;
}
/**
* @dev Returns an `AddressSlot` with member `value` located at `slot`.
*/
function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {
assembly ("memory-safe") {
r.slot := slot
}
}
/**
* @dev Returns a `BooleanSlot` with member `value` located at `slot`.
*/
function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {
assembly ("memory-safe") {
r.slot := slot
}
}
/**
* @dev Returns a `Bytes32Slot` with member `value` located at `slot`.
*/
function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {
assembly ("memory-safe") {
r.slot := slot
}
}
/**
* @dev Returns a `Uint256Slot` with member `value` located at `slot`.
*/
function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {
assembly ("memory-safe") {
r.slot := slot
}
}
/**
* @dev Returns a `Int256Slot` with member `value` located at `slot`.
*/
function getInt256Slot(bytes32 slot) internal pure returns (Int256Slot storage r) {
assembly ("memory-safe") {
r.slot := slot
}
}
/**
* @dev Returns a `StringSlot` with member `value` located at `slot`.
*/
function getStringSlot(bytes32 slot) internal pure returns (StringSlot storage r) {
assembly ("memory-safe") {
r.slot := slot
}
}
/**
* @dev Returns an `StringSlot` representation of the string storage pointer `store`.
*/
function getStringSlot(string storage store) internal pure returns (StringSlot storage r) {
assembly ("memory-safe") {
r.slot := store.slot
}
}
/**
* @dev Returns a `BytesSlot` with member `value` located at `slot`.
*/
function getBytesSlot(bytes32 slot) internal pure returns (BytesSlot storage r) {
assembly ("memory-safe") {
r.slot := slot
}
}
/**
* @dev Returns an `BytesSlot` representation of the bytes storage pointer `store`.
*/
function getBytesSlot(bytes storage store) internal pure returns (BytesSlot storage r) {
assembly ("memory-safe") {
r.slot := store.slot
}
}
}
lib/openzeppelin-contracts/contracts/utils/TransientSlot.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.3.0) (utils/TransientSlot.sol)
// This file was procedurally generated from scripts/generate/templates/TransientSlot.js.
pragma solidity ^0.8.24;
/**
* @dev Library for reading and writing value-types to specific transient storage slots.
*
* Transient slots are often used to store temporary values that are removed after the current transaction.
* This library helps with reading and writing to such slots without the need for inline assembly.
*
* * Example reading and writing values using transient storage:
* ```solidity
* contract Lock {
* using TransientSlot for *;
*
* // Define the slot. Alternatively, use the SlotDerivation library to derive the slot.
* bytes32 internal constant _LOCK_SLOT = 0xf4678858b2b588224636b8522b729e7722d32fc491da849ed75b3fdf3c84f542;
*
* modifier locked() {
* require(!_LOCK_SLOT.asBoolean().tload());
*
* _LOCK_SLOT.asBoolean().tstore(true);
* _;
* _LOCK_SLOT.asBoolean().tstore(false);
* }
* }
* ```
*
* TIP: Consider using this library along with {SlotDerivation}.
*/
library TransientSlot {
/**
* @dev UDVT that represents a slot holding an address.
*/
type AddressSlot is bytes32;
/**
* @dev Cast an arbitrary slot to a AddressSlot.
*/
function asAddress(bytes32 slot) internal pure returns (AddressSlot) {
return AddressSlot.wrap(slot);
}
/**
* @dev UDVT that represents a slot holding a bool.
*/
type BooleanSlot is bytes32;
/**
* @dev Cast an arbitrary slot to a BooleanSlot.
*/
function asBoolean(bytes32 slot) internal pure returns (BooleanSlot) {
return BooleanSlot.wrap(slot);
}
/**
* @dev UDVT that represents a slot holding a bytes32.
*/
type Bytes32Slot is bytes32;
/**
* @dev Cast an arbitrary slot to a Bytes32Slot.
*/
function asBytes32(bytes32 slot) internal pure returns (Bytes32Slot) {
return Bytes32Slot.wrap(slot);
}
/**
* @dev UDVT that represents a slot holding a uint256.
*/
type Uint256Slot is bytes32;
/**
* @dev Cast an arbitrary slot to a Uint256Slot.
*/
function asUint256(bytes32 slot) internal pure returns (Uint256Slot) {
return Uint256Slot.wrap(slot);
}
/**
* @dev UDVT that represents a slot holding a int256.
*/
type Int256Slot is bytes32;
/**
* @dev Cast an arbitrary slot to a Int256Slot.
*/
function asInt256(bytes32 slot) internal pure returns (Int256Slot) {
return Int256Slot.wrap(slot);
}
/**
* @dev Load the value held at location `slot` in transient storage.
*/
function tload(AddressSlot slot) internal view returns (address value) {
assembly ("memory-safe") {
value := tload(slot)
}
}
/**
* @dev Store `value` at location `slot` in transient storage.
*/
function tstore(AddressSlot slot, address value) internal {
assembly ("memory-safe") {
tstore(slot, value)
}
}
/**
* @dev Load the value held at location `slot` in transient storage.
*/
function tload(BooleanSlot slot) internal view returns (bool value) {
assembly ("memory-safe") {
value := tload(slot)
}
}
/**
* @dev Store `value` at location `slot` in transient storage.
*/
function tstore(BooleanSlot slot, bool value) internal {
assembly ("memory-safe") {
tstore(slot, value)
}
}
/**
* @dev Load the value held at location `slot` in transient storage.
*/
function tload(Bytes32Slot slot) internal view returns (bytes32 value) {
assembly ("memory-safe") {
value := tload(slot)
}
}
/**
* @dev Store `value` at location `slot` in transient storage.
*/
function tstore(Bytes32Slot slot, bytes32 value) internal {
assembly ("memory-safe") {
tstore(slot, value)
}
}
/**
* @dev Load the value held at location `slot` in transient storage.
*/
function tload(Uint256Slot slot) internal view returns (uint256 value) {
assembly ("memory-safe") {
value := tload(slot)
}
}
/**
* @dev Store `value` at location `slot` in transient storage.
*/
function tstore(Uint256Slot slot, uint256 value) internal {
assembly ("memory-safe") {
tstore(slot, value)
}
}
/**
* @dev Load the value held at location `slot` in transient storage.
*/
function tload(Int256Slot slot) internal view returns (int256 value) {
assembly ("memory-safe") {
value := tload(slot)
}
}
/**
* @dev Store `value` at location `slot` in transient storage.
*/
function tstore(Int256Slot slot, int256 value) internal {
assembly ("memory-safe") {
tstore(slot, value)
}
}
}
lib/openzeppelin-contracts/contracts/utils/introspection/IERC165.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (utils/introspection/IERC165.sol)
pragma solidity >=0.4.16;
/**
* @dev Interface of the ERC-165 standard, as defined in the
* https://eips.ethereum.org/EIPS/eip-165[ERC].
*
* Implementers can declare support of contract interfaces, which can then be
* queried by others ({ERC165Checker}).
*
* For an implementation, see {ERC165}.
*/
interface IERC165 {
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[ERC section]
* to learn more about how these ids are created.
*
* This function call must use less than 30 000 gas.
*/
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}
Compiler settingsShow
{
"viaIR": true,
"metadata": {
"appendCBOR": false,
"bytecodeHash": "none",
"useLiteralContent": false
},
"optimizer": {
"runs": 200,
"enabled": true
},
"evmVersion": "cancun",
"remappings": [
"@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/",
"@openzeppelin/contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/",
"erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/",
"forge-std/=lib/forge-std/src/",
"halmos-cheatcodes/=lib/openzeppelin-contracts/lib/halmos-cheatcodes/src/",
"openzeppelin-contracts/=lib/openzeppelin-contracts/",
"openzeppelin-contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/",
"@ft-common/=lib/ft-common-contracts/contracts/",
"murky/=lib/murky/src/",
"ds-test/=lib/ft-common-contracts/lib/openzeppelin-contracts/lib/forge-std/lib/ds-test/src/",
"ft-common-contracts/=lib/ft-common-contracts/contracts/"
]
}Source code and metadata: Sourcify.
The source code belongs to the authors of the contract.