npm package: @nuveminc/pharos-sdk
Description: <p style="text-align:center">    </span>       <img src="https://img.shields.io/github/actions/workflow/status/mkpace/npm-sdk/publish.yml" />    </span>    <span>       <img src="https://img.shields.io/npm/l/@nuveminc/pharos-sdk" />    </span>    <span>  
Author: mpace
Latest version: 0.0.7

<p style="text-align:center">
   </span>
      <img src="https://img.shields.io/github/actions/workflow/status/mkpace/npm-sdk/publish.yml" />
   </span>
   <span>
      <img src="https://img.shields.io/npm/l/@nuveminc/pharos-sdk" />
   </span>
   <span>
      <img src="https://img.shields.io/github/last-commit/mkpace/npm-sdk" />
   </span>
   <span>
      <img src="https://img.shields.io/npm/v/@nuveminc/pharos-sdk" />
   </span>   
</p>

# Polymesh Core Principles

The Polymesh network operates on a few principles which are distinct and separate from your typical public chains such as Bitcoin or Ethereum. These principles are specific to Polymesh as they are core primitives by which a security token network is able to provide an institutional grade permissioned blockchain.

## Identity (uID)

Every user on the Polymesh network has a unique user Id (uID). This unique id is assigned to a user whether they are a `juridical person` or a `natural person`. Each of these identities can control one or more accounts on the network. Each `uID` is verified by a KYC provider which guarantees and uniquely identifies that entity or individual. A KYC provider will issue attestations for the specific entity or user. These signed attestations are evidence of the KYC provider testifying to their review process.

## Account (DID)

Each entity or individual can control one or more accounts on the network. Each of these accounts is represented by a `DID` which also maps to a single `uID`.

## Signing Keys

Each identity `uID` has a single `primary key` they use to sign transactions when acting on behalf of themselves. An identity can also posess multiple secondary keys (`signing keys`) which allow the user (`uID`) to act on behalf of another entity or individual.

Each of these keys (primary or secondary) can be one of two types:

- `simple private` key: based on a seed or mnemonic and is sufficient for an individual.
- `mulit-signature` key: that is based on `n-keys` of which `q`, a quorum, must be presented for any action to be validated.

## Portfolios

Portfolios are logical containers which are managed by `DID`s. These portfolios provide a way to manage assets and create permission boundaries for various assets held in portfolios.

# PharosDEX SDK

The PharosDEX SDK provides the abstractions and interfaces to simplify interaction with the PharosDEX contracts on the Polymesh network.
The PharosDEX assist you with developing your own web application to provide investors with an easy to use user interface for interacting with the PharosDEX.

## Installation

Installing the PharosDEX SDK with pnpm:

```bash
$ pnpm i --save @pharos/sdk
```

Installing the PharosDEX SDK with npm:

```bash
$ npm i --save @pharos/sdk
```

Installing the PharosDEX SDK with yarn:

```bash
$ yarn add @pharos/sdk
```

## Pool Deployer / Contract Deployer

**Using a contract deployer account**

1. Create a new "pool" contract for the two ticker symbols

   1.1 The contract creates a venue and and portfolio \*\* what are these?

2. Deploy the contract and get the contract address
3. Grant permission for the contract to create a venue and portfolio
4. Add a name for the porfolio and initialize the portfolio contract

## Liquidity Provider

**Using the LP account**

A Custody Portfolio (CP) is required to be created because funds can't be transferred unless the pool has custody of a portfolio that is owned by the user.

Each and every pool will need to use a CP contract to allow the transfer of funds from the user to the pool.

LP Account (grants custody) => Custody Portfolio (proxy) => Pool (is able to transfer from portfolio)

1. Create a CP so the CP contract can transfer. Name portfolio
2. Grant the newly created CP contract custody of the user account to allow transfer of tokens to the pool.
3. Accept custody is manual as the Custody Portfolio must "accept" custody from the user account.

## Adding Liquidity

Adding tokens to the liquidity pool requires transferring tokens from their Default Portfolio account (DP) to the CP then transferring those tokens from the CP to the pool.

1. A user must transfer tokens from their "default" portfolio (DP) to the custody portfolio to allow the pool to gain access to those tokens. Recall that the pool contract requires access (granted permission) to access the Custody Portfolio contract (CP)