đī¸Vaults Infrastructure
How vaults work from infrastructure point of view
Last updated
How vaults work from infrastructure point of view
Last updated
Two vaults (JLP and USDC) under Adrastea protocol have been developed in tandem. Core accounts: Program BgFH1pBWFzbkDARiJPYDMMwTTzAyTGB7DFJBxfbQWYub mainAccount 3EGAW8esSxjeA2CGfjj6wPhY85ruiQ31ZXbqKuQ7yqYF protocolVault 5UdVUMca5sufDcZukjXFK1mACamiPeTwEagSjaR75M3C revenueVault 6NLwik12ShL2Sm54zFTBa64MUPoHNbAdiebXVg8BS4TL
Core instructions of leverage strategy: - Deposit JLP - Deposit USDC - Profit fixing and redistribution - Withdraw JLP - Withdraw USDC - Liquidations Let's start going one by one:
When a user connects their wallet to the Adrastea website and links their social accounts during the beta phase, Adrastea verifies the presence of specific âallowâ roles in Discord to authorize deposits. Upon successful verification, the user is permitted to deposit JLP.
This entire process is seamlessly executed in a single transaction:
The deposited JLP tokens are transferred to the âmain_account.â
The program records this deposit as collateral and, based on a target leverage of 2x, calculates the maximum leverage available for borrowing.
The program then deploys liquidity from the USDC pool to purchase JLP via an on-chain swap on Meteora, adhering to the maximum allowable slippage parameters.
The protocol stores the final actual swap price on-chain in the âjlp_ledger,â where the userâs âposition entry priceâ is represented as one of the holders record. This completes the JLP deposit process.
When a user connects their wallet to the Adrastea website and links their social accounts during the beta phase, Adrastea verifies the presence of specific âallowâ roles in Discord to authorize deposits. Upon successful verification, the user is permitted to deposit USDC. This entire process is seamlessly executed in a single transaction:
The program transfers USDC to the âmain_account.â
The userâs USDC deposit is recorded in the âUSDC_ledger.â
The main program checks the âJLP_Ledgerâ and reviews user records to identify if any user requires leverage to be bought and the amount needed.
If no leverage is needed, the USDC deposit process completes.
If leverage is needed:
The program initiates a swap for the total amount of leverage required for the user. To identify the leverage needed, the program uses specific variables and a formula. Variables:
Formula:
The swap is performed through the Meteora on-chain program under âacceptableâ slippage terms.
The received JLP after the swap is distributed and recorded in the âjlp_ledgerâ by the program according to each userâs JLP needs to reach the target leverage.
The USDC deposit process then completes.
When the JLP price grows, profits are established on the leverage position and are ready to be distributed among JLP depositors, USDC depositors, and the Protocol.
The program reviews the jlp_ledger and checks the delta between the last dynamic benchmark price or the position open price and the current JLP price for the leveraged JLP. If the delta is positive, the program sums up the total positive delta for all users. Variables:
For each user i :
If \Delta_i > 0 , it is included in the total delta:
The program virtually converts the sum of the positive delta into USDC value. Based on the protocolâs utilization, the exact yield share is determined for the USDC vault and the JLP vault. A portion of the yield share goes to the protocol itself.
During the beta phase, the protocol does not earn any yield share.
The program then virtually converts the positive delta back into JLP from the USDC value.
The JLP to USDC swap is performed through the Meteora on-chain program under âacceptableâ slippage terms.
The received tokens are redistributed / recorded in the jlp_ledger and usdc_ledger according to the protocolâs yield share distribution.
JLP holders who generated profits are updated with a new dynamic benchmark price based on the swap price.
Profit fixing and redistribution completes.
This entire process is seamlessly executed in a single transaction. During a withdrawal request by a user, the program checks if the user has enough leverage value to close the position without incurring a loss. Losses can occur due to two main reasons: 1. The leverage value has decreased since the position was opened or new leverage was bought. 2. Slippage on the swap of leverage to return funds to the USDC vault. If a loss is identified, a portion of the userâs collateral must be sold to compensate USDC providers for the loss on their supplied funds.
If the userâs position has earned enough profit to cover the losses, the program will use the profits to compensate for the losses. However, if the profits are insufficient, the program will sell part of the userâs collateral to cover the losses.
The JLP to USDC swap is performed through the Meteora on-chain program under âacceptableâ slippage terms. After covering the position loss, the remaining JLP collateral is sent back to the user. If profits are still available to claim, the 'jlp_ledger' record remains until the user claims the profits. If no profits are left, the 'jlp_ledger' record of the userâs position is deleted. The JLP withdrawal process is then complete.
This entire process is seamlessly executed in a single transaction.
The program checks if there is sufficient USDC liquidity available for withdrawal.
Depending on the poolâs utilization ratio, not all liquidity may be withdrawable at once if the utilization is high. We have designed a 70% target utilization rate to ensure 30% of liquidity is available for withdrawal. This doesnât indicate that the protocol has lost money or is insolvent; it simply means the liquidity is being utilized in the Leverage Vault. When available liquidity is low, the APY increases to attract more capital providers and achieve equilibrium. This mechanism is standard among lending protocols like Compound and Aave. Adrastea DAO will be able to adjust the utilization curve parameters to influence protocol behavior in unusual situations.
If Yes:
The requested amount is transferred to the user.
If the user has profits yet to claim, their record remains in the usdc_ledger.
If there are no profits to claim, the userâs record is deleted from the usdc_ledger.
If no:
The user cannot withdraw USDC at this moment, and the program will not allow the withdrawal.
To ensure the security of USDC depositors, the protocol has developed liquidation scenarios. There are two types of liquidations:
Initiated by JLP User
Initiated by Protocol
Initiated by JLP User:
If a user decides to close their position while the JLP price has decreased, the protocol executes a partial liquidation of the collateral equivalent to the loss incurred on the leveraged position. This is done to return the full amount of debt to the USDC vault. A user may choose to wait for the JLP price to rise to avoid liquidating part of their collateral by closing the position at a specific time. Initiated by Protocol:
The protocol ensures that the debt owed to USDC depositors equals the JLP value held by the protocol. The team has conducted market back tests on the assetsâ volatility in the JLP index, creating a virtual index and analyzing historical volatility and black swan events. Based on these tests, a target leverage of 2x was selected to minimize the risks of full liquidation. The protocolâs safe margin is set at 5% and will be reevaluated based on community and market feedback. In the event of a significant price drop in JLP that triggers a protocol-initiated liquidation, all collateral positions will be liquidated, and funds will be transferred to the USDC main account for depositors to claim.