Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New-Docs-Created #21

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions docs/learn/mars-v2/borrow.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,19 @@
sidebar_position: 3
---



# Lend & Borrow

Mars Protocol offers a unique lending and borrowing platform that allows you to earn passive income by lending crypto assets or accessing liquidity by borrowing against the collateral. This document provides an overview of the lending and borrowing process on Mars, the benefits associated with each, and important considerations for borrowers.

## How to Lend and Borrow

### Lending

- 1. Connect your wallet: Ensure your supported wallet (e.g., Keplr, Leap, Cosmostation) is connected to the Mars Protocol platform.


## The Red Bank

The Red Bank is a peer-to-peer, decentralized, autonomous token lending/borrowing smart contract deployed to a particular Outpost. Lenders deposit tokens into the Red Bank to earn token rewards (sometimes described as 'yield' or an 'interest rate' or 'APR/APY') that are ultimately funded by token borrowers.
Expand Down
93 changes: 93 additions & 0 deletions docs/learn/tutorials/basics/getting-started.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
---
sidebar_position: 1
---

import connectwallet from '@site/static/img/mars-v2/wallets.png';
import wallettransfer from '@site/static/img/mars-v2/wallet-transfer.png';
import ibctransfer from '@site/static/img/mars-v2/ibc-transfer.png';
import hlsstaking from '@site/static/img/mars-v2/hls-staking.png';

# Getting Started

This guide will walk you through the initial steps of interacting with Mars Protocol. Whether you're a seasoned DeFi user or new to the world of decentralized finance, we've got you covered.

## Setting Up Your Wallet

The first step to interacting with Mars Protocol is setting up a compatible wallet such as Keplr, Leap, and Cosmostation Wallet.
These wallets provide a secure and convenient way to manage your digital assets and interact with decentralized applications.

<img src={connectwallet} style={{ marginBottom: 15 }} />

### Choosing the Right Wallet

Mars Protocol is built on Neutron and Osmosis and Keplr is well-suited for both these chains. However, you must consider factors like security, ease of use, and supported features when selecting a wallet.

### Setting Up Your Wallet

- Follow the step-by-step instructions provided by your chosen wallet provider to create a new account. To set up your Keplr wallet you can follow the steps mentioned here.
- Make sure to back up your seed phrase in a secure location and never share your seed phrase with anyone.

### Connecting Your Wallet to Mars Protocol

- Once your wallet is set up, you'll need to connect it to the Mars dApp.
- Follow the on-screen instructions to establish a connection between your wallet and the Mars Protocol.

## Understanding Networks

Mars Protocol operates on Neutron and Osmosis. Each network has its own unique characteristics, such as speed, fees, and available assets.

### Supported Networks

**Neutron**

Neutron is a layer-1 blockchain designed for interoperability and scalability. It offers high throughput and low transaction fees, making it an efficient platform for DeFi applications. Neutron's focus on interoperability enables seamless asset transfers and interactions with other chains, expanding the possibilities for DeFi innovation.

**Osmosis**

Osmosis is a decentralized exchange (DEX) built on the Cosmos ecosystem. It offers a wide range of trading pairs, high liquidity, and fast transaction speeds. As a core component of the Cosmos ecosystem, Osmosis benefits from interoperability with other chains through IBC, allowing for seamless asset transfers.

### Network Selection

- Choose the network that best suits your needs based on factors like the assets you want to interact with, transaction fees, and network congestion.
- You can usually switch between networks within your wallet settings.

## Funding Your Account

To start using Mars Protocol, you'll need to fund your wallet with supported tokens that you want to lend or trade.

### Depositing Funds into Credit Account

**Buying Supported Cryptocurrencies**

You can purchase supported cryptocurrencies on supported exchanges and transfer them to your wallet address.

**Supported Wallet Transfer**

To get started with Mars it is important to transfer sufficient funds to a supported wallet. If you have bought supported cryptocurrency on a CEX, you can withdraw funds to one such wallet.

<img src={wallettransfer} style={{ marginBottom: 15 }} />

**Bridging from Other Chains**

If you hold assets on other blockchains, you can bridge them to the Mars Protocol ecosystem using compatible bridges or IBC transfer.

<img src={ibctransfer} style={{ marginBottom: 15 }} />

### Depositing Funds into your HLS Account

HLS stands for High Leverage Strategies. It's a feature on Mars Protocol that allows users to leverage their staked assets (like stATOM or stOSMO) to increase their exposure without depositing additional collateral. It's a specialized credit account designed for specific use cases, offering significantly higher leverage than traditional margin accounts.

### Funding Your HLS Account

To fund your HLS account, you'll need to deposit the required asset (e.g., stATOM or stOSMO) into the specific HLS market. Here's a general outline of the steps involved:
- 1. Check HLS Market Availability: Ensure the desired HLS market (stATOM or stOSMO) is active and accepting deposits.
- 2. Transfer Assets: Transfer the required amount of stATOM or stOSMO to your Mars Protocol wallet address.
- 3. Deposit into HLS Market: Navigate to the HLS section on the Mars Protocol platform and select the desired market.
- 4. Approve Transaction: Approve the transaction to deposit your assets into the HLS market.

<img src={hlsstaking} style={{ marginBottom: 15 }} />

## Security Considerations

- Always double-check the recipient's address before sending funds.
- Be aware of potential scams and phishing attempts.
90 changes: 90 additions & 0 deletions docs/learn/tutorials/lending/lending-borrowing.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
---
sidebar_position: 1
---

import walletconnect from '@site/static/img/mars-v2/tutorials/9-lend-assets/wallet.png';
import fundwallet from '@site/static/img/mars-v2/tutorials/9-lend-assets/fundwallet.png';
import Lend from '@site/static/img/mars-v2/tutorials/9-lend-assets/lend.png';
import Manage from '@site/static/img/mars-v2/tutorials/9-lend-assets/manage-lending.png';
import Borrow from '@site/static/img/mars-v2/tutorials/15-borrow/borrow.png';
import BorrowFunds from '@site/static/img/mars-v2/tutorials/15-borrow/borrow-funds.png';
import Approve from '@site/static/img/mars-v2/tutorials/15-borrow/approve.png';


# Lend and Borrow on Mars Protocol

Mars Protocol offers a unique lending and borrowing platform that allows you to earn passive income by lending crypto assets or accessing liquidity by borrowing against the collateral. This document provides an overview of the lending and borrowing process on Mars, the benefits associated with each, and important considerations for borrowers.

## How to Lend and Borrow

### Lending

1. **Connect your wallet:** Ensure your supported wallet (e.g., Keplr, Leap, Cosmostation) is connected to the Mars Protocol platform.

<img src={walletconnect} style={{ marginBottom: 15 }} />


2. **Fund your Credit Account:** When you fund your account, you also get an option to automatically lend.

<img src={fundwallet} style={{ marginBottom: 15 }} />

3. **Navigate to Earn Section and Lend:** You can also navigate to the Earn section and get an option to lend. Choose the specific cryptocurrency you want to lend from the available options (e.g., ATOM, OSMO, USDC).

<img src={Lend} style={{ marginBottom: 15 }} />

4. **Deposit funds:** Transfer the desired amount of cryptocurrency from your wallet to the lending pool. This action will lock your funds in the lending market.

5. **Earn interest:** Once your funds are deposited, you will start earning interest on your lent assets. The interest rate may fluctuate based on market supply and demand.

6. **Manage Asset**: Once you lend your asset, you get an option to manage your funds to lend more or unlend.

<img src={Manage} style={{ marginBottom: 15 }} />

## Borrowing

1. **Connect your wallet:** Ensure your supported wallet is connected to the Mars Protocol platform.

<img src={walletconnect} style={{ marginBottom: 15 }} />

2. **Navigate to the Borrowing module:** Locate the borrowing section within the Mars Protocol interface.

<img src={Borrow} style={{ marginBottom: 15 }} />

3. **Borrow Funds:** Choose the cryptocurrency you want to borrow and specify the amount. The borrowing limit will be displayed based on your collateral value.

<img src={BorrowFunds} style={{ marginBottom: 15 }} />

4. **Confirm and borrow:** Review the loan terms, including interest rates and liquidation risk. Confirm the transaction to proceed with the loan.

<img src={Approve} style={{ marginBottom: 15 }} />

Note: Interest rates for both lending and borrowing can fluctuate based on market conditions and utilization.

## Benefits of Lending and Borrowing

### Benefits of Lending

- **Earn passive income:** Generate returns on idle assets.
- **Support the ecosystem:** Contribute to the liquidity of the platform.
- **Risk mitigation:** Diversify your portfolio.

### Benefits of Borrowing

- **Access liquidity:** Utilize your crypto assets without selling them.
- **Leverage trading opportunities:** Increase your exposure to the market.
- **Flexible financial management:** Optimize your asset allocation.

A unique advantage that Mars offers is that your collateral deposited into the credit account can also be lent and you can earn interest on your collateral which will ultimately help you maximize your returns and reduce the interest rates on your borrowings.

### Cautions While Borrowing

While borrowing can be a powerful tool, it's essential to exercise caution.

- **Health Score:** Maintain a sufficient collateral ratio to avoid liquidation.
- **Liquidation Risk:** Understand the risks associated with borrowing and take appropriate precautions, if you borrow more than what your health score permits, your asset can be liquidated.
- **Interest Rates:** Mars protocol works on a [two-slope interest rate model](https://docs.marsprotocol.io/docs/learn/mars-v2/interest-rates), pioneered by Aave and Compound. Monitor interest rates for both lending and borrowing to optimize your strategy.

Mars Protocol's lending and borrowing platform provides a flexible and efficient way to optimize your crypto assets. It is important to understand the benefits and risks associated with each so that you can make informed decisions to maximize your returns or access liquidity as needed.



120 changes: 120 additions & 0 deletions docs/learn/tutorials/trading/spot-margin-trading.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
---
sidebar_position: 1
---

import MarginTrading from '@site/static/img/mars-v2/margin-trading.png';
import OSMO from '@site/static/img/mars-v2/osmo.png';
import OSMO45 from '@site/static/img/mars-v2/45-osmo.png';
import TradeUSDC from '@site/static/img/mars-v2/trade-usdc.png';
import HealthFactor from '@site/static/img/mars-v2/healthfactor.png';



# Spot and Margin Trading on Mars Protocol

Mars Protocol offers two primary trading modes: Spot and Margin. Understanding the distinction between the two and the innovative features that Mars offers is crucial for optimizing trading strategies and managing risk effectively.

## Spot Trading

Spot trading involves the immediate exchange of one asset for another at the current market price. Essentially, you buy or sell an asset with the funds you already hold in your wallet. There are two types of Spot Trading options available on Mars:

**Spot Simple**

- Focuses on trading volatile assets against stablecoins.
- Offers a simplified trading interface for new users.
- Supports trading pairs like NTRN/USDT, OSMO/USDC.

**Spot Advanced**

- Allows trading of any asset pair directly.
- Provides flexibility for experienced traders.
- Supports trading pairs like NTRN/WETH, ATOM/OSMO.

### Key characteristics

- Immediate execution of trades
- No borrowing or leverage involved
- Suitable for traders who prefer lower risk and a simpler trading experience

### How it works

- Connect your wallet with Mars
- Select the trading pair (e.g., NTRN/USDT)
- Choose a buy or sell order
- Input the desired amount of the asset to buy or sell
- Confirm the order

Note: Mars trading view, by default, is set for Margin trading. If you wish to execute spot trades, you can turn off the Margin trading view.

<img src={MarginTrading} style={{ marginBottom: 15 }} />

## Margin Trading

Margin trading allows traders to amplify their buying power by borrowing funds against their existing assets. It can be applied directly for both Spot Simple and Spot Advanced. All the user needs to do is turn on the "Margin" toggle button. This enables larger positions and potentially higher profits but also comes with increased risk.

### Key characteristics

Use of borrowed funds to increase trading position size.
Leverage magnifies both profits and losses.
Requires a higher level of trading expertise and risk management.

### Example of Margin Trading WBTC

Let's illustrate margin trading with a WBTC example.
Assume you have 1 WBTC worth $30,000. You want to increase your exposure to Bitcoin without investing additional funds. By using a 3x leverage, you can effectively control a position worth $90,000.

### Benefits of Margin Trading

- Amplified returns: Potential for higher profits on successful trades.
- Flexibility: Ability to leverage existing assets to increase trading positions.
- Short selling: Opportunity to profit from declining asset prices.

### Risks of Margin Trading

- **Increased risk of loss:** Leverage magnifies both profits and losses.
- **Liquidation risk:** If your margin level falls below the maintenance margin, your position may be liquidated.
- **Interest charges:** You'll be charged interest on the borrowed funds.

## Credit Account: Health and Liquidations

A [credit](https://docs.marsprotocol.io/docs/learn/mars-v2/credit-accounts) account is a virtual account used for margin trading, lending and borrowing, and the High Leverage Strategies on Mars Protocol. Mars has two types of credit accounts. One is for the general purpose of trading (Spot and Margin), lending, and borrowing and the other one is for High Leverage Strategies (HLS). It is also the fundamental leverage money Lego used by managed vaults (copy trading vaults) and perpetual markets. The credit account allows users to borrow funds against their existing assets (also known as leverage) to increase their trading positions. It also presents another opportunity to use all the deposited collateral in the credit account to open cross-margined perps positions. You can also view your total net worth in a given moment and it is calculated based on the value of the user's collateral and borrowed funds.

For example, if you have a collateral of 10 OSMO in your credit account, you can trade up to 45 OSMO.

<img src={OSMO} style={{ marginBottom: 15 }} />

<img src={OSMO45} style={{ marginBottom: 15 }} />

Besides over-collateralization, you can also do cross-collateralization. For example, if you have deposited OSMO, you can also use USDC to buy any other asset, let’s say ATOM.

<img src={TradeUSDC} style={{ marginBottom: 15 }} />

### How it works:

- Connect your wallet to Mars protocol, preferably Keplr.
- Fund your credit account.
- Start trading.
- You can use deposited assets in your credit account to get leverage on your trade to increase your trading position.
- But you will also need to manage your margin level to avoid liquidation.

A crucial aspect of margin trading is maintaining a sufficient health factor. The credit account is a measure of your account's solvency.

**Health factor is calculated as the ratio of your collateral value as per Liquidation LTV to your borrowed amount.** For instance, if your collateral liquidation value is $100 and $50 worth of borrowed funds, your health factor would be 2.

If your **health factor** falls below a predetermined threshold (generally 1), your position is at risk of liquidation.

This means the platform will automatically sell part or all of your collateral to repay the borrowed funds. To prevent liquidation, it's essential to maintain a healthy health factor by either increasing your collateral or reducing your borrowed funds.

**For example** in the given image, if you've maximized your borrow limit on an OSMO position and the price of OSMO drops significantly, your health factor will decline. If it falls below the liquidation threshold, your OSMO holdings will be automatically sold to repay the borrowed funds.

<img src={HealthFactor} style={{ marginBottom: 15 }} />

To avoid liquidation, it's essential to monitor your margin level closely and adjust your position as needed.

## Looping with One Click

Traditionally, DeFi platforms achieved leveraged exposure through a process known as **"looping."** This involved multiple steps, including depositing collateral, borrowing a stablecoin, swapping it for the desired asset on a different platform, and then repeating the cycle. This method was inefficient due to high gas fees and slippage.

Mars Protocol simplifies this process with its **"looping with one click"** feature. By directly borrowing any asset against your collateral, you can increase your position efficiently. This streamlined approach saves time and reduces the potential for errors. However, maintaining a healthy credit account is crucial to avoid liquidation.

Essentially, Mars Protocol's **margin trading is a more capital-efficient form of looping**. By offering direct borrowing and often higher LTVs, Mars provides a superior user experience as of CEX compared to traditional DeFi methods.
Loading