npm package: @oamo/contracts
Description: Collection of Solidity Smart-Contract used by Oamo.io
Author: Oamo.io
Latest version: 0.2.17

# Oamo - Smart-Contracts

[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![npm](https://img.shields.io/npm/v/@oamo/contracts.svg?maxAge=2592000)](https://www.npmjs.com/package/@oamo/contracts)

## Table of contents

- [General info](#general-info)
- [Role and Ownership Security](#role-and-ownership-security)
- [Functionality](#functionality)
- [Security](#security)
- [Setup](#setup)
- [Documentation](#documentation)

## General info

This repository is composed of the Smart Contracts that are used by the Oamo. There is currently 2 main Smart Contracts:

- **DataPool.sol**: ERC721 contract that represent the ownership of a data pool. (non transferable)
- **Vault.sol**: Contract receiving and distributing rewards to participants of a data pool.

This repository also include many tests for the Smart Contracts, the tests are written using Foundry and Hardhat.

The Smart Contracts are intended to be deployed on the Polygon Network.

- DataPool: 0x33AA4Cf440e8d2A1c37A5aD7be356E1ffB28F76d
- Vault: 0x8c07df06DED7D71A71E776425ff905c10f558D2A

- Multi-Sig Wallet: 0x05a0F169084836C68a85E55DF8d61F2fEbe881fb (Owning the Admin Proxy and Admin Role on both Smart Contracts)

## Functionality

The main functionality of the Smart Contracts are the ability to create Data Pool and participate in them.
To create a new Data Pool or participate in them, the transaction must be first signed by an Oracle. The Oracle is a trusted third party that is responsible for verifying the validity of the transaction and signing it. The Oracle has also the capability to execute the transaction.

Each Data Pool is represented as a NFT, that been said the functionality to transfer the ownership of the NFT has been disabled.

**To be completed**

> More detail to come

## Security

The 2 main Smart Contracts in this repository (DataPool and Vault) are intended to be deployed as Upgradeable Smart Contracts. Using the OpenZeppelin Transparent Proxy pattern, the upgradeability is achieved by using a Proxy contract that delegates all calls to an implementation contract. The implementation contract can be upgraded by the owner of the AdminProxy contract.

To ensure the security of the upgradeability mechanism, the AdminProxy contract is owned by a MultiSig wallet. The MultiSig wallet is controlled by 5 owners and a threshold of 3 signatures is required for any transaction to be executed.

Both Smart Contracts also use a system of roles to restrict access to certain functions. The roles are managed by the AccessControl contract from OpenZeppelin.
The 2 roles currently in use by both smart contracts are:

- Admin: Can assign or remove role to other addresses
- Oracle: Can approve or execute createDataPool and participate functions

The Admin role is assigned to the same MultiSig wallet that owns the AdminProxy contract.

> **To be implemented**
> The Oracle role is assign to a separate MultiSig wallet that is controlled by 3 owners, with a threshold of 2 signatures required for any transaction to be executed.

## Setup

### Install Dependencies

```bash
yarn install
```

### Run test with Hardhat

```bash
npx hardhat test
```

### List all Hardhat tasks

```bash
npx hardhat help
```

### Run test with Foundry

```bash
forge test
```

## Documentation

- [Hardhat Documentation](https://hardhat.org/getting-started/)
- [Foundry Documentation](https://book.getfoundry.sh/index.html)