Intro

Welcome to the Arrakis documentation.

Arrakis is a MEV-aware market maker that powers onchain liquidity for token issuers and LPs. We're building the Arrakis Protocol to make onchain liquidity provision more scalable and efficient.

Read this Intro to Arrakis for a high-level overview:

Or jump straight into:

The liquidity must flow.

Arrakis Protocol

Arrakis Protocol consists of two major infrastructural components:

  • Offchain Market Making Infrastructure
  • Onchain Smart Contract Framework

Our smart contract framework for DEX integrations (Arrakis Modular) works together with our offchain market making infrastructure. The union of these onchain and offchain components comprise the Arrakis Protocol.

arrakis-modular

For example, the new HOT AMM Public Vault is formed by the following components:

  • Arrakis Quoter and other offchain market making components.
  • Arrakis Modular (smart contract framework) Public Vaults.
  • A new custom Valantis Sovereign Pool (as the 1st DEX integration).

HOT AMM

LPs are getting rekt by toxic order flow. HOT improves returns and maximizes capital efficiency for LPs, by internalizing MEV using an intent-based design.

To learn more, refer to this HOT AMM: Concepts page.

Just want to deposit? Here's our New User Interface

HOT was designed by Arrakis and Valantis Labs. It is built on the Valantis Modular DEX Framework. HOT is the first integration on Arrakis Modular and is powered by Arrakis's offchain market making infrastructure.

Flagship Public Vault using HOT AMM

Our flagship WETH/USDC Arrakis Modular Public Vault on Ethereum Mainnet deploys it's funds into a HOT AMM liquidity pool (details).

This public vault offering is similar to LPing on a traditional AMM, but has a few advanced features under the hood:

  • actively managed concentrated liquidity rebalancing (via the Arrakis Public Vault manager role)
  • intents-based Quoter activity (via the underlying HOT AMM QuoteSigner role)

Thanks to these roles (and proper strategies for their activity), LPs can passively make WETH/USDC markets in a way that is competitive with the most sophisticated Private Market Makers onchain.

Arrakis Pro

Arrakis Pro is the industry leading, non-custodial onchain liquidity management solution for token issuers (protocols and DAOs). Arrakis Pro powers protocol owned liquidity.

Problem Statement

Uniswap v3 introduced the concept of concentrated liquidity AMM pools which enabled high capital efficiency, but were complex to manage.

Arrakis Pro supports token issuers by:

  • Supporting token launches
  • Bootstraping liquidity
  • Ongoing inventory management

Benefits

Protocols and DAOs can benefit from the following:

  1. Greater capital efficiency: narrow price range with rebalancing to keep the price in the range.
  2. Minimum price impact: increased liquidity depth leading to reduced downside price impact and market volatility.
  3. Return on capital: facilitate more trading volumes whilst reducing toxic order flow.
  4. Active inventory management: exposure the right amount of liquidity at the right time.

Solution

Arrakis Pro simplifies the process of managing concentrated liquidity by automating liquidity provisioning and rebalancing, for any concentrated liquidity pool (including Uniswap v3, HOT AMM and Uniswap v4). Arrakis Pro is powered by Arrakis's Offchain Market Making infrastructure.

Arrakis Pro was formerly known as PALM (built on top of Uniswap v3). With Arrakis Modular — the new and improved version of the Arrakis vaults — any DEX can be supported.

Get in Touch

Arrakis is trusted by MakerDAO, Lido, EtherFi, Across, Stargate, Gnosis, Redacted Cartel, Angle, Mountain, Kwenta, IndexCoop, Sturdy, Everclear and many more leading protocols. As of October 2024, Arrakis vaults have facilitated over $20B in cumulative trading volume.

Contact us to learn more about how Arrakis Pro can support your token launch and ongoing liquidity management.

Arrakis Modular

Arrakis Modular represents the next evolution of the Arrakis liquidity management smart contract framework, aiming to overcome the limitations of previous versions (V1 and V2).

Check out the Github Repo as well as the documentation here.

Motivation

Arrakis vault contracts have allowed LPs to actively manage or delegate the management of their DEX liquidity positions. However, Arrakis V1 and V2 were purpose-built around Uniswap V3 liquidity. To support alternative venues (e.g. Uniswap V4, Balancer, etc) Arrakis would have to make a completely new standard for each integration from scratch.

Arrakis Modular introduces a universal Meta Vault standard. This modular framework allows Arrakis to create entirely different two-sided LP Vault integrations, which all reuse the same Meta Vault infrastructure and interfaces.

Architecture

Meta Vault: At the heart of the Arrakis Modular system is the concept of a Meta Vault. The Meta Vault creates a unified standard for providing two-sided liquidity to DEXs regardless of the particular features or interfaces of a given DEX.

Modules: Each Meta Vault has the capability to whitelist various modules. A module is essentially a smart contract that establishes an integration with a liquidity-consuming dApp.

Configuration: Each Meta Vaults is configurable by the Vault owner. This design ensures that as new DEXs emerge, Arrakis integration becomes a matter of simply creating and whitelisting a new module compatible with the DEX, and then activating it.

Diagram: Arrakis Modular smart contract system represented visually.

Security: Arrakis Modular from a Security POV.

Arrakis Meta Vault

Meta Vaults are a core component of the Arrakis Modular system, designed to provide a flexible and efficient way for users to manage liquidity on or across various decentralized exchanges (DEXs) and trading venues.

Public Versus Private

nft

  1. Public Meta Vaults: These vaults implement ERC20 and are intended for shared liquidity positions or strategies. They allow for delegated management of liquidity on behalf of multiple participants who mint and burn vault ERC20 token supply by depositing or withdrawing a proportion of vault underlying assets.

nft

  1. Private Meta Vaults: These are designed for token issuers and individual users to manage or delegate management of their own private liquidity. The ownership and transfer rights of Private Meta Vaults is tokenized as a fully onchain NFT, as shown below. Only vault owners can withdraw underlying liquidity from a private vault.

nft

Deploying Vaults

The Factory is responsible for deploying new instances of both public and private Meta Vaults. Private vaults can be permissionlessly deployed by any address while public vaults are only deployed and controlled by whitelisted addresses. The Factory contract maintains a list of all deployed vaults and manages permissions for public vault deployments.

nft

This architecture allows for efficient liquidity management across multiple platforms while providing options for both shared and private liquidity strategies, all within a modular and extensible framework.

Modules

Modules are smart contracts that act as a bridge between Meta Vaults and specific decentralized exchanges (DEXs) or liquidity protocols. They encapsulate the logic for interacting with particular trading venues, allowing Meta Vaults to provide liquidity across various platforms without changing their core structure.

Modules also each expose their own custom functions for liquidity management that only the manager of the Meta Vault can call.

nft

Module implementations are whitelisted on public and private registry contracts to ensure security and proper functionality. The vault owner selects which module(s) to attach to their vaults. Each vault has exactly one "active" module and every vault has a setModule function which only the manager can call (to change the "active" module).

The key strength of modules lies in their flexibility and standardization. As new DEXs emerge or trading strategies evolve, new modules can be created and integrated seamlessly, enabling the Arrakis system to adapt to the rapidly changing DeFi landscape.

Explore module implementations built by Arrakis here. Or check out the modules interfaces here

Vault Configuration

Every Meta Vault has configurable components which can be adjusted by the Vault owner role. The two main configurables are:

  1. modules: whitelisting and revoking modules which each define the integration with an underlying liquidity protocol (e.g. HOT AMM module) and also expose certain liquidity management functions that can be invoked by the Arrakis Standard Manager.

  2. manager configuration: set on the Arrakis Standard Manager, the vault owner controls the VaultInfo struct including an executor who can call liquidity management functions for this vault from offchain, and safety checks on any liquidity management actions that the executor invokes.

nft

Configuration Management

The Meta Vault owner role has the ability to whitelist modules and configure management parameters on the Arrakis Standard Manager. This means a vault owner can entirely augment where vault liquidity flows, how it behaves, what management functions it exposes, and who can execute management functions.

All Public Vault ownership is immutably behind a multi-day timelock (controlled by the Arrakis DAO) so that LPs are guaranteed to have time to react to any changes in configuration.

Private Vaults Ownership is mapped in the Private Vault NFT contract, and Private Vaults do not enforce a timelock on vault ownership (private vault liquidity providers are intended to be the owner of their private vaults).

Diagram


architecture

Security

Arrakis Modular employs a multi-layered security approach that combines proactive monitoring and rapid response capabilities with enforced delays on any critical changes.

  1. Guardian: responsible for implementing a rushing pauser role that can quickly pause parts of the system in case of critical errors or vulnerabilities.

  2. TimeLock: enforces a delay on changes to critical security parameters. This provides security guarantees for public Meta Vaults against compromised multisigs and malicious actors.

Upgradeability

Most of the Arrakis Modular smart contracts are entirely immutable. However module implementations and the ArrakisStandardManager are behind proxies and may be upgradeable as an initial safety precaution. All upgradeability in Arrakis Modular is behind strict timelocks (controlled by Arrakis DAO) absolutely no instant contract upgrades can be made on the Arrakis Modular system

(NOTE: the modular nature of Arrakis Meta Vaults make them inherently similar to upgradeable proxy patterns. By whitelisting and activating a new module, Arrakis Vault functionality can critically change. This is why Public Vault ownership enforces a timelock.)

Audits

Quickstart: Public Vaults

To make the deposit process safe and simple we created the Arrakis Public Vault Router. This contract is in charge of getting the right amounts and tokens to deposit, as well as containing convenient functions with the ability to wrap assets and swap atomically before deposit. It also integrates the Permit 2 standard for gassless approvals.

Add Liquidity

The following provides a step-by-step explanation of depositing liquidity into an Arrakis Public Vault via the Router.

  1. Identify the Meta Vault associated to the pair you want to participate in. See for example here for a list of Public Vaults.

  2. Next step is use the Router to determine how many of each tokens you expect to need to join the Meta Vault.

    • Use getMintAmounts to determine the extact amounts of token0 and token1 you expect to deposit, given the maximum of each token you'd like to provide.
  3. In order to set token transfer authorizations before depositing, there are two alternatives:

    • Calling the standard ERC20 Approve (approve <router> to spend)
    • Set up Permit2 data and signature
  4. Now, in order to deposit into the pool there are multiple paths:

  5. Once your deposit transaction goes through, you obtain ERC20 LP shares of the vault you are depositing to.

Remove Liquidity

Removing Liquidity from an Arakis Public Vault that you hold LP tokens of is easy.

Simply call the burn directly on an Arrakis Meta Vault Public contract to burn amount of LP tokens that you hold and remit two-sided underlying (token0 and token1) to your receiver address of choice.

Public Vault List

Just want to deposit? Here's our New User Interface

Ethereum Mainnet

WETH/USDC Vault

This is the first and flagship Arrakis Modular Public Vault.

Management Configuration:

HOT AMM pool WETH/USDC Config:

  • QuoteSigner: 0x498c8a1a179b5D1D4Ff64bC90Cf3224a3478765C (controlled by Arrakis)
  • HOT Manager: 0xAf6f9640092cB1236E5DB6E517576355b6C40b7f (timelocked)
  • Price Oracle: Chainlink
  • Max HOT Swaps Per Block: 3
  • Max HOT Swap Oracle Deviation: 3.5%

Read more about the HOT AMM Quoter and the Vault Manager Functions which both perform actions that help power this Public Vault.

Price Oracles

All Arrakis Vaults have a concept of a price oracle set by vault owners on the ArrakisStandardManager. These price oracles are used as a third-party check on executor management calls to a vault.

We use our own standard interface for oracle reads and thus we can seamlessly integrate any type of onchain oracle price feed no matter the interfaces/patterns (RedStone, Chainlink, Uni V3 TWAP, etc) -- just by defining a simple Oracle Wrapper smart contract.

To accelerate the integration of safe public and private Meta Vaults for newer tokens that may not already have performant oracle feeds onchain, we refer clients to our oracle partner RedStone.

Methodology

Arrakis implements a standard oracle interface that must be followed:

interface IOracleWrapper {
    /// @notice function used to get price0.
    /// @return price0 price of token0/token1.
    function getPrice0() external view returns (uint256 price0);

    /// @notice function used to get price1.
    /// @return price1 price of token1/token0.
    function getPrice1() external view returns (uint256 price1);
}

Any smart contract that utilizes this interface can function as an oracle on the Arrakis standard manager. This interface is consumed during ArrakisStandardManager.rebalance here:

        uint256 price0 = info.oracle.getPrice0();

        uint256 vaultInToken1BeforeRebalance = FullMath.mulDiv(
            amount0, price0, 10 ** token0Decimals
        ) + amount1;

we store vaultInToken1BeforeRebalance and then compare it to the value after rebalance. Further checks can be implemented at the module level with oracle price feeds thanks to this call here:

    module.validateRebalance(info.oracle, info.maxDeviation);

Deployments

Arrakis Modular Smart Contracts are deployed on Mainnet, Arbitrum, Base and Sepolia. They are deployed using CREATE3, and share addresses among all the networks.

ContractAddress
Arrakis Standard Manager0x2e6E879648293e939aA68bA4c6c129A1Be733bDA
Arrakis Meta Vault Factory0x820FB8127a689327C863de8433278d6181123982
Private Vault NFT0x44A801e7E2E073bd8bcE4bCCf653239Fa156B762
Renderer Controller0x1Cc0Adff599F244f036a5C2425f646Aef884149D
TimeLock0xAf6f9640092cB1236E5DB6E517576355b6C40b7f
Guardian0x6F441151B478E0d60588f221f1A35BcC3f7aB981
Public Module Registry0x791d75F87a701C3F7dFfcEC1B6094dB22c779603
Private Module Registry0xe278C1944BA3321C1079aBF94961E9fF1127A265
Public Vault Router0x72aa2C8e6B14F30131081401Fa999fC964A66041
Public Vault Router Executor0x19488620Cdf3Ff1B0784AC4529Fb5c5AbAceb1B6
Public Vault Router Resolver0xC6c53369c36D6b4f4A6c195441Fe2d33149FB265
Valantis Public Module Implementation0x9Ac1249E37EE1bDc38dC0fF873F1dB0c5E6aDdE3
Valantis Private Module Implementation0x7E2fc9b2D37EA3E771b6F2375915b87CcA9E55bc
Pauser*0x700a1cdA1495C1B34c4962e9742A8A8832aAc03A

* Not available on Sepolia

Technical reference

Welcome to the smart contract technical reference of the Arrakis Modular smart contract framework. See Here for the github repository.

Getting Started

In order to run the test suite of Arrakis modular smart contracts, follow these steps:

  1. Clone the repository by running:
git clone https://github.com/ArrakisFinance/arrakis-modular.git
  1. Install the required submodules and compile the contracts by running:
forge build
  1. Create .env file using .envExample as a reference. You can fill in your own alchemy api key (or a different RPC url altogether)
  2. Execute the test suite by running:
forge test -vv

If tests run and pass then your dev environment is set up correctly!

Arrakis Modular Smart Contracts

Meta-Vaults

Vaults

abstracts/ArrakisMetaVault.sol This contract is the core of the minimal Arrakis Meta Vault standard. It encodes the interfaces and patterns of an Arrakis Meta Vault. A functional ArrakisMetaVault has a module contract connected to it which entirely defines how the vault integrates with an underlying Liquidity Provision protocol, using standard interfaces. This contract is abstract because it is extended to expose the differenced in the Public and Private vault type, most notable how they are tokenized and how the deposit function is implemented.

  • ArrakisMetaVaultPublic.sol This inherits and extends the abstract ArrakisMetaVault.sol to create the ERC20 wrapped “public” Arrakis Meta Vault. If we want to create a shared LP position/strategy which can configure or delegate LP active management on behalf of all participants, then we’ll deploy an instance of this through the Factory contract. Public Vault deployments are permissioned since sensitive security parameters for multiple parties are under the timelocked control of a vault owner, so we want some ability to control who might deploy/configure/own these public vaults. Eventually this authority would be under the control of the “Arrakis DAO.”

  • ArrakisMetaVaultPrivate.sol This inherits and extends the abstract ArrakisMetaVault.sol to create the “private” Arrakis Meta Vault, where only the vault owner controls adding or removing liquidity. If you want to create an LP management contract for your own private liquidity (we call this PALM for private active liquidity management) you’d deploy an instance of this through the Factory contract. Ownership is not timelocked and deployment is permissionless in this case, since the sensitive security parameters are fundamentally under the control of the custodian of the vault funds (i.e. the owner is the user).

Factory

ArrakisMetaVaultFactory.sol deploys fresh instances of ArrakisMetaVaultPublic and ArrakisMetaVaultPrivate public vault deployments are permissioned, but private vault ones are not. Stores complete list of all vaults deployed, by type.

Ownership

PrivateVaultNFT.sol an NFT contract that allows ownership of private vaults to each be tokenized and thus transferrable. Very standard NFT contract

Modules

abstracts/ModuleRegistry.sol this abstract contract handles the simple duty of “module” whitelistsing, so only modules deemed safe and correct can be used by vaults.

  • ModulePrivateRegistry.sol registry of all modules which can be whitelisted and used by private vaults.

  • ModulePublicRegsitry.sol registry of all modules which can be whitelisted and used by public vaults.

Implementations

modules/ValantisSOTModule.sol This is the first ArrakisMetaVault module we will put into production, integrating a specific Sovereign Pool type of the new Valantis DEX.

Administration

ArrakisStandardManager.sol The manager contract that adds additional safety checks to make delegated LP management safe and as trustless as possible. Arrakis will use this as the entry point to actively manage both private vaults and public vaults. Also how we confiuge/harvest manager fee collection for Arrakis protocol to take cut of revenues generated.

Security

Guardian.sol this contract is in charge of a rushing pauser role who can pause parts of the system in the case of critical error/vulnerability. This authority would be ultimately in the hands of some “Guardian Multisig” much like how AAVE works today. For any upgradeable contracts (modules are all beacon proxies and could potentially be upgradeable) there would be a timelock. So pauses are rushing but upgrades are slow.

TimeLock.sol a slightly modified generic timelock (so that timelock cannot transfer ownership of the vault away from the timelock contract) a fresh instance of this is used for each Public Arrakis vault to make sure that security parameters cannot be rushingly reconfigured by a compromised public vault owner to extract value from the public vault.

Routing

ArrakisPublicVaultRouter.sol A router contract which integrates permit2 which helps depositors add liquidity to ArrakisMetaVaultPublic instances, safely and conveniently.

RouterSwapExecutor.sol a sub-component of the Public Vault Router used for swapping safely (need the middleman contract here for security concerns on these generic low level swaps being abused)

Meta Vaults

Content

Core

Content

ArrakisMetaVault

Git Source

Inherits: IArrakisMetaVault, ReentrancyGuard, Initializable

State Variables

moduleRegistry

address public immutable moduleRegistry;

token0

address public immutable token0;

token1

address public immutable token1;

manager

address public immutable manager;

module

IArrakisLPModule public module;

_whitelistedModules

EnumerableSet.AddressSet internal _whitelistedModules;

Functions

onlyOwnerCustom

modifier onlyOwnerCustom();

onlyManager

modifier onlyManager();

constructor

constructor(
    address moduleRegistry_,
    address manager_,
    address token0_,
    address token1_
);

initialize

function initialize(address module_) external initializer;

setModule

function used to set module

function setModule(
    address module_,
    bytes[] calldata payloads_
) external onlyManager nonReentrant;

Parameters

NameTypeDescription
module_addressaddress of the new module
payloads_bytes[]datas to initialize/rebalance on the new module

whitelistModules

function used to whitelist modules that can used by manager.

we transfer here all tokens to the new module.

function whitelistModules(
    address[] calldata beacons_,
    bytes[] calldata data_
) external onlyOwnerCustom;

Parameters

NameTypeDescription
beacons_address[]array of beacons addresses to use for modules creation.
data_bytes[]array of payload to use for modules creation.

blacklistModules

function used to blacklist modules that can used by manager.

function blacklistModules(address[] calldata modules_)
    external
    onlyOwnerCustom;

Parameters

NameTypeDescription
modules_address[]array of module addresses to be blacklisted.

whitelistedModules

function used to get the list of modules whitelisted.

function whitelistedModules()
    external
    view
    returns (address[] memory modules);

Returns

NameTypeDescription
modulesaddress[]whitelisted modules addresses.

getInits

function used to get the initial amounts needed to open a position.

function getInits()
    external
    view
    returns (uint256 init0, uint256 init1);

Returns

NameTypeDescription
init0uint256the amount of token0 needed to open a position.
init1uint256the amount of token1 needed to open a position.

totalUnderlying

function used to get the amount of token0 and token1 sitting on the position.

function totalUnderlying()
    public
    view
    returns (uint256 amount0, uint256 amount1);

Returns

NameTypeDescription
amount0uint256the amount of token0 sitting on the position.
amount1uint256the amount of token1 sitting on the position.

totalUnderlyingAtPrice

function used to get the amounts of token0 and token1 sitting on the position for a specific price.

function totalUnderlyingAtPrice(uint160 priceX96_)
    external
    view
    returns (uint256 amount0, uint256 amount1);

Parameters

NameTypeDescription
priceX96_uint160price at which we want to simulate our tokens composition

Returns

NameTypeDescription
amount0uint256the amount of token0 sitting on the position for priceX96.
amount1uint256the amount of token1 sitting on the position for priceX96.

_withdraw

function _withdraw(
    address receiver_,
    uint256 proportion_
) internal returns (uint256 amount0, uint256 amount1);

_withdrawManagerBalance

function _withdrawManagerBalance(IArrakisLPModule module_)
    internal
    returns (uint256 amount0, uint256 amount1);

_call

function _call(address module_, bytes memory data_) internal;

_onlyOwnerCheck

function _onlyOwnerCheck() internal view virtual;

ArrakisMetaVaultFactory

Git Source

Inherits: IArrakisMetaVaultFactory, Pausable, Ownable

this contract will use create3 to deploy vaults.

State Variables

moduleRegistryPublic

address public immutable moduleRegistryPublic;

moduleRegistryPrivate

address public immutable moduleRegistryPrivate;

creationCodePublicVault

address public immutable creationCodePublicVault;

creationCodePrivateVault

address public immutable creationCodePrivateVault;

nft

PrivateVaultNFT public immutable nft;

manager

address public manager;

_publicVaults

EnumerableSet.AddressSet internal _publicVaults;

_privateVaults

EnumerableSet.AddressSet internal _privateVaults;

_deployers

EnumerableSet.AddressSet internal _deployers;

Functions

constructor

constructor(
    address owner_,
    address manager_,
    address moduleRegistryPublic_,
    address moduleRegistryPrivate_,
    address creationCodePublicVault_,
    address creationCodePrivateVault_
);

pause

function used to pause the factory.

only callable by owner.

function pause() external onlyOwner;

unpause

function used to unpause the factory.

only callable by owner.

function unpause() external onlyOwner;

setManager

function used to set a new manager.

only callable by owner.

function setManager(address newManager_) external onlyOwner;

Parameters

NameTypeDescription
newManager_addressaddress that will managed newly created vault.

deployPublicVault

function used to deploy ERC20 token wrapped Arrakis Meta Vault.

function deployPublicVault(
    bytes32 salt_,
    address token0_,
    address token1_,
    address owner_,
    address beacon_,
    bytes calldata moduleCreationPayload_,
    bytes calldata initManagementPayload_
) external whenNotPaused returns (address vault);

Parameters

NameTypeDescription
salt_bytes32bytes32 used to get a deterministic all chains address.
token0_addressaddress of the first token of the token pair.
token1_addressaddress of the second token of the token pair.
owner_addressaddress of the owner of the vault.
beacon_addressaddress of the beacon that will be used to create the default module.
moduleCreationPayload_bytespayload for initializing the module.
initManagementPayload_bytesdata for initialize management.

Returns

NameTypeDescription
vaultaddressaddress of the newly created Token Meta Vault.

deployPrivateVault

function used to deploy owned Arrakis Meta Vault.

function deployPrivateVault(
    bytes32 salt_,
    address token0_,
    address token1_,
    address owner_,
    address beacon_,
    bytes calldata moduleCreationPayload_,
    bytes calldata initManagementPayload_
) external whenNotPaused returns (address vault);

Parameters

NameTypeDescription
salt_bytes32bytes32 needed to compute vault address deterministic way.
token0_addressaddress of the first token of the token pair.
token1_addressaddress of the second token of the token pair.
owner_addressaddress of the owner of the vault.
beacon_addressaddress of the beacon that will be used to create the default module.
moduleCreationPayload_bytespayload for initializing the module.
initManagementPayload_bytesdata for initialize management.

Returns

NameTypeDescription
vaultaddressaddress of the newly created private Meta Vault.

whitelistDeployer

function used to grant the role to deploy to a list of addresses.

function whitelistDeployer(address[] calldata deployers_)
    external
    onlyOwner;

Parameters

NameTypeDescription
deployers_address[]list of addresses that owner want to grant permission to deploy.

blacklistDeployer

function used to grant the role to deploy to a list of addresses.

function blacklistDeployer(address[] calldata deployers_)
    external
    onlyOwner;

Parameters

NameTypeDescription
deployers_address[]list of addresses that owner want to revoke permission to deploy.

getTokenName

get Arrakis Modular standard token name for two corresponding tokens.

function getTokenName(
    address token0_,
    address token1_
) public view returns (string memory);

Parameters

NameTypeDescription
token0_addressaddress of the first token.
token1_addressaddress of the second token.

Returns

NameTypeDescription
<none>stringname name of the arrakis modular token vault.

publicVaults

get a list of public vaults created by this factory

function publicVaults(
    uint256 startIndex_,
    uint256 endIndex_
) external view returns (address[] memory);

Parameters

NameTypeDescription
startIndex_uint256start index
endIndex_uint256end index

Returns

NameTypeDescription
<none>address[]vaults list of all created vaults.

numOfPublicVaults

numOfPublicVaults counts the total number of public vaults in existence

function numOfPublicVaults() public view returns (uint256 result);

Returns

NameTypeDescription
resultuint256total number of vaults deployed

isPublicVault

isPublicVault check if the inputed vault is a public vault.

function isPublicVault(address vault_) external view returns (bool);

Parameters

NameTypeDescription
vault_addressaddress of the address to check.

Returns

NameTypeDescription
<none>boolisPublicVault true if the inputed vault is public or otherwise false.

privateVaults

get a list of private vaults created by this factory

function privateVaults(
    uint256 startIndex_,
    uint256 endIndex_
) external view returns (address[] memory);

Parameters

NameTypeDescription
startIndex_uint256start index
endIndex_uint256end index

Returns

NameTypeDescription
<none>address[]vaults list of all created vaults.

numOfPrivateVaults

numOfPrivateVaults counts the total number of private vaults in existence

function numOfPrivateVaults() public view returns (uint256 result);

Returns

NameTypeDescription
resultuint256total number of vaults deployed

isPrivateVault

isPrivateVault check if the inputed vault is a private vault.

function isPrivateVault(address vault_)
    external
    view
    returns (bool);

Parameters

NameTypeDescription
vault_addressaddress of the address to check.

Returns

NameTypeDescription
<none>boolisPublicVault true if the inputed vault is private or otherwise false.

deployers

function used to get a list of address that can deploy public vault.

function deployers() external view returns (address[] memory);

_initManagement

function _initManagement(
    address vault_,
    bytes memory data_
) internal;

_getPublicVaultConstructorPayload

to anticipate futur changes in the manager's initManagement function manager should implement getInitManagementSelector function, so factory can get the the right selector of the function.

for initializing management we need to know the vault address, so manager should follow this pattern where vault address is the first parameter of the function.

function _getPublicVaultConstructorPayload(
    address timeLock_,
    address token0_,
    address token1_
) internal view returns (bytes memory);

_append

function _append(
    string memory a_,
    string memory b_,
    string memory c_,
    string memory d_
) internal pure returns (string memory);

ArrakisStandardManager

Git Source

Inherits: IArrakisStandardManager, IManager, Ownable, ReentrancyGuardUpgradeable, PausableUpgradeable

State Variables

defaultFeePIPS

uint256 public immutable defaultFeePIPS;

nativeToken

address public immutable nativeToken;

nativeTokenDecimals

uint8 public immutable nativeTokenDecimals;

defaultReceiver

address public defaultReceiver;

receiversByToken

mapping(address => address) public receiversByToken;

vaultInfo

mapping(address => VaultInfo) public vaultInfo;

pendingFeeIncrease

mapping(address => FeeIncrease) public pendingFeeIncrease;

factory

address public factory;

_guardian

address internal immutable _guardian;

_vaults

EnumerableSet.AddressSet internal _vaults;

Functions

onlyVaultOwner

modifier onlyVaultOwner(address vault_);

onlyWhitelistedVault

modifier onlyWhitelistedVault(address vault_);

onlyGuardian

modifier onlyGuardian();

constructor

constructor(
    uint256 defaultFeePIPS_,
    address nativeToken_,
    uint8 nativeTokenDecimals_,
    address guardian_
);

initialize

function used to initialize standard manager proxy.

we are not checking if the default fee pips is not zero, to have the option to set 0 as default fee pips.

function initialize(
    address owner_,
    address defaultReceiver_,
    address factory_
) external initializer;

Parameters

NameTypeDescription
owner_addressaddress of the owner of standard manager.
defaultReceiver_addressaddress of the receiver of tokens (by default).
factory_addressArrakisMetaVaultFactory contract address.

pause

function used to pause the manager.

only callable by guardian

function pause() external onlyGuardian;

unpause

function used to unpause the manager.

only callable by guardian

function unpause() external onlyGuardian;

setDefaultReceiver

function used to set the default receiver of tokens earned.

function setDefaultReceiver(address newDefaultReceiver_)
    external
    onlyOwner;

Parameters

NameTypeDescription
newDefaultReceiver_addressaddress of the new default receiver of tokens.

setReceiverByToken

function used to set receiver of a specific token.

function setReceiverByToken(
    address vault_,
    bool isSetReceiverToken0_,
    address receiver_
) external onlyOwner onlyWhitelistedVault(vault_);

Parameters

NameTypeDescription
vault_addressaddress of the meta vault that contain the specific token.
isSetReceiverToken0_boolboolean if true means that receiver is for token0 if not it's for token1.
receiver_addressaddress of the receiver of this specific token.

decreaseManagerFeePIPS

function used to decrease the fees taken by manager for a specific vault.

function decreaseManagerFeePIPS(
    address vault_,
    uint24 newFeePIPS_
) external onlyOwner onlyWhitelistedVault(vault_);

Parameters

NameTypeDescription
vault_addressaddress of the vault.
newFeePIPS_uint24fees in pips to set on the specific vault.

finalizeIncreaseManagerFeePIPS

function used to finalize a time lock fees increase on a vault.

function finalizeIncreaseManagerFeePIPS(address vault_)
    external
    onlyOwner;

Parameters

NameTypeDescription
vault_addressaddress of the vault where the fees increase will be applied.

submitIncreaseManagerFeePIPS

function used to submit a fees increase in a managed vault.

function submitIncreaseManagerFeePIPS(
    address vault_,
    uint24 newFeePIPS_
) external onlyOwner onlyWhitelistedVault(vault_);

Parameters

NameTypeDescription
vault_addressaddress of the vault where fees will be increase after timeLock.
newFeePIPS_uint24fees in pips to set on the specific managed vault.

withdrawManagerBalance

function used by manager to get his balance of fees earned on a vault.

function withdrawManagerBalance(address vault_)
    external
    onlyOwner
    nonReentrant
    whenNotPaused
    returns (uint256 amount0, uint256 amount1);

Parameters

NameTypeDescription
vault_addressfrom which fees will be collected.

Returns

NameTypeDescription
amount0uint256amount of token0 sent to receiver_
amount1uint256amount of token1 sent to receiver_

rebalance

function used to manage vault's strategy.

function rebalance(
    address vault_,
    bytes[] calldata payloads_
) external nonReentrant whenNotPaused onlyWhitelistedVault(vault_);

Parameters

NameTypeDescription
vault_addressaddress of the vault that need a rebalance.
payloads_bytes[]call data to do specific action of vault side.

setModule

function used to set a new module (strategy) for the vault.

only public vault should have this check.

function setModule(
    address vault_,
    address module_,
    bytes[] calldata payloads_
) external whenNotPaused onlyWhitelistedVault(vault_);

Parameters

NameTypeDescription
vault_addressaddress of the vault the manager want to change module.
module_addressaddress of the new module.
payloads_bytes[]call data to initialize position on the new module.

initManagement

function used to init management of a meta vault.

function initManagement(SetupParams calldata params_)
    external
    whenNotPaused;

Parameters

NameTypeDescription
params_SetupParamsstruct containing all the data for initialize the vault.

updateVaultInfo

function used to update meta vault management informations.

function updateVaultInfo(SetupParams calldata params_)
    external
    whenNotPaused
    onlyWhitelistedVault(params_.vault)
    onlyVaultOwner(params_.vault);

Parameters

NameTypeDescription
params_SetupParamsstruct containing all the data for updating the vault.

receive

receive() external payable;

announceStrategy

function used to announce the strategy that the vault will follow.

function announceStrategy(
    address vault_,
    string memory strategy_
) external onlyWhitelistedVault(vault_);

Parameters

NameTypeDescription
vault_addressaddress of arrakis meta vault that will follow the strategy.
strategy_stringstring containing the strategy name that will be used.

initializedVaults

function used to get a list of managed vaults.

function initializedVaults(
    uint256 startIndex_,
    uint256 endIndex_
) external view whenNotPaused returns (address[] memory);

Parameters

NameTypeDescription
startIndex_uint256starting index from which the caller want to read the array of managed vaults.
endIndex_uint256ending index until which the caller want to read the array of managed vaults.

numInitializedVaults

function used to get the number of vault under management.

function numInitializedVaults()
    external
    view
    returns (uint256 numberOfVaults);

guardian

address of the pauser of manager.

function guardian() external view returns (address);

Returns

NameTypeDescription
<none>addresspauser address that can pause/unpause manager.

isManaged

function used to know if a vault is under management by this manager.

function isManaged(address vault_) external view returns (bool);

Parameters

NameTypeDescription
vault_addressaddress of the meta vault the caller want to check.

Returns

NameTypeDescription
<none>boolisManaged boolean which is true if the vault is under management, false otherwise.

getInitManagementSelector

function used to know the selector of initManagement functions.

function getInitManagementSelector()
    external
    pure
    returns (bytes4 selector);

_initManagement

function _initManagement(SetupParams memory params_) internal;

_updateParamsChecks

function _updateParamsChecks(SetupParams memory params_)
    internal
    view;

Public Vaults

Content

ArrakisMetaVaultPublic

Git Source

Inherits: IArrakisMetaVaultPublic, ArrakisMetaVault, Ownable, ERC20

State Variables

_name

string internal _name;

_symbol

string internal _symbol;

Functions

constructor

constructor(
    address owner_,
    string memory name_,
    string memory symbol_,
    address moduleRegistry_,
    address manager_,
    address token0_,
    address token1_
) ArrakisMetaVault(moduleRegistry_, manager_, token0_, token1_);

mint

function used to mint share of the vault position

function mint(
    uint256 shares_,
    address receiver_
) external payable returns (uint256 amount0, uint256 amount1);

Parameters

NameTypeDescription
shares_uint256amount representing the part of the position owned by receiver.
receiver_addressaddress where share token will be sent.

Returns

NameTypeDescription
amount0uint256amount of token0 deposited.
amount1uint256amount of token1 deposited.

burn

function used to burn share of the vault position.

function burn(
    uint256 shares_,
    address receiver_
) external returns (uint256 amount0, uint256 amount1);

Parameters

NameTypeDescription
shares_uint256amount of share that will be burn.
receiver_addressaddress where underlying tokens will be sent.

Returns

NameTypeDescription
amount0uint256amount of token0 withdrawn.
amount1uint256amount of token1 withdrawn.

transferOwnership

override transfer of ownership, to make it not possible.

function transferOwnership(address) public payable override;

renounceOwnership

override transfer of ownership, to make it not possible.

function renounceOwnership() public payable override;

completeOwnershipHandover

override transfer of ownership, to make it not possible.

function completeOwnershipHandover(address) public payable override;

name

function used to get the name of the LP token.

function name() public view override returns (string memory);

Returns

NameTypeDescription
<none>stringname string value containing the name.

symbol

function used to get the symbol of the LP token.

function symbol() public view override returns (string memory);

Returns

NameTypeDescription
<none>stringsymbol string value containing the symbol.

_deposit

function _deposit(uint256 proportion_)
    internal
    nonReentrant
    returns (uint256 amount0, uint256 amount1);

_onlyOwnerCheck

msg.sender should be the tokens provider

function _onlyOwnerCheck() internal view override;

CreationCodePublicVault

Git Source

Inherits: ICreationCode

Functions

getCreationCode

function getCreationCode() external pure returns (bytes memory);

Private Vaults

ArrakisMetaVaultPrivate

Git Source

Inherits: ArrakisMetaVault, IArrakisMetaVaultPrivate, IOwnable

State Variables

nft

address public immutable nft;

_depositors

EnumerableSet.AddressSet internal _depositors;

Functions

constructor

constructor(
    address moduleRegistry_,
    address manager_,
    address token0_,
    address token1_,
    address nft_
) ArrakisMetaVault(moduleRegistry_, manager_, token0_, token1_);

deposit

function used to deposit tokens or expand position inside the inherent strategy.

function deposit(
    uint256 amount0_,
    uint256 amount1_
) external payable;

Parameters

NameTypeDescription
amount0_uint256amount of token0 need to increase the position by proportion_;
amount1_uint256amount of token1 need to increase the position by proportion_;

withdraw

function used to withdraw tokens or position contraction of the underpin strategy.

function withdraw(
    uint256 proportion_,
    address receiver_
)
    external
    onlyOwnerCustom
    returns (uint256 amount0, uint256 amount1);

Parameters

NameTypeDescription
proportion_uint256the proportion of position contraction.
receiver_addressthe address that will receive withdrawn tokens.

Returns

NameTypeDescription
amount0uint256amount of token0 returned.
amount1uint256amount of token1 returned.

whitelistDepositors

function used to whitelist depositors.

function whitelistDepositors(address[] calldata depositors_)
    external
    onlyOwnerCustom;

Parameters

NameTypeDescription
depositors_address[]list of address that will be granted to depositor role.

blacklistDepositors

function used to blacklist depositors.

function blacklistDepositors(address[] calldata depositors_)
    external
    onlyOwnerCustom;

Parameters

NameTypeDescription
depositors_address[]list of address who depositor role will be revoked.

owner

function used to get the owner of this contract.

function owner() external view returns (address);

depositors

function used to get the list of depositors.

function depositors() external view returns (address[] memory);

Returns

NameTypeDescription
<none>address[]depositors list of address granted to depositor role.

_deposit

function _deposit(
    uint256 amount0_,
    uint256 amount1_
) internal nonReentrant;

_onlyOwnerCheck

msg.sender should be the tokens provider

function _onlyOwnerCheck() internal view override;

CreationCodePrivateVault

Git Source

Inherits: ICreationCode

Functions

getCreationCode

function getCreationCode() external pure returns (bytes memory);

PrivateVaultNFT

Git Source

Inherits: Ownable, ERC721, IPrivateVaultNFT

State Variables

renderController

address public immutable renderController;

Functions

constructor

constructor() ERC721("Arrakis Private LP NFT", "ARRAKIS");

mint

function used to mint nft (representing a vault) and send it.

function mint(address to_, uint256 tokenId_) external onlyOwner;

Parameters

NameTypeDescription
to_addressaddress where to send the NFT.
tokenId_uint256id of the NFT to mint.

tokenURI

function tokenURI(uint256 tokenId_)
    public
    view
    override
    returns (string memory);

getMetaDatas

function getMetaDatas(
    address token0_,
    address token1_
)
    public
    view
    returns (
        uint8 decimals0,
        uint8 decimals1,
        string memory symbol0,
        string memory symbol1
    );

RenderController

Git Source

Inherits: Ownable, IRenderController, Initializable

State Variables

renderer

address public renderer;

Functions

initialize

function initialize(address owner_) external initializer;

setRenderer

function used to set the renderer contract

only the svgController can do it.

function setRenderer(address renderer_) external onlyOwner;

Parameters

NameTypeDescription
renderer_addressaddress of the contract that will render the tokenUri for the svg of the nft.

isNFTSVG

function isNFTSVG(address renderer_) public view returns (bool);

Modules

Content

Registry

Content

ModuleRegistry

Git Source

Inherits: IModuleRegistry, Ownable, Initializable

State Variables

factory

IArrakisMetaVaultFactory public factory;

admin

should be a timelock contract.

address public immutable admin;

_guardian

address internal immutable _guardian;

_beacons

EnumerableSet.AddressSet internal _beacons;

Functions

constructor

constructor(address owner_, address guardian_, address admin_);

initialize

function used to initialize module registry.

function initialize(address factory_) external initializer;

Parameters

NameTypeDescription
factory_addressaddress of ArrakisMetaVaultFactory, who is the only one who can call the init management function.

beacons

function to get the whitelisted list of IBeacon that have module as implementation.

function beacons() external view returns (address[] memory);

Returns

NameTypeDescription
<none>address[]beacons list of upgradeable beacon.

beaconsContains

function to know if the beacons enumerableSet contain beacon_

function beaconsContains(address beacon_)
    external
    view
    returns (bool isContained);

Parameters

NameTypeDescription
beacon_addressbeacon address to check

guardian

function used to get the guardian address of arrakis protocol.

function guardian() external view returns (address);

Returns

NameTypeDescription
<none>addressguardian address of the pauser.

whitelistBeacons

function used to whitelist IBeacon that contain implementation of valid module.

function whitelistBeacons(address[] calldata beacons_)
    external
    onlyOwner;

Parameters

NameTypeDescription
beacons_address[]list of beacon to whitelist.

blacklistBeacons

function used to blacklist IBeacon that contain implementation of unvalid (from now) module.

function blacklistBeacons(address[] calldata beacons_)
    external
    onlyOwner;

Parameters

NameTypeDescription
beacons_address[]list of beacon to blacklist.

_createModule

function _createModule(
    address vault_,
    address beacon_,
    bytes calldata payload_
) internal returns (address module);

_checkVaultNotAddressZero

function _checkVaultNotAddressZero(address vault_) internal pure;

ModulePublicRegistry

Git Source

Inherits: ModuleRegistry, IModulePublicRegistry

Functions

constructor

constructor(
    address owner_,
    address guardian_,
    address admin_
) ModuleRegistry(owner_, guardian_, admin_);

createModule

function used to create module instance that can be whitelisted as module inside a vault.

function createModule(
    address vault_,
    address beacon_,
    bytes calldata payload_
) external returns (address module);

Parameters

NameTypeDescription
vault_address
beacon_addresswhich whitelisted beacon's implementation we want to create an instance of.
payload_bytespayload to create the module.

ModulePrivateRegistry

Git Source

Inherits: ModuleRegistry, IModulePrivateRegistry

Functions

constructor

constructor(
    address owner_,
    address guardian_,
    address admin_
) ModuleRegistry(owner_, guardian_, admin_);

createModule

function used to create module instance that can be whitelisted as module inside a vault.

function createModule(
    address vault_,
    address beacon_,
    bytes calldata payload_
) external returns (address module);

Parameters

NameTypeDescription
vault_address
beacon_addresswhich whitelisted beacon's implementation we want to create an instance of.
payload_bytespayload to create the module.

Implementations

Content

ValantisModule

Git Source

Inherits: IArrakisLPModule, IValantisHOTModule, PausableUpgradeable, ReentrancyGuardUpgradeable

BeaconProxy be careful for changing implementation with upgrade.

State Variables

metaVault

IArrakisMetaVault public metaVault;

pool

ISovereignPool public pool;

alm

IHOT public alm;

token0

IERC20Metadata public token0;

token1

IERC20Metadata public token1;

maxSlippage

should we change it to mutable state variable, and settable by who?

uint24 public maxSlippage;

oracle

IOracleWrapper public oracle;

_guardian

address internal immutable _guardian;

_init0

uint256 internal _init0;

_init1

uint256 internal _init1;

_managerFeePIPS

uint256 internal _managerFeePIPS;

Functions

onlyMetaVault

modifier onlyMetaVault();

onlyManager

modifier onlyManager();

onlyGuardian

modifier onlyGuardian();

constructor

constructor(address guardian_);

initialize

initialize function to delegate call onced the beacon proxy is deployed, for initializing the valantis module. who can call deposit and withdraw functions.

function initialize(
    address pool_,
    uint256 init0_,
    uint256 init1_,
    uint24 maxSlippage_,
    address metaVault_
) external initializer;

Parameters

NameTypeDescription
pool_addressaddress of the valantis sovereign pool.
init0_uint256initial amount of token0 to provide to valantis module.
init1_uint256initial amount of token1 to provide to valantis module.
maxSlippage_uint24allowed to manager for rebalancing the inventory using swap.
metaVault_addressaddress of the meta vault

initializePosition

function used to initialize the module when a module switch happen

function initializePosition(bytes calldata data_)
    external
    virtual
    onlyMetaVault;

Parameters

NameTypeDescription
data_bytesbytes that contain information to initialize the position.

pause

function used to pause the module.

only callable by guardian

function pause() external onlyGuardian;

unpause

function used to unpause the module.

only callable by guardian

function unpause() external onlyGuardian;

setALMAndManagerFees

set HOT, oracle (wrapper of HOT) and init manager fees function.

function setALMAndManagerFees(
    address alm_,
    address oracle_
) external;

Parameters

NameTypeDescription
alm_addressaddress of the valantis HOT ALM.
oracle_addressaddress of the oracle used by the valantis HOT module.

withdraw

function used by metaVault to withdraw tokens from the strategy.

function withdraw(
    address receiver_,
    uint256 proportion_
)
    public
    virtual
    onlyMetaVault
    nonReentrant
    returns (uint256 amount0, uint256 amount1);

Parameters

NameTypeDescription
receiver_addressaddress that will receive tokens.
proportion_uint256the proportion of the total position that need to be withdrawn.

Returns

NameTypeDescription
amount0uint256amount of token0 withdrawn.
amount1uint256amount of token1 withdrawn.

withdrawManagerBalance

function used by metaVault or manager to get manager fees.

function withdrawManagerBalance()
    external
    whenNotPaused
    nonReentrant
    returns (uint256 amount0, uint256 amount1);

Returns

NameTypeDescription
amount0uint256amount of token0 sent to manager.
amount1uint256amount of token1 sent to manager.

setManagerFeePIPS

function used to set manager fees.

function setManagerFeePIPS(uint256 newFeePIPS_)
    external
    whenNotPaused
    onlyManager;

Parameters

NameTypeDescription
newFeePIPS_uint256new fee that will be applied.

setPriceBounds

fucntion used to set range on valantis AMM

function setPriceBounds(
    uint160 sqrtPriceLowX96_,
    uint160 sqrtPriceHighX96_,
    uint160 expectedSqrtSpotPriceUpperX96_,
    uint160 expectedSqrtSpotPriceLowerX96_
) external onlyManager;

Parameters

NameTypeDescription
sqrtPriceLowX96_uint160lower bound of the range in sqrt price.
sqrtPriceHighX96_uint160upper bound of the range in sqrt price.
expectedSqrtSpotPriceUpperX96_uint160expected lower limit of current spot price (to prevent sandwich attack and manipulation).
expectedSqrtSpotPriceLowerX96_uint160expected upper limit of current spot price (to prevent sandwich attack and manipulation).

swap

function to swap token0->token1 or token1->token0 and then change inventory.

function swap(
    bool zeroForOne_,
    uint256 expectedMinReturn_,
    uint256 amountIn_,
    address router_,
    uint160 expectedSqrtSpotPriceUpperX96_,
    uint160 expectedSqrtSpotPriceLowerX96_,
    bytes calldata payload_
) external onlyManager whenNotPaused;

Parameters

NameTypeDescription
zeroForOne_boolboolean if true token0->token1, if false token1->token0.
expectedMinReturn_uint256minimum amount of tokenOut expected.
amountIn_uint256amount of tokenIn used during swap.
router_addressaddress of smart contract that will execute swap.
expectedSqrtSpotPriceUpperX96_uint160upper bound of current price.
expectedSqrtSpotPriceLowerX96_uint160lower bound of current price.
payload_bytesdata payload used for swapping.

managerBalance0

function used to get manager token0 balance.

amount of fees in token0 that manager have not taken yet.

function managerBalance0() external view returns (uint256 fees0);

Returns

NameTypeDescription
fees0uint256amount of token0 that manager earned.

managerBalance1

function used to get manager token1 balance.

amount of fees in token1 that manager have not taken yet.

function managerBalance1() external view returns (uint256 fees1);

Returns

NameTypeDescription
fees1uint256amount of token1 that manager earned.

validateRebalance

function used to validate if module state is not manipulated before rebalance.

function validateRebalance(
    IOracleWrapper oracle_,
    uint24 maxDeviation_
) external view;

Parameters

NameTypeDescription
oracle_IOracleWrapperonchain oracle to check the current amm price against.
maxDeviation_uint24maximum deviation tolerated by management.

managerFeePIPS

function used to get manager fees.

function managerFeePIPS() external view returns (uint256);

Returns

NameTypeDescription
<none>uint256managerFeePIPS amount of token1 that manager earned.

getInits

function used to get the initial amounts needed to open a position.

function getInits()
    external
    view
    returns (uint256 init0, uint256 init1);

Returns

NameTypeDescription
init0uint256the amount of token0 needed to open a position.
init1uint256the amount of token1 needed to open a position.

totalUnderlying

function used to get the amount of token0 and token1 sitting on the position.

function totalUnderlying() external view returns (uint256, uint256);

Returns

NameTypeDescription
<none>uint256amount0 the amount of token0 sitting on the position.
<none>uint256amount1 the amount of token1 sitting on the position.

totalUnderlyingAtPrice

function used to get the amounts of token0 and token1 sitting on the position for a specific price.

function totalUnderlyingAtPrice(uint160 priceX96_)
    external
    view
    returns (uint256, uint256);

Parameters

NameTypeDescription
priceX96_uint160price at which we want to simulate our tokens composition

Returns

NameTypeDescription
<none>uint256amount0 the amount of token0 sitting on the position for priceX96.
<none>uint256amount1 the amount of token1 sitting on the position for priceX96.

guardian

function used to get the address that can pause the module.

function guardian() external view returns (address);

Returns

NameTypeDescription
<none>addressguardian address of the pauser.

_initializePosition

function _initializePosition() internal;

_checkMinReturn

function _checkMinReturn(
    bool zeroForOne_,
    uint256 expectedMinReturn_,
    uint256 amountIn_,
    uint8 decimals0_,
    uint8 decimals1_
) internal view;

Routers

Content

ArrakisPublicVaultRouter

Git Source

Inherits: IArrakisPublicVaultRouter, ReentrancyGuard, Ownable, Pausable

State Variables

nativeToken

address public immutable nativeToken;

permit2

IPermit2 public immutable permit2;

factory

IArrakisMetaVaultFactory public immutable factory;

weth

IWETH9 public immutable weth;

swapper

IRouterSwapExecutor public swapper;

Functions

onlyPublicVault

modifier onlyPublicVault(address vault_);

constructor

constructor(
    address nativeToken_,
    address permit2_,
    address owner_,
    address factory_,
    address weth_
);

pause

function used to pause the router.

only callable by owner

function pause() external onlyOwner;

unpause

function used to unpause the router.

only callable by owner

function unpause() external onlyOwner;

updateSwapExecutor

function updateSwapExecutor(address swapper_)
    external
    whenNotPaused
    onlyOwner;

addLiquidity

addLiquidity adds liquidity to meta vault of interest (mints L tokens)

function addLiquidity(AddLiquidityData memory params_)
    external
    payable
    nonReentrant
    whenNotPaused
    onlyPublicVault(params_.vault)
    returns (uint256 amount0, uint256 amount1, uint256 sharesReceived);

Parameters

NameTypeDescription
params_AddLiquidityDataAddLiquidityData struct containing data for adding liquidity

Returns

NameTypeDescription
amount0uint256amount of token0 transferred from msg.sender to mint mintAmount
amount1uint256amount of token1 transferred from msg.sender to mint mintAmount
sharesReceiveduint256amount of public vault tokens transferred to receiver

swapAndAddLiquidity

swapAndAddLiquidity transfer tokens to and calls RouterSwapExecutor

function swapAndAddLiquidity(SwapAndAddData memory params_)
    external
    payable
    nonReentrant
    whenNotPaused
    onlyPublicVault(params_.addData.vault)
    returns (
        uint256 amount0,
        uint256 amount1,
        uint256 sharesReceived,
        uint256 amount0Diff,
        uint256 amount1Diff
    );

Parameters

NameTypeDescription
params_SwapAndAddDataSwapAndAddData struct containing data for swap

Returns

NameTypeDescription
amount0uint256amount of token0 transferred from msg.sender to mint mintAmount
amount1uint256amount of token1 transferred from msg.sender to mint mintAmount
sharesReceiveduint256amount of public vault tokens transferred to receiver
amount0Diffuint256token0 balance difference post swap
amount1Diffuint256token1 balance difference post swap

removeLiquidity

removeLiquidity removes liquidity from vault and burns LP tokens

function removeLiquidity(RemoveLiquidityData memory params_)
    external
    nonReentrant
    whenNotPaused
    onlyPublicVault(params_.vault)
    returns (uint256 amount0, uint256 amount1);

Parameters

NameTypeDescription
params_RemoveLiquidityDataRemoveLiquidityData struct containing data for withdrawals

Returns

NameTypeDescription
amount0uint256actual amount of token0 transferred to receiver for burning burnAmount
amount1uint256actual amount of token1 transferred to receiver for burning burnAmount

addLiquidityPermit2

addLiquidityPermit2 adds liquidity to public vault of interest (mints LP tokens)

function addLiquidityPermit2(AddLiquidityPermit2Data memory params_)
    external
    payable
    nonReentrant
    whenNotPaused
    onlyPublicVault(params_.addData.vault)
    returns (uint256 amount0, uint256 amount1, uint256 sharesReceived);

Parameters

NameTypeDescription
params_AddLiquidityPermit2DataAddLiquidityPermit2Data struct containing data for adding liquidity

Returns

NameTypeDescription
amount0uint256amount of token0 transferred from msg.sender to mint mintAmount
amount1uint256amount of token1 transferred from msg.sender to mint mintAmount
sharesReceiveduint256amount of public vault tokens transferred to receiver

swapAndAddLiquidityPermit2

swapAndAddLiquidityPermit2 transfer tokens to and calls RouterSwapExecutor

function swapAndAddLiquidityPermit2(
    SwapAndAddPermit2Data memory params_
)
    external
    payable
    nonReentrant
    whenNotPaused
    onlyPublicVault(params_.swapAndAddData.addData.vault)
    returns (
        uint256 amount0,
        uint256 amount1,
        uint256 sharesReceived,
        uint256 amount0Diff,
        uint256 amount1Diff
    );

Parameters

NameTypeDescription
params_SwapAndAddPermit2DataSwapAndAddPermit2Data struct containing data for swap

Returns

NameTypeDescription
amount0uint256amount of token0 transferred from msg.sender to mint mintAmount
amount1uint256amount of token1 transferred from msg.sender to mint mintAmount
sharesReceiveduint256amount of public vault tokens transferred to receiver
amount0Diffuint256token0 balance difference post swap
amount1Diffuint256token1 balance difference post swap

removeLiquidityPermit2

removeLiquidityPermit2 removes liquidity from vault and burns LP tokens

function removeLiquidityPermit2(
    RemoveLiquidityPermit2Data memory params_
)
    external
    nonReentrant
    whenNotPaused
    onlyPublicVault(params_.removeData.vault)
    returns (uint256 amount0, uint256 amount1);

Parameters

NameTypeDescription
params_RemoveLiquidityPermit2DataRemoveLiquidityPermit2Data struct containing data for withdrawals

Returns

NameTypeDescription
amount0uint256actual amount of token0 transferred to receiver for burning burnAmount
amount1uint256actual amount of token1 transferred to receiver for burning burnAmount

wrapAndAddLiquidity

wrapAndAddLiquidity wrap eth and adds liquidity to meta vault of interest (mints L tokens)

function wrapAndAddLiquidity(AddLiquidityData memory params_)
    external
    payable
    nonReentrant
    whenNotPaused
    onlyPublicVault(params_.vault)
    returns (uint256 amount0, uint256 amount1, uint256 sharesReceived);

Parameters

NameTypeDescription
params_AddLiquidityDataAddLiquidityData struct containing data for adding liquidity

Returns

NameTypeDescription
amount0uint256amount of token0 transferred from msg.sender to mint mintAmount
amount1uint256amount of token1 transferred from msg.sender to mint mintAmount
sharesReceiveduint256amount of public vault tokens transferred to receiver

wrapAndSwapAndAddLiquidity

wrapAndSwapAndAddLiquidity wrap eth and transfer tokens to and calls RouterSwapExecutor

function wrapAndSwapAndAddLiquidity(SwapAndAddData memory params_)
    external
    payable
    nonReentrant
    whenNotPaused
    onlyPublicVault(params_.addData.vault)
    returns (
        uint256 amount0,
        uint256 amount1,
        uint256 sharesReceived,
        uint256 amount0Diff,
        uint256 amount1Diff
    );

Parameters

NameTypeDescription
params_SwapAndAddDataSwapAndAddData struct containing data for swap

Returns

NameTypeDescription
amount0uint256amount of token0 transferred from msg.sender to mint mintAmount
amount1uint256amount of token1 transferred from msg.sender to mint mintAmount
sharesReceiveduint256amount of public vault tokens transferred to receiver
amount0Diffuint256token0 balance difference post swap
amount1Diffuint256token1 balance difference post swap

wrapAndAddLiquidityPermit2

wrapAndAddLiquidityPermit2 wrap eth and adds liquidity to public vault of interest (mints LP tokens)

hack to get rid of stack too depth

function wrapAndAddLiquidityPermit2(
    AddLiquidityPermit2Data memory params_
)
    external
    payable
    nonReentrant
    whenNotPaused
    onlyPublicVault(params_.addData.vault)
    returns (uint256 amount0, uint256 amount1, uint256 sharesReceived);

Parameters

NameTypeDescription
params_AddLiquidityPermit2DataAddLiquidityPermit2Data struct containing data for adding liquidity

Returns

NameTypeDescription
amount0uint256amount of token0 transferred from msg.sender to mint mintAmount
amount1uint256amount of token1 transferred from msg.sender to mint mintAmount
sharesReceiveduint256amount of public vault tokens transferred to receiver

wrapAndSwapAndAddLiquidityPermit2

wrapAndSwapAndAddLiquidityPermit2 wrap eth and transfer tokens to and calls RouterSwapExecutor

function wrapAndSwapAndAddLiquidityPermit2(
    SwapAndAddPermit2Data memory params_
)
    external
    payable
    nonReentrant
    whenNotPaused
    onlyPublicVault(params_.swapAndAddData.addData.vault)
    returns (
        uint256 amount0,
        uint256 amount1,
        uint256 sharesReceived,
        uint256 amount0Diff,
        uint256 amount1Diff
    );

Parameters

NameTypeDescription
params_SwapAndAddPermit2DataSwapAndAddPermit2Data struct containing data for swap

Returns

NameTypeDescription
amount0uint256amount of token0 transferred from msg.sender to mint mintAmount
amount1uint256amount of token1 transferred from msg.sender to mint mintAmount
sharesReceiveduint256amount of public vault tokens transferred to receiver
amount0Diffuint256token0 balance difference post swap
amount1Diffuint256token1 balance difference post swap

receive

hack to get rid of stack too depth

receive() external payable;

getMintAmounts

getMintAmounts used to get the shares we can mint from some max amounts.

function getMintAmounts(
    address vault_,
    uint256 maxAmount0_,
    uint256 maxAmount1_
)
    external
    view
    returns (
        uint256 shareToMint,
        uint256 amount0ToDeposit,
        uint256 amount1ToDeposit
    );

Parameters

NameTypeDescription
vault_addressmeta vault address.
maxAmount0_uint256maximum amount of token0 user want to contribute.
maxAmount1_uint256maximum amount of token1 user want to contribute.

Returns

NameTypeDescription
shareToMintuint256maximum amount of share user can get for 'maxAmount0*' and 'maxAmount1*'.
amount0ToDeposituint256amount of token0 user should deposit into the vault for minting 'shareToMint'.
amount1ToDeposituint256amount of token1 user should deposit into the vault for minting 'shareToMint'.

_addLiquidity

function _addLiquidity(
    address vault_,
    uint256 amount0_,
    uint256 amount1_,
    uint256 shares_,
    address receiver_,
    address token0_,
    address token1_
) internal;

_swapAndAddLiquidity

function _swapAndAddLiquidity(
    SwapAndAddData memory params_,
    address token0_,
    address token1_
)
    internal
    returns (
        uint256 amount0Use,
        uint256 amount1Use,
        uint256 amount0,
        uint256 amount1,
        uint256 sharesReceived,
        uint256 amount0Diff,
        uint256 amount1Diff
    );

_swapAndAddLiquiditySendBackLeftOver

function _swapAndAddLiquiditySendBackLeftOver(
    SwapAndAddData memory params_,
    address token0_,
    address token1_
)
    internal
    returns (
        uint256 amount0,
        uint256 amount1,
        uint256 sharesReceived,
        uint256 amount0Diff,
        uint256 amount1Diff
    );

_removeLiquidity

function _removeLiquidity(RemoveLiquidityData memory params_)
    internal
    returns (uint256 amount0, uint256 amount1);

_permit2AddLengthOne

function _permit2AddLengthOne(
    AddLiquidityPermit2Data memory params_,
    address token0_,
    address token1_,
    uint256 amount0_,
    uint256 amount1_
) internal;

_permit2AddLengthOneOrTwo

function _permit2AddLengthOneOrTwo(
    AddLiquidityPermit2Data memory params_,
    address token0_,
    address token1_,
    uint256 amount0_,
    uint256 amount1_
) internal;

_permit2Add

function _permit2Add(
    uint256 permittedLength_,
    AddLiquidityPermit2Data memory params_,
    address token0_,
    address token1_,
    uint256 amount0_,
    uint256 amount1_
) internal;

_permit2SwapAndAddLengthOne

function _permit2SwapAndAddLengthOne(
    SwapAndAddPermit2Data memory params_,
    address token0_,
    address token1_
) internal;

_permit2SwapAndAddLengthOneOrTwo

function _permit2SwapAndAddLengthOneOrTwo(
    SwapAndAddPermit2Data memory params_,
    address token0_,
    address token1_
) internal;

_permit2SwapAndAdd

function _permit2SwapAndAdd(
    uint256 permittedLength_,
    SwapAndAddPermit2Data memory params_,
    address token0_,
    address token1_
) internal;

_getMintAmounts

function _getMintAmounts(
    address vault_,
    uint256 maxAmount0_,
    uint256 maxAmount1_
)
    internal
    view
    returns (
        uint256 shareToMint,
        uint256 amount0ToDeposit,
        uint256 amount1ToDeposit
    );

RouterSwapExecutor

Git Source

Inherits: IRouterSwapExecutor

State Variables

router

address public immutable router;

nativeToken

address public immutable nativeToken;

Functions

onlyRouter

modifier onlyRouter();

constructor

constructor(address router_, address nativeToken_);

swap

function used to swap tokens.

function swap(SwapAndAddData memory params_)
    external
    payable
    onlyRouter
    returns (uint256 amount0Diff, uint256 amount1Diff);

Parameters

NameTypeDescription
params_SwapAndAddDatastruct containing all the informations for swapping.

Returns

NameTypeDescription
amount0Diffuint256the difference in token0 amount before and after the swap.
amount1Diffuint256the difference in token1 amount before and after the swap.

receive

receive() external payable;

RouterSwapResolver

Git Source

Inherits: IRouterSwapResolver

State Variables

router

IArrakisPublicVaultRouter public immutable router;

Functions

constructor

constructor(address router_);

calculateSwapAmount

function calculateSwapAmount(
    IArrakisMetaVault vault_,
    uint256 amount0In_,
    uint256 amount1In_,
    uint256 price18Decimals_
) external view returns (bool zeroForOne, uint256 swapAmount);

_getUnderlyingOrLiquidity

function _getUnderlyingOrLiquidity(IArrakisMetaVault vault_)
    internal
    view
    returns (uint256 gross0, uint256 gross1);

Roter Structs

Content

AddLiquidityData

Git Source

struct AddLiquidityData {
    uint256 amount0Max;
    uint256 amount1Max;
    uint256 amount0Min;
    uint256 amount1Min;
    uint256 amountSharesMin;
    address vault;
    address receiver;
}

Variables

NameTypeDescription
amount0Maxuint256Maximum amount of token0 to be transferred from msg.sender to the vault
amount1Maxuint256Maximum amount of token1 to be transferred from msg.sender to the vault
amount0Minuint256Minimum amount of token0 to be transferred from msg.sender to the vault
amount1Minuint256Minimum amount of token1 to be transferred from msg.sender to the vault
amountSharesMinuint256Minimum amount of vault shares to be received by receiver
vaultaddressAddress of the vault to add liquidity to
receiveraddressAddress of the receiver of the vault shares

AddLiquidityPermit2Data

Git Source

struct AddLiquidityPermit2Data {
    AddLiquidityData addData;
    PermitBatchTransferFrom permit;
    bytes signature;
}

Variables

NameTypeDescription
addDataAddLiquidityDataAddLiquidityData struct containing data for adding liquidity
permitPermitBatchTransferFromPermitBatchTransferFrom struct containing Permit2 approvals information
signaturebytesData containing the signature of msg.sender to verify by Permit2

RemoveLiquidityData

Git Source

struct RemoveLiquidityData {
    uint256 burnAmount;
    uint256 amount0Min;
    uint256 amount1Min;
    address vault;
    address payable receiver;
}

Variables

NameTypeDescription
burnAmountuint256Amount of vault shares to be burned by msg.sender
amount0Minuint256Minimum amount of token0 to be send to receiver
amount1Minuint256Minimum amount of token1 to be send to receiver
vaultaddressAddress of the vault to remove liquidity from
receiverpayable addressAddress of the receiver of token0 and token1

RemoveLiquidityPermit2Data

Git Source

struct RemoveLiquidityPermit2Data {
    RemoveLiquidityData removeData;
    PermitTransferFrom permit;
    bytes signature;
}

Variables

NameTypeDescription
removeDataRemoveLiquidityDataRemoveLiquidityData struct containing data for removing liquidity
permitPermitTransferFromPermitTransferFrom struct of a signature containing Permit2 approval for vault token
signaturebytesData containing the signature of msg.sender to verify by Permit2

SwapAndAddData

Git Source

struct SwapAndAddData {
    SwapData swapData;
    AddLiquidityData addData;
}

Variables

NameTypeDescription
swapDataSwapDataSwapData struct containing data for swapping one of the tokens for the other
addDataAddLiquidityDataAddLiquidityData struct containing data for adding liquidity

SwapAndAddPermit2Data

Git Source

struct SwapAndAddPermit2Data {
    SwapAndAddData swapAndAddData;
    PermitBatchTransferFrom permit;
    bytes signature;
}
NameTypeDescription
swapAndAddDataSwapAndAddDataSwapAndAddData struct containing data for swapping one of the tokens for the other and adding liquidity
permitPermitBatchTransferFromPermitBatchTransferFrom struct of signatures containing Permit2 approvals
signaturebytesData containing the signature of msg.sender to verify by Permit2

SwapData

Git Source

struct SwapData {
    bytes swapPayload;
    uint256 amountInSwap;
    uint256 amountOutSwap;
    address swapRouter;
    bool zeroForOne;
}

Variables

NameTypeDescription
swapPayloadbytesPayload to use for a swap in an external venue. Transaction must be atomic
amountInSwapuint256Amount of token to be swapped
amountOutSwapuint256Minimum amount of the other token to be received from the swap
swapRouteraddressAddress of the router to be used for the swap
zeroForOneboolBoolean to determine the direction of the swap. If true swaps token0 for token1 and viceversa

Admin and Security

Content

Guardian

Git Source

Inherits: Ownable, IGuardian

State Variables

pauser

address public pauser;

Functions

constructor

constructor(address owner_, address pauser_);

setPauser

function to set the pauser of Arrakis protocol.

function setPauser(address newPauser_) external onlyOwner;

Pauser

Git Source

Inherits: IPauser, Ownable

State Variables

_pausers

EnumerableSet.AddressSet internal _pausers;

Functions

constructor

constructor(address pauser_, address owner_);

pause

function pause(address target_) external override;

whitelistPausers

function whitelistPausers(address[] calldata pausers_)
    external
    override
    onlyOwner;

blacklistPausers

function blacklistPausers(address[] calldata pausers_)
    external
    override
    onlyOwner;

isPauser

function isPauser(address account_) public view returns (bool);

TimeLock

Git Source

Inherits: TimelockController, ITimeLock

Functions

constructor

constructor(
    uint256 minDelay,
    address[] memory proposers,
    address[] memory executors,
    address admin
) TimelockController(minDelay, proposers, executors, admin);

updateDelay

override updateDelay function of TimelockController to not allow update of delay.

function updateDelay(uint256) external pure override;

More

This page contains the whole Arrakis Modular smart contracts documentation, which was autogenerated with Foundry forge doc. This serves as a complete reference for developers and facilitates a detailed search by terms.

Contents

Contents

ArrakisMetaVault

Git Source

Inherits: IArrakisMetaVault, ReentrancyGuard, Initializable

State Variables

moduleRegistry

address public immutable moduleRegistry;

token0

address public immutable token0;

token1

address public immutable token1;

manager

address public immutable manager;

module

IArrakisLPModule public module;

_whitelistedModules

EnumerableSet.AddressSet internal _whitelistedModules;

Functions

onlyOwnerCustom

modifier onlyOwnerCustom();

onlyManager

modifier onlyManager();

constructor

constructor(
    address moduleRegistry_,
    address manager_,
    address token0_,
    address token1_
);

initialize

function initialize(address module_) external initializer;

setModule

function used to set module

function setModule(
    address module_,
    bytes[] calldata payloads_
) external onlyManager nonReentrant;

Parameters

NameTypeDescription
module_addressaddress of the new module
payloads_bytes[]datas to initialize/rebalance on the new module

whitelistModules

function used to whitelist modules that can used by manager.

we transfer here all tokens to the new module.

function whitelistModules(
    address[] calldata beacons_,
    bytes[] calldata data_
) external onlyOwnerCustom;

Parameters

NameTypeDescription
beacons_address[]array of beacons addresses to use for modules creation.
data_bytes[]array of payload to use for modules creation.

blacklistModules

function used to blacklist modules that can used by manager.

function blacklistModules(address[] calldata modules_)
    external
    onlyOwnerCustom;

Parameters

NameTypeDescription
modules_address[]array of module addresses to be blacklisted.

whitelistedModules

function used to get the list of modules whitelisted.

function whitelistedModules()
    external
    view
    returns (address[] memory modules);

Returns

NameTypeDescription
modulesaddress[]whitelisted modules addresses.

getInits

function used to get the initial amounts needed to open a position.

function getInits()
    external
    view
    returns (uint256 init0, uint256 init1);

Returns

NameTypeDescription
init0uint256the amount of token0 needed to open a position.
init1uint256the amount of token1 needed to open a position.

totalUnderlying

function used to get the amount of token0 and token1 sitting on the position.

function totalUnderlying()
    public
    view
    returns (uint256 amount0, uint256 amount1);

Returns

NameTypeDescription
amount0uint256the amount of token0 sitting on the position.
amount1uint256the amount of token1 sitting on the position.

totalUnderlyingAtPrice

function used to get the amounts of token0 and token1 sitting on the position for a specific price.

function totalUnderlyingAtPrice(uint160 priceX96_)
    external
    view
    returns (uint256 amount0, uint256 amount1);

Parameters

NameTypeDescription
priceX96_uint160price at which we want to simulate our tokens composition

Returns

NameTypeDescription
amount0uint256the amount of token0 sitting on the position for priceX96.
amount1uint256the amount of token1 sitting on the position for priceX96.

_withdraw

function _withdraw(
    address receiver_,
    uint256 proportion_
) internal returns (uint256 amount0, uint256 amount1);

_withdrawManagerBalance

function _withdrawManagerBalance(IArrakisLPModule module_)
    internal
    returns (uint256 amount0, uint256 amount1);

_call

function _call(address module_, bytes memory data_) internal;

_onlyOwnerCheck

function _onlyOwnerCheck() internal view virtual;

ModuleRegistry

Git Source

Inherits: IModuleRegistry, Ownable, Initializable

State Variables

factory

IArrakisMetaVaultFactory public factory;

admin

should be a timelock contract.

address public immutable admin;

_guardian

address internal immutable _guardian;

_beacons

EnumerableSet.AddressSet internal _beacons;

Functions

constructor

constructor(address owner_, address guardian_, address admin_);

initialize

function used to initialize module registry.

function initialize(address factory_) external initializer;

Parameters

NameTypeDescription
factory_addressaddress of ArrakisMetaVaultFactory, who is the only one who can call the init management function.

beacons

function to get the whitelisted list of IBeacon that have module as implementation.

function beacons() external view returns (address[] memory);

Returns

NameTypeDescription
<none>address[]beacons list of upgradeable beacon.

beaconsContains

function to know if the beacons enumerableSet contain beacon_

function beaconsContains(address beacon_)
    external
    view
    returns (bool isContained);

Parameters

NameTypeDescription
beacon_addressbeacon address to check

guardian

function used to get the guardian address of arrakis protocol.

function guardian() external view returns (address);

Returns

NameTypeDescription
<none>addressguardian address of the pauser.

whitelistBeacons

function used to whitelist IBeacon that contain implementation of valid module.

function whitelistBeacons(address[] calldata beacons_)
    external
    onlyOwner;

Parameters

NameTypeDescription
beacons_address[]list of beacon to whitelist.

blacklistBeacons

function used to blacklist IBeacon that contain implementation of unvalid (from now) module.

function blacklistBeacons(address[] calldata beacons_)
    external
    onlyOwner;

Parameters

NameTypeDescription
beacons_address[]list of beacon to blacklist.

_createModule

function _createModule(
    address vault_,
    address beacon_,
    bytes calldata payload_
) internal returns (address module);

_checkVaultNotAddressZero

function _checkVaultNotAddressZero(address vault_) internal pure;

ValantisModule

Git Source

Inherits: IArrakisLPModule, IValantisHOTModule, PausableUpgradeable, ReentrancyGuardUpgradeable

BeaconProxy be careful for changing implementation with upgrade.

State Variables

metaVault

IArrakisMetaVault public metaVault;

pool

ISovereignPool public pool;

alm

IHOT public alm;

token0

IERC20Metadata public token0;

token1

IERC20Metadata public token1;

maxSlippage

should we change it to mutable state variable, and settable by who?

uint24 public maxSlippage;

oracle

IOracleWrapper public oracle;

_guardian

address internal immutable _guardian;

_init0

uint256 internal _init0;

_init1

uint256 internal _init1;

_managerFeePIPS

uint256 internal _managerFeePIPS;

Functions

onlyMetaVault

modifier onlyMetaVault();

onlyManager

modifier onlyManager();

onlyGuardian

modifier onlyGuardian();

constructor

constructor(address guardian_);

initialize

initialize function to delegate call onced the beacon proxy is deployed, for initializing the valantis module. who can call deposit and withdraw functions.

function initialize(
    address pool_,
    uint256 init0_,
    uint256 init1_,
    uint24 maxSlippage_,
    address metaVault_
) external initializer;

Parameters

NameTypeDescription
pool_addressaddress of the valantis sovereign pool.
init0_uint256initial amount of token0 to provide to valantis module.
init1_uint256initial amount of token1 to provide to valantis module.
maxSlippage_uint24allowed to manager for rebalancing the inventory using swap.
metaVault_addressaddress of the meta vault

initializePosition

function used to initialize the module when a module switch happen

function initializePosition(bytes calldata data_)
    external
    virtual
    onlyMetaVault;

Parameters

NameTypeDescription
data_bytesbytes that contain information to initialize the position.

pause

function used to pause the module.

only callable by guardian

function pause() external onlyGuardian;

unpause

function used to unpause the module.

only callable by guardian

function unpause() external onlyGuardian;

setALMAndManagerFees

set HOT, oracle (wrapper of HOT) and init manager fees function.

function setALMAndManagerFees(
    address alm_,
    address oracle_
) external;

Parameters

NameTypeDescription
alm_addressaddress of the valantis HOT ALM.
oracle_addressaddress of the oracle used by the valantis HOT module.

withdraw

function used by metaVault to withdraw tokens from the strategy.

function withdraw(
    address receiver_,
    uint256 proportion_
)
    public
    virtual
    onlyMetaVault
    nonReentrant
    returns (uint256 amount0, uint256 amount1);

Parameters

NameTypeDescription
receiver_addressaddress that will receive tokens.
proportion_uint256the proportion of the total position that need to be withdrawn.

Returns

NameTypeDescription
amount0uint256amount of token0 withdrawn.
amount1uint256amount of token1 withdrawn.

withdrawManagerBalance

function used by metaVault or manager to get manager fees.

function withdrawManagerBalance()
    external
    whenNotPaused
    nonReentrant
    returns (uint256 amount0, uint256 amount1);

Returns

NameTypeDescription
amount0uint256amount of token0 sent to manager.
amount1uint256amount of token1 sent to manager.

setManagerFeePIPS

function used to set manager fees.

function setManagerFeePIPS(uint256 newFeePIPS_)
    external
    whenNotPaused
    onlyManager;

Parameters

NameTypeDescription
newFeePIPS_uint256new fee that will be applied.

setPriceBounds

fucntion used to set range on valantis AMM

function setPriceBounds(
    uint160 sqrtPriceLowX96_,
    uint160 sqrtPriceHighX96_,
    uint160 expectedSqrtSpotPriceUpperX96_,
    uint160 expectedSqrtSpotPriceLowerX96_
) external onlyManager;

Parameters

NameTypeDescription
sqrtPriceLowX96_uint160lower bound of the range in sqrt price.
sqrtPriceHighX96_uint160upper bound of the range in sqrt price.
expectedSqrtSpotPriceUpperX96_uint160expected lower limit of current spot price (to prevent sandwich attack and manipulation).
expectedSqrtSpotPriceLowerX96_uint160expected upper limit of current spot price (to prevent sandwich attack and manipulation).

swap

function to swap token0->token1 or token1->token0 and then change inventory.

function swap(
    bool zeroForOne_,
    uint256 expectedMinReturn_,
    uint256 amountIn_,
    address router_,
    uint160 expectedSqrtSpotPriceUpperX96_,
    uint160 expectedSqrtSpotPriceLowerX96_,
    bytes calldata payload_
) external onlyManager whenNotPaused;

Parameters

NameTypeDescription
zeroForOne_boolboolean if true token0->token1, if false token1->token0.
expectedMinReturn_uint256minimum amount of tokenOut expected.
amountIn_uint256amount of tokenIn used during swap.
router_addressaddress of smart contract that will execute swap.
expectedSqrtSpotPriceUpperX96_uint160upper bound of current price.
expectedSqrtSpotPriceLowerX96_uint160lower bound of current price.
payload_bytesdata payload used for swapping.

managerBalance0

function used to get manager token0 balance.

amount of fees in token0 that manager have not taken yet.

function managerBalance0() external view returns (uint256 fees0);

Returns

NameTypeDescription
fees0uint256amount of token0 that manager earned.

managerBalance1

function used to get manager token1 balance.

amount of fees in token1 that manager have not taken yet.

function managerBalance1() external view returns (uint256 fees1);

Returns

NameTypeDescription
fees1uint256amount of token1 that manager earned.

validateRebalance

function used to validate if module state is not manipulated before rebalance.

function validateRebalance(
    IOracleWrapper oracle_,
    uint24 maxDeviation_
) external view;

Parameters

NameTypeDescription
oracle_IOracleWrapperonchain oracle to check the current amm price against.
maxDeviation_uint24maximum deviation tolerated by management.

managerFeePIPS

function used to get manager fees.

function managerFeePIPS() external view returns (uint256);

Returns

NameTypeDescription
<none>uint256managerFeePIPS amount of token1 that manager earned.

getInits

function used to get the initial amounts needed to open a position.

function getInits()
    external
    view
    returns (uint256 init0, uint256 init1);

Returns

NameTypeDescription
init0uint256the amount of token0 needed to open a position.
init1uint256the amount of token1 needed to open a position.

totalUnderlying

function used to get the amount of token0 and token1 sitting on the position.

function totalUnderlying() external view returns (uint256, uint256);

Returns

NameTypeDescription
<none>uint256amount0 the amount of token0 sitting on the position.
<none>uint256amount1 the amount of token1 sitting on the position.

totalUnderlyingAtPrice

function used to get the amounts of token0 and token1 sitting on the position for a specific price.

function totalUnderlyingAtPrice(uint160 priceX96_)
    external
    view
    returns (uint256, uint256);

Parameters

NameTypeDescription
priceX96_uint160price at which we want to simulate our tokens composition

Returns

NameTypeDescription
<none>uint256amount0 the amount of token0 sitting on the position for priceX96.
<none>uint256amount1 the amount of token1 sitting on the position for priceX96.

guardian

function used to get the address that can pause the module.

function guardian() external view returns (address);

Returns

NameTypeDescription
<none>addressguardian address of the pauser.

_initializePosition

function _initializePosition() internal;

_checkMinReturn

function _checkMinReturn(
    bool zeroForOne_,
    uint256 expectedMinReturn_,
    uint256 amountIn_,
    uint8 decimals0_,
    uint8 decimals1_
) internal view;

Contents

Constants

Git Source

MINIMUM_LIQUIDITY

uint256 constant MINIMUM_LIQUIDITY = 10 ** 3;

BASE

uint256 constant BASE = 1e18;

PIPS

uint24 constant PIPS = 1_000_000;

TEN_PERCENT

uint24 constant TEN_PERCENT = 100_000;

WEEK

uint256 constant WEEK = 604_800;

NATIVE_COIN

address constant NATIVE_COIN =
    0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;

NATIVE_COIN_DECIMALS

uint8 constant NATIVE_COIN_DECIMALS = 18;

Contents

ArrakisPrivateHook

Git Source

Inherits: IHooks, IArrakisPrivateHook

State Variables

module

address public immutable module;

poolManager

address public immutable poolManager;

vault

address public immutable vault;

manager

address public immutable manager;

fee

uint24 public fee;

Functions

constructor

constructor(address module_, address poolManager_);

setFee

function setFee(PoolKey calldata poolKey_, uint24 fee_) external;

beforeInitialize

The hook called before the state of a pool is initialized.

function not implemented, ArrakisPrivateHook will not support this hook.

function beforeInitialize(
    address,
    PoolKey calldata,
    uint160,
    bytes calldata
) external virtual returns (bytes4);

afterInitialize

The hook called after the state of a pool is initialized.

function not implemented, ArrakisPrivateHook will not support this hook.

function afterInitialize(
    address,
    PoolKey calldata,
    uint160,
    int24,
    bytes calldata
) external virtual returns (bytes4);

beforeAddLiquidity

The hook called before liquidity is added

function beforeAddLiquidity(
    address sender,
    PoolKey calldata,
    IPoolManager.ModifyLiquidityParams calldata,
    bytes calldata
) external virtual returns (bytes4);

Parameters

NameTypeDescription
senderaddressThe initial msg.sender for the add liquidity call.
<none>PoolKey
<none>IPoolManager.ModifyLiquidityParams
<none>bytes

afterAddLiquidity

The hook called after liquidity is added.

function not implemented, ArrakisPrivateHook will not support this hook.

function afterAddLiquidity(
    address,
    PoolKey calldata,
    IPoolManager.ModifyLiquidityParams calldata,
    BalanceDelta,
    BalanceDelta,
    bytes calldata
) external virtual returns (bytes4, BalanceDelta);

beforeRemoveLiquidity

The hook called before liquidity is removed.

function beforeRemoveLiquidity(
    address sender,
    PoolKey calldata,
    IPoolManager.ModifyLiquidityParams calldata,
    bytes calldata
) external virtual returns (bytes4);

Parameters

NameTypeDescription
senderaddressThe initial msg.sender for the remove liquidity call.
<none>PoolKey
<none>IPoolManager.ModifyLiquidityParams
<none>bytes

afterRemoveLiquidity

The hook called after liquidity is removed.

function not implemented, ArrakisPrivateHook will not support this hook.

function afterRemoveLiquidity(
    address,
    PoolKey calldata,
    IPoolManager.ModifyLiquidityParams calldata,
    BalanceDelta,
    BalanceDelta,
    bytes calldata
) external virtual returns (bytes4, BalanceDelta);

beforeSwap

The hook called before a swap.

function not implemented, ArrakisPrivateHook will not support this hook.

function beforeSwap(
    address,
    PoolKey calldata,
    IPoolManager.SwapParams calldata,
    bytes calldata
) external virtual returns (bytes4, BeforeSwapDelta, uint24);

afterSwap

The hook called after a swap.

function not implemented, ArrakisPrivateHook will not support this hook.

function afterSwap(
    address,
    PoolKey calldata,
    IPoolManager.SwapParams calldata,
    BalanceDelta,
    bytes calldata
) external virtual returns (bytes4, int128);

beforeDonate

The hook called before donate.

function not implemented, ArrakisPrivateHook will not support this hook.

function beforeDonate(
    address,
    PoolKey calldata,
    uint256,
    uint256,
    bytes calldata
) external virtual returns (bytes4);

afterDonate

The hook called after donate.

function not implemented, ArrakisPrivateHook will not support this hook.

function afterDonate(
    address,
    PoolKey calldata,
    uint256,
    uint256,
    bytes calldata
) external virtual returns (bytes4);

Contents

AggregatorV3Interface

Git Source

Functions

decimals

function decimals() external view returns (uint8);

description

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

version

function version() external view returns (uint256);

getRoundData

function getRoundData(uint80 _roundId)
    external
    view
    returns (
        uint80 roundId,
        int256 answer,
        uint256 startedAt,
        uint256 updatedAt,
        uint80 answeredInRound
    );

latestRoundData

function latestRoundData()
    external
    view
    returns (
        uint80 roundId,
        int256 answer,
        uint256 startedAt,
        uint256 updatedAt,
        uint80 answeredInRound
    );

IArrakisLPModule

Git Source

Author: Arrakis Finance

Module interfaces, modules are implementing differents strategies that an arrakis module can use.

Functions

pause

function used to pause the module.

only callable by guardian

function pause() external;

unpause

function used to unpause the module.

only callable by guardian

function unpause() external;

initializePosition

function used to initialize the module when a module switch happen

function initializePosition(bytes calldata data_) external;

Parameters

NameTypeDescription
data_bytesbytes that contain information to initialize the position.

withdraw

function used by metaVault to withdraw tokens from the strategy.

function withdraw(
    address receiver_,
    uint256 proportion_
) external returns (uint256 amount0, uint256 amount1);

Parameters

NameTypeDescription
receiver_addressaddress that will receive tokens.
proportion_uint256the proportion of the total position that need to be withdrawn.

Returns

NameTypeDescription
amount0uint256amount of token0 withdrawn.
amount1uint256amount of token1 withdrawn.

withdrawManagerBalance

function used by metaVault or manager to get manager fees.

function withdrawManagerBalance()
    external
    returns (uint256 amount0, uint256 amount1);

Returns

NameTypeDescription
amount0uint256amount of token0 sent to manager.
amount1uint256amount of token1 sent to manager.

setManagerFeePIPS

function used to set manager fees.

function setManagerFeePIPS(uint256 newFeePIPS_) external;

Parameters

NameTypeDescription
newFeePIPS_uint256new fee that will be applied.

metaVault

function used to get metaVault as IArrakisMetaVault.

function metaVault() external view returns (IArrakisMetaVault);

Returns

NameTypeDescription
<none>IArrakisMetaVaultmetaVault that implement IArrakisMetaVault.

guardian

function used to get the address that can pause the module.

function guardian() external view returns (address);

Returns

NameTypeDescription
<none>addressguardian address of the pauser.

managerBalance0

function used to get manager token0 balance.

amount of fees in token0 that manager have not taken yet.

function managerBalance0() external view returns (uint256);

Returns

NameTypeDescription
<none>uint256managerBalance0 amount of token0 that manager earned.

managerBalance1

function used to get manager token1 balance.

amount of fees in token1 that manager have not taken yet.

function managerBalance1() external view returns (uint256);

Returns

NameTypeDescription
<none>uint256managerBalance1 amount of token1 that manager earned.

managerFeePIPS

function used to get manager fees.

function managerFeePIPS() external view returns (uint256);

Returns

NameTypeDescription
<none>uint256managerFeePIPS amount of token1 that manager earned.

token0

function used to get token0 as IERC20Metadata.

function token0() external view returns (IERC20Metadata);

Returns

NameTypeDescription
<none>IERC20Metadatatoken0 as IERC20Metadata.

token1

function used to get token1 as IERC20Metadata.

function token1() external view returns (IERC20Metadata);

Returns

NameTypeDescription
<none>IERC20Metadatatoken1 as IERC20Metadata.

getInits

function used to get the initial amounts needed to open a position.

function getInits()
    external
    view
    returns (uint256 init0, uint256 init1);

Returns

NameTypeDescription
init0uint256the amount of token0 needed to open a position.
init1uint256the amount of token1 needed to open a position.

totalUnderlying

function used to get the amount of token0 and token1 sitting on the position.

function totalUnderlying()
    external
    view
    returns (uint256 amount0, uint256 amount1);

Returns

NameTypeDescription
amount0uint256the amount of token0 sitting on the position.
amount1uint256the amount of token1 sitting on the position.

totalUnderlyingAtPrice

function used to get the amounts of token0 and token1 sitting on the position for a specific price.

function totalUnderlyingAtPrice(uint160 priceX96_)
    external
    view
    returns (uint256 amount0, uint256 amount1);

Parameters

NameTypeDescription
priceX96_uint160price at which we want to simulate our tokens composition

Returns

NameTypeDescription
amount0uint256the amount of token0 sitting on the position for priceX96.
amount1uint256the amount of token1 sitting on the position for priceX96.

validateRebalance

function used to validate if module state is not manipulated before rebalance.

function validateRebalance(
    IOracleWrapper oracle_,
    uint24 maxDeviation_
) external view;

Parameters

NameTypeDescription
oracle_IOracleWrapperoracle that will used to check internal state.
maxDeviation_uint24maximum deviation allowed.

Events

LogWithdraw

Event describing a withdrawal of participation by an user inside this module.

withdraw action can be indexed by receiver.

event LogWithdraw(
    address indexed receiver,
    uint256 proportion,
    uint256 amount0,
    uint256 amount1
);

Parameters

NameTypeDescription
receiveraddressaddress that will receive the tokens withdrawn.
proportionuint256percentage of the current position that user want to withdraw.
amount0uint256amount of token0 send to "receiver" due to withdraw action.
amount1uint256amount of token1 send to "receiver" due to withdraw action.

LogWithdrawManagerBalance

Event describing a manager fee withdrawal.

event LogWithdrawManagerBalance(
    address manager, uint256 amount0, uint256 amount1
);

Parameters

NameTypeDescription
manageraddressaddress of the manager that will fees earned due to his fund management.
amount0uint256amount of token0 that manager has earned and will be transfered.
amount1uint256amount of token1 that manager has earned and will be transfered.

LogSetManagerFeePIPS

Event describing manager set his fees.

event LogSetManagerFeePIPS(uint256 oldFee, uint256 newFee);

Parameters

NameTypeDescription
oldFeeuint256fees share that have been taken by manager.
newFeeuint256fees share that have been taken by manager.

Errors

AddressZero

triggered when an address that should not be zero is equal to address zero.

error AddressZero();

OnlyMetaVault

triggered when the caller is different than the metaVault that own this module.

error OnlyMetaVault(address caller, address metaVault);

OnlyManager

triggered when the caller is different than the manager defined by the metaVault.

error OnlyManager(address caller, address manager);

ProportionZero

triggered if proportion of minting or burning is zero.

error ProportionZero();

ProportionGtBASE

triggered if during withdraw more than 100% of the position.

error ProportionGtBASE();

NewFeesGtPIPS

triggered when manager want to set his more earned by the position than 100% of fees earned.

error NewFeesGtPIPS(uint256 newFees);

SameManagerFee

triggered when manager is setting the same fees that already active.

error SameManagerFee();

InitsAreZeros

triggered when inits values are zeros.

error InitsAreZeros();

OnlyGuardian

triggered when pause/unpaused function is called by someone else than guardian.

error OnlyGuardian();

IArrakisLPModuleID

Git Source

Functions

id

function id() external view returns (bytes32);

IArrakisLPModulePrivate

Git Source

expose a deposit function for that can deposit any share of token0 and token1.

this deposit feature will be used by private actor.

Functions

fund

deposit function for private vault.

function fund(
    address depositor_,
    uint256 amount0_,
    uint256 amount1_
) external payable;

Parameters

NameTypeDescription
depositor_addressaddress that will provide the tokens.
amount0_uint256amount of token0 that depositor want to send to module.
amount1_uint256amount of token1 that depositor want to send to module.

Events

LogFund

event emitted when owner of private fund the private vault.

event LogFund(address depositor, uint256 amount0, uint256 amount1);

Parameters

NameTypeDescription
depositoraddressaddress that are sending the tokens, the owner.
amount0uint256amount of token0 sent by depositor.
amount1uint256amount of token1 sent by depositor.

Errors

DepositZero

error DepositZero();

IArrakisLPModulePublic

Git Source

expose a deposit function for that can deposit a specific share of token0 and token1.

this deposit feature will be used by public actor.

Functions

deposit

deposit function for public vault.

function deposit(
    address depositor_,
    uint256 proportion_
) external payable returns (uint256 amount0, uint256 amount1);

Parameters

NameTypeDescription
depositor_addressaddress that will provide the tokens.
proportion_uint256percentage of portfolio position vault want to expand.

Returns

NameTypeDescription
amount0uint256amount of token0 needed to expand the portfolio by "proportion" percent.
amount1uint256amount of token1 needed to expand the portfolio by "proportion" percent.

Events

LogDeposit

Event describing a deposit done by an user inside this module.

deposit action can be indexed by depositor.

event LogDeposit(
    address depositor,
    uint256 proportion,
    uint256 amount0,
    uint256 amount1
);

Parameters

NameTypeDescription
depositoraddressaddress of the tokens provider.
proportionuint256percentage of the current position that depositor want to increase.
amount0uint256amount of token0 needed to increase the portfolio of "proportion" percent.
amount1uint256amount of token1 needed to increase the portfolio of "proportion" percent.

IArrakisMetaVault

Git Source

IArrakisMetaVault is a vault that is able to invest dynamically deposited tokens into protocols through his module.

Functions

initialize

function used to initialize default module.

function initialize(address module_) external;

Parameters

NameTypeDescription
module_addressaddress of the default module.

setModule

function used to set module

function setModule(
    address module_,
    bytes[] calldata payloads_
) external;

Parameters

NameTypeDescription
module_addressaddress of the new module
payloads_bytes[]datas to initialize/rebalance on the new module

whitelistModules

function used to whitelist modules that can used by manager.

function whitelistModules(
    address[] calldata beacons_,
    bytes[] calldata data_
) external;

Parameters

NameTypeDescription
beacons_address[]array of beacons addresses to use for modules creation.
data_bytes[]array of payload to use for modules creation.

blacklistModules

function used to blacklist modules that can used by manager.

function blacklistModules(address[] calldata modules_) external;

Parameters

NameTypeDescription
modules_address[]array of module addresses to be blacklisted.

whitelistedModules

function used to get the list of modules whitelisted.

function whitelistedModules()
    external
    view
    returns (address[] memory modules);

Returns

NameTypeDescription
modulesaddress[]whitelisted modules addresses.

totalUnderlying

function used to get the amount of token0 and token1 sitting on the position.

function totalUnderlying()
    external
    view
    returns (uint256 amount0, uint256 amount1);

Returns

NameTypeDescription
amount0uint256the amount of token0 sitting on the position.
amount1uint256the amount of token1 sitting on the position.

totalUnderlyingAtPrice

function used to get the amounts of token0 and token1 sitting on the position for a specific price.

function totalUnderlyingAtPrice(uint160 priceX96)
    external
    view
    returns (uint256 amount0, uint256 amount1);

Parameters

NameTypeDescription
priceX96uint160price at which we want to simulate our tokens composition

Returns

NameTypeDescription
amount0uint256the amount of token0 sitting on the position for priceX96.
amount1uint256the amount of token1 sitting on the position for priceX96.

getInits

function used to get the initial amounts needed to open a position.

function getInits()
    external
    view
    returns (uint256 init0, uint256 init1);

Returns

NameTypeDescription
init0uint256the amount of token0 needed to open a position.
init1uint256the amount of token1 needed to open a position.

token0

function used to get the address of token0.

function token0() external view returns (address);

token1

function used to get the address of token1.

function token1() external view returns (address);

manager

function used to get manager address.

function manager() external view returns (address);

module

function used to get module used to open/close/manager a position.

function module() external view returns (IArrakisLPModule);

moduleRegistry

function used to get module registry.

function moduleRegistry() external view returns (address registry);

Returns

NameTypeDescription
registryaddressaddress of module registry.

Events

LogWithdrawManagerBalance

Event describing a manager fee withdrawal.

event LogWithdrawManagerBalance(uint256 amount0, uint256 amount1);

Parameters

NameTypeDescription
amount0uint256amount of token0 that manager has earned and will be transfered.
amount1uint256amount of token1 that manager has earned and will be transfered.

LogSetManager

Event describing owner setting the manager.

event LogSetManager(address manager);

Parameters

NameTypeDescription
manageraddressaddress of manager that will manage the portfolio.

LogSetModule

Event describing manager setting the module.

event LogSetModule(address module, bytes[] payloads);

Parameters

NameTypeDescription
moduleaddressaddress of the new active module.
payloadsbytes[]data payloads for initializing positions on the new module.

LogSetFirstModule

Event describing default module that the vault will be initialized with.

event LogSetFirstModule(address module);

Parameters

NameTypeDescription
moduleaddressaddress of the default module.

LogWhiteListedModules

Event describing list of modules that has been whitelisted by owner.

event LogWhiteListedModules(address[] modules);

Parameters

NameTypeDescription
modulesaddress[]list of addresses corresponding to new modules now available to be activated by manager.

LogWhitelistedModule

Event describing whitelisted of the first module during vault creation.

event LogWhitelistedModule(address module);

Parameters

NameTypeDescription
moduleaddressdefault activation.

LogBlackListedModules

Event describing blacklisting action of modules by owner.

event LogBlackListedModules(address[] modules);

Parameters

NameTypeDescription
modulesaddress[]list of addresses corresponding to old modules that has been blacklisted.

Errors

AddressZero

triggered when an address that should not be zero is equal to address zero.

error AddressZero(string property);

OnlyManager

triggered when the caller is different than the manager.

error OnlyManager(address caller, address manager);

CallFailed

triggered when a low level call failed during execution.

error CallFailed();

SameModule

triggered when manager try to set the active module as active.

error SameModule();

SameManager

triggered when owner of the vault try to set the manager with the current manager.

error SameManager();

ModuleNotEmpty

triggered when all tokens withdrawal has been done during a switch of module.

error ModuleNotEmpty(uint256 amount0, uint256 amount1);

AlreadyWhitelisted

triggered when owner try to whitelist a module that has been already whitelisted.

error AlreadyWhitelisted(address module);

NotWhitelistedModule

triggered when owner try to blacklist a module that has not been whitelisted.

error NotWhitelistedModule(address module);

ActiveModule

triggered when owner try to blacklist the active module.

error ActiveModule();

Token0GtToken1

triggered during vault creation if token0 address is greater than token1 address.

error Token0GtToken1();

Token0EqToken1

triggered during vault creation if token0 address is equal to token1 address.

error Token0EqToken1();

NotWhitelistedBeacon

triggered when whitelisting action is occuring and module's beacon is not whitelisted on module registry.

error NotWhitelistedBeacon();

NotSameGuardian

triggered when guardian of the whitelisting module is different than the guardian of the registry.

error NotSameGuardian();

NotImplemented

triggered when a function logic is not implemented.

error NotImplemented();

ArrayNotSameLength

triggered when two arrays suppposed to have the same length, have different length.

error ArrayNotSameLength();

OnlyOwner

triggered when function is called by someone else than the owner.

error OnlyOwner();

WithdrawNotAllowed

triggered when setModule action try to remove funds.

error WithdrawNotAllowed();

PositionNotInitialized

triggered when setModule function end without initiliazePosition call.

error PositionNotInitialized();

NotPositionInitializationCall

triggered when the first external call of setModule function isn't InitializePosition function.

error NotPositionInitializationCall();

IArrakisMetaVaultFactory

Git Source

Functions

pause

function used to pause the factory.

only callable by owner.

function pause() external;

unpause

function used to unpause the factory.

only callable by owner.

function unpause() external;

setManager

function used to set a new manager.

only callable by owner.

function setManager(address newManager_) external;

Parameters

NameTypeDescription
newManager_addressaddress that will managed newly created vault.

deployPublicVault

function used to deploy ERC20 token wrapped Arrakis Meta Vault.

function deployPublicVault(
    bytes32 salt_,
    address token0_,
    address token1_,
    address owner_,
    address beacon_,
    bytes calldata moduleCreationPayload_,
    bytes calldata initManagementPayload_
) external returns (address vault);

Parameters

NameTypeDescription
salt_bytes32bytes32 used to get a deterministic all chains address.
token0_addressaddress of the first token of the token pair.
token1_addressaddress of the second token of the token pair.
owner_addressaddress of the owner of the vault.
beacon_addressaddress of the beacon that will be used to create the default module.
moduleCreationPayload_bytespayload for initializing the module.
initManagementPayload_bytesdata for initialize management.

Returns

NameTypeDescription
vaultaddressaddress of the newly created Token Meta Vault.

deployPrivateVault

function used to deploy owned Arrakis Meta Vault.

function deployPrivateVault(
    bytes32 salt_,
    address token0_,
    address token1_,
    address owner_,
    address beacon_,
    bytes calldata moduleCreationPayload_,
    bytes calldata initManagementPayload_
) external returns (address vault);

Parameters

NameTypeDescription
salt_bytes32bytes32 needed to compute vault address deterministic way.
token0_addressaddress of the first token of the token pair.
token1_addressaddress of the second token of the token pair.
owner_addressaddress of the owner of the vault.
beacon_addressaddress of the beacon that will be used to create the default module.
moduleCreationPayload_bytespayload for initializing the module.
initManagementPayload_bytesdata for initialize management.

Returns

NameTypeDescription
vaultaddressaddress of the newly created private Meta Vault.

whitelistDeployer

function used to grant the role to deploy to a list of addresses.

function whitelistDeployer(address[] calldata deployers_) external;

Parameters

NameTypeDescription
deployers_address[]list of addresses that owner want to grant permission to deploy.

blacklistDeployer

function used to grant the role to deploy to a list of addresses.

function blacklistDeployer(address[] calldata deployers_) external;

Parameters

NameTypeDescription
deployers_address[]list of addresses that owner want to revoke permission to deploy.

getTokenName

get Arrakis Modular standard token name for two corresponding tokens.

function getTokenName(
    address token0_,
    address token1_
) external view returns (string memory);

Parameters

NameTypeDescription
token0_addressaddress of the first token.
token1_addressaddress of the second token.

Returns

NameTypeDescription
<none>stringname name of the arrakis modular token vault.

publicVaults

get a list of public vaults created by this factory

function publicVaults(
    uint256 startIndex_,
    uint256 endIndex_
) external view returns (address[] memory);

Parameters

NameTypeDescription
startIndex_uint256start index
endIndex_uint256end index

Returns

NameTypeDescription
<none>address[]vaults list of all created vaults.

numOfPublicVaults

numOfPublicVaults counts the total number of token vaults in existence

function numOfPublicVaults() external view returns (uint256 result);

Returns

NameTypeDescription
resultuint256total number of vaults deployed

isPublicVault

isPublicVault check if the inputed vault is a public vault.

function isPublicVault(address vault_) external view returns (bool);

Parameters

NameTypeDescription
vault_addressaddress of the address to check.

Returns

NameTypeDescription
<none>boolisPublicVault true if the inputed vault is public or otherwise false.

privateVaults

get a list of private vaults created by this factory

function privateVaults(
    uint256 startIndex_,
    uint256 endIndex_
) external view returns (address[] memory);

Parameters

NameTypeDescription
startIndex_uint256start index
endIndex_uint256end index

Returns

NameTypeDescription
<none>address[]vaults list of all created vaults.

numOfPrivateVaults

numOfPrivateVaults counts the total number of private vaults in existence

function numOfPrivateVaults()
    external
    view
    returns (uint256 result);

Returns

NameTypeDescription
resultuint256total number of vaults deployed

isPrivateVault

isPrivateVault check if the inputed vault is a private vault.

function isPrivateVault(address vault_)
    external
    view
    returns (bool);

Parameters

NameTypeDescription
vault_addressaddress of the address to check.

Returns

NameTypeDescription
<none>boolisPublicVault true if the inputed vault is private or otherwise false.

manager

function used to get the manager of newly deployed vault.

function manager() external view returns (address);

Returns

NameTypeDescription
<none>addressmanager address that will manager vault that will be created.

deployers

function used to get a list of address that can deploy public vault.

function deployers() external view returns (address[] memory);

moduleRegistryPublic

function used to get public module registry.

function moduleRegistryPublic() external view returns (address);

moduleRegistryPrivate

function used to get private module registry.

function moduleRegistryPrivate() external view returns (address);

Events

LogPublicVaultCreation

event emitted when public vault is created by a deployer.

event LogPublicVaultCreation(
    address indexed creator,
    bytes32 salt,
    address token0,
    address token1,
    address owner,
    address module,
    address publicVault,
    address timeLock
);

Parameters

NameTypeDescription
creatoraddressaddress that is creating the public vault, a deployer.
saltbytes32salt used for create3.
token0addressfirst token of the token pair.
token1addresssecond token of the token pair.
owneraddressaddress of the owner.
moduleaddressdefault module that will be used by the meta vault.
publicVaultaddressaddress of the deployed meta vault.
timeLockaddresstimeLock that will owned the meta vault.

LogPrivateVaultCreation

event emitted when private vault is created.

event LogPrivateVaultCreation(
    address indexed creator,
    bytes32 salt,
    address token0,
    address token1,
    address owner,
    address module,
    address privateVault
);

Parameters

NameTypeDescription
creatoraddressaddress that is deploying the vault.
saltbytes32salt used for create3.
token0addressaddress of the first token of the pair.
token1addressaddress of the second token of the pair.
owneraddressaddress that will owned the private vault.
moduleaddressaddress of the default module.
privateVaultaddressaddress of the deployed meta vault.

LogWhitelistDeployers

event emitted when whitelisting an array of public vault deployers.

event LogWhitelistDeployers(address[] deployers);

Parameters

NameTypeDescription
deployersaddress[]list of deployers added to the whitelist.

LogBlacklistDeployers

event emitted when blacklisting an array of public vault deployers.

event LogBlacklistDeployers(address[] deployers);

Parameters

NameTypeDescription
deployersaddress[]list of deployers removed from the whitelist.

LogSetManager

event emitted when owner set a new manager.

event LogSetManager(address oldManager, address newManager);

Parameters

NameTypeDescription
oldManageraddressaddress of the previous manager.
newManageraddressaddress of the new manager.

Errors

AddressZero

error AddressZero();

StartIndexLtEndIndex

triggered when querying vaults on factory and start index is lower than end index.

error StartIndexLtEndIndex(uint256 startIndex, uint256 endIndex);

EndIndexGtNbOfVaults

triggered when querying vaults on factory and end index of the query is bigger the biggest index of the vaults array.

error EndIndexGtNbOfVaults(uint256 endIndex, uint256 numberOfVaults);

AlreadyWhitelistedDeployer

triggered when owner want to whitelist a deployer that has been already whitelisted.

error AlreadyWhitelistedDeployer(address deployer);

NotAlreadyADeployer

triggered when owner want to blackist a deployer that is not a current deployer.

error NotAlreadyADeployer(address deployer);

NotADeployer

triggered when public vault deploy function is called by an address that is not a deployer.

error NotADeployer();

CallFailed

triggered when init management low level failed.

error CallFailed();

VaultNotManaged

triggered when init management happened and still the vault is not under management by manager.

error VaultNotManaged();

SameManager

triggered when owner is setting a new manager, and the new manager address match with the old manager address.

error SameManager();

IArrakisMetaVaultPrivate

Git Source

Functions

deposit

function used to deposit tokens or expand position inside the inherent strategy.

function deposit(
    uint256 amount0_,
    uint256 amount1_
) external payable;

Parameters

NameTypeDescription
amount0_uint256amount of token0 need to increase the position by proportion_;
amount1_uint256amount of token1 need to increase the position by proportion_;

withdraw

function used to withdraw tokens or position contraction of the underpin strategy.

function withdraw(
    uint256 proportion_,
    address receiver_
) external returns (uint256 amount0, uint256 amount1);

Parameters

NameTypeDescription
proportion_uint256the proportion of position contraction.
receiver_addressthe address that will receive withdrawn tokens.

Returns

NameTypeDescription
amount0uint256amount of token0 returned.
amount1uint256amount of token1 returned.

whitelistDepositors

function used to whitelist depositors.

function whitelistDepositors(address[] calldata depositors_)
    external;

Parameters

NameTypeDescription
depositors_address[]list of address that will be granted to depositor role.

blacklistDepositors

function used to blacklist depositors.

function blacklistDepositors(address[] calldata depositors_)
    external;

Parameters

NameTypeDescription
depositors_address[]list of address who depositor role will be revoked.

depositors

function used to get the list of depositors.

function depositors() external view returns (address[] memory);

Returns

NameTypeDescription
<none>address[]depositors list of address granted to depositor role.

Events

LogDeposit

Event describing a deposit done by an user inside this vault.

event LogDeposit(uint256 amount0, uint256 amount1);

Parameters

NameTypeDescription
amount0uint256amount of token0 needed to increase the portfolio of "proportion" percent.
amount1uint256amount of token1 needed to increase the portfolio of "proportion" percent.

LogWithdraw

Event describing a withdrawal of participation by an user inside this vault.

event LogWithdraw(
    uint256 proportion, uint256 amount0, uint256 amount1
);

Parameters

NameTypeDescription
proportionuint256percentage of the current position that user want to withdraw.
amount0uint256amount of token0 withdrawn due to withdraw action.
amount1uint256amount of token1 withdrawn due to withdraw action.

LogWhitelistDepositors

Event describing the whitelist of fund depositor.

event LogWhitelistDepositors(address[] depositors);

Parameters

NameTypeDescription
depositorsaddress[]list of address that are granted to depositor role.

LogBlacklistDepositors

Event describing the blacklist of fund depositor.

event LogBlacklistDepositors(address[] depositors);

Parameters

NameTypeDescription
depositorsaddress[]list of address who depositor role is revoked.

Errors

MintZero

error MintZero();

BurnZero

error BurnZero();

BurnOverflow

error BurnOverflow();

DepositorAlreadyWhitelisted

error DepositorAlreadyWhitelisted();

NotAlreadyWhitelistedDepositor

error NotAlreadyWhitelistedDepositor();

OnlyDepositor

error OnlyDepositor();

IArrakisMetaVaultPublic

Git Source

Functions

mint

function used to mint share of the vault position

function mint(
    uint256 shares_,
    address receiver_
) external payable returns (uint256 amount0, uint256 amount1);

Parameters

NameTypeDescription
shares_uint256amount representing the part of the position owned by receiver.
receiver_addressaddress where share token will be sent.

Returns

NameTypeDescription
amount0uint256amount of token0 deposited.
amount1uint256amount of token1 deposited.

burn

function used to burn share of the vault position.

function burn(
    uint256 shares_,
    address receiver_
) external returns (uint256 amount0, uint256 amount1);

Parameters

NameTypeDescription
shares_uint256amount of share that will be burn.
receiver_addressaddress where underlying tokens will be sent.

Returns

NameTypeDescription
amount0uint256amount of token0 withdrawn.
amount1uint256amount of token1 withdrawn.

Events

LogMint

event emitted when a user mint some shares on a public vault.

event LogMint(
    uint256 shares, address receiver, uint256 amount0, uint256 amount1
);

Parameters

NameTypeDescription
sharesuint256amount of shares minted.
receiveraddressaddress that will receive the LP token (shares).
amount0uint256amount of token0 needed to mint shares.
amount1uint256amount of token1 needed to mint shares.

LogBurn

event emitted when a user burn some of his shares.

event LogBurn(
    uint256 shares, address receiver, uint256 amount0, uint256 amount1
);

Parameters

NameTypeDescription
sharesuint256amount of share burned by the user.
receiveraddressaddress that will receive amounts of tokens related to burning the shares.
amount0uint256amount of token0 that is collected from burning shares.
amount1uint256amount of token1 that is collected from burning shares.

Errors

MintZero

error MintZero();

BurnZero

error BurnZero();

IArrakisPrivateHook

Git Source

Functions

setFee

function setFee(PoolKey calldata poolKey_, uint24 fee_) external;

module

function module() external view returns (address);

vault

function vault() external view returns (address);

manager

function manager() external view returns (address);

fee

function fee() external view returns (uint24);

poolManager

function poolManager() external view returns (address);

Events

SetFee

event SetFee(uint24 fee);

Errors

AddressZero

error AddressZero();

OnlyModule

error OnlyModule();

NotImplemented

error NotImplemented();

OnlyVaultExecutor

error OnlyVaultExecutor();

IArrakisPublicVaultRouter

Git Source

Functions

pause

function used to pause the router.

only callable by owner

function pause() external;

unpause

function used to unpause the router.

only callable by owner

function unpause() external;

addLiquidity

addLiquidity adds liquidity to meta vault of interest (mints L tokens)

function addLiquidity(AddLiquidityData memory params_)
    external
    payable
    returns (uint256 amount0, uint256 amount1, uint256 sharesReceived);

Parameters

NameTypeDescription
params_AddLiquidityDataAddLiquidityData struct containing data for adding liquidity

Returns

NameTypeDescription
amount0uint256amount of token0 transferred from msg.sender to mint mintAmount
amount1uint256amount of token1 transferred from msg.sender to mint mintAmount
sharesReceiveduint256amount of public vault tokens transferred to receiver

swapAndAddLiquidity

swapAndAddLiquidity transfer tokens to and calls RouterSwapExecutor

function swapAndAddLiquidity(SwapAndAddData memory params_)
    external
    payable
    returns (
        uint256 amount0,
        uint256 amount1,
        uint256 sharesReceived,
        uint256 amount0Diff,
        uint256 amount1Diff
    );

Parameters

NameTypeDescription
params_SwapAndAddDataSwapAndAddData struct containing data for swap

Returns

NameTypeDescription
amount0uint256amount of token0 transferred from msg.sender to mint mintAmount
amount1uint256amount of token1 transferred from msg.sender to mint mintAmount
sharesReceiveduint256amount of public vault tokens transferred to receiver
amount0Diffuint256token0 balance difference post swap
amount1Diffuint256token1 balance difference post swap

removeLiquidity

removeLiquidity removes liquidity from vault and burns LP tokens

function removeLiquidity(RemoveLiquidityData memory params_)
    external
    returns (uint256 amount0, uint256 amount1);

Parameters

NameTypeDescription
params_RemoveLiquidityDataRemoveLiquidityData struct containing data for withdrawals

Returns

NameTypeDescription
amount0uint256actual amount of token0 transferred to receiver for burning burnAmount
amount1uint256actual amount of token1 transferred to receiver for burning burnAmount

addLiquidityPermit2

addLiquidityPermit2 adds liquidity to public vault of interest (mints LP tokens)

function addLiquidityPermit2(AddLiquidityPermit2Data memory params_)
    external
    payable
    returns (uint256 amount0, uint256 amount1, uint256 sharesReceived);

Parameters

NameTypeDescription
params_AddLiquidityPermit2DataAddLiquidityPermit2Data struct containing data for adding liquidity

Returns

NameTypeDescription
amount0uint256amount of token0 transferred from msg.sender to mint mintAmount
amount1uint256amount of token1 transferred from msg.sender to mint mintAmount
sharesReceiveduint256amount of public vault tokens transferred to receiver

swapAndAddLiquidityPermit2

swapAndAddLiquidityPermit2 transfer tokens to and calls RouterSwapExecutor

function swapAndAddLiquidityPermit2(
    SwapAndAddPermit2Data memory params_
)
    external
    payable
    returns (
        uint256 amount0,
        uint256 amount1,
        uint256 sharesReceived,
        uint256 amount0Diff,
        uint256 amount1Diff
    );

Parameters

NameTypeDescription
params_SwapAndAddPermit2DataSwapAndAddPermit2Data struct containing data for swap

Returns

NameTypeDescription
amount0uint256amount of token0 transferred from msg.sender to mint mintAmount
amount1uint256amount of token1 transferred from msg.sender to mint mintAmount
sharesReceiveduint256amount of public vault tokens transferred to receiver
amount0Diffuint256token0 balance difference post swap
amount1Diffuint256token1 balance difference post swap

removeLiquidityPermit2

removeLiquidityPermit2 removes liquidity from vault and burns LP tokens

function removeLiquidityPermit2(
    RemoveLiquidityPermit2Data memory params_
) external returns (uint256 amount0, uint256 amount1);

Parameters

NameTypeDescription
params_RemoveLiquidityPermit2DataRemoveLiquidityPermit2Data struct containing data for withdrawals

Returns

NameTypeDescription
amount0uint256actual amount of token0 transferred to receiver for burning burnAmount
amount1uint256actual amount of token1 transferred to receiver for burning burnAmount

wrapAndAddLiquidity

wrapAndAddLiquidity wrap eth and adds liquidity to meta vault of interest (mints L tokens)

function wrapAndAddLiquidity(AddLiquidityData memory params_)
    external
    payable
    returns (uint256 amount0, uint256 amount1, uint256 sharesReceived);

Parameters

NameTypeDescription
params_AddLiquidityDataAddLiquidityData struct containing data for adding liquidity

Returns

NameTypeDescription
amount0uint256amount of token0 transferred from msg.sender to mint mintAmount
amount1uint256amount of token1 transferred from msg.sender to mint mintAmount
sharesReceiveduint256amount of public vault tokens transferred to receiver

wrapAndSwapAndAddLiquidity

wrapAndSwapAndAddLiquidity wrap eth and transfer tokens to and calls RouterSwapExecutor

function wrapAndSwapAndAddLiquidity(SwapAndAddData memory params_)
    external
    payable
    returns (
        uint256 amount0,
        uint256 amount1,
        uint256 sharesReceived,
        uint256 amount0Diff,
        uint256 amount1Diff
    );

Parameters

NameTypeDescription
params_SwapAndAddDataSwapAndAddData struct containing data for swap

Returns

NameTypeDescription
amount0uint256amount of token0 transferred from msg.sender to mint mintAmount
amount1uint256amount of token1 transferred from msg.sender to mint mintAmount
sharesReceiveduint256amount of public vault tokens transferred to receiver
amount0Diffuint256token0 balance difference post swap
amount1Diffuint256token1 balance difference post swap

wrapAndAddLiquidityPermit2

wrapAndAddLiquidityPermit2 wrap eth and adds liquidity to public vault of interest (mints LP tokens)

function wrapAndAddLiquidityPermit2(
    AddLiquidityPermit2Data memory params_
)
    external
    payable
    returns (uint256 amount0, uint256 amount1, uint256 sharesReceived);

Parameters

NameTypeDescription
params_AddLiquidityPermit2DataAddLiquidityPermit2Data struct containing data for adding liquidity

Returns

NameTypeDescription
amount0uint256amount of token0 transferred from msg.sender to mint mintAmount
amount1uint256amount of token1 transferred from msg.sender to mint mintAmount
sharesReceiveduint256amount of public vault tokens transferred to receiver

wrapAndSwapAndAddLiquidityPermit2

wrapAndSwapAndAddLiquidityPermit2 wrap eth and transfer tokens to and calls RouterSwapExecutor

function wrapAndSwapAndAddLiquidityPermit2(
    SwapAndAddPermit2Data memory params_
)
    external
    payable
    returns (
        uint256 amount0,
        uint256 amount1,
        uint256 sharesReceived,
        uint256 amount0Diff,
        uint256 amount1Diff
    );

Parameters

NameTypeDescription
params_SwapAndAddPermit2DataSwapAndAddPermit2Data struct containing data for swap

Returns

NameTypeDescription
amount0uint256amount of token0 transferred from msg.sender to mint mintAmount
amount1uint256amount of token1 transferred from msg.sender to mint mintAmount
sharesReceiveduint256amount of public vault tokens transferred to receiver
amount0Diffuint256token0 balance difference post swap
amount1Diffuint256token1 balance difference post swap

getMintAmounts

getMintAmounts used to get the shares we can mint from some max amounts.

function getMintAmounts(
    address vault_,
    uint256 maxAmount0_,
    uint256 maxAmount1_
)
    external
    view
    returns (
        uint256 shareToMint,
        uint256 amount0ToDeposit,
        uint256 amount1ToDeposit
    );

Parameters

NameTypeDescription
vault_addressmeta vault address.
maxAmount0_uint256maximum amount of token0 user want to contribute.
maxAmount1_uint256maximum amount of token1 user want to contribute.

Returns

NameTypeDescription
shareToMintuint256maximum amount of share user can get for 'maxAmount0*' and 'maxAmount1*'.
amount0ToDeposituint256amount of token0 user should deposit into the vault for minting 'shareToMint'.
amount1ToDeposituint256amount of token1 user should deposit into the vault for minting 'shareToMint'.

Events

Swapped

event emitted when a swap happen before depositing.

event Swapped(
    bool zeroForOne,
    uint256 amount0Diff,
    uint256 amount1Diff,
    uint256 amountOutSwap
);

Parameters

NameTypeDescription
zeroForOneboolboolean indicating if we are swap token0 to token1 or the inverse.
amount0Diffuint256amount of token0 get or consumed by the swap.
amount1Diffuint256amount of token1 get or consumed by the swap.
amountOutSwapuint256minimum amount of tokens out wanted after swap.

Errors

AddressZero

error AddressZero();

NotEnoughNativeTokenSent

error NotEnoughNativeTokenSent();

NoNativeTokenAndValueNotZero

error NoNativeTokenAndValueNotZero();

OnlyPublicVault

error OnlyPublicVault();

EmptyMaxAmounts

error EmptyMaxAmounts();

NothingToMint

error NothingToMint();

NothingToBurn

error NothingToBurn();

BelowMinAmounts

error BelowMinAmounts();

SwapCallFailed

error SwapCallFailed();

ReceivedBelowMinimum

error ReceivedBelowMinimum();

LengthMismatch

error LengthMismatch();

NoNativeToken

error NoNativeToken();

MsgValueZero

error MsgValueZero();

NativeTokenNotSupported

error NativeTokenNotSupported();

MsgValueDTMaxAmount

error MsgValueDTMaxAmount();

NoWethToken

error NoWethToken();

Permit2WethNotAuthorized

error Permit2WethNotAuthorized();

IArrakisStandardManager

Git Source

Functions

initialize

function used to initialize standard manager proxy.

function initialize(
    address owner_,
    address defaultReceiver_,
    address factory_
) external;

Parameters

NameTypeDescription
owner_addressaddress of the owner of standard manager.
defaultReceiver_addressaddress of the receiver of tokens (by default).
factory_addressArrakisMetaVaultFactory contract address.

pause

function used to pause the manager.

only callable by guardian

function pause() external;

unpause

function used to unpause the manager.

only callable by guardian

function unpause() external;

setDefaultReceiver

function used to set the default receiver of tokens earned.

function setDefaultReceiver(address newDefaultReceiver_) external;

Parameters

NameTypeDescription
newDefaultReceiver_addressaddress of the new default receiver of tokens.

setReceiverByToken

function used to set receiver of a specific token.

function setReceiverByToken(
    address vault_,
    bool isSetReceiverToken0_,
    address receiver_
) external;

Parameters

NameTypeDescription
vault_addressaddress of the meta vault that contain the specific token.
isSetReceiverToken0_boolboolean if true means that receiver is for token0 if not it's for token1.
receiver_addressaddress of the receiver of this specific token.

decreaseManagerFeePIPS

function used to decrease the fees taken by manager for a specific managed vault.

function decreaseManagerFeePIPS(
    address vault_,
    uint24 newFeePIPS_
) external;

Parameters

NameTypeDescription
vault_addressaddress of the vault.
newFeePIPS_uint24fees in pips to set on the specific vault.

finalizeIncreaseManagerFeePIPS

function used to finalize a time lock fees increase on a vault.

function finalizeIncreaseManagerFeePIPS(address vault_) external;

Parameters

NameTypeDescription
vault_addressaddress of the vault where the fees increase will be applied.

submitIncreaseManagerFeePIPS

function used to submit a fees increase in a managed vault.

function submitIncreaseManagerFeePIPS(
    address vault_,
    uint24 newFeePIPS_
) external;

Parameters

NameTypeDescription
vault_addressaddress of the vault where fees will be increase after timeLock.
newFeePIPS_uint24fees in pips to set on the specific managed vault.

withdrawManagerBalance

function used by manager to get his balance of fees earned on a vault.

function withdrawManagerBalance(address vault_)
    external
    returns (uint256 amount0, uint256 amount1);

Parameters

NameTypeDescription
vault_addressfrom which fees will be collected.

Returns

NameTypeDescription
amount0uint256amount of token0 sent to receiver_
amount1uint256amount of token1 sent to receiver_

rebalance

function used to manage vault's strategy.

function rebalance(
    address vault_,
    bytes[] calldata payloads_
) external;

Parameters

NameTypeDescription
vault_addressaddress of the vault that need a rebalance.
payloads_bytes[]call data to do specific action of vault side.

setModule

function used to set a new module (strategy) for the vault.

function setModule(
    address vault_,
    address module_,
    bytes[] calldata payloads_
) external;

Parameters

NameTypeDescription
vault_addressaddress of the vault the manager want to change module.
module_addressaddress of the new module.
payloads_bytes[]call data to initialize position on the new module.

initManagement

function used to init management of a meta vault.

function initManagement(SetupParams calldata params_) external;

Parameters

NameTypeDescription
params_SetupParamsstruct containing all the data for initialize the vault.

updateVaultInfo

function used to update meta vault management informations.

function updateVaultInfo(SetupParams calldata params_) external;

Parameters

NameTypeDescription
params_SetupParamsstruct containing all the data for updating the vault.

announceStrategy

function used to announce the strategy that the vault will follow.

function announceStrategy(
    address vault_,
    string memory strategy_
) external;

Parameters

NameTypeDescription
vault_addressaddress of arrakis meta vault that will follow the strategy.
strategy_stringstring containing the strategy name that will be used.

initializedVaults

function used to get a list of managed vaults.

function initializedVaults(
    uint256 startIndex_,
    uint256 endIndex_
) external view returns (address[] memory);

Parameters

NameTypeDescription
startIndex_uint256starting index from which the caller want to read the array of managed vaults.
endIndex_uint256ending index until which the caller want to read the array of managed vaults.

numInitializedVaults

function used to get the number of vault under management.

function numInitializedVaults()
    external
    view
    returns (uint256 numberOfVaults);

guardian

address of the pauser of manager.

function guardian() external view returns (address);

Returns

NameTypeDescription
<none>addresspauser address that can pause/unpause manager.

factory

address of the vault factory.

function factory() external view returns (address);

Returns

NameTypeDescription
<none>addressfactory address that can deploy meta vault.

defaultFeePIPS

function used to get the default fee applied on manager vault.

function defaultFeePIPS() external view returns (uint256);

Returns

NameTypeDescription
<none>uint256defaultFeePIPS amount of default fees.

nativeToken

function used to get the native token/coin of the chain.

function nativeToken() external view returns (address);

Returns

NameTypeDescription
<none>addressnativeToken address of the native token/coin of the chain.

nativeTokenDecimals

function used to get the native token/coin decimals precision.

function nativeTokenDecimals() external view returns (uint8);

Returns

NameTypeDescription
<none>uint8nativeTokenDecimals decimals precision of the native coin.

defaultReceiver

function used to get the default receiver of tokens earned in managed vault.

function defaultReceiver() external view returns (address);

Returns

NameTypeDescription
<none>addressdefaultReceiver address of the default receiver.

receiversByToken

function used to get the receiver of a specific token.

function receiversByToken(address token_)
    external
    view
    returns (address receiver);

Parameters

NameTypeDescription
token_addressaddress of the ERC20 token that we want the receiver of

Returns

NameTypeDescription
receiveraddressaddress of the receiver of 'token_'

vaultInfo

function used to get vault management config.

function vaultInfo(address vault_)
    external
    view
    returns (
        uint256 lastRebalance,
        uint256 cooldownPeriod,
        IOracleWrapper oracle,
        uint24 maxDeviation,
        address executor,
        address stratAnnouncer,
        uint24 maxSlippagePIPS,
        uint24 managerFeePIPS
    );

Parameters

NameTypeDescription
vault_addressaddress of the metaVault.

Returns

NameTypeDescription
lastRebalanceuint256timestamp when the last rebalance happen.
cooldownPerioduint256minimum duration between two rebalance.
oracleIOracleWrapperoracle used to check against price manipulation.
maxDeviationuint24maximum deviation from oracle price allowed.
executoraddressaddress that can trigger a rebalance.
stratAnnounceraddressaddress that will announce a strategy to follow.
maxSlippagePIPSuint24maximum slippage authorized.
managerFeePIPSuint24fees that manager take.

Events

LogWhitelistNftRebalancers

event LogWhitelistNftRebalancers(address[] nftRebalancers);

LogBlacklistNftRebalancers

event LogBlacklistNftRebalancers(address[] nftRebalancers);

LogWhitelistStrategies

event LogWhitelistStrategies(string[] strategies);

LogSetManagementParams

event LogSetManagementParams(
    address indexed vault,
    address oracle,
    uint24 maxSlippagePIPS,
    uint24 maxDeviation,
    uint256 cooldownPeriod,
    address executor,
    address stratAnnouncer
);

LogSetVaultData

event LogSetVaultData(address indexed vault, bytes datas);

LogSetVaultStrat

event LogSetVaultStrat(address indexed vault, string strat);

LogFundBalance

event LogFundBalance(address indexed vault, uint256 balance);

LogWithdrawVaultBalance

event LogWithdrawVaultBalance(
    address indexed vault,
    uint256 amount,
    address receiver,
    uint256 newBalance
);

LogSetDefaultReceiver

event LogSetDefaultReceiver(address oldReceiver, address newReceiver);

LogSetReceiverByToken

event LogSetReceiverByToken(address indexed token, address receiver);

LogWithdrawManagerBalance

event LogWithdrawManagerBalance(
    address indexed receiver0,
    address indexed receiver1,
    uint256 amount0,
    uint256 amount1
);

LogChangeManagerFee

event LogChangeManagerFee(address vault, uint256 newFeePIPS);

LogIncreaseManagerFeeSubmission

event LogIncreaseManagerFeeSubmission(
    address vault, uint256 newFeePIPS
);

LogRebalance

event LogRebalance(address indexed vault, bytes[] payloads);

LogSetModule

event LogSetModule(
    address indexed vault, address module, bytes[] payloads
);

LogSetFactory

event LogSetFactory(address vaultFactory);

LogStrategyAnnouncement

event LogStrategyAnnouncement(address vault, string strategy);

Errors

EmptyNftRebalancersArray

error EmptyNftRebalancersArray();

NotWhitelistedNftRebalancer

error NotWhitelistedNftRebalancer(address nftRebalancer);

AlreadyWhitelistedNftRebalancer

error AlreadyWhitelistedNftRebalancer(address nftRebalancer);

OnlyNftRebalancers

error OnlyNftRebalancers(address caller);

EmptyString

error EmptyString();

StratAlreadyWhitelisted

error StratAlreadyWhitelisted();

StratNotWhitelisted

error StratNotWhitelisted();

OnlyPrivateVault

error OnlyPrivateVault();

OnlyERC20Vault

error OnlyERC20Vault();

OnlyVaultOwner

error OnlyVaultOwner(address caller, address vaultOwner);

AlreadyInManagement

error AlreadyInManagement();

NotTheManager

error NotTheManager(address caller, address manager);

SlippageTooHigh

error SlippageTooHigh();

MaxDeviationTooHigh

error MaxDeviationTooHigh();

CooldownPeriodSetToZero

error CooldownPeriodSetToZero();

ValueDtBalanceInputed

error ValueDtBalanceInputed(uint256 value, uint256 balance);

OnlyOwner

error OnlyOwner();

OnlyManagedVault

error OnlyManagedVault();

DataIsUpdated

error DataIsUpdated();

SameStrat

error SameStrat();

NotWhitelistedStrat

error NotWhitelistedStrat();

NotNativeCoinSent

error NotNativeCoinSent();

NoEnoughBalance

error NoEnoughBalance();

OverMaxSlippage

error OverMaxSlippage();

NativeTokenDecimalsZero

error NativeTokenDecimalsZero();

NotFeeDecrease

error NotFeeDecrease();

AlreadyPendingIncrease

error AlreadyPendingIncrease();

NotFeeIncrease

error NotFeeIncrease();

TimeNotPassed

error TimeNotPassed();

NoPendingIncrease

error NoPendingIncrease();

NotExecutor

error NotExecutor();

NotStratAnnouncer

error NotStratAnnouncer();

AddressZero

error AddressZero();

NotWhitelistedVault

error NotWhitelistedVault(address vault);

AlreadyWhitelistedVault

error AlreadyWhitelistedVault(address vault);

EmptyVaultsArray

error EmptyVaultsArray();

CallFailed

error CallFailed(bytes payload);

StartIndexLtEndIndex

error StartIndexLtEndIndex(uint256 startIndex, uint256 endIndex);

EndIndexGtNbOfVaults

error EndIndexGtNbOfVaults(uint256 endIndex, uint256 numberOfVaults);

OnlyGuardian

error OnlyGuardian(address caller, address guardian);

OnlyFactory

error OnlyFactory(address caller, address factory);

VaultNotDeployed

error VaultNotDeployed();

SetManagerFeeCallNotAllowed

error SetManagerFeeCallNotAllowed();

OnlyStratAnnouncer

error OnlyStratAnnouncer();

PublicVaultTotalSupplyChanged

error PublicVaultTotalSupplyChanged();

IBunkerModule

Git Source

Functions

initialize

initialize function to delegate call onced the beacon proxy is deployed, for initializing the bunker module.

function initialize(address metaVault_) external;

Parameters

NameTypeDescription
metaVault_addressaddress of the meta vault

Errors

NotImplemented

error NotImplemented();

AmountsZeros

error AmountsZeros();

ICreationCode

Git Source

Functions

getCreationCode

function getCreationCode() external pure returns (bytes memory);

IGuardian

Git Source

Functions

pauser

function to get the address of the pauser of arrakis protocol.

function pauser() external view returns (address);

Returns

NameTypeDescription
<none>addresspauser address that can pause the arrakis protocol.

setPauser

function to set the pauser of Arrakis protocol.

function setPauser(address newPauser_) external;

Events

LogSetPauser

event emitted when the pauser is set by the owner of the Guardian.

event LogSetPauser(address oldPauser, address newPauser);

Parameters

NameTypeDescription
oldPauseraddressaddress of the previous pauser.
newPauseraddressaddress of the current pauser.

Errors

AddressZero

error AddressZero();

SamePauser

error SamePauser();

IHOTExecutor

Git Source

Functions

setW3f

function setW3f(address newW3f_) external;

rebalance

function rebalance(
    address vault_,
    bytes[] calldata payloads_,
    uint256 expectedReservesAmount_,
    bool zeroToOne_
) external;

manager

function manager() external view returns (address);

w3f

function w3f() external view returns (address);

Events

LogSetW3f

event LogSetW3f(address newW3f);

Errors

AddressZero

error AddressZero();

SameW3f

error SameW3f();

UnexpectedReservesAmount0

error UnexpectedReservesAmount0();

UnexpectedReservesAmount1

error UnexpectedReservesAmount1();

OnlyW3F

error OnlyW3F();

IManager

Git Source

Functions

getInitManagementSelector

function used to know the selector of initManagement functions.

function getInitManagementSelector()
    external
    pure
    returns (bytes4 selector);

isManaged

function used to know if a vault is under management by this manager.

function isManaged(address vault_)
    external
    view
    returns (bool isManaged);

Parameters

NameTypeDescription
vault_addressaddress of the meta vault the caller want to check.

Returns

NameTypeDescription
isManagedboolboolean which is true if the vault is under management, false otherwise.

IModulePrivateRegistry

Git Source

Events

LogCreatePrivateModule

Log creation of a private module.

event LogCreatePrivateModule(
    address beacon,
    bytes payload,
    address vault,
    address creator,
    address module
);

Parameters

NameTypeDescription
beaconaddresswhich beacon from who we get the implementation.
payloadbytespayload sent to the module constructor.
vaultaddressaddress of the Arrakis Meta Vault that will own this module
creatoraddressaddress that create the module.
moduleaddressaddress of the newly created module.

Errors

NotPrivateVault

error NotPrivateVault();

IModulePublicRegistry

Git Source

Events

LogCreatePublicModule

Log creation of a public module.

event LogCreatePublicModule(
    address beacon,
    bytes payload,
    address vault,
    address creator,
    address module
);

Parameters

NameTypeDescription
beaconaddresswhich beacon from who we get the implementation.
payloadbytespayload sent to the module constructor.
vaultaddressaddress of the Arrakis Meta Vault that will own this module
creatoraddressaddress that create the module.
moduleaddressaddress of the newly created module.

Errors

NotPublicVault

error NotPublicVault();

IModuleRegistry

Git Source

Author: Arrakis Team.

interface of module registry that contains all whitelisted modules.

Functions

beacons

function to get the whitelisted list of IBeacon that have module as implementation.

function beacons() external view returns (address[] memory beacons);

Returns

NameTypeDescription
beaconsaddress[]list of upgradeable beacon.

beaconsContains

function to know if the beacons enumerableSet contain beacon_

function beaconsContains(address beacon_)
    external
    view
    returns (bool isContained);

Parameters

NameTypeDescription
beacon_addressbeacon address to check

guardian

function used to get the guardian address of arrakis protocol.

function guardian() external view returns (address);

Returns

NameTypeDescription
<none>addressguardian address of the pauser.

admin

function used to get the admin address that can upgrade beacon implementation.

admin address should be a timelock contract.

function admin() external view returns (address);

Returns

NameTypeDescription
<none>addressadmin address that can upgrade beacon implementation.

initialize

function used to initialize module registry.

function initialize(address factory_) external;

Parameters

NameTypeDescription
factory_addressaddress of ArrakisMetaVaultFactory, who is the only one who can call the init management function.

whitelistBeacons

function used to whitelist IBeacon that contain implementation of valid module.

function whitelistBeacons(address[] calldata beacons_) external;

Parameters

NameTypeDescription
beacons_address[]list of beacon to whitelist.

blacklistBeacons

function used to blacklist IBeacon that contain implementation of unvalid (from now) module.

function blacklistBeacons(address[] calldata beacons_) external;

Parameters

NameTypeDescription
beacons_address[]list of beacon to blacklist.

createModule

function used to create module instance that can be whitelisted as module inside a vault.

function createModule(
    address vault_,
    address beacon_,
    bytes calldata payload_
) external returns (address module);

Parameters

NameTypeDescription
vault_address
beacon_addresswhich whitelisted beacon's implementation we want to create an instance of.
payload_bytespayload to create the module.

Events

LogWhitelistBeacons

Log whitelist action of beacons.

event LogWhitelistBeacons(address[] beacons);

Parameters

NameTypeDescription
beaconsaddress[]list of beacons whitelisted.

LogBlacklistBeacons

Log blacklist action of beacons.

event LogBlacklistBeacons(address[] beacons);

Parameters

NameTypeDescription
beaconsaddress[]list of beacons blacklisted.

Errors

AddressZero

error AddressZero();

AlreadyWhitelistedBeacon

error AlreadyWhitelistedBeacon(address beacon);

NotAlreadyWhitelistedBeacon

error NotAlreadyWhitelistedBeacon(address beacon);

NotWhitelistedBeacon

error NotWhitelistedBeacon();

NotBeacon

error NotBeacon();

ModuleNotLinkedToMetaVault

error ModuleNotLinkedToMetaVault();

NotSameGuardian

error NotSameGuardian();

NotSameAdmin

error NotSameAdmin();

IOracleWrapper

Git Source

Functions

getPrice0

function used to get price0.

function getPrice0() external view returns (uint256 price0);

Returns

NameTypeDescription
price0uint256price of token0/token1.

getPrice1

function used to get price1.

function getPrice1() external view returns (uint256 price1);

Returns

NameTypeDescription
price1uint256price of token1/token0.

Errors

AddressZero

error AddressZero();

DecimalsToken0Zero

error DecimalsToken0Zero();

DecimalsToken1Zero

error DecimalsToken1Zero();

IOwnable

Git Source

Functions

owner

function used to get the owner of this contract.

function owner() external view returns (address);

IPausable

Git Source

Functions

pause

function pause() external;

unpause

function unpause() external;

IPauser

Git Source

Functions

pause

function pause(address target_) external;

whitelistPausers

function whitelistPausers(address[] calldata pausers_) external;

blacklistPausers

function blacklistPausers(address[] calldata pausers_) external;

isPauser

function isPauser(address account) external view returns (bool);

Events

LogPauserWhitelisted

event LogPauserWhitelisted(address[] indexed pauser);

LogPauserBlacklisted

event LogPauserBlacklisted(address[] indexed pauser);

LogPause

event LogPause(address indexed target);

Errors

AddressZero

error AddressZero();

AlreadyPauser

error AlreadyPauser();

NotPauser

error NotPauser();

OnlyPauser

error OnlyPauser();

IPermit2

Git Source

Functions

permitTransferFrom

function permitTransferFrom(
    PermitBatchTransferFrom memory permit,
    SignatureTransferDetails[] calldata transferDetails,
    address owner,
    bytes calldata signature
) external;

permitTransferFrom

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

IPrivateVaultNFT

Git Source

Functions

mint

function used to mint nft (representing a vault) and send it.

function mint(address to_, uint256 tokenId_) external;

Parameters

NameTypeDescription
to_addressaddress where to send the NFT.
tokenId_uint256id of the NFT to mint.

getMetaDatas

for doing meta data calls of tokens.

function getMetaDatas(
    address token0_,
    address token1_
)
    external
    view
    returns (
        uint8 decimals0,
        uint8 decimals1,
        string memory symbol0,
        string memory symbol1
    );

IRenderController

Git Source

Functions

setRenderer

function used to set the renderer contract adress

only the owner can do it.

function setRenderer(address renderer_) external;

Parameters

NameTypeDescription
renderer_addressaddress of the contract that will render the tokenUri for the svg of the nft.

isNFTSVG

for knowning if renderer is a NFTSVG contract.

function isNFTSVG(address renderer_) external view returns (bool);

renderer

NFTSVG contract that will generate the tokenURI.

function renderer() external view returns (address);

Events

LogSetRenderer

event LogSetRenderer(address newRenderer);

Errors

InvalidRenderer

error InvalidRenderer();

AddressZero

error AddressZero();

IResolver

Git Source

Functions

getMintAmounts

getMintAmounts used to get the shares we can mint from some max amounts.

function getMintAmounts(
    address vault_,
    uint256 maxAmount0_,
    uint256 maxAmount1_
)
    external
    view
    returns (
        uint256 shareToMint,
        uint256 amount0ToDeposit,
        uint256 amount1ToDeposit
    );

Parameters

NameTypeDescription
vault_addressmeta vault address.
maxAmount0_uint256maximum amount of token0 user want to contribute.
maxAmount1_uint256maximum amount of token1 user want to contribute.

Returns

NameTypeDescription
shareToMintuint256maximum amount of share user can get for 'maxAmount0*' and 'maxAmount1*'.
amount0ToDeposituint256amount of token0 user should deposit into the vault for minting 'shareToMint'.
amount1ToDeposituint256amount of token1 user should deposit into the vault for minting 'shareToMint'.

IRouterSwapExecutor

Git Source

Functions

swap

function used to swap tokens.

function swap(SwapAndAddData memory _swapData)
    external
    payable
    returns (uint256 amount0Diff, uint256 amount1Diff);

Parameters

NameTypeDescription
_swapDataSwapAndAddDatastruct containing all the informations for swapping.

Returns

NameTypeDescription
amount0Diffuint256the difference in token0 amount before and after the swap.
amount1Diffuint256the difference in token1 amount before and after the swap.

Errors

OnlyRouter

error OnlyRouter(address caller, address router);

AddressZero

error AddressZero();

SwapCallFailed

error SwapCallFailed();

ReceivedBelowMinimum

error ReceivedBelowMinimum();

IRouterSwapResolver

Git Source

Functions

calculateSwapAmount

function calculateSwapAmount(
    IArrakisMetaVault vault,
    uint256 amount0In,
    uint256 amount1In,
    uint256 price18Decimals
) external view returns (bool zeroForOne, uint256 swapAmount);

Errors

AddressZero

error AddressZero();

ISovereignPool

Git Source

Functions

setPoolManagerFeeBips

function setPoolManagerFeeBips(uint256 poolManagerFeeBips_)
    external;

setPoolManager

function setPoolManager(address manager_) external;

claimPoolManagerFees

function claimPoolManagerFees(
    uint256 feeProtocol0Bips_,
    uint256 feeProtocol1Bips_
)
    external
    returns (
        uint256 feePoolManager0Received,
        uint256 feePoolManager1Received
    );

getPoolManagerFees

function getPoolManagerFees()
    external
    view
    returns (uint256 poolManagerFee0, uint256 poolManagerFee1);

poolManagerFeeBips

function poolManagerFeeBips() external view returns (uint256);

getReserves

function getReserves() external view returns (uint256, uint256);

ITimeLock

Git Source

Errors

NotImplemented

error NotImplemented();

IValantisHOTModule

Git Source

Functions

initialize

initialize function to delegate call onced the beacon proxy is deployed, for initializing the valantis module. who can call deposit and withdraw functions.

function initialize(
    address pool_,
    uint256 init0_,
    uint256 init1_,
    uint24 maxSlippage_,
    address metaVault_
) external;

Parameters

NameTypeDescription
pool_addressaddress of the valantis sovereign pool.
init0_uint256initial amount of token0 to provide to valantis module.
init1_uint256initial amount of token1 to provide to valantis module.
maxSlippage_uint24allowed to manager for rebalancing the inventory using swap.
metaVault_addressaddress of the meta vault

setALMAndManagerFees

set HOT and initialize manager fees function.

function setALMAndManagerFees(
    address alm_,
    address oracle_
) external;

Parameters

NameTypeDescription
alm_addressaddress of the valantis HOT ALM.
oracle_addressaddress of the oracle used by the valantis HOT module.

setPriceBounds

fucntion used to set range on valantis AMM

function setPriceBounds(
    uint160 _sqrtPriceLowX96,
    uint160 _sqrtPriceHighX96,
    uint160 _expectedSqrtSpotPriceLowerX96,
    uint160 _expectedSqrtSpotPriceUpperX96
) external;

Parameters

NameTypeDescription
_sqrtPriceLowX96uint160lower bound of the range in sqrt price.
_sqrtPriceHighX96uint160upper bound of the range in sqrt price.
_expectedSqrtSpotPriceLowerX96uint160expected upper limit of current spot price (to prevent sandwich attack and manipulation).
_expectedSqrtSpotPriceUpperX96uint160expected lower limit of current spot price (to prevent sandwich attack and manipulation).

swap

function to swap token0->token1 or token1->token0 and then change inventory.

function swap(
    bool zeroForOne_,
    uint256 expectedMinReturn_,
    uint256 amountIn_,
    address router_,
    uint160 expectedSqrtSpotPriceUpperX96_,
    uint160 expectedSqrtSpotPriceLowerX96_,
    bytes calldata payload_
) external;

Parameters

NameTypeDescription
zeroForOne_boolboolean if true token0->token1, if false token1->token0.
expectedMinReturn_uint256minimum amount of tokenOut expected.
amountIn_uint256amount of tokenIn used during swap.
router_addressaddress of smart contract that will execute swap.
expectedSqrtSpotPriceUpperX96_uint160upper bound of current price.
expectedSqrtSpotPriceLowerX96_uint160lower bound of current price.
payload_bytesdata payload used for swapping.

pool

function used to get the valantis hot pool.

function pool() external view returns (ISovereignPool);

alm

function used to get the valantis hot alm/ liquidity module.

function alm() external view returns (IHOT);

maxSlippage

function used to get the max slippage that can occur during swap rebalance.

function maxSlippage() external view returns (uint24);

oracle

function used to get the oracle that will be used to proctect rebalances.

function oracle() external view returns (IOracleWrapper);

Events

LogSetALM

event LogSetALM(address alm);

LogInitializePosition

event LogInitializePosition(uint256 amount0, uint256 amount1);

LogSwap

event LogSwap(
    uint256 oldBalance0,
    uint256 oldBalance1,
    uint256 newBalance0,
    uint256 newBalance1
);

Errors

NoNativeToken

error NoNativeToken();

OnlyPool

error OnlyPool(address caller, address pool);

AmountsZeros

error AmountsZeros();

NotImplemented

error NotImplemented();

ExpectedMinReturnTooLow

error ExpectedMinReturnTooLow();

MaxSlippageGtTenPercent

error MaxSlippageGtTenPercent();

NotDepositedAllToken0

error NotDepositedAllToken0();

NotDepositedAllToken1

error NotDepositedAllToken1();

OnlyMetaVaultOwner

error OnlyMetaVaultOwner();

ALMAlreadySet

error ALMAlreadySet();

SlippageTooHigh

error SlippageTooHigh();

NotEnoughToken0

error NotEnoughToken0();

NotEnoughToken1

error NotEnoughToken1();

SwapCallFailed

error SwapCallFailed();

OverMaxDeviation

error OverMaxDeviation();

WrongRouter

error WrongRouter();

IWETH9

Contents

Contents

ValantisResolver

Git Source

Inherits: IResolver

Functions

getMintAmounts

getMintAmounts used to get the shares we can mint from some max amounts.

function getMintAmounts(
    address vault_,
    uint256 maxAmount0_,
    uint256 maxAmount1_
)
    external
    view
    returns (
        uint256 shareToMint,
        uint256 amount0ToDeposit,
        uint256 amount1ToDeposit
    );

Parameters

NameTypeDescription
vault_addressmeta vault address.
maxAmount0_uint256maximum amount of token0 user want to contribute.
maxAmount1_uint256maximum amount of token1 user want to contribute.

Returns

NameTypeDescription
shareToMintuint256maximum amount of share user can get for 'maxAmount0*' and 'maxAmount1*'.
amount0ToDeposituint256amount of token0 user should deposit into the vault for minting 'shareToMint'.
amount1ToDeposituint256amount of token1 user should deposit into the vault for minting 'shareToMint'.

BunkerModule

Git Source

Inherits: IArrakisLPModule, IArrakisLPModuleID, IBunkerModule, PausableUpgradeable, ReentrancyGuardUpgradeable

State Variables

id

bytes32 public constant id =
    0xce98d8396fff0b5125f78c5c5878c5c82596417dec23d9d52e0ed2377d14b9b8;

metaVault

IArrakisMetaVault public metaVault;

token0

IERC20Metadata public token0;

token1

IERC20Metadata public token1;

_guardian

address internal immutable _guardian;

Functions

onlyMetaVault

modifier onlyMetaVault();

onlyGuardian

modifier onlyGuardian();

constructor

constructor(address guardian_);

initialize

initialize function to delegate call onced the beacon proxy is deployed, for initializing the bunker module.

function initialize(address metaVault_) external initializer;

Parameters

NameTypeDescription
metaVault_addressaddress of the meta vault.

pause

function used to pause the module.

only callable by guardian

function pause() external onlyGuardian;

unpause

function used to unpause the module.

only callable by guardian

function unpause() external onlyGuardian;

initializePosition

function initializePosition(bytes calldata) external;

withdraw

function used by metaVault to withdraw tokens from the strategy.

function withdraw(
    address receiver_,
    uint256 proportion_
)
    public
    virtual
    onlyMetaVault
    nonReentrant
    returns (uint256 amount0, uint256 amount1);

Parameters

NameTypeDescription
receiver_addressaddress that will receive tokens.
proportion_uint256the proportion of the total position that need to be withdrawn.

Returns

NameTypeDescription
amount0uint256amount of token0 withdrawn.
amount1uint256amount of token1 withdrawn.

withdrawManagerBalance

function used by metaVault or manager to get manager fees.

function withdrawManagerBalance()
    external
    returns (uint256 amount0, uint256 amount1);

Returns

NameTypeDescription
amount0uint256amount of token0 sent to manager.
amount1uint256amount of token1 sent to manager.

setManagerFeePIPS

function used to set manager fees.

function setManagerFeePIPS(uint256) external;

managerBalance0

function used to get manager token0 balance.

amount of fees in token0 that manager have not taken yet.

function managerBalance0() external view returns (uint256 fees0);

Returns

NameTypeDescription
fees0uint256amount of token0 that manager earned.

managerBalance1

function used to get manager token1 balance.

amount of fees in token1 that manager have not taken yet.

function managerBalance1() external view returns (uint256 fees1);

Returns

NameTypeDescription
fees1uint256amount of token1 that manager earned.

validateRebalance

function used to validate if module state is not manipulated before rebalance.

function validateRebalance(IOracleWrapper, uint24) external view;

totalUnderlyingAtPrice

function used to get the amounts of token0 and token1 sitting on the position for a specific price.

function totalUnderlyingAtPrice(uint160)
    external
    view
    returns (uint256 amount0, uint256 amount1);

Returns

NameTypeDescription
amount0uint256the amount of token0 sitting on the position for priceX96.
amount1uint256the amount of token1 sitting on the position for priceX96.

totalUnderlying

function used to get the amount of token0 and token1 sitting on the position.

function totalUnderlying()
    external
    view
    returns (uint256 amount0, uint256 amount1);

Returns

NameTypeDescription
amount0uint256the amount of token0 sitting on the position.
amount1uint256the amount of token1 sitting on the position.

getInits

function used to get the initial amounts needed to open a position.

function getInits()
    external
    view
    returns (uint256 init0, uint256 init1);

Returns

NameTypeDescription
init0uint256the amount of token0 needed to open a position.
init1uint256the amount of token1 needed to open a position.

managerFeePIPS

function used to get manager fees.

function managerFeePIPS() external view returns (uint256);

Returns

NameTypeDescription
<none>uint256managerFeePIPS amount of token1 that manager earned.

guardian

function used to get the address that can pause the module.

function guardian() external view returns (address);

Returns

NameTypeDescription
<none>addressguardian address of the pauser.

HOTExecutor

Git Source

Inherits: IHOTExecutor, Ownable

State Variables

manager

address public immutable manager;

w3f

address public w3f;

Functions

constructor

constructor(address manager_, address w3f_, address owner_);

setW3f

function setW3f(address newW3f_) external onlyOwner;

rebalance

function rebalance(
    address vault_,
    bytes[] calldata payloads_,
    uint256 expectedReservesAmount_,
    bool zeroToOne_
) external;

HOTOracleWrapper

Git Source

Inherits: IOracleWrapper

State Variables

oracle

IHOTOracle public immutable oracle;

decimals0

uint8 public immutable decimals0;

decimals1

uint8 public immutable decimals1;

Functions

constructor

constructor(address oracle_, uint8 decimals0_, uint8 decimals1_);

getPrice0

function getPrice0() public view returns (uint256 price0);

getPrice1

function getPrice1() public view returns (uint256 price1);

ValantisModulePrivate

Git Source

Inherits: ValantisModule, IArrakisLPModulePrivate

Functions

constructor

constructor(address guardian_) ValantisModule(guardian_);

fund

deposit function for private vault.

function fund(
    address depositor_,
    uint256 amount0_,
    uint256 amount1_
) external payable onlyMetaVault whenNotPaused nonReentrant;

Parameters

NameTypeDescription
depositor_addressaddress that will provide the tokens.
amount0_uint256amount of token0 that depositor want to send to module.
amount1_uint256amount of token1 that depositor want to send to module.

ValantisModulePublic

Git Source

Inherits: ValantisModule, IArrakisLPModulePublic

State Variables

notFirstDeposit

bool public notFirstDeposit;

Functions

constructor

constructor(address guardian_) ValantisModule(guardian_);

deposit

deposit function for public vault.

function deposit(
    address depositor_,
    uint256 proportion_
)
    external
    payable
    onlyMetaVault
    whenNotPaused
    nonReentrant
    returns (uint256 amount0, uint256 amount1);

Parameters

NameTypeDescription
depositor_addressaddress that will provide the tokens.
proportion_uint256percentage of portfolio position vault want to expand.

Returns

NameTypeDescription
amount0uint256amount of token0 needed to expand the portfolio by "proportion" percent.
amount1uint256amount of token1 needed to expand the portfolio by "proportion" percent.

withdraw

function used by metaVault to withdraw tokens from the strategy.

function withdraw(
    address receiver_,
    uint256 proportion_
) public override returns (uint256 amount0, uint256 amount1);

Parameters

NameTypeDescription
receiver_addressaddress that will receive tokens.
proportion_uint256number of share needed to be withdrawn.

Returns

NameTypeDescription
amount0uint256amount of token0 withdrawn.
amount1uint256amount of token1 withdrawn.

initializePosition

function initializePosition(bytes calldata data_)
    external
    override
    onlyMetaVault;

Contents

VaultInfo

Git Source

struct VaultInfo {
    uint256 lastRebalance;
    uint256 cooldownPeriod;
    IOracleWrapper oracle;
    uint24 maxDeviation;
    address executor;
    address stratAnnouncer;
    uint24 maxSlippagePIPS;
    uint24 managerFeePIPS;
}

SetupParams

Git Source

struct SetupParams {
    address vault;
    IOracleWrapper oracle;
    uint24 maxDeviation;
    uint256 cooldownPeriod;
    address executor;
    address stratAnnouncer;
    uint24 maxSlippagePIPS;
}

FeeIncrease

Git Source

struct FeeIncrease {
    uint256 submitTimestamp;
    uint24 newFeePIPS;
}

TokenPermissions

Git Source

struct TokenPermissions {
    address token;
    uint256 amount;
}

PermitTransferFrom

Git Source

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

SignatureTransferDetails

Git Source

struct SignatureTransferDetails {
    address to;
    uint256 requestedAmount;
}

PermitBatchTransferFrom

Git Source

struct PermitBatchTransferFrom {
    TokenPermissions[] permitted;
    uint256 nonce;
    uint256 deadline;
}

AddLiquidityData

Git Source

struct AddLiquidityData {
    uint256 amount0Max;
    uint256 amount1Max;
    uint256 amount0Min;
    uint256 amount1Min;
    uint256 amountSharesMin;
    address vault;
    address receiver;
}

RemoveLiquidityData

Git Source

struct RemoveLiquidityData {
    uint256 burnAmount;
    uint256 amount0Min;
    uint256 amount1Min;
    address vault;
    address payable receiver;
}

SwapData

Git Source

struct SwapData {
    bytes swapPayload;
    uint256 amountInSwap;
    uint256 amountOutSwap;
    address swapRouter;
    bool zeroForOne;
}

SwapAndAddData

Git Source

struct SwapAndAddData {
    SwapData swapData;
    AddLiquidityData addData;
}

AddLiquidityPermit2Data

Git Source

struct AddLiquidityPermit2Data {
    AddLiquidityData addData;
    PermitBatchTransferFrom permit;
    bytes signature;
}

RemoveLiquidityPermit2Data

Git Source

struct RemoveLiquidityPermit2Data {
    RemoveLiquidityData removeData;
    PermitTransferFrom permit;
    bytes signature;
}

SwapAndAddPermit2Data

Git Source

struct SwapAndAddPermit2Data {
    SwapAndAddData swapAndAddData;
    PermitBatchTransferFrom permit;
    bytes signature;
}

SwapBalances

Git Source

struct SwapBalances {
    uint256 actual0;
    uint256 actual1;
    uint256 initBalance0;
    uint256 initBalance1;
    uint256 balance0;
    uint256 balance1;
}

Contents

SVGParams

Git Source

Parameters for generating the URI

struct SVGParams {
    address vault;
    uint256 amount0;
    uint256 amount1;
    uint8 decimals0;
    uint8 decimals1;
    string symbol0;
    string symbol1;
}

INFTSVG

Git Source

Interface for the NFTSVG contract

Functions

isNFTSVG

Checks if the contract is compliant with the NFTSVG interface

function isNFTSVG() external pure returns (bool);

generateVaultURI

Generates a URI for a given vault

function generateVaultURI(SVGParams memory params_)
    external
    pure
    returns (string memory);

Parameters

NameTypeDescription
params_SVGParamsParameters for generating the URI

generateFallbackURI

Generates a fallback URI for a given vault

function generateFallbackURI(SVGParams memory params_)
    external
    pure
    returns (string memory);

Parameters

NameTypeDescription
params_SVGParamsParameters for generating the URI

NFTSVG

Git Source

Inherits: INFTSVG

Functions

isNFTSVG

Checks if the contract is compliant with the NFTSVG interface

function isNFTSVG() external pure returns (bool);

generateVaultURI

Generates a URI for a given vault

function generateVaultURI(SVGParams memory params_)
    public
    pure
    returns (string memory);

Parameters

NameTypeDescription
params_SVGParamsParameters for generating the URI

generateFallbackURI

Generates a fallback URI for a given vault

function generateFallbackURI(SVGParams memory params_)
    public
    pure
    returns (string memory);

Parameters

NameTypeDescription
params_SVGParamsParameters for generating the URI

_generateName

Generates the name of the URI for a given vault

function _generateName(SVGParams memory params_)
    internal
    pure
    returns (string memory);

Parameters

NameTypeDescription
params_SVGParamsParameters for generating the URI

_generateDescription

Generates the description of the URI for a given vault

function _generateDescription(SVGParams memory params_)
    internal
    pure
    returns (string memory);

Parameters

NameTypeDescription
params_SVGParamsParameters for generating the URI

_generateSVGImage

Generates the SVG image of the URI for a given vault

function _generateSVGImage(address vault_)
    internal
    pure
    returns (string memory svg);

Parameters

NameTypeDescription
vault_addressThe vault address represented by the NFT

_generateSVGDefs

function _generateSVGDefs() internal pure returns (string memory);

_generateSVGMasks

function _generateSVGMasks() internal pure returns (string memory);

_generateSVGFrame

function _generateSVGFrame() internal pure returns (string memory);

_generateSVGDunes

function _generateSVGDunes() internal pure returns (string memory);

_generateSVGFront

function _generateSVGFront() internal pure returns (string memory);

_generateSVGBack

function _generateSVGBack(address vault_)
    internal
    pure
    returns (string memory);

NFTSVGUtils

Git Source

State Variables

HEX_DIGITS

bytes16 private constant HEX_DIGITS = "0123456789abcdef";

Functions

Generates the logo for the NFT.

function generateSVGLogo() public pure returns (string memory);

addressToString

Converts an address to 2 string slices.

function addressToString(address addr_)
    public
    pure
    returns (string memory, string memory);

Parameters

NameTypeDescription
addr_addressaddress to convert to string.

uintToFloatString

Converts uints to float strings with 4 decimal places.

function uintToFloatString(
    uint256 value_,
    uint8 decimals_
) public pure returns (string memory);

Parameters

NameTypeDescription
value_uint256uint to convert to string.
decimals_uint8number of decimal places of the input value.

_uintToString

Code borrowed form: https://github.com/transmissions11/solmate/blob/main/src/utils/LibString.sol

Converts uints to strings.

function _uintToString(uint256 value_)
    internal
    pure
    returns (string memory str);

Parameters

NameTypeDescription
value_uint256uint to convert to string.

ArrakisMetaVaultFactory

Git Source

Inherits: IArrakisMetaVaultFactory, Pausable, Ownable

this contract will use create3 to deploy vaults.

State Variables

moduleRegistryPublic

address public immutable moduleRegistryPublic;

moduleRegistryPrivate

address public immutable moduleRegistryPrivate;

creationCodePublicVault

address public immutable creationCodePublicVault;

creationCodePrivateVault

address public immutable creationCodePrivateVault;

nft

PrivateVaultNFT public immutable nft;

manager

address public manager;

_publicVaults

EnumerableSet.AddressSet internal _publicVaults;

_privateVaults

EnumerableSet.AddressSet internal _privateVaults;

_deployers

EnumerableSet.AddressSet internal _deployers;

Functions

constructor

constructor(
    address owner_,
    address manager_,
    address moduleRegistryPublic_,
    address moduleRegistryPrivate_,
    address creationCodePublicVault_,
    address creationCodePrivateVault_
);

pause

function used to pause the factory.

only callable by owner.

function pause() external onlyOwner;

unpause

function used to unpause the factory.

only callable by owner.

function unpause() external onlyOwner;

setManager

function used to set a new manager.

only callable by owner.

function setManager(address newManager_) external onlyOwner;

Parameters

NameTypeDescription
newManager_addressaddress that will managed newly created vault.

deployPublicVault

function used to deploy ERC20 token wrapped Arrakis Meta Vault.

function deployPublicVault(
    bytes32 salt_,
    address token0_,
    address token1_,
    address owner_,
    address beacon_,
    bytes calldata moduleCreationPayload_,
    bytes calldata initManagementPayload_
) external whenNotPaused returns (address vault);

Parameters

NameTypeDescription
salt_bytes32bytes32 used to get a deterministic all chains address.
token0_addressaddress of the first token of the token pair.
token1_addressaddress of the second token of the token pair.
owner_addressaddress of the owner of the vault.
beacon_addressaddress of the beacon that will be used to create the default module.
moduleCreationPayload_bytespayload for initializing the module.
initManagementPayload_bytesdata for initialize management.

Returns

NameTypeDescription
vaultaddressaddress of the newly created Token Meta Vault.

deployPrivateVault

function used to deploy owned Arrakis Meta Vault.

function deployPrivateVault(
    bytes32 salt_,
    address token0_,
    address token1_,
    address owner_,
    address beacon_,
    bytes calldata moduleCreationPayload_,
    bytes calldata initManagementPayload_
) external whenNotPaused returns (address vault);

Parameters

NameTypeDescription
salt_bytes32bytes32 needed to compute vault address deterministic way.
token0_addressaddress of the first token of the token pair.
token1_addressaddress of the second token of the token pair.
owner_addressaddress of the owner of the vault.
beacon_addressaddress of the beacon that will be used to create the default module.
moduleCreationPayload_bytespayload for initializing the module.
initManagementPayload_bytesdata for initialize management.

Returns

NameTypeDescription
vaultaddressaddress of the newly created private Meta Vault.

whitelistDeployer

function used to grant the role to deploy to a list of addresses.

function whitelistDeployer(address[] calldata deployers_)
    external
    onlyOwner;

Parameters

NameTypeDescription
deployers_address[]list of addresses that owner want to grant permission to deploy.

blacklistDeployer

function used to grant the role to deploy to a list of addresses.

function blacklistDeployer(address[] calldata deployers_)
    external
    onlyOwner;

Parameters

NameTypeDescription
deployers_address[]list of addresses that owner want to revoke permission to deploy.

getTokenName

get Arrakis Modular standard token name for two corresponding tokens.

function getTokenName(
    address token0_,
    address token1_
) public view returns (string memory);

Parameters

NameTypeDescription
token0_addressaddress of the first token.
token1_addressaddress of the second token.

Returns

NameTypeDescription
<none>stringname name of the arrakis modular token vault.

publicVaults

get a list of public vaults created by this factory

function publicVaults(
    uint256 startIndex_,
    uint256 endIndex_
) external view returns (address[] memory);

Parameters

NameTypeDescription
startIndex_uint256start index
endIndex_uint256end index

Returns

NameTypeDescription
<none>address[]vaults list of all created vaults.

numOfPublicVaults

numOfPublicVaults counts the total number of public vaults in existence

function numOfPublicVaults() public view returns (uint256 result);

Returns

NameTypeDescription
resultuint256total number of vaults deployed

isPublicVault

isPublicVault check if the inputed vault is a public vault.

function isPublicVault(address vault_) external view returns (bool);

Parameters

NameTypeDescription
vault_addressaddress of the address to check.

Returns

NameTypeDescription
<none>boolisPublicVault true if the inputed vault is public or otherwise false.

privateVaults

get a list of private vaults created by this factory

function privateVaults(
    uint256 startIndex_,
    uint256 endIndex_
) external view returns (address[] memory);

Parameters

NameTypeDescription
startIndex_uint256start index
endIndex_uint256end index

Returns

NameTypeDescription
<none>address[]vaults list of all created vaults.

numOfPrivateVaults

numOfPrivateVaults counts the total number of private vaults in existence

function numOfPrivateVaults() public view returns (uint256 result);

Returns

NameTypeDescription
resultuint256total number of vaults deployed

isPrivateVault

isPrivateVault check if the inputed vault is a private vault.

function isPrivateVault(address vault_)
    external
    view
    returns (bool);

Parameters

NameTypeDescription
vault_addressaddress of the address to check.

Returns

NameTypeDescription
<none>boolisPublicVault true if the inputed vault is private or otherwise false.

deployers

function used to get a list of address that can deploy public vault.

function deployers() external view returns (address[] memory);

_initManagement

function _initManagement(
    address vault_,
    bytes memory data_
) internal;

_getPublicVaultConstructorPayload

to anticipate futur changes in the manager's initManagement function manager should implement getInitManagementSelector function, so factory can get the the right selector of the function.

for initializing management we need to know the vault address, so manager should follow this pattern where vault address is the first parameter of the function.

function _getPublicVaultConstructorPayload(
    address timeLock_,
    address token0_,
    address token1_
) internal view returns (bytes memory);

_append

function _append(
    string memory a_,
    string memory b_,
    string memory c_,
    string memory d_
) internal pure returns (string memory);

ArrakisMetaVaultPrivate

ArrakisMetaVaultPublic

Git Source

Inherits: IArrakisMetaVaultPublic, ArrakisMetaVault, Ownable, ERC20

State Variables

_name

string internal _name;

_symbol

string internal _symbol;

Functions

constructor

constructor(
    address owner_,
    string memory name_,
    string memory symbol_,
    address moduleRegistry_,
    address manager_,
    address token0_,
    address token1_
) ArrakisMetaVault(moduleRegistry_, manager_, token0_, token1_);

mint

function used to mint share of the vault position

function mint(
    uint256 shares_,
    address receiver_
) external payable returns (uint256 amount0, uint256 amount1);

Parameters

NameTypeDescription
shares_uint256amount representing the part of the position owned by receiver.
receiver_addressaddress where share token will be sent.

Returns

NameTypeDescription
amount0uint256amount of token0 deposited.
amount1uint256amount of token1 deposited.

burn

function used to burn share of the vault position.

function burn(
    uint256 shares_,
    address receiver_
) external returns (uint256 amount0, uint256 amount1);

Parameters

NameTypeDescription
shares_uint256amount of share that will be burn.
receiver_addressaddress where underlying tokens will be sent.

Returns

NameTypeDescription
amount0uint256amount of token0 withdrawn.
amount1uint256amount of token1 withdrawn.

transferOwnership

override transfer of ownership, to make it not possible.

function transferOwnership(address) public payable override;

renounceOwnership

override transfer of ownership, to make it not possible.

function renounceOwnership() public payable override;

completeOwnershipHandover

override transfer of ownership, to make it not possible.

function completeOwnershipHandover(address) public payable override;

name

function used to get the name of the LP token.

function name() public view override returns (string memory);

Returns

NameTypeDescription
<none>stringname string value containing the name.

symbol

function used to get the symbol of the LP token.

function symbol() public view override returns (string memory);

Returns

NameTypeDescription
<none>stringsymbol string value containing the symbol.

_deposit

function _deposit(uint256 proportion_)
    internal
    nonReentrant
    returns (uint256 amount0, uint256 amount1);

_onlyOwnerCheck

msg.sender should be the tokens provider

function _onlyOwnerCheck() internal view override;

ArrakisPublicVaultRouter

Git Source

Inherits: IArrakisPublicVaultRouter, ReentrancyGuard, Ownable, Pausable

State Variables

nativeToken

address public immutable nativeToken;

permit2

IPermit2 public immutable permit2;

factory

IArrakisMetaVaultFactory public immutable factory;

weth

IWETH9 public immutable weth;

swapper

IRouterSwapExecutor public swapper;

Functions

onlyPublicVault

modifier onlyPublicVault(address vault_);

constructor

constructor(
    address nativeToken_,
    address permit2_,
    address owner_,
    address factory_,
    address weth_
);

pause

function used to pause the router.

only callable by owner

function pause() external onlyOwner;

unpause

function used to unpause the router.

only callable by owner

function unpause() external onlyOwner;

updateSwapExecutor

function updateSwapExecutor(address swapper_)
    external
    whenNotPaused
    onlyOwner;

addLiquidity

addLiquidity adds liquidity to meta vault of interest (mints L tokens)

function addLiquidity(AddLiquidityData memory params_)
    external
    payable
    nonReentrant
    whenNotPaused
    onlyPublicVault(params_.vault)
    returns (uint256 amount0, uint256 amount1, uint256 sharesReceived);

Parameters

NameTypeDescription
params_AddLiquidityDataAddLiquidityData struct containing data for adding liquidity

Returns

NameTypeDescription
amount0uint256amount of token0 transferred from msg.sender to mint mintAmount
amount1uint256amount of token1 transferred from msg.sender to mint mintAmount
sharesReceiveduint256amount of public vault tokens transferred to receiver

swapAndAddLiquidity

swapAndAddLiquidity transfer tokens to and calls RouterSwapExecutor

function swapAndAddLiquidity(SwapAndAddData memory params_)
    external
    payable
    nonReentrant
    whenNotPaused
    onlyPublicVault(params_.addData.vault)
    returns (
        uint256 amount0,
        uint256 amount1,
        uint256 sharesReceived,
        uint256 amount0Diff,
        uint256 amount1Diff
    );

Parameters

NameTypeDescription
params_SwapAndAddDataSwapAndAddData struct containing data for swap

Returns

NameTypeDescription
amount0uint256amount of token0 transferred from msg.sender to mint mintAmount
amount1uint256amount of token1 transferred from msg.sender to mint mintAmount
sharesReceiveduint256amount of public vault tokens transferred to receiver
amount0Diffuint256token0 balance difference post swap
amount1Diffuint256token1 balance difference post swap

removeLiquidity

removeLiquidity removes liquidity from vault and burns LP tokens

function removeLiquidity(RemoveLiquidityData memory params_)
    external
    nonReentrant
    whenNotPaused
    onlyPublicVault(params_.vault)
    returns (uint256 amount0, uint256 amount1);

Parameters

NameTypeDescription
params_RemoveLiquidityDataRemoveLiquidityData struct containing data for withdrawals

Returns

NameTypeDescription
amount0uint256actual amount of token0 transferred to receiver for burning burnAmount
amount1uint256actual amount of token1 transferred to receiver for burning burnAmount

addLiquidityPermit2

addLiquidityPermit2 adds liquidity to public vault of interest (mints LP tokens)

function addLiquidityPermit2(AddLiquidityPermit2Data memory params_)
    external
    payable
    nonReentrant
    whenNotPaused
    onlyPublicVault(params_.addData.vault)
    returns (uint256 amount0, uint256 amount1, uint256 sharesReceived);

Parameters

NameTypeDescription
params_AddLiquidityPermit2DataAddLiquidityPermit2Data struct containing data for adding liquidity

Returns

NameTypeDescription
amount0uint256amount of token0 transferred from msg.sender to mint mintAmount
amount1uint256amount of token1 transferred from msg.sender to mint mintAmount
sharesReceiveduint256amount of public vault tokens transferred to receiver

swapAndAddLiquidityPermit2

swapAndAddLiquidityPermit2 transfer tokens to and calls RouterSwapExecutor

function swapAndAddLiquidityPermit2(
    SwapAndAddPermit2Data memory params_
)
    external
    payable
    nonReentrant
    whenNotPaused
    onlyPublicVault(params_.swapAndAddData.addData.vault)
    returns (
        uint256 amount0,
        uint256 amount1,
        uint256 sharesReceived,
        uint256 amount0Diff,
        uint256 amount1Diff
    );

Parameters

NameTypeDescription
params_SwapAndAddPermit2DataSwapAndAddPermit2Data struct containing data for swap

Returns

NameTypeDescription
amount0uint256amount of token0 transferred from msg.sender to mint mintAmount
amount1uint256amount of token1 transferred from msg.sender to mint mintAmount
sharesReceiveduint256amount of public vault tokens transferred to receiver
amount0Diffuint256token0 balance difference post swap
amount1Diffuint256token1 balance difference post swap

removeLiquidityPermit2

removeLiquidityPermit2 removes liquidity from vault and burns LP tokens

function removeLiquidityPermit2(
    RemoveLiquidityPermit2Data memory params_
)
    external
    nonReentrant
    whenNotPaused
    onlyPublicVault(params_.removeData.vault)
    returns (uint256 amount0, uint256 amount1);

Parameters

NameTypeDescription
params_RemoveLiquidityPermit2DataRemoveLiquidityPermit2Data struct containing data for withdrawals

Returns

NameTypeDescription
amount0uint256actual amount of token0 transferred to receiver for burning burnAmount
amount1uint256actual amount of token1 transferred to receiver for burning burnAmount

wrapAndAddLiquidity

wrapAndAddLiquidity wrap eth and adds liquidity to meta vault of interest (mints L tokens)

function wrapAndAddLiquidity(AddLiquidityData memory params_)
    external
    payable
    nonReentrant
    whenNotPaused
    onlyPublicVault(params_.vault)
    returns (uint256 amount0, uint256 amount1, uint256 sharesReceived);

Parameters

NameTypeDescription
params_AddLiquidityDataAddLiquidityData struct containing data for adding liquidity

Returns

NameTypeDescription
amount0uint256amount of token0 transferred from msg.sender to mint mintAmount
amount1uint256amount of token1 transferred from msg.sender to mint mintAmount
sharesReceiveduint256amount of public vault tokens transferred to receiver

wrapAndSwapAndAddLiquidity

wrapAndSwapAndAddLiquidity wrap eth and transfer tokens to and calls RouterSwapExecutor

function wrapAndSwapAndAddLiquidity(SwapAndAddData memory params_)
    external
    payable
    nonReentrant
    whenNotPaused
    onlyPublicVault(params_.addData.vault)
    returns (
        uint256 amount0,
        uint256 amount1,
        uint256 sharesReceived,
        uint256 amount0Diff,
        uint256 amount1Diff
    );

Parameters

NameTypeDescription
params_SwapAndAddDataSwapAndAddData struct containing data for swap

Returns

NameTypeDescription
amount0uint256amount of token0 transferred from msg.sender to mint mintAmount
amount1uint256amount of token1 transferred from msg.sender to mint mintAmount
sharesReceiveduint256amount of public vault tokens transferred to receiver
amount0Diffuint256token0 balance difference post swap
amount1Diffuint256token1 balance difference post swap

wrapAndAddLiquidityPermit2

wrapAndAddLiquidityPermit2 wrap eth and adds liquidity to public vault of interest (mints LP tokens)

hack to get rid of stack too depth

function wrapAndAddLiquidityPermit2(
    AddLiquidityPermit2Data memory params_
)
    external
    payable
    nonReentrant
    whenNotPaused
    onlyPublicVault(params_.addData.vault)
    returns (uint256 amount0, uint256 amount1, uint256 sharesReceived);

Parameters

NameTypeDescription
params_AddLiquidityPermit2DataAddLiquidityPermit2Data struct containing data for adding liquidity

Returns

NameTypeDescription
amount0uint256amount of token0 transferred from msg.sender to mint mintAmount
amount1uint256amount of token1 transferred from msg.sender to mint mintAmount
sharesReceiveduint256amount of public vault tokens transferred to receiver

wrapAndSwapAndAddLiquidityPermit2

wrapAndSwapAndAddLiquidityPermit2 wrap eth and transfer tokens to and calls RouterSwapExecutor

function wrapAndSwapAndAddLiquidityPermit2(
    SwapAndAddPermit2Data memory params_
)
    external
    payable
    nonReentrant
    whenNotPaused
    onlyPublicVault(params_.swapAndAddData.addData.vault)
    returns (
        uint256 amount0,
        uint256 amount1,
        uint256 sharesReceived,
        uint256 amount0Diff,
        uint256 amount1Diff
    );

Parameters

NameTypeDescription
params_SwapAndAddPermit2DataSwapAndAddPermit2Data struct containing data for swap

Returns

NameTypeDescription
amount0uint256amount of token0 transferred from msg.sender to mint mintAmount
amount1uint256amount of token1 transferred from msg.sender to mint mintAmount
sharesReceiveduint256amount of public vault tokens transferred to receiver
amount0Diffuint256token0 balance difference post swap
amount1Diffuint256token1 balance difference post swap

receive

hack to get rid of stack too depth

receive() external payable;

getMintAmounts

getMintAmounts used to get the shares we can mint from some max amounts.

function getMintAmounts(
    address vault_,
    uint256 maxAmount0_,
    uint256 maxAmount1_
)
    external
    view
    returns (
        uint256 shareToMint,
        uint256 amount0ToDeposit,
        uint256 amount1ToDeposit
    );

Parameters

NameTypeDescription
vault_addressmeta vault address.
maxAmount0_uint256maximum amount of token0 user want to contribute.
maxAmount1_uint256maximum amount of token1 user want to contribute.

Returns

NameTypeDescription
shareToMintuint256maximum amount of share user can get for 'maxAmount0*' and 'maxAmount1*'.
amount0ToDeposituint256amount of token0 user should deposit into the vault for minting 'shareToMint'.
amount1ToDeposituint256amount of token1 user should deposit into the vault for minting 'shareToMint'.

_addLiquidity

function _addLiquidity(
    address vault_,
    uint256 amount0_,
    uint256 amount1_,
    uint256 shares_,
    address receiver_,
    address token0_,
    address token1_
) internal;

_swapAndAddLiquidity

function _swapAndAddLiquidity(
    SwapAndAddData memory params_,
    address token0_,
    address token1_
)
    internal
    returns (
        uint256 amount0Use,
        uint256 amount1Use,
        uint256 amount0,
        uint256 amount1,
        uint256 sharesReceived,
        uint256 amount0Diff,
        uint256 amount1Diff
    );

_swapAndAddLiquiditySendBackLeftOver

function _swapAndAddLiquiditySendBackLeftOver(
    SwapAndAddData memory params_,
    address token0_,
    address token1_
)
    internal
    returns (
        uint256 amount0,
        uint256 amount1,
        uint256 sharesReceived,
        uint256 amount0Diff,
        uint256 amount1Diff
    );

_removeLiquidity

function _removeLiquidity(RemoveLiquidityData memory params_)
    internal
    returns (uint256 amount0, uint256 amount1);

_permit2AddLengthOne

function _permit2AddLengthOne(
    AddLiquidityPermit2Data memory params_,
    address token0_,
    address token1_,
    uint256 amount0_,
    uint256 amount1_
) internal;

_permit2AddLengthOneOrTwo

function _permit2AddLengthOneOrTwo(
    AddLiquidityPermit2Data memory params_,
    address token0_,
    address token1_,
    uint256 amount0_,
    uint256 amount1_
) internal;

_permit2Add

function _permit2Add(
    uint256 permittedLength_,
    AddLiquidityPermit2Data memory params_,
    address token0_,
    address token1_,
    uint256 amount0_,
    uint256 amount1_
) internal;

_permit2SwapAndAddLengthOne

function _permit2SwapAndAddLengthOne(
    SwapAndAddPermit2Data memory params_,
    address token0_,
    address token1_
) internal;

_permit2SwapAndAddLengthOneOrTwo

function _permit2SwapAndAddLengthOneOrTwo(
    SwapAndAddPermit2Data memory params_,
    address token0_,
    address token1_
) internal;

_permit2SwapAndAdd

function _permit2SwapAndAdd(
    uint256 permittedLength_,
    SwapAndAddPermit2Data memory params_,
    address token0_,
    address token1_
) internal;

_getMintAmounts

function _getMintAmounts(
    address vault_,
    uint256 maxAmount0_,
    uint256 maxAmount1_
)
    internal
    view
    returns (
        uint256 shareToMint,
        uint256 amount0ToDeposit,
        uint256 amount1ToDeposit
    );

ArrakisStandardManager

Git Source

Inherits: IArrakisStandardManager, IManager, Ownable, ReentrancyGuardUpgradeable, PausableUpgradeable

State Variables

defaultFeePIPS

uint256 public immutable defaultFeePIPS;

nativeToken

address public immutable nativeToken;

nativeTokenDecimals

uint8 public immutable nativeTokenDecimals;

defaultReceiver

address public defaultReceiver;

receiversByToken

mapping(address => address) public receiversByToken;

vaultInfo

mapping(address => VaultInfo) public vaultInfo;

pendingFeeIncrease

mapping(address => FeeIncrease) public pendingFeeIncrease;

factory

address public factory;

_guardian

address internal immutable _guardian;

_vaults

EnumerableSet.AddressSet internal _vaults;

Functions

onlyVaultOwner

modifier onlyVaultOwner(address vault_);

onlyWhitelistedVault

modifier onlyWhitelistedVault(address vault_);

onlyGuardian

modifier onlyGuardian();

constructor

constructor(
    uint256 defaultFeePIPS_,
    address nativeToken_,
    uint8 nativeTokenDecimals_,
    address guardian_
);

initialize

function used to initialize standard manager proxy.

we are not checking if the default fee pips is not zero, to have the option to set 0 as default fee pips.

function initialize(
    address owner_,
    address defaultReceiver_,
    address factory_
) external initializer;

Parameters

NameTypeDescription
owner_addressaddress of the owner of standard manager.
defaultReceiver_addressaddress of the receiver of tokens (by default).
factory_addressArrakisMetaVaultFactory contract address.

pause

function used to pause the manager.

only callable by guardian

function pause() external onlyGuardian;

unpause

function used to unpause the manager.

only callable by guardian

function unpause() external onlyGuardian;

setDefaultReceiver

function used to set the default receiver of tokens earned.

function setDefaultReceiver(address newDefaultReceiver_)
    external
    onlyOwner;

Parameters

NameTypeDescription
newDefaultReceiver_addressaddress of the new default receiver of tokens.

setReceiverByToken

function used to set receiver of a specific token.

function setReceiverByToken(
    address vault_,
    bool isSetReceiverToken0_,
    address receiver_
) external onlyOwner onlyWhitelistedVault(vault_);

Parameters

NameTypeDescription
vault_addressaddress of the meta vault that contain the specific token.
isSetReceiverToken0_boolboolean if true means that receiver is for token0 if not it's for token1.
receiver_addressaddress of the receiver of this specific token.

decreaseManagerFeePIPS

function used to decrease the fees taken by manager for a specific vault.

function decreaseManagerFeePIPS(
    address vault_,
    uint24 newFeePIPS_
) external onlyOwner onlyWhitelistedVault(vault_);

Parameters

NameTypeDescription
vault_addressaddress of the vault.
newFeePIPS_uint24fees in pips to set on the specific vault.

finalizeIncreaseManagerFeePIPS

function used to finalize a time lock fees increase on a vault.

function finalizeIncreaseManagerFeePIPS(address vault_)
    external
    onlyOwner;

Parameters

NameTypeDescription
vault_addressaddress of the vault where the fees increase will be applied.

submitIncreaseManagerFeePIPS

function used to submit a fees increase in a managed vault.

function submitIncreaseManagerFeePIPS(
    address vault_,
    uint24 newFeePIPS_
) external onlyOwner onlyWhitelistedVault(vault_);

Parameters

NameTypeDescription
vault_addressaddress of the vault where fees will be increase after timeLock.
newFeePIPS_uint24fees in pips to set on the specific managed vault.

withdrawManagerBalance

function used by manager to get his balance of fees earned on a vault.

function withdrawManagerBalance(address vault_)
    external
    onlyOwner
    nonReentrant
    whenNotPaused
    returns (uint256 amount0, uint256 amount1);

Parameters

NameTypeDescription
vault_addressfrom which fees will be collected.

Returns

NameTypeDescription
amount0uint256amount of token0 sent to receiver_
amount1uint256amount of token1 sent to receiver_

rebalance

function used to manage vault's strategy.

function rebalance(
    address vault_,
    bytes[] calldata payloads_
) external nonReentrant whenNotPaused onlyWhitelistedVault(vault_);

Parameters

NameTypeDescription
vault_addressaddress of the vault that need a rebalance.
payloads_bytes[]call data to do specific action of vault side.

setModule

function used to set a new module (strategy) for the vault.

only public vault should have this check.

function setModule(
    address vault_,
    address module_,
    bytes[] calldata payloads_
) external whenNotPaused onlyWhitelistedVault(vault_);

Parameters

NameTypeDescription
vault_addressaddress of the vault the manager want to change module.
module_addressaddress of the new module.
payloads_bytes[]call data to initialize position on the new module.

initManagement

function used to init management of a meta vault.

function initManagement(SetupParams calldata params_)
    external
    whenNotPaused;

Parameters

NameTypeDescription
params_SetupParamsstruct containing all the data for initialize the vault.

updateVaultInfo

function used to update meta vault management informations.

function updateVaultInfo(SetupParams calldata params_)
    external
    whenNotPaused
    onlyWhitelistedVault(params_.vault)
    onlyVaultOwner(params_.vault);

Parameters

NameTypeDescription
params_SetupParamsstruct containing all the data for updating the vault.

receive

receive() external payable;

announceStrategy

function used to announce the strategy that the vault will follow.

function announceStrategy(
    address vault_,
    string memory strategy_
) external onlyWhitelistedVault(vault_);

Parameters

NameTypeDescription
vault_addressaddress of arrakis meta vault that will follow the strategy.
strategy_stringstring containing the strategy name that will be used.

initializedVaults

function used to get a list of managed vaults.

function initializedVaults(
    uint256 startIndex_,
    uint256 endIndex_
) external view whenNotPaused returns (address[] memory);

Parameters

NameTypeDescription
startIndex_uint256starting index from which the caller want to read the array of managed vaults.
endIndex_uint256ending index until which the caller want to read the array of managed vaults.

numInitializedVaults

function used to get the number of vault under management.

function numInitializedVaults()
    external
    view
    returns (uint256 numberOfVaults);

guardian

address of the pauser of manager.

function guardian() external view returns (address);

Returns

NameTypeDescription
<none>addresspauser address that can pause/unpause manager.

isManaged

function used to know if a vault is under management by this manager.

function isManaged(address vault_) external view returns (bool);

Parameters

NameTypeDescription
vault_addressaddress of the meta vault the caller want to check.

Returns

NameTypeDescription
<none>boolisManaged boolean which is true if the vault is under management, false otherwise.

getInitManagementSelector

function used to know the selector of initManagement functions.

function getInitManagementSelector()
    external
    pure
    returns (bytes4 selector);

_initManagement

function _initManagement(SetupParams memory params_) internal;

_updateParamsChecks

function _updateParamsChecks(SetupParams memory params_)
    internal
    view;

CreationCodePrivateVault

Git Source

Inherits: ICreationCode

Functions

getCreationCode

function getCreationCode() external pure returns (bytes memory);

CreationCodePublicVault

Git Source

Inherits: ICreationCode

Functions

getCreationCode

function getCreationCode() external pure returns (bytes memory);

Guardian

Git Source

Inherits: Ownable, IGuardian

State Variables

pauser

address public pauser;

Functions

constructor

constructor(address owner_, address pauser_);

setPauser

function to set the pauser of Arrakis protocol.

function setPauser(address newPauser_) external onlyOwner;

ModulePrivateRegistry

Git Source

Inherits: ModuleRegistry, IModulePrivateRegistry

Functions

constructor

constructor(
    address owner_,
    address guardian_,
    address admin_
) ModuleRegistry(owner_, guardian_, admin_);

createModule

function used to create module instance that can be whitelisted as module inside a vault.

function createModule(
    address vault_,
    address beacon_,
    bytes calldata payload_
) external returns (address module);

Parameters

NameTypeDescription
vault_address
beacon_addresswhich whitelisted beacon's implementation we want to create an instance of.
payload_bytespayload to create the module.

ModulePublicRegistry

Git Source

Inherits: ModuleRegistry, IModulePublicRegistry

Functions

constructor

constructor(
    address owner_,
    address guardian_,
    address admin_
) ModuleRegistry(owner_, guardian_, admin_);

createModule

function used to create module instance that can be whitelisted as module inside a vault.

function createModule(
    address vault_,
    address beacon_,
    bytes calldata payload_
) external returns (address module);

Parameters

NameTypeDescription
vault_address
beacon_addresswhich whitelisted beacon's implementation we want to create an instance of.
payload_bytespayload to create the module.

Pauser

Git Source

Inherits: IPauser, Ownable

State Variables

_pausers

EnumerableSet.AddressSet internal _pausers;

Functions

constructor

constructor(address pauser_, address owner_);

pause

function pause(address target_) external override;

whitelistPausers

function whitelistPausers(address[] calldata pausers_)
    external
    override
    onlyOwner;

blacklistPausers

function blacklistPausers(address[] calldata pausers_)
    external
    override
    onlyOwner;

isPauser

function isPauser(address account_) public view returns (bool);

PrivateVaultNFT

Git Source

Inherits: Ownable, ERC721, IPrivateVaultNFT

State Variables

renderController

address public immutable renderController;

Functions

constructor

constructor() ERC721("Arrakis Private LP NFT", "ARRAKIS");

mint

function used to mint nft (representing a vault) and send it.

function mint(address to_, uint256 tokenId_) external onlyOwner;

Parameters

NameTypeDescription
to_addressaddress where to send the NFT.
tokenId_uint256id of the NFT to mint.

tokenURI

function tokenURI(uint256 tokenId_)
    public
    view
    override
    returns (string memory);

getMetaDatas

function getMetaDatas(
    address token0_,
    address token1_
)
    public
    view
    returns (
        uint8 decimals0,
        uint8 decimals1,
        string memory symbol0,
        string memory symbol1
    );

RenderController

Git Source

Inherits: Ownable, IRenderController, Initializable

State Variables

renderer

address public renderer;

Functions

initialize

function initialize(address owner_) external initializer;

setRenderer

function used to set the renderer contract

only the svgController can do it.

function setRenderer(address renderer_) external onlyOwner;

Parameters

NameTypeDescription
renderer_addressaddress of the contract that will render the tokenUri for the svg of the nft.

isNFTSVG

function isNFTSVG(address renderer_) public view returns (bool);

RouterSwapExecutor

Git Source

Inherits: IRouterSwapExecutor

State Variables

router

address public immutable router;

nativeToken

address public immutable nativeToken;

Functions

onlyRouter

modifier onlyRouter();

constructor

constructor(address router_, address nativeToken_);

swap

function used to swap tokens.

function swap(SwapAndAddData memory params_)
    external
    payable
    onlyRouter
    returns (uint256 amount0Diff, uint256 amount1Diff);

Parameters

NameTypeDescription
params_SwapAndAddDatastruct containing all the informations for swapping.

Returns

NameTypeDescription
amount0Diffuint256the difference in token0 amount before and after the swap.
amount1Diffuint256the difference in token1 amount before and after the swap.

receive

receive() external payable;

RouterSwapResolver

Git Source

Inherits: IRouterSwapResolver

State Variables

router

IArrakisPublicVaultRouter public immutable router;

Functions

constructor

constructor(address router_);

calculateSwapAmount

function calculateSwapAmount(
    IArrakisMetaVault vault_,
    uint256 amount0In_,
    uint256 amount1In_,
    uint256 price18Decimals_
) external view returns (bool zeroForOne, uint256 swapAmount);

_getUnderlyingOrLiquidity

function _getUnderlyingOrLiquidity(IArrakisMetaVault vault_)
    internal
    view
    returns (uint256 gross0, uint256 gross1);

TimeLock

Git Source

Inherits: TimelockController, ITimeLock

Functions

constructor

constructor(
    uint256 minDelay,
    address[] memory proposers,
    address[] memory executors,
    address admin
) TimelockController(minDelay, proposers, executors, admin);

updateDelay

override updateDelay function of TimelockController to not allow update of delay.

function updateDelay(uint256) external pure override;

Module Implementations

HOT AMM Overview

TL;DR

LPs are getting rekt by toxic order flow. HOT improves returns and maximizes capital efficiency for LPs, by internalizing MEV using an intent-based design.

HOT was designed by Arrakis and Valantis Labs. It is built on the Valantis Modular DEX Framework. HOT is the first integration on Arrakis Modular and is powered by Arrakis's offchain market making infrastructure.

Concepts

Hybrid Order Type

HOT is a first of its kind hybrid AMM design, that combines the permissionless properties of AMMs with the capital efficiency and non-toxic order flow of Private market making on intents-based protocols like CoWSwap and UniswapX.

HOT stands for Hybrid Order Type. HOT pools have two swap execution mechanisms that run in parallel: RfQ Quotes and Permissionless AMM.

RfQ Quotes

  • Solvers compete for non-toxic uninformed order flow from intents-based protocols (CoW Swap, UniswapX, 1inch Fusion etc).

  • Permissioned solvers request quotes from an API, which calls the Arrakis offchain quoter and in turn issues quotes as a signed intent. Solvers can use these signed quotes at deterministic prices to fill their order against the HOT liquidity pool (until expiration).

  • When executed, these signed quotes update the pool price playing a special role in keeping the price from becoming stale to mitigate against arbitrage.

Learn more about the Quoter here.

Permissionless AMM

  • A single concentrated liquidity position is used, akin to Uniswap v3. In addition a dynamic fee is implemented. Anyone can permissionlessly swap against the pool onchain by invoking the swap method.

  • A dynamic fee that increases over time is used to further protect the pool against stale price arbitrage, in the event that a RfQ Quotes hasn’t been issued onchain recently. This fee is reset at the time a RfQ signed quoted is executed onchain.

Arrakis Module

The only way to provide liquidity to a HOT pool is via an Arrakis Vault. The Vault exposes Manager Functions that the manager role can call to actively manage the Arrakis liquidity position in the pool.

Quickstart HOT AMM

Solvers

Are you a solver looking to integrate HOT AMM liquidity pools as a liquidity source? Please refer to the Valantis Solver Guide.

Permissionless AMM Users

HOT AMM functions as a permissionless onchain liquidity pool very similar to Uniswap V3 pools.

  • Provide Liquidity: see this guide for interacting with HOT AMM as a liquidity provider.

  • Swap: for retail users and aggregators that desire to swap with low fees and up-to-date prices. These swaps happen against a single concentrated liquidity position, according to a UniswapV3 like constant-product AMM logic. For more details, we refer to the Valantis Sovereign Pool documentation.

Manager Functions

Note that ALL manager functions defined in Modules are subject to checks in the ArrakisStandardManager. Learn more about vault management and configurability here.

Set Price Bounds

This module exposes a function where the manager can change the concentration of the Arrakis vault liquidity position.

    function setPriceBounds(
        uint160 sqrtPriceLowX96_,
        uint160 sqrtPriceHighX96_,
        uint160 expectedSqrtSpotPriceUpperX96_,
        uint160 expectedSqrtSpotPriceLowerX96_
    ) external onlyManager {

Swap

This module exposes a function where the manager can swap to rebalance Arrakis vault liquidity against another onchain liquidity source (atomically).

    function swap(
        bool zeroForOne_,
        uint256 expectedMinReturn_,
        uint256 amountIn_,
        address router_,
        uint160 expectedSqrtSpotPriceUpperX96_,
        uint160 expectedSqrtSpotPriceLowerX96_,
        bytes calldata payload_
    ) external onlyManager whenNotPaused {

All modules also implement a setManagerFeePIPS and withdrawManagerBalance functions for handling Arrakis Protocol fee collection.

NOTE: while not executed through the manager role, the Quoter functionality is another offchain process that HOT pools rely on.

Quoter

A crucial offchain component of the HOT AMM is the QuoteSigner role which is set directly on the HOT.sol valantis ALM smart contract containing the core pricing logic of the HOT AMM.

Whoever holds the private key to the QuoteSigner role has the authority to at any time issue a signed quote that allows the recipient to execute a swap directly against the funds in the liquidity pool at the price specified in the signed quote (subject to certain onchain safety checks on the price and volume of the quote).

For Arrakis Public Vaults, the Quoter is a semi-trusted automated offchain process, which escrows Public Vault QuoteSigner keys and signs quotes to integrated parties (like CoWSwap solvers) at prices determined by the state of centralized exchanges, state of the LP Vault's onchain reserves, and the current Requests-For-Quotes seeking to trade.

Quoter Market Making Strategy

A quoter can use any offchain quoting strategy, as long as it's within the bounds enforced at the smart contract level:

  • bounds on size of any quote
  • bounds on number of quotes in a block
  • bounds on quote prices compared to an onchain oracle

A manager on the HOT.sol smart contract can set both the QuoteSigner role and these bounds on the QuoteSigner activity (this role should be burned, timelocked, or otherwise trusted). Within these guardrails, a quoter can implement any strategy it likes to issue quotes (and signed quote holders can execute these valid quotes).

The ETH/USDC Public Vault Quoter uses an Avellaneda and Stoikov based approach, where the bid ask spread skews around the mid market price with the goal to converge to a target inventory ratio (in this case, 50% ETH and 50% USDC).

Quoter Oracle Values

When the QuoteSigner issues signed quotes they can attach metadata that acts as oracle values to the state of the onchain AMM if and when the quote gets executed onchain. The key values are:

  • a new value for the midprice of the AMM, based on the Quoter's current instantaneous midprice observed offchain (sqrtSpotPriceX96New)
  • a new starting value for swap fee rates (feeMinToken{0,1})
  • a new growth rate for swap fees (feeGrowthE6Token{0,1})
  • a new max swap fee for the fee growth to stop at (feeMaxToken{0,1})

When a quote actually executes onchain (and is the first one to do so in a block) it will automagically reset the state of the AMM from that point in the block onward to:

  • spot price at sqrtSpotPriceX96New
  • swap fee for token{0,1} of feeMinToken{0,1} + feeGrowthE6Token{0,1} * (blockTimestamp- signatureTimestamp) / 100 (the minimum fee, plus the growth rate for the amount of time that has elapsed since this quote was signed)

If no new signed quotes land at the top of the next block then the swap fee rates will continue to grow second by second at the linear rate and thus will be larger at the top of the next block. This swap fee growth continues until the fee hits the maximum rate or until a new signed quote lands and resets the process.

Quoter Decentralization

One major direction of research and development at Arrakis is to make the Public Vault Quoter more transparently verifiable and trustless. More info on that coming soon!

Loss-Versus-Rebalancing (LVR)

LVR Problem

MEV losses are frequently associated with swappers because most retail DeFi users interact with DEXs to execute swaps. But passive LPs collectively account for the biggest losses in today’s MEV landscape because they offer stale prices and lose out on fees to searchers, builders, and proposers (and they need these fees to maintain profitability). In the 2022 paper Automated Market Making and Loss-Versus-Rebalancing, Columbia University professor and a16z researcher Tim Roughgarden and his team found that arbitrage costs ETH-USDC LPs about 11% of their principal per year.

Loss-Versus-Rebalancing (LVR) is a term used to describe MEV lost through arbitrage as a result of AMMs offering LPs liquidity at stale prices. As AMM prices update slower than CEXs, LPs become exposed to losses when arbitrageurs correct the discrepancy. LVR accounts for a major part of MEV extraction on Ethereum.

The AMM space has evolved since MEV extraction started to encroach on DeFi. Uniswap V3 pioneered liquidity concentration to help LPs earn more fees but this feature requires active monitoring. As MEV is brokered offchain through MEV-Boost, and most LPs passively provide liquidity onchain, LPs keep getting burned by LVR.

HOT AMM solution

HOT is an AMM design that attacks the LVR problem head on. It is done with a first of its kind Hybrid Order Type liquidity pool design. The summary for why it works well to recapture value for LPs is that an offchain API is trusted by the pool to issue signed orders to offchain swap requests at fair and competitive prices.

This offchain RfQ is one of the two parallel order types that the HOT liquidity pool supports. RfQ sidesteps the LVR problem completely by handling pricing offchain (within some bounds of an onchain oracle check, for LP safety from a malicious quoter).

For the classical AMM swap mode of the HOT liquidity pool, which is entirely onchain and thus subject to LVR, a combination of Dynamic Fees and injection of up-to-date info in RfQ swap execution both allow HOT to have more performant pricing than other onchain AMMs.

Deployments

Mainnet

WETH/USDC

Whitepaper

Abstract: Hybrid Order Type (HOT) is a novel automated market maker (AMM) created by Arrakis Finance and Valantis Labs. The HOT AMM is designed to mitigate MEV in the form of LVR by symbiotically existing alongside intent-centric protocols. HOT pools have a hybrid execution setup whereby trades can either occur through a familiar permissionless AMM swap or through a novel RfQ system where solvers can receive a deterministic quote to trade against the pool in exchange for updating the two key AMM state variables: the spot price and the dynamic fee. The fresher pricing combined with protective dynamic fees provides robust guarantees of LVR reduction for LPs on Arrakis. In this paper, we present the core design elements of this novel AMM as well as its advantages over conventional AMMs.

See Full Whitepaper

Uniswap v4 Hook

Contents

Audits

Arrakis smart contracts have been audited by world class security firms. You can find the audit reports below:

ChainSecurity

Sherlock

Watchpug

Research

Here you can find Arrakis's research papers:

Legacy Documentation

Arrakis Modular is the third version of Arrakis's smart contracts. Here you can find the documentation for the previous versions covering both:

  • Non-technical overviews
  • Developer documentation

Arrakis v2

Arrakis v1

History

Background

Arrakis Finance started in early 2021, shortly after the Uniswap v3 whitepaper was released. The introduction of concentrated Liquidity AMMs promised to finally disrupt the need for traditional Centralized Exchanges (CEX) in terms of efficiency, enabling AMMs to behave similar to their Central Limit Order Book (CLOB) counterparts.

These substantial efficiency improvements over older constant product AMMs unfortunately came at the cost of Liquidity Providers (LPs) facing substantial complexity and overhead associated with trying to fully leverage the potential of providing liquidity in a concentrated fashion on Uniswap V3.

The project, first being part of Gelato Network, later spun out into an independant project after receiving substantial organic traction and going on to have $1.8B TVL.

Arrakis has gone on to facilitate $20B in volume traded.

Since mid 2023, Arrakis has been focussed on the next generation of AMMs and MEV recapture to tackle the biggest threat Ethereum faces: extractive centralised actors.

Centralised Actors Taking Over DeFi

We are in the midst of a shift in DeFi. As Ethereum has grown, sophisticated actors have infiltrated DeFi and leveraged complex strategies to extract value from the ecosystem.

Naturally this has increased the scope of the problem statement Arrakis is tackling. It has grown to encompass recapturing MEV from centralised actors who are extractive to the ecosystem. Arrakis aims to give token issuers and LPs a fairer share of the pie.

Arrakis is focused on being a decentralized onchain market making solution, with a key feature of built-in MEV-Awareness / vertical integration into the MEV supply chain. Arrakis aims to give all token markets a seamless next-generation onchain spot market liquidity provision experience.

Inspiration

The name Arrakis comes in reference to Frank Herbert’s Dune Universe. Arrakis is a harsh desert planet full of dangers and mineable riches (the fabled “spice melange”), which echoes the similarly harsh, dangerous and yet financially potent world of crypto.