bitpro가 원문에서 글자만 모은 내용이에요. 표·그림·수식은 빠지거나 깨질 수 있어요. 전체 20쪽 중 8쪽
nge. The user then signs this price, confirming their acceptance of the potential variation within the specified range.
When the transaction is executed, the smart contract logic ensures that the final minting settlement price falls within the signed slippage range. This approach provides users with a level of certainty about the price they will receive and makes the transaction predictable.
Slippage management is a key part of Ethena's minting design strategy, aiming to provide users with a more stable and transparent transaction experience. 
### Audit
The Ethena Minting Contracts are regularly audited. See the section for up-to-date information. 
***
### Quick Answers
***Q: Am I only able to get USDe via minting USDe with Ethena?***
No, you can acquire *USDe* initially via decentralized protocols such as Curve and Uniswap as well as buy & sell USDe on Centralized Exchanges such as Binance, OKX and Bybit.
# Order Validity Checks
Ensures only orders at fair prices are submitted on chain
## Context
Ethena conducts several validations to ensure both the user and the protocol can honour the signed order before it is submitted to the blockchain.
When users **mint** or **redeem** *USDe*, after the user has signed the order with their wallet, Ethena retains "last-look" ability. This enables Ethena to be sure the price agreed between Ethena & the user wouldn't impose a loss on the protocol. *This is principally motivated to ensure neither Ethena nor the user is adversely affected in highly volatile markets.*
{% hint style="info" %}
Ethena cannot change the user-signed EIP712 order as a result of the blockchain.
{% endhint %}
## Validations
<table data-full-width="true"><thead><tr><th>Validation</th><th width="239.33333333333337">Description</th><th>Purpose</th></tr></thead><tbody><tr><td><ol><li>Cryptographically Valid Signature</li></ol></td><td>The user-provided signature is cryptographically valid.</td><td>This ensures the user has the necessary ability & permissions to request this operation.</td></tr><tr><td><ol start="2"><li>System health check</li></ol></td><td>A health check of Ethena hedging & pricing internal systems</td><td>This is to ensure Ethena can manage the delta of the operation.</td></tr><tr><td><ol start="3"><li>Whitelisted trader</li></ol></td><td>The user's Ethereum address is whitelisted. </td><td>Only KYC/KYB'd users are able to directly <strong>mint</strong> & <strong>redeem</strong> <em>USDe</em> with Ethena.</td></tr><tr><td><ol start="4"><li>Approved beneficiary</li></ol></td><td>If the beneficiary of the mint is different than the benefactor, the benefactor must have approved this beneficiary onchain.</td><td>Ensures benefactors or their delegates do not accidentally or maliciously redirect proceeds to another wallet. Benefactors can approve beneficiaries by calling <code>setApprovedBeneficiary</code> once. <a href="https://etherscan.io/address/0xe3490297a08d6fC8Da46Edb7B6142E4F461b62D3#writeContract#F20">Etherscan offers a UI for doing this.</a></td></tr><tr><td><ol start="4"><li>Sufficient balances and approvals</li></ol></td><td>The user has provided sufficient approvals and has sufficient funds to honour the request. </td><td>Prevents time and gas wastage and ensures transaction success at the smart contract.</td></tr><tr><td><ol start="5"><li>Timeliness of order return</li></ol></td><td>The user has returned a signed order within an acceptable time period of Ethena sending a response to their initial RFQ request. </td><td>Keeps prices relevant by ensuring prompt order response.</td></tr><tr><td><ol start="6"><li>Order expiration check</li></ol></td><td>The user's signed order expiry attribute is at least 30 seconds in the future</td><td>The user's signed order expiry attribute is at least 30 seconds in the future to ensure the transaction is able to reach finality in almost all gas environments.</td></tr><tr><td><ol start="7"><li>RFQ and order match</li></ol></td><td>The user's signed order <code>collateral_amount</code> and <code>usde_amount</code> attributes are an exact match to the RFQ payload Ethena returned to them.</td><td>This ensures users and protocol positively affirm the terms of the agreement.</td></tr><tr><td><ol start="8"><li>Last look</li></ol></td><td>The present system price compared to the signed order's price is within the acceptable tolerance the user and Ethena have agreed to.</td><td>This ensures that the price hasn't moved outside of tolerance bands adversely against the protocol.</td></tr><tr><td><ol start="9"><li>External price check</li></ol></td><td>That the signed price is within a specific tolerance of another external pricing source, such as <a href="https://pyth.network/">Pyth</a> and Redstone. </td><td>This operates as one of many sources of redundancy and fail-safes to ensure the system is functioning correctly at all times.</td></tr><tr><td><ol start="10"><li>$N per block limit check</li></ol></td><td>The order will not exceed the defined maximum capacity that is available per block for <strong>mint</strong> and <strong>redeem</strong> <em>USDe</em> requests.</td><td>Contributes to protocol stability.</td></tr><tr><td><ol start="11"><li>Multiple orders check</li></ol></td><td>The user does not have another order to be processed in this block. </td><td>Users are only allowed to successfully submit one <strong>mint</strong> / <strong>redeem</strong> <em>USDe</em> request per block.</td></tr></tbody></table>
# User Security Measures
## Overview
Several 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 has implemented across the deployed smart contracts.
## Measures
1. Only whitelisted user wallet addresses are able to successfully **mint** & **redeem** *USDe*. This seeks to ensure that only non-malicious actors are able to call the aforementioned functions.
2. Provided backing assets are only able to be sent from the Ethena Minting contract to whitelisted wallet addresses of our OES provider partners. This ensures protocol backing is not able to be diverted to improper wallets and protocol funds enjoy the legal and governance protections without interruption.
* Updating the whitelisted addresses in the Ethena Minting contract requires a multi-sig transaction by members of both Ethena & external responsible parties.
3. Mint/Redeem Smart contract keys are generated in an air-gapped secure manner whereby a single person is not able to access these keys.
4. A small proportion of the protocol's total assets are kept in EOA wallets. Secure multi-sig approval process is required for major fund transfers.
5. Internal pricing sourced from multiple centralized exchanges is constantly validated with external sources such as Pyth and Redstone to ensure integrity.
6. Numerous [Order Validity checks](/technical-design/minting-usde/order-validity-checks) are performed throughout the system + workflow to ensure the integrity of the system.
7. Separate `GATEKEEPER_ROLE` roles across the smart contract exist to detect unusual **mint**/**redeem** transactions and immediately disable the mint/redeem functionality upon unexpected behavior.
8. The `DEFAULT_ADMIN_ROLE` and `owner` smart contract roles are all multi-sig keys and are securely stored in cold wallets.
<table data-header-hidden data-full-width="true"><thead><tr><th></th><th></th><th></th></tr></thead><tbody><tr><td><strong>Security Measure</strong></td><td><strong>Action Taken by Ethena</strong></td><td><strong>Purpose & Benefit</strong></td></tr><tr><td><strong>Handling of Mint/Redeem Keys</strong></td><td>Ethena securely generated mint/redeem keys are stored safely in AWS secrets manager. Exist on production machines upon deployment only which has critically restricted access.</td><td>Ensures no unauthorized access, safeguarding users and the protocol from potential mint/redeem key compromises.</td></tr><tr><td><strong>Address Validity</strong></td><td>Only whitelisted addresses can receive backing assets. Withdrawals restricted to whitelisted custodian addresses.</td><td>Minimises risk of sending funds to incorrect addresses, ensuring targeted and secure end to end mint/redeem flows.</td></tr><tr><td><strong>On-Chain Fund Management</strong></td><td>Avoid keeping large sums in EOA wallets. Secure multi-sig approval process for major fund transfers.</td><td>Safeguards protocol assets and protects from unintended fund movements.</td></tr><tr><td><strong>Ensuring Correct Pricing</strong></td><td>Validate internal pricing consistently against third-party sources. Real-time checks and balance measures.</td><td>Accurate pricing is essential, ensuring users get the best value and protocol remains stable.</td></tr><tr><td><strong>Hedging Processes</strong></td><td>Robust checks and balances for hedging, including block number validations and system health checks.</td><td>Ensures orders are handled correctly and reliably, minimising potential order execution errors.</td></tr><tr><td><strong>Protecting against Adverse Selection</strong></td><td>Employ a last-look architecture, whitelist market makers, and set tight windows for quote validity.</td><td>Priorities giving users the best pricing and protects against potential manipulations or unfair play.</td></tr><tr><td><strong>Gas Estimation</strong></td><td>Maintain a limited ETH balance for transactions and monitor gas fees to prevent overpayment.</td><td>Ensures users are not overcharged due to gas estimation errors, preserving user funds.</td></tr></tbody></table>
<table data-header-hidden data-full-width="true"><thead><tr><th></th><th></th><th></th></tr></thead><tbody><tr><td><strong>Strict Order Submission</strong></td><td>Only whitelisted users can submit orders, which must meet Ethena’s validation criteria.</td><td>Protects the system against malicious public internet orders, only genuine requests are processed.</td></tr><tr><td><strong>Robust Role Management</strong></td><td>Distinct gatekeeper roles for monitoring and managing unusual mint/redeem transactions.</td><td>Specialised roles allow for targeted oversight and faster response to potential security threats.</td></tr><tr><td><strong>Cold Storage of Multi-Sig Keys</strong></td><td>Admin and owner multi-sig keys of all contracts are securely stored in cold wallets.</td><td>Enhances security by reducing exposure of essential keys to online threats.</td></tr></tbody></table>
<br>
# Mint & Redeem Key Functions
Important functions of the mint and redeem smart contract
## Roles in EthenaMinting contract
### Overview
The Ethena minting contract has been designed to offer a safe and secure platform for the creation of *USDe*. Its atomic operations ensure that tasks are either fully completed or reverted, leaving no room for partial executions. Its immutable nature guarantees that its critical rules and operations cannot be easily altered, ensuring consistency and trust in the process. It has these key pieces of functionality:
1. **Minting**: Minters can mint *USDe* by providing assets and receiving *USDe* tokens in return. The backing assets are transferred to "Off-Exchange Settlement" providers based on a predefined route. The minting process is subject to a maximum limit set by the contract.
2. **Redemption**: Redeemers can redeem their *USDe* by providing them as input and receiving the underlying assets back *USDe* in return. The redeemed *USDe* tokens are burned from the user's balance. The redemption process is subject to a maximum limit set by the contract.
3. **Signature Verification**: The contract cryptographically verifies the signature provided by the user to ensure the authenticity of the minting or redemption order.
4. **Supported Assets:** The contract maintains a strict list of supported assets that can be used as backing assets for minting and redemption.
5. **Custodian Addresses:** The contract maintains a strict list of custodian addresses to which backing assets can be transferred during the minting process.
6. **Max Mint/Redeem Per Block:** The contract sets a maximum limit for the number of *USDe* tokens that can be minted or redeemed per block.
Roles in smart contracts are what control lower level operations and function calls. It's a security feature, like AWS IAM, that allows the authors of smart contracts, and the users using them once deployed to the blockchain, to be certain of how they can operate.
{% hint style="info" %}
Despite being named the "Ethena Minting contract", it is responsible for both the **minting** & **redeeming** functionality of *USDe*.
{% endhint %}
## Roles in the Ethena Minting contract
There are five roles in the Ethena Minting contract. You can view the deployed Ethena Minting contract on the Ethereum blockchain **here**.
<table data-full-width="true"><thead><tr><th width="156">Role</th><th width="103.19999999999999">Type</th><th width="194">Controller</th><th width="125">Role Count</th><th width="427">Functions / Notes</th></tr></thead><tbody><tr><td><code>ADMIN</code></td><td>Multi-Sig</td><td>Ethena Labs</td><td>1</td><td><ul><li>Transfer Ownership</li><li>Add/remove supported collateral asset</li><li>Add/remove custodian addresses</li><li>Grant/revoke Minter, Redeemer, Gatekeeper roles</li><li>Set max/mint mint/redeem per block</li><li>Reenable mint/redeem</li></ul></td></tr><tr><td><code>GATEKEEPER</code></td><td>EOA</td><td><p>Shared between</p><ul><li>Ethena Labs</li><li>External Security Firms</li></ul></td><td>3+ internal 3+ external</td><td><ul><li><p>Disable mint/redeem</p><ul><li>Disables when they execute at incorrect prices on chain</li><li>Limits damage on mint/redeem roles compromise</li></ul></li></ul></td></tr><tr><td><code>MINTER</code></td><td>EOA</td><td>Ethena Labs</td><td>20</td><td><ul><li>Mint</li><li>Transfer to approved "Off-Exchange Settlement" providers</li></ul></td></tr><tr><td><code>REDEEMER</code></td><td>EOA</td><td>Ethena Labs</td><td>20</td><td><ul><li>Redeem</li></ul></td></tr></tbody></table>
# Mint and Redeem Contract V2
## Overview
Ethena upgraded the Mint and Redeem Contract from the [first version](https://etherscan.io/address/0x2cc440b721d2cafd6d64908d6d8c4acc57f8afc3) to the [second version](https://etherscan.io/address/0xe3490297a08d6fC8Da46Edb7B6142E4F461b62D3#code) on the 8th of July 2024 at approximately 10am UTC.
Ethena gathered feedback from all key stakeholders, requested buy-in, and scheduled the deployment at a date & time that was optimal for whitelisted API users. This upgrade represented a breaking change to existing whitelisted users' trading systems.
Both versions of the contract were written by the same engineering team and have both successfully passed [Audit](/resources/audits).
The updates to the Mint and Redeem Contract were principally motivated by:
* Improvements to the protocol's security and continuing to reduce potential risk surfaces.
* Adding features requested by existing and potential users to support new workflows.
* Introducing additional controls around specific risk configurations.
***
## Action Items for API Users
Functionally for existing whitelisted API users, the changes were quite minor and not a large engineering lift for whitelisted users.
1. Review the [#changes-in-detail](#changes-in-detail "mention") between the existing & second versions of the Mint & Redeem Contract.
2. Prepare required updates to your trading system to accommodate the second version of the contract, including:
1. Updating your connection URL to either `https://public.api.ethena.fi` or `https://private.api.ethena.fi` from `https://api.ethena.fi`.
1. You must provide an IP address to be whitelisted if you wish to use the `private.api.ethena.fi` connection URL. There is no difference in priority, performance, or rate limits between the two connection URLs.
2. Ensuring new approvals are added to your whitelisted addresses given the new [Mint and Redeem Smart Contract](https://etherscan.io/address/0xe3490297a08d6fC8Da46Edb7B6142E4F461b62D3). 
3. Updating to use the[ ](https://gist.github.com/mcevoyinit/0660818e968a6a46603e06fa80b20d40)new [Minting Contract ABI](https://gist.github.com/mcevoyinit/0660818e968a6a46603e06fa80b20d40).
4. The [\[POST\]](/api-documentation/overview) `/order` submission remains the same, except for the following changes:
1. `rfq_id` is no longer required in the [\[POST\]](/api-documentation/overview) `/order` parameters. Instead, it must be included inside the signed object body object as `order_id.` This is because the rfq id is now stored onchain, and thus requires you to sign it.
5. For EIP-1271 users, you must add the `signature_type` parameter with the value `EIP1271` to the [\[POST\]](/api-documentation/overview) `/order` request. The default is `EIP712` so the former is only required if you're using EIP-1271.
```
url = {ethena_url}order?signature={signature_hex}&signature_type=EIP1271
```
6. Supporting the new `error_code` value `27` that enables you to perform a hot upgrade if you would like during the deployment. If you receive this code from V1 then it is time to begin minting/redeeming with your V2 client.
3. During deployment, prepare for approximately 15 minutes of downtime. 
1. The Ethena Labs team will proactively confirm to users if the deployment has been successful.
2. API users will be required to meet the new API specifications & requirements to be able to mint & redeem directly with Ethena.
1. In the event of an unsuccessful launch, Ethena Labs will:
1. Communicate proactively with all API users.
1. Immediately roll back to V1 of the Mint & Redeem Smart Contract enabling the existing V1 systems to continue functioning without change.
2. Coordinate another deployment date in the future for all API users.
{% hint style="info" %}
Only the USDT/USDe pair will be available for minting and redeeming for the initial V2 rollout. Other pairs are available at the protocol's discretion.
{% endhint %}
***
## Changes
### Overview
<table data-header-hidden data-full-width="true"><thead><tr><th></th><th></th><th></th></tr></thead><tbody><tr><td><strong>Change</strong></td><td><strong>Description</strong></td><td><strong>Operation / Outcome</strong></td></tr><tr><td>Distinct Asset Mint/Redeem Max Per Block Limits</td><td>Implements asset-specific block-by-block minting and redeeming limits for stablecoins versus assets/LSTs, with a global cap.</td><td>Limits can be adjusted using the <a href="/technical-design/key-addresses">Ethena Dev multi-sig</a>.</td></tr><tr><td>EIP-1271 Smart Contract Signing</td><td>Adopts EIP-1271 standards to verify signatures, enabling smart contracts to recognize and accept collateral.</td><td>Market Maker Smart Contract implementing the <a href="https://eips.ethereum.org/EIPS/eip-1271">https://eips.ethereum.org/EIPS/eip-1271</a> Interface can partake in this type of Minting via adding a parameter to the <a href="/api-documentation/overview">[POST]</a> <code>/order</code> request.</td></tr><tr><td>Onchain API User Whitelisting</td><td>Introduces multi-sig whitelist for benefactors and a self serve beneficiary whitelist directly within the Mint and Redeem Contract.</td><td>Benefactor addresses are onboarded via <a href="/technical-design/key-addresses">Ethena Dev multi-sig</a>; beneficiaries are assigned by benefactors.</td></tr><tr><td>Mandate Delta Limit Between Stables & USDe</td><td>Sets a mandated delta limit in bps for price divergence between stablecoins and USDe in specific cases, mainly to protect protocol from blackswan events like stablecoin collateral de-pegging events or private key compromise.</td><td><p>The value of the limit is configurable via the <a href="/technical-design/key-addre프로젝트로 돌아가기