Skip to content

0xIntuition/intuition-contracts

Repository files navigation

Intuition Protocol

Intuition is an Ethereum-based attestation protocol harnessing the wisdom of the crowds to create an open knowledge and reputation graph. Our infrastructure makes it easy for applications and their users to capture, explore, and curate verifiable data. We’ve prioritized making developer integrations easy and have implemented incentive structures that prioritize ‘useful’ data and discourage spam.

In bringing this new data layer to the decentralized web, we’re opening the flood gates to countless new use cases that we believe will kick off a consumer application boom.

The Intuition Knowledge Graph will be recognized as an organic flywheel, where the more developers that implement it, the more valuable the data it houses becomes.

Getting Started

Branching

The main branches we use are:

  • main (default): The most up-to-date branch, containing the work-in-progress code for upcoming releases
  • tob-audit: The snapshot of the code that was audited by Trail of Bits in March and April 2024

Documentation

To get a basic understanding of the Intuition protocol, please check out the following:

The ‘Multi Vault’

To bring our vision to life, Intuition proudly presents the ‘Multi Vault’—a revolutionary framework that seamlessly blends the ERC-1155 and ERC-4626 standards into a dynamic, scalable solution capable of managing millions of vaults with unprecedented efficiency. By consolidating vault management into a single contract, we address the inherent scalability and cost challenges faced by traditional systems.

Our current implementation carefully integrates key aspects of ERC-1155 and ERC-4626, with a clear ambition: to evolve into a fully compatible and interoperable standard. Through this journey, we aim not only to adhere to established protocols but to push the boundaries, creating a new benchmark that enhances the ecosystem's utility and efficiency.

Additionally, we have successfully integrated ERC-4337 into the AtomWallet contract. This contract is an abstract account associated with a corresponding atom, further advancing the capabilities of our protocol.

Audit Report

The Intuition Protocol underwent a comprehensive security audit by Trail of Bits. The full audit report can be accessed here.

Known Nuances

  • Share prices may get arbitrarily large as deposits/withdraws occur after Vault asset and share amounts approach 0 (i.e. if all users have withdrawn from the Vault), but this still elegantly achieves our desired functionality - which is, Users earn fee revenue when they are shareholders of a vault and deposit/redeem activities occur while they remain shareholders. This novel share price mechanism is used in lieu of a side-pocket reward pool for gas efficiency.
  • The Admin can pause the contracts, though there is an emergency withdraw that allows users to withdraw from the contract even while paused. This emergency withdraw bypasses all fees, to reduce the surface area of attack.
  • Exit fees are configurable, but have a maximum limit which they can be set to, preventing loss of user funds. Users also have the timelock window to withdraw from the contracts if they do not agree with a parameter change.

Building and Running Tests

To build the project and run tests, follow these steps:

Prerequisites

Step by Step Guide

Install Dependencies

$ npm i
$ forge install

Build

$ forge build

Run Tests

$ forge test -vvv

Run Fuzz Tests

  • Make sure you have at least node 16 and python 3.6 installed on your local machine
  • Add your FUZZ_AP_KEY to the .env file locally
  • Run the following command to install the diligence-fuzzing package:
$ pip3 install diligence-fuzzing
  • After the installation is completed, run the fuzzing CLI:
$ fuzz forge test
  • Finally, check your Diligence Fuzzing dashboard to see the results of the fuzzing tests

Run Slither (Static Analysis)

  • Install the slither-analyzer package:
  $ pip3 install slither-analyzer
  • After the installation is completed, run the slither analysis bash script:
  $ npm run slither

Run Manticore (Symbolic Execution)

  • Make sure you have Docker installed on your local machine

  • Build the Docker image:

  $ docker build -t manticore-analysis .
  • Run the Docker container:
  $ docker run --rm -v "$(pwd)":/app manticore-analysis

Deployment Process

To deploy the Beta smart contract system on to a public testnet or mainnet, you’ll need the following:

  • RPC URL of the network that you’re trying to deploy to (as for us, we’re targeting Base Sepolia testnet as our target chain for the testnet deployments)
  • Export PRIVATE_KEY of a deployer account in the terminal, and fund it with some test ETH to be able to cover the gas fees for the smart contract deployments
  • For Base Sepolia, there is a reliable testnet faucet deployed by Alchemy
  • Deploy smart contracts using the following command:
$ forge script script/Deploy.s.sol --broadcast --rpc-url <your_rpc_url> --private-key $PRIVATE_KEY

Deployment Verification

To verify the deployed smart contracts on Basescan, you’ll need to export your Basescan API key as ETHERSCAN_API_KEY in the terminal, and then run the following command:

$ forge verify-contract <0x_contract_address> ContractName --watch --chain-id <chain_id>

Notes:

  • When verifying your smart contracts, you can use an optional parameter --constructor-args to pass the constructor arguments of the smart contract in the ABI-encoded format
  • The chain ID for Base Sepolia is 84532, whereas the chain ID for Base Mainnet is 8453