ποΈVaults Infrastructure
How vaults work from infrastructure point of view
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:
1. Deposit JLP
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.

2. Deposit USDC
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:
P_i : The current position in JLP of the i-th user. \lambda_t : The target leverage ratio. (2x as of current protocol setup) \lambda_{c,i} : The current leverage amount in JLP for the i-th user. N : The total number of users in the JLP ledger.
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.

3. Profit fixing and redistribution
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:
P_{\text{current}} be the current JLP price. P_{\text{benchmark}, i} be the last dynamic benchmark price or position open price. for user i . \Delta_i be the delta for user i in jlp_ledger. \Delta_{\text{total}} be the total positive delta for all users in jlp ledger.
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.
Total Yield - USDC Yield Share - Protocol Yield Share = JLP Yield Share
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.

4. Withdraw JLP
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.
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.

5. Withdraw USDC
This entire process is seamlessly executed in a single transaction.
The program checks if there is sufficient USDC liquidity available for withdrawal.
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.

6. Liquidations
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.

Last updated