ftYieldWrapper
Overview
The ftYieldWrapper contract is a capital management system that wraps a single underlying asset (e.g., USDCUSDCStablecoins accepted in PCA contributions and used across products; each has distinct risk/peg mechanics.View glossary entry) and issues corresponding ftTokens (e.g., ftUSDC). It enables deploying assets across multiple yield-generating strategies while maintaining a unified interface for deposits, withdrawals, and yield claiming. The contract serves as a key infrastructure component for Flying Tulip's yield generation and capital efficiencycapital efficiencyUsing the same collateral to support multiple activities (e.g., accrue yield and back trading/borrowing) to increase effective return per unit of capital.View glossary entry.
Access Control
The contract has four privileged roles:
- Yield Claimer: Primary administrator who can deploy capital to strategies, force withdrawals, and claim yield. Also manages the role assignments.
- StrategyStrategyA yield venue tracked by the wrapper; strategies can be added/removed/reordered and capital moved between them by authorized roles.View glossary entry Manager: Responsible for adding, removing, and reordering strategies.
- Treasury: Receives claimed yield and serves as a confirming party for role changes.
- Sub Yield Claimer: Secondary yield claiming role with limited permissions.
These roles operate with a two-step confirmation process for critical changes, enhancing security.
Contract Inheritance
The contract also inherits all standard ERC20 view and transfer functions.
Write Functions
setYieldClaimer
Sets a new yield claimer (requires confirmation)
function setYieldClaimer(address _yieldClaimer) external onlyYieldClaimer
Parameters
_yieldClaimer:: Address of the proposed new yield claimer
setSubYieldClaimer
Sets the sub yield claimer directly
function setSubYieldClaimer(address _subYieldClaimer) external onlyYieldClaimer
Parameters
_subYieldClaimer: Address of the new sub yield claimer
confirmYieldClaimer
Confirms a pending yield claimer change
function confirmYieldClaimer() external
setStrategyManager
Sets a new strategystrategyA yield venue tracked by the wrapper; strategies can be added/removed/reordered and capital moved between them by authorized roles.View glossary entry manager (requires confirmation)
function setStrategyManager(address _strategyManager) external onlyStrategyManager
Parameters
_strategyManager: Address of the proposed new strategystrategyA yield venue tracked by the wrapper; strategies can be added/removed/reordered and capital moved between them by authorized roles.View glossary entry manager
confirmStrategyManager
Confirms a pending strategystrategyA yield venue tracked by the wrapper; strategies can be added/removed/reordered and capital moved between them by authorized roles.View glossary entry manager change
function confirmStrategyManager() external
setTreasury
Sets a new treasury (requires confirmation)
function setTreasury(address _treasury) external
Parameters
_treasury: Address of the proposed new treasury
confirmTreasury
Confirms a pending treasury change
function confirmTreasury() external
setStrategy
Sets a new strategystrategyA yield venue tracked by the wrapper; strategies can be added/removed/reordered and capital moved between them by authorized roles.View glossary entry to be added (requires confirmation)
function setStrategy(address _strategy) external onlyStrategyManager
Parameters
_strategy: Address of the strategystrategyA yield venue tracked by the wrapper; strategies can be added/removed/reordered and capital moved between them by authorized roles.View glossary entry to add
confirmStrategy
Confirms adding a pending strategystrategyA yield venue tracked by the wrapper; strategies can be added/removed/reordered and capital moved between them by authorized roles.View glossary entry
function confirmStrategy() external
removeStrategy
Removes a strategystrategyA yield venue tracked by the wrapper; strategies can be added/removed/reordered and capital moved between them by authorized roles.View glossary entry whose wrapper share balance is zero
function removeStrategy(uint256 index) external onlyStrategyManager
Parameters
index: Index of the strategystrategyA yield venue tracked by the wrapper; strategies can be added/removed/reordered and capital moved between them by authorized roles.View glossary entry to remove
setStrategiesOrder
Reorders strategies for withdrawal priority
function setStrategiesOrder(address[] calldata _newOrder) external onlyStrategyManager
Parameters
_newOrder: Array of strategystrategyA yield venue tracked by the wrapper; strategies can be added/removed/reordered and capital moved between them by authorized roles.View glossary entry addresses in the desired order
claimYield
Claims yield from a specific strategystrategyA yield venue tracked by the wrapper; strategies can be added/removed/reordered and capital moved between them by authorized roles.View glossary entry
function claimYield(address _strategy) external onlyYieldClaimers returns (uint256 _yield)
Parameters
_strategy: The strategystrategyA yield venue tracked by the wrapper; strategies can be added/removed/reordered and capital moved between them by authorized roles.View glossary entry to claim yield from
Returns
_yield: Amount of yield claimed
claimYields
Claims yield from all registered strategies
function claimYields() external onlyYieldClaimers returns (uint256 _yield)
Returns
_yield: Total amount of yield claimed
claimMerkl
Claims Merkle rewards from a strategystrategyA yield venue tracked by the wrapper; strategies can be added/removed/reordered and capital moved between them by authorized roles.View glossary entry
function claimMerkl(address _strategy, address[] calldata users, address[] calldata tokens, uint256[] calldata amounts, bytes32[][] calldata proofs) external onlyYieldClaimers
Parameters
_strategy: StrategyStrategyA yield venue tracked by the wrapper; strategies can be added/removed/reordered and capital moved between them by authorized roles.View glossary entry to claim Merkle rewards from
users: Array of user addresses
tokens: Array of token addresses
amounts: Array of token amounts
proofs: Array of Merkle proofs
execute
Executes a custom function call on a strategystrategyA yield venue tracked by the wrapper; strategies can be added/removed/reordered and capital moved between them by authorized roles.View glossary entry
function execute(address _strategy, address to, uint256 value, bytes calldata data) external onlyYieldClaimers returns (bool success, bytes memory result)
Parameters
_strategy: StrategyStrategyA yield venue tracked by the wrapper; strategies can be added/removed/reordered and capital moved between them by authorized roles.View glossary entry to execute the call on
to: Target address for the call
value: Native token value to send
data: Call data
Returns
success: Whether the call was successful
result: Return data from the call
deposit
Deposits underlying tokens and mints wrapper tokens
function deposit(uint256 amount) external nonReentrant
Parameters
amount: Amount of underlying tokens to deposit
withdraw
Burns wrapper tokens and returns underlying tokens
function withdraw(uint256 amount, address to) external nonReentrant
Parameters
amount: Amount of wrapper tokens to burn
to: Address to receive the underlying tokens
withdrawUnderlying
Burns wrapper tokens and returns position tokens
function withdrawUnderlying(uint256 amount, address to) external nonReentrant
Parameters
amount: Amount of wrapper tokens to burn
to: Address to receive the position tokens
deploy
Deploys capital to a registered strategystrategyA yield venue tracked by the wrapper; strategies can be added/removed/reordered and capital moved between them by authorized roles.View glossary entry
function deploy(address strategy, uint256 amount) external onlyYieldClaimer nonReentrant
Parameters
strategy: StrategyStrategyA yield venue tracked by the wrapper; strategies can be added/removed/reordered and capital moved between them by authorized roles.View glossary entry to deploy capital to
amount: Amount of underlying tokens to deploy
forceWithdrawToWrapper
Forces withdrawal from a strategystrategyA yield venue tracked by the wrapper; strategies can be added/removed/reordered and capital moved between them by authorized roles.View glossary entry to the wrapper
function forceWithdrawToWrapper(address strategy, uint256 amount) external onlyYieldClaimer nonReentrant
Parameters
strategy: StrategyStrategyA yield venue tracked by the wrapper; strategies can be added/removed/reordered and capital moved between them by authorized roles.View glossary entry to withdraw from
amount: Amount of tokens to withdraw
withdrawQueued
QueuesQueuesWaiting periods required to withdraw from certain staking positions (e.g., stETH withdrawals, SOL/AVAX unbonding).View glossary entry a withdrawal from a strategystrategyA yield venue tracked by the wrapper; strategies can be added/removed/reordered and capital moved between them by authorized roles.View glossary entry
function withdrawQueued(address strategy, uint256 amount) external onlyYieldClaimer nonReentrant returns (uint256 id)
Parameters
strategy: StrategyStrategyA yield venue tracked by the wrapper; strategies can be added/removed/reordered and capital moved between them by authorized roles.View glossary entry to queue withdrawal from
amount: Amount to withdraw
Returns
id: Withdrawal queue ID
claimQueued
Claims a queued withdrawal
function claimQueued(address strategy, uint256 id) external onlyYieldClaimer nonReentrant returns (uint256 received)
Parameters
strategy: StrategyStrategyA yield venue tracked by the wrapper; strategies can be added/removed/reordered and capital moved between them by authorized roles.View glossary entry to claim from
id: Withdrawal queue ID
Returns
received: Amount received from the withdrawal
View Functions
numberOfStrategies
Returns the number of registered strategies
function numberOfStrategies() external view returns (uint256)
Returns
uint256: Number of registered strategies
capital
Returns the total capital managed by the wrapper
function capital() external view returns (uint256)
Returns
uint256: Total capital (in underlying tokens)
valueOfCapital
Returns the total value of capital including yield
function valueOfCapital() public view returns (uint256 _capital)
Returns
_capital: Total value of capital including yield
yield
Returns the accumulated yield
function yield() public view returns (uint256)
Returns
uint256: Accumulated yield
availableToWithdraw (strategy)
Returns the amount available to withdraw from a strategystrategyA yield venue tracked by the wrapper; strategies can be added/removed/reordered and capital moved between them by authorized roles.View glossary entry
function availableToWithdraw(address strategy) public view returns (uint256 liquidity)
Parameters
strategy: StrategyStrategyA yield venue tracked by the wrapper; strategies can be added/removed/reordered and capital moved between them by authorized roles.View glossary entry address to check
Returns
liquidity: Amount available to withdraw
availableToWithdraw (total)
Returns the total amount available to withdraw
function availableToWithdraw() public view returns (uint256 liquidity)
Returns
liquidity: Total amount available to withdraw
canWithdraw
Checks if a withdrawal amount is possible
function canWithdraw(uint256 amount) external view returns (bool)
Parameters
amount: Amount to check
Returns
bool: Whether the amount can be withdrawn
maxAbleToWithdraw
Returns the maximum amount that can be withdrawn
function maxAbleToWithdraw(uint256 amount) external view returns (uint256)
Parameters
amount: Requested amount
Returns
uint256: Maximum amount that can be withdrawn
isStrategy
Checks if an address is a registered strategystrategyA yield venue tracked by the wrapper; strategies can be added/removed/reordered and capital moved between them by authorized roles.View glossary entry
function isStrategy(address _strategy) public view returns (bool)
Parameters
_strategy: Address to check
Returns
bool: Whether the address is a registered strategystrategyA yield venue tracked by the wrapper; strategies can be added/removed/reordered and capital moved between them by authorized roles.View glossary entry
availableToDeposit
Returns the amount available to deposit
function availableToDeposit() external view returns (uint256)
Returns
uint256: Amount available to deposit
decimals
Returns the number of decimals for the token
function decimals() public view returns (uint8)
Returns
uint8:: Number of decimals
deployed
Returns the total amount deployed to strategies
uint256 public deployed
Returns
uint256: Total amount deployed
token
Returns the underlying token address
address public immutable token
Returns
address: Underlying token address
strategies
Returns a strategystrategyA yield venue tracked by the wrapper; strategies can be added/removed/reordered and capital moved between them by authorized roles.View glossary entry at the specified index
IStrategy[] public strategies
Parameters
index: Array index
Returns
IStrategy: StrategyStrategyA yield venue tracked by the wrapper; strategies can be added/removed/reordered and capital moved between them by authorized roles.View glossary entry contract at that index
deployedToStrategy
Returns the amount deployed to a specific strategystrategyA yield venue tracked by the wrapper; strategies can be added/removed/reordered and capital moved between them by authorized roles.View glossary entry
mapping(address strategy => uint256 deployed) public deployedToStrategy
Parameters
strategy: StrategyStrategyA yield venue tracked by the wrapper; strategies can be added/removed/reordered and capital moved between them by authorized roles.View glossary entry address
Returns
uint256: Amount deployed to strategystrategyA yield venue tracked by the wrapper; strategies can be added/removed/reordered and capital moved between them by authorized roles.View glossary entry