Tutorials
Introduction
Here you will find several tutorials on how you can do several actions on Mystic, namely:
Creating Vault
Supply and Withdraw (Core Pools or Vaults)
Borrow and Repay (Core Pools or Vaults)
Liquidation: Rates and Incentives
KYC
Custody
Without further ado, let's get stuck in!
Creating Vault
Navigate to the Vault Factory: Access the vault factory contract on the chain you're using. The contract addresses can be found in the protocol’s "Addresses" section. The vault factory is necessary if you wish to act as a vault curator. For example, the vault factory for the Plume Network devnet can be found at 0xbbbbbbbbbb9cc5e90e3b3af64bdaf62c37eeffcb.
Fill in the required attributes: Go to the createVault function within the Vault Factory contract, either through the explorer or the protocol UI, and fill in the necessary data:
initialTimelock: Minimum time delay required for a withdrawal request to become withdrawable.
asset: The primary asset for deposits and withdrawals (usually stablecoins like USDT, USDC).
maxDeposit: The maximum deposit value for the asset.
maxWithdrawal: The maximum withdrawal value for the asset.
fee: The percentage fee for every withdrawal (e.g., 100 = 1%).
feeRecipient: The address that will receive the fees.
name: Name of the Vault and Vault token.
symbol: Symbol of the Vault token.
salt: A bytes32 value used in the deployment process (use 0x as the default).
Sign the transaction: Approve and sign the transaction in your wallet.
Retrieve the Vault Address: You can retrieve the vault address by:
Checking the return value of the call (if using Solidity/JavaScript code), or checking the transaction hash in the explorer, and viewing the events tab to find the CreateVault event. The first address in the event is the vault address.
Add Pool to Vault: To activate the vault, you need to add pools. Use the addMysticPool function via the explorer or UI and provide the following:
newAsset: The asset for the pool reserve (should match the main asset in the vault).
oracle: The oracle address for the asset (same oracle can be reused).
allocationPercentage: The percentage of deposits allocated to this pool (1% = 100).
mysticPoolAddress: The pool address to add.
Sign the second transaction: Approve and sign the addMysticPool transaction in your wallet.
Supply and Withdraw (Core Pools or Vaults)
Supplying on Core Pools:
Access Mystic's Core Pools: Navigate to the Mystic Finance UI, select the chain, and go to the Core Pools section.
Select Asset: Choose an asset from the available reserves to deposit.
Approve and Sign Transactions: Approve the asset and sign the supply transaction.
Check for myTokens: After the transaction, check the explorer for the myToken (LP tokens) you have received.
Supplying on Vaults:
Access the Vault: Go to the Vaults page in the Mystic Finance UI, select the appropriate chain, and navigate to the vault.
Deposit the Required Asset: Enter the deposit amount for the defined vault asset.
Approve and Sign the Transaction: Approve the asset and sign the deposit transaction.
Check for Vault Tokens: Check the explorer for your Vault tokens after the transaction is completed.
Withdrawing on Core Pools:
Access Core Mystic Pools: Navigate to the core pools section in the UI.
Select Asset to Withdraw: Choose an asset to withdraw and enter the amount.
Sign the Withdraw Transaction: Sign the withdrawal transaction and check your wallet for the received assets.
Withdrawing on Vaults:
Access the Vault: Navigate to the vault section in the UI.
Withdraw Required Asset: Enter the withdrawal amount for the vault asset.
Sign the Withdraw Transaction: Approve and sign the transaction and check your wallet for the withdrawn assets.
Borrow and Repay (Core Pools and Vaults)
Borrow on Core Pools:
Access Core Mystic Pools: Go to the Mystic Finance UI, select the chain, and navigate to the Core Pools section.
Select Asset to Borrow: Choose an asset from the list of reserves, then provide collateral and specify the borrowing amount.
Approve and Sign the Transactions: Approve the collateral, set it as collateral (if needed), and sign the borrowing transaction.
Check for Debt Tokens: Check your wallet for borrowed assets and debt tokens.
Borrow on Vault:
Access the Vault: Go to the vault page in the UI and select an asset to borrow.
Borrowing Options: Enter the collateral amount and the amount to borrow. You can choose whether to receive the borrowed asset or Vault shares based on the borrow amount.
Approve and Sign the Transactions: Approve the collateral and sign the borrow transaction.
Check for Vault Tokens: Check your wallet for borrowed assets or Vault shares and debt tokens.
Repay on Core Pools:
Access Core Mystic Pools: Navigate to the repayment section in the UI.
Select Asset to Repay: Choose an asset to repay and enter the repayment amount.
Sign the Repay Transaction: Sign the repayment transaction and check your wallet for reduced debt and burnt debt tokens.
Repay on Vault:
Access the Vault: Navigate to the vault repayment section.
Repay Vault Asset: Enter the repayment amount, choosing whether to repay with the vault or another asset.
Sign the Repay Transaction: Approve and sign the repayment transaction and check for reduced debt and burnt debt tokens.
Liquidation: Rates and Incentives
Liquidation in Mystic Finance is triggered when a user’s health factor falls below 1, making their account eligible for liquidation. Liquidators can repay up to 90% of the user’s debt in exchange for a portion of their collateral plus a liquidation incentive. This process is essential for maintaining the health and stability of the protocol.
LiquidationCall Function
The liquidationCall function can be executed by liquidators when a borrower's account is undercollateralized. Here’s a breakdown of the function parameters and how to use it:
Parameters for liquidationCall:
```
function liquidationCall(
collateralAsset address,
debtAsset address,
user address,
debtToCover uint256,
receiveAToken bool,
) external;
Input Parameters:
Liquidating a loan
To first find which loan to liquidate, liquidators must carefully monitor borrowers' Health Factors, which is a measure of how close an account is to liquidation. A health factor below 1 means the account is undercollateralized and can be liquidated.
Health Factor = (Total Collateral * LTV) / Total Debt
For example, if a user has $10,000 in collateral and $8,000 in debt, with a loan-to-value (LTV) ratio of 80%, the health factor would be (10,000 * 0.80) / 8,000 = 1.0.
If the user’s collateral value falls or their debt increases, the health factor may drop below 1, making them eligible for liquidation. When the health factor is below 1, the liquidator can repay part of the borrower’s debt by calling liquidationCall. In return, the liquidator receives a portion of the borrower’s collateral, plus an added extra to incentivize them to liquidate in the first place. This incentive compensates the liquidator for the risk and cost of performing the liquidation. Let's go through an example:
Let’s assume a user (borrower) has a health factor of 0.9 due to a fictional fluctuation in DAI's price, making them eligible for liquidation. The user has:
$10,000 worth of DAI as collateral
$8,000 worth of USDC as debt
A liquidator decides to cover $4,500 of the user’s USDC debt. The parameters for the liquidationCall would be:
collateralAsset: DAI (the collateral asset).
debtAsset: USDC (the debt to be repaid).
user: The address of the borrower.
debtToCover: $4,500 (amount of USDC debt being repaid).
receiveAToken: false (liquidator wants to receive DAI directly instead of myTokens).
The liquidator signs and sends the transaction. Upon successful execution, the liquidator repays $4,500 of the user’s USDC debt and receives an equivalent amount of DAI (plus the liquidation incentive).
Use Cases for Liquidation:
Risk Management: Liquidation allows the protocol to recover assets from accounts that are at risk of default, thus ensuring the security of the protocol’s reserves.
Market Stability: Liquidations ensure that bad debts do not accumulate, maintaining overall market stability.
Incentives for Liquidators: The Liquidation Incentive motivates participants to take part in the process, further ensuring that unhealthy positions are addressed swiftly.
For more technical details on liquidations, refer to Aave's liquidation documentation:
Prerequisites: Aave Docs - Prerequisites
Finding accounts to liquidate: Aave Docs - Getting Accounts
Executing liquidation: Aave Docs - Executing Liquidation
Rates and Incentives
The interest rate strategy and incentives for Mystic Finance will be designed to incentivize lending and borrowing, potentially including Mystic tokens as rewards. As for interest rate strategies, refer to the Aave documentation:
KYC (Know Your Customer)
Some pools on Mystic require participants to KYC. This process ensures that both Mystic and all its users adhere to the relevant regulatory standards before interacting with the system.
KYC Process Flow
User Initiates KYC Process:
To access the Borrow and Repay functionalities in certain pools, users must first complete the KYC verification process. This can be done through the Mystic Finance UI by navigating to the KYC section.
Personal Data Submission: to complete KYC, users must submit:
Full Name: As per your official documents.
Address: Your residential address.
Proof of Identity: Government-issued ID (passport, driver’s license, etc.).8Proof of Address: Utility bills, bank statements, etc.
Here's an example KYC data flow: {
"fullName": "John Doe",
"address": "123 Main Street",
"idType": "passport",
"idNumber": "AB1234567",
"proofOfAddress": "utility_bill.pdf",
“walletAddress”:”0x1”
}
KYC Approval:
After submission, the submission is verified. If approved, users will receive a notification (either via email or directly on the platform) indicating that the KYC process has been successfully completed and their account has been approved for borrowing and repaying.
Example KYC notification status: {
"kycStatus": "approved",
"timestamp": "2024-10-20T12:00:00Z",
"userID": "0x1"
}
Borrowing and Repayment Access:
Once the KYC is approved, users will get their Mystic ID minted as a Soulbound token and be able to access new roles for borrowing and repaying. This verification step ensures that only eligible users may access specific financial instruments.
KYC Data Handling
Security and Privacy: All personal data submitted during the KYC process is handled securely and in compliance with GDPR and other privacy laws. Mystic Finance follows industry best practices to ensure user data is protected.
Custody of Assets
Mystic Finance ensures that user assets are securely stored with a third-party custodian, in compliance with regulatory requirements (i.e. EU financial regulations). This allows the platform to operate legally while maintaining the highest standards of security for user assets.
Custody Overview
Proposed Custodian: Mystic Finance collaborates with a regulated custodian for the safekeeping of assets. This custodian is responsible for ensuring the security of user assets and compliance with applicable regulations. The custodian is chosen based on their adherence to regulatory standards, security protocols, and overall trustworthiness. Users will be proposed such a custodian via the Mystic UI.
Regulatory Compliance: As a financial platform, Mystic Finance complies with EU regulations and other international financial laws regarding the storage and security of user assets. This includes requirements around asset segregation, reporting, and regular audits of the custodian’s security protocols.
Regulatory guidelines:
MiCA (Markets in Crypto-Assets Regulation): Ensures compliance with EU financial regulations for digital assets.
GDPR (General Data Protection Regulation): Ensures that all user data is handled with the highest level of privacy and security.
Asset Security:
The custodian takes care of the safekeeping of assets by using advanced security mechanisms such as multi-signature wallets, cold storage, and encryption to protect user funds from hacking or loss.
Users can rest assured that their assets are protected without needing to take any direct action for the security or custody process.
No User Interaction Required:
The custody process is fully automated and transparent to the end user. Once assets are deposited or borrowed within the protocol, they are automatically transferred to the custodian’s infrastructure, where they are securely held.
There is no manual intervention required from the user in terms of custody management.
Custody Example Flow
After a user deposits assets on the Mystic Finance platform, the assets are transferred to the custodian’s secure storage and can be transferred back to the pool later when needed. Do note, users can still interact with the protocol (e.g. borrowing or repaying), but the assets themselves remain securely held by the custodian.
Custody Benefits
Compliance: The custody model ensures the platform complies with regulations that require assets to be stored securely by a regulated third party.
Security: Multi-layer security protocols are in place to ensure that assets are protected from malicious attacks or internal failures.
No User Responsibility: Users do not need to take any action or worry about managing the custody of their assets. This responsibility is entirely managed by the custodian.
Last updated