bitpro가 원문에서 글자만 모은 내용이에요. 표·그림·수식은 빠지거나 깨질 수 있어요. 전체 15쪽 중 5쪽
p would result in bad debt for Cap.
Similarly, restaking across multiple Borrowers within Cap is not allowed. When multiple Underwriters are delegating to the same Borrower, a withdrawal from one of the Underwriters can result in a liquidation event for other Underwriters.
In other words, an Underwriter's stake can only be used for a single Borrower in Cap. Alternatively, a Borrower cannot receive stake from multiple Underwriters. If the Borrower were to receive delegations from a new Underwriter, then the Borrower can simply create a new Ethereum address to do so.
### Underwriting Premiums
Each Borrower-Underwriter pair agrees upon a predetermined premium for underwriting. As such, each Borrower-Underwriter pair has a unique fixed yearly rate that can be updated via Admin controls. The rates are set in the respective SSN upon deployment.
Underwriting premiums are distributed per each SSN's reward handler.
### Liquidation and Redistribution
Liquidation conditions in Cap are objective: they are triggered when the health factor of the Borrower drops below the liquidation threshold. Liquidations can be called permissionlessly, and verified onchain. Liquidated funds are redistributed back to the Liquidators, ensuring cUSD is always backed 1:1.
To incentivize liquidations, liquidation and redistribution happen instantly. There are no veto committees nor delay periods for liquidations to occur, nor for the liquidated funds to be redistributed.
### Whitelisted Participants
While the protocol can function fully autonomously, to prevent malicious actors from attacking the protocol, Cap will initially whitelist Underwriters and Borrowers. Underwriters and Borrowers that seek to join the protocol should refer to the Onboarding Guides to do so.
For function signatures, parameters, and data structures, see the [Delegation Contract Reference](/developers/contracts/delegation).
# Symbiotic
Cap integrates Symbiotic's restaking infrastructure to create a delegation-based credit system where Underwriters provide coverage for Borrowers (agents). Underwriters can deploy Vaults to provide stake to Borrowers as coverage, where depositors can deposit and withdraw out of the vault.
## Overview
### Vault to Borrower relationship
* **Unique Borrower-Vault pair**: Each Symbiotic Vault can only delegate to one Borrower. A Borrower must use a different Ethereum address in order to receive delegations from a new Vault. Likewise, an Underwriter must deploy a new Vault in order to delegate to a new Borrower.
* Once a Borrower starts receiving delegations, the Borrower address is immutable.
### Lifecycle of Symbiotic Vault
1. Vault Creation: Underwriter creates a Vault via the Cap Symbiotic Vault Factory Contract, which accepts one ERC20 collateral type
2. Cap Whitelisting: After the Vault is deployed, Cap adds the Vault and Borrower address to Cap system along with loan parameters and underwriting premiums
3. Vault Management: Once the Borrower-Vault pair is live, Underwriters have access control over depositors and claiming rewards. Liquidations will trigger liquidation events on the Vault.
Let's dive deeper into each of the steps.
## Vault Creation
### Deploy Vault
<figure><img src="https://315632032-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkRZQBMptsoesj7n1mr8a%2Fuploads%2Fgit-blob-0cb0bc8c4b06edf932883fb8aa26456a43c8b621%2Fimage.png?alt=media" alt=""><figcaption><p>Cap Symbiotic Vault creation and deposit flow</p></figcaption></figure>
The `createVault` function is the core deployment function in the `CapSymbioticVaultFactory` contract.
{% hint style="info" %}
Vaults that are not registered using the Vault Factory will not be accepted in Cap's system.
{% endhint %}
```solidity
function createVault(
address _owner, // Vault owner/admin address
address _asset, // Collateral asset address (e.g., wstETH)
address _agent, // Agent address for delegation coverage
address _network // Cap Symbiotic network address
) external returns (
address vault, // Deployed vault contract address
address delegator, // Deployed delegator contract address
address burner, // Deployed burner router address
address slasher, // Deployed slasher contract address
address stakerRewards // Deployed staker rewards contract address
);
```
Specifically, the function executes the following:
1. deploys a Symbiotic operator for the specified agent to manage delegation
2. deploys Symbiotic Vault and modules according to Cap requirements
Let us dive deeper into the specific requirements of Cap Symbiotic Vaults.
#### 1. Burner
The burner specifies where assets are transferred to when liquidation happens.
A burner router is deployed to set the receiver of the liquidated assets. By setting the owner of the router to be the zero address, the global receiver is immutably set to be Cap's middleware.
```solidity
function _deployBurner(address _collateral) internal returns (address) {
return burnerRouterFactory.create(
IBurnerRouter.InitParams({
owner: address(0), // No owner (immutable)
collateral: _collateral, // Asset to burn
delay: 0, // Instant execution
globalReceiver: middleware, // Cap network middleware
networkReceivers: new IBurnerRouter.NetworkReceiver[](0),
operatorNetworkReceivers: new IBurnerRouter.OperatorNetworkReceiver[](0)
})
);
}
```
#### 2. Delegator
The Delegator module specifies whether restaking is allowed across networks and Borrowers, and the allocation of assets.
Cap requires that staked assets are solely used as coverage for the specific Borrower receiving delegations (i.e. stake cannot be shared with other networks/Borrowers). As such, the [OperatorNetworkSpecificDelegator](https://docs.symbiotic.fi/modules/vault/delegation#3-operatornetworkspecificdelegator) is used to ensure delegations are siloed. Each vault can only delegate to one Borrower.
#### 3. Slasher
The Slasher handles slash requests from Cap’s middleware, by fetching stake from the Delegator and calling the Vault to transfer the assets to the Burner.
The vault uses `INSTANT` slasher type for immediate slash execution, so that liquidation bonuses can be redistributed immediately.
#### 4. Vault
The Vault handles deposit and withdrawals on an epoch basis. Assets leave Symbiotic vaults only when there is a withdrawal or liquidation event.
Deposits are instant. Withdrawals take until the end of the next epoch to withdraw. The epoch is fixed to 7 days, hence withdrawals take up to 14 days to execute.
#### 5. Staker Rewards
The stakerRewards contract creates a rewards contract to distribute underwriting premiums to Underwriters
```solidity
stakerRewards = defaultStakerRewardsFactory.create(
IDefaultStakerRewards.InitParams({
vault: vault,
adminFee: 0, // Initial admin fee (0%)
defaultAdminRoleHolder: _owner, // Vault owner gets admin role
adminFeeClaimRoleHolder: _owner, // Vault wner can claim admin fees
adminFeeSetRoleHolder: _owner // Vault owner can set admin fees
})
);
```
### Whitelisting
After the Vault is created, the Vault needs to be added to Cap's system.
Cap whitelists the Borrower-Vault pair via the addAgent function in the [SymbioticAgentManager](https://github.com/cap-labs-dev/cap-contracts/blob/1064b6a969d55c822dcf0b2c4b733ceb4118737e/contracts/delegation/providers/symbiotic/SymbioticAgentManager.sol#L42) contract. The contract acts as a bridge between the Cap delegation system and the Symbiotic restaking infrastructure, ensuring proper registration and configuration of Borrowers in the system.
The function takes in the following parameters:
```solidity
struct AgentConfig {
address agent; // Agent address (operator)
address vault; // Associated Symbiotic vault
address rewarder; // Staker rewards contract
uint256 ltv; // Loan-to-value ratio (e.g., 0.5e27 = 50%)
uint256 liquidationThreshold; // Liquidation threshold (e.g., 0.7e27 = 70%)
uint256 delegationRate; // Underwriting premium for interest calculation
}
```
First, the pair is added to the delegation contract, configuring loan parameters such as LTV and LT. By default, LTV is set to 50%, with the liquidation threshold at 80%. Notice, the underwriting premium is also configured in this step.
```solidity
// Add agent to delegation contract
IDelegation(delegation).addAgent(
agentAddress, // Agent address
middleware, // Network middleware
0.5e27, // LTV (50%)
0.8e27 // Liquidation threshold (80%)
);
```
Next, the Vault, rewarder and agent are registered to Cap's Middleware, completing necessary Symbiotic Opt In processes.
```solidity
ISymbioticNetworkMiddleware($.networkMiddleware).registerVault(
_agentConfig.vault,
_agentConfig.rewarder,
_agentConfig.agent
);
```
In particular, a subnetwork identifier is created for the Borrower. The identifier is used to enforce the one-to-one relationship between the Borrower and the vault. Delegations to other subnetwork identifiers will not count as effective stake.
## Vault Management
### Rewards
**`distributeRewards`**: Distributes rewards through Symbiotic network
```solidity
function distributeRewards(address _agent, address _token) external checkAccess(this.distributeRewards.selector)
```
* `_agent`: Agent address for reward distribution
* `_token`: Reward token address
### Liquidation
**`slash`**: Executes liquidation through Symbiotic network via the Burner
```solidity
function slash(address _agent, address _recipient, uint256 _slashShare, uint48 _timestamp) external checkAccess(this.slash.selector)
```
* `_agent`: Borrower address to liquidate
* `_recipient`: Address to receive liquidated collateral
* `_slashShare`: Share of collateral to liquidate
* `_timestamp`: Timestamp for liquidation
### Admin Control
* `DEFAULT_ADMIN_ROLE` - Full vault management
* `DEPOSIT_WHITELIST_SET_ROLE` - Manage deposit whitelist
* `DEPOSIT_LIMIT_SET_ROLE` - Set deposit limitst
# Understanding Epochs
### 1. Primer: dependency chain
Cap credit is backed by restaker delegation held in a Symbiotic vault dedicated to your agent. Recovery on a bad loan means slashing that delegation. Three facts follow from how Symbiotic implements slashing, and together they determine everything else in this document.
**Slashing is timestamp-addressed.** A slash calls `slashableStake(subnetwork, operator, captureTimestamp)` and executes against the stake that existed at that timestamp, not against the current balance.
**The capture timestamp is only valid for one Symbiotic vault epoch.** Outside that range there is nothing to slash and the recovery path fails.
**Therefore borrow capacity cannot be "what is delegated."** It has to be *what is slashable at a timestamp Cap can actually cite right now*. That quantity is what Cap calls **coverage**, and it is the input to your LTV and health factor.
The Cap epoch exists to supply that timestamp. It is a protocol-wide checkpoint cadence that gives every agent a capture timestamp which is deterministic, derivable on-chain by any liquidator without off-chain input, and guaranteed to sit inside Symbiotic's window.
### 2. Two epoch clocks
<table><thead><tr><th width="138.3046875"></th><th>Symbiotic vault epoch</th><th>Cap delegation epoch</th></tr></thead><tbody><tr><td><strong>Duration</strong></td><td>7 days</td><td>3 days</td></tr><tr><td><strong>Enforced by</strong></td><td>Vault config; Cap rejects vaults below 7 days at registration</td><td><code>Delegation.epochDuration()</code></td></tr><tr><td><strong>Determines</strong></td><td>Width of the valid capture-timestamp window</td><td>Which checkpoint <code>slashTimestamp</code> falls back to</td></tr><tr><td><strong>Phase</strong></td><td>Vault creation time</td><td>Absolute Unix time — boundaries at <code>timestamp % 259200 == 0</code></td></tr></tbody></table>
`slashTimestamp` is never more than **two Cap epochs (6 days)** old, against a **7-day** Symbiotic window. The one-day margin is the reason Cap enforces a 7-day minimum vault epoch and refuses to register anything shorter.
### 3. slashTimestamp
`slashTimestamp(agent) = max( (epoch() − 1) × epochDuration , lastBorrow − 1 )`
**The start of the previous Cap epoch is the floor.** The timestamp is always inside the Symbiotic window, and is what a dormant agent is measured against. Its age oscillates between 3 and 6 days as the current epoch advances.
**`lastBorrow − 1`** is the fast path. Cap writes `lastBorrow = block.timestamp` on every borrow. The instant before a borrow is by construction a moment when sufficient coverage existed, so it is both safe and far more recent. The `− 1` is required because Symbiotic rejects `captureTimestamp == now`; Cap also decrements defensively if the computed value lands on the current block.
### 4. Calculating coverage
`Delegation.coverage()` does not read a single value. It takes the minimum of four measurements below to state what is recoverable.
<table><thead><tr><th width="45.7890625">#</th><th>Measurement</th><th>Timestamp</th><th>Denies credit for</th></tr></thead><tbody><tr><td>1</td><td><code>slashableStake</code></td><td>Start of <strong>current</strong> Cap epoch</td><td>Delegation added mid-epoch, not yet checkpointed</td></tr><tr><td>2</td><td><code>slashableStake</code></td><td><strong><code>slashTimestamp</code></strong></td><td>Coverage that could not actually be slashed today</td></tr><tr><td>3</td><td><code>stakeAt</code> (active)</td><td><strong>Now</strong></td><td>Stake already queued for withdrawal</td></tr><tr><td>4</td><td><code>slashableStake</code></td><td><strong><code>now − 1</code></strong></td><td>As #3, one block back</td></tr></tbody></table>
**Quantities are snapshotted; prices are not.** Each measurement snapshots the collateral *amount* at its timestamp, then values it at the **current** oracle price. Price movement therefore transmits to coverage with zero lag. The epoch mechanism lags quantity only.
**Active and slashable stake diverge.** A withdrawal request removes stake from *active* immediately while leaving it *slashable* until the withdrawal clears. Measurements 1, 2 and 4 read slashable stake; measurement 3 reads active stake. The `min()` means a withdrawal request cuts your capacity on request, not on settlement.
### 5. Refreshing slashTimestamp by borrowing
Every borrow writes `lastBorrow`. It is the only borrower-controlled input to the epoch machinery that can update the coverage amount of the restaker.
New delegation counts only once **both** lagging snapshots postdate it. They clear by different means:
* **The slash-timestamp snapshot you can move yourself.** Any borrow at or above the reserve's `minBorrow` sets `lastBorrow = block.timestamp`, pulling `slashTimestamp` to one second ago. Effective in the same block, regardless of draw size.
* **The epoch snapshot you cannot.** It is pinned to the current epoch boundary and advances only when the clock crosses the next one.
Sequence after a restaker increases your delegation:
<table><thead><tr><th width="78.21484375">Step</th><th>Action</th><th>Result</th></tr></thead><tbody><tr><td>1</td><td>Wait for the next epoch boundary</td><td>Epoch snapshot now postdates the increase</td></tr><tr><td>2</td><td>Borrow ≥ <code>minBorrow</code> immediately after</td><td><code>slashTimestamp</code> now postdates the increase</td></tr><tr><td>3</td><td>—</td><td>Full coverage live</td></tr></tbody></table>
Borrowing before the boundary accomplishes nothing — the epoch snapshot still predates the increase, and `min()` still selects it. Crossing the boundary without borrowing does work, but leaves `slashTimestamp` sitting on the previous-boundary floor, which costs another 3 days.
**Constraints on the refresh**
* **Borrows validate against pre-borrow coverage.** `validateBorrow` sizes against `maxBorrowable` as it currently stands, so the refresh draw cannot itself consume the capacity it unlocks. Refresh with a minimal draw, then size up.
* **Repayment does not write `lastBorrow`.** Only `borrow` does.
* **Over-refreshing is free.** A `lastBorrow` older than the previous epoch boundary is simply ignored — the floor takes over — so there is no penalty for refreshing more often than strictly necessary.
### 6. Reference
| Query | Call |
| -------------------------------------- | ------------------------------------------------------------------ |
| Current epoch index | `Delegation.epoch()` |
| Capture timestamp in force | `Delegation.slashTimestamp(agent)` |
| Coverage driving your capacity | `Delegation.coverage(agent)` |
| Slashable collateral at that timestamp | `Delegation.slashableCollateral(agent)` |
| LTV / liquidation threshold (ray) | `Delegation.ltv(agent)` · `Delegation.liquidationThreshold(agent)` |
# Oracles
The Oracle module in CAP is responsible for providing reliable, up-to-date price and rate data to the protocol. It acts as the backbone for all value calculations, including minting, burning, borrowing, and liquidation processes.
## Oracle Data Sources
The protocol leverages multiple oracle sources for different types of data:
* [**RedStone Oracles**](https://www.redstone.finance/): Primary source for reserve asset pricing ([USDC, USDT, pyUSD & cUSD](https://app.redstone.finance/app/feeds/?page=1\&sortBy=popularity\&sortDesc=false\&perPage=32\&networks=1))
* [**Chainlink Oracles**](https://chain.link/): Used for delegation asset pricing (wstETH, wBTC) on shared security side
* [**Cap Token Adapter**](https://github.com/cap-labs-dev/cap-contracts/blob/1064b6a969d55c822dcf0b2c4b733ceb4118737e/contracts/oracle/libraries/CapTokenAdapter.sol): Calculates weighted average of underlying basket for cUSD pricing
* [**Staked Cap Adapter**](https://github.com/cap-labs-dev/cap-contracts/blob/1064b6a969d55c822dcf0b2c4b733ceb4118737e/contracts/oracle/libraries/StakedCapAdapter.sol): Accounts for accrued yield and cUSD price for stcUSD pricing
* [**Aave Adapter**](mailto:undefined): Fetches current borrow rates from external markets
* [**Vault Adapter**](mailto:undefined): Calculates utilization-based interest rates
For function signatures, parameters, and data structures, see the [Oracle Contract Reference](/developers/contracts/oracle).
# Access Controls
The Access Control system implements granular, function-level permissions across all contracts of Cap. It provides a sophisticated role-based access control mechanism that allows precise management of who can call specific functions on specific contracts, building on OpenZeppelin's [AccessControlEnumberable](https://docs.openzeppelin.com/contracts/3.x/access-control) Integration.
Roles are managed by the Access Control admin, currently set to Cap's multisig address
## Mechanics
* Each function on each contract has its own unique 32-byte role ID
* The role ID is generated by combining:
* The function selector (first 4 bytes of the function signature)
* The contract address
* Permissions can be granted/revoked at the function level
* Contracts inherit access control through the `Access` abstract contract and uses the checkAccess modifier on protected functions
For function signatures and data structures, see the [Access Controls Contract Reference](/developers/contracts/access-controls).
## Role Hierarchy
```
DEFAULT_ADMIN_ROLE
├── access_control_admin
│ ├── oracle_admin
│ ├── rate_oracle_admin
│ ├── lender_admin
│ ├── delegation_admin
│ └── vault_config_admin
└── Emergency Admin
```
1. **DEFAULT\_ADMIN\_ROLE**: Can upgrade the AccessControl contract
2. **Access Management Roles**: Can grant/revoke permissions
3. **Function-Specific Roles**: Control access to individual functions
## Permission Types
**1. Administrative Permissions**
* Contract upgrades (`bytes4(0)`)
* Access management (`grantAccess`, `revokeAccess`)
**2. Operational Permissions**
* Vault operations (`borrow`, `repay`, `mint`, `burn`)
* Oracle managements (`setOracleData`, `setStaleness`, `setRates`)
* Asset management (`addAsset`, `removeAsset`, `pauseAsset`, `setReserve`프로젝트로 돌아가기