# Introduction

Shprd is a **blockchain-based** protocol that seamlessly connects **traders** to **investors**.&#x20;

It provides a mechanism for creating **decentralised trading strategies**. These strategies are managed by professional or non-professional traders to profit from the rise or fall of the crypto-currencies traded in the strategy. Any user will be allowed to invest in a vault and benefit from the **trader's skills**.

A trader's goal when creating a strategy is to generate as much **profit** as possible for his investors in order to earn **performance fees**. In addition, if the strategy is successful, new users will invest in the vault, which will generate more volume and push the trader to be even more successful. All this creates a **virtuous circle**.

###


# Whitepaper

{% file src="/files/JUDGgKqv8x2mgwhLNOGl" %}


# Protocol Overview

Shprd protocol is designed to combine **security** with **decentralisation**.

For this purpose, a **role-based** access system has been set up to drastically reduce the risk of malicious actions. Besides, sensitive smart-contracts use proxies, which allow changes to be made in case of discovered vulnerabilities or the addition of new features.&#x20;

Learn more about Shprd's security measures on [Security](/understand-shprd/pause).

### DeFi protocols used by Shprd:

Vault smart contracts rely on two external actors, a **DEX Aggregator API** and **Chainlink price feeds**.&#x20;

1. **Chainlink Price Feeds**: In a vault, each asset is associated with a Chainlink price feed denominated in USD to exactly 8 decimal places. Chainlink price feeds are the fastest, most reliable and most secure way to obtain asset prices in a decentralised manner.
2. **DEX Aggregator and AMM**: The rebalance process is performed via Paraswap which is a swap optimizer like 1inch or 0x. The aim is to swap assets in a decentralised way and at the best prices.

### Factory

The *Factory* enables the creation of vaults and serves as a **registry**.

{% content-ref url="/pages/KP01txS9We0TXmupShSn" %}
[Factory](/technical-reference/core-contracts/factory)
{% endcontent-ref %}

### Vault

**Shprd** protocol is mainly represented by one contract, the vault. Vaults are smart contracts deployed by a **Factory** with a set of parameters defined at creation (assets, fees, security constraints). At creation, the vault creates an **ERC20** which will represent its **shares**.

A vault accepts deposits (e.g. in BUSD) and mints new ERC20 shares, in proportion to the deposit. It accepts withdrawals (in shares of the vault) and charges **fees** (management, performance and exit fees) according to the rates defined at creation.

To continuously value itself, it uses **Chainlink oracles** (e.g. USD-BTC, USD-ETH price feed) to determine the prices of volatile assets (e.g. BTC, ETH). Depending on the development of the volatile asset included in the vault, the **value** of the shares in the vault **increases**.

{% content-ref url="/pages/HxlsgisKuAG9RxIGju1p" %}
[Vault](/technical-reference/core-contracts/vault)
{% endcontent-ref %}

### FeesManager

The FeesManager contract manages **management** and **performance** fees **receivers**.

{% content-ref url="/pages/c3PkNnPP621B4rTOvQC4" %}
[FeesManager](/technical-reference/core-contracts/feesmanager)
{% endcontent-ref %}

### AccessManager

The AccessManager contract manages the **privileges** of protocol users. Indeed, vault creation by the Factory's 'createVault' method is only possible for addresses with the vault creator **role** granted by the AccessManager contract.

{% content-ref url="/pages/jqbcUCvrz4StYr4iWhfy" %}
[AccessManager](/technical-reference/core-contracts/accessmanager)
{% endcontent-ref %}

### KYCToken

The KYCToken contract manages the **KYC** of the protocol users. It may be necessary to be KYC to invest in a vault depending on the configuration chosen by the **trader**.

{% content-ref url="/pages/yFVRzPf33yrMiL5pyzZk" %}
[KYCToken](/technical-reference/core-contracts/kyctoken)
{% endcontent-ref %}


# Vault Rebalancing

There are 2 types of vault in Shprd protocol:

* **Shprd's official vaults**
* **Community's vaults**&#x20;

## Shprd's official vaults

Shprd's official vaults are rebalanced by automated strategies using artificial intelligence. Once a day, the algorithm decides on the vault's asset allocation and rebalances it if necessary. To learn more about the strategies of the vaults, go to the mirror page of each vault:

|       Vault Name      |                                                          Mirror Link                                                         |
| :-------------------: | :--------------------------------------------------------------------------------------------------------------------------: |
|   BTC AI Long Daily   | [View on Mirror ](https://mirror.xyz/0xdA926277C7c4FD1F1A54f4C22EB825f1CE5f1a5a/I_YylbR0H8R3rMYOSdUXh3bwIF1BitFle2jIARIzZnQ) |
|   ETH AI Long Daily   |  [View on Mirror](https://mirror.xyz/0xdA926277C7c4FD1F1A54f4C22EB825f1CE5f1a5a/OhL_nw7yJkdG9dxtwZFgFNlUKWD_-GBqbWzNrBtn3ss) |
| BTC/ETH AI Long Daily | [View on Mirror ](https://mirror.xyz/0xdA926277C7c4FD1F1A54f4C22EB825f1CE5f1a5a/J0MXlEOHbHwfZ2eXNII7Rs4M65qgVqDQHIpKRm3TCE0) |
|   BNB AI Long Daily   |  [View on Mirror](https://mirror.xyz/0xdA926277C7c4FD1F1A54f4C22EB825f1CE5f1a5a/YfS8gm0JqaF4rddqhS38Zc0f8KYxyfRHDF9435vkpjs) |

## Community's vaults

The strategies of the Community vaults can be automated or not, depending on the trader's preferences. For each vault, it is therefore important to consult the vault's mirror page for information on the strategy.


# Security

## UUPS Proxies

In order to be able to **improve** and **secure** the protocol, the following smart-contracts use UUPS Proxy pattern to make them **upgradeable**:&#x20;

* AccessManager
* FeesManager
* KYCToken&#x20;

The UUPS proxy pattern was first documented in EIP-1822. Unlike Transparent pattern, in UUPS the upgrade logic is handled by the implementation contract itself. The UUPS implementation used by Shprd smart-contracts is the OpenZeppelin UUPSUpgradeable interface.

{% embed url="<https://eips.ethereum.org/EIPS/eip-1822>" %}
EIP-1822
{% endembed %}

{% embed url="<https://docs.openzeppelin.com/contracts/4.x/api/proxy#UUPSUpgradeable>" %}
OpenZeppelin UUPSUpgradeable interface
{% endembed %}

## Beacon Proxy

Vault smart-contracts use Beacon proxy pattern to be able to change the logic of **all** the vaults created at once. The beacon proxy pattern was first documented in EIP-1967. The Beacon implementation used by Shprd smart-contracts is the OpenZeppelin UpgradeableBeacon interface.&#x20;

{% embed url="<https://eips.ethereum.org/EIPS/eip-1967>" %}
EIP-1967
{% endembed %}

{% embed url="<https://docs.openzeppelin.com/contracts/4.x/api/proxy#UpgradeableBeacon>" %}
OpenZeppelin UpgradeableBeacon interface
{% endembed %}


# Pause procedure

{% hint style="danger" %}
In case of an **emergency**, some parts of the protocol can be paused by administrator wallet via the *setConfigProps* method of the vault.
{% endhint %}

Here are the functions that will be paused:

* *deposit*&#x20;
* *redeem*
* *rebalance*
* *harvestManagementFees*
* *harvestPerformanceFees*

{% hint style="info" %}
Users will still be able to withdraw their funds through the ***redeemEach*** feature. They will get their investment back in **all the currencies** of the vault and not only in base token since rebalancing will not be allowed to avoid any additional risk.
{% endhint %}


# Emergency Contact

Any vulnerability or bug discovered must be reported to the Team via this Discord bug-report channel : <https://discord.com/channels/938433296130531368/978691571723698226>

{% hint style="danger" %}
For any **critical** vulnerability, please contact **The Herdsman#2566** on Discord.
{% endhint %}


# Protocol Fees

Each vault collects **exit**, **management** and **performance** fees. Exit fees are kept in the vault at redemption. A portion of the management and performance fees is returned to the vault **strategist/beneficiary** in the form of shares (freshly minted). The remainder goes to the DAO represented by the holders and stakers.

Only the **harvester** can collect performance or management fees, it’s a role given by the vault owner. At creation of the vault, the strategist and a global DAO harvester address are granted this role.

### Exit Fees

{% hint style="info" %}
Exit fees are applied to the **redemption** of shares and serve to prevent repeated entries/exits.
{% endhint %}

The variables defining exit fees are specific to each vault and are represented in basis points by exitFees in the FeesProps structure.They can only be changed by the owner, who will always be the DAO of the project, but they are chosen by the strategist at creation.

There is a **minimum** for management and performance fees to be claimed which is given in USD terms in *SecurityProps.minHarvestThreshold*

### Management Fees

Management fees are defined by the variable *managementFeesRate* which indicates the **8-hours** management fees rate (not in basis point, but on 1,000,000). The total value of the vault, multiplied by the number of rounds (8 hours) since the last claim and by the managementFeesRate gives the total management fee. Then this amount is paid under the form of shares to the strategist and to the fee receiver given by the *FeesManager* contract.

The formula to compute the shares to mint for management fees is the following one:

$$
rounds = \frac{block.timestamp - previousManagementFeesHarvestTimestamp}{8 \* 60 \* 60}
$$

$$
toMint = \frac{rounds \* shareTotalSupply \* managementFeesRate}{10^6}
$$

{% hint style="info" %}
The harvesting of management fees leads to a **dilution** of the share price, naturally to the detriment of investors, who indirectly pay fees.
{% endhint %}

### Performance Fees

Performance fees work in a similar way to management fees. A percentage in basis points is given by the variable *performanceFeesRate*. At the time of the claim, the fund share price is compared to the **all time high**, which is given by the variable *highWaterMark*. The formula to compute the share to mint to pay for performance fees is the following one.

$$
perf = sharePrice - hmw
$$

$$
totalPerf = \frac{perf \* shareTotalSupply}{10^8}
$$

$$
feesOnPerf = \frac{totalPerf \* performanceFeesRate}{10^4}
$$

$$
feesToMintInShare = \frac{feesOnPerf\*10^8}{sharePrice}
$$

The ratio given by *performanceFeesToTrader* is sent to the strategist and the rest to the address indicated by the variable feesReceiver in the *FeesManager* contract. If the *highWaterMark* is higher than the share price, then the performance fees are paid and the *highWaterMark* is set to the new share price for future harvests.

Given this implementation, there is an incentive to enter the vault when it has a *highWaterMark* above *sharePrice*. The investor gets a ”free ride” by not paying a performance fee when the fund increases.

{% hint style="info" %}
The harvesting of performance fees leads to a **dilution** of the share price, naturally to the detriment of investors, who indirectly pay fees.
{% endhint %}


# Networks

**BNB Chain** and **Arbitrum** will be the main EVM blockchains used to deploy the protocol. Given the current state of liquidity on this network, only tokens with **sufficient liquidity** and **price feed** will be used. As the protocol is developed in Solidity, it can be deployed on all EVM-compatible blockchains.

The DAO may decide on the further integration of other networks such as Avalanche, Polygon or Starknet.


# Create and manage a vault

Guides to create and manage a vault.

{% content-ref url="/pages/GG6UXtS0KhYsWYqKUz9t" %}
[Create a vault](/guides/create-and-manage-a-vault/create-a-vault)
{% endcontent-ref %}

{% content-ref url="/pages/OhsEGJDAHEdNSvSHpr7b" %}
[Manage a vault](/guides/create-and-manage-a-vault/managing-a-vault)
{% endcontent-ref %}


# Create a vault

Guide to create a vault.

When permission-less mode is enabled by the AccessManager contract, anyone can create a vault. When creating a vault, at least two tokens from the factory's authorised list must be chosen.&#x20;

{% hint style="info" %}
The creator will have the right to **rebalance** the vault and **collect the fees**.
{% endhint %}

## How to create a vault&#x20;

In the vaults section, click on "create your vault".

<figure><img src="https://4042996663-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fp22VZjhas5Bq2OgV9HzX%2Fuploads%2FlrxFsW92y2aVDFNn2Ugt%2FCapture%20d%E2%80%99e%CC%81cran%202022-10-24%20a%CC%80%2010.24.18.png?alt=media&amp;token=9d1e569f-adbb-4242-9b87-fc36a4d2a379" alt=""><figcaption><p>Vaults</p></figcaption></figure>

In the first section, you can choose a **name** for your vault and add a **mirror** page url. Moreover, you also have to choose a **name** and a **symbol** for your **share**. As indicating in the app this two element are immutable. Therefore, you will **not** be able to modify them after their creation.

For the strategist, you have to put the **address** of the wallet which will **manage** the vault.

<figure><img src="https://4042996663-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fp22VZjhas5Bq2OgV9HzX%2Fuploads%2FZMoBWE3mcROphaZAZBKc%2Fstep1.png?alt=media&amp;token=7cc182c2-54f8-42b3-9173-fd70ce26a9e9" alt=""><figcaption><p>Vault creation - General</p></figcaption></figure>

In the second section, you can choose the **assets** that will compose your vault. The **base asset** correspond to the asset that users will have to deposit to the vault whereas the **traded assets** corresponds to the assets will you be able to buy. In this example the BUSD is the base asset and the ETH is the traded assets.

<figure><img src="https://4042996663-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fp22VZjhas5Bq2OgV9HzX%2Fuploads%2FtrgPZ1aWEHvAYduzKllu%2FCapture%20d%E2%80%99e%CC%81cran%202022-10-13%20a%CC%80%2010.32.01.png?alt=media&amp;token=30cd3bc8-3559-472a-be47-c8e22bc6a98c" alt=""><figcaption><p>Vault creation - Assets</p></figcaption></figure>

This third section presents few parameters:

* **Maximum AUM** correspond to the maximum amount a vault can handle. In this example, once the vault reaches 10 000 US dollars, deposits will be disabled.
* **Minimum Deposi**t corresponds to the minium amount a user can deposit to a vault. In this example the user can not deposit any amount lower than $5.
* **Maximum Deposit** corresponds to the maximum amount a user can deposit to a vault. In this example the user can not deposit any amount greater than $100.
* **Minimum Frequency** swap corresponds to the minimum time to wait between two changements of exposition.
* **Maximum Loss Swap** corresponds to the maximum loss acceptable after a swap. Since you are trading on DEXs with large amount, **slippage and price impact** must be taken in consideration. Be sure to understand these concept before trading.

<figure><img src="https://4042996663-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fp22VZjhas5Bq2OgV9HzX%2Fuploads%2FW9WkodQilSI744jnp4jy%2Fstep3.png?alt=media&amp;token=8f3d67cd-2490-4383-baf7-75e85a29e1f2" alt=""><figcaption><p>Vault creation - Security</p></figcaption></figure>

This fourth section is focused on fees.

* **Beneficiary** corresponds to the address that will get fees generated by the vault
* **Exit fees** corresponds to the percentage a user will have to pay for redeeming.
* **Management Fees** corresponds to percentage users pay for using the vault. The value is indicated after 8 hours of managements and annually.
* **Performance Fees** corresponds to the percentage to pay from the performance generated by the vault
* **Management Fees To Strategist** corresponds to the part that will be received by the strategist from all management fees generated. In this example, the strategist will receive 50% from all management fees. The rest will be for the DAO.
* **Performance Fees To Strategist** corresponds to the part that will be received by the strategist from all performance fees generated. In this example, the strategist will receive 50% from all performance fees. The rest will be for the DAO.

After completing all parameters, the last section will resume everything and you will able to create the vault through your wallet.

<figure><img src="https://4042996663-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fp22VZjhas5Bq2OgV9HzX%2Fuploads%2FocGxwk1uwLXYSUiLqT3M%2Fstep4.png?alt=media&amp;token=d6ce5aa8-02ee-42e0-bbde-3ce0a4a1fa31" alt=""><figcaption><p>Vault creation - fees</p></figcaption></figure>


# Manage a vault

Guide to manage a vault.

During the lifetime of the vault smart contract, the trader will be able to send **signals** in the form of a hexadecimal coded transaction (e.g. from Paraswap, 1inch or 0x API) with a uint256\[] ranging from 0 to 10000 (basis points) that indicates the exposure associated with the swap transaction, for the asset traded within the vault.

{% hint style="info" %}
There is a **minimum time interval** between two **rebalances** to prevent a malicious vault strategist from executing too many swaps.
{% endhint %}

{% hint style="warning" %}
If the swap volume is too large and costs too much in terms of **price impact** and **slippage**, the rebalancing transaction will be **reverted**, depending on the max loss swap tolerance.
{% endhint %}

## How to rebalance a vault

As a strategist, you can change the exposure of your vault.

In your vault, you can access to a rebalance section. Here the strategist decided to have his vault at 73% on ETH and 27% on BTCB. The sum of exposition must be 100% in order to rebalance. Once you are satisfied with your strategy, you can click on "next".

<figure><img src="https://4042996663-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fp22VZjhas5Bq2OgV9HzX%2Fuploads%2FL1dbz4I48jHOYlEtJ46A%2FCapture%20d%E2%80%99e%CC%81cran%202022-10-13%20a%CC%80%2014.07.20.png?alt=media&amp;token=6b07fa87-ca31-4d14-af0a-141e61928f62" alt=""><figcaption><p>Rebalance section</p></figcaption></figure>

On the next page a recap is visible. You can see the current exposition of your assets before the rebalancing. Then you can click on rebalance and pay for your transaction on your wallet after having read and accepted the terms and conditions.

{% hint style="warning" %}
Always make sure that you are swapping **more** than **$1** for each swap. Otherwise, your swap will not be taken into account.
{% endhint %}

<figure><img src="https://4042996663-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fp22VZjhas5Bq2OgV9HzX%2Fuploads%2FDskynJDFDk7TrFT0FrUw%2FCapture%20d%E2%80%99e%CC%81cran%202022-10-13%20a%CC%80%2014.07.45.png?alt=media&amp;token=5e1f8409-f3aa-49e2-b206-44eb08ac8fdc" alt=""><figcaption><p>Rebalance confirmation</p></figcaption></figure>


# Investing in a vault

Guides to investing in a vault.

{% content-ref url="/pages/ibTUiHijFf8Lb07f7hxJ" %}
[Choose a vault](/guides/investing-in-a-vault/choose-a-vault)
{% endcontent-ref %}

{% content-ref url="/pages/FDAEKNHI2jvRWNduIQ1m" %}
[Deposit in a vault](/guides/investing-in-a-vault/deposit-in-a-vault)
{% endcontent-ref %}

{% content-ref url="/pages/G0FCiU7CXAS86pnHp2Cf" %}
[Redeem in vault](/guides/investing-in-a-vault/vault-redemptions)
{% endcontent-ref %}


# Choose a vault

Guide to decide which vault to invest in

## How to choose a vault&#x20;

{% hint style="info" %}
Before investing in a vault, **do your own research**.&#x20;
{% endhint %}

On the vaults page you will find the most important information about each vault:

* **Traded Assets:** Names of tokens that can be traded from the base token and current proportions in the vault
* **Performance:** Performance of the trader's strategy
* **TVL:** Total **value** currently locked in the vault
* **Inception:** Date of vault creation

If there is a "*KYCed vault*" label, this means that you must be **KYC** to invest in the vault. Go to the [Authentication](/other-websites/authentication) page to learn more about KYC

<figure><img src="https://4042996663-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fp22VZjhas5Bq2OgV9HzX%2Fuploads%2FkEv3LYvwy7hI82WQJcQG%2FCapture%20d%E2%80%99e%CC%81cran%202022-10-24%20a%CC%80%2009.47.17.png?alt=media&amp;token=11619bd2-ff74-4600-8a84-5e450a267d8a" alt=""><figcaption><p>KYCed Vault label</p></figcaption></figure>

When you click on "see details to deposit" in the vaults homepage, you can see all the information about a vault.&#x20;

<figure><img src="https://4042996663-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fp22VZjhas5Bq2OgV9HzX%2Fuploads%2FOeSTHnlD8v9AS2pi5pf0%2FCapture%20d%E2%80%99e%CC%81cran%202022-10-24%20a%CC%80%2009.46.10.png?alt=media&amp;token=601701dc-b09b-41d3-9a63-23064da3de57" alt=""><figcaption><p>Vaults Homepage</p></figcaption></figure>

### Vault overview

* **Share price** curve over time
* **TVL** curve over time
* **TVL - latest:** Total **value** currently locked in the vault
* **Management fees - yearly:** Percentage of management fee to be paid per year
* **Performance fees - yearly:** Percentage of performance fees to be paid&#x20;
* **High-Water Mark:** Highest peak in value reached in the vault

<figure><img src="https://4042996663-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fp22VZjhas5Bq2OgV9HzX%2Fuploads%2FTkFreCqxZKHVWZSNGmD5%2FCapture%20d%E2%80%99e%CC%81cran%202022-10-24%20a%CC%80%2009.30.56.png?alt=media&amp;token=fa0d94af-0b9a-4b25-8053-aeca2c29d599" alt=""><figcaption><p>Vault Overview </p></figcaption></figure>

Information about the vault:

* **Base asset:** Base token name and current proportion in the vault
* **Traded Assets:** Names of tokens that can be traded from the base token and current proportions in the vault
* **Performance:** Performance of the trader's strategy
* **Smart contract:** Smart contract address of the vault
* **Strategists:** Addresses of traders&#x20;
* **Owners:** Addresses of vault owners&#x20;
* **Inception:** Date of vault creation

<figure><img src="https://4042996663-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fp22VZjhas5Bq2OgV9HzX%2Fuploads%2FlffV93StuixAlu8GYUbm%2FCapture%20d%E2%80%99e%CC%81cran%202022-10-24%20a%CC%80%2009.31.09.png?alt=media&amp;token=35a8032a-3fc8-4653-b265-53bf987d7e79" alt=""><figcaption><p>Vault information</p></figcaption></figure>

Information about the share:

* **Name:** Name of the vault share&#x20;
* **Symbol:** Symbol of the vault share
* **Share price:** Current share price of the vault
* **Share supply:** Current amount of vault shares
* **Smart contract:** Smart contract of the vault share

<figure><img src="https://4042996663-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fp22VZjhas5Bq2OgV9HzX%2Fuploads%2FIlyB22ETXw9IbahdmBSf%2FCapture%20d%E2%80%99e%CC%81cran%202022-10-24%20a%CC%80%2009.31.18.png?alt=media&amp;token=eb45b0a9-9d7d-4d61-87a1-f8788fe51bba" alt=""><figcaption><p>Share information</p></figcaption></figure>

### Vault strategy

As you may have noticed, there is a button "Trader's strategy" with a blue icon below the vault name. Clicking on it will take you to the trader's strategy Mirror page to learn more about the trading strategy used.

<figure><img src="https://4042996663-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fp22VZjhas5Bq2OgV9HzX%2Fuploads%2FbE926sPRZ3LtUfuQrzQ0%2FCapture%20d%E2%80%99e%CC%81cran%202022-10-24%20a%CC%80%2009.47.02.png?alt=media&amp;token=1e07d755-e76c-4774-a7de-185a8e1c8289" alt=""><figcaption><p>Trader's strategy button</p></figcaption></figure>

<figure><img src="https://4042996663-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fp22VZjhas5Bq2OgV9HzX%2Fuploads%2FO0V3GgAWIHWn3wJXCLuq%2FCapture%20d%E2%80%99e%CC%81cran%202022-10-24%20a%CC%80%2009.31.46.png?alt=media&amp;token=c7807e27-2a9f-4b6a-b301-bcdcb1d1ffaf" alt=""><figcaption><p>Trader's strategy Mirror page</p></figcaption></figure>

### Vault assets&#x20;

Information on the proportion of assets in the vault and price developments:

<figure><img src="https://4042996663-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fp22VZjhas5Bq2OgV9HzX%2Fuploads%2Fqq1vo6Cp6fZYDj0ZxeaC%2FCapture%20d%E2%80%99e%CC%81cran%202022-10-24%20a%CC%80%2009.32.02.png?alt=media&amp;token=e27724b1-881d-4943-8dd3-a75e24b8fc32" alt=""><figcaption><p>Vault assets information</p></figcaption></figure>

### Vault fees

Information on vault fees:

* **Exit fees:** Percentage of exit fee to be paid during redemption of shares
* **Beneficiary:** Address of the beneficiary of the protocol fee (trader address)
* **Management fees:** Percentage of management fee to be paid per year
* **Management fees to DAO:** Percentage of management fees paid to the DAO
* **Performance fees:** Percentage of performance fee to be paid
* **Performance fees to DAO:** Percentage of performance fees paid to the DAO
* **Minimum harvest:** Minimum amount of fees to be collected

<figure><img src="https://4042996663-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fp22VZjhas5Bq2OgV9HzX%2Fuploads%2FQgbPStplK9AaGVrICvJy%2FCapture%20d%E2%80%99e%CC%81cran%202022-10-24%20a%CC%80%2009.32.23.png?alt=media&amp;token=edc433e5-3d84-41ad-a6b7-79a2693064f7" alt=""><figcaption><p>Vault fees information</p></figcaption></figure>


# Deposit in a vault

Guide to deposit in a vault.

Any user can deposit in a vault. The user must deposit **base token**, which is the first token of the vault contained in the structure (in Solidity, at vault.tokens(0)). Most of the time it will be dollar pegged stablecoin. For a vault with \[USDC, WBTC, WETH, WMATIC], the deposited token must be USDC.

{% hint style="info" %}
The deposit transaction must not change the vault's current exposure to its underlying assets, so on each deposit the transaction takes as input calldata the associated swaps (generated by the Dex Aggregator API) to exchange the amount deposited.
{% endhint %}

## How to deposit in a vault

On the Vaults page you can decide on which vault you want to deposit. If you want more precision about a vault or deposit, you can click on "see details to deposit".

<figure><img src="https://4042996663-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fp22VZjhas5Bq2OgV9HzX%2Fuploads%2FXvnZt8slfKNwVgNUQ8ac%2FCapture%20d%E2%80%99e%CC%81cran%202022-10-24%20a%CC%80%2009.28.47.png?alt=media&amp;token=828157d1-eba9-4a55-853e-ec0a62506c7e" alt=""><figcaption><p>Vaults</p></figcaption></figure>

Then click on "Deposit"

<figure><img src="https://4042996663-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fp22VZjhas5Bq2OgV9HzX%2Fuploads%2Fb9yvZDfITt68TIY1QaeK%2FCapture%20d%E2%80%99e%CC%81cran%202022-10-24%20a%CC%80%2009.30.56.png?alt=media&amp;token=d35fd1b8-d7ec-4de7-adbb-dd495b3d0411" alt=""><figcaption><p>Vault Overview</p></figcaption></figure>

{% hint style="info" %}
As is usual in DeFi with protocols that use ERC20 contracts, you have to sign **2 transactions** to invest in a vault:

1. **Approval** transaction : Allow the protocol to interact with a quantity of ERC20 tokens that you own.
2. **Deposit** transaction : Execute the deposit transaction.&#x20;
   {% endhint %}

If you click on "Approved" you will see the amount of base token you have already approved and if you click on "Balance" you will see your base token balance.&#x20;

You will also find the essential information on the vault: &#x20;

* **Name :** Name of the vault
* **TVL :** Total value locked in the vault
* **Min deposit :** Minimum deposit amount of basic tokens allowed
* **Max AUM :** Maximum total market value of the vault

You can now enter the amount of base token to **approve** and click on "Approve SHPRD to access your ...". Here, the amount to approve is 6 BUSD.

<figure><img src="https://4042996663-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fp22VZjhas5Bq2OgV9HzX%2Fuploads%2FgwNb5oHAk8mcmXi2GD0p%2FCapture%20d%E2%80%99e%CC%81cran%202022-10-18%20a%CC%80%2017.39.13.png?alt=media&amp;token=b3bf3c66-ed6b-48bb-a91c-1ba61f18b15f" alt=""><figcaption><p>Approve SHPRD to access your BUSD</p></figcaption></figure>

A Metamask pop-pup should now appear. Take the time to check the transaction and sign it.  As you can see below, this transaction allows the vault to interact with 6 BUSD.

{% hint style="info" %}
You will need some **BNB** on the BSC or **ETH** on Arbitrum to pay the **gas fee**.
{% endhint %}

<figure><img src="https://4042996663-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fp22VZjhas5Bq2OgV9HzX%2Fuploads%2F3hthHvtKkA1v7Hh15ett%2FCapture%20d%E2%80%99e%CC%81cran%202022-10-18%20a%CC%80%2017.40.58.png?alt=media&amp;token=73720dd6-6dc1-4ff5-ae09-57de62295139" alt=""><figcaption><p>Metamask - Approval transaction</p></figcaption></figure>

After the end of the approval, you will be able to deposit. Click on "Deposit ...". Here the amount to deposit is 6 BUSD.&#x20;

<figure><img src="https://4042996663-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fp22VZjhas5Bq2OgV9HzX%2Fuploads%2FWIl1UvE9fCG2rssPghlM%2FCapture%20d%E2%80%99e%CC%81cran%202022-10-18%20a%CC%80%2017.41.48.png?alt=media&amp;token=5918abcb-ec84-4b9b-b4f2-8aeb1151010e" alt=""><figcaption><p>Deposit funds in a vault</p></figcaption></figure>

A second pop-up window should appear, sign it to execute the deposit transaction. You are now the owner of some vault shares.

You can see all deposit you have made on this page : <https://beta.shprd.finance/app/wallet>


# Redeem in vault

Guide to redeem in a vault.

**Redemption** is the reverse process of deposit. The user **burns** his shares. If the vault has an exposure to the traded assets (i.e. it is not within 10000,0,...,0 exposures/positions), then swaps are required to redeem the user. These swap transactions are also quoted by the DEX Aggregator API and provided as call data to the function.

{% hint style="info" %}
There is also a function *redeemEach* that can be used to redeem **each assets** in proportion to the vault positions. It might be useful if the DEX Aggregator API is down.
{% endhint %}

## How to redeem

<figure><img src="https://4042996663-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fp22VZjhas5Bq2OgV9HzX%2Fuploads%2F02Z3x0FrTuL5pVwnoHOY%2FApprove-Redeem.png?alt=media&amp;token=7ae3b7ae-b3dc-4a2d-8a40-8a723eef99b0" alt=""><figcaption><p>Redeem window</p></figcaption></figure>

Like for a deposit you have to indicate the amount you want to redeem. Then you have to approve the amount.

<figure><img src="https://4042996663-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fp22VZjhas5Bq2OgV9HzX%2Fuploads%2FRErmt7BlyEmdBTJKeHbg%2FRedeem.png?alt=media&amp;token=e3bb73d0-ed03-45d4-a85b-400eeae3faae" alt=""><figcaption><p>Redeem after approval</p></figcaption></figure>

After the approval you can click on redeem. After the transaction is confirmed by the blockchain you will see your funds in your wallet .

{% hint style="info" %}
In case of an issue with the DEX aggregator, the redeem function may not work anymore. This is why you can use the *redeemEach* function which will allow you to redeem each asset of the vault **separately**.
{% endhint %}


# RPC

All dApps (decentralized applications) need a way to communicate with blockchains. Without a means of communication, dApps won’t be able to access information and make transactions on the blockchain on which they operate. This connection between the blockchain and the dApps is facilitated by what is known as RPC nodes.

{% embed url="<https://moralis.io/ethereum-rpc-nodes-what-they-are-and-why-you-shouldnt-use-them/>" %}

{% content-ref url="/pages/YOQG6q509FPebJIfIbkt" %}
[Change RPC](/guides/rpc/change-rpc)
{% endcontent-ref %}

{% content-ref url="/pages/h6fcSzdDVho04nxAKcVy" %}
[Create your own RPC](/guides/rpc/create-your-own-rpc)
{% endcontent-ref %}


# Change RPC

Guide to modifying the RPC for better performance on the Shprd application.

When launching Shprd, it is recommended to modify the RPC to get the best possible performance.

<figure><img src="https://4042996663-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fp22VZjhas5Bq2OgV9HzX%2Fuploads%2FyUeEQrBz2sJiWaIzLbm3%2FCapture%20d%E2%80%99e%CC%81cran%202022-10-12%20a%CC%80%2010.06.55.png?alt=media&amp;token=bb9ffc5a-dd53-47fa-ab7f-e92e5cdf7d51" alt=""><figcaption><p>Login Page</p></figcaption></figure>

First, click on the button at the top right of the screen. A modal will appear and it will be possible to choose the network and configure the RPC by clicking on the settings icon.

<figure><img src="https://4042996663-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fp22VZjhas5Bq2OgV9HzX%2Fuploads%2FgxzUd2x7LA0xEy1Apb4s%2FCapture%20d%E2%80%99e%CC%81cran%202022-10-12%20a%CC%80%2010.09.32.png?alt=media&amp;token=b5629970-6994-422f-b320-ab4b0887b32a" alt=""><figcaption><p>Networks Modal</p></figcaption></figure>

Get the url of a RPC and enter it in the '*Enter RPC url*' input field and press 'SAVE'. You are now able to connect your Metamask wallet and use your own RPC.&#x20;

{% hint style="info" %}
To get your own RPC API Key follow this tutorial: [Create your own RPC](/guides/rpc/create-your-own-rpc)
{% endhint %}

<figure><img src="https://4042996663-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fp22VZjhas5Bq2OgV9HzX%2Fuploads%2FCYvtMrsv4ojY6Xl5og5z%2FCapture%20d%E2%80%99e%CC%81cran%202022-10-12%20a%CC%80%2010.10.13.png?alt=media&amp;token=216fdfb2-3b2d-45ff-b8d4-7f7f59a4419a" alt=""><figcaption><p>RPC Settings Page</p></figcaption></figure>


# Create your own RPC

Guide to create a private RPC. It is recommended to use private RPCs to get the best experience on the Shprd application.

### Getblock Tutorial

Go to the [Getblock](https://account.getblock.io/sign-in) website and create an account if you don't already have one.

When you are connected, go to "GetBlock Dashboard" page.

![GetBlock Dashboard](https://4042996663-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fp22VZjhas5Bq2OgV9HzX%2Fuploads%2FYOU3N1hJt1PTBgL8F8wt%2FCapture%20d%E2%80%99%C3%A9cran%202022-07-13%20121428.png?alt=media\&token=57ee9581-f9af-48e0-b5c5-1e7074574acd)

You will see your API key in the "Production" section. You will need this to use the custom RPC.&#x20;

To generate a full RPC link, click on Production. You will be taken to a page to create your custom RPC for any network.

![API Key Detail ](https://4042996663-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fp22VZjhas5Bq2OgV9HzX%2Fuploads%2F6BUk5VWlCGREcW1SLgFl%2FCapture%20d%E2%80%99%C3%A9cran%202022-07-13%20121923.png?alt=media\&token=66b13a3c-5cbc-4ca6-9319-472c50edf0cb)

On this page, click on "Generate endpoint".&#x20;

![Generate Endpoint ](https://4042996663-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fp22VZjhas5Bq2OgV9HzX%2Fuploads%2Fj1O2ziZ2AS2B7CberWzk%2FCapture%20d%E2%80%99%C3%A9cran%202022-07-13%20122036.png?alt=media\&token=acd91c18-9214-4c8f-9597-b0768c992696)

Select the blockchain you want to use, JSON-RPC, Mainnet and click on create. You will get a link with this format (API\_KEY being your own API key):&#x20;

{% embed url="<https://bsc.getblock.io/mainnet/?api_key=API_KEY>" %}

.


# Cold Wallet

Thanks to **Metamask**, it is possible to access Shprd Finance services with your **cold wallet** (Ledger, Trezor or Lattice).

### Step 1: Connect your cold wallet to your computer and select the right network. Then open Metamask extension and go to the "My accounts" section.

<figure><img src="https://4042996663-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fp22VZjhas5Bq2OgV9HzX%2Fuploads%2Fv3zAwgDZWxxTd16Ahp05%2FCapture%20d%E2%80%99e%CC%81cran%202022-11-29%20a%CC%80%2013.52.39.png?alt=media&amp;token=5da68348-45ee-4120-898f-052c5ebc2de1" alt=""><figcaption><p>Metamask Extension</p></figcaption></figure>

### Step 2: Click on "Connect hardware wallet"

<figure><img src="https://4042996663-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fp22VZjhas5Bq2OgV9HzX%2Fuploads%2FNmDElN4eTnqt78aulmfN%2FCapture%20d%E2%80%99e%CC%81cran%202022-11-29%20a%CC%80%2013.52.54.png?alt=media&amp;token=5c7ac29a-0e9f-48d3-a5e8-eb11a1251e8e" alt=""><figcaption><p>Metamask Extension - My accounts</p></figcaption></figure>

### Step 3: Select the brand of your cold wallet and click on "Continue"

<figure><img src="https://4042996663-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fp22VZjhas5Bq2OgV9HzX%2Fuploads%2FTRyoZGmSJU608KD9XuS4%2FCapture%20d%E2%80%99e%CC%81cran%202022-11-29%20a%CC%80%2013.53.00.png?alt=media&amp;token=daa903cf-69a2-479b-95ed-8c58f1bf5248" alt=""><figcaption><p>Metamask Extension - Connect a hardware wallet</p></figcaption></figure>

### Step 4: Allow Metamask access to the cold wallet

<figure><img src="https://4042996663-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fp22VZjhas5Bq2OgV9HzX%2Fuploads%2Ff0rcoAqVqunXUXGnQdpE%2FCapture%20d%E2%80%99e%CC%81cran%202022-11-29%20a%CC%80%2013.53.08.png?alt=media&amp;token=769f2964-878f-49b5-9254-c1829fa3a4ac" alt=""><figcaption><p>Metamask Extension - Authorising access to the cold wallet</p></figcaption></figure>

### Step 5: Select the account you wish to use and click on "Unlock"

<figure><img src="https://4042996663-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fp22VZjhas5Bq2OgV9HzX%2Fuploads%2FPruZcEiRu3jgkglBfb0I%2FCapture%20d%E2%80%99e%CC%81cran%202022-11-29%20a%CC%80%2014.11.34.png?alt=media&amp;token=b3ff4c6c-d3bd-4e13-9a48-e511caf27b86" alt=""><figcaption><p>Metamask Extension - Select accounts</p></figcaption></figure>

### Step 6: Go to a Shprd Finance login page and select "MetaMask"

<figure><img src="https://4042996663-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fp22VZjhas5Bq2OgV9HzX%2Fuploads%2Fs6l8d0Li2AQVBRinEk0h%2FCapture%20d%E2%80%99e%CC%81cran%202022-11-29%20a%CC%80%2013.51.41.png?alt=media&amp;token=9d3a2d40-f7c0-47a5-ba05-5a5f6aa23ce3" alt=""><figcaption><p>Shprd KYC Login Page</p></figcaption></figure>

### Step 7: A window will open, click on "Sign"

<figure><img src="https://4042996663-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fp22VZjhas5Bq2OgV9HzX%2Fuploads%2FVUWWDHn8ADynTWY6ibug%2FCapture%20d%E2%80%99e%CC%81cran%202022-11-29%20a%CC%80%2013.53.54.png?alt=media&amp;token=5aaf2167-00d4-4a61-afa4-1a4d510121d8" alt=""><figcaption><p>Metamask Extension - Signature request</p></figcaption></figure>

### Step 8: Take your cold wallet, check and sign the message

<figure><img src="https://4042996663-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fp22VZjhas5Bq2OgV9HzX%2Fuploads%2FJ9o95FyHG1oe6KQFf3SV%2FIMG_7734.jpeg?alt=media&amp;token=9fa5b7de-89fa-4027-aafd-ebceff81dcbb" alt=""><figcaption><p>Cold Wallet - Sign message</p></figcaption></figure>

### Step 9: You are now connected, enjoy!&#x20;

To start the KYC procedure, click on "Start verification".

<figure><img src="https://4042996663-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fp22VZjhas5Bq2OgV9HzX%2Fuploads%2FTjtKQC3sWP2ZXlVOoMcI%2FCapture%20d%E2%80%99e%CC%81cran%202022-11-29%20a%CC%80%2013.55.24.png?alt=media&amp;token=4053f5cb-4b31-4570-a88b-57b0a3f9a770" alt=""><figcaption><p>Shprd KYC Home</p></figcaption></figure>


# Core Contracts

{% content-ref url="/pages/tUlQPEmFjFc5tVlamHk3" %}
[VLib](/technical-reference/core-contracts/vlib)
{% endcontent-ref %}

{% content-ref url="/pages/KP01txS9We0TXmupShSn" %}
[Factory](/technical-reference/core-contracts/factory)
{% endcontent-ref %}

{% content-ref url="/pages/HxlsgisKuAG9RxIGju1p" %}
[Vault](/technical-reference/core-contracts/vault)
{% endcontent-ref %}

{% content-ref url="/pages/c3PkNnPP621B4rTOvQC4" %}
[FeesManager](/technical-reference/core-contracts/feesmanager)
{% endcontent-ref %}

{% content-ref url="/pages/jqbcUCvrz4StYr4iWhfy" %}
[AccessManager](/technical-reference/core-contracts/accessmanager)
{% endcontent-ref %}

{% content-ref url="/pages/yFVRzPf33yrMiL5pyzZk" %}
[KYCToken](/technical-reference/core-contracts/kyctoken)
{% endcontent-ref %}


# VLib

Library which defined the main data structured used by the protocol.

## Data Structures

### CreationProps

```solidity
struct CreationProps {
    string vaultName;
    string description;
    string shareName;
    string shareSymbol;
    address strategist; 
}
```

| Name          | Type    | Description               |
| ------------- | ------- | ------------------------- |
| `vaultName`   | string  | name of the vault         |
| `description` | string  | description of the vault  |
| `shareName`   | string  | name of vault's share     |
| `shareSymbol` | string  | symbol of the share       |
| `strategist`  | address | address of the strategist |

### Token

```solidity
struct Token {
    address tokenAddress;
    address priceFeedAddress;
    uint8 priceFeedPrecision;
    uint256 denominator;
}
```

| Name                 | Type    | Description                                                   |
| -------------------- | ------- | ------------------------------------------------------------- |
| `tokenAddress`       | address | address of a token                                            |
| `priceFeedAddress`   | address | address of the token's oracle                                 |
| `priceFeedPrecision` | uint8   | decimal of the response from the price feed. Usually $$10^8$$ |
| `denominator`        | uint256 | decimal of the token                                          |

## UserProps

```solidity
mapping(address => uint256) lastEntries;
```

## ConstantProps

```solidity
struct ConstantProps {
    address factory;
    uint256 createdAt; 
    address share;
}
```

| Name        | Type    | Description                       |
| ----------- | ------- | --------------------------------- |
| `factory`   | address | factory's address                 |
| `createdAt` | uint256 | block timestamp at vault creation |
| `share`     | address | address of vault's share          |

## HistoryProps

```solidity
struct HistoryProps {
    uint256 highWaterMark; 
    uint256[] prevRebalanceSignals; 
    uint256 prevSwap; 
    uint256 prevMngHarvest; 
}
```

| Name                   | Type       | Description                                            |
| ---------------------- | ---------- | ------------------------------------------------------ |
| `highWaterMark`        | uint256    | highest price peak of Vault share                      |
| `prevRebalanceSignals` | uint256\[] | last signal send by the strategist                     |
| `prevSwap`             | uint256    | last timestamp at which the Vault was rebalanced       |
| `prevMngHarvest`       | uint256    | last timestamp at which management fees were collected |

## FeesProps

```solidity
struct FeesProps {
    address beneficiary;
    uint256 exitFees; 
    uint256 managementFeesRate; 
    uint256 managementFeesToStrategist; 
    uint256 performanceFeesRate; 
    uint256 performanceFeesToStrategist; 
}
```

| Name                          | Type    | Description                                                |
| ----------------------------- | ------- | ---------------------------------------------------------- |
| `beneficiary`                 | address | strategist address                                         |
| `exitFees`                    | uint256 | fees in Basis Point : \[0, 10000]                          |
| `managementFeesRate`          | uint256 | from 0 to 1 000 000                                        |
| `managementFeesToStrategist`  | uint256 | fees to strategist in basis point - \[0, 5000]             |
| `performanceFeesRate`         | uint256 | performance fees rate in basis point - \[0, 7500]          |
| `performanceFeesToStrategist` | uint256 | performance fees to strategist in basis point - \[0, 5000] |

## ConfigProps

```solidity
struct ConfigProps {
    bool paused;
    uint8 verified;
    string name;
    string description;
}
```

| Name          | Type   | Description                        |
| ------------- | ------ | ---------------------------------- |
| `paused`      | bool   | indicates if the vault is paused   |
| `verified`    | uint8  | indicates if the vault is verified |
| `name`        | string | name of the vault                  |
| `description` | string | description of the vault           |

## SecurityProps

```solidity
struct SecurityProps {
    uint256 maxAUM; 
    uint256 maxLossSwap; 
    uint256 minAmountDeposit; 
    uint256 maxAmountDeposit; 
    uint256 minFrequencySwap; 
    uint256 minSecurityTime; 
    uint256 minHarvestThreshold; 
}
```

| Name                  | Type    | Description                                                          |
| --------------------- | ------- | -------------------------------------------------------------------- |
| `maxAUM`              | uint256 | maximum amount the vault can handle                                  |
| `maxLossSwap`         | uint256 | price Impact and Slippage                                            |
| `minAmountDeposit`    | uint256 | minimum amount a user can deposit to the vault                       |
| `maxAmountDeposit`    | uint256 | maximum amount a user can deposit to the vault                       |
| `minFrequencySwap`    | uint256 | minimum period during which the operator can not rebalance the vault |
| `minSecurityTime`     | uint256 | minimum time between two deposit/redeem                              |
| `minHarvestThreshold` | uint256 | minimum worth of share to mint from harvesting fees                  |


# Factory

Factory contract is the main contract of the protocol. It is used to create vault proxies and serves as registry.

## View Methods

### countVault

```solidity
function countVault() external view returns (uint256)
```

Returns the number of vaults from the factory.

**Return Value:**

| Type    | Description      |
| ------- | ---------------- |
| uint256 | number of vaults |

### getWhitelistedTokens

```solidity
function getWhitelistedTokens() external view returns (address[] memory)
```

Returns a list of all whitelisted token addresses.

**Return Value:**

| Type       | Description                     |
| ---------- | ------------------------------- |
| address\[] | addresses of whitelisted tokens |

### getFeesReceiver

```solidity
function getFeesReceiver(uint256 _feeType) external view returns (address)
```

Returns the address of the fees receiver.

**Call Parameters:**

| Name       | Type    | Description                                       |
| ---------- | ------- | ------------------------------------------------- |
| `_feeType` | uint256 | <p>0 corresponds to<br>managementFeesReceiver</p> |

**Return Value:**

| Type    | Description                             |
| ------- | --------------------------------------- |
| address | address of the fees receivercreateVault |

### isTokenWhitelisted

```solidity
function isTokenWhitelisted(address _token) public view returns (bool)
```

Checks if a token is whitelisted.

**Call Parameters:**

| Name      | Type    | Description              |
| --------- | ------- | ------------------------ |
| `_tokens` | address | token's address to check |

**Return Value:**

| Type | Description                                               |
| ---- | --------------------------------------------------------- |
| bool | returns `true` if the address of the token is whitelisted |

### getFactoryState

```solidity
function getFactoryState()
    external
    view
    returns (
        address[] memory,
        address,
        address,
        address,
        address,
        address
    )
```

Returns all parameters from the factory.

**Return Values:**

| Type       | Description                   |
| ---------- | ----------------------------- |
| address\[] | addresses of the vaults       |
| address    | address of the fees manager   |
| address    | address of the access manager |
| address    | address of the harvester      |
| address    | address of the proxy          |
| address    | address of the router         |

### getVaultState

```solidity
function getVaultState(address _vault)
    external
    view
    returns (
        VLib.Token[] memory vTokens,
        VLib.ConstantProps memory constantProps,
        VLib.HistoryProps memory historyProps,
        VLib.ConfigProps memory configProps,
        VLib.FeesProps memory feesProps,
        VLib.SecurityProps memory securityProps,
        uint256[] memory balances,
        uint256[] memory positions,
        uint256 vvl,
        uint256 sharePrice,
        uint256[2] memory ongoingFees
    )
```

Returns the parameters of a vault.

**Call Parameters:**

| Name     | Type    | Description          |
| -------- | ------- | -------------------- |
| `_vault` | address | address of the vault |

**Return Values:**

| Name            | Type               | Description                                          |
| --------------- | ------------------ | ---------------------------------------------------- |
| `vTokens`       | VLib.Token\[]      | list of the tokens managed by the vault              |
| `constantProps` | VLib.constantProps | constant parameters from the vault                   |
| `historyProps`  | VLib.HistoryProps  | previous parameters                                  |
| `configProps`   | VLib.ConfigProps   | main configuration parameters from the vault         |
| `feesProps`     | VLib.FeesProps     | fees parameter from the vault                        |
| `securityProps` | VLib.securityProps | security parameter from the vault                    |
| `balances`      | uint256            | amount of each assets in the vault                   |
| `positions`     | uint256            | positions from the vaults                            |
| `vvl`           | uint256            | vault's TVL                                          |
| `sharePrice`    | uint256            | share price                                          |
| `ongoingFees`   | uint256\[2]        | amount of management and performance fees to harvest |

### getVaultOngoingFees

<pre class="language-solidity"><code class="lang-solidity"><strong>function getVaultOngoingFees(address _vault) 
</strong><strong>    external 
</strong><strong>    view 
</strong><strong>    returns (
</strong><strong>        uint256 ongoingManagementFees, 
</strong><strong>        uint256 ongoingPerformanceFees
</strong><strong>    )
</strong></code></pre>

Returns the amount of fees to harvest according to a vault address.

**Call Parameters:**

| Name     | Type    | Description          |
| -------- | ------- | -------------------- |
| `_vault` | address | address of the vault |

**Return Values:**

| Name                     | Type    | Description                           |
| ------------------------ | ------- | ------------------------------------- |
| `ongoingManagementFees`  | uint256 | amount of management fees to harvest  |
| `ongoingPerformanceFees` | uint256 | amount of performance fees to harvest |

### getShareState

```solidity
function getShareState(address _vault)
    external
    view
    returns (
        address share,
        string memory name,
        string memory symbol,
        uint8 decimals,
        uint256 supply,
        bool transferable
    )
```

Returns the share parameters from a vault according to its address.

**Call Parameters:**

| Name     | Type    | Description          |
| -------- | ------- | -------------------- |
| `_vault` | address | address of the vault |

**Return Values:**

| Name           | Type    | Description                   |
| -------------- | ------- | ----------------------------- |
| `share`        | address | address of vault's share      |
| `name`         | string  | name of the vault's share     |
| `symbol`       | string  | symbol of vault's share       |
| `decimals`     | uint8   | vault's share decimals        |
| `supply`       | uint256 | vault's share supply          |
| `transferable` | bool    | vault's share transferability |

### getUserShareState

```solidity
function getUserShareState(address _vault, address _user)
    external
    view
    returns (
        address share,
        uint256 balance,
        uint256 allowanceToVault
    )
```

Returns user's share information according to the vault's address and the user address.

**Call Parameters:**

| Name     | Type    | Description          |
| -------- | ------- | -------------------- |
| `_vault` | address | address of the vault |
| `_user`  | address | address of the user  |

**Return Values:**

| Name               | Type    | Description                              |
| ------------------ | ------- | ---------------------------------------- |
| `share`            | address | address of vault's share                 |
| `balance`          | uint256 | amount of share in user's wallet         |
| `allowanceToVault` | uint256 | allowance between the user and the vault |

### getRolesPerVault

```solidity
function getRolesPerVault(address _vault)
    external
    view
    returns (
        bytes32[3] memory,
        address[] memory,
        address[] memory,
        address[] memory
    )
```

Returns the roles names and the addresses of the admins, strategists and harvesters according to a vault address.

**Call Parameters:**

| Name     | Type    | Description          |
| -------- | ------- | -------------------- |
| `_vault` | address | address of the vault |

**Return Values:**

| Type        | Description                   |
| ----------- | ----------------------------- |
| bytes32\[3] | list of roles names           |
| address\[]  | list of admins addresses      |
| address\[]  | list of strategists addresses |
| address\[]  | list of harvesters addresses  |

## Write Methods

### createVault

```solidity
function createVault(
    address[] calldata _tokensAddresses,
    VLib.CreationProps calldata _creationProps,
    VLib.FeesProps calldata _feesProps,
    VLib.SecurityProps calldata _securityProps
) external
```

Creates a vault with the parameters requested.

{% hint style="info" %}
This method can only be called by address with **VAULT\_CREATOR\_ROLE**.
{% endhint %}

**Call Parameters:**

| Name               | Type               | Description            |
| ------------------ | ------------------ | ---------------------- |
| `_tokensAddresses` | address\[]         | all manageable assets  |
| `_creationProps`   | VLib.CreationProps | main vault information |
| `_feesProps`       | VLib.FeesProps     | fees parameters        |
| `_securityProps`   | VLib.SecurityProps | security parameters    |

### setAccessManager

```solidity
function setAccessManager(address _newAccesslolManager) external
```

Settles the new AccessManager.&#x20;

{% hint style="info" %}
This method can only be called by the contract **owner**.
{% endhint %}

**Call Parameters:**

| Name                | Type    | Description                      |
| ------------------- | ------- | -------------------------------- |
| `_newAccessManager` | address | address of the new AccessManager |

### setFeesManager

```solidity
function setFeesManager(address _newFeesManager) external
```

Settles the new FeesManager.&#x20;

{% hint style="info" %}
This method can only be called by the contract **owner**.
{% endhint %}

**Call Parameters:**

| Name              | Type    | Description                    |
| ----------------- | ------- | ------------------------------ |
| `_newFeesManager` | address | address of the new FeesManager |

### setHarvester

```solidity
function setHarvester(address _newHarvester) external
```

Settles the new Harvester.&#x20;

{% hint style="info" %}
This method can only be called by the contract **owner**.
{% endhint %}

**Call Parameters:**

| Name            | Type    | Description                  |
| --------------- | ------- | ---------------------------- |
| `_newHarvester` | address | address of the new Harvester |

### setSwapContracts

```solidity
function setSwapContracts(address _newSwapRouter, address _newSwapProxy) external
```

Settles the new aggregator proxy and router.&#x20;

{% hint style="info" %}
This method can only be called by the contract **owner**.
{% endhint %}

**Call Parameters:**

| Name             | Type    | Description               |
| ---------------- | ------- | ------------------------- |
| `_newSwapRouter` | address | address of the new router |
| `_newSwapProxy`  | address | address of the new proxy  |

### setSwapAdapter

<pre class="language-solidity"><code class="lang-solidity"><strong>function setSwapAdapter(address _newSwapAdapter) external
</strong></code></pre>

Settles the new swap adapter.&#x20;

{% hint style="info" %}
This method can only be called by the contract **owner**.
{% endhint %}

**Call Parameters:**

| Name              | Type    | Description                     |
| ----------------- | ------- | ------------------------------- |
| `_newSwapAdapter` | address | address of the new swap adapter |

### addTokenAndPriceFeedsToWL

```solidity
function addTokensAndPriceFeedsToWL(
    address[] calldata _tokens, 
    address[] calldata _priceFeeds
) external
```

Whitelists a tokens and their oracles for vaults.&#x20;

{% hint style="info" %}
This method can only be called by the contract **owner**.
{% endhint %}

**Call Parameters:**

| Name          | Type       | Description                                |
| ------------- | ---------- | ------------------------------------------ |
| `_token`      | address\[] | list of tokens addresses to whitelist      |
| `_priceFeeds` | address\[] | list token's oracle addresses to whitelist |

### removeTokensFromWhitelist

```solidity
function removeTokensFromWhitelist(address[] calldata _tokens) external
```

Removes tokens and their oracles from the whitelist.&#x20;

{% hint style="info" %}
This method can only be called by the contract **owner**.
{% endhint %}

**Parameters:**

| Name      | Type       | Description                        |
| --------- | ---------- | ---------------------------------- |
| `_tokens` | address\[] | list of tokens addresses to remove |

###


# Vault

Vault contract is used to protect funds and perform swaps.

## Types

### ActionType

```solidity
enum ActionType {
    DEPOSIT,
    REBALANCE,
    REDEEM
}
```

### SwapDataExecution

<pre class="language-solidity"><code class="lang-solidity">struct SwapDataExecution {
<strong>    ActionType action;
</strong>    bytes[] swapTxs;
    uint256[] tokenBalancesBefore;
    uint256[] currentPositions;
    uint256 shareOrBaseTokenAmount;
    uint256 totalShareSupply;
}
</code></pre>

| Name                     | Type       | Description                                  |
| ------------------------ | ---------- | -------------------------------------------- |
| `swapTxs`                | bytes\[]   | swap data transaction                        |
| `tokenBalancesBefore`    | uint256\[] | list of vault asset balances before the swap |
| `currentPositions`       | uint256\[] | list of vault positions                      |
| `shareOrBaseTokenAmount` | uint256    | share or base token amount swapped           |
| `totalShareSupply`       | uint256    | total supply of shares                       |

## View Methods

### getConstantProps

```solidity
function getConstantProps() external view virtual returns (VLib.ConstantProps memory)
```

Returns the Constant properties of the vault.

Refer to the [VLib](/technical-reference/core-contracts/vlib)'s data structure for more information

### getHistoryProps

```solidity
function getHistoryProps() external view virtual returns (VLib.HistoryProps memory)
```

Returns the History properties of the vault.

Refer to the [VLib](/technical-reference/core-contracts/vlib)'s data structure for more information

### getConfigProps

```solidity
function getConfigProps() external view virtual returns (VLib.ConfigProps memory) 
```

Returns the Config properties of the vault.

Refer to the [VLib](/technical-reference/core-contracts/vlib)'s data structure for more information

### getFeesProps

```solidity
function getFeesProps() external view virtual returns (VLib.FeesProps memory)
```

Returns the Fees properties of the vault.

Refer to the [VLib](/technical-reference/core-contracts/vlib)'s data structure for more information

### getSecurityProps

```solidity
function getSecurityProps() external view virtual returns (VLib.SecurityProps memory)
```

Returns the Security properties of the vault.

Refer to the [VLib](/technical-reference/core-contracts/vlib)'s data structure for more information

### tokensLength

```solidity
function tokensLength() public view virtual returns (uint256)
```

Returns the number of different tokens in the vault.

**Return Value:**

| Type    | Description                             |
| ------- | --------------------------------------- |
| uint256 | number of different assets in the vault |

### getLatestPrice

```solidity
function getLatestPrice(address _priceFeed) public view virtual returns (uint256) 
```

Returns the last price of a chainlink price feed.

**Call Parameters:**

| Name         | Type    | Description               |
| ------------ | ------- | ------------------------- |
| `_priceFeed` | address | address of the price feed |

**Return Value:**

| Type    | Description                  |
| ------- | ---------------------------- |
| uint256 | last price of the price feed |

### getVaultBalances

```solidity
function getVaultBalances() public view virtual returns (uint256[] memory balances)
```

Returns the balances of each assets of the vault.

**Return Value:**

| Name       | Type       | Description              |
| ---------- | ---------- | ------------------------ |
| `balances` | uint256\[] | balances of vault assets |

### getVaultStatus

<pre class="language-solidity"><code class="lang-solidity"><strong>function getVaultStatus()
</strong>    public
    view
    returns (
        uint256[] memory positions,
        uint256 vvl,
        uint256 sharePrice
    )
</code></pre>

Returns the status of the vault.

**Return Values:**

| Name         | Type       | Description                 |
| ------------ | ---------- | --------------------------- |
| `positions`  | uint256\[] | vault's position            |
| `vvl`        | uint256    | vault's valorization in USD |
| `sharePrice` | uint256    | price of one vault's share  |

### getManagementFees

```solidity
function getManagementFees() public view returns (uint256 toMint, uint256 sharePrice)
```

Returns the amount of management fees to harvest.

**Return Values:**

| Name         | Type    | Description              |
| ------------ | ------- | ------------------------ |
| `toMint`     | uint256 | amount of shares to mint |
| `sharePrice` | uint256 | share price              |

### getPerformanceFees

```solidity
function getPerformanceFees()
```

Returns the amount of performance fees to harvest.

**Return Values:**

| Name         | Type    | Description              |
| ------------ | ------- | ------------------------ |
| `toMint`     | uint256 | amount of shares to mint |
| `sharePrice` | uint256 | share price              |

## Write Methods

### deposit

```solidity
function deposit(uint256 _baseTokenAmountIn, bytes[] calldata _swapTxs) external
```

Deposits an amount of base token in the vault.

**Call Parameters:**

| Name                 | Type     | Description                                   |
| -------------------- | -------- | --------------------------------------------- |
| `_baseTokenAmountIn` | uint256  | amount to deposit                             |
| `_swapTxs`           | bytes\[] | payload to interact with paraswap's contracts |

### redeem

```solidity
function redeem(uint256 _amountIn, bytes[] calldata _swapTxs) external
```

Redeems an amount from the vault and receive in the same currency as deposit.

**Call Parameters:**

| Name        | Type     | Description                                   |
| ----------- | -------- | --------------------------------------------- |
| `_amountIn` | uint256  | amount to redeem                              |
| `_swapTxs`  | bytes\[] | payload to interact with paraswap's contracts |

### redeemEach

```solidity
function redeemEach(uint256 _amountIn) external
```

Redeems each parts of the assets in proportion to the shares burned.

**Call Parameters:**

| Name        | Type    | Description             |
| ----------- | ------- | ----------------------- |
| `_amountIn` | uint256 | shares amount to redeem |

### redeemForced

```solidity
function redeemForced(address _user, uint256 _amountIn) external
```

Redeems each parts of the assets in proportion to the shares burned to a user.&#x20;

{% hint style="info" %}
This method can only be called by address with **DEFAULT\_ADMIN\_ROLE**.
{% endhint %}

**Call Parameters:**

| Name        | Type    | Description             |
| ----------- | ------- | ----------------------- |
| `_user`     | address | address of the user     |
| `_amountIn` | uint256 | shares amount to redeem |

### rebalance

```solidity
function rebalance(uint256[] memory _signals, bytes[] calldata _swapTxs) external
```

Rebalances the vault.

{% hint style="info" %}
This method can only be called by address with **STRATEGIST\_ROLE**.
{% endhint %}

**Call Parameters:**

|            | Type     | Description                                                 |
| ---------- | -------- | ----------------------------------------------------------- |
| `_signals` | uint256  | <p>vault in \[BTC ETH]<br>signal in bps : \[3000, 7000]</p> |
| `_swapTxs` | bytes\[] | payload to interact with paraswap's contracts               |

### harvestManagementFees

```solidity
function harvestManagementFees() external
```

Mints share in proportion of management fees, based on current fees ratio and last withdraw timestamp.&#x20;

{% hint style="info" %}
This method can only be called by address with **STRATEGIST\_ROLE**.
{% endhint %}

### harvestPerformanceFees

```solidity
function harvestPerformanceFees() external
```

Mints share in proportion of performance fees, based on current fees ratio and last withdraw timestamp.&#x20;

{% hint style="info" %}
This method can only be called by address with **STRATEGIST\_ROLE**.
{% endhint %}

### approveForSwap

<pre class="language-solidity"><code class="lang-solidity"><strong>function approveForSwap(uint256[] memory _amounts) public
</strong></code></pre>

Modifies approvals for assets managed by the vault.&#x20;

{% hint style="info" %}
This method can only be called by address with **DEFAULT\_ADMIN\_ROLE**.
{% endhint %}

**Call Parameters:**

| Name       | Type       | Description        |
| ---------- | ---------- | ------------------ |
| `_amounts` | uint256\[] | amounts to approve |

### addVaultAsset

```solidity
function addVaultAsset(address _token) external
```

Adds a new asset to the vault.&#x20;

{% hint style="info" %}
This method can only be called by address with **STRATEGIST\_ROLE**.
{% endhint %}

**Call Parameters:**

| Name     | Type    | Description                 |
| -------- | ------- | --------------------------- |
| `_token` | address | address of the token to add |

### setShareTransferability

```solidity
function setShareTransferability(bool _status) external
```

Settles the new share transferability status.&#x20;

{% hint style="info" %}
This method can only be called by address with **DEFAULT\_ADMIN\_ROLE**.
{% endhint %}

**Call Parameters:**

| Name      | Type | Description                       |
| --------- | ---- | --------------------------------- |
| `_status` | bool | true if the share is transferable |

### setConfigProps

```solidity
function setConfigProps(VLib.ConfigProps memory _configProps) public
```

Settles ConfigProps.&#x20;

Refer to the [VLib](/technical-reference/core-contracts/vlib)'s data structure for more information. Only callable by the admin.

{% hint style="info" %}
This method can only be called by address with **DEFAULT\_ADMIN\_ROLE**.
{% endhint %}

### setSecurityProps

```solidity
function setSecurityProps(VLib.SecurityProps memory _securityProps) public
```

Settles SecurityProps.

Refer to the [VLib](/technical-reference/core-contracts/vlib)'s data structure for more information.

{% hint style="info" %}
This method can only be called by address with **DEFAULT\_ADMIN\_ROLE**.
{% endhint %}

### setFeesProps

```solidity
function setFeesProps(VLib.FeesProps memory _feesProps) public
```

Settles FeesProps.

Refer to the [VLib](/technical-reference/core-contracts/vlib)'s data structure for more information

{% hint style="info" %}
This method can only be called by address with **DEFAULT\_ADMIN\_ROLE**.
{% endhint %}


# FeesManager

The FeesManager contract manages management and performance fees receivers.

## Write Methods

### setManagementFeesReceiver

```solidity
function setManagementFeesReceiver(address _managementFeesReceiver) external
```

Settles the address of the management fees receiver.&#x20;

{% hint style="info" %}
Only callable by the contract **owner**.
{% endhint %}

**Call Parameters:**

<table><thead><tr><th width="281">Name</th><th>Type</th><th>Description</th></tr></thead><tbody><tr><td><code>_managementFeesReceiver</code></td><td>address</td><td>address of the management fees receiver</td></tr></tbody></table>

### setPerformanceFeesReceiver

```solidity
function setPerformanceFeesReceiver(address _performanceFeesReceiver) external
```

Settles the address of the performance fees receiver.&#x20;

{% hint style="info" %}
Only callable by the contract **owner**.
{% endhint %}

**Call Parameters:**

<table><thead><tr><th width="289">Name</th><th>Type</th><th>Description</th></tr></thead><tbody><tr><td><code>_performanceFeesReceiver</code></td><td>address</td><td>address of the performance fees receiver</td></tr></tbody></table>


# AccessManager

AccessManager contract manages roles and whitelist status related to Vaults contracts.

## View Methods

### whiteListMode (KYC)

```solidity
function whiteListMode(address _vaultAddress) external view returns (bool isEnabled)
```

Returns the KYC mode status of a vault.

**Call Parameters:**

|                | Type    | Description          |
| -------------- | ------- | -------------------- |
| \_vaultAddress | address | address of the vault |

**Return Value:**

| Type | Description                       |
| ---- | --------------------------------- |
| bool | `true` if the KYC mode is enabled |

### permissionLessMode

```solidity
function permissionLessMode() external view returns (bool isEnabled)
```

Returns the status of the permission-less mode.&#x20;

**Return Value:**

| Type | Description                                   |
| ---- | --------------------------------------------- |
| bool | `true` if the permission-less mode is enabled |

### getUserAccessInfo

```solidity
function getUserAccessInfo(address _user)
    external
    view
    returns (
        uint256 ownedTokenID,
        bool isUserKYC,
        IKYCToken.TokenParameters memory _tokenParameters
    )
```

Returns the KYC information for a given user.

**Call Parameters:**

<table><thead><tr><th width="214">Name</th><th>Type</th><th>Description</th></tr></thead><tbody><tr><td><code>_user</code></td><td>address</td><td>address of the user</td></tr></tbody></table>

**Return Values:**

<table><thead><tr><th width="214">Name</th><th>Type</th><th>Description</th></tr></thead><tbody><tr><td><code>ownedTokenID</code></td><td>uint256</td><td>KYC token ID</td></tr><tr><td><code>isUserKYC</code></td><td>bool</td><td>KYC state of the user</td></tr><tr><td><code>_tokenParameters</code></td><td>IKYCToken.TokenParameters</td><td>KYC information of the user</td></tr></tbody></table>

### isWhiteListed

```solidity
function isWhiteListed(address _vault, address _user) 
    public view returns (bool)
```

Returns the whitelist status of a given user.

**Call Parameters:**

| Name     | Type    | Description               |
| -------- | ------- | ------------------------- |
| `_vault` | address | address of a vault        |
| `_user`  | address | address of a vault's user |

**Return Value:**

| Type | Description                          |
| ---- | ------------------------------------ |
| bool | `true` if the address is whitelisted |

## Write Methods

### SetPermissionLessMode

```solidity
function setPermissionLessMode(bool _status) external
```

Settles the permission-less mode.&#x20;

{% hint style="info" %}
This method can only be called by address with **DEFAULT\_ADMIN\_ROLE**.
{% endhint %}

**Call Parameters:**

| Name      | Type | Description                               |
| --------- | ---- | ----------------------------------------- |
| `_status` | bool | `true` to enable the permission-less mode |

### SetWhiteListMode (KYC)

```solidity
function setWhiteListMode(address _vault, bool _status) external
```

Settles the KYC mode of a vault.&#x20;

{% hint style="info" %}
This method can only be called by address with **DEFAULT\_ADMIN\_ROLE**.
{% endhint %}

**Call Parameters:**

| Name      | Type    | Description                   |
| --------- | ------- | ----------------------------- |
| `_vault`  | address | address of a vault            |
| `_status` | bool    | `true` to enable the KYC mode |

### SetKYCTokenImp

```solidity
function setKYCTokenImp(address _newKYCTokenImp) external
```

Settles the implementation address of the KYCToken.&#x20;

{% hint style="info" %}
This method can only be called by address with **DEFAULT\_ADMIN\_ROLE**.
{% endhint %}

**Call Parameters:**

| Name              | Type    | Description                                                   |
| ----------------- | ------- | ------------------------------------------------------------- |
| `_newKYCTokenImp` | address | the address of the contract containing the new implementation |


# KYCToken

KYCToken contract is used to manage the KYC-mode on a vault.

{% hint style="info" %}
The KYC status is represented by a **non-transferable** NFT ERC721, minted only by **trusted KYC providers**. This NFT, associated with a **unique** address, allows that address to deposit funds in all vaults.
{% endhint %}

## Types

### TokenParameters

```solidity
struct TokenParameters {
    bool active; 
    string provider; 
    string proof; 
    uint256 flag; 
    uint256 expiration; 
}
```

TokenParameters represents the stored metadata to enable on chain filtering when entering Vaults

| Name         | Type    | Description           |
| ------------ | ------- | --------------------- |
| `active`     | bool    | ongoing KYC state     |
| `provider`   | string  | KYC trust provider    |
| `proof`      | string  | hash of the proof     |
| `flag`       | uint256 | degree of sensitivity |
| `expiration` | uint256 | expiration date       |

## View Methods

### ownedNFTMap

```solidity
function ownedNFTMap(address _owner) external view returns (uint256 tokenId)
```

Returns the token ID of the KYC NFT of a user.&#x20;

**Call Parameters:**

| Name     | Type    | Description         |
| -------- | ------- | ------------------- |
| `_owner` | address | address of an owner |

**Return Value:**

| Type    | Description             |
| ------- | ----------------------- |
| uint256 | token ID of the KYC NFT |

### tokenParameters

```solidity
function tokenParameters(uint256 tokenId) 
    public view virtual returns (TokenParameters memory)
```

Returns the KYC parameters for a given token ID.

**Call Parameters:**

| Name      | Type    | Description |
| --------- | ------- | ----------- |
| `tokenId` | uint256 | token ID    |

**Return Value:**

| Type            | Description                 |
| --------------- | --------------------------- |
| TokenParameters | KYC parameters of the token |

### isUserKYC

```solidity
function isUserKYC(address user) external view returns (bool)
```

Returns whether or not the user has a valid NFT.

**Call Parameters:**

| Name   | Type    | Description         |
| ------ | ------- | ------------------- |
| `user` | address | address of the user |

**Return Value:**

| Type | Description                |
| ---- | -------------------------- |
| bool | `true` if the NFT is valid |

## Write Methods

### setTokenParameters

```solidity
function setTokenParameters(
    uint256 tokenId, 
    TokenParameters calldata parameters
) external
```

Allows KYC providers to edit TokenParameters of a given token ID.&#x20;

{% hint style="info" %}
This method can only be called by address with **DEFAULT\_ADMIN\_ROLE**.
{% endhint %}

**Call Parameters:**

| Name         | Type            | Description    |
| ------------ | --------------- | -------------- |
| `tokenId`    | uint256         | ID of the NFT  |
| `parameters` | TokenParameters | KYC parameters |

### mint

```solidity
function mint(address to, TokenParameters memory parameters) public
```

Mints a KYC NFT and stores the KYC Metadata.

{% hint style="info" %}
This method can only be called by address with **MINTER\_ROLE**.
{% endhint %}

**Call Parameters:**

| Name         | Type            | Description         |
| ------------ | --------------- | ------------------- |
| `to`         | address         | address of the user |
| `parameters` | TokenParameters | KYC parameters      |

### batch

```solidity
function batch(address[] memory users, TokenParameters[] memory parameters) external
```

Mints several KYC NFTs in one transaction.&#x20;

{% hint style="info" %}
This method can only be called by address with **MINTER\_ROLE**.
{% endhint %}

**Call Parameters:**

| Name         | Type               | Description             |
| ------------ | ------------------ | ----------------------- |
| `users`      | address\[]         | list of users addresses |
| `parameters` | TokenParameters\[] | list of KYC parameters  |


# Contracts Addresses

The latest version of Shprd contracts are deployed on the following chains.

{% hint style="info" %}
Please note that Shprd smart contracts are currently deployed with the **same** **address** on **BNB Chain** and **Arbitrum**.
{% endhint %}

{% content-ref url="/pages/M6MNIlonNmaPxjVb6CaU" %}
[BNB Chain](/technical-reference/contracts-addresses/bnb-chain)
{% endcontent-ref %}

{% content-ref url="/pages/Y5vzqv8IzCDJUfuGpDQl" %}
[Arbitrum](/technical-reference/contracts-addresses/arbitrum)
{% endcontent-ref %}


# BNB Chain

The latest version of Shprd contracts are deployed at the following addresses.

<table><thead><tr><th width="140">Contract</th><th width="421" align="center">Contract Address </th><th align="center">Explorer</th></tr></thead><tbody><tr><td>Factory</td><td align="center"><pre class="language-solidity"><code class="lang-solidity">0xF0EE0b31aAE29f0bEa8Ff806c101377Fc92e4FFA
</code></pre></td><td align="center"><a href="https://bscscan.com/address/0xF0EE0b31aAE29f0bEa8Ff806c101377Fc92e4FFA">View on BscScan</a></td></tr><tr><td>Fees<br>Manager</td><td align="center"><pre class="language-solidity"><code class="lang-solidity"><strong>0x59E6d8Eb72235Fc964534e0E6283D93cd73E1F22
</strong></code></pre></td><td align="center"><a href="https://bscscan.com/address/0x59E6d8Eb72235Fc964534e0E6283D93cd73E1F22">View on BscScan</a></td></tr><tr><td><p>Access</p><p>Manager</p></td><td align="center"><pre class="language-solidity"><code class="lang-solidity">0x04EE4821bEEA5073c519D443D2AFC69a0202495d
</code></pre></td><td align="center"><a href="https://bscscan.com/address/0x04EE4821bEEA5073c519D443D2AFC69a0202495d">View on BscScan</a></td></tr><tr><td>KYCToken </td><td align="center"><pre class="language-solidity"><code class="lang-solidity">0x36Ce89c9eD0EC401305cf34b590dc2A24978fA68
</code></pre></td><td align="center"><a href="https://bscscan.com/address/0x36Ce89c9eD0EC401305cf34b590dc2A24978fA68">View on BscScan</a></td></tr><tr><td>ShareLogic</td><td align="center"><pre class="language-solidity"><code class="lang-solidity">0x939818eFE9C0DDC6F9e4faDCeA46fe0670A04C3a
</code></pre></td><td align="center"><a href="https://bscscan.com/address/0x939818eFE9C0DDC6F9e4faDCeA46fe0670A04C3a">View on BscScan</a></td></tr><tr><td>Beacon</td><td align="center"><pre class="language-solidity"><code class="lang-solidity"><strong>0xb7fCCEd2Aae943F478ccf570c3C10872f4EB9f6d
</strong></code></pre></td><td align="center"><a href="https://bscscan.com/address/0xb7fCCEd2Aae943F478ccf570c3C10872f4EB9f6d">View on BscScan</a></td></tr></tbody></table>


# Arbitrum

The latest version of Shprd contracts are deployed at the following addresses.

<table><thead><tr><th width="140">Contract</th><th width="421" align="center">Contract Address </th><th align="center">Explorer</th></tr></thead><tbody><tr><td>Factory</td><td align="center"><pre class="language-solidity"><code class="lang-solidity">0xF0EE0b31aAE29f0bEa8Ff806c101377Fc92e4FFA
</code></pre></td><td align="center"><a href="https://arbiscan.io/address/0xF0EE0b31aAE29f0bEa8Ff806c101377Fc92e4FFA">View on Arbiscan</a></td></tr><tr><td>Fees<br>Manager</td><td align="center"><pre class="language-solidity"><code class="lang-solidity"><strong>0x59E6d8Eb72235Fc964534e0E6283D93cd73E1F22
</strong></code></pre></td><td align="center"><a href="https://arbiscan.io/address/0x59E6d8Eb72235Fc964534e0E6283D93cd73E1F22">View on Arbiscan</a></td></tr><tr><td><p>Access</p><p>Manager</p></td><td align="center"><pre class="language-solidity"><code class="lang-solidity">0x04EE4821bEEA5073c519D443D2AFC69a0202495d
</code></pre></td><td align="center"><a href="https://arbiscan.io/address/0x04EE4821bEEA5073c519D443D2AFC69a0202495d">View on Arbiscan</a></td></tr><tr><td>KYCToken </td><td align="center"><pre class="language-solidity"><code class="lang-solidity">0x36Ce89c9eD0EC401305cf34b590dc2A24978fA68
</code></pre></td><td align="center"><a href="https://arbiscan.io/address/0x36Ce89c9eD0EC401305cf34b590dc2A24978fA68">View on Arbiscan</a></td></tr><tr><td>ShareLogic</td><td align="center"><pre class="language-solidity"><code class="lang-solidity">0x939818eFE9C0DDC6F9e4faDCeA46fe0670A04C3a
</code></pre></td><td align="center"><a href="https://arbiscan.io/address/0x939818eFE9C0DDC6F9e4faDCeA46fe0670A04C3a">View on Arbiscan</a></td></tr><tr><td>Beacon</td><td align="center"><pre class="language-solidity"><code class="lang-solidity"><strong>0xb7fCCEd2Aae943F478ccf570c3C10872f4EB9f6d
</strong></code></pre></td><td align="center"><a href="https://arbiscan.io/address/0xb7fCCEd2Aae943F478ccf570c3C10872f4EB9f6d">View on Arbiscan</a></td></tr></tbody></table>


# Subgraphs

Subgraphs maintained by Shprd on The Graph's hosted service.

| Network   | URL                                                                                             |
| --------- | ----------------------------------------------------------------------------------------------- |
| BNB Chain | [View on The Graph](https://thegraph.com/hosted-service/subgraph/henri-npx/shprd-beta-bnb)      |
| Arbitrum  | [View on The Graph](https://thegraph.com/hosted-service/subgraph/henri-npx/shprd-beta-arbitrum) |


# Authentication

## KYC NFT

Depending on the configuration of the vault, it may be necessary to be **KYC**. If so, there will be a "**KYCed vault**" label on the vault.&#x20;

<figure><img src="https://4042996663-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fp22VZjhas5Bq2OgV9HzX%2Fuploads%2FkEv3LYvwy7hI82WQJcQG%2FCapture%20d%E2%80%99e%CC%81cran%202022-10-24%20a%CC%80%2009.47.17.png?alt=media&amp;token=11619bd2-ff74-4600-8a84-5e450a267d8a" alt=""><figcaption><p>KYCed Vault label</p></figcaption></figure>

To do so, you must go here to obtain **proof of identity**:

{% embed url="<https://kyc.shprd.finance/>" %}
Shprd KYC&#x20;
{% endembed %}

Once the KYC is completed, you will receive a **ShprdKYC NFT**. This is a **non-transferable** ERC721 token which proves that you are **KYC**, without revealing your identity.

{% hint style="info" %}
No **personal** or **confidential** information is stored on the blockchain, so the sovereignty of your data is guaranteed.
{% endhint %}

## KYC status

At the top right of the application, you can see the KYC status information:

* **KYC Status:** User's KYC status and link to [kyc.shprd.finance](https://kyc.shprd.finance/)
* **KYC NFT:** User balance and address of the NFT KYC contract. The balance will be equal to **1** if the user is KYC.

<figure><img src="https://4042996663-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fp22VZjhas5Bq2OgV9HzX%2Fuploads%2FYbhfg3bvcbewz0CbREqK%2FCapture%20d%E2%80%99e%CC%81cran%202022-10-24%20a%CC%80%2009.47.58.png?alt=media&amp;token=ab4f647f-58a6-44dc-9382-c90769684328" alt=""><figcaption><p>Non-KYC user</p></figcaption></figure>

## Who can mint &#x20;

Shprd's KYC process is managed by **decentralised** protocols, approved to validate an individual's **identity**. Once an individual's KYC has been validated, the ShprdKYC NFT is minted automatically or, in some cases, manually if further verification actions are required.

## Waiting time&#x20;

Once the KYC request is made, the verification process may take **a** **few days**. Due to high demand, please be patient!

## Compliance

KYC verifications performed on **kyc.shprd.finance** are certified by Shprd's compliance team.

## Synaps

Synaps is a provider of digital identity services for cryptocurrencies. It allows new users to verify their identity through biometric facial authentication. Besides, Synaps has developed the decentralised identity protocol Anima, used by **kyc.shprd.finance.**&#x20;

## Anima&#x20;

Anima is what we call a **self-sovereign** identity. It allows you to manage your **digital identity** yourself in a **decentralised** way. With Anima, you take back control of your data and your digital identity. Anima changes the paradigm, you become the sole owner of your digital identity. All the attributes that are part of your identity such as your name, date of birth or nickname are **encrypted** with the private key of your wallet in a decentralised storage.<br>

##


# Trading Signals

The official strategy signals from Shprd's vaults can be found at **signals.shprd.finance**.&#x20;

This website allows you to see the performance history of the trading strategies. It will be accessible in the future by holding a specific token.&#x20;

Join the [Official Shprd Discord ](https://discord.shprd.finance/)to keep up with future developments.

<figure><img src="https://4042996663-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fp22VZjhas5Bq2OgV9HzX%2Fuploads%2F59vp1qN2vYDycxVDc3dN%2FCapture%20d%E2%80%99e%CC%81cran%202022-10-21%20a%CC%80%2017.10.21.png?alt=media&amp;token=b64e6ef0-5768-446f-a3be-8842629c8e48" alt=""><figcaption><p>Shprd Signals</p></figcaption></figure>


# Issues

If you face any issue you can contact us on Discord: <https://discord.gg/WnHwH7DSMe>


