bitpro가 원문에서 글자만 모은 내용이에요. 표·그림·수식은 빠지거나 깨질 수 있어요. 전체 20쪽 중 7쪽
e funds throughout the flow from users end up in custodial solutions within a single transaction. Only `DEFAULT_ADMIN_ROLE` can add custodian address.
#### Redeeming <a href="#user-content-redeeming" id="user-content-redeeming"></a>
Similar to minting, the user performs an EIP712 signature with prices provided by the system. Their signature is submitted and order into `redeem()` function. The funds from redemption come from the Ethena minting contract directly. Ethena aims to hold a certain amount of backing assets at all times for hot redemptions. Users intending to redeem a large amount will need to redeem over several blocks. Alternatively they can sell USDe on the open market.
#### Setting delegated signer <a href="#user-content-setting-delegated-signer" id="user-content-setting-delegated-signer"></a>
Some users trade through smart contracts. Ethena minting has the ability to delegate signers to sign for an address, using `setDelegatedSigner`. The smart contract should call this function with the desired EOA address to delegate signing to. To remove delegation, call `removeDelegatedSigner`. Multiple signers can be delegated at once, and it can be used by EOA addresses as well.
By setting a delegated signer, the smart contract allows both the `order.benefactor` and delegated signed to be the address that's ecrecovered from the order and signature, rather than just `order.benefactor`.
**Security**
`EthenaMinting.sol` has crucial roles called the `MINTER` and `REDEEMER`. Starting with `MINTER`, in the original design, they have the ability to mint any amount of USDe for any amount of backing assets. Given `MINTER` is a hot wallet and is an EOA address, in the scenario where this key becomes compromised, an attacker could then mint a billion USDe for no backing, and dump them on pools, causing a black swan event the reserve fund cannot cover.
The solution is to enforce an on chain mint and redeem limitation per block. In addition, the contracts have `GATEKEEPER` roles with the ability to disable mint/redeems and remove `MINTERS`,`REDEEMERS`. `GATEKEEPERS` acts as a safety layer in case of compromised `MINTER`/`REDEEMER`. They will be run in separate AWS accounts not tied to Ethena, constantly checking each transaction on chain and disable mint/redeems on detecting transactions at prices not in line with the market. In case compromised `MINTERS` or `REDEEMERS` after this security implementation, a hacker can at most mint 100k USDe for no backing, and redeem all the backing within the hot contract, for a max loss in a single block, before `GATEKEEPER` disable mint and redeem. The loss would not be expected to materially affect operations.
Further down the line, there has been considerations to give external organisations a `GATEKEEPER` role. Such an external organisation would only be expected to invoke the gatekeeper functions when price errors occur on chain. Abuse of this privilege means their `GATEKEEPER` role will be removed.
The `DEFAULT_ADMIN_ROLE` is required to re-enable minting/redeeming. `DEFAULT_ADMIN_ROLE` also has the power to add/remove `GATEKEEPERS`,`MINTER` and `REDEEMER`.
`DEFAULT_ADMIN_ROLE` is the most powerful role in the minting contract, but is still beneath the `OWNER` role of `USDe.sol`, given that the owner can remove the minting contract's privilege to mint.
#### [StakedUSDeV2.sol](https://etherscan.io/address/0x9d39a5de30e57443bff2a8307a4256c8797a3497) <a href="#user-content-stakedusdev2sol" id="user-content-stakedusdev2sol"></a>
`StakedUSDeV2.sol` is where holders of USDe stablecoin can stake their stablecoin, get stUSDe in return and earn yield. Protocol yield is transferred out by having a `REWARDER` role of the staking contract send protocol yield in USDe, increasing the sUSDe value with respect to USDe.
This contract is a modification of the ERC4626 standard, with a change to vest in rewards linearly over 8 hours to prevent users frontrunning the transfer of protocol yield, then unwinding their position right after (or even in the same block). This is also the reason for `REWARDER` role. Otherwise users can be denied rewards if random addresses send in 1 wei and modifies the rate of reward vesting.
There's also an additional feature to add a 14 day cooldown period on unstaking sUSDe. When the unstake process is initiated, from the user's perspective, sUSDe is burnt immediately, and they will be able to invoke the withdraw function after cooldown is up to get USDe in return. Behind the scenes, on burning of sUSDe, USDe is sent to a separate silo contract to hold the assets for the cooldown period. And on withdrawal, the staking contract moves those funds from the silo contract out to the user's address. The cooldown is configurable up to 90 days.
Due to legal requirements, there's a `SOFT_RESTRICTED_STAKER_ROLE` and `FULL_RESTRICTED_STAKER_ROLE`. The former is for addresses based in countries that are restricted from accessing the protocol for regulatory reasons, for example USA. Addresses under this category will be soft restricted. They cannot deposit USDe to get sUSDe or receive USDe for sUSDe. 
`FULL_RESTRCITED_STAKER_ROLE` is for any address associated with sanctioned individuals or associated with users suspected to be operating within a country subject to comprehensive sanctions, or for addresses associated with criminal activity, or if we get a request from law enforcement to freeze funds. Addresses fully restricted cannot move sUSDe, and only Ethena can unfreeze the address. Ethena also has the ability to repossess funds of an address subject to full restrictions. It is understood that having the ability to freeze and repossess funds could be a cause of concern for defi users deciding whether to stake USDe; while the aim is to make operations as secure as possible, interacting with Ethena still requires a certain amount of trust outside of code on the smart contract, given the nature of the architecture.
Note this restriction only applied to staking contract, there are no restrictions or ability to freeze funds of USDe.
#### [ **StakingRewardsDistributor.sol**](https://etherscan.io/address/0xf2fa332bd83149c66b09b45670bce64746c6b439)
`StakingRewardsDistributor.sol` is a helper contract that automates and streamlines the distribution of staking rewards to the `StakedUSDeV2` contract. It serves as an intermediary between the **EthenaMinting** contract and the **staking contract**, allowing for more frequent and automated reward distributions while mitigating potential arbitrage opportunities.The contract has two key roles:
* `OWNER` (**multisig**) - Responsible for administrative configuration such as setting the operator, updating the minting contract, and managing asset approvals.
* `OPERATOR` - A delegated signer that can only perform two actions: mint USDe using available funds in the contract and transfer the minted USDe rewards to the staking contract via `transferInRewards()`.
The main function `transferInRewards()` can only be called by the operator and requires the contract to have sufficient USDe balance. This contract must be granted the `REWARDER_ROLE` in the staking contract to successfully distribute rewards.
Safety features:
* Two-step ownership transfer (inherited from **Ownable2Step**)
* Owner cannot renounce ownership
* Operator can be instantly replaced by the owner
* Assets can only be approved to the current minting contract
This contract simplifies the reward distribution process by removing the need for frequent multisig transactions while maintaining security through role separation and safety checks. The operator's permissions are strictly limited to reward distribution functions, while all administrative control remains with the owner multisig.
#### [StakedENA.sol](https://etherscan.io/address/0x8bE3460A480c80728a8C4D7a5D5303c85ba7B3b9)
`StakedENA.sol` is the staking contract for `ENA` tokens, implementing **ERC4626** with additional security features and vesting mechanics. Users can stake their ENA tokens to receive **sENA** (Staked ENA) tokens in return. The contract includes both a cooldown period for unstaking and a vesting period for rewards distribution. Key Features:
* Vesting System - Rewards are vested linearly over a configurable period (max 90 days) to prevent reward sniping
* Cooldown Mechanism - Similar to `StakedUSDeV2`, implements a configurable cooldown period (max 90 days) for unstaking
* Blacklist System - Includes roles for managing restricted addresses
* Minimum Shares - Implements a minimum shares threshold (1 ENA) to prevent donation attacks
The contract has several important roles:
* `DEFAULT_ADMIN_ROLE` - The owner with highest privileges
* `REWARDER_ROLE` - Allowed to distribute rewards via transferInRewards()
* `BLACKLIST_MANAGER_ROLE` - Can add/remove addresses to/from blacklist
* `BLACKLISTED_ROLE` - Addresses restricted from transfers, staking, or unstaking
Security Features:
* Two-step ownership transfer (inherited from SingleAdminAccessControl)
* Reentrancy protection on critical functions
* Role-based access control
* Non-renounceable roles (prevents accidental role abandonment)
* Blacklist system for regulatory compliance
* Emergency token rescue functionality (except for ENA tokens)
* Prevention of zero-amount transactions
* Minimum shares requirement
* Vesting and cooldown periods cannot exceed 90 days
* Cannot update vesting parameters while rewards are still vesting
This contract serves as the core staking mechanism for ENA tokens while maintaining necessary security controls and regulatory compliance features. The combination of vesting and cooldown periods helps prevent various economic attacks while the blacklist system provides regulatory compliance capabilities.
### [Owner of Ethena's smart contracts](https://app.safe.global/home?safe=eth:0x3B0AAf6e6fCd4a7cEEf8c92C32DFeA9E64dC1862) <a href="#user-content-owner-of-ethenas-smart-contracts" id="user-content-owner-of-ethenas-smart-contracts"></a>
Ethena utilises a gnosis safe multisig to hold ownership of its smart contracts. All multisig keys are cold wallets and each multisig requires 7/10 or more confirmations before transactions are approved. This multisig is purely for the purpose of owning the smart contracts, and will not hold funds or do other on chain actions.
<br>
<br>
# Key Trust Assumptions
While the Ethena protocol attempts to minimize trust assumptions across all areas of the infrastructure, certain trust assumptions need to exist in order to access centralized liquidity and enable the scaling of the underlying product.
As the protocol develops further, there are specific plans to gradually reduce trust assumptions on certain entities.
### Summary of Major Trust Assumptions
1. The user initially needs to trust that the hedging system will execute the appropriate hedge for the backing assets provided upon issuance of *USDe*. However, this can easily be verified by the issuance of *USDe* vs assets transferred, alongside the existence of read APIs to both custody wallets and the exchange APIs that are transparently displayed on the Ethena [dashboards](https://app.ethena.fi/dashboards/solvency).
2. The *USDe* holder makes a trust assumption that the various OES providers will undertake their roles diligently and without major errors with regard to custody of the underlying backing. To date, none of the custodial providers which hold the assets have ever lost users' funds compared to $7bn of hacks on DeFi smart contracts.
3. The `GATEKEEPER_ROLE` is responsible for pausing the mint and redeem function, as well as adding new whitelisted custodial addresses that backing assets assets on mint are transferred to. This role is time-locked to ensure an extensive time period exists before such a sensitive change is able to be made.
4. The `DEFAULT_ADMIN_ROLE`, granted exclusively to the protocol multisig, will act seldomly and only in the best interest of the protocol. This multi-sig wallet requires 7 signatures to sign or transact, both from internal and external stakeholders, with keys geographically distributed and controlled by distinct individuals both within and outside of the Ethena Labs team.
### The GATEKEEPER\_ROLE and Multi-Sig Safety Layer
1. The `GATEKEEPER_ROLE` is used in the system in order to accelerate response times in the case of an issue. Gatekeepers can only disable minting and redeeming or remove the corresponding minting and redeeming roles from individual addresses. Gatekeepers cannot re-enable minting and redeeming nor take any other action. This role is distributed both within the Ethena Labs organization and among external stakeholders including market makers and exchanges.
2. The time-locked multi-sig ensures that privileged roles cannot be abused by the Ethena Labs team with keys distributed outside of the core contributor team and 7 day time-locks for any change to core functions.
### Mint & Redeem Privileged Roles
**`EthenaMinting.sol`**
`DEFAULT_ADMIN_ROLE`
* Can set the `maxMintPerBlock`.
* Can set the `maxRedeemPerBlock`.
* Can add and remove supported assets.
* Can add and remove custodian wallets.
* **Can add and remove addresses from other roles and perform all actions restricted by other roles.**
`MINTER_ROLE`
* Can mint *USDe* from assets, within 5% of 3rd party oracle pricing provided by Pyth and Redstone.
* Can transfer any asset in the minting contract to any custodian wallets.
`REDEEMER_ROLE`
* Can redeem USDe for assets, within 5% of 3rd party oracle pricing.
`GATEKEEPER_ROLE`
* Can disable minting and redeeming.
* Can remove the `MINTER_ROLE` or `REDEEMER_ROLE` from an address.
**`USDe.sol`**
`Owner`
* can set `minter`
`minter`
* a single address, the only address that can mint *USDe*. It cannot be set to the same address as `owner`. Set to `EthenaMinting` and only modifiable in case a new minting contract needs to be deployed to preserve protocol.
### Staking Contract Privileged Roles
`owner`/`DEFAULT_ADMIN_ROLE`
1. Can add and remove addresses from other roles. This should be the role of the Gatekeeper according to documentation.
2. Can redistribute *sUSDe* from wallets with the `FULL_RESTRICTED_STAKER_ROLE` to any unrestricted address.
3. `REWARDER_ROLE` 
4. Can add protocol-generated yield vested *USDe* to the contract via transferInRewards().
<br>
# Matrix of Multisig and Timelocks
Transparency on the role of the multisig
> Ethena is required to implement safeguards in order to provide connective tissue between DeFi and centralized liquidity venues. The multisig is used to minimize these trust assumptions for core onchain functions.
 
<table data-header-hidden data-full-width="true"><thead><tr><th width="168"></th><th width="211"></th><th width="109.19999999999999"></th><th width="219"></th><th width="259"></th><th></th></tr></thead><tbody><tr><td><strong>Roles</strong></td><td><strong>Multi sig</strong></td><td><strong>Number of role</strong></td><td><strong>Functions</strong></td><td><strong>Notes</strong></td><td></td></tr><tr><td><strong>Owner</strong></td><td>Yes, Ethena org</td><td>1</td><td>transferOwnership, add/remove supported collateral asset, add/remove custodian addresses, setUSDe address</td><td><p>If desired, owner and admin can be different multi sigs</p><p>setUSDe address is redundant, to be removed</p></td><td></td></tr><tr><td><strong>Admin</strong></td><td>Yes, Ethena org</td><td>1</td><td>grant/revoke Minter, Redeemer, Gatekeeper roles</td><td> </td><td></td></tr><tr><td><strong>Gatekeepers</strong></td><td>No, EOA controlled by Ethena plus external trusted organisations</td><td>At least 3</td><td>Disable mint/redeem functionality, remove Minter, Redeemer roles</td><td>Will include external trusted organisations to be gatekeepers. Limits damage on mint/redeem roles compromise. Disables mint/redeems when they execute at incorrect prices on chain.</td><td></td></tr><tr><td><strong>Minter</strong></td><td>No, EOA controlled by Ethena</td><td>20</td><td><ul><li><code>mint()</code></li><li><code>transferToCustody</code></li></ul></td><td>Mint/Redeemer roles to be the same set of 20 addresses. This is to ensure the system can handle a high load of mint transaction concurrently.</td><td></td></tr><tr><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td><strong>Redeemer</strong></td><td>No, EOA controlled by Ethena</td><td>20</td><td><ul><li><code>redeem()</code></li></ul></td><td>Mint/Redeemer roles to be the same set of 20 addresses. This is to ensure the system can handle a high load of mint transaction concurrently.</td><td></td></tr></tbody></table>
<br>
<br>
# Minting USDe
The genesis of USDe
"Minting" *USDe* refers to the creation of new synthetic dollars. "Redeeming" *USDe* is the reversal process, of exchanging synthetic dollars for the assets that collateralize them.
The methods of minting vary depending on the type of stablecoin/synthetic dollar. Here we will explore the novel Ethena synthetic dollar minting process.
The Ethena synthetic dollar minting system encompasses the following design principles:<br>
### How does it work?
<figure><img src="https://596495599-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsBsPyff5ft3inFy9jyjt%2Fuploads%2FCsYMaHx5s8vXBguYWd3b%2Fminting.png?alt=media&token=bfc2d305-95bd-4736-84f4-80fd75620e1c" alt=""><figcaption></figcaption></figure>
1. Users request a price from the Ethena Pricing API.
2. Users can generate a signed [EIP712](https://eips.ethereum.org/EIPS/eip-712) order and optionally submit it to Ethena's minting server. 
* **Note**: at this stage, users have complete control over their assets - they have the freedom to create, hold, and sign the price at their discretion. The approval to transfer assets only happens when the user willingly signs the order.
3. Once the signed order is received, Ethena's server checks that the user has the required asset balance and signed approvals and that the dynamic hedging server can currently handle the order. Part of this involves communicating with the OES solution to prepare for the incoming mint or redemption request.
* **Note**: Ethena does have the ability to reject an order based on these conditions. However, even in this centralized part of the process, the protocol could never alter the contents of the signed order due to the immutability of blockchain cryptographic signatures. This design ensures that the user's order - the backing asset, its size, any included slippage, and the synthetic dollars to be minted - remains as the user intended.
4. The order is sent to the blockchain with the atomic mint function called when these checks are passed. As above both the transfer of the user's assets and the minted synthetic dollars happen in a single transaction.
5. Upon success the hedging system actions the mint events to ensure the delta neutrality of the protocol's overall backing. Read more about these concepts in the [Hedging System](/technical-design/hedging-system)and[Backing Asset Custody](/backing-custody-and-security/backing-asset-custody)sections.
By blending centralized and decentralized elements in this way, Ethena achieves a relatively high level of trustlessness. Users always retain control over their assets prior to mint and their orders will be processed exactly as specified. And while Ethena has some control over order acceptance, the blockchain's transparency and cryptographic guarantees mean users can confidently engage with the protocol, knowing their transactions are secure and unalterable.
### Slippage 
Slippage occurs when the price at which a trade is executed differs from the expected price, usually due to market volatility or trade size.
Ethena has designed its minting process to minimize slippage for users. Before submitting a minting transaction, users receive a "price" from the Ethena Pricing API that includes a predefined slippage ra프로젝트로 돌아가기