Olympus 백서

Olympus

원문

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

function should also handle withdrawals from any external staking pools like Aura or Convex. /// @param lpAmount_ The amount of liquidity pool tokens to withdraw /// @param minTokenAmounts_ The minimum amounts of OHM and partner tokens to receive /// @return ohmOut The amount of OHM received /// @return tknOut The amount of partner tokens received function _withdraw( uint256 lpAmount_, uint256[] calldata minTokenAmounts_ ) internal virtual returns (uint256 ohmOut, uint256 tknOut); _accumulateExternalRewards: Internal function which harvests any external rewards from sources like Aura or Convex. /// @return rewardsOut The amounts of each external reward token harvested function _accumulateExternalRewards() internal virtual returns (uint256[] memory rewardsOut); Example Contract Implementation Once the key functions are understood, the implementation of a contract that inherits SingleSidedLiquidityVault will be easier and safer. For instance, let's take the StethLiquidityVault implementation as an example ( check the source code here ). In this case, the vault will be harvesting rewards from Aura. Therefore, it will first deposit its liquidity on Balancer and, afterwards, deposit the received BPT on Aura. Custom Variables and Getters ​ The SingleSidedLiquidityVault defines custom variables that help handle the interactions with Balancer and Aura Finance. Integration State ​ IVault public vault; vault holds the interface to interact with the Balancer Vault (on Balancer all the liquidity is managed in a single core vault). struct AuraPool { uint256 pid; IAuraBooster booster; IAuraRewardPool rewardsPool; } AuraPool public auraPool; auraPool stores the necessary information to deposit (BPTs managed by auraPool.booster and deposited on auraPool.pid ) and harvest (rewards are claimed from auraPool.rewardsPool ) on Aura . struct OracleFeed { AggregatorV3Interface feed; uint48 updateThreshold; } OracleFeed public ohmEthPriceFeed; OracleFeed public ethUsdPriceFeed; OracleFeed public stethUsdPriceFeed; Finally, to handle the price conversions, different Chainlink price oracles must be used. Overriding Virtual Functions ​ The easiest way to implement a these functions is by directly checking the StethLiquidityVault code ). Nevertheless, this section will list some of the this that any developer should have in mind. deposit ​ When implementing the _deposit function: Cast the liquidity pool address from abstract to Balancer Base pool. Fetch the underlying liquidity before joinning the pool (it will be used later to know the resulting LP tokens). Approve the core Balancer Vault as spender of both tokens (OHM and the pair token). Make a request to the Balancer Vault to join the liquidity pool. Calculate the amount of resulting LP tokens, approve the Aura Booster as a spender, and deposit them there. Return the amount of resulting BPT tokens. withdraw ​ When implementing the _withdraw function: Cast the liquidity pool address from abstract to Balancer Base pool. Fetch the underlying naked assets (OHM and the pair token) held by the vault. Unstake the BPT tokens from Aura. Make a request to the Balancer Vault to leave the liquidity pool. Return the amount of extra tokens (OHM and the pair token) held in the vault. accumulateExternalRewards ​ When implementing the _accumulateExternalRewards function: Loop over the externalRewardTokens to cast the balances of the vault. Harvest the rewards from Aura. Loop over the externalRewardTokens again to cast the new balances of the vault. Return a list with the harvested rewards for each token in the externalRewardTokens array. valueCollateral ​ When implementing the _valueCollateral function: Fetch the necessary price feed oracles to get the ratio of OHM / PairToken . Make sure that the decimals are in place. Return the conversion of the input _amount of pair token in OHM terms. getPoolPrice ​ When implementing the _getPoolPrice function: Calculate the OHM / pairToken ratio of the Liquidity pool by fetching the amount of each token in the pool. getPoolOhmShare ​ When implementing the _getPoolOhmShare function: Calculate the vault's share on the liquidity pool. Economic Mechanisms Operational Mechanisms Deposit Withdraw Benefits by Stakeholder For the Protocol: For Partners: For Users: Risks by Stakeholder For the Protocol: For Partners: For Users: Security Considerations Useful Variables and Getters Reward Token State Reward Token State View Functions Core Functions deposit withdraw claimRewards Virtual Functions Custom Variables and Getters Integration State Overriding Virtual Functions deposit withdraw accumulateExternalRewards valueCollateral getPoolPrice getPoolOhmShare ## /main/legacy/policy Policy Team & Framework The policy team was composed of about 10 members of the Olympus community who have displayed sufficient knowledge of the protocol and a curiosity to continue to learn as the protocol grew in size and complexity. Policy was largely guided by the policy framework that was ratified by community through governance. ## /main/legacy/dao-processes/treasury-process Treasury Decision Process One of Olympus DAO’s core values is being decentralized, so it’s important that the community has a say in all key decisions. Every decision must go through a rigorous process prior to execution which includes internal consensus as well as public governance. The diagram below illustrates the decision-making process for allocating funds from the treasury. ## /main/legacy/coolers On this page Cooler Loans Overview ​ Cooler Loans is a decentralized lending facility that allows OHM (Olympus) token holders to borrow DAI by using their gOHM (governance OHM) tokens as collateral. This lending facility is permissionless, immutable, and governed by Olympus smart contracts. With Cooler Loans, users will have a reliable access to liquidity using their gOHM token as collateral. Cooler Loans differentiates itself from existing lending markets: Peer-to-lender - loans originate from Olympus Treasury through a clearinghouse contract. Practically, Cooler Loans acts as lender-of-last-resort and can guarantee liquidity because every gOHM is backed by DAI. Fixed duration - all loans have a fixed maturity. Fixed interest - all loans have a fixed interest rate that is independent of market conditions. No liquidations - whereas most lending markets will liquidate your position if underlying collateral falls below a certain price, Cooler Loans is in a unique position to offer liquidation-free loans because every gOHM is backed by DAI. As long as Loan-to-Collateral value is at a safe discount relative to actual backing, the protocol remains solvent. Oracle-free - since Cooler Loans does not have liquidations and origination is based on a fixed value, it doesn’t depend on any external oracles. Isolated risk architecture - whereas most lending markets socialize borrower risk through shared pool architecture, Cooler Loans isolates risk via user-specific debt-collateral contracts called Coolers. Predictable Terms - Capacity, Loan-to-backing amount, tenor, and interest rates are all fixed parameters. Ability to roll - Users can roll their loans at any time prior to the loan's expiration, keeping the same fixed terms. Architecture ​ Cooler Loans is built on top of three smart contracts and two structs: Cooler.sol - Cooler is an escrow contract that facilitates fixed-duration, peer-to-peer loans for a user-debt-collateral combination. Some of the responsibilities of Cooler contract include: Keeps track of all the requests/loans and their status Escrows the collateral during the lending period Handles clearings, repayments, rollovers and defaults Offers callbacks to the lender after key actions happen Clearinghouse.sol - Clearinghouse is a lender-owned contract that manages loan workflows including fulfilling requests, extending maturities, claiming defaults and rebalancing funds to/from Olympus Treasury. Some of the responsibilities of Clearinghouse contract include: Implements the mandate of the Olympus community in OIP-144 by offering loans at the governance-approved terms Tracks the outstanding debt and interest that the protocol should be received upon repayment Its lending capacity is limited by a FUND_AMOUNT and a FUND_CADENCE. Despite providing loans denominated in DAI, the system allocates its dormant capital to the Dai Savings Rate (DSR) while maintaining holdings in sDAI. Implements permissioned functions to shutdown, defund, and reactivate the lending facility CoolerFactory.sol - CoolerFactory is a factory contract for deploying Cooler.sol contracts associated with a user-debt-collateral combination. Some of the responsibilities of CoolerFactory contract include: Keeps track of all the deployed contracts Deploys a new Cooler if the combination of user-debt-collateral doesn't exist yet Uses clones with immutable arguments to save gas In charge of logging the Cooler events Request struct - Request is a struct that represents intent (or request) by the borrower to borrow DAI against gOHM. Technically, requests may or may not be filled, but current implementation of Clearinghouse.sol automatically fills all requests. Loan struct - Loan is a struct that represents fulfillment by the lender of a particular Request. The following diagram may help understand the relationship between the various components: Using Cooler Loans ​ When a user wants to use Cooler Loans, they begin by interacting with CoolerFactory.sol to create a Cooler.sol that is unique to them, the collateral, and the borrowable asset. Within a user's Cooler.sol there may be multiple requests and loans. It is important to distinguish this singular escrow contract from the plural loan workflow. Next, when a user signals intent to borrow 2892.92 DAI against 1 gOHM, a Request struct is created. Simultaneously, Clearinghouse.sol withdraws the requisite amount of DAI from TRSRY.sol and fulfills the request. The act of fulfillment creates the Loan struct. At this point, Clearinghouse.sol gets gOHM collateral and the user gets DAI in their wallet. The user can then repay the loan, extend the loan, or default on the loan. Loan Terms and Conditions ​ Before borrowing from the Clearinghouse, it's important to understand the terms and conditions: Loans are extended in DAI, against gOHM collateral Loans have an annualized interest rate of 0.5%, as approved by TAP-28 Loan duration is 121 days, as approved by TAP-28 The loan-to-collateral ratio is 2892.92 DAI per gOHM, as approved by TAP-28 Loans can be extended with the same terms an arbitrary number of times into the future. While Clearinghouse.sol is immutable, future governance proposals may deploy new Clearinghouse contracts with updated parameters. Any loan terms made under the original Clearinghouse contract are not affected. To minimize smart contract risk, Cooler Loans will be rolled out with a weekly cadence of 18M DAI capacity. Opening a Loan ​ To open a loan, a user will first need to create a Cooler.sol escrow contract for themselves. This happens by interacting with CoolerFactory.sol factory, available on the Olympus frontend. Once a Cooler is created, a user requests a loan by specifying the amount of DAI to borrow. Alternatively, a user can specify the amount of gOHM collateral to deposit. The calculation between collateral and borrowable asset is fixed by the Loan-to-Collateral defined on Clearinghouse.sol. In the same transaction that a request is created, Clearinghouse.sol fulfills the request by creating a Loan struct with the following parameters: principal - amount of DAI that is borrowed expiry - expiration of the loan, defined to be the current block timestamp plus 121 days interestDue - amount of interest, in DAI, to be paid 121 days from current timestamp. It’s important to highlight that interest on the loan is accrued at the time the loan is opened. Keep this in mind as you read the next two sections. Example: user requests to borrow against 1 gOHM. The LTB for cooler is 2892.92 DAI per gOHM, at the time the loan is opened, the user owes 4.82 DAI in interest (0.5% multiplied by 2892.92 DAI principal multiplied by 121 days out of 365). User gets 2892.92 DAI in their wallet and transfers 1 gOHM. Repaying a Loan ​ A user can repay a loan at any time with any amount. However, because of how loans are fulfilled, any repayment will be allocated toward interest first. Any repayment in excess of interest owed is then allocated to repaying the principal. Once all outstanding interest and principal have been repaid, the user unlocks their collateral. Example: user requests to borrow against 1 gOHM. The LTB for cooler is 2892.92 DAI per gOHM, therefore the interest owed is 4.82 DAI per tenor. If user repays 1 DAI, the user now owes 3.82 DAI in interest and 2892.92 DAI in principal. User gets no collateral back. If user repays 4.82 DAI, user owes no interest and only 2892.92 DAI in principal. User gets no collateral back. If user repays 500 DAI, user has fully repaid interest (4.82 DAI) and partially repaid principal (495.18 DAI). User gets 0.17117 gOHM collateral back (495.18/2892.92). If user repays 2897.74 DAI, user has fully repaid interest (4.82 DAI) AND fully repaid 2892.92 DAI in principal. User gets back their 1 gOHM collateral. Extending Duration ​ A user can extend a loan at any time, for as long as they want, with the same terms they opened a Cooler with. However, because of how loans are fulfilled, any loan extension must first repay the accrued interest on previous loans before the extension is granted. This is done automatically in a single transaction, optimized to reduce friction and costs for the user. Furthermore, since Clearinghouse.sol gives the ability to extend a loan an arbitrary number of times, the user must pay N-1 interest terms if they want to extend a loan for N terms. This is best demonstrated with the examples below. Example: user has an open loan, borrowing 2892.92 DAI against 1 gOHM, owing 4.82 DAI in interest. They want to extend the loan for one more term (121 days). For this to work, they transfer 4.82 DAI (paying off interest on previous loan) and loan expiry extends by 121 days. In another 121 days, user owes 4.82 DAI interest and 2892.92 DAI in principal. Example: Consider the same example but now the user wants to extend for 10 terms (1210 days). For this to work, they transfer 48.2 DAI (ten times 4.82 DAI) and loan expiry extends by 1210 days. In 1210 days, user owes 4.82 DAI and 2892.92 DAI in principal. Notice how interest due remains the same as the original loan term. Why? Functionally speaking, user’s interestDue variable didn’t change; the user just transferred the amount of interest that would’ve been charged during the extension directly to Clearinghouse.sol contract. FAQ ​ What chains are Cooler Loans available on? ​ Cooler Loans are only available on Ethereum. What token do I need for interest payments? ​ Interest payments must be completed with DAI. Can I pay interest from a different wallet? ​ Yes, interest payments can be made by wallets other than the one originating the loan. What if I need to repay before the term is over, can I pay partial interest? ​ Interest is charged upfront. To get your principal back or extend a loan, you will need to pay that in full. As this is a fixed-term product, there's no distinction between paying at maturity or earlier. Is there a limit to the number of times I can extend my loan? ​ There is no functional limit to the number of extensions, however extensions are not supported past August 23rd, 275760. Please plan accordingly. How many Cooler Loans can I have? ​ There is no limit on the number of loans or the total cumulative value of loans per user. Limits are based on fixed terms and the weekly clearinghouse capacity. Can I loop my loan? ​ Yes, it is possible to convert the DAI obtained from the loan back into gOHM and take out another Cooler Loan. Use caution when choosing to leverage. What if I want to add to my loan amount? ​ You cannot add to an existing loan. To increase the loan amount either take out an additional loan, or pay off the first loan in full and take a new loan with the total amount desired. Can I partially pay back my loan? ​ You may make a partial payment on your loan. All payments are automatically applied towards outstanding interest payment prior to being applied to the principal. If I partially repay a loan, can I just reborrow those funds later? ​ No, there's no ability to add to the loan once a payment has been received. If I partially repay a loan, will my interest payments change to reflect the lower balance? ​ If you have paid part of the balance prior to maturity, the interest amount on the next roll will reflect the outstanding balance instead of the original loan value. What if price or backing goes up, can I pull out the added equity from my loan? ​ Loan terms are hard-coded at time of launch. So if backing goes up, LTV remains at X DAI per gOHM. Price has no impact on loan terms. What if I forget to roll my loan, is there a grace period before defaulting? ​ Expiration of the loan will occur automatically according to contract terms. I accidentally defaulted, can I recover my collateral? ​ Unfortunately, this is not possible. Once loan expiration occurs contract terms are automatically executed. If other users repay their loans, will that increase the capacity available in the clearinghouse? ​ The capacity in the clearinghouse is rebalanced weekly. If a user repays their loan, the DAI will be available in the clearinghouse. If the available amount is below the threshold upon rebalancing it will be topped up, if the available amount is above the threshold the excess will be removed when rebalancing occurs. Do Cooler Loans increase OHM supply? ​ No, Cooler Loans do not cause an increase in supply. What happens to the defaulted gOHM? ​ When a loan is defaulted, the underlying collateral is burned. What happens with the collected interest payments? ​ Interest payments are directed to Liquid Backing. Can a user vote with their Cooler collateral? ​ To participate in governance, users MUST self-delegate in order to be able to use Cooler collateral to vote on snapshot proposals. Undelegated collateral is unable to be recognized by snapshot. Users can either delegate to their own address, or delegate their voting power to another address. Delegation can be completed via the Cooler page on the app once a user has an active loan. Delegation must be completed prior to a snapshot proposal going live or the user will be unable to vote for that proposal. ALL of the collateral in your Cooler is delegated when calling this function, it is not on a per loan basis. If you have multiple loans, they will all be delegated to the same address. You only need to call delegate once, it will automatically recognize each time you add to a loan to your Cooler and reflect the increased collateral. You can choose to change the address that you delegate to at a later time. Contracts ​ Contract Address Clearinghouse v1 0xD6A6E8d9e82534bD65821142fcCd91ec9cF31880 Clearinghouse v2 0xE6343ad0675C9b8D3f32679ae6aDbA0766A2ab4c Overview Architecture Using Cooler Loans Loan Terms and Conditions Opening a Loan Repaying a Loan Extending Duration FAQ What chains are Cooler Loans available on? What token do I need for interest payments? Can I pay interest from a different wallet? What if I need to repay before the term is over, can I pay partial interest? Is there a limit to the number of times I can extend my loan? How many Cooler Loans can I have? Can I loop my loan? What if I want to add to my loan amount? Can I partially pay back my loan? If I partially repay a loan, can I just reborrow those funds later? If I partially repay a loan, will my interest payments change to reflect the lower balance? What if price or backing goes up, can I pull out the added equity fro
프로젝트로 돌아가기