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:
- Official Website
- Official Documentation
- Deep Dive into Our Smart Contracts
- Full Contracts Documentation
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 is8453
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
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
Name | Type | Description |
---|---|---|
<none> | string | name The name of the curve |
maxShares
Get the maximum number of shares the curve can handle
function maxShares() external view returns (uint256);
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | The maximum number of shares |
maxAssets
Get the maximum number of assets the curve can handle
function maxAssets() external view returns (uint256);
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | The 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
Name | Type | Description |
---|---|---|
assets | uint256 | Quantity of assets to deposit |
totalAssets | uint256 | Total quantity of assets already staked into the curve |
totalShares | uint256 | Total quantity of shares already awarded by the curve |
Returns
Name | Type | Description |
---|---|---|
shares | uint256 | The 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
Name | Type | Description |
---|---|---|
shares | uint256 | Quantity of shares to burn |
totalShares | uint256 | Total quantity of shares already awarded by the curve |
totalAssets | uint256 | Total quantity of assets already staked into the curve |
Returns
Name | Type | Description |
---|---|---|
assets | uint256 | The 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
Name | Type | Description |
---|---|---|
assets | uint256 | Quantity of assets to withdraw |
totalAssets | uint256 | Total quantity of assets already staked into the curve |
totalShares | uint256 | Total quantity of shares already awarded by the curve |
Returns
Name | Type | Description |
---|---|---|
shares | uint256 | The 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
Name | Type | Description |
---|---|---|
shares | uint256 | Quantity of shares to mint |
totalShares | uint256 | Total quantity of shares already awarded by the curve |
totalAssets | uint256 | Total quantity of assets already staked into the curve |
Returns
Name | Type | Description |
---|---|---|
assets | uint256 | The 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
Name | Type | Description |
---|---|---|
assets | uint256 | Quantity of assets to convert to shares |
totalAssets | uint256 | Total quantity of assets already staked into the curve |
totalShares | uint256 | Total quantity of shares already awarded by the curve |
Returns
Name | Type | Description |
---|---|---|
shares | uint256 | The 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
Name | Type | Description |
---|---|---|
shares | uint256 | Quantity of shares to convert to assets |
totalShares | uint256 | Total quantity of shares already awarded by the curve |
totalAssets | uint256 | Total quantity of assets already staked into the curve |
Returns
Name | Type | Description |
---|---|---|
assets | uint256 | The 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
Name | Type | Description |
---|---|---|
totalShares | uint256 | Total quantity of shares already awarded by the curve |
Returns
Name | Type | Description |
---|---|---|
sharePrice | uint256 | The current price of a share, scaled by 1e18 |
IBondingCurveRegistry
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
Name | Type | Description |
---|---|---|
assets | uint256 | Quantity of assets to deposit |
totalAssets | uint256 | Total quantity of assets already staked into the curve |
totalShares | uint256 | Total quantity of shares already awarded by the curve |
id | uint256 | Curve ID to use for the calculation |
Returns
Name | Type | Description |
---|---|---|
shares | uint256 | The 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
Name | Type | Description |
---|---|---|
shares | uint256 | Quantity of shares to burn |
totalShares | uint256 | Total quantity of shares already awarded by the curve |
totalAssets | uint256 | Total quantity of assets already staked into the curve |
id | uint256 | Curve ID to use for the calculation |
Returns
Name | Type | Description |
---|---|---|
assets | uint256 | The 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
Name | Type | Description |
---|---|---|
assets | uint256 | Quantity of assets to withdraw |
totalAssets | uint256 | Total quantity of assets already staked into the curve |
totalShares | uint256 | Total quantity of shares already awarded by the curve |
id | uint256 | Curve ID to use for the calculation |
Returns
Name | Type | Description |
---|---|---|
shares | uint256 | The 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
Name | Type | Description |
---|---|---|
shares | uint256 | Quantity of shares to mint |
totalShares | uint256 | Total quantity of shares already awarded by the curve |
totalAssets | uint256 | Total quantity of assets already staked into the curve |
id | uint256 | Curve ID to use for the calculation |
Returns
Name | Type | Description |
---|---|---|
assets | uint256 | The 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
Name | Type | Description |
---|---|---|
assets | uint256 | Quantity of assets to convert to shares |
totalAssets | uint256 | Total quantity of assets already staked into the curve |
totalShares | uint256 | Total quantity of shares already awarded by the curve |
id | uint256 | Curve ID to use for the calculation |
Returns
Name | Type | Description |
---|---|---|
shares | uint256 | The 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
Name | Type | Description |
---|---|---|
shares | uint256 | Quantity of shares to convert to assets |
totalShares | uint256 | Total quantity of shares already awarded by the curve |
totalAssets | uint256 | Total quantity of assets already staked into the curve |
id | uint256 | Curve ID to use for the calculation |
Returns
Name | Type | Description |
---|---|---|
assets | uint256 | The 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
Name | Type | Description |
---|---|---|
totalShares | uint256 | Total quantity of shares already awarded by the curve |
id | uint256 | Curve ID to use for the calculation |
Returns
Name | Type | Description |
---|---|---|
sharePrice | uint256 | The current price of a share |
getCurveName
Get the name of a curve
function getCurveName(uint256 id) external view returns (string memory name);
Parameters
Name | Type | Description |
---|---|---|
id | uint256 | Curve ID to query |
Returns
Name | Type | Description |
---|---|---|
name | string | The 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
Name | Type | Description |
---|---|---|
id | uint256 | Curve ID to query |
Returns
Name | Type | Description |
---|---|---|
maxShares | uint256 | The 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
Name | Type | Description |
---|---|---|
id | uint256 | Curve ID to query |
Returns
Name | Type | Description |
---|---|---|
maxAssets | uint256 | The maximum number of assets |
count
Get the number of curves registered in the registry
function count() external view returns (uint256);
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | count The number of curves registered |
curveAddresses
Get the curve address for a given ID
function curveAddresses(uint256 id) external view returns (address);
Parameters
Name | Type | Description |
---|---|---|
id | uint256 | The curve ID to query |
Returns
Name | Type | Description |
---|---|---|
<none> | address | The address of the curve |
curveIds
Get the curve ID for a given address
function curveIds(address curve) external view returns (uint256);
Parameters
Name | Type | Description |
---|---|---|
curve | address | The curve address to query |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | The ID of the curve |
IEthMultiVault
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
Name | Type | Description |
---|---|---|
_generalConfig | GeneralConfig | General configuration struct |
_atomConfig | AtomConfig | Atom configuration struct |
_tripleConfig | TripleConfig | Triple configuration struct |
_walletConfig | WalletConfig | Wallet configuration struct |
_defaultVaultFees | VaultFees | Default vault fees struct NOTE: This function is called only once (during contract deployment) |
_bondingCurveConfig | BondingCurveConfig |
reinitialize
Reinitialize the contract with new bonding curve configuration
function reinitialize(BondingCurveConfig calldata bondingCurveConfig) external;
Parameters
Name | Type | Description |
---|---|---|
bondingCurveConfig | BondingCurveConfig | The 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
Name | Type | Description |
---|---|---|
operationId | bytes32 | unique identifier for the operation |
data | bytes | data to be executed |
cancelOperation
execute a scheduled operation
function cancelOperation(bytes32 operationId, bytes calldata data) external;
Parameters
Name | Type | Description |
---|---|---|
operationId | bytes32 | unique identifier for the operation |
data | bytes | data to be executed |
setAdmin
Requires new admin to 'confirm' the timelocked operation
set admin
function setAdmin(address admin) external;
Parameters
Name | Type | Description |
---|---|---|
admin | address | address of the new admin |
setProtocolMultisig
set protocol multisig
function setProtocolMultisig(address protocolMultisig) external;
Parameters
Name | Type | Description |
---|---|---|
protocolMultisig | address | address of the new protocol multisig |
setMinDeposit
sets the minimum deposit amount for atoms and triples
function setMinDeposit(uint256 minDeposit) external;
Parameters
Name | Type | Description |
---|---|---|
minDeposit | uint256 | new minimum deposit amount |
setMinShare
sets the minimum share amount for atoms and triples
function setMinShare(uint256 minShare) external;
Parameters
Name | Type | Description |
---|---|---|
minShare | uint256 | new minimum share amount |
setAtomUriMaxLength
sets the atom URI max length
function setAtomUriMaxLength(uint256 atomUriMaxLength) external;
Parameters
Name | Type | Description |
---|---|---|
atomUriMaxLength | uint256 | new atom URI max length |
setAtomWalletInitialDepositAmount
sets the atom share lock fee
function setAtomWalletInitialDepositAmount(uint256 atomWalletInitialDepositAmount) external;
Parameters
Name | Type | Description |
---|---|---|
atomWalletInitialDepositAmount | uint256 | new atom share lock fee |
setAtomCreationProtocolFee
sets the atom creation fee
function setAtomCreationProtocolFee(uint256 atomCreationProtocolFee) external;
Parameters
Name | Type | Description |
---|---|---|
atomCreationProtocolFee | uint256 | new atom creation fee |
setTripleCreationProtocolFee
sets fee charged in wei when creating a triple to protocol multisig
function setTripleCreationProtocolFee(uint256 tripleCreationProtocolFee) external;
Parameters
Name | Type | Description |
---|---|---|
tripleCreationProtocolFee | uint256 | new 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
Name | Type | Description |
---|---|---|
totalAtomDepositsOnTripleCreation | uint256 | new 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
Name | Type | Description |
---|---|---|
atomDepositFractionForTriple | uint256 | new atom deposit fraction percentage |
setBondingCurveConfig
sets the bonding curve configuration
function setBondingCurveConfig(address registry, uint256 defaultCurveId) external;
Parameters
Name | Type | Description |
---|---|---|
registry | address | address of the new bonding curve registry |
defaultCurveId | uint256 | new 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
Name | Type | Description |
---|---|---|
id | uint256 | vault id to set entry fee for |
entryFee | uint256 | entry 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
Name | Type | Description |
---|---|---|
id | uint256 | vault id to set exit fee for |
exitFee | uint256 | exit 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
Name | Type | Description |
---|---|---|
id | uint256 | vault id to set protocol fee for |
protocolFee | uint256 | protocol fee to set |
setAtomWarden
sets the atomWarden address
function setAtomWarden(address atomWarden) external;
Parameters
Name | Type | Description |
---|---|---|
atomWarden | address | address of the new atomWarden |
deployAtomWallet
deploy a given atom wallet
function deployAtomWallet(uint256 atomId) external returns (address);
Parameters
Name | Type | Description |
---|---|---|
atomId | uint256 | vault id of atom |
Returns
Name | Type | Description |
---|---|---|
<none> | address | atomWallet 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
Name | Type | Description |
---|---|---|
sender | address | address to set approval for |
approvalType | ApprovalTypes | type 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
Name | Type | Description |
---|---|---|
atomUri | bytes | atom data to create atom with |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | id 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
Name | Type | Description |
---|---|---|
atomUris | bytes[] | atom data array to create atoms with |
Returns
Name | Type | Description |
---|---|---|
<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
Name | Type | Description |
---|---|---|
subjectId | uint256 | vault id of the subject atom |
predicateId | uint256 | vault id of the predicate atom |
objectId | uint256 | vault id of the object atom |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | id 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
Name | Type | Description |
---|---|---|
subjectIds | uint256[] | vault ids array of subject atoms |
predicateIds | uint256[] | vault ids array of predicate atoms |
objectIds | uint256[] | 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
Name | Type | Description |
---|---|---|
receiver | address | the address to receive the shares |
id | uint256 | the vault ID of the atom |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | shares 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
Name | Type | Description |
---|---|---|
receiver | address | the address to receive the shares |
atomId | uint256 | the vault ID of the atom |
curveId | uint256 | the vault ID of the curve |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | shares 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
Name | Type | Description |
---|---|---|
shares | uint256 | the amount of shares to redeem |
receiver | address | the address to receiver the assets |
id | uint256 | the vault ID of the atom |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | assets 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
Name | Type | Description |
---|---|---|
shares | uint256 | the amount of shares to redeem |
receiver | address | the address to receiver the assets |
atomId | uint256 | the vault ID of the atom |
curveId | uint256 | the vault ID of the curve |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | assets 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
Name | Type | Description |
---|---|---|
receiver | address | the address to receive the shares |
id | uint256 | the vault ID of the triple |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | shares 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
Name | Type | Description |
---|---|---|
receiver | address | the address to receive the shares |
tripleId | uint256 | the vault ID of the triple |
curveId | uint256 | the vault ID of the curve |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | shares 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
Name | Type | Description |
---|---|---|
shares | uint256 | the amount of shares to redeem |
receiver | address | the address to receiver the assets |
id | uint256 | the vault ID of the triple |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | assets 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
Name | Type | Description |
---|---|---|
shares | uint256 | the amount of shares to redeem |
receiver | address | the address to receiver the assets |
tripleId | uint256 | the vault ID of the triple |
curveId | uint256 | the vault ID of the curve |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | assets 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
Name | Type | Description |
---|---|---|
receiver | address | the address to receive the shares |
termIds | uint256[] | the IDs of the terms (atoms, triples, or counter-triples) to deposit into |
amounts | uint256[] | array of the amount to deposit in each vault |
Returns
Name | Type | Description |
---|---|---|
<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
Name | Type | Description |
---|---|---|
receiver | address | the address to receive the shares |
termIds | uint256[] | array of the vault IDs of the terms (atoms, triples, or counter-triples) |
curveIds | uint256[] | array of the vault IDs of the curves |
amounts | uint256[] | array of the amount to deposit in each vault |
Returns
Name | Type | Description |
---|---|---|
<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
Name | Type | Description |
---|---|---|
percentage | uint256 | the percentage of shares to redeem from each vault (i.e. 50% -> 50, 100% -> 100) |
receiver | address | the address to receiver the assets |
ids | uint256[] | array of IDs of the term (atom, triple or counter-triple) to redeem from |
Returns
Name | Type | Description |
---|---|---|
<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
Name | Type | Description |
---|---|---|
percentage | uint256 | the percentage of shares to redeem from the vaults |
receiver | address | the address to receiver the assets |
termIds | uint256[] | array of the IDs of the terms (atoms, triples, or counter-triples) |
curveIds | uint256[] | array of the IDs of the curves for each term |
Returns
Name | Type | Description |
---|---|---|
<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
Name | Type | Description |
---|---|---|
<none> | uint256 | atomCost the cost of creating an atom |
getTripleCost
returns the cost of creating a triple
function getTripleCost() external view returns (uint256);
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | tripleCost 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
Name | Type | Description |
---|---|---|
assets | uint256 | amount of assets to calculate fees on |
id | uint256 | vault id to get corresponding fees for |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | totalFees 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
Name | Type | Description |
---|---|---|
assets | uint256 | amount of assets to calculate fees on (should always be msg.value - protocolFee) |
id | uint256 | vault id to get corresponding fees for |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | totalAssetsDelta changes in vault's total assets |
<none> | uint256 | sharesForReceiver changes in vault's total shares (shares owed to receiver) |
<none> | uint256 | userAssetsAfterTotalFees amount of assets that goes towards minting shares for the receiver |
<none> | uint256 | entryFee 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
Name | Type | Description |
---|---|---|
shares | uint256 | amount of shares to calculate fees on |
id | uint256 | vault id to get corresponding fees for |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | totalUserAssets total amount of assets user would receive if redeeming 'shares', not including fees |
<none> | uint256 | assetsForReceiver amount of assets that is redeemable by the receiver |
<none> | uint256 | protocolFee amount of assets that would be sent to the protocol multisig |
<none> | uint256 | exitFee 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
Name | Type | Description |
---|---|---|
assets | uint256 | amount of assets to calculate fee on |
id | uint256 | vault id to get corresponding fees for |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | feeAmount 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
Name | Type | Description |
---|---|---|
assets | uint256 | amount of assets to calculate fee on |
id | uint256 | vault id to get corresponding fees for |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | feeAmount 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
Name | Type | Description |
---|---|---|
assets | uint256 | amount of assets to calculate fee on |
id | uint256 | vault id to get corresponding fees for |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | feeAmount 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
Name | Type | Description |
---|---|---|
assets | uint256 | amount of assets to calculate fee on |
id | uint256 | vault id |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | feeAmount 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
Name | Type | Description |
---|---|---|
id | uint256 | vault id to get corresponding share price for |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | price 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
Name | Type | Description |
---|---|---|
owner | address | address of the account to get max redeemable shares for |
id | uint256 | vault id to get corresponding shares for |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | shares 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
Name | Type | Description |
---|---|---|
assets | uint256 | amount of assets to calculate shares on |
id | uint256 | vault id to get corresponding shares for |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | shares 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
Name | Type | Description |
---|---|---|
shares | uint256 | amount of shares to calculate assets on |
id | uint256 | vault id to get corresponding assets for |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | assets 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
Name | Type | Description |
---|---|---|
assets | uint256 | amount of assets to calculate shares on |
id | uint256 | vault id to get corresponding shares for |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | shares 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
Name | Type | Description |
---|---|---|
shares | uint256 | amount of shares to calculate assets on |
id | uint256 | vault id to get corresponding assets for |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | assets 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
Name | Type | Description |
---|---|---|
id | uint256 | vault id of the triple |
Returns
Name | Type | Description |
---|---|---|
<none> | bytes32 | hash 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
Name | Type | Description |
---|---|---|
id | uint256 | vault id to check |
Returns
Name | Type | Description |
---|---|---|
<none> | bool | bool 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
Name | Type | Description |
---|---|---|
id | uint256 | vault id of the triple/counter-triple |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | tuple(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
Name | Type | Description |
---|---|---|
subjectId | uint256 | the subject atom's vault id |
predicateId | uint256 | the predicate atom's vault id |
objectId | uint256 | the object atom's vault id |
Returns
Name | Type | Description |
---|---|---|
<none> | bytes32 | hash 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
Name | Type | Description |
---|---|---|
id | uint256 | vault id of the triple |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | counterId 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
Name | Type | Description |
---|---|---|
vaultId | uint256 | vault id of the vault |
receiver | address | address of the receiver |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | shares number of shares user has in the vault |
<none> | uint256 | assets 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
Name | Type | Description |
---|---|---|
vaultId | uint256 | vault id of the vault |
curveId | uint256 | curve id of the curve |
receiver | address | address of the receiver |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | shares 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
Name | Type | Description |
---|---|---|
assets | uint256 | amount of assets to calculate fees on (should always be msg.value - protocolFee) |
vaultId | uint256 | vault id to get corresponding fees for |
curveId | uint256 | curve id to get corresponding fees for |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | totalAssetsDelta changes in vault's total assets |
<none> | uint256 | sharesForReceiver changes in vault's total shares (shares owed to receiver) |
<none> | uint256 | userAssetsAfterTotalFees amount of assets that goes towards minting shares for the receiver |
<none> | uint256 | entryFee 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
Name | Type | Description |
---|---|---|
shares | uint256 | amount of shares to calculate fees on |
vaultId | uint256 | vault id to get corresponding fees for |
curveId | uint256 | curve id to get corresponding fees for |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | totalUserAssets total amount of assets user would receive if redeeming 'shares', not including fees |
<none> | uint256 | assetsForReceiver amount of assets that is redeemable by the receiver |
<none> | uint256 | protocolFee amount of assets that would be sent to the protocol multisig |
<none> | uint256 | exitFee 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
Name | Type | Description |
---|---|---|
vaultId | uint256 | vault id to get corresponding share price for |
curveId | uint256 | curve id to get corresponding share price for |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | price 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
Name | Type | Description |
---|---|---|
curveId | uint256 | curve id to get corresponding max deposit for |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | maxAssets 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
Name | Type | Description |
---|---|---|
owner | address | address of the account to get max redeemable shares for |
vaultId | uint256 | vault id to get corresponding shares for |
curveId | uint256 | curve id to get corresponding shares for |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | shares 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
Name | Type | Description |
---|---|---|
assets | uint256 | amount of assets to calculate shares on |
vaultId | uint256 | vault id to get corresponding shares for |
curveId | uint256 | curve id to get corresponding shares for |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | shares 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
Name | Type | Description |
---|---|---|
shares | uint256 | amount of shares to calculate assets on |
vaultId | uint256 | vault id to get corresponding assets for |
curveId | uint256 | curve id to get corresponding assets for |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | assets 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
Name | Type | Description |
---|---|---|
assets | uint256 | amount of assets to calculate shares on |
vaultId | uint256 | vault id to get corresponding shares for |
curveId | uint256 | curve id to get corresponding shares for |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | shares 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
Name | Type | Description |
---|---|---|
shares | uint256 | amount of shares to calculate assets on |
vaultId | uint256 | vault id to get corresponding assets for |
curveId | uint256 | curve id to get corresponding assets for |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | assets 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
Name | Type | Description |
---|---|---|
id | uint256 | vault id of the atom associated to the atom wallet |
Returns
Name | Type | Description |
---|---|---|
<none> | address | atomWallet 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
Name | Type | Description |
---|---|---|
sender | address | The address of the sender |
receiver | address | The address of the receiver |
Returns
Name | Type | Description |
---|---|---|
<none> | bool | bool 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
Name | Type | Description |
---|---|---|
sender | address | The address of the sender |
receiver | address | The address of the receiver |
Returns
Name | Type | Description |
---|---|---|
<none> | bool | bool 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
Name | Type | Description |
---|---|---|
sender | address | address of the sender being approved/disapproved |
receiver | address | address of the receiver granting/revoking approval |
approvalType | ApprovalTypes | the 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
Name | Type | Description |
---|---|---|
sender | address | initializer of the deposit |
receiver | address | beneficiary of the minted shares |
receiverTotalSharesInVault | uint256 | total shares held by the receiver in the vault |
senderAssetsAfterTotalFees | uint256 | total assets that go towards minting shares for the receiver |
sharesForReceiver | uint256 | total shares minted for the receiver |
entryFee | uint256 | total fee amount collected for entering the vault |
vaultId | uint256 | vault id of the vault being deposited into |
isTriple | bool | whether the vault is a triple vault or not |
isAtomWallet | bool | whether 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
Name | Type | Description |
---|---|---|
sender | address | initializer of the withdrawal (owner of the shares) |
receiver | address | beneficiary of the withdrawn assets (can be different from the sender) |
senderTotalSharesInVault | uint256 | total shares held by the sender in the vault |
assetsForReceiver | uint256 | quantity of assets withdrawn by the receiver |
sharesRedeemedBySender | uint256 | quantity of shares redeemed by the sender |
exitFee | uint256 | total fee amount collected for exiting the vault |
vaultId | uint256 | vault 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
Name | Type | Description |
---|---|---|
creator | address | address of the atom creator |
atomWallet | address | address of the atom's associated abstract account |
atomData | bytes | the atom's respective string |
vaultId | uint256 | the 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
Name | Type | Description |
---|---|---|
creator | address | address of the triple creator |
subjectId | uint256 | the triple's respective subject atom |
predicateId | uint256 | the triple's respective predicate atom |
objectId | uint256 | the triple's respective object atom |
vaultId | uint256 | the 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
Name | Type | Description |
---|---|---|
sender | address | address of the sender |
protocolMultisig | address | address of the protocol multisig |
amount | uint256 | amount of fees transferred |
OperationScheduled
emitted upon scheduling an operation
event OperationScheduled(bytes32 indexed operationId, bytes data, uint256 readyTime);
Parameters
Name | Type | Description |
---|---|---|
operationId | bytes32 | unique identifier for the operation |
data | bytes | data to be executed |
readyTime | uint256 | block number when the operation is ready |
OperationExecuted
emitted upon executing an operation
event OperationExecuted(bytes32 indexed operationId, bytes data);
Parameters
Name | Type | Description |
---|---|---|
operationId | bytes32 | unique identifier for the operation |
data | bytes | data of the operation that was executed |
OperationCancelled
emitted upon cancelling an operation
event OperationCancelled(bytes32 indexed operationId, bytes data);
Parameters
Name | Type | Description |
---|---|---|
operationId | bytes32 | unique identifier for the operation |
data | bytes | data of the operation that was cancelled |
AdminSet
emitted upon changing the admin
event AdminSet(address indexed newAdmin, address indexed oldAdmin);
Parameters
Name | Type | Description |
---|---|---|
newAdmin | address | address of the new admin |
oldAdmin | address | address of the old admin |
protocolMultisigSet
emitted upon changing the protocol multisig
event protocolMultisigSet(address indexed newProtocolMultisig, address indexed oldProtocolMultisig);
Parameters
Name | Type | Description |
---|---|---|
newProtocolMultisig | address | address of the new protocol multisig |
oldProtocolMultisig | address | address of the old protocol multisig |
MinDepositSet
emitted upon changing the minimum deposit amount
event MinDepositSet(uint256 newMinDeposit, uint256 oldMinDeposit);
Parameters
Name | Type | Description |
---|---|---|
newMinDeposit | uint256 | new minimum deposit amount |
oldMinDeposit | uint256 | old minimum deposit amount |
MinShareSet
emitted upon changing the minimum share amount
event MinShareSet(uint256 newMinShare, uint256 oldMinShare);
Parameters
Name | Type | Description |
---|---|---|
newMinShare | uint256 | new minimum share amount |
oldMinShare | uint256 | old minimum share amount |
AtomUriMaxLengthSet
emitted upon changing the atom URI max length
event AtomUriMaxLengthSet(uint256 newAtomUriMaxLength, uint256 oldAtomUriMaxLength);
Parameters
Name | Type | Description |
---|---|---|
newAtomUriMaxLength | uint256 | new atom URI max length |
oldAtomUriMaxLength | uint256 | old atom URI max length |
AtomWalletInitialDepositAmountSet
emitted upon changing the atom share lock fee
event AtomWalletInitialDepositAmountSet(
uint256 newAtomWalletInitialDepositAmount, uint256 oldAtomWalletInitialDepositAmount
);
Parameters
Name | Type | Description |
---|---|---|
newAtomWalletInitialDepositAmount | uint256 | new atom share lock fee |
oldAtomWalletInitialDepositAmount | uint256 | old atom share lock fee |
AtomCreationProtocolFeeSet
emitted upon changing the atom creation fee
event AtomCreationProtocolFeeSet(uint256 newAtomCreationProtocolFee, uint256 oldAtomCreationProtocolFee);
Parameters
Name | Type | Description |
---|---|---|
newAtomCreationProtocolFee | uint256 | new atom creation fee |
oldAtomCreationProtocolFee | uint256 | old atom creation fee |
TripleCreationProtocolFeeSet
emitted upon changing the triple creation fee
event TripleCreationProtocolFeeSet(uint256 newTripleCreationProtocolFee, uint256 oldTripleCreationProtocolFee);
Parameters
Name | Type | Description |
---|---|---|
newTripleCreationProtocolFee | uint256 | new triple creation fee |
oldTripleCreationProtocolFee | uint256 | old triple creation fee |
TotalAtomDepositsOnTripleCreationSet
emitted upon changing the atom deposit fraction on triple creation
event TotalAtomDepositsOnTripleCreationSet(
uint256 newTotalAtomDepositsOnTripleCreation, uint256 oldTotalAtomDepositsOnTripleCreation
);
Parameters
Name | Type | Description |
---|---|---|
newTotalAtomDepositsOnTripleCreation | uint256 | new atom deposit fraction on triple creation |
oldTotalAtomDepositsOnTripleCreation | uint256 | old atom deposit fraction on triple creation |
AtomDepositFractionForTripleSet
emitted upon changing the atom deposit fraction for triples
event AtomDepositFractionForTripleSet(uint256 newAtomDepositFractionForTriple, uint256 oldAtomDepositFractionForTriple);
Parameters
Name | Type | Description |
---|---|---|
newAtomDepositFractionForTriple | uint256 | new atom deposit fraction for triples |
oldAtomDepositFractionForTriple | uint256 | old 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
Name | Type | Description |
---|---|---|
newRegistry | address | address of the new bonding curve registry |
newDefaultCurveId | uint256 | new default curve ID |
oldRegistry | address | address of the old bonding curve registry |
oldDefaultCurveId | uint256 | old default curve ID |
EntryFeeSet
emitted upon changing the entry fee
event EntryFeeSet(uint256 id, uint256 newEntryFee, uint256 oldEntryFee);
Parameters
Name | Type | Description |
---|---|---|
id | uint256 | vault id to set entry fee for |
newEntryFee | uint256 | new entry fee for the vault |
oldEntryFee | uint256 | old entry fee for the vault |
ExitFeeSet
emitted upon changing the exit fee
event ExitFeeSet(uint256 id, uint256 newExitFee, uint256 oldExitFee);
Parameters
Name | Type | Description |
---|---|---|
id | uint256 | vault id to set exit fee for |
newExitFee | uint256 | new exit fee for the vault |
oldExitFee | uint256 | old exit fee for the vault |
ProtocolFeeSet
emitted upon changing the protocol fee
event ProtocolFeeSet(uint256 id, uint256 newProtocolFee, uint256 oldProtocolFee);
Parameters
Name | Type | Description |
---|---|---|
id | uint256 | vault id to set protocol fee for |
newProtocolFee | uint256 | new protocol fee for the vault |
oldProtocolFee | uint256 | old protocol fee for the vault |
AtomWardenSet
emitted upon changing the atomWarden
event AtomWardenSet(address indexed newAtomWarden, address indexed oldAtomWarden);
Parameters
Name | Type | Description |
---|---|---|
newAtomWarden | address | address of the new atomWarden |
oldAtomWarden | address | address of the old atomWarden |
AtomWalletDeployed
emitted upon deploying an atom wallet
event AtomWalletDeployed(uint256 indexed vaultId, address indexed atomWallet);
Parameters
Name | Type | Description |
---|---|---|
vaultId | uint256 | vault id of the atom |
atomWallet | address | address 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
Name | Type | Description |
---|---|---|
termId | uint256 | id of the atom, triple or counter triple |
newSharePrice | uint256 | new share price of the vault |
totalAssets | uint256 | new total assets in vault |
totalShares | uint256 | new 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
Name | Type | Description |
---|---|---|
termId | uint256 | id of the atom, triple or counter triple |
curveId | uint256 | curve id of the curve |
newSharePrice | uint256 | new share price of the curve vault |
totalAssets | uint256 | new total assets in vault |
totalShares | uint256 | new 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
Functions
permitTransferFrom
Consume a permit2 message and transfer tokens
function permitTransferFrom(
PermitTransferFrom calldata permit,
SignatureTransferDetails calldata transferDetails,
address owner,
bytes calldata signature
) external;
Parameters
Name | Type | Description |
---|---|---|
permit | PermitTransferFrom | The permit message |
transferDetails | SignatureTransferDetails | Details for the transfer |
owner | address | The owner of the tokens |
signature | bytes | The 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
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
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
Name | Type | Description |
---|---|---|
anEntryPoint | IEntryPoint | the entry point contract address |
_ethMultiVault | IEthMultiVault | the EthMultiVault contract address |
receive
receive() external payable;
execute
function execute(address dest, uint256 value, bytes calldata func)
external
payable
onlyOwnerOrEntryPoint
nonReentrant;
Parameters
Name | Type | Description |
---|---|---|
dest | address | the target address |
value | uint256 | the value to send |
func | bytes | the 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
Name | Type | Description |
---|---|---|
dest | address[] | the target addresses array |
values | uint256[] | |
func | bytes[] | 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
Name | Type | Description |
---|---|---|
withdrawAddress | address payable | target to send to |
amount | uint256 | to withdraw |
transferOwnership
Initiates the ownership transfer over the wallet to a new owner.
function transferOwnership(address newOwner) public override onlyOwner;
Parameters
Name | Type | Description |
---|---|---|
newOwner | address | the 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
Name | Type | Description |
---|---|---|
<none> | IEntryPoint | the 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
Name | Type | Description |
---|---|---|
<none> | address | the 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
Name | Type | Description |
---|---|---|
userOp | UserOperation | the user operation |
userOpHash | bytes32 | the hash of the user operation |
Returns
Name | Type | Description |
---|---|---|
validationData | uint256 | the 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
Name | Type | Description |
---|---|---|
target | address | the target address |
value | uint256 | the value to send |
data | bytes | the 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
Name | Type | Description |
---|---|---|
callData | bytes | the call data |
Returns
Name | Type | Description |
---|---|---|
validUntil | uint256 | the valid until timestamp |
validAfter | uint256 | the valid after timestamp |
actualCallData | bytes | the 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
Name | Type | Description |
---|---|---|
$ | OwnableStorage | the storage slot |
_getAtomWalletPendingOwnerStorage
Get the storage slot for the AtomWallet contract pending owner
function _getAtomWalletPendingOwnerStorage() private pure returns (Ownable2StepStorage storage $);
Returns
Name | Type | Description |
---|---|---|
$ | Ownable2StepStorage | the storage slot |
BaseCurve
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
Name | Type | Description |
---|---|---|
_name | string | Unique 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
Name | Type | Description |
---|---|---|
assets | uint256 | Quantity of assets to deposit |
totalAssets | uint256 | Total quantity of assets already staked into the curve |
totalShares | uint256 | Total quantity of shares already awarded by the curve |
Returns
Name | Type | Description |
---|---|---|
shares | uint256 | The 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
Name | Type | Description |
---|---|---|
shares | uint256 | Quantity of shares to mint |
totalShares | uint256 | Total quantity of shares already awarded by the curve |
totalAssets | uint256 | Total quantity of assets already staked into the curve |
Returns
Name | Type | Description |
---|---|---|
assets | uint256 | The 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
Name | Type | Description |
---|---|---|
assets | uint256 | Quantity of assets to withdraw |
totalAssets | uint256 | Total quantity of assets already staked into the curve |
totalShares | uint256 | Total quantity of shares already awarded by the curve |
Returns
Name | Type | Description |
---|---|---|
shares | uint256 | The 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
Name | Type | Description |
---|---|---|
shares | uint256 | Quantity of shares to burn |
totalShares | uint256 | Total quantity of shares already awarded by the curve |
totalAssets | uint256 | Total quantity of assets already staked into the curve |
Returns
Name | Type | Description |
---|---|---|
assets | uint256 | The 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
Name | Type | Description |
---|---|---|
assets | uint256 | Quantity of assets to convert to shares |
totalAssets | uint256 | Total quantity of assets already staked into the curve |
totalShares | uint256 | Total quantity of shares already awarded by the curve |
Returns
Name | Type | Description |
---|---|---|
shares | uint256 | The 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
Name | Type | Description |
---|---|---|
shares | uint256 | Quantity of shares to convert to assets |
totalShares | uint256 | Total quantity of shares already awarded by the curve |
totalAssets | uint256 | Total quantity of assets already staked into the curve |
Returns
Name | Type | Description |
---|---|---|
assets | uint256 | The 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
Name | Type | Description |
---|---|---|
totalShares | uint256 | Total quantity of shares already awarded by the curve |
Returns
Name | Type | Description |
---|---|---|
sharePrice | uint256 | The current price of a share, scaled by 1e18 |
BondingCurveRegistry
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
Name | Type | Description |
---|---|---|
_admin | address | Address who may add curves to the registry |
addBondingCurve
Add a new bonding curve to the registry
function addBondingCurve(address bondingCurve) external;
Parameters
Name | Type | Description |
---|---|---|
bondingCurve | address | Address of the new bonding curve |
transferOwnership
Transfer the admin role to a new address
function transferOwnership(address newOwner) external;
Parameters
Name | Type | Description |
---|---|---|
newOwner | address | The 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
Name | Type | Description |
---|---|---|
assets | uint256 | Quantity of assets to deposit |
totalAssets | uint256 | Total quantity of assets already staked into the curve |
totalShares | uint256 | Total quantity of shares already awarded by the curve |
id | uint256 | Curve ID to use for the calculation |
Returns
Name | Type | Description |
---|---|---|
shares | uint256 | The 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
Name | Type | Description |
---|---|---|
shares | uint256 | Quantity of shares to burn |
totalShares | uint256 | Total quantity of shares already awarded by the curve |
totalAssets | uint256 | Total quantity of assets already staked into the curve |
id | uint256 | Curve ID to use for the calculation |
Returns
Name | Type | Description |
---|---|---|
assets | uint256 | The 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
Name | Type | Description |
---|---|---|
assets | uint256 | Quantity of assets to withdraw |
totalAssets | uint256 | Total quantity of assets already staked into the curve |
totalShares | uint256 | Total quantity of shares already awarded by the curve |
id | uint256 | Curve ID to use for the calculation |
Returns
Name | Type | Description |
---|---|---|
shares | uint256 | The 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
Name | Type | Description |
---|---|---|
shares | uint256 | Quantity of shares to mint |
totalShares | uint256 | Total quantity of shares already awarded by the curve |
totalAssets | uint256 | Total quantity of assets already staked into the curve |
id | uint256 | Curve ID to use for the calculation |
Returns
Name | Type | Description |
---|---|---|
assets | uint256 | The 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
Name | Type | Description |
---|---|---|
assets | uint256 | Quantity of assets to convert to shares |
totalAssets | uint256 | Total quantity of assets already staked into the curve |
totalShares | uint256 | Total quantity of shares already awarded by the curve |
id | uint256 | Curve ID to use for the calculation |
Returns
Name | Type | Description |
---|---|---|
shares | uint256 | The 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
Name | Type | Description |
---|---|---|
shares | uint256 | Quantity of shares to convert to assets |
totalShares | uint256 | Total quantity of shares already awarded by the curve |
totalAssets | uint256 | Total quantity of assets already staked into the curve |
id | uint256 | Curve ID to use for the calculation |
Returns
Name | Type | Description |
---|---|---|
assets | uint256 | The 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
Name | Type | Description |
---|---|---|
totalShares | uint256 | Total quantity of shares already awarded by the curve |
id | uint256 | Curve ID to use for the calculation |
Returns
Name | Type | Description |
---|---|---|
sharePrice | uint256 | The current price of a share |
getCurveName
Get the name of a curve
function getCurveName(uint256 id) external view returns (string memory name);
Parameters
Name | Type | Description |
---|---|---|
id | uint256 | Curve ID to query |
Returns
Name | Type | Description |
---|---|---|
name | string | The 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
Name | Type | Description |
---|---|---|
id | uint256 | Curve ID to query |
Returns
Name | Type | Description |
---|---|---|
maxShares | uint256 | The 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
Name | Type | Description |
---|---|---|
id | uint256 | Curve ID to query |
Returns
Name | Type | Description |
---|---|---|
maxAssets | uint256 | The 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
Name | Type | Description |
---|---|---|
curveId | uint256 | The ID of the curve |
curveAddress | address | The address of the curve |
curveName | string | The name of the curve |
OwnershipTransferred
Emitted when the admin role is transferred
event OwnershipTransferred(address indexed oldAdmin, address indexed newAdmin);
Parameters
Name | Type | Description |
---|---|---|
oldAdmin | address | The previous admin address |
newAdmin | address | The new admin address |
EthMultiVault
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:
- 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.
- 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
- Security Features
- Timelocked admin operations
- Reentrancy protection
- Pausable functionality
- Granular fee controls with maximum caps
- Approval system for delegated deposits
- Smart Account Integration
- Deploys ERC4337-compatible atom wallets
- BeaconProxy pattern for upgradeable wallet implementations
- Maintains initialization deposits for wallet operations
- 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
Name | Type | Description |
---|---|---|
_generalConfig | GeneralConfig | General configuration struct |
_atomConfig | AtomConfig | Atom configuration struct |
_tripleConfig | TripleConfig | Triple configuration struct |
_walletConfig | WalletConfig | Wallet configuration struct |
_defaultVaultFees | VaultFees | Default vault fees struct |
_bondingCurveConfig | BondingCurveConfig |
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
Name | Type | Description |
---|---|---|
_bondingCurveConfig | BondingCurveConfig | Bonding 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
Name | Type | Description |
---|---|---|
operationId | bytes32 | unique identifier for the operation |
data | bytes | data to be executed |
cancelOperation
cancel a scheduled operation
function cancelOperation(bytes32 operationId, bytes calldata data) external onlyAdmin;
Parameters
Name | Type | Description |
---|---|---|
operationId | bytes32 | unique identifier for the operation |
data | bytes | data of the operation to be cancelled |
setAdmin
Requires new admin to 'confirm' the timelocked operation
set admin
function setAdmin(address admin) external;
Parameters
Name | Type | Description |
---|---|---|
admin | address | address of the new admin |
setProtocolMultisig
set protocol multisig
function setProtocolMultisig(address protocolMultisig) external onlyAdmin;
Parameters
Name | Type | Description |
---|---|---|
protocolMultisig | address | address of the new protocol multisig |
setMinDeposit
sets the minimum deposit amount for atoms and triples
function setMinDeposit(uint256 minDeposit) external onlyAdmin;
Parameters
Name | Type | Description |
---|---|---|
minDeposit | uint256 | new minimum deposit amount |
setMinShare
sets the minimum share amount for atoms and triples
function setMinShare(uint256 minShare) external onlyAdmin;
Parameters
Name | Type | Description |
---|---|---|
minShare | uint256 | new minimum share amount |
setAtomUriMaxLength
sets the atom URI max length
function setAtomUriMaxLength(uint256 atomUriMaxLength) external onlyAdmin;
Parameters
Name | Type | Description |
---|---|---|
atomUriMaxLength | uint256 | new atom URI max length |
setAtomWalletInitialDepositAmount
sets the atom share lock fee
function setAtomWalletInitialDepositAmount(uint256 atomWalletInitialDepositAmount) external onlyAdmin;
Parameters
Name | Type | Description |
---|---|---|
atomWalletInitialDepositAmount | uint256 | new atom share lock fee |
setAtomCreationProtocolFee
sets the atom creation fee
function setAtomCreationProtocolFee(uint256 atomCreationProtocolFee) external onlyAdmin;
Parameters
Name | Type | Description |
---|---|---|
atomCreationProtocolFee | uint256 | new atom creation fee |
setTripleCreationProtocolFee
sets fee charged in wei when creating a triple to protocol multisig
function setTripleCreationProtocolFee(uint256 tripleCreationProtocolFee) external onlyAdmin;
Parameters
Name | Type | Description |
---|---|---|
tripleCreationProtocolFee | uint256 | new 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
Name | Type | Description |
---|---|---|
totalAtomDepositsOnTripleCreation | uint256 | new 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
Name | Type | Description |
---|---|---|
atomDepositFractionForTriple | uint256 | new 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
Name | Type | Description |
---|---|---|
id | uint256 | vault id to set entry fee for |
entryFee | uint256 | entry 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
Name | Type | Description |
---|---|---|
id | uint256 | vault id to set exit fee for |
exitFee | uint256 | exit 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
Name | Type | Description |
---|---|---|
id | uint256 | vault id to set protocol fee for |
protocolFee | uint256 | protocol fee to set |
setAtomWarden
sets the atomWarden address
function setAtomWarden(address atomWarden) external onlyAdmin;
Parameters
Name | Type | Description |
---|---|---|
atomWarden | address | address of the new atomWarden |
setBondingCurveConfig
Sets the bonding curve configuration
function setBondingCurveConfig(address newRegistry, uint256 _defaultCurveId) external onlyAdmin;
Parameters
Name | Type | Description |
---|---|---|
newRegistry | address | Address of the new bonding curve registry |
_defaultCurveId | uint256 | New 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
Name | Type | Description |
---|---|---|
atomId | uint256 | vault id of atom |
Returns
Name | Type | Description |
---|---|---|
<none> | address | atomWallet 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
Name | Type | Description |
---|---|---|
sender | address | address to set approval for |
approvalType | ApprovalTypes | type 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
Name | Type | Description |
---|---|---|
atomUri | bytes | atom data to create atom with |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | id 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
Name | Type | Description |
---|---|---|
atomUris | bytes[] | atom data array to create atoms with |
Returns
Name | Type | Description |
---|---|---|
<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
Name | Type | Description |
---|---|---|
atomUri | bytes | The atom data to create an atom with |
value | uint256 | The value sent with the transaction |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | id 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
Name | Type | Description |
---|---|---|
subjectId | uint256 | vault id of the subject atom |
predicateId | uint256 | vault id of the predicate atom |
objectId | uint256 | vault id of the object atom |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | id 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
Name | Type | Description |
---|---|---|
subjectIds | uint256[] | vault ids array of subject atoms |
predicateIds | uint256[] | vault ids array of predicate atoms |
objectIds | uint256[] | 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
Name | Type | Description |
---|---|---|
subjectId | uint256 | vault id of the subject atom |
predicateId | uint256 | vault id of the predicate atom |
objectId | uint256 | vault id of the object atom |
value | uint256 | The amount of ETH the user has sent minus the base triple cost |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | id The new vault ID of the created triple |
<none> | uint256 | protocolDepositFee 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
Name | Type | Description |
---|---|---|
receiver | address | the address to receive the shares |
id | uint256 | the vault ID of the atom |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | shares 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
Name | Type | Description |
---|---|---|
receiver | address | the address to receive the shares |
atomId | uint256 | the vault ID of the atom |
curveId | uint256 | the vault ID of the curve |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | shares 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
Name | Type | Description |
---|---|---|
shares | uint256 | the amount of shares to redeem |
receiver | address | the address to receiver the assets |
id | uint256 | the vault ID of the atom |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | assets 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
Name | Type | Description |
---|---|---|
shares | uint256 | the amount of shares to redeem |
receiver | address | the address to receiver the assets |
atomId | uint256 | the vault ID of the atom |
curveId | uint256 | the vault ID of the curve |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | assets 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
Name | Type | Description |
---|---|---|
receiver | address | the address to receive the shares |
id | uint256 | the vault ID of the triple |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | shares 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
Name | Type | Description |
---|---|---|
receiver | address | the address to receive the shares |
tripleId | uint256 | the vault ID of the triple |
curveId | uint256 | the vault ID of the curve |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | shares 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
Name | Type | Description |
---|---|---|
shares | uint256 | the amount of shares to redeem |
receiver | address | the address to receiver the assets |
id | uint256 | the vault ID of the triple |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | assets 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
Name | Type | Description |
---|---|---|
shares | uint256 | the amount of shares to redeem |
receiver | address | the address to receiver the assets |
tripleId | uint256 | the vault ID of the triple |
curveId | uint256 | the vault ID of the curve |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | assets 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
Name | Type | Description |
---|---|---|
receiver | address | the address to receive the shares |
termIds | uint256[] | the IDs of the terms (atoms, triples, or counter-triples) to deposit into |
amounts | uint256[] | array of the amount to deposit in each vault |
Returns
Name | Type | Description |
---|---|---|
shares | uint256[] | 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
Name | Type | Description |
---|---|---|
receiver | address | the address to receive the shares |
termIds | uint256[] | array of the vault IDs of the terms (atoms, triples, or counter-triples) |
curveIds | uint256[] | array of the vault IDs of the curves |
amounts | uint256[] | array of the amount to deposit in each vault |
Returns
Name | Type | Description |
---|---|---|
shares | uint256[] | 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
Name | Type | Description |
---|---|---|
percentage | uint256 | the percentage of shares to redeem from each vault (10000 -> 100.00%, 5000 -> 50.00%, etc) |
receiver | address | the address to receiver the assets |
ids | uint256[] | array of IDs of the term (atom, triple or counter-triple) to redeem from |
Returns
Name | Type | Description |
---|---|---|
assets | uint256[] | 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
Name | Type | Description |
---|---|---|
percentage | uint256 | the percentage of shares to redeem from the vaults (10000 -> 100.00%, 5000 -> 50.00%, etc) |
receiver | address | the address to receiver the assets |
termIds | uint256[] | array of the IDs of the terms (atoms, triples, or counter-triples) |
curveIds | uint256[] | array of the IDs of the curves for each term |
Returns
Name | Type | Description |
---|---|---|
assets | uint256[] | array of the amounts of assets/eth withdrawn |
_transferFeesToProtocolMultisig
transfer fees to the protocol multisig
function _transferFeesToProtocolMultisig(uint256 value) internal;
Parameters
Name | Type | Description |
---|---|---|
value | uint256 | the 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
Name | Type | Description |
---|---|---|
id | uint256 | the vault ID of the triple |
receiver | address | the address to receive the shares |
amount | uint256 | the 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
Name | Type | Description |
---|---|---|
id | uint256 | the vault ID of the atom or triple |
receiver | address | the address to receive the shares |
assets | uint256 | the 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
Name | Type | Description |
---|---|---|
receiver | address | the address to receive the shares |
id | uint256 | the vault ID of the atom or triple |
value | uint256 | the amount of eth to deposit |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | sharesForReceiver 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
Name | Type | Description |
---|---|---|
id | uint256 | the vault ID of the atom or triple |
sender | address | the address to redeem the shares from |
receiver | address | the address to receive the assets |
shares | uint256 | the amount of shares to redeem |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | assetsForReceiver the amount of assets/eth to be transferred to the receiver |
<none> | uint256 | protocolFee 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
Name | Type | Description |
---|---|---|
id | uint256 | the vault ID of the atom or triple |
curveId | uint256 | the vault ID of the curve |
sender | address | the address to redeem the shares from |
receiver | address | the address to receive the assets |
shares | uint256 | the amount of shares to redeem |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | assetsForReceiver the amount of assets/eth to be transferred to the receiver |
<none> | uint256 | protocolFee 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
Name | Type | Description |
---|---|---|
to | address | address to mint shares to |
id | uint256 | vault ID to mint shares for |
amount | uint256 | amount 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
Name | Type | Description |
---|---|---|
from | address | address to burn shares from |
id | uint256 | vault ID to burn shares from |
amount | uint256 | amount 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
Name | Type | Description |
---|---|---|
id | uint256 | vault ID to set totals for |
totalAssets | uint256 | new total assets for the vault |
totalShares | uint256 | new 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
Name | Type | Description |
---|---|---|
id | uint256 | the vault ID of the atom or triple |
curveId | uint256 | the vault ID of the curve |
assetsDelta | uint256 | the amount of assets to increase the total assets by |
sharesDelta | uint256 | the 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
Name | Type | Description |
---|---|---|
id | uint256 | the vault ID of the atom or triple |
curveId | uint256 | the vault ID of the curve |
assetsDelta | uint256 | the amount of assets to decrease the total assets by |
sharesDelta | uint256 | the 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
Name | Type | Description |
---|---|---|
<none> | uint256 | atomCost the cost of creating an atom |
getTripleCost
returns the cost of creating a triple
function getTripleCost() public view returns (uint256);
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | tripleCost 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
Name | Type | Description |
---|---|---|
assets | uint256 | amount of assets to calculate fees on |
id | uint256 | vault id to get corresponding fees for |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | totalFees 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
Name | Type | Description |
---|---|---|
assets | uint256 | amount of assets to calculate fees on (should always be msg.value - protocolFee) |
id | uint256 | vault id to get corresponding fees for |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | totalAssetsDelta changes in vault's total assets |
<none> | uint256 | sharesForReceiver changes in vault's total shares (shares owed to receiver) |
<none> | uint256 | userAssetsAfterTotalFees amount of assets that goes towards minting shares for the receiver |
<none> | uint256 | entryFee 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
Name | Type | Description |
---|---|---|
shares | uint256 | amount of shares to calculate fees on |
id | uint256 | vault id to get corresponding fees for |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | totalUserAssets total amount of assets user would receive if redeeming 'shares', not including fees |
<none> | uint256 | assetsForReceiver amount of assets that is redeemable by the receiver |
<none> | uint256 | protocolFee amount of assets that would be sent to the protocol multisig |
<none> | uint256 | exitFee 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
Name | Type | Description |
---|---|---|
assets | uint256 | amount of assets to calculate fee on |
id | uint256 | vault id to get corresponding fees for |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | feeAmount 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
Name | Type | Description |
---|---|---|
assets | uint256 | amount of assets to calculate fee on |
id | uint256 | vault id to get corresponding fees for |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | feeAmount 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
Name | Type | Description |
---|---|---|
assets | uint256 | amount of assets to calculate fee on |
id | uint256 | vault id to get corresponding fees for |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | feeAmount 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
Name | Type | Description |
---|---|---|
assets | uint256 | amount of assets to calculate fee on |
id | uint256 | vault id |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | feeAmount 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
Name | Type | Description |
---|---|---|
amount | uint256 | amount of assets to calculate fee on |
fee | uint256 | fee in % |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | amount 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
Name | Type | Description |
---|---|---|
id | uint256 | vault id to get corresponding share price for |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | price 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
Name | Type | Description |
---|---|---|
id | uint256 | vault id to get corresponding share price for |
curveId | uint256 | curve id to get corresponding share price for |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | price 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
Name | Type | Description |
---|---|---|
<none> | uint256 | maxDeposit 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
Name | Type | Description |
---|---|---|
curveId | uint256 | the vault ID of the curve |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | maxDepositCurve 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
Name | Type | Description |
---|---|---|
sender | address | address of the account to get max redeemable shares for |
id | uint256 | vault id to get corresponding shares for |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | shares 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
Name | Type | Description |
---|---|---|
sender | address | the address to redeem the shares from |
id | uint256 | the vault ID of the atom or triple |
curveId | uint256 | the vault ID of the curve |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | shares 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
Name | Type | Description |
---|---|---|
assets | uint256 | amount of assets to calculate shares on |
id | uint256 | vault id to get corresponding shares for |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | shares 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:
- 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
Name | Type | Description |
---|---|---|
assets | uint256 | amount of assets to calculate shares on |
id | uint256 | vault id to get corresponding shares for |
curveId | uint256 | vault id of the curve |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | shares 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
Name | Type | Description |
---|---|---|
shares | uint256 | amount of shares to calculate assets on |
id | uint256 | vault id to get corresponding assets for |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | assets 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:
- 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
Name | Type | Description |
---|---|---|
shares | uint256 | amount of shares to calculate assets on |
id | uint256 | vault id to get corresponding assets for |
curveId | uint256 | vault id of the curve |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | assets 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
Name | Type | Description |
---|---|---|
assets | uint256 | amount of assets to calculate shares on |
id | uint256 | vault id to get corresponding shares for |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | shares 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
Name | Type | Description |
---|---|---|
shares | uint256 | amount of shares to calculate assets on |
id | uint256 | vault id to get corresponding assets for |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | assets 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
Name | Type | Description |
---|---|---|
id | uint256 | vault id of the triple |
Returns
Name | Type | Description |
---|---|---|
<none> | bytes32 | hash 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
Name | Type | Description |
---|---|---|
id | uint256 | vault id to check |
Returns
Name | Type | Description |
---|---|---|
<none> | bool | bool 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
Name | Type | Description |
---|---|---|
id | uint256 | vault id of the triple/counter-triple |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | tuple(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
Name | Type | Description |
---|---|---|
subjectId | uint256 | the subject atom's vault id |
predicateId | uint256 | the predicate atom's vault id |
objectId | uint256 | the object atom's vault id |
Returns
Name | Type | Description |
---|---|---|
<none> | bytes32 | hash 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
Name | Type | Description |
---|---|---|
id | uint256 | vault id of the triple |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | counterId 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
Name | Type | Description |
---|---|---|
vaultId | uint256 | vault id of the vault |
receiver | address | address of the receiver |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | shares number of shares user has in the vault |
<none> | uint256 | assets 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
Name | Type | Description |
---|---|---|
id | uint256 | vault id of the atom associated to the atom wallet |
Returns
Name | Type | Description |
---|---|---|
<none> | address | atomWallet 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
Name | Type | Description |
---|---|---|
sender | address | The address of the sender |
receiver | address | The address of the receiver |
Returns
Name | Type | Description |
---|---|---|
<none> | bool | bool 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
Name | Type | Description |
---|---|---|
sender | address | The address of the sender |
receiver | address | The address of the receiver |
Returns
Name | Type | Description |
---|---|---|
<none> | bool | bool 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
Name | Type | Description |
---|---|---|
id | uint256 | the id of the vault to check |
receiver | address | the account to check |
Returns
Name | Type | Description |
---|---|---|
<none> | bool | bool 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
Name | Type | Description |
---|---|---|
<none> | bytes | bytes 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
Name | Type | Description |
---|---|---|
operationHash | bytes32 | hash of the operation |
_registry
function _registry() internal view returns (IBondingCurveRegistry);
LinearCurve
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
Name | Type | Description |
---|---|---|
_name | string | The 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
Name | Type | Description |
---|---|---|
assets | uint256 | Quantity of assets to deposit |
<none> | uint256 | |
<none> | uint256 |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | shares 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
Name | Type | Description |
---|---|---|
shares | uint256 | Quantity of shares to mint |
<none> | uint256 | |
<none> | uint256 |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | assets 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
Name | Type | Description |
---|---|---|
assets | uint256 | Quantity of assets to withdraw |
<none> | uint256 | |
<none> | uint256 |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | shares 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
Name | Type | Description |
---|---|---|
shares | uint256 | Quantity of shares to burn |
<none> | uint256 | |
<none> | uint256 |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | assets 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
Name | Type | Description |
---|---|---|
assets | uint256 | Quantity of assets to convert to shares |
<none> | uint256 | |
<none> | uint256 |
Returns
Name | Type | Description |
---|---|---|
shares | uint256 | The 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
Name | Type | Description |
---|---|---|
shares | uint256 | Quantity of shares to convert to assets |
<none> | uint256 | |
<none> | uint256 |
Returns
Name | Type | Description |
---|---|---|
assets | uint256 | The 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
Name | Type | Description |
---|---|---|
<none> | uint256 |
Returns
Name | Type | Description |
---|---|---|
sharePrice | uint256 | The 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
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
Name | Type | Description |
---|---|---|
_name | string | The name of the curve (i.e. "Progressive Curve #465") |
slope18 | uint256 | The slope of the curve, in basis points (i.e. 0.0025e18) |
offset18 | uint256 | The 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
Name | Type | Description |
---|---|---|
assets | uint256 | Quantity of assets to deposit |
<none> | uint256 | |
totalShares | uint256 | Total quantity of shares already awarded by the curve |
Returns
Name | Type | Description |
---|---|---|
shares | uint256 | The 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
Name | Type | Description |
---|---|---|
shares | uint256 | Quantity of shares to burn |
totalShares | uint256 | Total quantity of shares already awarded by the curve |
<none> | uint256 |
Returns
Name | Type | Description |
---|---|---|
assets | uint256 | The 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
Name | Type | Description |
---|---|---|
shares | uint256 | Quantity of shares to mint |
totalShares | uint256 | Total quantity of shares already awarded by the curve |
<none> | uint256 |
Returns
Name | Type | Description |
---|---|---|
assets | uint256 | The 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
Name | Type | Description |
---|---|---|
assets | uint256 | Quantity of assets to withdraw |
<none> | uint256 | |
totalShares | uint256 | Total quantity of shares already awarded by the curve |
Returns
Name | Type | Description |
---|---|---|
shares | uint256 | The 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
Name | Type | Description |
---|---|---|
totalShares | uint256 | Total quantity of shares already awarded by the curve |
Returns
Name | Type | Description |
---|---|---|
sharePrice | uint256 | The 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
Name | Type | Description |
---|---|---|
assets | uint256 | Quantity of assets to convert to shares |
<none> | uint256 | |
totalShares | uint256 | Total quantity of shares already awarded by the curve |
Returns
Name | Type | Description |
---|---|---|
shares | uint256 | The 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
Name | Type | Description |
---|---|---|
shares | uint256 | Quantity of shares to convert to assets |
totalShares | uint256 | Total quantity of shares already awarded by the curve |
<none> | uint256 |
Returns
Name | Type | Description |
---|---|---|
assets | uint256 | The 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
Name | Type | Description |
---|---|---|
juniorSupply | UD60x18 | The smaller supply in the operation (the initial supply during mint, or the final supply during a redeem operation). |
seniorSupply | UD60x18 | The larger supply in the operation (the final supply during mint, or the initial supply during a redeem operation). |
Returns
Name | Type | Description |
---|---|---|
assets | UD60x18 | The 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
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
Name | Type | Description |
---|---|---|
_name | string | The name of the curve (i.e. "Progressive Curve #465") |
slope18 | uint256 | The 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
Name | Type | Description |
---|---|---|
assets | uint256 | Quantity of assets to deposit |
<none> | uint256 | |
totalShares | uint256 | Total quantity of shares already awarded by the curve |
Returns
Name | Type | Description |
---|---|---|
shares | uint256 | The 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
Name | Type | Description |
---|---|---|
shares | uint256 | Quantity of shares to burn |
totalShares | uint256 | Total quantity of shares already awarded by the curve |
<none> | uint256 |
Returns
Name | Type | Description |
---|---|---|
assets | uint256 | The 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
Name | Type | Description |
---|---|---|
shares | uint256 | Quantity of shares to mint |
totalShares | uint256 | Total quantity of shares already awarded by the curve |
<none> | uint256 |
Returns
Name | Type | Description |
---|---|---|
assets | uint256 | The 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
Name | Type | Description |
---|---|---|
assets | uint256 | Quantity of assets to withdraw |
<none> | uint256 | |
totalShares | uint256 | Total quantity of shares already awarded by the curve |
Returns
Name | Type | Description |
---|---|---|
shares | uint256 | The 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
Name | Type | Description |
---|---|---|
totalShares | uint256 | Total quantity of shares already awarded by the curve |
Returns
Name | Type | Description |
---|---|---|
sharePrice | uint256 | The 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
Name | Type | Description |
---|---|---|
assets | uint256 | Quantity of assets to convert to shares |
<none> | uint256 | |
totalShares | uint256 | Total quantity of shares already awarded by the curve |
Returns
Name | Type | Description |
---|---|---|
shares | uint256 | The 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
Name | Type | Description |
---|---|---|
shares | uint256 | Quantity of shares to convert to assets |
totalShares | uint256 | Total quantity of shares already awarded by the curve |
<none> | uint256 |
Returns
Name | Type | Description |
---|---|---|
assets | uint256 | The 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
Name | Type | Description |
---|---|---|
juniorSupply | UD60x18 | The smaller supply in the operation (the initial supply during mint, or the final supply during a redeem operation). |
seniorSupply | UD60x18 | The larger supply in the operation (the final supply during mint, or the initial supply during a redeem operation). |
Returns
Name | Type | Description |
---|---|---|
assets | UD60x18 | The 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);