# Working with Margin Account

Arkis Margin Accounts are smart contracts that hold both your collateral and your borrowed assets. Through the Arkis Portal, you can inspect every detail of your account, perform permitted trades via WalletConnect, and — when you’re ready — close the account to settle your loan and reclaim your collateral.

### 1. Viewing Account Details

<figure><img src="/files/atWRXbNVLzSoy0Ir02SI" alt=""><figcaption><p>Margin Accounts Overview page</p></figcaption></figure>

Once you’ve opened a loan, navigate to the <mark style="color:purple;">**Borrowed**</mark>**&#x20;->&#x20;**<mark style="color:purple;">**Opened**</mark> in the Arkis Portal to see all your Margin Accounts. For each account, ,you’ll see:

* **Account Address:** The onchain Ethereum address of your Margin Account. Click to copy or view on Etherscan.
* [**Risk Factor**](/home/concepts/risk-factor.md)**:** Your current collateral coverage ratio (Stress-Tested Portfolio Value ÷ Borrowed Amount).
  * RF >> 1.0 = healthy
  * RF ≈ Margin Call RF = at margin call level
  * RF < 1.0 = subject to liquidation
* [**Stress-Tested Value**](/home/concepts/stress-tested-value.md)**:** The total value of assets in the Margin Account, adjusted for stress tests, based on the configured stress multipliers for each asset within a specific Liquidity Pool.
* **Total Accrued Interest:** The sum of interest owed to the Liquidity Pool.

### 2. Interacting With Specific Margin Account

<figure><img src="/files/mujjhtDhyhvG1lCSh2wE" alt=""><figcaption><p>Click to Margin Account card to start interacting with specific margin account</p></figcaption></figure>

By clicking on a specific Margin Account, a user is navigated to a dedicated page for interaction with the Margin Account.&#x20;

Within this section a user can:

* Trade through Margin Account.&#x20;
* Close Margin Account (i.e repay the loan).&#x20;

<figure><img src="/files/62P0AfxgpIvCOUCchi5B" alt=""><figcaption><p>Margin Account page</p></figcaption></figure>

#### 2.1 Trading Through Wallet Connect

Your Margin Account functions like a normal wallet—except that all actions are constrained by the **Com**pliance Manager whitelist. To trade:

1. Go to the protocol page you want to interact with (Pendle, for example) and find Wallet Connect in Connect section.

<figure><img src="/files/nyVdPGn6jkK03sce5ixJ" alt=""><figcaption></figcaption></figure>

**2.2 Copy QR Code symbols**

<figure><img src="/files/CDk23o6jo6nzHoggYR85" alt=""><figcaption></figcaption></figure>

**2.3 Connect Margin Account**

Navigate back to the Arkis Portal, click <mark style="color:purple;">**Trade with Wallet Connect**</mark>**,** and **paste the copied symbols into the window,** and click <mark style="color:purple;">**Connect**</mark>&#x20;

<figure><img src="/files/YEJnARUXr64hpmmgqTIF" alt=""><figcaption><p>Connect Margin Account</p></figcaption></figure>

Once you click **Connect**, you will see that the Margin Account was successfully connected to the external dApp.

<figure><img src="/files/b0Uf10eajek74gw7w9ms" alt=""><figcaption></figcaption></figure>

**2.4 Navigate back to the Pendle dApp.**

Once you navigate back to Pendle, you will see that you have connected a wallet with the address of your Margin Account. You can now interact with the protocol on behalf of Margin Account.&#x20;

<figure><img src="/files/PEeisN7qfvWI5OC4COCw" alt=""><figcaption><p>Margin Account is connected with dApp</p></figcaption></figure>

Now you can interact with the dApp as if it were your own wallet. You can view analytics, close positions, enter and exit positions, and swap, unless this action is whitelisted.

**2.5 Initiate a Trade**

Within the Pendle app, choose a market you want to interact with (make sure PT/LP assets are whitelisted in the Liquidity Pool the Margin Account borrowed from) and click **Swap**. &#x20;

<figure><img src="/files/UtSQrVDkVtACD3NrQZJC" alt=""><figcaption><p>Initiate a trade on Pendle</p></figcaption></figure>

#### 2.6 Navigate back to Arkis Platform to initiate a transaction

<figure><img src="/files/rasL26hyKkhoGhpzyZzl" alt=""><figcaption><p>By navigating back to Arkis Platform you will see window pop up</p></figcaption></figure>

Navigate back to the Arkis Platform, and **you will see a transaction pop-up from our wallet that originated the loan**.&#x20;

{% hint style="success" %}
You can now sign a transaction from your wallet on behalf of Margin Account.
{% endhint %}

Once the transaction is signed, you will see that the Swap happened on the Margin Account. You can check the Margin Account state by pasting its address to DeBank or Etherscan.

#### 2.8 Closing Your Margin Account = Repaying the Debt

Below the Trade with Wallet Connect button, you can find <mark style="color:purple;">**"Close Credit Account,"**</mark> which refers to repaying the loan and closing the Margin Account. &#x20;

<figure><img src="/files/fKRR3jZLg56Ihln3zqH4" alt=""><figcaption></figcaption></figure>

{% hint style="warning" %}
To repay the loan (close Margin Account), the Margin Account address must have the borrowed amount of the asset plus accrued interest.&#x20;
{% endhint %}

By clicking <mark style="color:purple;">**"Close Credit Account"**</mark> an Asset Manager is navigated to the page to initiate the process of the Margin Account loan repayment.&#x20;

However, if the Margin Account does not contain enough borrowed asset tokens and accrued interest (also in borrowed asset tokens), the <mark style="color:purple;">**Proceed**</mark> button will be disabled.&#x20;

<figure><img src="/files/wcs7oO3JY5uZvKmeQcit" alt=""><figcaption><p>Proceed is disabled until Margin Account contains enough of Total Debt</p></figcaption></figure>

There are two ways how an Asset Manager can get Debt + Accrued interest to the Margin Account:

1. Direct deposit to the Margin Account address the necessary amount of tokens (48.81413 USDT in this example). - *The Arkis team recommends this option as the fastest and easiest to implement.*&#x20;
2. Sell, exit from available positions on the Margin Account, and swap them to the necessary amount of Total Debt.

{% hint style="success" %}
Once the Margin Account has the necessary amount of borrowed tokens, the Proceed button will become active.&#x20;
{% endhint %}

### 3. What happens when the Margin Account is closed? Is the loan repaid?&#x20;

Once an Asset Manager signs the transaction to close the Margin Account, the protocol does the following:

1. Analyses the amount of borrowed assets (Total Debt + Accrued Interest) to be sent into the liquidity pool. <mark style="color:green;">**Please note that the protocol will only take the total debt plus the interest amount**</mark>. Any surplus will be returned to the wallet of the Asset Manager who originated the loan.&#x20;
2. All other whitelisted assets (tokens, PT, LP positions) within the Margin Account will be transferred back to the Asset Manager's wallet.&#x20;

As you can see, when Margin Account is closed, the protocol takes only what Margin Account owes to the Liquidity Pool, the rest is returned to Asset Manager's wallet.&#x20;

If an Asset Manager wants to liquidate Margin Account portfolio themselves (using other protocols, or some specific techniques) or don't want to exit positions at all to close the loan - they only need to send borrowed amount + interest to the Margin Account address and they will get everything else back to their own wallet once Close Margin Account procedure is successfull. &#x20;


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.arkis.xyz/home/for-borrowers/working-with-margin-account.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
