Ethena Protocol Adapter

The Ethena adapter enables the Yieldinator Facet to integrate with Ethena's yield-bearing stablecoin protocol, allowing vaults to earn yield on stablecoins through USDe and staked USDe (sUSDe).

Overview

Ethena is a protocol that offers USDe, a yield-bearing stablecoin, and sUSDe, a staked version that generates yield from delta-neutral strategies. The protocol uses a combination of perpetual futures positions across centralized and decentralized exchanges to maintain the peg of USDe to USD while generating yield. The Ethena adapter facilitates minting USDe with collateral, staking USDe to receive sUSDe, and managing these positions to generate yield for the Vaultinator Protocol.

Implementation Details

Contract: EthenaAdapter.sol

The adapter implements the standard YieldinatorAdapter interface with Ethena-specific functionality:

contract EthenaAdapter is YieldinatorAdapter {
    using SafeERC20 for IERC20;
    
    // Ethena contracts
    address public usde; // USDe stablecoin address
    address public susde; // staked USDe (sUSDe) address
    IEthenaStaking public staking; // Ethena staking contract
    IEthenaMinter public minter; // Ethena minting contract
    
    // Supported collateral tokens for minting USDe
    mapping(address => bool) public supportedCollateral;
    
    // Staking configuration
    struct StakingConfig {
        bool autoStake; // Whether to automatically stake USDe
        bool active; // Whether staking is active
    }
    
    // Configuration for each token
    mapping(address => StakingConfig) public tokenConfig;
    
    // Deposited amounts per token
    mapping(address => uint256) public depositedAmount;
    
    // Constructor
    constructor(
        address _admin,
        address _usde,
        address _susde,
        address _staking,
        address _minter
    ) YieldinatorAdapter("Ethena", _admin) {
        require(_usde != address(0), "EthenaAdapter: USDe cannot be zero address");
        require(_susde != address(0), "EthenaAdapter: sUSDe cannot be zero address");
        require(_staking != address(0), "EthenaAdapter: staking cannot be zero address");
        require(_minter != address(0), "EthenaAdapter: minter cannot be zero address");
        
        usde = _usde;
        susde = _susde;
        staking = IEthenaStaking(_staking);
        minter = IEthenaMinter(_minter);
    }
}

Key Functions

Configure Collateral and Staking

Before using the adapter, collateral tokens must be registered and staking configured:

Deposit

The deposit function handles depositing collateral to mint USDe or staking USDe directly:

Withdraw

The withdraw function handles unstaking sUSDe and redeeming USDe for the original collateral:

Harvest Yield

The harvestYield function calculates and claims the yield earned from staking USDe:

Emergency Withdraw

The emergencyWithdraw function provides a safety mechanism to withdraw all funds:

APY Calculation

The getCurrentAPY function calculates the current APY for staking USDe:

Get Total Deposited

The getTotalDeposited function returns the total amount of tokens deposited:

Usage Example

Here's an example of how to use the Ethena adapter with the Yieldinator Facet:

Security Considerations

  • Smart Contract Risk: The adapter interacts with multiple external contracts which may have vulnerabilities.

  • Oracle Risk: Ethena relies on price oracles for minting and redeeming USDe, which could be manipulated.

  • Delta-Neutral Strategy Risk: Ethena's yield generation relies on delta-neutral strategies that may be impacted by market conditions.

  • Stablecoin Peg Risk: USDe could potentially lose its peg to USD under extreme market conditions.

Risk Mitigation

  • The adapter implements strict access controls to prevent unauthorized access.

  • Emergency withdrawal functionality is available to recover funds in case of critical issues.

  • The adapter validates all inputs and handles edge cases to prevent unexpected behavior.

  • Slippage protection can be implemented for minting and redeeming operations.

Gas Optimization

  • The adapter minimizes gas usage by batching operations when possible.

  • The adapter avoids unnecessary approvals by only approving tokens when needed.

  • Auto-staking configuration allows for optimizing gas costs based on expected holding periods.

Future Improvements

  • Support for Ethena's governance system for participating in protocol decisions

  • Integration with Ethena's insurance mechanism if implemented

  • Support for leveraged staking strategies using USDe as collateral

  • Automated reinvestment of staking rewards for compound growth

  • Integration with other DeFi protocols that accept USDe or sUSDe as collateral