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

Documentation

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

Rationale

  • This repository contains a sort of frankenstein of the previously audited EthMultiVault and the new Bonding Curve Registry features.
  • All bonding curve related activities have their own methods / routes in the EthMultiVault.
  • This results in duplicative code, but enables us to keep the old EthMultiVault and the new Bonding Curve Registry features separate.
  • The next version of the MultiVault will consolidate and converge these disparate pathways into a far more elegant and organized system.

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 Etherscan, you’ll need to export your Etherscan 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

Contract Architecture

This document provides an overview of the core contracts and their relationships. Click on any contract to view its detailed documentation.

graph TB
    Interfaces(("Interfaces"))
    Core(("Core"))
    Libraries(("Libraries"))

    subgraph InterfacesList ["Interfaces"]
        direction LR
        IBaseCurve & IBondingCurveRegistry
        IEthMultiVault & IPermit2
    end
    Interfaces --> InterfacesList

    subgraph CoreList ["Core"]
        direction LR
        AtomWallet & BaseCurve
        BondingCurveRegistry & EthMultiVault
        LinearCurve & OffsetProgressiveCurve
        ProgressiveCurve
    end
    Core --> CoreList

    subgraph LibrariesList ["Libraries"]
        direction LR
        Errors
    end
    Libraries --> LibrariesList

    %% Style definitions
    classDef default fill:#f4f4f4,stroke:#333,stroke-width:2px,font-size:24px,font-family:Arial,rounded:true,color:#000;
    classDef root fill:#6366f1,color:#fff,stroke:#4338ca,stroke-width:4px,font-size:32px,font-weight:bold,font-family:Arial,rx:40px;
    classDef category fill:none,stroke:none,color:#000,font-size:24px,font-weight:bold,font-family:Arial;
    
    %% Apply styles
    class Interfaces,Core,Libraries root;
    class InterfacesList,CoreList,LibrariesList category;

    %% Click actions
    click IPermit2 "http://localhost:3000/src/interfaces/IPermit2.sol/interface.IPermit2.html" "IPermit2 documentation"
    click IEthMultiVault "http://localhost:3000/src/interfaces/IEthMultiVault.sol/interface.IEthMultiVault.html" "IEthMultiVault documentation"
    click IBaseCurve "http://localhost:3000/src/interfaces/IBaseCurve.sol/interface.IBaseCurve.html" "IBaseCurve documentation"
    click IBondingCurveRegistry "http://localhost:3000/src/interfaces/IBondingCurveRegistry.sol/interface.IBondingCurveRegistry.html" "IBondingCurveRegistry documentation"
    click EthMultiVault "EthMultiVault.html" "EthMultiVault documentation"
    click LinearCurve "LinearCurve.html" "LinearCurve documentation"
    click AtomWallet "AtomWallet.html" "AtomWallet documentation"
    click ProgressiveCurve "ProgressiveCurve.html" "ProgressiveCurve documentation"
    click BondingCurveRegistry "BondingCurveRegistry.html" "BondingCurveRegistry documentation"
    click BaseCurve "BaseCurve.html" "BaseCurve documentation"
    click OffsetProgressiveCurve "OffsetProgressiveCurve.html" "OffsetProgressiveCurve documentation"
    click Errors "http://localhost:3000/src/libraries/Errors.sol/library.Errors.html" "Errors documentation"

EthMultiVault

Detailed view of the EthMultiVault contract and its members. Click on any member to view its documentation.

graph TB
    root(("EthMultiVault"))

    %% Style definitions
    classDef default fill:#f4f4f4,stroke:#333,stroke-width:2px,font-size:28px,font-family:Arial,rounded:true;
    classDef root fill:#6366f1,color:#fff,stroke:#4338ca,stroke-width:4px,font-size:32px,font-weight:bold,font-family:Arial,rx:40px;
    classDef stateVar fill:#dbeafe,stroke:#3b82f6,stroke-width:2px,color:#1e40af,font-size:28px,font-family:Arial,rounded:true;
    classDef function fill:#e0e7ff,stroke:#818cf8,stroke-width:2px,color:#4338ca,font-size:28px,font-family:Arial,rounded:true;
    classDef contract fill:#fef3c7,stroke:#f59e0b,stroke-width:2px,color:#b45309,font-size:28px,font-family:Arial,rounded:true;
    classDef category fill:none,stroke:none,color:#333,font-size:28px,font-weight:bold,font-family:Arial;
    
    %% Apply styles
    class root root;
    class StateVars,CoreFunctions,Getters,Setters,PreviewFunctions,ConversionFunctions,Initialization,Uses,Inheritance category;

    %% Click actions
    click root "http://localhost:3000/src/EthMultiVault.sol/contract.EthMultiVault.html" "EthMultiVault documentation"

BondingCurveRegistry

Detailed view of the BondingCurveRegistry contract and its members. Click on any member to view its documentation.

graph TB
    root(("BondingCurveRegistry"))

    %% Style definitions
    classDef default fill:#f4f4f4,stroke:#333,stroke-width:2px,font-size:28px,font-family:Arial,rounded:true;
    classDef root fill:#6366f1,color:#fff,stroke:#4338ca,stroke-width:4px,font-size:32px,font-weight:bold,font-family:Arial,rx:40px;
    classDef stateVar fill:#dbeafe,stroke:#3b82f6,stroke-width:2px,color:#1e40af,font-size:28px,font-family:Arial,rounded:true;
    classDef function fill:#e0e7ff,stroke:#818cf8,stroke-width:2px,color:#4338ca,font-size:28px,font-family:Arial,rounded:true;
    classDef contract fill:#fef3c7,stroke:#f59e0b,stroke-width:2px,color:#b45309,font-size:28px,font-family:Arial,rounded:true;
    classDef category fill:none,stroke:none,color:#333,font-size:28px,font-weight:bold,font-family:Arial;
    
    %% Apply styles
    class root root;
    class StateVars,CoreFunctions,Getters,Setters,PreviewFunctions,ConversionFunctions,Initialization,Uses,Inheritance category;

    %% Click actions
    click root "http://localhost:3000/src/BondingCurveRegistry.sol/contract.BondingCurveRegistry.html" "BondingCurveRegistry documentation"

BaseCurve

Detailed view of the BaseCurve contract and its members. Click on any member to view its documentation.

graph TB
    root(("BaseCurve"))

    %% Style definitions
    classDef default fill:#f4f4f4,stroke:#333,stroke-width:2px,font-size:28px,font-family:Arial,rounded:true;
    classDef root fill:#6366f1,color:#fff,stroke:#4338ca,stroke-width:4px,font-size:32px,font-weight:bold,font-family:Arial,rx:40px;
    classDef stateVar fill:#dbeafe,stroke:#3b82f6,stroke-width:2px,color:#1e40af,font-size:28px,font-family:Arial,rounded:true;
    classDef function fill:#e0e7ff,stroke:#818cf8,stroke-width:2px,color:#4338ca,font-size:28px,font-family:Arial,rounded:true;
    classDef contract fill:#fef3c7,stroke:#f59e0b,stroke-width:2px,color:#b45309,font-size:28px,font-family:Arial,rounded:true;
    classDef category fill:none,stroke:none,color:#333,font-size:28px,font-weight:bold,font-family:Arial;
    
    %% Apply styles
    class root root;
    class StateVars,CoreFunctions,Getters,Setters,PreviewFunctions,ConversionFunctions,Initialization,Uses,Inheritance category;

    %% Click actions
    click root "http://localhost:3000/src/BaseCurve.sol/contract.BaseCurve.html" "BaseCurve documentation"

LinearCurve

Detailed view of the LinearCurve contract and its members. Click on any member to view its documentation.

graph TB
    root(("LinearCurve"))

    %% Style definitions
    classDef default fill:#f4f4f4,stroke:#333,stroke-width:2px,font-size:28px,font-family:Arial,rounded:true;
    classDef root fill:#6366f1,color:#fff,stroke:#4338ca,stroke-width:4px,font-size:32px,font-weight:bold,font-family:Arial,rx:40px;
    classDef stateVar fill:#dbeafe,stroke:#3b82f6,stroke-width:2px,color:#1e40af,font-size:28px,font-family:Arial,rounded:true;
    classDef function fill:#e0e7ff,stroke:#818cf8,stroke-width:2px,color:#4338ca,font-size:28px,font-family:Arial,rounded:true;
    classDef contract fill:#fef3c7,stroke:#f59e0b,stroke-width:2px,color:#b45309,font-size:28px,font-family:Arial,rounded:true;
    classDef category fill:none,stroke:none,color:#333,font-size:28px,font-weight:bold,font-family:Arial;
    
    %% Apply styles
    class root root;
    class StateVars,CoreFunctions,Getters,Setters,PreviewFunctions,ConversionFunctions,Initialization,Uses,Inheritance category;

    %% Click actions
    click root "http://localhost:3000/src/LinearCurve.sol/contract.LinearCurve.html" "LinearCurve documentation"

ProgressiveCurve

Detailed view of the ProgressiveCurve contract and its members. Click on any member to view its documentation.

graph TB
    root(("ProgressiveCurve"))

    %% Style definitions
    classDef default fill:#f4f4f4,stroke:#333,stroke-width:2px,font-size:28px,font-family:Arial,rounded:true;
    classDef root fill:#6366f1,color:#fff,stroke:#4338ca,stroke-width:4px,font-size:32px,font-weight:bold,font-family:Arial,rx:40px;
    classDef stateVar fill:#dbeafe,stroke:#3b82f6,stroke-width:2px,color:#1e40af,font-size:28px,font-family:Arial,rounded:true;
    classDef function fill:#e0e7ff,stroke:#818cf8,stroke-width:2px,color:#4338ca,font-size:28px,font-family:Arial,rounded:true;
    classDef contract fill:#fef3c7,stroke:#f59e0b,stroke-width:2px,color:#b45309,font-size:28px,font-family:Arial,rounded:true;
    classDef category fill:none,stroke:none,color:#333,font-size:28px,font-weight:bold,font-family:Arial;
    
    %% Apply styles
    class root root;
    class StateVars,CoreFunctions,Getters,Setters,PreviewFunctions,ConversionFunctions,Initialization,Uses,Inheritance category;

    %% Click actions
    click root "http://localhost:3000/src/ProgressiveCurve.sol/contract.ProgressiveCurve.html" "ProgressiveCurve documentation"

AtomWallet

Detailed view of the AtomWallet contract and its members. Click on any member to view its documentation.

graph TB
    root(("AtomWallet"))

    %% Style definitions
    classDef default fill:#f4f4f4,stroke:#333,stroke-width:2px,font-size:28px,font-family:Arial,rounded:true;
    classDef root fill:#6366f1,color:#fff,stroke:#4338ca,stroke-width:4px,font-size:32px,font-weight:bold,font-family:Arial,rx:40px;
    classDef stateVar fill:#dbeafe,stroke:#3b82f6,stroke-width:2px,color:#1e40af,font-size:28px,font-family:Arial,rounded:true;
    classDef function fill:#e0e7ff,stroke:#818cf8,stroke-width:2px,color:#4338ca,font-size:28px,font-family:Arial,rounded:true;
    classDef contract fill:#fef3c7,stroke:#f59e0b,stroke-width:2px,color:#b45309,font-size:28px,font-family:Arial,rounded:true;
    classDef category fill:none,stroke:none,color:#333,font-size:28px,font-weight:bold,font-family:Arial;
    
    %% Apply styles
    class root root;
    class StateVars,CoreFunctions,Getters,Setters,PreviewFunctions,ConversionFunctions,Initialization,Uses,Inheritance category;

    %% Click actions
    click root "http://localhost:3000/src/AtomWallet.sol/contract.AtomWallet.html" "AtomWallet documentation"

Attestoor

AttestoorFactory

CustomMulticall3

Contents

IBaseCurve

Git Source

Author: 0xIntuition

Interface for bonding curves in the Intuition protocol. All curves must implement these functions to be compatible with the protocol.

Functions

name

Get the name of the curve

function name() external view returns (string memory);

Returns

NameTypeDescription
<none>stringname The name of the curve

maxShares

Get the maximum number of shares the curve can handle

function maxShares() external view returns (uint256);

Returns

NameTypeDescription
<none>uint256The maximum number of shares

maxAssets

Get the maximum number of assets the curve can handle

function maxAssets() external view returns (uint256);

Returns

NameTypeDescription
<none>uint256The maximum number of assets

previewDeposit

Preview how many shares would be minted for a deposit of assets

function previewDeposit(uint256 assets, uint256 totalAssets, uint256 totalShares)
    external
    view
    returns (uint256 shares);

Parameters

NameTypeDescription
assetsuint256Quantity of assets to deposit
totalAssetsuint256Total quantity of assets already staked into the curve
totalSharesuint256Total quantity of shares already awarded by the curve

Returns

NameTypeDescription
sharesuint256The number of shares that would be minted

previewRedeem

Preview how many assets would be returned for burning a specific amount of shares

function previewRedeem(uint256 shares, uint256 totalShares, uint256 totalAssets)
    external
    view
    returns (uint256 assets);

Parameters

NameTypeDescription
sharesuint256Quantity of shares to burn
totalSharesuint256Total quantity of shares already awarded by the curve
totalAssetsuint256Total quantity of assets already staked into the curve

Returns

NameTypeDescription
assetsuint256The number of assets that would be returned

previewWithdraw

Preview how many shares would be redeemed for a withdrawal of assets

function previewWithdraw(uint256 assets, uint256 totalAssets, uint256 totalShares)
    external
    view
    returns (uint256 shares);

Parameters

NameTypeDescription
assetsuint256Quantity of assets to withdraw
totalAssetsuint256Total quantity of assets already staked into the curve
totalSharesuint256Total quantity of shares already awarded by the curve

Returns

NameTypeDescription
sharesuint256The number of shares that would need to be redeemed

previewMint

Preview how many assets would be required to mint a specific amount of shares

function previewMint(uint256 shares, uint256 totalShares, uint256 totalAssets) external view returns (uint256 assets);

Parameters

NameTypeDescription
sharesuint256Quantity of shares to mint
totalSharesuint256Total quantity of shares already awarded by the curve
totalAssetsuint256Total quantity of assets already staked into the curve

Returns

NameTypeDescription
assetsuint256The number of assets that would be required to mint the shares

convertToShares

Convert assets to shares at a specific point on the curve

function convertToShares(uint256 assets, uint256 totalAssets, uint256 totalShares)
    external
    view
    returns (uint256 shares);

Parameters

NameTypeDescription
assetsuint256Quantity of assets to convert to shares
totalAssetsuint256Total quantity of assets already staked into the curve
totalSharesuint256Total quantity of shares already awarded by the curve

Returns

NameTypeDescription
sharesuint256The number of shares equivalent to the given assets

convertToAssets

Convert shares to assets at a specific point on the curve

function convertToAssets(uint256 shares, uint256 totalShares, uint256 totalAssets)
    external
    view
    returns (uint256 assets);

Parameters

NameTypeDescription
sharesuint256Quantity of shares to convert to assets
totalSharesuint256Total quantity of shares already awarded by the curve
totalAssetsuint256Total quantity of assets already staked into the curve

Returns

NameTypeDescription
assetsuint256The number of assets equivalent to the given shares

currentPrice

Get the current price of a share

function currentPrice(uint256 totalShares) external view returns (uint256 sharePrice);

Parameters

NameTypeDescription
totalSharesuint256Total quantity of shares already awarded by the curve

Returns

NameTypeDescription
sharePriceuint256The current price of a share, scaled by 1e18

IBondingCurveRegistry

Git Source

Author: 0xIntuition

Interface for the BondingCurveRegistry contract. Routes access to the curves associated with atoms & triples.

Functions

previewDeposit

Preview how many shares would be minted for a deposit of assets

function previewDeposit(uint256 assets, uint256 totalAssets, uint256 totalShares, uint256 id)
    external
    view
    returns (uint256 shares);

Parameters

NameTypeDescription
assetsuint256Quantity of assets to deposit
totalAssetsuint256Total quantity of assets already staked into the curve
totalSharesuint256Total quantity of shares already awarded by the curve
iduint256Curve ID to use for the calculation

Returns

NameTypeDescription
sharesuint256The number of shares that would be minted

previewRedeem

Preview how many assets would be returned for burning a specific amount of shares

function previewRedeem(uint256 shares, uint256 totalShares, uint256 totalAssets, uint256 id)
    external
    view
    returns (uint256 assets);

Parameters

NameTypeDescription
sharesuint256Quantity of shares to burn
totalSharesuint256Total quantity of shares already awarded by the curve
totalAssetsuint256Total quantity of assets already staked into the curve
iduint256Curve ID to use for the calculation

Returns

NameTypeDescription
assetsuint256The number of assets that would be returned

previewWithdraw

Preview how many shares would be redeemed for a withdrawal of assets

function previewWithdraw(uint256 assets, uint256 totalAssets, uint256 totalShares, uint256 id)
    external
    view
    returns (uint256 shares);

Parameters

NameTypeDescription
assetsuint256Quantity of assets to withdraw
totalAssetsuint256Total quantity of assets already staked into the curve
totalSharesuint256Total quantity of shares already awarded by the curve
iduint256Curve ID to use for the calculation

Returns

NameTypeDescription
sharesuint256The number of shares that would need to be redeemed

previewMint

Preview how many assets would be required to mint a specific amount of shares

function previewMint(uint256 shares, uint256 totalShares, uint256 totalAssets, uint256 id)
    external
    view
    returns (uint256 assets);

Parameters

NameTypeDescription
sharesuint256Quantity of shares to mint
totalSharesuint256Total quantity of shares already awarded by the curve
totalAssetsuint256Total quantity of assets already staked into the curve
iduint256Curve ID to use for the calculation

Returns

NameTypeDescription
assetsuint256The number of assets that would be required to mint the shares

convertToShares

Convert assets to shares at a specific point on the curve

function convertToShares(uint256 assets, uint256 totalAssets, uint256 totalShares, uint256 id)
    external
    view
    returns (uint256 shares);

Parameters

NameTypeDescription
assetsuint256Quantity of assets to convert to shares
totalAssetsuint256Total quantity of assets already staked into the curve
totalSharesuint256Total quantity of shares already awarded by the curve
iduint256Curve ID to use for the calculation

Returns

NameTypeDescription
sharesuint256The number of shares equivalent to the given assets

convertToAssets

Convert shares to assets at a specific point on the curve

function convertToAssets(uint256 shares, uint256 totalShares, uint256 totalAssets, uint256 id)
    external
    view
    returns (uint256 assets);

Parameters

NameTypeDescription
sharesuint256Quantity of shares to convert to assets
totalSharesuint256Total quantity of shares already awarded by the curve
totalAssetsuint256Total quantity of assets already staked into the curve
iduint256Curve ID to use for the calculation

Returns

NameTypeDescription
assetsuint256The number of assets equivalent to the given shares

currentPrice

Get the current price of a share

function currentPrice(uint256 totalShares, uint256 id) external view returns (uint256 sharePrice);

Parameters

NameTypeDescription
totalSharesuint256Total quantity of shares already awarded by the curve
iduint256Curve ID to use for the calculation

Returns

NameTypeDescription
sharePriceuint256The current price of a share

getCurveName

Get the name of a curve

function getCurveName(uint256 id) external view returns (string memory name);

Parameters

NameTypeDescription
iduint256Curve ID to query

Returns

NameTypeDescription
namestringThe name of the curve

getCurveMaxShares

Get the maximum number of shares a curve can handle

function getCurveMaxShares(uint256 id) external view returns (uint256 maxShares);

Parameters

NameTypeDescription
iduint256Curve ID to query

Returns

NameTypeDescription
maxSharesuint256The maximum number of shares

getCurveMaxAssets

Get the maximum number of assets a curve can handle

function getCurveMaxAssets(uint256 id) external view returns (uint256 maxAssets);

Parameters

NameTypeDescription
iduint256Curve ID to query

Returns

NameTypeDescription
maxAssetsuint256The maximum number of assets

count

Get the number of curves registered in the registry

function count() external view returns (uint256);

Returns

NameTypeDescription
<none>uint256count The number of curves registered

curveAddresses

Get the curve address for a given ID

function curveAddresses(uint256 id) external view returns (address);

Parameters

NameTypeDescription
iduint256The curve ID to query

Returns

NameTypeDescription
<none>addressThe address of the curve

curveIds

Get the curve ID for a given address

function curveIds(address curve) external view returns (uint256);

Parameters

NameTypeDescription
curveaddressThe curve address to query

Returns

NameTypeDescription
<none>uint256The ID of the curve

IEthMultiVault

Git Source

Author: 0xIntuition

Interface for managing many ERC4626 style vaults in a single contract

Functions

init

Initializes the EthMultiVault contract

function init(
    GeneralConfig memory _generalConfig,
    AtomConfig memory _atomConfig,
    TripleConfig memory _tripleConfig,
    WalletConfig memory _walletConfig,
    VaultFees memory _defaultVaultFees,
    BondingCurveConfig memory _bondingCurveConfig
) external;

Parameters

NameTypeDescription
_generalConfigGeneralConfigGeneral configuration struct
_atomConfigAtomConfigAtom configuration struct
_tripleConfigTripleConfigTriple configuration struct
_walletConfigWalletConfigWallet configuration struct
_defaultVaultFeesVaultFeesDefault vault fees struct NOTE: This function is called only once (during contract deployment)
_bondingCurveConfigBondingCurveConfig

reinitialize

Reinitialize the contract with new bonding curve configuration

function reinitialize(BondingCurveConfig calldata bondingCurveConfig) external;

Parameters

NameTypeDescription
bondingCurveConfigBondingCurveConfigThe new bonding curve configuration

pause

pauses the pausable contract methods

function pause() external;

unpause

unpauses the pausable contract methods

function unpause() external;

scheduleOperation

schedule an operation to be executed after a delay

function scheduleOperation(bytes32 operationId, bytes calldata data) external;

Parameters

NameTypeDescription
operationIdbytes32unique identifier for the operation
databytesdata to be executed

cancelOperation

execute a scheduled operation

function cancelOperation(bytes32 operationId, bytes calldata data) external;

Parameters

NameTypeDescription
operationIdbytes32unique identifier for the operation
databytesdata to be executed

setAdmin

Requires new admin to 'confirm' the timelocked operation

set admin

function setAdmin(address admin) external;

Parameters

NameTypeDescription
adminaddressaddress of the new admin

setProtocolMultisig

set protocol multisig

function setProtocolMultisig(address protocolMultisig) external;

Parameters

NameTypeDescription
protocolMultisigaddressaddress of the new protocol multisig

setMinDeposit

sets the minimum deposit amount for atoms and triples

function setMinDeposit(uint256 minDeposit) external;

Parameters

NameTypeDescription
minDeposituint256new minimum deposit amount

setMinShare

sets the minimum share amount for atoms and triples

function setMinShare(uint256 minShare) external;

Parameters

NameTypeDescription
minShareuint256new minimum share amount

setAtomUriMaxLength

sets the atom URI max length

function setAtomUriMaxLength(uint256 atomUriMaxLength) external;

Parameters

NameTypeDescription
atomUriMaxLengthuint256new atom URI max length

setAtomWalletInitialDepositAmount

sets the atom share lock fee

function setAtomWalletInitialDepositAmount(uint256 atomWalletInitialDepositAmount) external;

Parameters

NameTypeDescription
atomWalletInitialDepositAmountuint256new atom share lock fee

setAtomCreationProtocolFee

sets the atom creation fee

function setAtomCreationProtocolFee(uint256 atomCreationProtocolFee) external;

Parameters

NameTypeDescription
atomCreationProtocolFeeuint256new atom creation fee

setTripleCreationProtocolFee

sets fee charged in wei when creating a triple to protocol multisig

function setTripleCreationProtocolFee(uint256 tripleCreationProtocolFee) external;

Parameters

NameTypeDescription
tripleCreationProtocolFeeuint256new fee in wei

setTotalAtomDepositsOnTripleCreation

sets the atom deposit fraction on triple creation used to increase the amount of assets in the underlying atom vaults on triple creation

function setTotalAtomDepositsOnTripleCreation(uint256 totalAtomDepositsOnTripleCreation) external;

Parameters

NameTypeDescription
totalAtomDepositsOnTripleCreationuint256new atom deposit fraction on triple creation

setAtomDepositFractionForTriple

sets the atom deposit fraction percentage for atoms used in triples (number to be divided by generalConfig.feeDenominator)

function setAtomDepositFractionForTriple(uint256 atomDepositFractionForTriple) external;

Parameters

NameTypeDescription
atomDepositFractionForTripleuint256new atom deposit fraction percentage

setBondingCurveConfig

sets the bonding curve configuration

function setBondingCurveConfig(address registry, uint256 defaultCurveId) external;

Parameters

NameTypeDescription
registryaddressaddress of the new bonding curve registry
defaultCurveIduint256new default curve ID

setEntryFee

sets entry fees for the specified vault (id=0 sets the default fees for all vaults) id = 0 changes the default entry fee, id = n changes fees for vault n specifically

admin cannot set the entry fee to be greater than maxEntryFeePercentage, which is set to be the 10% of generalConfig.feeDenominator (which represents 100%), to avoid being able to prevent users from depositing assets with unreasonable fees

function setEntryFee(uint256 id, uint256 entryFee) external;

Parameters

NameTypeDescription
iduint256vault id to set entry fee for
entryFeeuint256entry fee to set

setExitFee

sets exit fees for the specified vault (id=0 sets the default fees for all vaults) id = 0 changes the default exit fee, id = n changes fees for vault n specifically

admin cannot set the exit fee to be greater than maxExitFeePercentage, which is set to be the 10% of generalConfig.feeDenominator (which represents 100%), to avoid being able to prevent users from withdrawing their assets

function setExitFee(uint256 id, uint256 exitFee) external;

Parameters

NameTypeDescription
iduint256vault id to set exit fee for
exitFeeuint256exit fee to set

setProtocolFee

sets protocol fees for the specified vault (id=0 sets the default fees for all vaults) id = 0 changes the default protocol fee, id = n changes fees for vault n specifically

admin cannot set the protocol fee to be greater than maxProtocolFeePercentage, which is set to be the 10% of generalConfig.feeDenominator (which represents 100%), to avoid being able to prevent users from depositing or withdrawing their assets with unreasonable fees

function setProtocolFee(uint256 id, uint256 protocolFee) external;

Parameters

NameTypeDescription
iduint256vault id to set protocol fee for
protocolFeeuint256protocol fee to set

setAtomWarden

sets the atomWarden address

function setAtomWarden(address atomWarden) external;

Parameters

NameTypeDescription
atomWardenaddressaddress of the new atomWarden

deployAtomWallet

deploy a given atom wallet

function deployAtomWallet(uint256 atomId) external returns (address);

Parameters

NameTypeDescription
atomIduint256vault id of atom

Returns

NameTypeDescription
<none>addressatomWallet the address of the atom wallet NOTE: deploys an ERC4337 account (atom wallet) through a BeaconProxy. Reverts if the atom vault does not exist

approve

Set the approval type for a sender to act on behalf of the receiver

function approve(address sender, ApprovalTypes approvalType) external;

Parameters

NameTypeDescription
senderaddressaddress to set approval for
approvalTypeApprovalTypestype of approval to grant (NONE = 0, DEPOSIT = 1, REDEMPTION = 2, BOTH = 3)

createAtom

Create an atom and return its vault id

function createAtom(bytes calldata atomUri) external payable returns (uint256);

Parameters

NameTypeDescription
atomUribytesatom data to create atom with

Returns

NameTypeDescription
<none>uint256id vault id of the atom NOTE: This function will revert if called with less than getAtomCost() in msg.value

batchCreateAtom

Batch create atoms and return their vault ids

function batchCreateAtom(bytes[] calldata atomUris) external payable returns (uint256[] memory);

Parameters

NameTypeDescription
atomUrisbytes[]atom data array to create atoms with

Returns

NameTypeDescription
<none>uint256[]ids vault ids array of the atoms NOTE: This function will revert if called with less than getAtomCost() * atomUris.length in msg.value

createTriple

create a triple and return its vault id

function createTriple(uint256 subjectId, uint256 predicateId, uint256 objectId) external payable returns (uint256);

Parameters

NameTypeDescription
subjectIduint256vault id of the subject atom
predicateIduint256vault id of the predicate atom
objectIduint256vault id of the object atom

Returns

NameTypeDescription
<none>uint256id vault id of the triple NOTE: This function will revert if called with less than getTripleCost() in msg.value. This function will revert if any of the atoms do not exist or if any ids are triple vaults.

batchCreateTriple

batch create triples and return their vault ids

function batchCreateTriple(uint256[] calldata subjectIds, uint256[] calldata predicateIds, uint256[] calldata objectIds)
    external
    payable
    returns (uint256[] memory);

Parameters

NameTypeDescription
subjectIdsuint256[]vault ids array of subject atoms
predicateIdsuint256[]vault ids array of predicate atoms
objectIdsuint256[]vault ids array of object atoms NOTE: This function will revert if called with less than getTripleCost() * array.length in msg.value. This function will revert if any of the atoms do not exist or if any ids are triple vaults.

depositAtom

deposit eth into an atom vault and grant ownership of 'shares' to 'reciever' *payable msg.value amount of eth to deposit

assets parameter is omitted in favor of msg.value, unlike in ERC4626

function depositAtom(address receiver, uint256 id) external payable returns (uint256);

Parameters

NameTypeDescription
receiveraddressthe address to receive the shares
iduint256the vault ID of the atom

Returns

NameTypeDescription
<none>uint256shares the amount of shares minted NOTE: this function will revert if the minimum deposit amount of eth is not met and if the vault ID does not exist/is not an atom.

depositAtomCurve

deposit eth into an atom vault and grant ownership of 'shares' to 'reciever' *payable msg.value amount of eth to deposit

assets parameter is omitted in favor of msg.value, unlike in ERC4626

function depositAtomCurve(address receiver, uint256 atomId, uint256 curveId) external payable returns (uint256);

Parameters

NameTypeDescription
receiveraddressthe address to receive the shares
atomIduint256the vault ID of the atom
curveIduint256the vault ID of the curve

Returns

NameTypeDescription
<none>uint256shares the amount of shares minted NOTE: this function will revert if the minimum deposit amount of eth is not met and if the vault ID does not exist/is not an atom.

redeemAtom

redeem assets from an atom vault

function redeemAtom(uint256 shares, address receiver, uint256 id) external returns (uint256);

Parameters

NameTypeDescription
sharesuint256the amount of shares to redeem
receiveraddressthe address to receiver the assets
iduint256the vault ID of the atom

Returns

NameTypeDescription
<none>uint256assets the amount of assets/eth withdrawn NOTE: Emergency redemptions without any fees being charged are always possible, even if the contract is paused See getRedeemAssetsAndFees for more details on the fees charged

redeemAtomCurve

redeem shares from a bonding curve atom vault for assets

function redeemAtomCurve(uint256 shares, address receiver, uint256 atomId, uint256 curveId)
    external
    returns (uint256);

Parameters

NameTypeDescription
sharesuint256the amount of shares to redeem
receiveraddressthe address to receiver the assets
atomIduint256the vault ID of the atom
curveIduint256the vault ID of the curve

Returns

NameTypeDescription
<none>uint256assets the amount of assets/eth withdrawn NOTE: Emergency redemptions without any fees being charged are always possible, even if the contract is paused See getRedeemAssetsAndFees for more details on the fees charged

depositTriple

deposits assets of underlying tokens into a triple vault and grants ownership of 'shares' to 'receiver' *payable msg.value amount of eth to deposit

assets parameter is omitted in favor of msg.value, unlike in ERC4626

function depositTriple(address receiver, uint256 id) external payable returns (uint256);

Parameters

NameTypeDescription
receiveraddressthe address to receive the shares
iduint256the vault ID of the triple

Returns

NameTypeDescription
<none>uint256shares the amount of shares minted NOTE: this function will revert if the minimum deposit amount of eth is not met and if the vault ID does not exist/is not a triple.

depositTripleCurve

deposit eth into a bonding curve triple vault and grant ownership of 'shares' to 'receiver' *payable msg.value amount of eth to deposit

assets parameter is omitted in favor of msg.value, unlike in ERC4626

function depositTripleCurve(address receiver, uint256 tripleId, uint256 curveId) external payable returns (uint256);

Parameters

NameTypeDescription
receiveraddressthe address to receive the shares
tripleIduint256the vault ID of the triple
curveIduint256the vault ID of the curve

Returns

NameTypeDescription
<none>uint256shares the amount of shares minted NOTE: this function will revert if the minimum deposit amount of eth is not met and if the vault ID does not exist/is not a triple.

redeemTriple

redeems 'shares' number of shares from the triple vault and send 'assets' eth from the contract to 'reciever' factoring in exit fees

function redeemTriple(uint256 shares, address receiver, uint256 id) external returns (uint256);

Parameters

NameTypeDescription
sharesuint256the amount of shares to redeem
receiveraddressthe address to receiver the assets
iduint256the vault ID of the triple

Returns

NameTypeDescription
<none>uint256assets the amount of assets/eth withdrawn NOTE: Emergency redemptions without any fees being charged are always possible, even if the contract is paused See getRedeemAssetsAndFees for more details on the fees charged

redeemTripleCurve

redeem shares from a bonding curve triple vault for assets

function redeemTripleCurve(uint256 shares, address receiver, uint256 tripleId, uint256 curveId)
    external
    returns (uint256);

Parameters

NameTypeDescription
sharesuint256the amount of shares to redeem
receiveraddressthe address to receiver the assets
tripleIduint256the vault ID of the triple
curveIduint256the vault ID of the curve

Returns

NameTypeDescription
<none>uint256assets the amount of assets/eth withdrawn NOTE: Emergency redemptions without any fees being charged are always possible, even if the contract is paused See getRedeemAssetsAndFees for more details on the fees charged

batchDeposit

deposit eth into multiple terms and grant ownership of 'shares' to 'reciever' *payable msg.value amount of eth to deposit works with atoms, triples, and counter-triples

function batchDeposit(address receiver, uint256[] calldata termIds, uint256[] calldata amounts)
    external
    payable
    returns (uint256[] memory);

Parameters

NameTypeDescription
receiveraddressthe address to receive the shares
termIdsuint256[]the IDs of the terms (atoms, triples, or counter-triples) to deposit into
amountsuint256[]array of the amount to deposit in each vault

Returns

NameTypeDescription
<none>uint256[]shares the amount of shares minted for each atom

batchDepositCurve

deposit eth into an atom vault and grant ownership of 'shares' to 'reciever' *payable msg.value amount of eth to deposit

function batchDepositCurve(
    address receiver,
    uint256[] calldata termIds,
    uint256[] calldata curveIds,
    uint256[] calldata amounts
) external payable returns (uint256[] memory);

Parameters

NameTypeDescription
receiveraddressthe address to receive the shares
termIdsuint256[]array of the vault IDs of the terms (atoms, triples, or counter-triples)
curveIdsuint256[]array of the vault IDs of the curves
amountsuint256[]array of the amount to deposit in each vault

Returns

NameTypeDescription
<none>uint256[]shares array of the amount of shares minted in the specified vaults

batchRedeem

redeem shares from an atom vault for assets -- works for atoms, triples and counter-triples

function batchRedeem(uint256 percentage, address receiver, uint256[] calldata ids)
    external
    returns (uint256[] memory);

Parameters

NameTypeDescription
percentageuint256the percentage of shares to redeem from each vault (i.e. 50% -> 50, 100% -> 100)
receiveraddressthe address to receiver the assets
idsuint256[]array of IDs of the term (atom, triple or counter-triple) to redeem from

Returns

NameTypeDescription
<none>uint256[]assets the amount of assets/eth withdrawn

batchRedeemCurve

redeem shares from bonding curve atom vaults for assets

function batchRedeemCurve(uint256 percentage, address receiver, uint256[] calldata termIds, uint256[] calldata curveIds)
    external
    returns (uint256[] memory);

Parameters

NameTypeDescription
percentageuint256the percentage of shares to redeem from the vaults
receiveraddressthe address to receiver the assets
termIdsuint256[]array of the IDs of the terms (atoms, triples, or counter-triples)
curveIdsuint256[]array of the IDs of the curves for each term

Returns

NameTypeDescription
<none>uint256[]assets array of the amounts of assets/eth withdrawn

getAtomCost

returns the cost of creating an atom

function getAtomCost() external view returns (uint256);

Returns

NameTypeDescription
<none>uint256atomCost the cost of creating an atom

getTripleCost

returns the cost of creating a triple

function getTripleCost() external view returns (uint256);

Returns

NameTypeDescription
<none>uint256tripleCost the cost of creating a triple

getDepositFees

returns the total fees that would be charged for depositing 'assets' into a vault

function getDepositFees(uint256 assets, uint256 id) external view returns (uint256);

Parameters

NameTypeDescription
assetsuint256amount of assets to calculate fees on
iduint256vault id to get corresponding fees for

Returns

NameTypeDescription
<none>uint256totalFees total fees that would be charged for depositing 'assets' into a vault

getDepositSharesAndFees

returns the shares for recipient and other important values when depositing 'assets' into a vault

function getDepositSharesAndFees(uint256 assets, uint256 id)
    external
    view
    returns (uint256, uint256, uint256, uint256);

Parameters

NameTypeDescription
assetsuint256amount of assets to calculate fees on (should always be msg.value - protocolFee)
iduint256vault id to get corresponding fees for

Returns

NameTypeDescription
<none>uint256totalAssetsDelta changes in vault's total assets
<none>uint256sharesForReceiver changes in vault's total shares (shares owed to receiver)
<none>uint256userAssetsAfterTotalFees amount of assets that goes towards minting shares for the receiver
<none>uint256entryFee amount of assets that would be charged for the entry fee

getRedeemAssetsAndFees

returns the assets for receiver and other important values when redeeming 'shares' from a vault

function getRedeemAssetsAndFees(uint256 shares, uint256 id)
    external
    view
    returns (uint256, uint256, uint256, uint256);

Parameters

NameTypeDescription
sharesuint256amount of shares to calculate fees on
iduint256vault id to get corresponding fees for

Returns

NameTypeDescription
<none>uint256totalUserAssets total amount of assets user would receive if redeeming 'shares', not including fees
<none>uint256assetsForReceiver amount of assets that is redeemable by the receiver
<none>uint256protocolFee amount of assets that would be sent to the protocol multisig
<none>uint256exitFee amount of assets that would be charged for the exit fee

entryFeeAmount

returns amount of assets that would be charged for the entry fee given an amount of 'assets' provided

function entryFeeAmount(uint256 assets, uint256 id) external view returns (uint256);

Parameters

NameTypeDescription
assetsuint256amount of assets to calculate fee on
iduint256vault id to get corresponding fees for

Returns

NameTypeDescription
<none>uint256feeAmount amount of assets that would be charged for the entry fee NOTE: if the vault being deposited on has a vault total shares of 0, the entry fee is not applied

exitFeeAmount

returns amount of assets that would be charged for the exit fee given an amount of 'assets' provided

function exitFeeAmount(uint256 assets, uint256 id) external view returns (uint256);

Parameters

NameTypeDescription
assetsuint256amount of assets to calculate fee on
iduint256vault id to get corresponding fees for

Returns

NameTypeDescription
<none>uint256feeAmount amount of assets that would be charged for the exit fee NOTE: if the vault being redeemed from given the shares to redeem results in a total shares after of 0, the exit fee is not applied

protocolFeeAmount

returns amount of assets that would be charged by a vault on protocol fee given amount of 'assets' provided

function protocolFeeAmount(uint256 assets, uint256 id) external view returns (uint256);

Parameters

NameTypeDescription
assetsuint256amount of assets to calculate fee on
iduint256vault id to get corresponding fees for

Returns

NameTypeDescription
<none>uint256feeAmount amount of assets that would be charged by vault on protocol fee

atomDepositsAmount

returns atom deposit given amount of 'assets' provided

function atomDepositsAmount(uint256 assets, uint256 id) external view returns (uint256);

Parameters

NameTypeDescription
assetsuint256amount of assets to calculate fee on
iduint256vault id

Returns

NameTypeDescription
<none>uint256feeAmount amount of assets that would be used as atom deposit fraction NOTE: only applies to triple vaults

currentSharePrice

returns the current share price for the given vault id

function currentSharePrice(uint256 id) external view returns (uint256);

Parameters

NameTypeDescription
iduint256vault id to get corresponding share price for

Returns

NameTypeDescription
<none>uint256price current share price for the given vault id

maxRedeem

returns max amount of shares that can be redeemed from the 'owner' balance through a redeem call

function maxRedeem(address owner, uint256 id) external view returns (uint256);

Parameters

NameTypeDescription
owneraddressaddress of the account to get max redeemable shares for
iduint256vault id to get corresponding shares for

Returns

NameTypeDescription
<none>uint256shares amount of shares that can be redeemed from the 'owner' balance through a redeem call

convertToShares

returns amount of shares that would be exchanged by vault given amount of 'assets' provided

function convertToShares(uint256 assets, uint256 id) external view returns (uint256);

Parameters

NameTypeDescription
assetsuint256amount of assets to calculate shares on
iduint256vault id to get corresponding shares for

Returns

NameTypeDescription
<none>uint256shares amount of shares that would be exchanged by vault given amount of 'assets' provided

convertToAssets

returns amount of assets that would be exchanged by vault given amount of 'shares' provided

function convertToAssets(uint256 shares, uint256 id) external view returns (uint256);

Parameters

NameTypeDescription
sharesuint256amount of shares to calculate assets on
iduint256vault id to get corresponding assets for

Returns

NameTypeDescription
<none>uint256assets amount of assets that would be exchanged by vault given amount of 'shares' provided

previewDeposit

simulates the effects of the deposited amount of 'assets' and returns the estimated amount of shares that would be minted from the deposit of assets

function previewDeposit(uint256 assets, uint256 id) external view returns (uint256);

Parameters

NameTypeDescription
assetsuint256amount of assets to calculate shares on
iduint256vault id to get corresponding shares for

Returns

NameTypeDescription
<none>uint256shares amount of shares that would be minted from the deposit of assets NOTE: this function pessimistically estimates the amount of shares that would be minted from the input amount of assets so if the vault is empty before the deposit the caller receives more shares than returned by this function, reference internal _depositIntoVault logic for details

previewRedeem

simulates the effects of the redemption of shares and returns the estimated amount of assets estimated to be returned to the receiver of the redeem

function previewRedeem(uint256 shares, uint256 id) external view returns (uint256);

Parameters

NameTypeDescription
sharesuint256amount of shares to calculate assets on
iduint256vault id to get corresponding assets for

Returns

NameTypeDescription
<none>uint256assets amount of assets estimated to be returned to the receiver

tripleHash

returns the corresponding hash for the given RDF triple, given the triple vault id

function tripleHash(uint256 id) external view returns (bytes32);

Parameters

NameTypeDescription
iduint256vault id of the triple

Returns

NameTypeDescription
<none>bytes32hash the corresponding hash for the given RDF triple NOTE: only applies to triple vault IDs as input

isTripleId

returns whether the supplied vault id is a triple

function isTripleId(uint256 id) external view returns (bool);

Parameters

NameTypeDescription
iduint256vault id to check

Returns

NameTypeDescription
<none>boolbool whether the supplied vault id is a triple

getTripleAtoms

returns the atoms that make up a triple/counter-triple

function getTripleAtoms(uint256 id) external view returns (uint256, uint256, uint256);

Parameters

NameTypeDescription
iduint256vault id of the triple/counter-triple

Returns

NameTypeDescription
<none>uint256tuple(atomIds) the atoms that make up the triple/counter-triple NOTE: only applies to triple vault IDs as input
<none>uint256
<none>uint256

tripleHashFromAtoms

returns the corresponding hash for the given RDF triple, given the atoms that make up the triple

function tripleHashFromAtoms(uint256 subjectId, uint256 predicateId, uint256 objectId)
    external
    pure
    returns (bytes32);

Parameters

NameTypeDescription
subjectIduint256the subject atom's vault id
predicateIduint256the predicate atom's vault id
objectIduint256the object atom's vault id

Returns

NameTypeDescription
<none>bytes32hash the corresponding hash for the given RDF triple based on the atom vault ids

getCounterIdFromTriple

returns the counter id from the given triple id

function getCounterIdFromTriple(uint256 id) external returns (uint256);

Parameters

NameTypeDescription
iduint256vault id of the triple

Returns

NameTypeDescription
<none>uint256counterId the counter vault id from the given triple id NOTE: only applies to triple vault IDs as input

getAtomWarden

returns the address of the atom warden

function getAtomWarden() external view returns (address);

getVaultStateForUser

returns the number of shares and assets (less fees) user has in the vault

function getVaultStateForUser(uint256 vaultId, address receiver) external view returns (uint256, uint256);

Parameters

NameTypeDescription
vaultIduint256vault id of the vault
receiveraddressaddress of the receiver

Returns

NameTypeDescription
<none>uint256shares number of shares user has in the vault
<none>uint256assets number of assets user has in the vault

getVaultStateForUserCurve

returns the number of shares and assets (less fees) user has in the vault for a specific curve

function getVaultStateForUserCurve(uint256 vaultId, uint256 curveId, address receiver)
    external
    view
    returns (uint256, uint256);

Parameters

NameTypeDescription
vaultIduint256vault id of the vault
curveIduint256curve id of the curve
receiveraddressaddress of the receiver

Returns

NameTypeDescription
<none>uint256shares number of shares user has in the vault
<none>uint256

getDepositSharesAndFeesCurve

returns the shares for recipient and other important values when depositing 'assets' into a bonding curve vault

function getDepositSharesAndFeesCurve(uint256 assets, uint256 vaultId, uint256 curveId)
    external
    view
    returns (uint256, uint256, uint256, uint256);

Parameters

NameTypeDescription
assetsuint256amount of assets to calculate fees on (should always be msg.value - protocolFee)
vaultIduint256vault id to get corresponding fees for
curveIduint256curve id to get corresponding fees for

Returns

NameTypeDescription
<none>uint256totalAssetsDelta changes in vault's total assets
<none>uint256sharesForReceiver changes in vault's total shares (shares owed to receiver)
<none>uint256userAssetsAfterTotalFees amount of assets that goes towards minting shares for the receiver
<none>uint256entryFee amount of assets that would be charged for the entry fee

getRedeemAssetsAndFeesCurve

returns the assets for receiver and other important values when redeeming 'shares' from a bonding curve vault

function getRedeemAssetsAndFeesCurve(uint256 shares, uint256 vaultId, uint256 curveId)
    external
    view
    returns (uint256, uint256, uint256, uint256);

Parameters

NameTypeDescription
sharesuint256amount of shares to calculate fees on
vaultIduint256vault id to get corresponding fees for
curveIduint256curve id to get corresponding fees for

Returns

NameTypeDescription
<none>uint256totalUserAssets total amount of assets user would receive if redeeming 'shares', not including fees
<none>uint256assetsForReceiver amount of assets that is redeemable by the receiver
<none>uint256protocolFee amount of assets that would be sent to the protocol multisig
<none>uint256exitFee amount of assets that would be charged for the exit fee

currentSharePriceCurve

returns the current share price for the given vault id and curve id

function currentSharePriceCurve(uint256 vaultId, uint256 curveId) external view returns (uint256);

Parameters

NameTypeDescription
vaultIduint256vault id to get corresponding share price for
curveIduint256curve id to get corresponding share price for

Returns

NameTypeDescription
<none>uint256price current share price for the given vault id and curve id

maxDepositCurve

returns max amount of assets that can be deposited into the vault through a deposit call for a specific curve

function maxDepositCurve(uint256 curveId) external view returns (uint256);

Parameters

NameTypeDescription
curveIduint256curve id to get corresponding max deposit for

Returns

NameTypeDescription
<none>uint256maxAssets amount of assets that can be deposited into the vault through a deposit call

maxRedeemCurve

returns max amount of shares that can be redeemed from the 'owner' balance through a redeem call for a specific curve

function maxRedeemCurve(address owner, uint256 vaultId, uint256 curveId) external view returns (uint256);

Parameters

NameTypeDescription
owneraddressaddress of the account to get max redeemable shares for
vaultIduint256vault id to get corresponding shares for
curveIduint256curve id to get corresponding shares for

Returns

NameTypeDescription
<none>uint256shares amount of shares that can be redeemed from the 'owner' balance through a redeem call

convertToSharesCurve

returns amount of shares that would be exchanged by vault given amount of 'assets' provided for a specific curve

function convertToSharesCurve(uint256 assets, uint256 vaultId, uint256 curveId) external view returns (uint256);

Parameters

NameTypeDescription
assetsuint256amount of assets to calculate shares on
vaultIduint256vault id to get corresponding shares for
curveIduint256curve id to get corresponding shares for

Returns

NameTypeDescription
<none>uint256shares amount of shares that would be exchanged by vault given amount of 'assets' provided

convertToAssetsCurve

returns amount of assets that would be exchanged by vault given amount of 'shares' provided for a specific curve

function convertToAssetsCurve(uint256 shares, uint256 vaultId, uint256 curveId) external view returns (uint256);

Parameters

NameTypeDescription
sharesuint256amount of shares to calculate assets on
vaultIduint256vault id to get corresponding assets for
curveIduint256curve id to get corresponding assets for

Returns

NameTypeDescription
<none>uint256assets amount of assets that would be exchanged by vault given amount of 'shares' provided

previewDepositCurve

simulates the effects of the deposited amount of 'assets' and returns the estimated amount of shares that would be minted from the deposit of assets for a specific curve

function previewDepositCurve(uint256 assets, uint256 vaultId, uint256 curveId) external view returns (uint256);

Parameters

NameTypeDescription
assetsuint256amount of assets to calculate shares on
vaultIduint256vault id to get corresponding shares for
curveIduint256curve id to get corresponding shares for

Returns

NameTypeDescription
<none>uint256shares amount of shares that would be minted from the deposit of assets NOTE: this function pessimistically estimates the amount of shares that would be minted from the input amount of assets so if the vault is empty before the deposit the caller receives more shares than returned by this function, reference internal _depositIntoVault logic for details

previewRedeemCurve

simulates the effects of the redemption of shares and returns the estimated amount of assets estimated to be returned to the receiver of the redeem for a specific curve

function previewRedeemCurve(uint256 shares, uint256 vaultId, uint256 curveId) external view returns (uint256);

Parameters

NameTypeDescription
sharesuint256amount of shares to calculate assets on
vaultIduint256vault id to get corresponding assets for
curveIduint256curve id to get corresponding assets for

Returns

NameTypeDescription
<none>uint256assets amount of assets estimated to be returned to the receiver

computeAtomWalletAddr

returns the Atom Wallet address for the given atom data

function computeAtomWalletAddr(uint256 id) external view returns (address);

Parameters

NameTypeDescription
iduint256vault id of the atom associated to the atom wallet

Returns

NameTypeDescription
<none>addressatomWallet the address of the atom wallet NOTE: the create2 salt is based off of the vault ID

isApprovedDeposit

Check if a sender is approved to deposit on behalf of a receiver

function isApprovedDeposit(address sender, address receiver) external view returns (bool);

Parameters

NameTypeDescription
senderaddressThe address of the sender
receiveraddressThe address of the receiver

Returns

NameTypeDescription
<none>boolbool Whether the sender is approved to deposit

isApprovedRedeem

Check if a sender is approved to redeem on behalf of a receiver

function isApprovedRedeem(address sender, address receiver) external view returns (bool);

Parameters

NameTypeDescription
senderaddressThe address of the sender
receiveraddressThe address of the receiver

Returns

NameTypeDescription
<none>boolbool Whether the sender is approved to redeem

Events

ApprovalTypeUpdated

Emitted when a receiver changes the approval type for a sender

event ApprovalTypeUpdated(address indexed sender, address indexed receiver, ApprovalTypes approvalType);

Parameters

NameTypeDescription
senderaddressaddress of the sender being approved/disapproved
receiveraddressaddress of the receiver granting/revoking approval
approvalTypeApprovalTypesthe type of approval granted (NONE = 0, DEPOSIT = 1, REDEMPTION = 2, BOTH = 3)

Deposited

Emitted upon the minting of shares in the vault by depositing assets

event Deposited(
    address indexed sender,
    address indexed receiver,
    uint256 receiverTotalSharesInVault,
    uint256 senderAssetsAfterTotalFees,
    uint256 sharesForReceiver,
    uint256 entryFee,
    uint256 vaultId,
    bool isTriple,
    bool isAtomWallet
);

Parameters

NameTypeDescription
senderaddressinitializer of the deposit
receiveraddressbeneficiary of the minted shares
receiverTotalSharesInVaultuint256total shares held by the receiver in the vault
senderAssetsAfterTotalFeesuint256total assets that go towards minting shares for the receiver
sharesForReceiveruint256total shares minted for the receiver
entryFeeuint256total fee amount collected for entering the vault
vaultIduint256vault id of the vault being deposited into
isTripleboolwhether the vault is a triple vault or not
isAtomWalletboolwhether the receiver is an atom wallet or not

DepositedCurve

event DepositedCurve(
    address indexed sender,
    address indexed receiver,
    uint256 receiverTotalSharesInVault,
    uint256 senderAssetsAfterTotalFees,
    uint256 sharesForReceiver,
    uint256 entryFee,
    uint256 vaultId,
    uint256 curveId,
    bool isTriple,
    bool isAtomWallet
);

Redeemed

Emitted upon the withdrawal of assets from the vault by redeeming shares

event Redeemed(
    address indexed sender,
    address indexed receiver,
    uint256 senderTotalSharesInVault,
    uint256 assetsForReceiver,
    uint256 sharesRedeemedBySender,
    uint256 exitFee,
    uint256 vaultId
);

Parameters

NameTypeDescription
senderaddressinitializer of the withdrawal (owner of the shares)
receiveraddressbeneficiary of the withdrawn assets (can be different from the sender)
senderTotalSharesInVaultuint256total shares held by the sender in the vault
assetsForReceiveruint256quantity of assets withdrawn by the receiver
sharesRedeemedBySenderuint256quantity of shares redeemed by the sender
exitFeeuint256total fee amount collected for exiting the vault
vaultIduint256vault id of the vault being redeemed from

RedeemedCurve

event RedeemedCurve(
    address indexed sender,
    address indexed receiver,
    uint256 senderTotalSharesInVault,
    uint256 assetsForReceiver,
    uint256 sharesRedeemedBySender,
    uint256 exitFee,
    uint256 vaultId,
    uint256 curveId
);

AtomCreated

emitted upon creation of an atom

event AtomCreated(address indexed creator, address indexed atomWallet, bytes atomData, uint256 vaultId);

Parameters

NameTypeDescription
creatoraddressaddress of the atom creator
atomWalletaddressaddress of the atom's associated abstract account
atomDatabytesthe atom's respective string
vaultIduint256the vault id of the atom

TripleCreated

emitted upon creation of a triple

event TripleCreated(address indexed creator, uint256 subjectId, uint256 predicateId, uint256 objectId, uint256 vaultId);

Parameters

NameTypeDescription
creatoraddressaddress of the triple creator
subjectIduint256the triple's respective subject atom
predicateIduint256the triple's respective predicate atom
objectIduint256the triple's respective object atom
vaultIduint256the vault id of the triple

FeesTransferred

emitted upon the transfer of fees to the protocol multisig

event FeesTransferred(address indexed sender, address indexed protocolMultisig, uint256 amount);

Parameters

NameTypeDescription
senderaddressaddress of the sender
protocolMultisigaddressaddress of the protocol multisig
amountuint256amount of fees transferred

OperationScheduled

emitted upon scheduling an operation

event OperationScheduled(bytes32 indexed operationId, bytes data, uint256 readyTime);

Parameters

NameTypeDescription
operationIdbytes32unique identifier for the operation
databytesdata to be executed
readyTimeuint256block number when the operation is ready

OperationExecuted

emitted upon executing an operation

event OperationExecuted(bytes32 indexed operationId, bytes data);

Parameters

NameTypeDescription
operationIdbytes32unique identifier for the operation
databytesdata of the operation that was executed

OperationCancelled

emitted upon cancelling an operation

event OperationCancelled(bytes32 indexed operationId, bytes data);

Parameters

NameTypeDescription
operationIdbytes32unique identifier for the operation
databytesdata of the operation that was cancelled

AdminSet

emitted upon changing the admin

event AdminSet(address indexed newAdmin, address indexed oldAdmin);

Parameters

NameTypeDescription
newAdminaddressaddress of the new admin
oldAdminaddressaddress of the old admin

protocolMultisigSet

emitted upon changing the protocol multisig

event protocolMultisigSet(address indexed newProtocolMultisig, address indexed oldProtocolMultisig);

Parameters

NameTypeDescription
newProtocolMultisigaddressaddress of the new protocol multisig
oldProtocolMultisigaddressaddress of the old protocol multisig

MinDepositSet

emitted upon changing the minimum deposit amount

event MinDepositSet(uint256 newMinDeposit, uint256 oldMinDeposit);

Parameters

NameTypeDescription
newMinDeposituint256new minimum deposit amount
oldMinDeposituint256old minimum deposit amount

MinShareSet

emitted upon changing the minimum share amount

event MinShareSet(uint256 newMinShare, uint256 oldMinShare);

Parameters

NameTypeDescription
newMinShareuint256new minimum share amount
oldMinShareuint256old minimum share amount

AtomUriMaxLengthSet

emitted upon changing the atom URI max length

event AtomUriMaxLengthSet(uint256 newAtomUriMaxLength, uint256 oldAtomUriMaxLength);

Parameters

NameTypeDescription
newAtomUriMaxLengthuint256new atom URI max length
oldAtomUriMaxLengthuint256old atom URI max length

AtomWalletInitialDepositAmountSet

emitted upon changing the atom share lock fee

event AtomWalletInitialDepositAmountSet(
    uint256 newAtomWalletInitialDepositAmount, uint256 oldAtomWalletInitialDepositAmount
);

Parameters

NameTypeDescription
newAtomWalletInitialDepositAmountuint256new atom share lock fee
oldAtomWalletInitialDepositAmountuint256old atom share lock fee

AtomCreationProtocolFeeSet

emitted upon changing the atom creation fee

event AtomCreationProtocolFeeSet(uint256 newAtomCreationProtocolFee, uint256 oldAtomCreationProtocolFee);

Parameters

NameTypeDescription
newAtomCreationProtocolFeeuint256new atom creation fee
oldAtomCreationProtocolFeeuint256old atom creation fee

TripleCreationProtocolFeeSet

emitted upon changing the triple creation fee

event TripleCreationProtocolFeeSet(uint256 newTripleCreationProtocolFee, uint256 oldTripleCreationProtocolFee);

Parameters

NameTypeDescription
newTripleCreationProtocolFeeuint256new triple creation fee
oldTripleCreationProtocolFeeuint256old triple creation fee

TotalAtomDepositsOnTripleCreationSet

emitted upon changing the atom deposit fraction on triple creation

event TotalAtomDepositsOnTripleCreationSet(
    uint256 newTotalAtomDepositsOnTripleCreation, uint256 oldTotalAtomDepositsOnTripleCreation
);

Parameters

NameTypeDescription
newTotalAtomDepositsOnTripleCreationuint256new atom deposit fraction on triple creation
oldTotalAtomDepositsOnTripleCreationuint256old atom deposit fraction on triple creation

AtomDepositFractionForTripleSet

emitted upon changing the atom deposit fraction for triples

event AtomDepositFractionForTripleSet(uint256 newAtomDepositFractionForTriple, uint256 oldAtomDepositFractionForTriple);

Parameters

NameTypeDescription
newAtomDepositFractionForTripleuint256new atom deposit fraction for triples
oldAtomDepositFractionForTripleuint256old atom deposit fraction for triples

BondingCurveConfigSet

emitted upon changing the bonding curve configuration

event BondingCurveConfigSet(
    address indexed newRegistry, uint256 newDefaultCurveId, address indexed oldRegistry, uint256 oldDefaultCurveId
);

Parameters

NameTypeDescription
newRegistryaddressaddress of the new bonding curve registry
newDefaultCurveIduint256new default curve ID
oldRegistryaddressaddress of the old bonding curve registry
oldDefaultCurveIduint256old default curve ID

EntryFeeSet

emitted upon changing the entry fee

event EntryFeeSet(uint256 id, uint256 newEntryFee, uint256 oldEntryFee);

Parameters

NameTypeDescription
iduint256vault id to set entry fee for
newEntryFeeuint256new entry fee for the vault
oldEntryFeeuint256old entry fee for the vault

ExitFeeSet

emitted upon changing the exit fee

event ExitFeeSet(uint256 id, uint256 newExitFee, uint256 oldExitFee);

Parameters

NameTypeDescription
iduint256vault id to set exit fee for
newExitFeeuint256new exit fee for the vault
oldExitFeeuint256old exit fee for the vault

ProtocolFeeSet

emitted upon changing the protocol fee

event ProtocolFeeSet(uint256 id, uint256 newProtocolFee, uint256 oldProtocolFee);

Parameters

NameTypeDescription
iduint256vault id to set protocol fee for
newProtocolFeeuint256new protocol fee for the vault
oldProtocolFeeuint256old protocol fee for the vault

AtomWardenSet

emitted upon changing the atomWarden

event AtomWardenSet(address indexed newAtomWarden, address indexed oldAtomWarden);

Parameters

NameTypeDescription
newAtomWardenaddressaddress of the new atomWarden
oldAtomWardenaddressaddress of the old atomWarden

AtomWalletDeployed

emitted upon deploying an atom wallet

event AtomWalletDeployed(uint256 indexed vaultId, address indexed atomWallet);

Parameters

NameTypeDescription
vaultIduint256vault id of the atom
atomWalletaddressaddress of the atom wallet

SharePriceChanged

emitted upon changing the share price of a term base vault

event SharePriceChanged(uint256 indexed termId, uint256 newSharePrice, uint256 totalAssets, uint256 totalShares);

Parameters

NameTypeDescription
termIduint256id of the atom, triple or counter triple
newSharePriceuint256new share price of the vault
totalAssetsuint256new total assets in vault
totalSharesuint256new total shares in vault

SharePriceChangedCurve

emitted upon changing the share price of a curve vault

event SharePriceChangedCurve(
    uint256 indexed termId, uint256 indexed curveId, uint256 newSharePrice, uint256 totalAssets, uint256 totalShares
);

Parameters

NameTypeDescription
termIduint256id of the atom, triple or counter triple
curveIduint256curve id of the curve
newSharePriceuint256new share price of the curve vault
totalAssetsuint256new total assets in vault
totalSharesuint256new total shares in vault

Structs

GeneralConfig

General configuration struct

struct GeneralConfig {
    address admin;
    address protocolMultisig;
    uint256 feeDenominator;
    uint256 minDeposit;
    uint256 minShare;
    uint256 atomUriMaxLength;
    uint256 decimalPrecision;
    uint256 minDelay;
}

BondingCurveConfig

struct BondingCurveConfig {
    address registry;
    uint256 defaultCurveId;
}

AtomConfig

Atom configuration struct

struct AtomConfig {
    uint256 atomWalletInitialDepositAmount;
    uint256 atomCreationProtocolFee;
}

TripleConfig

Triple configuration struct

struct TripleConfig {
    uint256 tripleCreationProtocolFee;
    uint256 totalAtomDepositsOnTripleCreation;
    uint256 atomDepositFractionForTriple;
}

WalletConfig

Atom wallet configuration struct

struct WalletConfig {
    IPermit2 permit2;
    address entryPoint;
    address atomWarden;
    address atomWalletBeacon;
}

VaultState

Vault state struct

struct VaultState {
    uint256 totalAssets;
    uint256 totalShares;
    mapping(address account => uint256 balance) balanceOf;
}

VaultFees

Vault fees struct

struct VaultFees {
    uint256 entryFee;
    uint256 exitFee;
    uint256 protocolFee;
}

Timelock

Timelock struct

struct Timelock {
    bytes data;
    uint256 readyTime;
    bool executed;
}

Enums

ApprovalTypes

enum ApprovalTypes {
    NONE,
    DEPOSIT,
    REDEMPTION,
    BOTH
}

IPermit2

Git Source

Functions

permitTransferFrom

Consume a permit2 message and transfer tokens

function permitTransferFrom(
    PermitTransferFrom calldata permit,
    SignatureTransferDetails calldata transferDetails,
    address owner,
    bytes calldata signature
) external;

Parameters

NameTypeDescription
permitPermitTransferFromThe permit message
transferDetailsSignatureTransferDetailsDetails for the transfer
owneraddressThe owner of the tokens
signaturebytesThe signature for the permit message

Structs

TokenPermissions

Token and amount in a permit message

struct TokenPermissions {
    IERC20 token;
    uint256 amount;
}

PermitTransferFrom

The permit2 message

struct PermitTransferFrom {
    TokenPermissions permitted;
    uint256 nonce;
    uint256 deadline;
}

SignatureTransferDetails

Transfer details for permitTransferFrom()

struct SignatureTransferDetails {
    address to;
    uint256 requestedAmount;
}

Contents

Errors

Git Source

Author: 0xIntuition

Library containing all custom errors detailing cases where the Intuition Protocol may revert.

Errors

EthMultiVault_AdminOnly

error EthMultiVault_AdminOnly();

EthMultiVault_ArraysNotSameLength

error EthMultiVault_ArraysNotSameLength();

EthMultiVault_AtomDoesNotExist

error EthMultiVault_AtomDoesNotExist(uint256 atomId);

EthMultiVault_AtomExists

error EthMultiVault_AtomExists(bytes atomUri, uint256 atomId);

EthMultiVault_AtomUriTooLong

error EthMultiVault_AtomUriTooLong();

EthMultiVault_BurnFromZeroAddress

error EthMultiVault_BurnFromZeroAddress();

EthMultiVault_BurnInsufficientBalance

error EthMultiVault_BurnInsufficientBalance();

EthMultiVault_CannotApproveOrRevokeSelf

error EthMultiVault_CannotApproveOrRevokeSelf();

EthMultiVault_DeployAccountFailed

error EthMultiVault_DeployAccountFailed();

EthMultiVault_DepositOrWithdrawZeroShares

error EthMultiVault_DepositOrWithdrawZeroShares();

EthMultiVault_DepositExceedsMaxAssets

error EthMultiVault_DepositExceedsMaxAssets();

EthMultiVault_HasCounterStake

error EthMultiVault_HasCounterStake();

EthMultiVault_InsufficientBalance

error EthMultiVault_InsufficientBalance();

EthMultiVault_InsufficientDepositAmountToCoverFees

error EthMultiVault_InsufficientDepositAmountToCoverFees();

EthMultiVault_InsufficientRemainingSharesInVault

error EthMultiVault_InsufficientRemainingSharesInVault(uint256 remainingShares);

EthMultiVault_InsufficientSharesInVault

error EthMultiVault_InsufficientSharesInVault();

EthMultiVault_InvalidAtomDepositFractionForTriple

error EthMultiVault_InvalidAtomDepositFractionForTriple();

EthMultiVault_InvalidEntryFee

error EthMultiVault_InvalidEntryFee();

EthMultiVault_InvalidExitFee

error EthMultiVault_InvalidExitFee();

EthMultiVault_InvalidProtocolFee

error EthMultiVault_InvalidProtocolFee();

EthMultiVault_MinimumDeposit

error EthMultiVault_MinimumDeposit();

EthMultiVault_OperationAlreadyExecuted

error EthMultiVault_OperationAlreadyExecuted();

EthMultiVault_OperationAlreadyScheduled

error EthMultiVault_OperationAlreadyScheduled();

EthMultiVault_OperationNotScheduled

error EthMultiVault_OperationNotScheduled();

EthMultiVault_ReceiveNotAllowed

error EthMultiVault_ReceiveNotAllowed();

EthMultiVault_SenderNotApproved

error EthMultiVault_SenderNotApproved();

EthMultiVault_RedeemerNotApproved

error EthMultiVault_RedeemerNotApproved();

EthMultiVault_TimelockNotExpired

error EthMultiVault_TimelockNotExpired();

EthMultiVault_TransferFailed

error EthMultiVault_TransferFailed();

EthMultiVault_TripleExists

error EthMultiVault_TripleExists(uint256 subjectId, uint256 predicateId, uint256 objectId);

EthMultiVault_VaultDoesNotExist

error EthMultiVault_VaultDoesNotExist();

EthMultiVault_VaultIsTriple

error EthMultiVault_VaultIsTriple(uint256 vaultId);

EthMultiVault_VaultNotAtom

error EthMultiVault_VaultNotAtom();

EthMultiVault_VaultNotTriple

error EthMultiVault_VaultNotTriple();

EthMultiVault_InvalidRegistry

error EthMultiVault_InvalidRegistry();

AtomWallet_InvalidCallDataLength

error AtomWallet_InvalidCallDataLength();

AtomWallet_InvalidSignature

error AtomWallet_InvalidSignature();

AtomWallet_InvalidSignatureLength

error AtomWallet_InvalidSignatureLength(uint256 length);

AtomWallet_InvalidSignatureS

error AtomWallet_InvalidSignatureS(bytes32 s);

AtomWallet_OnlyOwner

error AtomWallet_OnlyOwner();

AtomWallet_OnlyOwnerOrEntryPoint

error AtomWallet_OnlyOwnerOrEntryPoint();

AtomWallet_WrongArrayLengths

error AtomWallet_WrongArrayLengths();

CustomMulticall3_InsufficientValue

error CustomMulticall3_InsufficientValue();

CustomMulticall3_InvalidAtomIdsLength

error CustomMulticall3_InvalidAtomIdsLength();

CustomMulticall3_InvalidAtomUrisLength

error CustomMulticall3_InvalidAtomUrisLength();

CustomMulticall3_InvalidEthMultiVaultAddress

error CustomMulticall3_InvalidEthMultiVaultAddress();

CustomMulticall3_InvalidValue

error CustomMulticall3_InvalidValue();

CustomMulticall3_InvalidValuesLength

error CustomMulticall3_InvalidValuesLength();

CustomMulticall3_ZeroLengthArray

error CustomMulticall3_ZeroLengthArray();

Attestoor_DeployAttestoorFailed

error Attestoor_DeployAttestoorFailed();

Attestoor_EmptyAttestorsArray

error Attestoor_EmptyAttestorsArray();

Attestoor_InsufficientValue

error Attestoor_InsufficientValue();

Attestoor_InvalidEthMultiVaultAddress

error Attestoor_InvalidEthMultiVaultAddress();

Attestoor_NotAWhitelistedAttestor

error Attestoor_NotAWhitelistedAttestor();

Attestoor_SharesCannotBeRedeeemed

error Attestoor_SharesCannotBeRedeeemed();

Attestoor_WrongArrayLengths

error Attestoor_WrongArrayLengths();

BondingCurveRegistry_CurveAlreadyExists

error BondingCurveRegistry_CurveAlreadyExists();

BondingCurveRegistry_CurveNameNotUnique

error BondingCurveRegistry_CurveNameNotUnique();

BondingCurveRegistry_OnlyOwner

error BondingCurveRegistry_OnlyOwner();

BondingCurveRegistry_RequiresOwner

error BondingCurveRegistry_RequiresOwner();

BaseCurve_EmptyStringNotAllowed

error BaseCurve_EmptyStringNotAllowed();

AtomWallet

Git Source

Inherits: Initializable, BaseAccount, Ownable2StepUpgradeable, ReentrancyGuardUpgradeable

Author: 0xIntuition

Core contract of the Intuition protocol. This contract is an abstract account associated with a corresponding atom.

State Variables

ethMultiVault

The EthMultiVault contract address

IEthMultiVault public ethMultiVault;

isClaimed

The flag to indicate if the wallet's ownership has been claimed by the user

bool public isClaimed;

AtomWalletOwnerStorageLocation

The storage slot for the AtomWallet owner

bytes32 private constant AtomWalletOwnerStorageLocation =
    0x9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c199300;

AtomWalletPendingOwnerStorageLocation

The storage slot for the AtomWallet pending owner

bytes32 private constant AtomWalletPendingOwnerStorageLocation =
    0x237e158222e3e6968b72b9db0d8043aacf074ad9f650f0d1606b4d82ee432c00;

_entryPoint

The entry point contract address

IEntryPoint private _entryPoint;

__gap

Gap for upgrade safety

uint256[50] private __gap;

Functions

onlyOwnerOrEntryPoint

Modifier to allow only the owner or entry point to call a function

modifier onlyOwnerOrEntryPoint();

init

Initialize the AtomWallet contract

function init(IEntryPoint anEntryPoint, IEthMultiVault _ethMultiVault) external initializer;

Parameters

NameTypeDescription
anEntryPointIEntryPointthe entry point contract address
_ethMultiVaultIEthMultiVaultthe EthMultiVault contract address

receive

receive() external payable;

execute

function execute(address dest, uint256 value, bytes calldata func)
    external
    payable
    onlyOwnerOrEntryPoint
    nonReentrant;

Parameters

NameTypeDescription
destaddressthe target address
valueuint256the value to send
funcbytesthe function call data

executeBatch

Execute a sequence (batch) of transactions

function executeBatch(address[] calldata dest, uint256[] calldata values, bytes[] calldata func)
    external
    payable
    onlyOwnerOrEntryPoint
    nonReentrant;

Parameters

NameTypeDescription
destaddress[]the target addresses array
valuesuint256[]
funcbytes[]the function call data array

addDeposit

Add deposit to the account in the entry point contract

function addDeposit() public payable;

withdrawDepositTo

Withdraws value from the account's deposit

function withdrawDepositTo(address payable withdrawAddress, uint256 amount) public;

Parameters

NameTypeDescription
withdrawAddressaddress payabletarget to send to
amountuint256to withdraw

transferOwnership

Initiates the ownership transfer over the wallet to a new owner.

function transferOwnership(address newOwner) public override onlyOwner;

Parameters

NameTypeDescription
newOwneraddressthe new owner of the wallet (becomes the pending owner) NOTE: Overrides the transferOwnership function of Ownable2StepUpgradeable

acceptOwnership

The new owner accepts the ownership over the wallet. If the wallet's ownership is being accepted by the user, the wallet is considered claimed. Once claimed, wallet is considered owned by the user and this action cannot be undone. NOTE: Overrides the acceptOwnership function of Ownable2StepUpgradeable

function acceptOwnership() public override;

getDeposit

Returns the deposit of the account in the entry point contract

function getDeposit() public view returns (uint256);

entryPoint

Get the entry point contract address

function entryPoint() public view virtual override returns (IEntryPoint);

Returns

NameTypeDescription
<none>IEntryPointthe entry point contract address NOTE: Overrides the entryPoint function of BaseAccount

owner

Returns the owner of the wallet. If the wallet has been claimed, the owner is the user. Otherwise, the owner is the atomWarden.

function owner() public view override returns (address);

Returns

NameTypeDescription
<none>addressthe owner of the wallet NOTE: Overrides the owner function of OwnableUpgradeable

_validateSignature

Validate the signature of the user operation

function _validateSignature(UserOperation calldata userOp, bytes32 userOpHash)
    internal
    virtual
    override
    returns (uint256 validationData);

Parameters

NameTypeDescription
userOpUserOperationthe user operation
userOpHashbytes32the hash of the user operation

Returns

NameTypeDescription
validationDatauint256the validation data (0 if successful) NOTE: Implements the template method of BaseAccount

_call

An internal method that calls a target address with value and data

function _call(address target, uint256 value, bytes memory data) internal;

Parameters

NameTypeDescription
targetaddressthe target address
valueuint256the value to send
databytesthe function call data

extractValidUntilAndValidAfter

Extract the validUntil and validAfter from the call data

function extractValidUntilAndValidAfter(bytes calldata callData)
    internal
    pure
    returns (uint256 validUntil, uint256 validAfter, bytes memory actualCallData);

Parameters

NameTypeDescription
callDatabytesthe call data

Returns

NameTypeDescription
validUntiluint256the valid until timestamp
validAfteruint256the valid after timestamp
actualCallDatabytesthe actual call data of the user operation

_getAtomWalletOwnerStorage

Get the storage slot for the AtomWallet contract owner

function _getAtomWalletOwnerStorage() private pure returns (OwnableStorage storage $);

Returns

NameTypeDescription
$OwnableStoragethe storage slot

_getAtomWalletPendingOwnerStorage

Get the storage slot for the AtomWallet contract pending owner

function _getAtomWalletPendingOwnerStorage() private pure returns (Ownable2StepStorage storage $);

Returns

NameTypeDescription
$Ownable2StepStoragethe storage slot

BaseCurve

Git Source

Inherits: IBaseCurve

Author: 0xIntuition

Abstract contract for a bonding curve. Defines the interface for converting assets to shares and vice versa.

This contract is designed to be inherited by other bonding curve contracts, providing a common interface for converting between assets and shares.

These curves handle the pure mathematical relationship for share price. Pool ratio adjustments (such as accomodating for the effect of fees, supply burn, airdrops, etc) are handled by the EthMultiVault instead of the curves themselves.

State Variables

name

The name of the curve

string public name;

Functions

constructor

Construct the curve with a unique name

constructor(string memory _name);

Parameters

NameTypeDescription
_namestringUnique name for the curve

maxShares

The maximum number of shares that this curve can handle without overflowing.

Checked by the EthMultiVault before transacting

function maxShares() external view virtual returns (uint256);

maxAssets

The maximum number of assets that this curve can handle without overflowing.

Checked by the EthMultiVault before transacting

function maxAssets() external view virtual returns (uint256);

previewDeposit

Preview how many shares would be minted for a deposit of assets

function previewDeposit(uint256 assets, uint256 totalAssets, uint256 totalShares)
    external
    view
    virtual
    returns (uint256 shares);

Parameters

NameTypeDescription
assetsuint256Quantity of assets to deposit
totalAssetsuint256Total quantity of assets already staked into the curve
totalSharesuint256Total quantity of shares already awarded by the curve

Returns

NameTypeDescription
sharesuint256The number of shares that would be minted

previewMint

Preview how many assets would be required to mint a specific amount of shares

function previewMint(uint256 shares, uint256 totalShares, uint256 totalAssets)
    external
    view
    virtual
    returns (uint256 assets);

Parameters

NameTypeDescription
sharesuint256Quantity of shares to mint
totalSharesuint256Total quantity of shares already awarded by the curve
totalAssetsuint256Total quantity of assets already staked into the curve

Returns

NameTypeDescription
assetsuint256The number of assets that would be required to mint the shares

previewWithdraw

Preview how many shares would be redeemed for a withdrawal of assets

function previewWithdraw(uint256 assets, uint256 totalAssets, uint256 totalShares)
    external
    view
    virtual
    returns (uint256 shares);

Parameters

NameTypeDescription
assetsuint256Quantity of assets to withdraw
totalAssetsuint256Total quantity of assets already staked into the curve
totalSharesuint256Total quantity of shares already awarded by the curve

Returns

NameTypeDescription
sharesuint256The number of shares that would need to be redeemed

previewRedeem

Preview how many assets would be returned for burning a specific amount of shares

function previewRedeem(uint256 shares, uint256 totalShares, uint256 totalAssets)
    external
    view
    virtual
    returns (uint256 assets);

Parameters

NameTypeDescription
sharesuint256Quantity of shares to burn
totalSharesuint256Total quantity of shares already awarded by the curve
totalAssetsuint256Total quantity of assets already staked into the curve

Returns

NameTypeDescription
assetsuint256The number of assets that would be returned

convertToShares

Convert assets to shares at a specific point on the curve

function convertToShares(uint256 assets, uint256 totalAssets, uint256 totalShares)
    external
    view
    virtual
    returns (uint256 shares);

Parameters

NameTypeDescription
assetsuint256Quantity of assets to convert to shares
totalAssetsuint256Total quantity of assets already staked into the curve
totalSharesuint256Total quantity of shares already awarded by the curve

Returns

NameTypeDescription
sharesuint256The number of shares equivalent to the given assets

convertToAssets

Convert shares to assets at a specific point on the curve

function convertToAssets(uint256 shares, uint256 totalShares, uint256 totalAssets)
    external
    view
    virtual
    returns (uint256 assets);

Parameters

NameTypeDescription
sharesuint256Quantity of shares to convert to assets
totalSharesuint256Total quantity of shares already awarded by the curve
totalAssetsuint256Total quantity of assets already staked into the curve

Returns

NameTypeDescription
assetsuint256The number of assets equivalent to the given shares

currentPrice

Get the current price of a share

function currentPrice(uint256 totalShares) public view virtual returns (uint256 sharePrice);

Parameters

NameTypeDescription
totalSharesuint256Total quantity of shares already awarded by the curve

Returns

NameTypeDescription
sharePriceuint256The current price of a share, scaled by 1e18

BondingCurveRegistry

Git Source

Inherits: IBondingCurveRegistry

Author: 0xIntuition

Registry contract for the Intuition protocol Bonding Curves. Routes access to the curves associated with atoms & triples. Does not maintain any economic state -- this merely performs computations based on the provided economic state.

An administrator may add new bonding curves to this registry, including those submitted by community members, once they are verified to be safe, and conform to the BaseCurve interface. The EthMultiVault supports a growing registry of curves, with each curve supplying a new "vault" for each term (atom or triple).

The registry is responsible for interacting with the curves, to fetch the mathematical computations given the provided economic state and the desired curve implementation. You can think of the registry as a concierge the EthMultiVault uses to access various economic incentive patterns.

State Variables

count

uint256 public count;

curveAddresses

mapping(uint256 => address) public curveAddresses;

curveIds

mapping(address => uint256) public curveIds;

registeredCurveNames

mapping(string => bool) public registeredCurveNames;

admin

address public admin;

Functions

constructor

Constructor for the BondingCurveRegistry contract

constructor(address _admin);

Parameters

NameTypeDescription
_adminaddressAddress who may add curves to the registry

addBondingCurve

Add a new bonding curve to the registry

function addBondingCurve(address bondingCurve) external;

Parameters

NameTypeDescription
bondingCurveaddressAddress of the new bonding curve

transferOwnership

Transfer the admin role to a new address

function transferOwnership(address newOwner) external;

Parameters

NameTypeDescription
newOwneraddressThe new admin address

previewDeposit

Preview how many shares would be minted for a deposit of assets

function previewDeposit(uint256 assets, uint256 totalAssets, uint256 totalShares, uint256 id)
    external
    view
    returns (uint256 shares);

Parameters

NameTypeDescription
assetsuint256Quantity of assets to deposit
totalAssetsuint256Total quantity of assets already staked into the curve
totalSharesuint256Total quantity of shares already awarded by the curve
iduint256Curve ID to use for the calculation

Returns

NameTypeDescription
sharesuint256The number of shares that would be minted

previewRedeem

Preview how many assets would be returned for burning a specific amount of shares

function previewRedeem(uint256 shares, uint256 totalShares, uint256 totalAssets, uint256 id)
    external
    view
    returns (uint256 assets);

Parameters

NameTypeDescription
sharesuint256Quantity of shares to burn
totalSharesuint256Total quantity of shares already awarded by the curve
totalAssetsuint256Total quantity of assets already staked into the curve
iduint256Curve ID to use for the calculation

Returns

NameTypeDescription
assetsuint256The number of assets that would be returned

previewWithdraw

Preview how many shares would be redeemed for a withdrawal of assets

function previewWithdraw(uint256 assets, uint256 totalAssets, uint256 totalShares, uint256 id)
    external
    view
    returns (uint256 shares);

Parameters

NameTypeDescription
assetsuint256Quantity of assets to withdraw
totalAssetsuint256Total quantity of assets already staked into the curve
totalSharesuint256Total quantity of shares already awarded by the curve
iduint256Curve ID to use for the calculation

Returns

NameTypeDescription
sharesuint256The number of shares that would need to be redeemed

previewMint

Preview how many assets would be required to mint a specific amount of shares

function previewMint(uint256 shares, uint256 totalShares, uint256 totalAssets, uint256 id)
    external
    view
    returns (uint256 assets);

Parameters

NameTypeDescription
sharesuint256Quantity of shares to mint
totalSharesuint256Total quantity of shares already awarded by the curve
totalAssetsuint256Total quantity of assets already staked into the curve
iduint256Curve ID to use for the calculation

Returns

NameTypeDescription
assetsuint256The number of assets that would be required to mint the shares

convertToShares

Convert assets to shares at a specific point on the curve

function convertToShares(uint256 assets, uint256 totalAssets, uint256 totalShares, uint256 id)
    external
    view
    returns (uint256 shares);

Parameters

NameTypeDescription
assetsuint256Quantity of assets to convert to shares
totalAssetsuint256Total quantity of assets already staked into the curve
totalSharesuint256Total quantity of shares already awarded by the curve
iduint256Curve ID to use for the calculation

Returns

NameTypeDescription
sharesuint256The number of shares equivalent to the given assets

convertToAssets

Convert shares to assets at a specific point on the curve

function convertToAssets(uint256 shares, uint256 totalShares, uint256 totalAssets, uint256 id)
    external
    view
    returns (uint256 assets);

Parameters

NameTypeDescription
sharesuint256Quantity of shares to convert to assets
totalSharesuint256Total quantity of shares already awarded by the curve
totalAssetsuint256Total quantity of assets already staked into the curve
iduint256Curve ID to use for the calculation

Returns

NameTypeDescription
assetsuint256The number of assets equivalent to the given shares

currentPrice

Get the current price of a share

function currentPrice(uint256 totalShares, uint256 id) external view returns (uint256 sharePrice);

Parameters

NameTypeDescription
totalSharesuint256Total quantity of shares already awarded by the curve
iduint256Curve ID to use for the calculation

Returns

NameTypeDescription
sharePriceuint256The current price of a share

getCurveName

Get the name of a curve

function getCurveName(uint256 id) external view returns (string memory name);

Parameters

NameTypeDescription
iduint256Curve ID to query

Returns

NameTypeDescription
namestringThe name of the curve

getCurveMaxShares

Get the maximum number of shares a curve can handle. Curves compute this ceiling based on their constructor arguments, to avoid overflow.

function getCurveMaxShares(uint256 id) external view returns (uint256 maxShares);

Parameters

NameTypeDescription
iduint256Curve ID to query

Returns

NameTypeDescription
maxSharesuint256The maximum number of shares

getCurveMaxAssets

Get the maximum number of assets a curve can handle. Curves compute this ceiling based on their constructor arguments, to avoid overflow.

function getCurveMaxAssets(uint256 id) external view returns (uint256 maxAssets);

Parameters

NameTypeDescription
iduint256Curve ID to query

Returns

NameTypeDescription
maxAssetsuint256The maximum number of assets

Events

BondingCurveAdded

Emitted when a new curve is added to the registry

event BondingCurveAdded(uint256 indexed curveId, address indexed curveAddress, string indexed curveName);

Parameters

NameTypeDescription
curveIduint256The ID of the curve
curveAddressaddressThe address of the curve
curveNamestringThe name of the curve

OwnershipTransferred

Emitted when the admin role is transferred

event OwnershipTransferred(address indexed oldAdmin, address indexed newAdmin);

Parameters

NameTypeDescription
oldAdminaddressThe previous admin address
newAdminaddressThe new admin address

EthMultiVault

Git Source

Inherits: IEthMultiVault, Initializable, ReentrancyGuardUpgradeable, PausableUpgradeable

Author: 0xIntuition

Core contract of the Intuition protocol. Manages the creation and management of vaults associated with atoms & triples.

A sophisticated vault management system that implements a dual-layer semantic data structure through "atoms" and "triples", reminiscent of RDF (Resource Description Framework) concepts.

Core protocol component managing the relationship between semantic data structures and their economic representations through vault mechanics. Implements ERC4626-style accounting with progressive bonding curves.

Key Components:

  1. Vault Management
  • ETH deposits/withdrawals through ERC4626-style vault accounting
  • Progressive bonding curves for price discovery
  • Supports both standard pro-rata vaults and curve-specific vaults, for backwards compatibility.
  1. Semantic Structure
  • Atoms: Base-level vaults representing individual semantic units
  • Triples: Composite vaults linking three atoms in subject-predicate-object relationships
  • Each vault type maintains independent state and fee structures
  1. Security Features
  • Timelocked admin operations
  • Reentrancy protection
  • Pausable functionality
  • Granular fee controls with maximum caps
  • Approval system for delegated deposits
  1. Smart Account Integration
  • Deploys ERC4337-compatible atom wallets
  • BeaconProxy pattern for upgradeable wallet implementations
  • Maintains initialization deposits for wallet operations
  1. Fee Structure
  • Entry, exit, and protocol fees
  • Configurable per vault
  • Separate fee structures for atom/triple creation
  • Proportional deposit distribution for triple-related operations

## Please note: This implementation of the EthMultiVault is messy for a reason. We wanted to keep all of the audited code in place, while also enabling users to interact with Bonding Curve vaults. For this reason, there are separate functions for all Bonding Curve related activity. While this bloats the code size, it ensures that users can still use the audited pathways in the code if they wish, while also enabling them to engage in more economically exciting activities like the Progressive Curve or Offset Curve.

The V2 of this contract will merge these pathways into one, providing a cleaner and more straightforward interface for depositing and redeeming.

State Variables

SET_ADMIN

bytes32 public constant SET_ADMIN = keccak256("setAdmin");

SET_EXIT_FEE

bytes32 public constant SET_EXIT_FEE = keccak256("setExitFee");

generalConfig

Configuration structs

GeneralConfig public generalConfig;

atomConfig

AtomConfig public atomConfig;

tripleConfig

TripleConfig public tripleConfig;

walletConfig

WalletConfig public walletConfig;

count

ID of the last vault to be created

uint256 public count;

vaults

Mapping of vault ID to vault state

mapping(uint256 vaultId => VaultState vaultState) public vaults;

vaultFees

Mapping of vault ID to vault fees

mapping(uint256 vaultId => VaultFees vaultFees) public vaultFees;

approvals

Mapping of receiver to sender to determine if a sender is allowed to deposit assets on behalf of a receiver

mapping(address receiver => mapping(address sender => uint8 approvalType)) public approvals;

atoms

RDF (Resource Description Framework)

mapping(uint256 atomId => bytes atomData) public atoms;

atomsByHash

mapping(bytes32 atomHash => uint256 atomId) public atomsByHash;

triples

mapping(uint256 tripleId => uint256[3] tripleAtomIds) public triples;

triplesByHash

mapping(bytes32 tripleHash => uint256 tripleId) public triplesByHash;

isTriple

mapping(uint256 vaultId => bool isTriple) public isTriple;

timelocks

Timelock mapping (operation hash -> timelock struct)

mapping(bytes32 operationHash => Timelock timelock) public timelocks;

bondingCurveVaults

Bonding Curve Vaults (termId -> curveId -> vaultState)

mapping(uint256 vaultId => mapping(uint256 curveId => VaultState vaultState)) public bondingCurveVaults;

bondingCurveConfig

Bonding Curve Configurations

BondingCurveConfig public bondingCurveConfig;

__gap

Gap for upgrade safety

uint256[47] private __gap;

Functions

onlyAdmin

Modifier to restrict a function to the admin

modifier onlyAdmin();

init

Initializes the EthMultiVault contract

This function is called only once (during contract deployment)

function init(
    GeneralConfig memory _generalConfig,
    AtomConfig memory _atomConfig,
    TripleConfig memory _tripleConfig,
    WalletConfig memory _walletConfig,
    VaultFees memory _defaultVaultFees,
    BondingCurveConfig memory _bondingCurveConfig
) external initializer;

Parameters

NameTypeDescription
_generalConfigGeneralConfigGeneral configuration struct
_atomConfigAtomConfigAtom configuration struct
_tripleConfigTripleConfigTriple configuration struct
_walletConfigWalletConfigWallet configuration struct
_defaultVaultFeesVaultFeesDefault vault fees struct
_bondingCurveConfigBondingCurveConfig

reinitialize

Reinitializes the EthMultiVault contract during an upgrade

This function can only be called once during a version upgrade

function reinitialize(BondingCurveConfig memory _bondingCurveConfig) external reinitializer(2);

Parameters

NameTypeDescription
_bondingCurveConfigBondingCurveConfigBonding curve configuration struct

constructor

Security measure for upgradeable contracts

Disables initializers on implementation contract to prevent direct initialization

(Security) Prevents attackers from initializing the implementation contract directly

constructor();

receive

contract does not accept ETH donations

receive() external payable;

fallback

fallback function to decompress the calldata and call the appropriate function

fallback() external payable;

pause

pauses the pausable contract methods

function pause() external onlyAdmin;

unpause

unpauses the pausable contract methods

function unpause() external onlyAdmin;

scheduleOperation

schedule an operation to be executed after a delay

function scheduleOperation(bytes32 operationId, bytes calldata data) external onlyAdmin;

Parameters

NameTypeDescription
operationIdbytes32unique identifier for the operation
databytesdata to be executed

cancelOperation

cancel a scheduled operation

function cancelOperation(bytes32 operationId, bytes calldata data) external onlyAdmin;

Parameters

NameTypeDescription
operationIdbytes32unique identifier for the operation
databytesdata of the operation to be cancelled

setAdmin

Requires new admin to 'confirm' the timelocked operation

set admin

function setAdmin(address admin) external;

Parameters

NameTypeDescription
adminaddressaddress of the new admin

setProtocolMultisig

set protocol multisig

function setProtocolMultisig(address protocolMultisig) external onlyAdmin;

Parameters

NameTypeDescription
protocolMultisigaddressaddress of the new protocol multisig

setMinDeposit

sets the minimum deposit amount for atoms and triples

function setMinDeposit(uint256 minDeposit) external onlyAdmin;

Parameters

NameTypeDescription
minDeposituint256new minimum deposit amount

setMinShare

sets the minimum share amount for atoms and triples

function setMinShare(uint256 minShare) external onlyAdmin;

Parameters

NameTypeDescription
minShareuint256new minimum share amount

setAtomUriMaxLength

sets the atom URI max length

function setAtomUriMaxLength(uint256 atomUriMaxLength) external onlyAdmin;

Parameters

NameTypeDescription
atomUriMaxLengthuint256new atom URI max length

setAtomWalletInitialDepositAmount

sets the atom share lock fee

function setAtomWalletInitialDepositAmount(uint256 atomWalletInitialDepositAmount) external onlyAdmin;

Parameters

NameTypeDescription
atomWalletInitialDepositAmountuint256new atom share lock fee

setAtomCreationProtocolFee

sets the atom creation fee

function setAtomCreationProtocolFee(uint256 atomCreationProtocolFee) external onlyAdmin;

Parameters

NameTypeDescription
atomCreationProtocolFeeuint256new atom creation fee

setTripleCreationProtocolFee

sets fee charged in wei when creating a triple to protocol multisig

function setTripleCreationProtocolFee(uint256 tripleCreationProtocolFee) external onlyAdmin;

Parameters

NameTypeDescription
tripleCreationProtocolFeeuint256new fee in wei

setTotalAtomDepositsOnTripleCreation

sets the atom deposit on triple creation used to increase the amount of assets in the underlying atom vaults on triple creation

function setTotalAtomDepositsOnTripleCreation(uint256 totalAtomDepositsOnTripleCreation) external onlyAdmin;

Parameters

NameTypeDescription
totalAtomDepositsOnTripleCreationuint256new atom deposit on triple creation

setAtomDepositFractionForTriple

sets the atom deposit percentage for atoms used in triples (number to be divided by generalConfig.feeDenominator)

function setAtomDepositFractionForTriple(uint256 atomDepositFractionForTriple) external onlyAdmin;

Parameters

NameTypeDescription
atomDepositFractionForTripleuint256new atom deposit percentage

setEntryFee

sets entry fees for the specified vault (id=0 sets the default fees for all vaults) id = 0 changes the default entry fee, id = n changes fees for vault n specifically

admin cannot set the entry fee to be greater than maxEntryFeePercentage, which is set to be the 10% of generalConfig.feeDenominator (which represents 100%), to avoid being able to prevent users from depositing assets with unreasonable fees

function setEntryFee(uint256 id, uint256 entryFee) external onlyAdmin;

Parameters

NameTypeDescription
iduint256vault id to set entry fee for
entryFeeuint256entry fee to set

setExitFee

sets exit fees for the specified vault (id=0 sets the default fees for all vaults) id = 0 changes the default exit fee, id = n changes fees for vault n specifically

admin cannot set the exit fee to be greater than maxExitFeePercentage, which is set to be the 10% of generalConfig.feeDenominator (which represents 100%), to avoid being able to prevent users from withdrawing their assets

function setExitFee(uint256 id, uint256 exitFee) external onlyAdmin;

Parameters

NameTypeDescription
iduint256vault id to set exit fee for
exitFeeuint256exit fee to set

setProtocolFee

sets protocol fees for the specified vault (id=0 sets the default fees for all vaults) id = 0 changes the default protocol fee, id = n changes fees for vault n specifically

admin cannot set the protocol fee to be greater than maxProtocolFeePercentage, which is set to be the 10% of generalConfig.feeDenominator (which represents 100%), to avoid being able to prevent users from depositing or withdrawing their assets with unreasonable fees

function setProtocolFee(uint256 id, uint256 protocolFee) external onlyAdmin;

Parameters

NameTypeDescription
iduint256vault id to set protocol fee for
protocolFeeuint256protocol fee to set

setAtomWarden

sets the atomWarden address

function setAtomWarden(address atomWarden) external onlyAdmin;

Parameters

NameTypeDescription
atomWardenaddressaddress of the new atomWarden

setBondingCurveConfig

Sets the bonding curve configuration

function setBondingCurveConfig(address newRegistry, uint256 _defaultCurveId) external onlyAdmin;

Parameters

NameTypeDescription
newRegistryaddressAddress of the new bonding curve registry
_defaultCurveIduint256New default curve ID

deployAtomWallet

deploy a given atom wallet

deploys an ERC4337 account (atom wallet) through a BeaconProxy. Reverts if the atom vault does not exist

function deployAtomWallet(uint256 atomId) external whenNotPaused returns (address);

Parameters

NameTypeDescription
atomIduint256vault id of atom

Returns

NameTypeDescription
<none>addressatomWallet the address of the atom wallet

approve

Set the approval type for a sender to act on behalf of the receiver

function approve(address sender, ApprovalTypes approvalType) external;

Parameters

NameTypeDescription
senderaddressaddress to set approval for
approvalTypeApprovalTypestype of approval to grant (NONE = 0, DEPOSIT = 1, REDEMPTION = 2, BOTH = 3)

createAtom

Create an atom and return its vault id

This function will revert if called with less than getAtomCost() in msg.value

function createAtom(bytes calldata atomUri) external payable nonReentrant whenNotPaused returns (uint256);

Parameters

NameTypeDescription
atomUribytesatom data to create atom with

Returns

NameTypeDescription
<none>uint256id vault id of the atom

batchCreateAtom

Batch create atoms and return their vault ids

This function will revert if called with less than getAtomCost() * atomUris.length in msg.value

function batchCreateAtom(bytes[] calldata atomUris)
    external
    payable
    nonReentrant
    whenNotPaused
    returns (uint256[] memory);

Parameters

NameTypeDescription
atomUrisbytes[]atom data array to create atoms with

Returns

NameTypeDescription
<none>uint256[]ids vault ids array of the atoms

_createAtom

Internal utility function to create an atom and handle vault creation

function _createAtom(bytes calldata atomUri, uint256 value) internal returns (uint256, uint256);

Parameters

NameTypeDescription
atomUribytesThe atom data to create an atom with
valueuint256The value sent with the transaction

Returns

NameTypeDescription
<none>uint256id The new vault ID created for the atom
<none>uint256

createTriple

create a triple and return its vault id

This function will revert if called with less than getTripleCost() in msg.value. This function will revert if any of the atoms do not exist or if any ids are triple vaults.

function createTriple(uint256 subjectId, uint256 predicateId, uint256 objectId)
    external
    payable
    nonReentrant
    whenNotPaused
    returns (uint256);

Parameters

NameTypeDescription
subjectIduint256vault id of the subject atom
predicateIduint256vault id of the predicate atom
objectIduint256vault id of the object atom

Returns

NameTypeDescription
<none>uint256id vault id of the triple

batchCreateTriple

batch create triples and return their vault ids

This function will revert if called with less than getTripleCost() * array.length in msg.value. This function will revert if any of the atoms do not exist or if any ids are triple vaults.

function batchCreateTriple(uint256[] calldata subjectIds, uint256[] calldata predicateIds, uint256[] calldata objectIds)
    external
    payable
    nonReentrant
    whenNotPaused
    returns (uint256[] memory);

Parameters

NameTypeDescription
subjectIdsuint256[]vault ids array of subject atoms
predicateIdsuint256[]vault ids array of predicate atoms
objectIdsuint256[]vault ids array of object atoms

_createTriple

Internal utility function to create a triple

function _createTriple(uint256 subjectId, uint256 predicateId, uint256 objectId, uint256 value)
    internal
    returns (uint256, uint256);

Parameters

NameTypeDescription
subjectIduint256vault id of the subject atom
predicateIduint256vault id of the predicate atom
objectIduint256vault id of the object atom
valueuint256The amount of ETH the user has sent minus the base triple cost

Returns

NameTypeDescription
<none>uint256id The new vault ID of the created triple
<none>uint256protocolDepositFee The calculated protocol fee for the deposit

depositAtom

deposit eth into an atom vault and grant ownership of 'shares' to 'reciever' *payable msg.value amount of eth to deposit

assets parameter is omitted in favor of msg.value, unlike in ERC4626

this function will revert if the minimum deposit amount of eth is not met and if the vault ID does not exist/is not an atom.

function depositAtom(address receiver, uint256 id) external payable nonReentrant whenNotPaused returns (uint256);

Parameters

NameTypeDescription
receiveraddressthe address to receive the shares
iduint256the vault ID of the atom

Returns

NameTypeDescription
<none>uint256shares the amount of shares minted

depositAtomCurve

deposit eth into an atom vault and grant ownership of 'shares' to 'reciever' *payable msg.value amount of eth to deposit

assets parameter is omitted in favor of msg.value, unlike in ERC4626

this function will revert if the minimum deposit amount of eth is not met and if the vault ID does not exist/is not an atom.

This method is entirely separate from depositAtom, because we wanted to leave the audited pathways intact. This serves as an intermediary solution to enable users to interact with bonding curve vaults before performing an audit of the full refactor (V2).

function depositAtomCurve(address receiver, uint256 atomId, uint256 curveId)
    external
    payable
    nonReentrant
    whenNotPaused
    returns (uint256);

Parameters

NameTypeDescription
receiveraddressthe address to receive the shares
atomIduint256the vault ID of the atom
curveIduint256the vault ID of the curve

Returns

NameTypeDescription
<none>uint256shares the amount of shares minted

redeemAtom

redeem shares from an atom vault for assets

Emergency redemptions without any fees being charged are always possible, even if the contract is paused See getRedeemAssetsAndFees for more details on the fees charged

function redeemAtom(uint256 shares, address receiver, uint256 id) external nonReentrant returns (uint256);

Parameters

NameTypeDescription
sharesuint256the amount of shares to redeem
receiveraddressthe address to receiver the assets
iduint256the vault ID of the atom

Returns

NameTypeDescription
<none>uint256assets the amount of assets/eth withdrawn

redeemAtomCurve

redeem shares from a bonding curve atom vault for assets

This method is entirely separate from redeemAtom, because we wanted to leave the audited pathways intact. This serves as an intermediary solution to enable users to interact with bonding curve vaults before performing an audit of the full refactor (V2).

function redeemAtomCurve(uint256 shares, address receiver, uint256 atomId, uint256 curveId)
    external
    nonReentrant
    returns (uint256);

Parameters

NameTypeDescription
sharesuint256the amount of shares to redeem
receiveraddressthe address to receiver the assets
atomIduint256the vault ID of the atom
curveIduint256the vault ID of the curve

Returns

NameTypeDescription
<none>uint256assets the amount of assets/eth withdrawn

depositTriple

deposits assets of underlying tokens into a triple vault and grants ownership of 'shares' to 'receiver' *payable msg.value amount of eth to deposit

assets parameter is omitted in favor of msg.value, unlike in ERC4626

this function will revert if the minimum deposit amount of eth is not met and if the vault ID does not exist/is not a triple.

function depositTriple(address receiver, uint256 id) external payable nonReentrant whenNotPaused returns (uint256);

Parameters

NameTypeDescription
receiveraddressthe address to receive the shares
iduint256the vault ID of the triple

Returns

NameTypeDescription
<none>uint256shares the amount of shares minted

depositTripleCurve

deposit eth into a bonding curve triple vault and grant ownership of 'shares' to 'receiver' *payable msg.value amount of eth to deposit

assets parameter is omitted in favor of msg.value, unlike in ERC4626

This method is entirely separate from depositTriple, because we wanted to leave the audited pathways intact. This serves as an intermediary solution to enable users to interact with bonding curve vaults before performing an audit of the full refactor (V2).

function depositTripleCurve(address receiver, uint256 tripleId, uint256 curveId)
    external
    payable
    nonReentrant
    whenNotPaused
    returns (uint256);

Parameters

NameTypeDescription
receiveraddressthe address to receive the shares
tripleIduint256the vault ID of the triple
curveIduint256the vault ID of the curve

Returns

NameTypeDescription
<none>uint256shares the amount of shares minted

redeemTriple

redeems 'shares' number of shares from the triple vault and send 'assets' eth from the contract to 'reciever' factoring in exit fees

Emergency redemptions without any fees being charged are always possible, even if the contract is paused See getRedeemAssetsAndFees for more details on the fees charged

function redeemTriple(uint256 shares, address receiver, uint256 id) external nonReentrant returns (uint256);

Parameters

NameTypeDescription
sharesuint256the amount of shares to redeem
receiveraddressthe address to receiver the assets
iduint256the vault ID of the triple

Returns

NameTypeDescription
<none>uint256assets the amount of assets/eth withdrawn

redeemTripleCurve

redeem shares from a bonding curve triple vault for assets

This method is entirely separate from redeemTriple, because we wanted to leave the audited pathways intact. This serves as an intermediary solution to enable users to interact with bonding curve vaults before performing an audit of the full refactor (V2).

function redeemTripleCurve(uint256 shares, address receiver, uint256 tripleId, uint256 curveId)
    external
    nonReentrant
    returns (uint256);

Parameters

NameTypeDescription
sharesuint256the amount of shares to redeem
receiveraddressthe address to receiver the assets
tripleIduint256the vault ID of the triple
curveIduint256the vault ID of the curve

Returns

NameTypeDescription
<none>uint256assets the amount of assets/eth withdrawn

batchDeposit

deposit eth into multiple terms and grant ownership of 'shares' to 'reciever' *payable msg.value amount of eth to deposit works with atoms, triples, and counter-triples

this function will revert if the minimum deposit amount of eth is not met and if a vault ID does not exist/is not an atom.

function batchDeposit(address receiver, uint256[] calldata termIds, uint256[] calldata amounts)
    external
    payable
    nonReentrant
    whenNotPaused
    returns (uint256[] memory shares);

Parameters

NameTypeDescription
receiveraddressthe address to receive the shares
termIdsuint256[]the IDs of the terms (atoms, triples, or counter-triples) to deposit into
amountsuint256[]array of the amount to deposit in each vault

Returns

NameTypeDescription
sharesuint256[]the amount of shares minted for each atom

batchDepositCurve

deposit eth into an atom vault and grant ownership of 'shares' to 'reciever' *payable msg.value amount of eth to deposit

assets parameter is omitted in favor of msg.value, unlike in ERC4626

this function will revert if the minimum deposit amount of eth is not met and if the vault ID does not exist/is not an atom.

This method is entirely separate from depositAtom, because we wanted to leave the audited pathways intact. This serves as an intermediary solution to enable users to interact with bonding curve vaults before performing an audit of the full refactor (V2).

function batchDepositCurve(
    address receiver,
    uint256[] calldata termIds,
    uint256[] calldata curveIds,
    uint256[] calldata amounts
) external payable nonReentrant whenNotPaused returns (uint256[] memory shares);

Parameters

NameTypeDescription
receiveraddressthe address to receive the shares
termIdsuint256[]array of the vault IDs of the terms (atoms, triples, or counter-triples)
curveIdsuint256[]array of the vault IDs of the curves
amountsuint256[]array of the amount to deposit in each vault

Returns

NameTypeDescription
sharesuint256[]array of the amount of shares minted in the specified vaults

batchRedeem

redeem shares from an atom vault for assets -- works for atoms, triples and counter-triples

Emergency redemptions without any fees being charged are always possible, even if the contract is paused See getRedeemAssetsAndFees for more details on the fees charged

function batchRedeem(uint256 percentage, address receiver, uint256[] calldata ids)
    external
    nonReentrant
    returns (uint256[] memory assets);

Parameters

NameTypeDescription
percentageuint256the percentage of shares to redeem from each vault (10000 -> 100.00%, 5000 -> 50.00%, etc)
receiveraddressthe address to receiver the assets
idsuint256[]array of IDs of the term (atom, triple or counter-triple) to redeem from

Returns

NameTypeDescription
assetsuint256[]the amount of assets/eth withdrawn

batchRedeemCurve

redeem shares from bonding curve atom vaults for assets

function batchRedeemCurve(uint256 percentage, address receiver, uint256[] calldata termIds, uint256[] calldata curveIds)
    external
    nonReentrant
    returns (uint256[] memory assets);

Parameters

NameTypeDescription
percentageuint256the percentage of shares to redeem from the vaults (10000 -> 100.00%, 5000 -> 50.00%, etc)
receiveraddressthe address to receiver the assets
termIdsuint256[]array of the IDs of the terms (atoms, triples, or counter-triples)
curveIdsuint256[]array of the IDs of the curves for each term

Returns

NameTypeDescription
assetsuint256[]array of the amounts of assets/eth withdrawn

_transferFeesToProtocolMultisig

transfer fees to the protocol multisig

function _transferFeesToProtocolMultisig(uint256 value) internal;

Parameters

NameTypeDescription
valueuint256the amount of eth to transfer

_depositConstituentAtoms

divides amount across the three atoms composing the triple and issues shares to the receiver. Doesn't charge additional protocol fees, but it does charge entry fees on each deposit into an atom vault.

assumes funds have already been transferred to this contract

function _depositConstituentAtoms(uint256 id, address receiver, uint256 amount) internal;

Parameters

NameTypeDescription
iduint256the vault ID of the triple
receiveraddressthe address to receive the shares
amountuint256the amount of eth to deposit

_depositConstituentAtomsCurve

function _depositConstituentAtomsCurve(uint256 tripleId, uint256 curveId, address receiver, uint256 amount) internal;

_depositOnVaultCreation

deposit assets into a vault upon creation. Changes the vault's total assets, total shares and balanceOf mappings to reflect the deposit. Additionally, initializes a counter vault with ghost shares.

function _depositOnVaultCreation(uint256 id, address receiver, uint256 assets) internal;

Parameters

NameTypeDescription
iduint256the vault ID of the atom or triple
receiveraddressthe address to receive the shares
assetsuint256the amount of eth to deposit

_deposit

Initialize the counter triple vault with ghost shares if it is a triple creation flow

Internal function to encapsulate the common deposit logic for both atoms and triples

function _deposit(address receiver, uint256 id, uint256 value) internal returns (uint256);

Parameters

NameTypeDescription
receiveraddressthe address to receive the shares
iduint256the vault ID of the atom or triple
valueuint256the amount of eth to deposit

Returns

NameTypeDescription
<none>uint256sharesForReceiver the amount of shares minted

_depositCurve

function _depositCurve(address receiver, uint256 id, uint256 curveId, uint256 value) internal returns (uint256);

_redeem

redeem shares out of a given vault. Changes the vault's total assets, total shares and balanceOf mappings to reflect the withdrawal

function _redeem(uint256 id, address sender, address receiver, uint256 shares) internal returns (uint256, uint256);

Parameters

NameTypeDescription
iduint256the vault ID of the atom or triple
senderaddressthe address to redeem the shares from
receiveraddressthe address to receive the assets
sharesuint256the amount of shares to redeem

Returns

NameTypeDescription
<none>uint256assetsForReceiver the amount of assets/eth to be transferred to the receiver
<none>uint256protocolFee the amount of protocol fees deducted

_redeemCurve

redeem shares out of a given bonding curve vault. Changes the vault's total assets, total shares and balanceOf mappings to reflect the withdrawal

function _redeemCurve(uint256 id, uint256 curveId, address sender, address receiver, uint256 shares)
    internal
    returns (uint256, uint256);

Parameters

NameTypeDescription
iduint256the vault ID of the atom or triple
curveIduint256the vault ID of the curve
senderaddressthe address to redeem the shares from
receiveraddressthe address to receive the assets
sharesuint256the amount of shares to redeem

Returns

NameTypeDescription
<none>uint256assetsForReceiver the amount of assets/eth to be transferred to the receiver
<none>uint256protocolFee the amount of protocol fees deducted

_mint

mint vault shares of vault ID id to address to

function _mint(address to, uint256 id, uint256 amount) internal;

Parameters

NameTypeDescription
toaddressaddress to mint shares to
iduint256vault ID to mint shares for
amountuint256amount of shares to mint

_mintCurve

function _mintCurve(address to, uint256 id, uint256 curveId, uint256 amount) internal;

_burn

burn amount vault shares of vault ID id from address from

function _burn(address from, uint256 id, uint256 amount) internal;

Parameters

NameTypeDescription
fromaddressaddress to burn shares from
iduint256vault ID to burn shares from
amountuint256amount of shares to burn

_burnCurve

function _burnCurve(address from, uint256 id, uint256 curveId, uint256 amount) internal;

_setVaultTotals

set total assets and shares for a vault

function _setVaultTotals(uint256 id, uint256 totalAssets, uint256 totalShares) internal;

Parameters

NameTypeDescription
iduint256vault ID to set totals for
totalAssetsuint256new total assets for the vault
totalSharesuint256new total shares for the vault

_increaseCurveVaultTotals

increase the total assets and shares for a given bonding curve vault

emits an event, as this affects the share price of the specified bonding curve vault

function _increaseCurveVaultTotals(uint256 id, uint256 curveId, uint256 assetsDelta, uint256 sharesDelta) internal;

Parameters

NameTypeDescription
iduint256the vault ID of the atom or triple
curveIduint256the vault ID of the curve
assetsDeltauint256the amount of assets to increase the total assets by
sharesDeltauint256the amount of shares to increase the total shares by

_decreaseCurveVaultTotals

decrease the total assets and shares for a given bonding curve vault

emits an event, as this affects the share price of the specified bonding curve vault

function _decreaseCurveVaultTotals(uint256 id, uint256 curveId, uint256 assetsDelta, uint256 sharesDelta) internal;

Parameters

NameTypeDescription
iduint256the vault ID of the atom or triple
curveIduint256the vault ID of the curve
assetsDeltauint256the amount of assets to decrease the total assets by
sharesDeltauint256the amount of shares to decrease the total shares by

_createVault

internal method for vault creation

function _createVault() internal returns (uint256);

getAtomCost

returns the cost of creating an atom

function getAtomCost() public view returns (uint256);

Returns

NameTypeDescription
<none>uint256atomCost the cost of creating an atom

getTripleCost

returns the cost of creating a triple

function getTripleCost() public view returns (uint256);

Returns

NameTypeDescription
<none>uint256tripleCost the cost of creating a triple

getDepositFees

returns the total fees that would be charged for depositing 'assets' into a vault

function getDepositFees(uint256 assets, uint256 id) public view returns (uint256);

Parameters

NameTypeDescription
assetsuint256amount of assets to calculate fees on
iduint256vault id to get corresponding fees for

Returns

NameTypeDescription
<none>uint256totalFees total fees that would be charged for depositing 'assets' into a vault

getDepositSharesAndFees

returns the shares for recipient and other important values when depositing 'assets' into a vault

function getDepositSharesAndFees(uint256 assets, uint256 id) public view returns (uint256, uint256, uint256, uint256);

Parameters

NameTypeDescription
assetsuint256amount of assets to calculate fees on (should always be msg.value - protocolFee)
iduint256vault id to get corresponding fees for

Returns

NameTypeDescription
<none>uint256totalAssetsDelta changes in vault's total assets
<none>uint256sharesForReceiver changes in vault's total shares (shares owed to receiver)
<none>uint256userAssetsAfterTotalFees amount of assets that goes towards minting shares for the receiver
<none>uint256entryFee amount of assets that would be charged for the entry fee

getDepositSharesAndFeesCurve

function getDepositSharesAndFeesCurve(uint256 assets, uint256 id, uint256 curveId)
    public
    view
    returns (uint256, uint256, uint256, uint256);

getRedeemAssetsAndFees

returns the assets for receiver and other important values when redeeming 'shares' from a vault

function getRedeemAssetsAndFees(uint256 shares, uint256 id) public view returns (uint256, uint256, uint256, uint256);

Parameters

NameTypeDescription
sharesuint256amount of shares to calculate fees on
iduint256vault id to get corresponding fees for

Returns

NameTypeDescription
<none>uint256totalUserAssets total amount of assets user would receive if redeeming 'shares', not including fees
<none>uint256assetsForReceiver amount of assets that is redeemable by the receiver
<none>uint256protocolFee amount of assets that would be sent to the protocol multisig
<none>uint256exitFee amount of assets that would be charged for the exit fee

getRedeemAssetsAndFeesCurve

function getRedeemAssetsAndFeesCurve(uint256 shares, uint256 id, uint256 curveId)
    public
    view
    returns (uint256, uint256, uint256, uint256);

entryFeeAmount

returns amount of assets that would be charged for the entry fee given an amount of 'assets' provided

if the vault being deposited on has a vault total shares of 0, the entry fee is not applied

function entryFeeAmount(uint256 assets, uint256 id) public view returns (uint256);

Parameters

NameTypeDescription
assetsuint256amount of assets to calculate fee on
iduint256vault id to get corresponding fees for

Returns

NameTypeDescription
<none>uint256feeAmount amount of assets that would be charged for the entry fee

exitFeeAmount

returns amount of assets that would be charged for the exit fee given an amount of 'assets' provided

if the vault being redeemed from given the shares to redeem results in a total shares after of 0, the exit fee is not applied

function exitFeeAmount(uint256 assets, uint256 id) public view returns (uint256);

Parameters

NameTypeDescription
assetsuint256amount of assets to calculate fee on
iduint256vault id to get corresponding fees for

Returns

NameTypeDescription
<none>uint256feeAmount amount of assets that would be charged for the exit fee

protocolFeeAmount

returns amount of assets that would be charged by a vault on protocol fee given amount of 'assets' provided

function protocolFeeAmount(uint256 assets, uint256 id) public view returns (uint256);

Parameters

NameTypeDescription
assetsuint256amount of assets to calculate fee on
iduint256vault id to get corresponding fees for

Returns

NameTypeDescription
<none>uint256feeAmount amount of assets that would be charged by vault on protocol fee

atomDepositsAmount

returns atom deposit given amount of 'assets' provided

only applies to triple vaults

function atomDepositsAmount(uint256 assets, uint256 id) public view returns (uint256);

Parameters

NameTypeDescription
assetsuint256amount of assets to calculate fee on
iduint256vault id

Returns

NameTypeDescription
<none>uint256feeAmount amount of assets that would be used as atom deposit

_feeOnRaw

calculates fee on raw amount

function _feeOnRaw(uint256 amount, uint256 fee) internal view returns (uint256);

Parameters

NameTypeDescription
amountuint256amount of assets to calculate fee on
feeuint256fee in %

Returns

NameTypeDescription
<none>uint256amount of assets that would be charged as fee

currentSharePrice

returns the current share price for the given vault id

function currentSharePrice(uint256 id) public view returns (uint256);

Parameters

NameTypeDescription
iduint256vault id to get corresponding share price for

Returns

NameTypeDescription
<none>uint256price current share price for the given vault id, scaled by 1e18

currentSharePriceCurve

returns the current share price for the given vault id and curve id

function currentSharePriceCurve(uint256 id, uint256 curveId) public view returns (uint256);

Parameters

NameTypeDescription
iduint256vault id to get corresponding share price for
curveIduint256curve id to get corresponding share price for

Returns

NameTypeDescription
<none>uint256price current share price for the given vault id and curve id, scaled by 1e18

maxDeposit

returns max amount of eth that can be deposited into the vault

function maxDeposit() public pure returns (uint256);

Returns

NameTypeDescription
<none>uint256maxDeposit max amount of eth that can be deposited into the vault

maxDepositCurve

returns max amount of assets that can be deposited into a bonding curve vault

Tells the registry to ask the specified curve what its asset limits are.

function maxDepositCurve(uint256 curveId) public view returns (uint256);

Parameters

NameTypeDescription
curveIduint256the vault ID of the curve

Returns

NameTypeDescription
<none>uint256maxDepositCurve max amount of assets that can be deposited into the bonding curve vault

maxRedeem

returns max amount of shares that can be redeemed from the 'sender' balance through a redeem call

function maxRedeem(address sender, uint256 id) public view returns (uint256);

Parameters

NameTypeDescription
senderaddressaddress of the account to get max redeemable shares for
iduint256vault id to get corresponding shares for

Returns

NameTypeDescription
<none>uint256shares amount of shares that can be redeemed from the 'sender' balance through a redeem call

maxRedeemCurve

returns max amount of shares that can be redeemed from a bonding curve vault

function maxRedeemCurve(address sender, uint256 id, uint256 curveId) public view returns (uint256);

Parameters

NameTypeDescription
senderaddressthe address to redeem the shares from
iduint256the vault ID of the atom or triple
curveIduint256the vault ID of the curve

Returns

NameTypeDescription
<none>uint256shares the amount of shares that can be redeemed from the 'sender' balance through a redeem call

convertToShares

returns amount of shares that would be exchanged by vault given amount of 'assets' provided

For regular vaults, shares maintain a linear relationship with assets: $shares = assets \cdot \frac{S_{total}}{A_{total}}$

Where:

$S_{total}$ = the total supply of shares $A_{total}$ = the total assets in the vault

TLDR: Since assets and shares maintain a 1:1 relationship, we only need simple proportion math. No domain conversion needed because 1 dollar worth of assets always equals 1 dollar worth of shares.

function convertToShares(uint256 assets, uint256 id) public view returns (uint256);

Parameters

NameTypeDescription
assetsuint256amount of assets to calculate shares on
iduint256vault id to get corresponding shares for

Returns

NameTypeDescription
<none>uint256shares amount of shares that would be exchanged by vault given amount of 'assets' provided

convertToSharesCurve

returns amount of shares that would be exchanged by vault given amount of 'assets' provided

The conversion happens in two steps:

  1. First, we get the base shares from the bonding curve: $$s_{base} = f_{curve}(assets)$$
function convertToSharesCurve(uint256 assets, uint256 id, uint256 curveId) public view returns (uint256);

Parameters

NameTypeDescription
assetsuint256amount of assets to calculate shares on
iduint256vault id to get corresponding shares for
curveIduint256vault id of the curve

Returns

NameTypeDescription
<none>uint256shares amount of shares that would be exchanged by vault given amount of 'assets' provided

convertToAssets

returns amount of assets that would be exchanged by vault given amount of 'shares' provided

For regular vaults, assets maintain a linear relationship with shares: $assets = shares \cdot \frac{A_{total}}{S_{total}}$

Where:

  • $S_{total}$ is the total supply of shares
  • $A_{total}$ is the total assets in the vault

TLDR: Since assets and shares maintain a 1:1 relationship, we only need simple proportion math. No domain conversion needed because 1 dollar worth of shares always equals 1 dollar worth of assets.

function convertToAssets(uint256 shares, uint256 id) public view returns (uint256);

Parameters

NameTypeDescription
sharesuint256amount of shares to calculate assets on
iduint256vault id to get corresponding assets for

Returns

NameTypeDescription
<none>uint256assets amount of assets that would be exchanged by vault given amount of 'shares' provided

convertToAssetsCurve

returns amount of assets that would be exchanged by vault given amount of 'shares' provided

The conversion happens in two steps:

  1. First, we get the base assets from the bonding curve: $$a_{base} = f_{curve}^{-1}(shares)$$
function convertToAssetsCurve(uint256 shares, uint256 id, uint256 curveId) public view returns (uint256);

Parameters

NameTypeDescription
sharesuint256amount of shares to calculate assets on
iduint256vault id to get corresponding assets for
curveIduint256vault id of the curve

Returns

NameTypeDescription
<none>uint256assets amount of assets that would be exchanged by vault given amount of 'shares' provided

previewDeposit

simulates the effects of the deposited amount of 'assets' and returns the estimated amount of shares that would be minted from the deposit of assets

this function pessimistically estimates the amount of shares that would be minted from the input amount of assets so if the vault is empty before the deposit the caller receives more shares than returned by this function, reference internal _depositIntoVault logic for details

function previewDeposit(uint256 assets, uint256 id) public view returns (uint256);

Parameters

NameTypeDescription
assetsuint256amount of assets to calculate shares on
iduint256vault id to get corresponding shares for

Returns

NameTypeDescription
<none>uint256shares amount of shares that would be minted from the deposit of assets

previewDepositCurve

function previewDepositCurve(uint256 assets, uint256 id, uint256 curveId) public view returns (uint256);

previewRedeem

simulates the effects of the redemption of shares and returns the estimated amount of assets estimated to be returned to the receiver of the redeem

function previewRedeem(uint256 shares, uint256 id) public view returns (uint256);

Parameters

NameTypeDescription
sharesuint256amount of shares to calculate assets on
iduint256vault id to get corresponding assets for

Returns

NameTypeDescription
<none>uint256assets amount of assets estimated to be returned to the receiver

previewRedeemCurve

function previewRedeemCurve(uint256 shares, uint256 id, uint256 curveId) public view returns (uint256);

tripleHash

returns the corresponding hash for the given RDF triple, given the triple vault id

only applies to triple vault IDs as input

function tripleHash(uint256 id) public view returns (bytes32);

Parameters

NameTypeDescription
iduint256vault id of the triple

Returns

NameTypeDescription
<none>bytes32hash the corresponding hash for the given RDF triple

isTripleId

returns whether the supplied vault id is a triple

function isTripleId(uint256 id) public view returns (bool);

Parameters

NameTypeDescription
iduint256vault id to check

Returns

NameTypeDescription
<none>boolbool whether the supplied vault id is a triple

getTripleAtoms

returns the atoms that make up a triple/counter-triple

only applies to triple vault IDs as input

function getTripleAtoms(uint256 id) public view returns (uint256, uint256, uint256);

Parameters

NameTypeDescription
iduint256vault id of the triple/counter-triple

Returns

NameTypeDescription
<none>uint256tuple(atomIds) the atoms that make up the triple/counter-triple
<none>uint256
<none>uint256

tripleHashFromAtoms

returns the corresponding hash for the given RDF triple, given the atoms that make up the triple

function tripleHashFromAtoms(uint256 subjectId, uint256 predicateId, uint256 objectId) public pure returns (bytes32);

Parameters

NameTypeDescription
subjectIduint256the subject atom's vault id
predicateIduint256the predicate atom's vault id
objectIduint256the object atom's vault id

Returns

NameTypeDescription
<none>bytes32hash the corresponding hash for the given RDF triple based on the atom vault ids

getCounterIdFromTriple

returns the counter id from the given triple id

only applies to triple vault IDs as input

function getCounterIdFromTriple(uint256 id) public pure returns (uint256);

Parameters

NameTypeDescription
iduint256vault id of the triple

Returns

NameTypeDescription
<none>uint256counterId the counter vault id from the given triple id

getAtomWarden

returns the address of the atom warden

function getAtomWarden() external view returns (address);

getVaultStateForUser

returns the number of shares and assets (less fees) user has in the vault

function getVaultStateForUser(uint256 vaultId, address receiver) external view returns (uint256, uint256);

Parameters

NameTypeDescription
vaultIduint256vault id of the vault
receiveraddressaddress of the receiver

Returns

NameTypeDescription
<none>uint256shares number of shares user has in the vault
<none>uint256assets number of assets user has in the vault

getVaultStateForUserCurve

function getVaultStateForUserCurve(uint256 vaultId, uint256 curveId, address receiver)
    external
    view
    returns (uint256, uint256);

getCurveVaultState

function getCurveVaultState(uint256 termId, uint256 curveId) external view returns (uint256, uint256);

computeAtomWalletAddr

returns the Atom Wallet address for the given atom data

the create2 salt is based off of the vault ID

function computeAtomWalletAddr(uint256 id) public view returns (address);

Parameters

NameTypeDescription
iduint256vault id of the atom associated to the atom wallet

Returns

NameTypeDescription
<none>addressatomWallet the address of the atom wallet

isApprovedDeposit

Check if a sender is approved to deposit on behalf of a receiver

function isApprovedDeposit(address sender, address receiver) public view returns (bool);

Parameters

NameTypeDescription
senderaddressThe address of the sender
receiveraddressThe address of the receiver

Returns

NameTypeDescription
<none>boolbool Whether the sender is approved to deposit

isApprovedRedeem

Check if a sender is approved to redeem on behalf of a receiver

function isApprovedRedeem(address sender, address receiver) public view returns (bool);

Parameters

NameTypeDescription
senderaddressThe address of the sender
receiveraddressThe address of the receiver

Returns

NameTypeDescription
<none>boolbool Whether the sender is approved to redeem

_hasCounterStake

checks if an account holds shares in the vault counter to the id provided

function _hasCounterStake(uint256 id, address receiver) internal view returns (bool);

Parameters

NameTypeDescription
iduint256the id of the vault to check
receiveraddressthe account to check

Returns

NameTypeDescription
<none>boolbool whether the account holds shares in the counter vault to the id provided or not

_hasCounterStakeCurve

function _hasCounterStakeCurve(uint256 id, uint256 curveId, address receiver) internal view returns (bool);

_getDeploymentData

returns the deployment data for the AtomWallet contract

function _getDeploymentData() internal view returns (bytes memory);

Returns

NameTypeDescription
<none>bytesbytes memory the deployment data for the AtomWallet contract (using BeaconProxy pattern)

_validateTimelock

internal method to validate the timelock constraints

function _validateTimelock(bytes32 operationHash) internal view;

Parameters

NameTypeDescription
operationHashbytes32hash of the operation

_registry

function _registry() internal view returns (IBondingCurveRegistry);

LinearCurve

Git Source

Curve Visualization

%%{init: {"xychart": {"showTitle": true}} }%%
xychart-beta
    title "Linear Curve"
    x-axis "Assets (ETH)" [0.000000000000000000, 1.000000000000000000, 2.000000000000000000, 3.000000000000000000, 4.000000000000000000, 5.000000000000000000, 6.000000000000000000, 7.000000000000000000, 8.000000000000000000, 9.000000000000000000, 10.000000000000000000, 11.000000000000000000, 12.000000000000000000, 13.000000000000000000, 14.000000000000000000, 15.000000000000000000, 16.000000000000000000, 17.000000000000000000, 18.000000000000000000, 19.000000000000000000, 20.000000000000000000, 21.000000000000000000, 22.000000000000000000, 23.000000000000000000, 24.000000000000000000, 25.000000000000000000, 26.000000000000000000, 27.000000000000000000, 28.000000000000000000, 29.000000000000000000, 30.000000000000000000, 31.000000000000000000, 32.000000000000000000, 33.000000000000000000, 34.000000000000000000, 35.000000000000000000, 36.000000000000000000, 37.000000000000000000, 38.000000000000000000, 39.000000000000000000, 40.000000000000000000, 41.000000000000000000, 42.000000000000000000, 43.000000000000000000, 44.000000000000000000, 45.000000000000000000, 46.000000000000000000, 47.000000000000000000, 48.000000000000000000, 49.000000000000000000, 50.000000000000000000, 51.000000000000000000, 52.000000000000000000, 53.000000000000000000, 54.000000000000000000, 55.000000000000000000, 56.000000000000000000, 57.000000000000000000, 58.000000000000000000, 59.000000000000000000, 60.000000000000000000, 61.000000000000000000, 62.000000000000000000, 63.000000000000000000, 64.000000000000000000, 65.000000000000000000, 66.000000000000000000, 67.000000000000000000, 68.000000000000000000, 69.000000000000000000, 70.000000000000000000, 71.000000000000000000, 72.000000000000000000, 73.000000000000000000, 74.000000000000000000, 75.000000000000000000, 76.000000000000000000, 77.000000000000000000, 78.000000000000000000, 79.000000000000000000, 80.000000000000000000, 81.000000000000000000, 82.000000000000000000, 83.000000000000000000, 84.000000000000000000, 85.000000000000000000, 86.000000000000000000, 87.000000000000000000, 88.000000000000000000, 89.000000000000000000, 90.000000000000000000, 91.000000000000000000, 92.000000000000000000, 93.000000000000000000, 94.000000000000000000, 95.000000000000000000, 96.000000000000000000, 97.000000000000000000, 98.000000000000000000, 99.000000000000000000]
    y-axis "Shares"
    line [0.000000000000000000, 1.000000000000000000, 2.000000000000000000, 3.000000000000000000, 4.000000000000000000, 5.000000000000000000, 6.000000000000000000, 7.000000000000000000, 8.000000000000000000, 9.000000000000000000, 10.000000000000000000, 11.000000000000000000, 12.000000000000000000, 13.000000000000000000, 14.000000000000000000, 15.000000000000000000, 16.000000000000000000, 17.000000000000000000, 18.000000000000000000, 19.000000000000000000, 20.000000000000000000, 21.000000000000000000, 22.000000000000000000, 23.000000000000000000, 24.000000000000000000, 25.000000000000000000, 26.000000000000000000, 27.000000000000000000, 28.000000000000000000, 29.000000000000000000, 30.000000000000000000, 31.000000000000000000, 32.000000000000000000, 33.000000000000000000, 34.000000000000000000, 35.000000000000000000, 36.000000000000000000, 37.000000000000000000, 38.000000000000000000, 39.000000000000000000, 40.000000000000000000, 41.000000000000000000, 42.000000000000000000, 43.000000000000000000, 44.000000000000000000, 45.000000000000000000, 46.000000000000000000, 47.000000000000000000, 48.000000000000000000, 49.000000000000000000, 50.000000000000000000, 51.000000000000000000, 52.000000000000000000, 53.000000000000000000, 54.000000000000000000, 55.000000000000000000, 56.000000000000000000, 57.000000000000000000, 58.000000000000000000, 59.000000000000000000, 60.000000000000000000, 61.000000000000000000, 62.000000000000000000, 63.000000000000000000, 64.000000000000000000, 65.000000000000000000, 66.000000000000000000, 67.000000000000000000, 68.000000000000000000, 69.000000000000000000, 70.000000000000000000, 71.000000000000000000, 72.000000000000000000, 73.000000000000000000, 74.000000000000000000, 75.000000000000000000, 76.000000000000000000, 77.000000000000000000, 78.000000000000000000, 79.000000000000000000, 80.000000000000000000, 81.000000000000000000, 82.000000000000000000, 83.000000000000000000, 84.000000000000000000, 85.000000000000000000, 86.000000000000000000, 87.000000000000000000, 88.000000000000000000, 89.000000000000000000, 90.000000000000000000, 91.000000000000000000, 92.000000000000000000, 93.000000000000000000, 94.000000000000000000, 95.000000000000000000, 96.000000000000000000, 97.000000000000000000, 98.000000000000000000, 99.000000000000000000]

Inherits: BaseCurve

Author: 0xIntuition

A simple 1:1 price model implemented as a bonding curve. This curve maintains a direct linear relationship between assets and shares, where the conversion follows the formula: $$f(x) = x$$ where:

  • $x$ represents either assets or shares to be converted
  • $f(x)$ returns the corresponding amount in the target unit

The price mechanism relies on fee accumulation rather than supply-based pricing. As fees are collected, they are distributed proportionally across all shareholders, creating gradual appreciation in share value. This provides a conservative incentivization model where early participants benefit from fee accumulation over time.

This implementation offers a low-volatility approach to value accrual, suitable for scenarios where predictable, steady returns are preferred over dynamic pricing mechanisms.

This curve is not currently used in the EthMultiVault implementation to preserve audited code. It serves as a reference implementation demonstrating how traditional pro-rata share pricing can be adapted to the bonding curve architecture for future versions.

State Variables

MAX_SHARES

Maximum number of shares that can be handled by the curve.

uint256 public constant MAX_SHARES = type(uint256).max;

MAX_ASSETS

Maximum number of assets that can be handled by the curve.

uint256 public constant MAX_ASSETS = type(uint256).max;

Functions

constructor

Constructor for the Linear Curve.

constructor(string memory _name) BaseCurve(_name);

Parameters

NameTypeDescription
_namestringThe name of the curve.

previewDeposit

Computes the 1:1 relationship between assets <--> shares.

function previewDeposit(uint256 assets, uint256, uint256) external pure override returns (uint256);

Parameters

NameTypeDescription
assetsuint256Quantity of assets to deposit
<none>uint256
<none>uint256

Returns

NameTypeDescription
<none>uint256shares The number of shares that would be minted

previewMint

Computes the 1:1 relationship between assets <--> shares.

function previewMint(uint256 shares, uint256, uint256) external pure override returns (uint256);

Parameters

NameTypeDescription
sharesuint256Quantity of shares to mint
<none>uint256
<none>uint256

Returns

NameTypeDescription
<none>uint256assets The number of assets that would be required to mint the shares

previewWithdraw

Computes the 1:1 relationship between assets <--> shares.

function previewWithdraw(uint256 assets, uint256, uint256) external pure override returns (uint256);

Parameters

NameTypeDescription
assetsuint256Quantity of assets to withdraw
<none>uint256
<none>uint256

Returns

NameTypeDescription
<none>uint256shares The number of shares that would need to be redeemed

previewRedeem

Computes the 1:1 relationship between assets <--> shares.

function previewRedeem(uint256 shares, uint256, uint256) external pure override returns (uint256);

Parameters

NameTypeDescription
sharesuint256Quantity of shares to burn
<none>uint256
<none>uint256

Returns

NameTypeDescription
<none>uint256assets The number of assets that would be returned

convertToShares

Computes the 1:1 relationship between assets <--> shares.

function convertToShares(uint256 assets, uint256, uint256) external pure override returns (uint256 shares);

Parameters

NameTypeDescription
assetsuint256Quantity of assets to convert to shares
<none>uint256
<none>uint256

Returns

NameTypeDescription
sharesuint256The number of shares equivalent to the given assets

convertToAssets

Computes the 1:1 relationship between assets <--> shares.

function convertToAssets(uint256 shares, uint256, uint256) external pure override returns (uint256 assets);

Parameters

NameTypeDescription
sharesuint256Quantity of shares to convert to assets
<none>uint256
<none>uint256

Returns

NameTypeDescription
assetsuint256The number of assets equivalent to the given shares

currentPrice

In a linear curve, the base price will always be 1. Pool ratio adjustments are dealt with in the EthMultiVault itself.

function currentPrice(uint256) public pure override returns (uint256 sharePrice);

Parameters

NameTypeDescription
<none>uint256

Returns

NameTypeDescription
sharePriceuint256The current price of a share, scaled by 1e18

maxShares

The maximum number of shares that this curve can handle without overflowing.

Checked by the EthMultiVault before transacting

function maxShares() external pure override returns (uint256);

maxAssets

The maximum number of assets that this curve can handle without overflowing.

Checked by the EthMultiVault before transacting

function maxAssets() external pure override returns (uint256);

OffsetProgressiveCurve

Git Source

Inherits: BaseCurve

Author: 0xIntuition

A modified version of the Progressive bonding curve that introduces an offset parameter to control the initial price dynamics. The price follows the formula: $$P(s) = m \cdot (s + \text{offset})$$ where:

  • $m$ is the slope (in basis points)
  • $s$ is the total supply of shares
  • $\text{offset}$ shifts the starting point of the curve The cost to mint shares is calculated as the area under this curve: $$\text{Cost} = ((s_2 + \text{offset})^2 - (s_1 + \text{offset})^2) \cdot \frac{m}{2}$$ where $s_1$ is the starting share supply and $s_2$ is the final share supply. The offset parameter allows for a more gradual initial price increase while maintaining the progressive pricing structure.

Uses the prb-math library for performant, precise fixed point arithmetic with UD60x18

Fixed point precision used for all internal calculations, while return values are all represented as regular uint256s, and unwrapped. I.e. we might use 123.456 internally and return 123.

The core equation: $$P(s) = m \cdot (s + \text{offset})$$ and the cost equation: $$\text{Cost} = ((s_2 + \text{offset})^2 - (s_1 + \text{offset})^2) \cdot \frac{m}{2}$$ comes from calculus - it's the integral of our modified linear price function. The area under the curve from point $s_1$ to $s_2$ gives us the total cost/return of minting/redeeming shares, but now shifted by our offset parameter.

Inspired by the Solaxy.sol contract: https://github.com/M3tering/Solaxy/blob/main/src/Solaxy.sol and https://m3tering.whynotswitch.com/token-economics/mint-and-distribution. The key difference between the Solaxy contract and this one is that the economic state is handled by the EthMultiVault instead of directly in the curve implementation. The other significant difference is the inclusion of the OFFSET value, which we use to make the curve more gentle.

State Variables

SLOPE

The slope of the curve, in basis points. This is the rate at which the price of shares increases.

0.0025e18 -> 25 basis points, 0.0001e18 = 1 basis point, etc etc

If minDeposit is 0.003 ether, this value would need to be 0.00007054e18 to avoid returning 0 shares for minDeposit assets

UD60x18 public SLOPE;

OFFSET

The offset of the curve. This value is used to snip off a portion of the beginning of the curve, realigning it to the origin. For more details, see the preview functions.

UD60x18 public OFFSET;

HALF_SLOPE

The half of the slope, used for calculations.

UD60x18 public HALF_SLOPE;

MAX_SHARES

Since powu(2) will overflow first (see slope equation), maximum totalShares is sqrt(MAX_UD60x18)

uint256 public MAX_SHARES;

MAX_ASSETS

The maximum assets is totalShares * slope / 2, because multiplication (see slope equation) would overflow beyond that point.

uint256 public MAX_ASSETS;

Functions

constructor

Constructs a new ProgressiveCurve with the given name and slope

Computes maximum values given constructor arguments

Computes Slope / 2 as commonly used constant

constructor(string memory _name, uint256 slope18, uint256 offset18) BaseCurve(_name);

Parameters

NameTypeDescription
_namestringThe name of the curve (i.e. "Progressive Curve #465")
slope18uint256The slope of the curve, in basis points (i.e. 0.0025e18)
offset18uint256The offset of the curve, in basis points (i.e. 0.0001e18)

previewDeposit

Preview how many shares would be minted for a deposit of assets

Let $s$ = current total supply

Let $a$ = amount of assets to deposit

Let $\frac{m}{2}$ = half of the slope

Let $o$ = offset value

shares: $$\text{shares} = \sqrt{(s + o)^2 + \frac{a}{m/2}} - (s + o)$$

or to say that another way: $$\text{shares} = \sqrt{(s + o)^2 + \frac{2a}{m}} - (s + o)$$

function previewDeposit(uint256 assets, uint256, uint256 totalShares) external view override returns (uint256 shares);

Parameters

NameTypeDescription
assetsuint256Quantity of assets to deposit
<none>uint256
totalSharesuint256Total quantity of shares already awarded by the curve

Returns

NameTypeDescription
sharesuint256The number of shares that would be minted

previewRedeem

Preview how many assets would be returned for burning a specific amount of shares

Let $s$ = initial total supply of shares

Let $r$ = shares to redeem

Let $\frac{m}{2}$ = half of the slope

Let $o$ = offset value

assets: $$\text{assets} = ((s + o)^2 - ((s - r + o)^2)) \cdot \frac{m}{2}$$

this can be expanded to: $$\text{assets} = ((s + o)^2 - ((s + o)^2 - 2(s + o)r + r^2)) \cdot \frac{m}{2}$$

which simplifies to: $$\text{assets} = (2(s + o)r - r^2) \cdot \frac{m}{2}$$

Implementation note: This formula is computed via the _convertToAssets helper,

where juniorSupply = (s - r + o) and seniorSupply = (s + o)

function previewRedeem(uint256 shares, uint256 totalShares, uint256) public view override returns (uint256 assets);

Parameters

NameTypeDescription
sharesuint256Quantity of shares to burn
totalSharesuint256Total quantity of shares already awarded by the curve
<none>uint256

Returns

NameTypeDescription
assetsuint256The number of assets that would be returned

previewMint

Preview how many assets would be required to mint a specific amount of shares

Let $s$ = current total supply of shares

Let $n$ = new shares to mint

Let $\frac{m}{2}$ = half of the slope

Let $o$ = offset value

assets: $$\text{assets} = ((s + n + o)^2 - (s + o)^2) \cdot \frac{m}{2}$$

which can be expanded to: $$\text{assets} = ((s + o)^2 + 2(s + o)n + n^2 - (s + o)^2) \cdot \frac{m}{2}$$

which simplifies to: $$\text{assets} = (2(s + o)n + n^2) \cdot \frac{m}{2}$$

Implementation note: This formula is computed via the _convertToAssets helper,

where juniorSupply = (s + o) and seniorSupply = (s + n + o)

function previewMint(uint256 shares, uint256 totalShares, uint256) external view override returns (uint256 assets);

Parameters

NameTypeDescription
sharesuint256Quantity of shares to mint
totalSharesuint256Total quantity of shares already awarded by the curve
<none>uint256

Returns

NameTypeDescription
assetsuint256The number of assets that would be required to mint the shares

previewWithdraw

Preview how many shares would be redeemed for a withdrawal of assets

Let $s$ = current total supply of shares

Let $a$ = assets to withdraw

Let $\frac{m}{2}$ = half of the slope

Let $o$ = offset value

shares: $$\text{shares} = (s + o) - \sqrt{(s + o)^2 - \frac{a}{m/2}}$$

or to say that another way: $$\text{shares} = (s + o) - \sqrt{(s + o)^2 - \frac{2a}{m}}$$

function previewWithdraw(uint256 assets, uint256, uint256 totalShares)
    external
    view
    override
    returns (uint256 shares);

Parameters

NameTypeDescription
assetsuint256Quantity of assets to withdraw
<none>uint256
totalSharesuint256Total quantity of shares already awarded by the curve

Returns

NameTypeDescription
sharesuint256The number of shares that would need to be redeemed

currentPrice

Get the current price of a share

Let $s$ = current total supply of shares

Let $m$ = the slope of the curve

Let $o$ = offset value

sharePrice: $$\text{sharePrice} = (s + o) \cdot m$$

This is the modified linear price function where the price increases linearly with the total supply plus offset

And the slope ($m$) determines how quickly the price increases

TLDR: Each new share costs more than the last, but starting from an offset point on the curve

function currentPrice(uint256 totalShares) public view override returns (uint256 sharePrice);

Parameters

NameTypeDescription
totalSharesuint256Total quantity of shares already awarded by the curve

Returns

NameTypeDescription
sharePriceuint256The current price of a share, scaled by 1e18

convertToShares

Convert assets to shares at a specific point on the curve

Let $s$ = the current total supply of shares

Let $\frac{m}{2}$ = half of the slope

Let $a$ = quantity of assets to convert to shares

Let $o$ = offset value

shares: $$\text{shares} = \frac{a}{(s + o) \cdot m/2}$$

Or to say that another way: $$\text{shares} = \frac{2a}{(s + o) \cdot m}$$

function convertToShares(uint256 assets, uint256, uint256 totalShares)
    external
    view
    override
    returns (uint256 shares);

Parameters

NameTypeDescription
assetsuint256Quantity of assets to convert to shares
<none>uint256
totalSharesuint256Total quantity of shares already awarded by the curve

Returns

NameTypeDescription
sharesuint256The number of shares equivalent to the given assets

convertToAssets

Convert shares to assets at a specific point on the curve

Let $s$ = current total supply of shares

Let $\frac{m}{2}$ = half of the slope

Let $n$ = quantity of shares to convert to assets

Let $o$ = offset value

conversion price: $$\text{price} = (s + o) \cdot \frac{m}{2}$$

where $\frac{m}{2}$ is average price per share

assets: $$\text{assets} = n \cdot ((s + o) \cdot \frac{m}{2})$$

Or to say that another way: $$\text{assets} = n \cdot (s + o) \cdot \frac{m}{2}$$

function convertToAssets(uint256 shares, uint256 totalShares, uint256)
    external
    view
    override
    returns (uint256 assets);

Parameters

NameTypeDescription
sharesuint256Quantity of shares to convert to assets
totalSharesuint256Total quantity of shares already awarded by the curve
<none>uint256

Returns

NameTypeDescription
assetsuint256The number of assets equivalent to the given shares

_convertToAssets

Computes assets as the area under a linear curve with a simplified form of the area of a trapezium, now including the offset: $$f(x) = m(x + o)$$ $$\text{Area} = \frac{1}{2} \cdot (a + b) \cdot h$$ where $a$ and $b$ can be both $f(\text{juniorSupply})$ or $f(\text{seniorSupply})$ depending if used in minting or redeeming, and $o$ is the offset value. Calculates area as: $$((seniorSupply + offset)^2 - (juniorSupply + offset)^2) \cdot \text{halfSlope}$$ where: $$\text{halfSlope} = \frac{\text{slope}}{2}$$

This method is identical to the ProgressiveCurve because it works entirely with relative values, which are already offset by the invoking methods.

function _convertToAssets(UD60x18 juniorSupply, UD60x18 seniorSupply) internal view returns (UD60x18 assets);

Parameters

NameTypeDescription
juniorSupplyUD60x18The smaller supply in the operation (the initial supply during mint, or the final supply during a redeem operation).
seniorSupplyUD60x18The larger supply in the operation (the final supply during mint, or the initial supply during a redeem operation).

Returns

NameTypeDescription
assetsUD60x18The computed assets as an instance of UD60x18 (a fixed-point number).

maxShares

The maximum number of shares that this curve can handle without overflowing.

Checked by the EthMultiVault before transacting

function maxShares() external view override returns (uint256);

maxAssets

The maximum number of assets that this curve can handle without overflowing.

Checked by the EthMultiVault before transacting

function maxAssets() external view override returns (uint256);

ProgressiveCurve

Git Source

Curve Visualization

%%{init: {"xychart": {"showTitle": true}} }%%
xychart-beta
    title "Progressive Curve"
    x-axis "Assets (ETH)" [0.000000000000000000, 1.000000000000000000, 2.000000000000000000, 3.000000000000000000, 4.000000000000000000, 5.000000000000000000, 6.000000000000000000, 7.000000000000000000, 8.000000000000000000, 9.000000000000000000, 10.000000000000000000, 11.000000000000000000, 12.000000000000000000, 13.000000000000000000, 14.000000000000000000, 15.000000000000000000, 16.000000000000000000, 17.000000000000000000, 18.000000000000000000, 19.000000000000000000, 20.000000000000000000, 21.000000000000000000, 22.000000000000000000, 23.000000000000000000, 24.000000000000000000, 25.000000000000000000, 26.000000000000000000, 27.000000000000000000, 28.000000000000000000, 29.000000000000000000, 30.000000000000000000, 31.000000000000000000, 32.000000000000000000, 33.000000000000000000, 34.000000000000000000, 35.000000000000000000, 36.000000000000000000, 37.000000000000000000, 38.000000000000000000, 39.000000000000000000, 40.000000000000000000, 41.000000000000000000, 42.000000000000000000, 43.000000000000000000, 44.000000000000000000, 45.000000000000000000, 46.000000000000000000, 47.000000000000000000, 48.000000000000000000, 49.000000000000000000, 50.000000000000000000, 51.000000000000000000, 52.000000000000000000, 53.000000000000000000, 54.000000000000000000, 55.000000000000000000, 56.000000000000000000, 57.000000000000000000, 58.000000000000000000, 59.000000000000000000, 60.000000000000000000, 61.000000000000000000, 62.000000000000000000, 63.000000000000000000, 64.000000000000000000, 65.000000000000000000, 66.000000000000000000, 67.000000000000000000, 68.000000000000000000, 69.000000000000000000, 70.000000000000000000, 71.000000000000000000, 72.000000000000000000, 73.000000000000000000, 74.000000000000000000, 75.000000000000000000, 76.000000000000000000, 77.000000000000000000, 78.000000000000000000, 79.000000000000000000, 80.000000000000000000, 81.000000000000000000, 82.000000000000000000, 83.000000000000000000, 84.000000000000000000, 85.000000000000000000, 86.000000000000000000, 87.000000000000000000, 88.000000000000000000, 89.000000000000000000, 90.000000000000000000, 91.000000000000000000, 92.000000000000000000, 93.000000000000000000, 94.000000000000000000, 95.000000000000000000, 96.000000000000000000, 97.000000000000000000, 98.000000000000000000, 99.000000000000000000]
    y-axis "Shares"
    line [0.000000000000000000, 1.000000000000000000, 1.414213562373095145, 1.732050807568877415, 2.000000000000000000, 2.236067977499789805, 2.449489742783178325, 2.645751311064590272, 2.828427124746190291, 3.000000000000000000, 3.162277660168379523, 3.316624790355399810, 3.464101615137754830, 3.605551275463989125, 3.741657386773941329, 3.872983346207417021, 4.000000000000000000, 4.123105625617660586, 4.242640687119285658, 4.358898943540673976, 4.472135954999579610, 4.582575694955839829, 4.690415759823429731, 4.795831523312720002, 4.898979485566356651, 5.000000000000000000, 5.099019513592784492, 5.196152422706632024, 5.291502622129180544, 5.385164807134503739, 5.477225575051661188, 5.567764362830021518, 5.656854249492380582, 5.744562646538028616, 5.830951894845300743, 5.916079783099616130, 6.000000000000000000, 6.082762530298219339, 6.164414002968976014, 6.244997998398398309, 6.324555320336759046, 6.403124237432848531, 6.480740698407860378, 6.557438524302001248, 6.633249580710799620, 6.708203932499368527, 6.782329983125268136, 6.855654600401044796, 6.928203230275509661, 7.000000000000000000, 7.071067811865475505, 7.141428428542850426, 7.211102550927978250, 7.280109889280518054, 7.348469228349534532, 7.416198487095662983, 7.483314773547882659, 7.549834435270749822, 7.615773105863908654, 7.681145747868608709, 7.745966692414834043, 7.810249675906653977, 7.874007874011811126, 7.937253933193772149, 8.000000000000000000, 8.062257748298549132, 8.124038404635960831, 8.185352771872450361, 8.246211251235321171, 8.306623862918074863, 8.366600265340755627, 8.426149773176359048, 8.485281374238571317, 8.544003745317532150, 8.602325267042626677, 8.660254037844387298, 8.717797887081347952, 8.774964387392122589, 8.831760866327847737, 8.888194417315588680, 8.944271909999159220, 9.000000000000000000, 9.055385138137417300, 9.110433579144299188, 9.165151389911679658, 9.219544457292887074, 9.273618495495703939, 9.327379053088815652, 9.380831519646859462, 9.433981132056604935, 9.486832980505136348, 9.539392014169456147, 9.591663046625440003, 9.643650760992954929, 9.695359714832658682, 9.746794344808964894, 9.797958971132713302, 9.848857801796103928, 9.899494936611665352, 9.949874371066199430]

Inherits: BaseCurve

Author: 0xIntuition

A bonding curve implementation that uses a progressive pricing model where each new share costs more than the last. The price follows the formula: $$P(s) = m \cdot s$$ where:

  • $m$ is the slope (in basis points)
  • $s$ is the total supply of shares The cost to mint shares is calculated as the area under this curve: $$\text{Cost} = (s_2^2 - s_1^2) \cdot \frac{m}{2}$$ where $s_1$ is the starting share supply and $s_2$ is the final share supply. This curve creates stronger incentives for early stakers compared to the LinearCurve, while maintaining fee-based appreciation.

Uses the prb-math library for fixed point arithmetic with UD60x18

Fixed point precision used for all internal calculations, while return values are all represented as regular uint256s, and unwrapped. I.e. we might use 123.456 internally and return 123.

The core equation: $$P(s) = m \cdot s$$ and the cost equation: $$\text{Cost} = (s_2^2 - s_1^2) \cdot \frac{m}{2}$$ comes from calculus - it's the integral of a linear price function. The area under a linear curve from point $s_1$ to $s_2$ gives us the total cost/return of minting/redeeming shares.

Inspired by the Solaxy.sol contract: https://github.com/M3tering/Solaxy/blob/main/src/Solaxy.sol and https://m3tering.whynotswitch.com/token-economics/mint-and-distribution. * The key difference between the Solaxy contract and this one is that the economic state is handled by the EthMultiVault instead of directly in the curve implementation. * Otherwise the math is identical.

State Variables

SLOPE

The slope of the curve, in basis points. This is the rate at which the price of shares increases.

0.0025e18 -> 25 basis points, 0.0001e18 = 1 basis point, etc etc

If minDeposit is 0.003 ether, this value would need to be 0.00007054e18 to avoid returning 0 shares for minDeposit assets

UD60x18 public SLOPE;

HALF_SLOPE

The half of the slope, used for calculations.

UD60x18 public HALF_SLOPE;

MAX_SHARES

Since powu(2) will overflow first (see slope equation), maximum totalShares is sqrt(MAX_UD60x18)

uint256 public MAX_SHARES;

MAX_ASSETS

The maximum assets is totalShares * slope / 2, because multiplication (see slope equation) would overflow beyond that point.

uint256 public MAX_ASSETS;

Functions

constructor

Constructs a new ProgressiveCurve with the given name and slope

Computes maximum values given constructor arguments

Computes Slope / 2 as commonly used constant

constructor(string memory _name, uint256 slope18) BaseCurve(_name);

Parameters

NameTypeDescription
_namestringThe name of the curve (i.e. "Progressive Curve #465")
slope18uint256The slope of the curve, in basis points (i.e. 0.0025e18)

previewDeposit

Preview how many shares would be minted for a deposit of assets

Let $s$ = current total supply

Let $a$ = amount of assets to deposit

Let $\frac{m}{2}$ = half of the slope

shares: $$\text{shares} = \sqrt{s^2 + \frac{a}{m/2}} - s$$

or to say that another way: $$\text{shares} = \sqrt{s^2 + \frac{2a}{m}} - s$$

function previewDeposit(uint256 assets, uint256, uint256 totalShares) external view override returns (uint256 shares);

Parameters

NameTypeDescription
assetsuint256Quantity of assets to deposit
<none>uint256
totalSharesuint256Total quantity of shares already awarded by the curve

Returns

NameTypeDescription
sharesuint256The number of shares that would be minted

previewRedeem

Preview how many assets would be returned for burning a specific amount of shares

Let $s$ = initial total supply of shares

Let $r$ = shares to redeem

Let $\frac{m}{2}$ = half of the slope

assets: $$\text{assets} = (s^2 - (s-r)^2) \cdot \frac{m}{2}$$

this can be expanded to: $$\text{assets} = (s^2 - (s^2 - 2sr + r^2)) \cdot \frac{m}{2}$$

which simplifies to: $$\text{assets} = (2sr - r^2) \cdot \frac{m}{2}$$

function previewRedeem(uint256 shares, uint256 totalShares, uint256) public view override returns (uint256 assets);

Parameters

NameTypeDescription
sharesuint256Quantity of shares to burn
totalSharesuint256Total quantity of shares already awarded by the curve
<none>uint256

Returns

NameTypeDescription
assetsuint256The number of assets that would be returned

previewMint

Preview how many assets would be required to mint a specific amount of shares

Let $s$ = current total supply of shares

Let $n$ = new shares to mint

Let $\frac{m}{2}$ = half of the slope

assets: $$\text{assets} = ((s + n)^2 - s^2) \cdot \frac{m}{2}$$

which can be expanded to: $$\text{assets} = (s^2 + 2sn + n^2 - s^2) \cdot \frac{m}{2}$$

which simplifies to: $$\text{assets} = (2sn + n^2) \cdot \frac{m}{2}$$

function previewMint(uint256 shares, uint256 totalShares, uint256) external view override returns (uint256 assets);

Parameters

NameTypeDescription
sharesuint256Quantity of shares to mint
totalSharesuint256Total quantity of shares already awarded by the curve
<none>uint256

Returns

NameTypeDescription
assetsuint256The number of assets that would be required to mint the shares

previewWithdraw

Preview how many shares would be redeemed for a withdrawal of assets

Let $s$ = current total supply of shares

Let $a$ = assets to withdraw

Let $\frac{m}{2}$ = half of the slope

shares: $$\text{shares} = s - \sqrt{s^2 - \frac{a}{m/2}}$$

or to say that another way: $$\text{shares} = s - \sqrt{s^2 - \frac{2a}{m}}$$

function previewWithdraw(uint256 assets, uint256, uint256 totalShares)
    external
    view
    override
    returns (uint256 shares);

Parameters

NameTypeDescription
assetsuint256Quantity of assets to withdraw
<none>uint256
totalSharesuint256Total quantity of shares already awarded by the curve

Returns

NameTypeDescription
sharesuint256The number of shares that would need to be redeemed

currentPrice

Get the current price of a share

Let $s$ = current total supply of shares

Let $m$ = the slope of the curve

sharePrice: $$\text{sharePrice} = s \cdot m$$

This is the basic linear price function where the price increases linearly with the total supply

And the slope ($m$) determines how quickly the price increases

TLDR: Each new share costs more than the last

function currentPrice(uint256 totalShares) public view override returns (uint256 sharePrice);

Parameters

NameTypeDescription
totalSharesuint256Total quantity of shares already awarded by the curve

Returns

NameTypeDescription
sharePriceuint256The current price of a share, scaled by 1e18

convertToShares

Convert assets to shares at a specific point on the curve

Let $s$ = current total supply of shares

Let $a$ = assets to convert to shares

Let $\frac{m}{2}$ = half of the slope

shares: $$\text{shares} = \frac{a}{s \cdot m/2}$$

Or to say that another way: $$\text{shares} = \frac{2a}{s \cdot m}$$

function convertToShares(uint256 assets, uint256, uint256 totalShares)
    external
    view
    override
    returns (uint256 shares);

Parameters

NameTypeDescription
assetsuint256Quantity of assets to convert to shares
<none>uint256
totalSharesuint256Total quantity of shares already awarded by the curve

Returns

NameTypeDescription
sharesuint256The number of shares equivalent to the given assets

convertToAssets

Convert shares to assets at a specific point on the curve

Let $s$ = current total supply of shares

Let $n$ = quantity of shares to convert to assets

conversion price: $$\text{price} = s \cdot \frac{m}{2}$$

where $\frac{m}{2}$ is average price per share

assets: $$\text{assets} = n \cdot (s \cdot \frac{m}{2})$$

Or to say that another way: $$\text{assets} = n \cdot s \cdot \frac{m}{2}$$

function convertToAssets(uint256 shares, uint256 totalShares, uint256)
    external
    view
    override
    returns (uint256 assets);

Parameters

NameTypeDescription
sharesuint256Quantity of shares to convert to assets
totalSharesuint256Total quantity of shares already awarded by the curve
<none>uint256

Returns

NameTypeDescription
assetsuint256The number of assets equivalent to the given shares

_convertToAssets

Computes assets as the area under a linear curve with a simplified form of the area of a trapezium: $$f(x) = mx + c$$ $$\text{Area} = \frac{1}{2} \cdot (a + b) \cdot h$$ where $a$ and $b$ can be both $f(\text{juniorSupply})$ or $f(\text{seniorSupply})$ depending if used in minting or redeeming. Calculates area as: $$(\text{seniorSupply}^2 - \text{juniorSupply}^2) \cdot \text{halfSlope}$$ where: $$\text{halfSlope} = \frac{\text{slope}}{2}$$

function _convertToAssets(UD60x18 juniorSupply, UD60x18 seniorSupply) internal view returns (UD60x18 assets);

Parameters

NameTypeDescription
juniorSupplyUD60x18The smaller supply in the operation (the initial supply during mint, or the final supply during a redeem operation).
seniorSupplyUD60x18The larger supply in the operation (the final supply during mint, or the initial supply during a redeem operation).

Returns

NameTypeDescription
assetsUD60x18The computed assets as an instance of UD60x18 (a fixed-point number).

maxShares

The maximum number of shares that this curve can handle without overflowing.

Checked by the EthMultiVault before transacting

function maxShares() external view override returns (uint256);

maxAssets

The maximum number of assets that this curve can handle without overflowing.

Checked by the EthMultiVault before transacting

function maxAssets() external view override returns (uint256);