Ethena 백서

Ethena

원문

bitpro가 원문에서 글자만 모은 내용이에요. 표·그림·수식은 빠지거나 깨질 수 있어요. 전체 20쪽 중 9쪽

sses">Ethena Dev multi-sig</a>.</p><ul><li>If MINT and the normalised amount of <em>USDe</em> minted is greater than the collateral received, the stable limit check is applied.</li><li>If REDEEM and the normalised amount of USDe is less than the amount of collateral returned, the stable limit check is applied.</li></ul></td></tr><tr><td>Gas Optimizations</td><td><p>Uses Solidity structs to optimize gas usage and rearranges declaration for efficiency.</p><p>Implements optimized gas usage through efficient memory management of variables like <code>order_type</code>, and <code>expiry</code>.</p></td><td>Mints and Redeems occur normally but with less ETH burned by minters and redeemers over time.</td></tr><tr><td>RFQ ID on chain</td><td>Enables further reconciliation between the quoted RFQ ID from the Ethena trading system and the actual mints and redeems.</td><td>Included in the V2 Market Maker client program. Must now be part of EIP-712 an EIP-1271 signed order payloads for <a href="/api-documentation/overview">[POST]</a> <code>/order</code> requests.</td></tr><tr><td>AES cipher encryption</td><td>Implemented advanced key encoding mechanisms using AES encryption and a rigorous key ceremony protocol involving multiple participants and secure storage methods. </td><td>Operations no longer rely upon AWS secrets. The secure process startup and interaction with the cryptographical of the system is strictly managed and executed by authorized Ethena Labs personnel only.</td></tr></tbody></table> ### Details The section below is not an exhaustive list of the aforementioned changes but rather expands on particular areas of interest. Please reach out if you have any questions or feedback. #### Distinct Asset Mint/Redeem Max Per Block Limits Ethena is now able to set specific direct Mint/Redeem global limits per ETH block by: * Asset * Groups of Assets, such as Stablecoins and LSTs This enables greater specificity around which assets whitelisted users are able to directly mint & redeem directly with Ethena. {% hint style="info" %} All block limits are measured in USDe terms. The global block limit can never be surpassed regardless of the individual USDe limits, per asset, per block. {% endhint %} #### Mandate Delta Limit Between Stables & USDe This feature introduces an additional validation to check such that it is not possible to directly mint or redeem with Ethena if the divergence in price between USDe and USDT/USDC exceeds a defined limit in an adverse way to the protocol. The limit is defined via the field `stablesDeltaLimit`with a default of zero. {% hint style="success" %} The **Distinct Asset Mint/Redeem Max Per Block Limits** feature in combination with the **Mandate Delta Limit between Stables & USDe** feature means, that when only stablecoin minting is enabled, a theoretical compromise of the Mint and Redeem Contract private keys can **NOT** lead to protocol losses.\ \ This unique pairing removes the risk surface that would enable an attacker to ever possibly be able to mint or redeem USDe at an unfavorable price to the protocol. {% endhint %} #### EIP-1271 Smart Contracts Signing With the adoption of EIP-1271 standards, this enables Smart Contracts to directly (after having been whitelisted) mint and redeem with Ethena via our [API](/api-documentation/overview). If using an EIP-1271, then the `signature_type` parameter, with the value `EIP1271`, must be added to the [\[POST\]](/api-documentation/overview) `/order` request. #### Onchain API User Whitelisting Ethena is moving from offchain to onchain whitelisting of users able to interact with the API. Newly requested addresses to be whitelisted will be added by a request from the [Ethena Dev multi-sig](https://etherscan.io/address/0x3b0aaf6e6fcd4a7ceef8c92c32dfea9e64dc1862). Whitelisted users now have the autonomy to whitelist their beneficiaries via the following smart contract function invocation: ``` function setApprovedBeneficiary(address beneficiary, bool status) ``` {% hint style="info" %} If the benefactor and the beneficiary are the same, there is NO need to whitelist the beneficiary onchain beforehand. {% endhint %} #### Hot (Graceful) Upgrade on Deployment An Error Code has been added to the API specification to notify when the migration has successfully occurred. Users are able to use this response, returned by [\[POST\]](/api-documentation/overview) `/orders`, to automatically swap trading systems to meet the requirements of the second version of the Mint and Redeem Contract. In the event of an unsuccessful deployment, users could also use this to swap their settings back to the original version 1. *Example of* `error_code` *==* `27` ```json { "error_name":"Incorrect USDe minter. Switch Minting API", "error_code":"27" } ``` # Staking USDe Staking is controlled by the StakedUSDe smart contract. Stakers can interact with it directly or through the Ethena dApp UI.&#x20; * When **staking**, a user transfers *USDe* into the contract and receives *sUSDE* (staked *USDe*) in return, another ERC20 token. * Over time, additional *USDe is* transferred in as rewards. * When **unstaking**, staked *USDe* is burned in exchange for a proportionate *USDe* amount based on the total amount of sUSDe outstanding vis-a-vis total USDe in the smart contract. {% hint style="info" %} Users will receive the principal amount of *USDe* staked as well as their proportionate share of the deposited rewards upon **unstaking**. {% endhint %} {% hint style="info" %} The acquisition of sUSDe is not offered to persons with their habitual residence or registered office in the European Union or the European Economic Area. {% endhint %} The StakedUSDe smart contract implements the [ERC4626 Token Vault standard](https://ethereum.org/en/developers/docs/standards/tokens/erc-4626/) for composability. This popular standard is widely used for onchain reward-accruing; thus, it is expected that other user interfaces beyond the Ethena dApp may likely support *USDe* staking in the future. Various deposit and redeem functions are exposed, enabling staking with or without a slippage threshold, and with or without an ERC2612 Permit signature authorizing the transfer of USDe. There is no minimum staking period. If a user **stakes** and **unstakes** in consecutive blocks, they would receive their share of any increase in vested *USDe* value in the contract that has occurred in that \~12-second period. Because reward payments into the contract occur every 8 hours and linearly vest over 8 hours, there are never any sudden spikes in the vested *USDe* value, which prevents sandwich attacks where an informed staker stakes before and unstakes after payment at the expense of all other stakers. {% hint style="info" %} Stakers should never lose *USDe* by **staking**. *USDe* transfers of rewards can only be positive or flat into the StakedUSDe contract. As such, the *USDe* value of *stUSDe* can only increase or stay flat over time. {% endhint %} Staking rewards accrual is related to the protocol's generated revenue from staking Ethereum & earning the funding and basis spread from the delta hedging derivatives position. While protocol generated revenue should remain fairly stable unless there is a slashing event, the funding and basis spread income from delta hedging derivatives will vary considerably (even day to day). In some periods, no rewards may be paid to stakers if the funding + basis spread yield is negative and it is greater than or equal to the income generated via the staked Ethereum. In this situation, when no rewards are transferred to the StakedUSDe smart contract, the Ethena reserve fund will support the underlying protocol backing. *** ### Quick Answers ***Q: Do I have to stake USDe to receive rewards?*** Yes. You have to stake your *USDe* with Ethena to receive incentive rewards. USDe is a synthetic dollar that does not earn rewards. ***Q: Why is there a cooldown period during launch?*** There is a cooldown from requesting to unstake *sUSDe* to receiving *USDe* in return. Users must first request their *USDe* be unstaked wherein their *USDe* will be placed in the [USDeSilo](https://etherscan.io/address/0x7FC7c91D556B400AFa565013E3F32055a0713425#tokentxns) smart contract. Once the cooldown period has elapsed, users will be able to withdraw their *USDe* from the USDeSilo smart contract. ***Q: Am I able to sell the sUSDe prior to the cooldown?*** Yes, you are able to do so if external markets exist. Note, however, that neither the Ethena Foundation nor Ethena Labs is planning to actively procure or facilitate creation of any such markets, and there can therefore be no guarantee that such market will exist. ***Q: Is it possible that I owe the protocol while staked?*** No. Rewards can only be positive or zero. ***Q: What are staking rewards paid in?*** The rewards are transferred to the staking contract in the form of USDe. # Staking Key Functions Important functions of the staking smart contract ## Overview The Ethena Staking contract is an extension of the [ERC4626 Token Vault standard](https://ethereum.org/en/developers/docs/standards/tokens/erc-4626/) with the added ability for a cooldown period upon unstaking as well as a legally required ability to freeze funds for sanctioned addresses. ## Roles in the Ethena Staking contract There are three roles in the Ethena Staking contract: * `DEFAULT_ADMIN_ROLE` * `Rewarder` * `Blacklister` You are able to view the deployed Ethena Staking contract on the Ethereum blockchain **here.** `DEFAULT_ADMIN_ROLE` The `DEFAULT_ADMIN_ROLE` is able to perform a number of operations: * It can set `setCooldownDuration`, up to a maximum value of 90 days from the unstaking request. The cooldown period is the time period from the unstaking request until the user is able to withdraw *USDe*. * It can rescue tokens using `rescueTokens` to move any ERC20 tokens (**except** ***USDe***) to an address Ethena Labs controls. This has been implemented in case a user accidentally sends non-*USDe* assets to the Ethena Staking contract. * It can redistribute *sUSDe* tokens that have been locked using `resdistributeLockedAmounts.` Locks on *sUSDe* held in specific wallets have been implemented due to legal requirements to ensure sanctioned, criminal, and other high-risk actors are not able to interact with the staking contract, in the interest of complying with Sanctions, Anti-Money Laundering, and Combating the Financing of Terrorism regimes. This is extremely similar functionality to what Circle implements for *USDC*. Ethena is able to redistribute funds to Ethena Labs addresses (in segregated wallets/vaults from other protocol assets) from fully restricted addresses. Note that this ability is limited to *sUSDe*. `Rewarder` The `Rewarder` role is able to transfer in `USDe` rewards, growing the balance of `USDe` in the Ethena Staking contract. `Blacklister` The `Blacklister` role is able to grant and remove `Soft_restricted_staking_role` or `Full_restricted_staking_role` assigned to an address. In practice, only `Full_restricted_staking_role` has been utilized. "Fully Restricted Stakers" cannot receive sUSDe. &#x20; The user of the `Blacklister` role is only intended to ensure high-risk actors, such as sanctioned individuals, wallets associated with criminal activity/terrorism, and other similar individuals covered under relevant laws and regulations cannot access protocol yield. The blacklist will never be invoked at the discretion of Ethena Labs for any user absent those conditions or unless required by law enforcement pursuant to a court order, injunction, or similar official action we are required by law to comply with. As noted above, this function is limited to *sUSDe*. # User Security Measures ## Overview A number of measures have been taken to ensure the integrity and resilience of the deployed smart contracts. These measures are designed principally to ensure the safety of protocol assets, but also to ensure reasonable governance occurs. Below is a list of some, but not all, of the user security measures Ethena Labs has implemented across the deployed smart contracts. ## Measures 1. Inherited from the OpenZeppelin implementation of the battle-tested [ERC4626 Token Vault standard](https://ethereum.org/en/developers/docs/standards/tokens/erc-4626/). This enables users to have comfort that the protocol is inheriting audited & thoroughly used code throughout the space. 2. An unstake cooldown period where *sUSDe* tokens are immediately settled for *USDe*, but the staker cannot withdraw the *USDe* until the cooldown period has elapsed to prevent attacks in a single block. 3. Linear vesting of reward payments over 8 hours to prevent sandwich attacks where a user stakes immediately before and unstakes immediately after a reward payment at the expense of other stakers. 4. A minimum non-zero total *sUSDe* supply of 1 ether ($1 to start) to further prevent donation attacks beyond the protections the OpenZeppelin implementation provides. # Use of Oracles ## Overview "Oracles" typically refer to price feeds a protocol utilizes to perform key business logic and functions. Ethena utilizes price feeds from various sources given the importance of real-time data to trading & risk workflows which exist offchain. The system is split between onchain and offchain components.&#x20; ### Price Feeds & Ethena's Offchain Systems Ethena relies on price feeds in order to price the **mint** and **redeem** *USDe* requests per the available derivatives market liquidity as well as manage the risk of derivatives positions. Real-time data feeds indicate not only where the system delegates protocol assets, but the various risk profiles between the exchanges.&#x20; With this in mind, it's critically important that Ethena has access to & is constantly consuming real-time price feeds, especially from where it matters most; the exchanges where the system holds derivatives positions due to their margin requirements. Ethena consumes real-time pricing information from three primary sources: 1. CeFi Exchanges such as Binance, Bybit, Okx, Deribit, Bitmex and Bitget. 2. [Pyth](https://pyth.network/). 3. [Redstone](https://redstone.finance/) This real-time data is used extensively throughout the system to apply business logic, but to also ensure the integrity of all actions. In that way, the system relies heavily upon CeFi Exchange price feeds, given the volume-weighted importance of their traded instruments, and also upon Pyth and Redstone to validate internal pricing throughout the system and before every single **mint** and **redeem** *USDe* request is accepted by Ethena. This ensures thorough checks for any inconsistency and protect the protocol from manipulation that might be occurring from one/multiple sources. Ethena is constantly working to provide the resilience and integrity of price sources and evaluating other low latency offchain pricing services. # Hedging System Risk Management, Pricing, Trading, and Backing Orchestration Ethena's "Hedging System" is composed of a number of offchain application services that enable many critical aspects of the user experience, including: * Calculating & publishing indicative prices for **minting** & **redeeming** *USDe*. * Returning pricing to **mint** & **redeem** *USDe* requests. * Ensuring the integrity of the system in real time. The "Hedging System" ingests & interacts directly with the protocol's onchain smart contracts as well as the Ethereum blockchain. {% hint style="info" %} The "Hedging System" is extremely risk-aware and has been designed in a manner wherein the preservation of protocol collateral is the most important consideration.&#x20; {% endhint %} <figure><img src="https://596495599-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsBsPyff5ft3inFy9jyjt%2Fuploads%2F6WCCypi2WpCW54LlU7IN%2FHedging%20System.png?alt=media&amp;token=34b46704-ac3c-493f-a688-443721807b53" alt=""><figcaption></figcaption></figure> ### Responsibilities At a level lower of detail, the "Hedging System" performs the following functions (but is not limited to): * Ingests market data from CeFi Exchanges, "Off-Exchange Settlement" providers, Pyth and Redstone. This data includes order book updates, public trade information, as well as private portfolio, positions, orders, and trade information. * Normalizes and validates the integrity of market data. * Calculates the risk exposure of the portfolio relative to defined risk limits and goals. * Reconciles internal system information relating to the protocol's portfolio, positions, orders, and trade information with CeFi Exchanges & "Off-Exchange Settlement" providers. * Calculates & publishes indicative prices for **minting** & **redeeming** *USDe*. * Ingests, validates, and publishes pricing for **mint** & **redeem** *USDe* requests. * Determines where to route & execute orders upon a successful **mint** & **redeem** *USDe* request. This incorporates information about fees, depth of liquidity, existing positions, and other funding + basis opportunities. * In real-time, validates all information & operations to ensure integrity relative to internal & external expectations. * Monitors and alerts in regards to the availability of internal & external dependencies such as other internal services or CeFi Exchanges. * Orchestrates the movement of backing assets between "Off-Exchange Settlement" providers and CeFi Exchanges. * Publishes & alerts Ethena team members to real-time developments. Enabling immediate manual intervention in the event of inconsistency. * Publishes & logs system data to different data stores. An example being the publication of trade data to a database. *** ### Hedging FAQ [Notion FAQ Link](https://ethena.notion.site/Ethena-FAQs-3ccc1437e13343f8b74c0d005e4f5128) # Internal Services At a high level, the "Hedging System" is composed of broadly five services: 1. **Portfolio Management System** 2. **Market Data Parser Service** 3. **Reference Data Service** 4. **Reconciliation Service** 5. **Persistor Service** ### **Services** #### **Portfolio Management System** The "Portfolio Management System" manages a number of key functions including: * Calculating and publishing indicative prices if users were to **mint** & **redeem** *USDe*. * Calculating and publishing prices for users' **mint** & **redeem** *USDe* requests. * Calculating portfolio exposure in real time & requesting operations as a result. * Orchestrating the delegation/undelegate between "Off-Exchange Settlement" providers and CeFi exchanges as well as coordinating the movement of backing assets between "Off-Exchange Settlement" providers & Minting + Staking smart contracts. * Routing and managing the execution of orders to manage risk. * Altering in the event of system degradation or inconsistency present in the system. #### **Market Data Parser Service**&#x20; The "Market Data Parser Service" connects & ingests market data updates from CeFi Exchanges, "Off-Exchange Settlement" providers, as well as Pyth and Redstone. This information includes order book updates, public trades, and private orders, positions & trade information. The application is designed, built, and deployed in a manner wherein it is resilient and functional even in high-volatility environments. *When does Ethena consider external market data invalid?* We capture invalid data in two dimensions: * Wrong/invalid * Outdated Data directly from exchanges gets compared against Pyth and has to fall within a tight tolerance, which is manually set but wide enough to allow even rapid moves. It's mainly trade-through events; one large order walks 50 levels into the order book, which we would like to avoid reacting on. During volatile moments, the exchanges tend to fall behind on their updates. We have spent extensive engineering resources to deal with such situations (efficient data readin
프로젝트로 돌아가기