Cap 백서

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

# 4. Updating Parameters To update the Underwriting Premium or the LTV for the Borrower, request a change to the Cap team. Namely, the underwriting premium can be updated via the [setRestakerRate](https://github.com/cap-labs-dev/cap-contracts/blob/1064b6a969d55c822dcf0b2c4b733ceb4118737e/contracts/delegation/Delegation.sol) function, and the LTV and LT via the [modifyAgent](https://github.com/cap-labs-dev/cap-contracts/blob/1064b6a969d55c822dcf0b2c4b733ceb4118737e/contracts/delegation/Delegation.sol#L97) function. # Symbiotic ## Overview Vault curators on Symbiotic can easily deploy Cap-specific Symbiotic Vaults using the [CapSymbioticVaultFactory](https://github.com/cap-labs-dev/cap-contracts/blob/main/contracts/delegation/providers/symbiotic/CapSymbioticVaultFactory.sol) directly on the app's [Create Vault page](https://cap.app/delegators/create-vault). Cap must first approve the Vault before delegated stake can be used as collateral. ### 1. Deploy Symbiotic Vault Curators can deploy Cap-specific Symbiotic Vaults either via 1. Cap's [UI](https://cap.app/underwriters/create-vault) for creating Vault 2. Vault Factory contract's [<kbd>createVault</kbd>](https://github.com/cap-labs-dev/cap-contracts/blob/1064b6a969d55c822dcf0b2c4b733ceb4118737e/contracts/delegation/providers/symbiotic/CapSymbioticVaultFactory.sol#L57) function on Etherscan. As most of the parameters and modules are preconfigured, curators only have to specify the Borrower address and Collateral asset address when creating the Vault. The factory contract will create Symbiotic's Delegator, Burner, Slasher and Rewarder modules as needed in Cap's Symbiotic Vault requirements. ```solidity /// @param _owner The owner of the vault, will manage delegations and set deposit limits /// @param asset The asset of the vault /// @param _agent The agent of the vault /// @param _network The network of the vault /// @return vault The address of the new vault function createVault(address _owner, address asset, address _agent, address _network) external returns (address vault, address delegator, address burner, address slasher, address stakerRewards); ``` {% hint style="info" %} To ensure that all parameters are set-up as intended in Cap's design, Cap only accepts Vaults deployed via the factory contract. {% endhint %} Once deployed,the Borrower-Underwriter pair will be added to Cap's contracts via SymbioticAgentManager's [`addAgent`](https://github.com/cap-labs-dev/cap-contracts/blob/1064b6a969d55c822dcf0b2c4b733ceb4118737e/contracts/delegation/providers/symbiotic/SymbioticAgentManager.sol#L42) function. The function handles necessary registry of the Vault. Once this part is complete, Underwriters can start using delegated stake as collateral. {% hint style="info" %} Vault creation will revert if the Borrower's address is already receiving delegations from another Vault. {% endhint %} ### 2. Admin Controls Key administrative functions available to vault admins include configuring admin fees, setting deposit limits, and whitelisting depositors. Admin fees are taken from the rewards distributed to depositors, as a percentage of the total rewards. ```solidity // Set an admin fee stakerRewards.setAdminFee(adminFee); // Enable/disable deposit limit vault.setIsDepositLimit(status); // Set deposit limit vault.setDepositLimit(amount); // Enable/disable deposit whitelist vault.setDepositWhitelist(status); // Add/remove whitelisted depositors vault.setDepositorWhitelistStatus(depositor, status); ``` The Borrower-Underwriter pair may also update loan specific parameters; while the liquidation threshold is a global parameter, the LTV can be set by the pair. ### 3. Collecting Rewards Rewards are automatically distributed to the StakerRewarder when a Borrower repays a loan. Underwriters can also manually claim rewards via the <kbd>realizeRestakerInterest</kbd> function on the [Lender](https://github.com/cap-labs-dev/cap-contracts/blob/main/contracts/lendingPool/Lender.sol) contract. The contract will distribute accrued interest on the Borrower's borrowed amount to the StakerRewarder. Vault admins can claim the admin fee via the <kbd>claimAdminFee</kbd> function of the Symbiotic StakerRewards. ### 4. Managing Withdrawals Withdrawals from Symbiotic Vaults take up to 2 epochs to process. Specifically, withdrawals start after the current epoch plus another epoch. Since an epoch is 7 days for Cap Symbiotic Vaults, it takes 8-14 days to complete the withdrawal. While the withdrawal is processed, the delegation assets are still liquidatable. If the withdrawal triggers an unhealthy position for the Borrower, then the asset may be liquidated (after the grace period). It is thus crucial that the withdrawal amount does not affect the Borrower's position: it is best advised for Underwriters to coordinate the withdrawal with the Borrower. ### 5. Verifying the Vault Once the Symbiotic Vault is deployed, Underwriters may verify the deployment status via the [Delegation](https://etherscan.io/address/0x09A3976d8D63728d20DCDFEe1e531C206Ba91225#readProxyContract) and [Symbiotic Network](https://etherscan.io/address/0x98e52Ea7578F2088c152E81b17A9a459bF089f2a#readProxyContract) Contracts. Use the \_agent field to input the Borrower's Ethereum address. * Delegation contract methods: * Collateral: delegation asset address * Coverage: how much stake is live * Vaults: the Borrower-Underwriter specific Symbiotic Vault * LTV: the max borrowable loan-to-value ratio * liquidationThreshold * Symbiotic Network methods: * getOperator: get SymbioticOperator address for Borrower address ### 6. Managing the Symbiotic App Once registered, the Underwriter profile will be updated in [Symbiotic's app page](https://app.symbiotic.fi/networks). If you wish to change the metadata on the app, please refer to [Symbiotic' guide](https://github.com/symbioticfi/metadata-mainnet) to do so. # EigenLayer The following is the onboarding guide for Underwriters using EigenLayer. The process is fully automated by the Cap system via the [EigenAgentManager](https://github.com/cap-labs-dev/cap-contracts/blob/main/contracts/delegation/providers/eigenlayer/EigenAgentManager.sol) contract. ### 1. Submit AgentConfig information to the Cap team This is the only action the Underwriter needs to take. The step can be completed by the Borrower (Agent). The rest of the process is handled on behalf of the Underwriter. ```solidity struct AgentConfig { address agent; // Your agent/borrower address address strategy; // EigenLayer strategy address (e.g., wstETH) address restaker; // Address of the Underwriter who will delegate to you string avsMetadata; // AVS metadata URI (can be empty string) string operatorMetadata; // Operator metadata URI (can be empty string) uint256 ltv; // Loan-to-Value ratio (e.g., 5e26 for 50%) uint256 liquidationThreshold; // Liquidation threshold (e.g., 8e26 for 80%) uint256 delegationRate; // Underwriting premium for rewards (e.g., 2e25 for 2%) } ``` If the strategy does not exist for the collateral asset, it can be permissionlessly created from the [StrategyFactory](https://github.com/Layr-Labs/eigenlayer-contracts/blob/8e25c9da31d5bb92de4fda14164d73911207aad5/src/contracts/strategies/StrategyFactory.sol#L4) contract. {% hint style="warning" %} The Underwriter cannot delegate to multiple Borrowers. A new address must be used to delegate to a new Borrower. {% endhint %} ### 2. Agent Registration Cap's Admin registers the Agent to both EigenLayer and Cap via the [addEigenAgent](https://github.com/cap-labs-dev/cap-contracts/blob/main/contracts/delegation/providers/eigenlayer/EigenAgentManager.sol#L44) function. Specifically, the function performs the following: * Registers Agent to Cap via [addAgent](https://github.com/cap-labs-dev/cap-contracts/blob/1064b6a969d55c822dcf0b2c4b733ceb4118737e/contracts/interfaces/ISymbioticAgentManager.sol#L45) function in the Delegation contract * Deploys [EigenOperator](https://github.com/cap-labs-dev/cap-contracts/blob/main/contracts/delegation/providers/eigenlayer/EigenOperator.sol) beacon proxy which handles * Registering to EigenLayer's DelegationManager * Creating and registering to a new Operator Set in EigenLayer's AllocationManager * Setting Operator AVS reward split 0% * Allowlisting TOTP digest for Underwriters (valid for 28 days) ### 3. Deposit At this time, Underwriters can deposit into the Strategy to receive strategy shares via the [depositIntoStrategy](https://github.com/Layr-Labs/eigenlayer-contracts/blob/8e25c9da31d5bb92de4fda14164d73911207aad5/src/contracts/core/StrategyManager.sol#L80) function. ### 4. Allocation Delay After registration, there is a **17.5** day delay of the allocation configuration for EigenLayer. During this delay, any delegations will **not** count as effective collateral. This is because the allocation magnitude cannot be updated prior to this allocation configuration delay period. After 17.5 days, Borrowers can allocate delegated collateral via the permissionless [allocate](https://github.com/cap-labs-dev/cap-contracts/blob/main/contracts/delegation/providers/eigenlayer/EigenServiceManager.sol#L227) function. ### 5. Delegate Once Borrowers allocate, strategy shares can be delegated to the EigenOperator via the [delegateTo](https://github.com/Layr-Labs/eigenlayer-contracts/blob/8e25c9da31d5bb92de4fda14164d73911207aad5/src/contracts/core/DelegationManager.sol#L124) function in the [DelegationManager](https://github.com/Layr-Labs/eigenlayer-contracts/blob/8e25c9da31d5bb92de4fda14164d73911207aad5/src/contracts/core/DelegationManager.sol) contract. Delegations will immediately count as effective coverage. #### TOTP When the addEigenAgent function is called, it creates a TOTP digest that is used when delegating to the EigenOperator. The TOTP delegation approval digest has an expiry timestamp that can be queried by the [getCurrentTotpExpiryTimestamp](https://github.com/cap-labs-dev/cap-contracts/blob/main/contracts/delegation/providers/eigenlayer/EigenOperator.sol#L148) function. If expired, a new digest can be generated via the [advanceTotp](https://github.com/cap-labs-dev/cap-contracts/blob/main/contracts/delegation/providers/eigenlayer/EigenOperator.sol#L105) function. With live coverage, the onboarding process is complete. Borrowers can now borrow against delegated collateral. ### 6. Verifying Information * Agent Registration: * IDelegation(delegation).agentData(agent).network should return EigenServiceManager's address * Agent Config: * IDelegation(delegation).agentData(agent) * EigenOperator Deployment: * IEigenServiceManager(eigenServiceManager).getEigenOperator(agent) * Operator address: * IEigenOperator(eigenOperator).operator() * Underwriter address: * IEigenOperator(eigenOperator).restaker() * Current Coverage: * IEigenServiceManager(eigenServiceManager).coverage(agent) * Delegated Shares: * IDelegationManager(delegationManager).getDepositedShares(restakerAddress) * TOTP expiry: * IEigenOperator(eigenOperator).getCurrentTotpExpiryTimestamp() ### 7. Tracking Rewards When the Borrower borrows, interest is paid and distributed to Underwriters through EigenLayer's RewardsCoordinator. Please refer to EigenLayer's [docs](https://docs.eigencloud.xyz/eigenlayer/concepts/rewards/rewards-claiming) to understand how rewards can be claimed. # Overview Cap consists of the six main modules: 1. [**Vault**](/concepts/vault): Stores reserve assets and issues cUSD tokens, providing liquidity to the Lender 2. [**Lender**](/concepts/lender): Handles borrowing, repayment, liquidation, and interest calculations 3. [**Fee Auction**](/concepts/fee-auction): Converts generated yield and fees to cUSD via a Dutch auction 4. [**Delegation**](/concepts/delegation): Connects to Shared Security Networks for delegated collateral, rewards, and liquidation 5. [**Oracles**](/concepts/oracles): Price oracles for asset valuation and rate oracles for interest calculations 6. [**Access Controls**](/concepts/access-controls): Function-level granular access controls across all protocol operations # Vault The Vault is the core module responsible for the storage, issuance, and redemption of cUSD, and for managing the underlying collateral assets. It plays a pivotal role as the protocol's liquidity backbone by enabling minting and burning of cUSD, facilitating liquidity for borrowers, and ensuring capital efficiency through the Fractional Reserves. ## Overview of operations * **Mint/Burn:** cUSD can be minted/burned *\~1:1* for any of the supported backing assets. Fees are dynamically calculated according to the allocation ratio of the asset. * **Redeem:** cUSD can be redeemed for a proportional amount of the basket of assets for a fixed fee. * [**Fractional Reserves**](/concepts/vault/fractional-reserves): Idle capital in the Vault is deployed into yield-generating strategies (US T-bill yield, crypto lending markets) until borrowed or withdrawn. * **Borrow/Repay**: When operators borrow/repays assets, the Vault tracks utilization of the pool ## Mechanics ### Mint/Burn The Vault is the main interface for liquidity providers to mint and burn cUSD. cUSD can be minted/burned at Oracle value for any of the assets. Fees are calculated in the [Minter](/concepts/vault/minter) contract according to the allocation of the assets. When a user mints/burns, the flow is as follows: 1. **User Call**: User calls `Vault.mint()` (or burn) with asset and amount 2. **Fee Calculation**: Vault calls `Minter.getMintAmount()` (or getBurnAmount) to calculate fees 3. **Logic Processing**: MinterLogic calculates amount out and fees at current Oracle value 4. **State Update**: VaultLogic handles asset transfer and state updates 5. **Token Minting**: cUSD is minted/burned in exchange for underlying assets {% hint style="info" %} Mint and burn functions are disabled if Oracle prices are stale, until Oracles are back in sync {% endhint %} ### Redeem A depeg event of any of the underlying assets can result in a last man standing problem where the last to withdraw will be left with the depegged asset. When such events occur, the protocol incentivizes users to withdraw proportionally to the ratio of the assets, effectively socializing the losses. Redeem fees are charged at a fixed percentage, whereas burn fees are dynamic, making it economically infeasible to burn for USDT beyond the burn kink ratio. For instance, if the basket contains 50% of USDC valued at $0.9 and 50% of USDT valued at $1, then the redeem request for $100 cUSD should withdraw $45 worth of USDC and $50 worth of USDT minus fees. When a user redeems, the flow is as follows: 1. **User Call**: User calls `Vault.redeem()` with cUSD 2. **Fee Calculation**: Vault calls `Minter.getRedeemAmount()` to calculate proportional amounts 3. **State Update**: cUSD is burned from user, assets are divested from strategies 4. **Asset Transfer**: All underlying assets are transferred to user ### Borrow Operations Registered Borrowers can borrow assets from the Vault via the Lender, provided they are sufficiently collateralized by delegated assets from shared security networks. While assets are lent out from the Vault, the core borrow logic is implemented in the Lender contract. When the Borrower requests to borrow via the Lender, the Lender calls `Vault.borrow()` to transfer assets to the Lender, updating the utilization and reserve state of the Vault. Similarly, Borrowers can repay via the Lender, which transfers borrowed assets back to the Vault. ### Vault Management Assets must first be whitelisted in order to be used in Cap. Only regulated dollar-denominated crypto assets are accepted as a backing assets. Interest rates for borrowing each asset of the reserve is a function of the utilization rate of the asset. The [current utilization rate](https://github.com/cap-labs-dev/cap-contracts/blob/main/contracts/vault/Vault.sol#L198) of each asset can be queried in the Vault contract. ### Configurations * **Whitelist minters**: Supports fee bypass for privileged users * **Pause mechanisms**: * Asset-Level Pause: Individual assets can be paused while others remain active * Protocol-Level Pause: Complete protocol shutdown capability ### Key Vault Parameters * **Total Supplies**: Total amount of each asset deposited in the vault * **Total Borrows**: Total amount of each asset borrowed from the vault * **Utilization Rate**: Ratio of borrowed assets to total supplies, calculated as (Total Borrows / Total Supplies) \* 100% * **Available Balance**: Amount of asset available for borrowing, calculated as Total Supplies - Total Borrows * **Utilization Index**: Cumulative utilization tracking for interest rate calculations * **Insurance Fund**: Address that receives fees from mint/burn operations * **Pause States**: Individual asset pause states and protocol-wide pause capability For function signatures, parameters, and data structures, see the [Vault Contract Reference](/developers/contracts/vault). # Fractional Reserves The [Fractional Reserve](https://github.com/cap-labs-dev/cap-contracts/blob/main/contracts/vault/FractionalReserve.sol) contracts allows the Vault to deploy idle capital into yield-generating strategies per reserve asset. In order to ensure sufficient liquidity for immediate withdrawals and redemptions, a fixed amount of capital can be set in the buffer reserve. The yield strategies are restricted to safe, verifiable sources such as direct revenue sharing from the reserve assets, or deployment into leading crypto lending markets such as Aave. This design ensures capital efficiency of the underlying assets while maintaining redeemability guarantees and reserve transparency. [Gelato](https://www.gelato.cloud/web3-functions) is used in Cap's Fractional Reserve system to automate capital deployment, yield harvesting, and fee distribution. ## Mechanics <figure><img src="https://315632032-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkRZQBMptsoesj7n1mr8a%2Fuploads%2Fgit-blob-4a5aec590715088b61b897c489168e70a4878862%2Fimage.png?alt=media" alt=""><figcaption><p>Flow of Funds: Fractional Reserves</p></figcaption></figure> The flow is as follows: 1. cUSD minters deposit assets into Cap Vault 2. Excess capital is invested into Fractional Reserve Vaults, where TokenHolder strategies will generate passive yield 3. Accrued yield is sent to the Fee Auction, sold for cUSD 4. The cUSD is transferred to the Fee Receiver which then periodically distributes rewards to stcUSD holders Fractional Reserve Vault & Gelato Mechanics * A ERC4626 [TokenHolder](https://github.com/cap-labs-dev/cap-contracts/blob/main/contracts/fractionalReserve/TokenHolder.sol) Fractional Reserve Vault is deployed for the underlying reserve asset (i.e. USDC) that acts as a strategy following Yearn V3's [Tokenized Strategy](https://github.com/yearn/tokenized-strategy) pattern. (i.e. lending to Aave V3). Only the Fractional Reserve Vault can deposit and withdraw from the Vault. * The [CapSweeper](https://github.com/cap-labs-dev/cap-contracts/blob/main/contracts/gelato/CapSweeper.sol) contract automatically invests excess assets every 6 hours * The strategy earns interest in the asset supplied until divested. [CapInterestHarvester](https://github.com/cap-labs-dev/cap-contracts/blob/main/contracts/gelato/CapInterestHarvester.sol) is used to automate yield harvesting from the fractional reserve strategies to the Fee Auction ### Key Fractional Reserve Parameters * **Reserve Level**: Minimum amount of each asset to keep in the vault (not invested) * **Loaned Amount**: Total amount of each asset currently invested in fractional reserve strategies * **Interest Receiver**: Address that receives realized interest (set to [Fee Auction](/concepts/fee-auction)) * **Claimable Interest**: Amount of interest available to be realized from strategies * **Investment Threshold**: Mini
프로젝트로 돌아가기