bitpro가 원문에서 글자만 모은 내용이에요. 표·그림·수식은 빠지거나 깨질 수 있어요. 전체 26쪽 중 23쪽
data: abi.encodeWithSelector(IVault.borrow.selector, borrowAmount, myAddress) // tokens sent to main address
});
connector.batch(items);
```
This distinction is about control, not a protocol rule that ERC-20 balances always live at a main address. Most ERC-20 contracts cannot authenticate EVC ownership of a derived sub-account, so tokens sent there are generally not recoverable with the owner's normal wallet signature unless a reviewed EVC-aware flow exists.
### 3. Account ownership and registration
The EVC maintains a mapping of account owners, which is important for resolving the relationship between sub-accounts and their primary (EOA or smart contract) owner. This is especially relevant for integrations, analytics, and off-chain systems.
#### How ownership is registered
An account's owner is registered in the EVC the first time the owner interacts with the EVC (for example, by enabling collateral or a controller, or performing EVC batch or call). Until this happens, the EVC does not know who the owner is.
#### Direct vault interactions and edge cases
Accounts can interact with vaults directly, bypassing the EVC. This means:
* An account may not have an owner registered in the EVC until it finally interacts with the EVC (e.g., to enable collateral or a controller for borrowing).
* If an account receives vault shares (e.g., as a transfer) before its owner has ever interacted with the EVC, the EVC will not have an owner registered for that account.
#### Integration pattern and limitations
A typical integration pattern is:
* Use the EVC's `getAccountOwner(address account)` function to resolve the owner.
* If the owner is not registered (i.e., the function returns `address(0)`), assume that the account is its own owner.
```solidity
address owner = evc.getAccountOwner(account);
if (owner == address(0)) {
// Owner not registered; assume the account is its own owner
owner = account;
}
```
:::note
This pattern is commonly used, but integrators should still handle edge cases where the true owner is not the account itself, especially if ownership is later registered by a different EOA. Consider the security and UX implications for your application.
:::
### 4. Operator delegation
Operators delegate EVC-authenticated authority to another address, such as a reviewed bot or automation contract. `setAccountOperator(account, operator, true)` toggles one account. `setOperator(prefix, operator, bitField)` sets a bitmap across the 256 account IDs sharing that prefix.
```solidity
// Grant operator rights for a specific sub-account
evc.setAccountOperator(subAccount, operatorAddress, true);
// Grant operator rights for ALL sub-accounts of the owner
// The prefix groups the owner's 256 account IDs.
// Each set bit grants the operator authority for that account ID.
// type(uint256).max sets all 256 bits.
evc.setOperator(evc.getAddressPrefix(owner), operatorAddress, type(uint256).max);
```
:::warning
Operator delegation is a safety-critical operation. An operator with access to your sub-accounts can move funds, borrow, repay, and perform any action on your behalf. Only delegate operator rights to trusted contracts or EOAs, and regularly review and revoke permissions you no longer need.
Operators can batch, deposit, withdraw, borrow, and more—enabling advanced automation and intent-based strategies. You can revoke operator rights at any time using the same functions with `false` or by updating the operator bitfield.
:::
:::tip
**What is an Address Prefix?**
In the EVC, an address prefix is the first 19 bytes of an Ethereum address. All 256 sub-accounts of an owner share the same prefix. The EVC uses this prefix to efficiently manage permissions and operator rights across all sub-accounts. The `getAddressPrefix(address)` function returns this value for any given address.
:::
### 5. Liquidations with controlCollateral
To perform a liquidation, the controller vault calls `controlCollateral` to seize collateral from a borrower's sub-account. Typically, this is done by transferring vault shares from the violator's sub-account to the liquidator using the `transfer` function:
```solidity
// Example: Controller vault seizes collateral shares from violator's sub-account
address collateralVault = /* address of the collateral vault */;
address violator = /* sub-account in violation */;
address liquidator = /* address of the liquidator */;
uint256 seizeShares = /* number of shares to seize */;
// Prepare transfer call data
bytes memory transferData = abi.encodeWithSelector(
IVault.transfer.selector,
liquidator, // recipient of the shares
seizeShares // amount of shares to transfer
);
// Call controlCollateral
connector.controlCollateral(
collateralVault,
violator,
0, // value
transferData
);
```
`controlCollateral` is accepted only from the account's enabled controller in the EVC's collateral-control context. Within that context the controller can call the enabled collateral vault on behalf of the account, including a withdrawal or share transfer that would not require the account's ordinary ERC-20 allowance. Collateral-vault implementations must authenticate this exact EVC context; controller implementations determine when and how the authority is used.
### 6. Simulating transactions
You can simulate batches before execution using `batchSimulation`:
```solidity
(
IEVC.BatchItemResult[] memory results,
IEVC.StatusCheckResult[] memory accountChecks,
IEVC.StatusCheckResult[] memory vaultChecks
) = connector.batchSimulation(items);
// Analyze results before sending a real transaction
```
This is useful for diagnostics in frontends, bots, and risk-management systems. Simulation mode is observable by called contracts, so an untrusted target can behave differently in simulation and execution. Do not treat a successful simulation as a security guarantee.
### 7. Relayed transactions with permits
The EVC supports EIP-712 permits. A user can sign an authorization offchain and an allowed relayer can submit it; the relayer pays execution gas, although an application may charge or recover that cost separately.
Permits are useful for relayed transactions and automation on the chain where the permit is valid. The EVC's `permit` function supports both ECDSA (EOA) and ERC-1271 (smart-contract wallet) signatures.
#### How to use EVC permits
1. Construct the permit message, specifying the signer, sender, nonce, deadline, value, and calldata (typically a batch of operations).
2. Sign the message off-chain using EIP-712.
3. Submit the permit to the EVC's `permit` function:
```solidity
evc.permit(
signer, // The user authorizing the action
sender, // The relayer or executor
nonceNamespace, // For replay protection
nonce, // For replay protection
deadline, // Expiry timestamp
value, // ETH value to forward (usually 0)
data, // Encoded calldata (e.g., batch)
signature // EIP-712 signature
);
```
The EVC will verify the signature, check the nonce and deadline, and then execute the requested operations as if they were sent by the signer.
:::info
**Security Note**
Permits are powerful. Verify the sender, nonce namespace, nonce, deadline, value, and calldata before signing. If a harmful permit may have been signed, use Permit Disabled Mode as described below.
:::
#### Understanding nonce namespace
The EVC's permit system uses a `nonceNamespace` and `nonce` for replay protection and sequencing. The `nonceNamespace` allows you to have multiple independent streams of permits for the same account. This is useful if you want to:
* Allow parallel workflows (e.g., one for regular actions, one for high-priority or emergency actions)
* Cancel or replace a specific stream of permits without affecting others
For most simple use cases, you can use a single namespace (e.g., `nonceNamespace = 0`) and increment the `nonce` for each new permit. For more advanced scenarios, you can assign different namespaces to different workflows or applications.
:::tip
If you are unsure, use `nonceNamespace = 0` for all your permits. Only use multiple namespaces if you need parallel, independent streams of permits.
:::
### 8. Emergency modes: lockdown and permit disabled
The EVC provides two emergency modes that can help users limit account activity in case of compromise or suspicious activity:
#### Lockdown mode
* When enabled, Lockdown Mode restricts all operations for the affected address prefix (all 256 sub-accounts), except for managing operators and nonces.
* No external contract calls or value transfers are allowed, but controllers can still control collateral for the accounts.
* Useful if you suspect a malicious operator or permit has been added.
Enable with:
```solidity
evc.setLockdownMode(evc.getAddressPrefix(owner), true);
```
#### Permit disabled mode
* When enabled, this mode prevents execution of any permits signed by the owner for the affected address prefix.
* Useful if you believe a harmful permit message has been signed.
Enable with:
```solidity
evc.setPermitDisabledMode(evc.getAddressPrefix(owner), true);
```
:::tip
Both modes can be disabled by calling the same functions with `false`.
:::
### 9. Best practices
* **Use batching** for related operations to save gas and make the operation atomic
* **Use sub-accounts** for position and strategy separation
* **Delegate with operators** for automation only after reviewing the delegated contract or account
* **Simulate** complex transactions before execution
* **Review EVC security features** such as Lockdown Mode and Permit Disabled Mode as part of your account response plan
### Read next
* [EVC overview](/build/evc)
* [EVC implementation security](/build/evc/security)
* [EVC utils](/build/evc/evc-utils)
* [Interact with vaults](/build/evk/interacting-with-vaults)
* [Euler SDK](/build/sdk)
* [Build](/build)
## Security Considerations
The [**Ethereum Vault Connector (EVC)**](./index) is designed as a foundational layer for secure, modular lending and collateral management. While it provides robust security features, both protocol users and integrators must understand its security model, limitations, and best practices to ensure safe operation.
### Core Security Features
#### Lockdown Mode
EVC introduces a `LOCKDOWN MODE` for emergency response. When activated by the owner, it restricts all accounts under that owner to only managing operators and nonces. All other operations, including calling external contracts, are blocked. This is especially useful if a malicious operator is added or a harmful permit is signed. Controllers can still control collaterals for the accounts under lockdown, allowing for safe unwinding of positions if needed.
#### Permit Disabled Mode
Owners can activate `PERMIT DISABLED MODE` to immediately block execution of any permits signed by them. This is a rapid response to accidental signing of a harmful permit.
#### Authentication and Authorization
* **Authentication** is handled by the EVC, which verifies the true sender and context for every operation (including sub-accounts and operators).
* **Authorization** is the responsibility of the vault. When called via EVC, vaults must use `getCurrentOnBehalfOfAccount` to determine the authenticated account and controller status.
#### Account and Vault Status Checks
* EVC enforces rigorous account and vault status checks, ensuring that accounts remain solvent and vault-level invariants are maintained.
* Vaults must require and implement these checks after any operation that could affect solvency or global constraints.
#### Execution Context and Re-entrancy Protection
* EVC maintains an execution context for each batch or call, deferring checks until the end of the context for atomicity and gas efficiency.
* The `checksInProgress` and `controlCollateralInProgress` mutexes prevent re-entrancy and ensure that status checks and collateral control are performed safely.
### Vault Implementation Security Considerations
Vaults integrating with EVC must:
* Implement the [`IVault`](https://github.com/euler-xyz/ethereum-vault-connector/blob/master/src/interfaces/IVault.sol) interface and follow the EVC vault specification ([vault implementation considerations](https://evc.wtf/docs/contracts/vault-implementation-considerations)).
* Use the `callThroughEVC` modifier (or equivalent pattern) to ensure status checks are always deferred and performed in the correct context.
* Always use `getCurrentOnBehalfOfAccount` for authorization when called via EVC.
* Require account and vault status checks at the end of any operation that could affect solvency or vault invariants.
* Implement `checkAccountStatus` and, if needed, `checkVaultStatus` with the recommended access control and context checks.
* Be careful with re-entrancy guards: when called directly (not via EVC), requiring a status check will immediately call back into the vault, which can trigger a re-entrancy guard. Use the callback pattern or relax the guard for status check calls as needed.
* Only allow calls to trusted contracts; never allow arbitrary contract calls from the vault.
* Restrict allowed collateral vaults to a known-good set of audited addresses or use a registry/factory for validation.
### Known Limitations and Attack Vectors
#### EVC Contract Privileges
EVC can call any contract with arbitrary calldata. It should never be given special privileges or hold tokens/ETH except temporarily mid-batch.
#### Read-only Re-entrancy
EVC's non-transient storage can be read while checks are deferred, but each operation leaves these lists in a consistent state. Vaults should not rely on the controller/collateral sets if checks are deferred.
#### Simulation Limitations
The simulation feature sets a flag that can be observed by external contracts. Malicious contracts could behave differently during simulation, so simulations should not be relied on for security with untrusted contracts.
#### Controller Risk
When a user enables a controller, all their collateral is subject to the controller's rules. Only the controller can disable itself, typically after all debt is repaid. Vaults must implement a standard `disableController` function.
#### Operator Risks
Operators have broad permissions; only trusted, audited contracts should be authorized as operators. Owners should be prepared to revoke operator permissions quickly if needed.
### Best Practices for Developers and Users
#### For Vault Developers
* Always use the EVC utility contracts and recommended modifiers for authentication, authorization, and status checks.
* Restrict collateral vaults to known-good, audited contracts.
* Require account and vault status checks after every operation that could affect solvency or vault invariants.
* Use the callback pattern or relax re-entrancy guards for status check calls as needed.
* Implement and test `disableController` logic carefully.
* Never allow uncontrolled calls to arbitrary contracts.
#### For Protocol Integrators and Users
* Use `LOCKDOWN MODE` and `PERMIT DISABLED MODE` immediately if suspicious activity is detected.
* Only enable trusted, audited controllers and operators.
* Use sub-accounts to isolate risk between positions.
* Be aware of the risks of using vaults as collateral, especially if they themselves accept risky collateral.
## Euler Data API V3
Euler Data API V3 is a hosted HTTP API for querying indexed Euler protocol data. It is intended for dashboards, portfolio views, bots, risk systems, research workflows, and integrations that need protocol data without running their own indexer.
Use the interactive reference and OpenAPI document for the current API contract. Versioned clients should still tolerate documented deprecations, indexing lag, and service errors.
The interactive API reference is available at:
**[https://v3.euler.finance/v3/docs](https://v3.euler.finance/v3/docs)**
The OpenAPI document is the current source of truth for request parameters, response schemas, and endpoint availability:
**[https://v3.euler.finance/v3/openapi.json](https://v3.euler.finance/v3/openapi.json)**
### Base URL
All public endpoints are versioned under `/v3`.
```bash
https://v3.euler.finance/v3
```
For example:
```bash
curl https://v3.euler.finance/v3/chains
curl "https://v3.euler.finance/v3/evk/vaults?chainId=1&limit=20"
```
### When to use it
For a ready-made interface to indexed protocol and vault metrics, use the [Risk & Analytics dashboard](/use/risk-dashboard). Its guide explains the views, metric definitions, and data coverage.
Use Euler Data API V3 when you need indexed, normalized data across Euler markets and chains. Common use cases include:
* Listing supported chains, tokens, EVK vaults, and EulerEarn vaults
* Reading vault details, totals, positions, holders, debt holders, labels, and visibility
* Querying account positions, sub-accounts, and activity
* Fetching token prices, historical prices, APYs, and rewards
* Monitoring liquidations, oracle state, governance actions, and indexed protocol events
* Building analytics workflows without managing RPC calls, event backfills, or local indexing infrastructure
For transaction construction or protocol reads that must exactly match current onchain state, use direct contract calls or lens contracts and simulate against the intended block. The Data API is optimized for offchain access, aggregation, and historical analysis.
### Authentication and rate limits
The API can be queried without an API key. Unauthenticated requests are rate limited by IP address.
API keys can be sent with either `X-API-Key` or a bearer token and provide higher rate limits.
```bash
curl -H "X-API-Key: your-key" \
"https://v3.euler.finance/v3/tokens"
```
Rate limit information is returned in response headers, including `RateLimit-Limit`, `RateLimit-Remaining`, and `RateLimit-Reset`.
### Endpoint families
The API reference contains the full list of endpoints and schemas. At a high level, the API is organized around these resource families:
| Area | Examples |
| ------------------- | ---------------------------------------------------------------------------------------------------------------- |
| Protocol and docs | `/v3`, `/v3/docs`, `/v3/openapi.json`, `/v3/graphql` |
| Chains | `/v3/chains`, `/v3/chains/{chainId}/stats`, `/v3/chains/{chainId}/borrowable-vaults` |
| EVK vaults | `/v3/evk/vaults`, `/v3/evk/vaults/{chainId}/{address}`, `/v3/evk/vaults/batch` |
| Vault history | LTV, cap, IRM, config, totals, positions, events, holders, and debt-holder endpoints |
| EulerEarn | `/v3/earn/vaults`, `/v3/earn/vaults/batch`, `/v3/earn/vaults/{chainId}/{address}` |
| Accounts | `/v3/accounts/{address}/positions`, `/v3/accounts/{address}/activity`, `/v3/accounts/{address}/sub-accounts` |
| Tokens and prices | `/v3/tokens`, `/v3/prices`, `/v3/prices/history`, `/v3/tokens/{chainId}/{address}/price` |
| APYs and rewards | `/v3/apys/intrinsic`, `/v3/apys/intrinsic/history`, `/v3/apys/rewards`, `/v3/rewards/breakdown` |
| Risk and monitoring | `/v3/liquidations`, `/v3/oracles/*`, vault/account event timelines, public-allocator events, and Fee Flow events |
### Response conventions
Responses use a consistent envelope. Successful list responses generally return `data` with optional pagination metadata:
```json
{
"data": [],
"meta": {
"total": 100,
"limit": 20,
"offset": 0,
"timestamp": "2026-07-15T12:00:00.000Z"
}
}
```
Errors return an `error` object with a stable code, message, and request id:
```json
{
"error": {
"code": "VALIDATION_ERROR",
"message": "Invalid chain ID",
"requestId": "req_abc123"
}
}
```
Common field conventions:
| Field | Convention |
| ---------------- | ---------------------------------------------------------------------------- |
| Addresses | EIP-55 checksummed addresses |
| On-chain amounts | Strings, to preserve bigint precision |
| USD prices | Numbers |
| APY values | Percent values, for example `5.25` means 5.25% |
| Timestamps | ISO-8601 U프로젝트로 돌아가기