About Arrakis Documentation
Welcome to the Arrakis documentation.
Whether you are a developer, liquidity provider, treasury manager, DeFi enjoyooor or an MEV enthusiast, we aim to make this reference guide useful and interesting.
The documentation is structured into three main sections:
Intro to Arrakis is a non-technical tl;dr of the problem we are solving, the Arrakis infrastructure, integrations and user-facing products.
Developer Docs covers smart contract architecture, how to get started guides, an extensive technical reference and more. It also includes module integrations such as HOT AMM. It is aimed at developers interested in understanding the inner workings of Arrakis who are already familiar with Ethereum and the DeFi ecosystem.
Resources contains links to smart contract audits, our research and legacy documentation for Arrakis v1 & v2.
The liquidity must flow.
Overview
Arrakis is an MEV-aware market maker that powers onchain liquidity for token issuers and LPs.
This introduction section provides an overview of Arrakis including:
- History: Arrakis's journey from inception to present day.
- Problem Statement: Centralised actors extracting value from DeFi at the expense of token issuers and LPs.
- Arrakis Infrastructure: The smart contract framework (Arrakis Modular) and offchain market making components.
- Integrations: An overview of integrations on Arrakis Modular like HOT AMM and the upcoming Uniswap v4 Hook.
- Arrakis Pro: The flagship user-facing product for token issuers (protocols and DAOs).
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.
Problem Statement
As Ethereum has grown, sophisticated actors have infiltrated DeFi using complex strategies and sophisiticated offchain infrastructure to extract value from Ethereum.
Centralised Vertically-integrated Market Makers (CVMMs) Taking Over DeFi
We define CVMMs as sophisticated centralised actors who simultaneously participate in block building, MEV extraction, private order flow and most recently, capturing volumes via private market makers (PMMs). In other words, trading firms like Wintermute.
CVMMs extract the majority of profits from onchain liquidity, leaving protocols and liquidity providers to fight for toxic order flow. As of Oct 2024, Token Issuers, Retail DeFi, and other LPs have leaked $800M in MEV to poorly designed AMMs since the merge (Oct 2022).
Before Intent protocols like UniswapX, CoWSwap and 1inch Fusion emerged, CVMMs primarily focused on extracting value from passive LPs and onchain traders by channeling MEV and arbitrage strategies through their own block builders.
The Rise of Intents Protocols
UniswapX, CoWSwap and 1inch Fusion account for more than 50% of all trades on Ethereum, as of October 2024 (link). As intents have gained pace, these actors have started to monopolize DeFi, leaving LPs with less revenue and more exposure to toxic flow.
Intents Protocols have disrupted the onchain trading landscape. While they might offer swappers better pricing in the short-term, they exacerbate losses for passive LPs who are now left behind with less healthy flow from noise trading and a higher relative quantity of toxic, arbitrage-laden order flow. How so? Intent protocols offer CVMMs the ability to fill non-toxic order flow on their own private inventory via proprietary and highly sophisticated RFQ systems, which passive LPs cannot compete with.
But even swappers will be hurt in the long-term. As highlighted in the excellent paper titled Illuminating Ethereum's Order FLow Landscape by the Flashbots team:
- Order from retail users is being segmentation away from passive LPs to a permissioned set of market makers
- This in turn drives power to the hands of a few actor, creating a winner-takes-all dynamic
- Ove the long-term, even swappers will be hurt as powerful actors dictate liquidity provision.
In short, the designs of intents could even threaten the very decentralised nature of Ethereum by giving power to a few powerful actors. We shouldn't repeat the same mistakes from TradFi where extractive market makers take the lions share of profits.
Long Tail Liquidity
Furthermore, CVMMs are poorly equipped to cater to longtail assets, which will become a bigger problem as more of the world’s value moves onchain.
CVMMs cannot service the entire long tail of tokens since they lack the inventory and operational scale. This results in the long-tail market being underserved, not benefiting from the improved pricing and capital efficiency that PMMs have provided to blue chips. The vast majority of these tokens are highly illiquid and mostly operate on legacy DEX infrastructure.
Where Arrakis Fits in
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. By recapturing value to the application layer, Arrakis protects token issuers and LPs capital and increases their profitability.
Arrakis is building the first decentralised vertically-integrated market making solution.
Arrakis Infrastructure
Arrakis Infrastructure consists of two components:
Together the Arrakis offchain market making and the Arrakis Modular (smart contract framework) form the Arrakis infrastructure known as the Arrakis protocol.
For example, HOT AMM is formed by the following components:
- Arrakis Quoter and other offchain market making components.
- Arrakis Modular (smart contract framework) using public vaults.
- Valantis Modular DEX framework (as the 1st integration).
Offchain Market Making
Arrakis Offchain Market Making is a suite of tools that allow Arrakis to make markets onchain.
They are comprised of:
- Arrakis Rebalancer
- Arrakis Quoter
- Arrakis Liquidity Concentrator
- Arrakis Swapper
- Arrakis Alerting System
Smart Contract Framework (Arrakis Modular)
Arrakis Modular represents the next evolution of the Arrakis onchain liquidity management smart contracts. Arrakis Modular introduces a universal Meta-Vault standard, which standardizes the interface for integration any two-sided liquidity provision protocol. Arrakis Modular is highly flexible, reusable and scalable:
- Flexibility: Modules adhering to a common interface can be easily developed and attached, supporting a broad range of DEXs and use-cases.
- Reusability: The Arrakis Vault standard facilitates the reuse of components and maintenance of standard interfaces, streamlining future expansions.
- Scalability: Adapting to new liquidity pool types becomes straightforward, focusing on module development rather than protocol overhauls.
Dive into the technical details in the developers documentation section at Arrakis Modular.
Vault Integrations
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.
Here you can find more information on the integrations available on Arrakis Modular:
-
HOT AMM: HOT improves returns and maximizes capital efficiency for LPs, by internalizing MEV using an intent-based design. Designed in partnership with Valantis Labs, built on the Valantis Modular DEX Framework. It is the first integration on Arrakis Modular and is powered by Arrakis's offchain market making infrastructure.
-
Uniswap v4 Hook: Coming soon...
More on Arrakis Modular
The potential for integrations extends beyond single DEXs. While current use cases focus on modules which each integrate an individual DEX liquidity provision protocol, in theory, modules could become more complex, enabling integrations with multiple DEXs simultaneously or combining DEX and peripheral protocols like lending markets or options protocols for advanced functionality (hedging and delta-neutral strategies etc). The architecture of Arrakis Modular supports such future innovations.
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.
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 intents protocols.
Problem Statement
LPs bear the high cost of rebalancing AMMs
By design, AMMs 'pay' arbitrageurs to rebalance pools. 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.
The rise of intents protocols has spawned a new class of centralised actors
An unintended consequence of intents protocols is that they have birthed a new class of liquidity provider called the "Centralised Vertically-integrated Market Maker" (CVMM).
Good flow to centralised actors and toxic order flow to AMMs
The sophisticated offchain infrastructure of CVMMs gives them an unfair advantage over passive LPs. LPs are left to compete for toxic order flow, driving passive LPs close to extinction.
How HOT AMM works
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.
HOT pools have two swap execution mechanisms:
RfQ Quotes
- Solvers compete for non-toxic uninformed order flow from intents protocols like CoW Swap, Uniswap X and 1inch Fusion.
- In turn these solvers update the pool price.
Permissionless AMM
- Anyone can swap against the AMM which is akin to Uniswap v3. In addition a dynamic fee is implemented.
- 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.
To learn more, refer to the HOT AMM section.
Uniswap v4 Hook
Coming soon...
Arrakis Pro: Liquidity Management for Token Issuers
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:
- Greater capital efficiency: narrow price range with rebalancing to keep the price in the range.
- Minimum price impact: increased liquidity depth leading to reduced downside price impact and market volatility.
- Return on capital: facilitate more trading volumes whilst reducing toxic order flow.
- 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 Pro is trusted by Maker, EtherFi, Across, Lido, Stargate, Gnosis, Angle, Mountain, Kwenta, Index, Sturdy, Everclear and many more leading protocols. As of October 2024, Arrakis vaults have facilitated over $20B in transactions.
Contact us to learn more about how Arrakis Pro can support your token launch and ongoing liquidity management.
Overview
Arrakis Modular represents the next evolution of the Arrakis onchain liquidity management protocol, aiming to overcome the limitations of previous versions (V1 and V2). Across versions, Arrakis vaults allow Liquidity Providers (LPs) to Decentralized Exchanges (DEXs) actively manage or delegate the management of their liquidity positions. However, Arrakis V1 and V2 were specifically built around Uniswap V3. Therefore, the previous standards were incompatible with other DEXs, and in order to support alternative venues (e.g. Uniswap V4, Balancer, Ambient, etc) Arrakis would have to make a completely new standard for every integration.
To address this, Arrakis Modular introduces a universal Meta-Vault standard. This modular framework enables the attachment of standardized modules to any two-sided liquidity provision protocol, simplifying the integration process. Key features include:
- Flexibility: Modules adhering to a common interface can be easily developed and attached, supporting a broad range of DEXs and use-cases.
- Reusability: The Arrakis Vault standard facilitates the reuse of components and maintenance of standard interfaces, streamlining future expansions.
- Scalability: Adapting to new liquidity pool types becomes straightforward, focusing on module development rather than protocol overhauls.
With Arrakis Modular essentially any onchain DeFi strategy based on a dual-asset underlying can be created and tokenized, simply by developing the corresponding module which correctly adheres to the Arrakis Meta-Vault module interface
We envision Arrakis Modular not only as a technical advancement internally, but as a platform for community and developer collaboration, inviting contributions to the ecosystem. With this modular approach, Arrakis Finance is poised to rapidly adapt to the evolving DeFi landscape, unlocking new possibilities for liquidity management.
Finally, note that the potential for modules extends beyond single DEX integrations. While current use cases focus on modules which each integrate an individual DEX liquidity provision protocol, in theory, modules could become more complex, enabling integrations with multiple DEXs simultaneously or combining DEX and peripheral protocols like lending markets or options protocols for advanced functionality (hedging and delta-neutral strategies etc). The architecture of Arrakis Modular supports such future innovations.
Architecture
At the heart of the Arrakis Modular system is the concept of Meta Vaults. These Meta Vaults enable users wishing to provide liquidity with two distinct assets to do so across any trading venue—without the need to deploy or migrate funds to new vaults. Meta Vaults have the capability to whitelist various modules, essentially smart contracts that establish integration with liquidity-consuming dApps. This design ensures that as new DEXs emerge, liquidity provision becomes a matter of simply creating and whitelisting a new module compatible with the DEX, and then activating it.
For now, the domain of use-cases considered for a module could still all be integrations with a (single) DEX liquidity provision protocol, though technically modules could become more complex (a module that integrates with multiple DEXs simultaneously and can rebalance across them, or a module that integrates a DEX and peripheral protocols like lending markets or options protocols).
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 across various decentralized exchanges (DEXs) and trading venues. The key features and concepts of Meta Vaults include:
-
Versatile Liquidity Provision: Meta Vaults allow users to provide liquidity using two distinct assets across multiple trading platforms without the need to deploy or migrate funds to separate vaults for each platform.
-
Modular Architecture: The system uses a modular approach, where modules (smart contracts) can be whitelisted to integrate with different liquidity-consuming decentralized applications (dApps). This modularity allows for easy expansion to new DEXs by simply creating and whitelisting new compatible modules.
-
Two Types of Meta Vaults:
a. Public Meta Vaults: These are ERC20-wrapped vaults intended for shared liquidity positions or strategies. They allow for delegated management of liquidity on behalf of multiple participants.
b. 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 can be tokenized as a fully onchain NFT, as shown below.
-
Factory: It is responsible for deploying new instances of both public and private Meta Vaults. It maintains a list of all deployed vaults and manages permissions for public vault deployments.
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.
These modules are whitelisted through public and private registry contracts to ensure security and proper functionality. While currently focused on single DEX integrations, the modular design allows for potential expansion into more complex scenarios, such as multi-DEX interactions or integration with other DeFi protocols.
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.
You can explore some module implementations built by Arrakis here.
Admin and Security
Arrakis Modular employs a multi-layered security approach that combines proactive management, rapid response capabilities, and enforced delays on critical changes. The three core elements are the following:
- Arrakis Standard Manager: serves as the entry point for active management of both private and public vaults. It implements additional safety checks to ensure delegated LP management is secure and trustless. It also handles the configuration and collection of management fees.
-
Guardian: responsible for implementing a rushing pauser role that can quickly pause parts of the system in case of critical errors or vulnerabilities.
-
TimeLock: enforces a delay on changes to critical security parameters. This provides security guarantees for public Meta Vaults against compromised multisigs and malicious actors.
Routers
Arrakis Routers serve as crucial intermediaries that enhance security, improve user experience, and optimize gas usage. By providing a standardized entry point, routers can implement additional safety checks, simplify complex multi-step processes into single transactions, and enable gas-efficient operations through batching. Some of the implementations are the following:
- Public Meta Vault Router: streamlines the process of adding liquidity to ArrakisMetaVaultPublic instances. It integrates Permit2, a standardized token approval system, which enhances both security and user experience.
- Swap Executor: is a sub-component of the Public Meta Vault Router. Its primary role is to execute token swaps in a secure manner. This middleman contract is necessary to mitigate potential security risks associated with low-level, generic swap operations.
Guides
The following guides are intended for users and developers that wish to interact with Arrakis Modular directly at the smart contract level. They also serve as a comprehensive walkthrough for users curious about the implementation details of core elements of the protocol. The guides are composed by
- Quickstart: here we dive deep into the details behind the experience behind our UI, specifically we explain the
addLiquidity
andremoveLiquidity
flows.
Quickstart
In this guide we provide all the elements to participate in a Public Vault, built on top of Arrakis Modular. We explain how to use the Public Router to deposit and remove funds from a Public Vault.
Introduction
Public Vault Depositor
Depositors supply two-sided liquidity in the current asset ratio of the Public Vault, minting an ERC20 LP receipt token. The vault's LP receipt token represents a claim on a proportion of the underlying vault assets which are being supplied to a DEX liquidity pool under the hood. LP tokens have a claim on a fluctuating amount of the two deposited assets, since swappers trade against the tokens in the liquidity pool (given the rules and constraints of the pool). LP token holders can burn these tokens at any time, to execute the claim and receive back the corresponding share of the vault's underlying two tokens at that time.
The beauty of Arrakis Modular Public Vaults is that the specific complexities of a DEX (its interfaces, LP decision space, and quirks) are abstracted away from depositors and every Arrakis Modular Public Vault has a simple UniswapV2-style experience, where LPs only make decisions about when and how much liquidity to provide, and when and how much liquidity to withdraw. The rest is a black box to an uncurious depositor who does not need to know how the liquidity is actively managed or even what DEX the liquidity is being supplied to. They can simple track the value and asset composition of their LP token at every block and decide if they are happy with the returns of the portfolio.
Public Vault Owner
In Arrakis Modular, Public Vaults can only be created by whitelisted and thus trusted parties. The whitelisted vault creator initializes a new vault with its asset pair, initial module, initial management configuration, and a timelocked owner role who has sensitive powers to set and reset vault whitelisted module(s) and vault management configuration. For every Public Vault created, a corresponding Timelock contract is also deployed which immutably controls ownership functions. The transferrable owner role is set on this Timelock contract. Thus, a Public Vault owner has the power to adjust important and sensitive Vault parameters but these changes are guaranteed to be behind (at least) a 48 hour timelock.
This gives Public Vault depositors some time to react to vault parameter updates even in the worst case scenario (e.g. malicious Public Vault owner activity). In the future the whitelisted Public Vault creator role and timelocked Public Vault Owner role set on creation, would both be in the hands of the Arrakis DAO and controlled with onchain governance. As of today (15/10/2024) these roles are controlled by an Arrakis Multisig requiring 4 signatures.
Add Liquidity
As we explained in the previous section, depositors who wish to provide liquidity to a Public Meta Vault must do it with both tokens in the pool and in the current proportion of the reserves. To simplify this process and improve the user experience we have designed a Public Router. This contract is in charge of getting the right amounts and tokens to deposit. This is achieved by integrating with a swap aggregator and wrapping tokens when necessary. It also implements the Permit 2 standard for gassless approvals.
The following guide provides a step-by-step explanation of adding liquidity by uisng our router.
-
Identify the Meta Vault associated to the pair you want to participate in. See for example here for a full list of deployment addresses related to HOT AMM.
-
From now on, we use the Arrakis Public Router contract, defined here
ArrakisPublicVaultRouter.sol
-
Next step is to determine how many of each tokens are needed to join the Meta Vault. There are several options:
- Use
getMintAmounts
to determine the extact amounts oftoken0
andtoken1
to deposit. - If you own only one of the tokens, you can either swap on your own to match the amounts needed, or you can use the buil-in swap features in
ArrakisPublicVaultRouter
. In the latter, only one token needs to be authorized.
- Use
-
In order to set token transfer authorizations before depositing, there are two alternatives:
- Calling the standard ERC20
Approve
- Set up Permit2 data and signature
- Calling the standard ERC20
-
Now, in order to deposit into the pool there are multiple paths:
-
If you set up ERC20 approvals:
- Call
addLiquidity
to deposit both tokens to the vault. - If you have
ETH
and want to deposit into a pool withWETH
as one of its tokens, you can also callwrapAndAddLiquidity
. - If you have only one of the tokens in the pair, you can call
swapAndAddLiquidity
- If you only have
ETH
and want to deposit into a pool withWETH
as one of its tokens, you can callwrapAndSwapAndAddLiquidity
- Call
-
If you have set the correct Permit2 data and signature you should respectively call
addLiquidityPermit2
,wrapAndAddLiquidityPermit2
,swapAndAddLiquidityPermit2
orwrapAndSwapAndAddLiquidityPermit2
-
-
Once your deposit transaction goes through, you obtain ERC20 LP
shares
of the vault you are depositing to.
Remove Liquidity
Here we explain how to remove liquidity from a Meta Vault that you own LP shares of.
- Identify the Meta Vault address you want to exit, and verify it matches the address of your LP token. See for example here for a full list of deployment addresses related to HOT AMM.
- From now on, we use the Arrakis Public Router contract, defined here
ArrakisPublicVaultRouter.sol
- Approve the LP token amount you want to burn and convert in the underlying tokens by using the standard ERC20
Approve
. The approval must be toArrakisPublicVaultRouter
. Alternatively, you can set up Permit2 data and signature for a gasless approval transaction. - Prepare the
RemoveLiquidityData
- Depending on the approval type for the vault LP token, there are two paths:
- If you did an ERC20 approval, call
removeLiquidity
. - If you set up Permit2 Data and Signature, call
removeLiquidityPermit2
- You will receive
token0
andtoken1
amounts correspondig to the amount of shares burned.
Deployments
Arrakis Modular Smart Contracts are deployed on Mainnet, Arbitrum, Base and Sepolia.
Contract | Address |
---|---|
Arrakis Standard Manager | 0x2e6E879648293e939aA68bA4c6c129A1Be733bDA |
Arrakis TimeLock | 0xAf6f9640092cB1236E5DB6E517576355b6C40b7f |
Factory | 0x820FB8127a689327C863de8433278d6181123982 |
Private Vault NFT | 0x44A801e7E2E073bd8bcE4bCCf653239Fa156B762 |
Renderer Controller | 0x1Cc0Adff599F244f036a5C2425f646Aef884149D |
Guardian | 0x6F441151B478E0d60588f221f1A35BcC3f7aB981 |
Pauser* | 0x700a1cdA1495C1B34c4962e9742A8A8832aAc03A |
Public Registry | 0x791d75F87a701C3F7dFfcEC1B6094dB22c779603 |
Private Registry | 0xe278C1944BA3321C1079aBF94961E9fF1127A265 |
Public Router | 0x72aa2C8e6B14F30131081401Fa999fC964A66041 |
Router Executor | 0x19488620Cdf3Ff1B0784AC4529Fb5c5AbAceb1B6 |
Router Resolver | 0xC6c53369c36D6b4f4A6c195441Fe2d33149FB265 |
Valantis Public Module Implementation | 0x9Ac1249E37EE1bDc38dC0fF873F1dB0c5E6aDdE3 |
Valantis Private Module Implementation | 0x7E2fc9b2D37EA3E771b6F2375915b87CcA9E55bc |
* Not available on Sepolia
Technical reference
Getting Started
In order to run the test suite of Arrakis modular smart contracts, follow these steps:
- Clone the repository by running:
git clone https://github.com/ArrakisFinance/arrakis-modular.git
- Install the required submodules and compile the contracts by running:
forge build
- Create
.env
file using.envExample
as a reference. You can fill in your own alchemy api key (or a different RPC url altogether) - 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 abstractArrakisMetaVault.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 abstractArrakisMetaVault.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
abstract/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
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
Name | Type | Description |
---|---|---|
module_ | address | address 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
Name | Type | Description |
---|---|---|
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
Name | Type | Description |
---|---|---|
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
Name | Type | Description |
---|---|---|
modules | address[] | 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
Name | Type | Description |
---|---|---|
init0 | uint256 | the amount of token0 needed to open a position. |
init1 | uint256 | the 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
Name | Type | Description |
---|---|---|
amount0 | uint256 | the amount of token0 sitting on the position. |
amount1 | uint256 | 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 amount0, uint256 amount1);
Parameters
Name | Type | Description |
---|---|---|
priceX96_ | uint160 | price at which we want to simulate our tokens composition |
Returns
Name | Type | Description |
---|---|---|
amount0 | uint256 | the amount of token0 sitting on the position for priceX96. |
amount1 | uint256 | the 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
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
Name | Type | Description |
---|---|---|
newManager_ | address | address 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
Name | Type | Description |
---|---|---|
salt_ | bytes32 | bytes32 used to get a deterministic all chains address. |
token0_ | address | address of the first token of the token pair. |
token1_ | address | address of the second token of the token pair. |
owner_ | address | address of the owner of the vault. |
beacon_ | address | address of the beacon that will be used to create the default module. |
moduleCreationPayload_ | bytes | payload for initializing the module. |
initManagementPayload_ | bytes | data for initialize management. |
Returns
Name | Type | Description |
---|---|---|
vault | address | address 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
Name | Type | Description |
---|---|---|
salt_ | bytes32 | bytes32 needed to compute vault address deterministic way. |
token0_ | address | address of the first token of the token pair. |
token1_ | address | address of the second token of the token pair. |
owner_ | address | address of the owner of the vault. |
beacon_ | address | address of the beacon that will be used to create the default module. |
moduleCreationPayload_ | bytes | payload for initializing the module. |
initManagementPayload_ | bytes | data for initialize management. |
Returns
Name | Type | Description |
---|---|---|
vault | address | address 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
Name | Type | Description |
---|---|---|
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
Name | Type | Description |
---|---|---|
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
Name | Type | Description |
---|---|---|
token0_ | address | address of the first token. |
token1_ | address | address of the second token. |
Returns
Name | Type | Description |
---|---|---|
<none> | string | name 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
Name | Type | Description |
---|---|---|
startIndex_ | uint256 | start index |
endIndex_ | uint256 | end index |
Returns
Name | Type | Description |
---|---|---|
<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
Name | Type | Description |
---|---|---|
result | uint256 | total number of vaults deployed |
isPublicVault
isPublicVault check if the inputed vault is a public vault.
function isPublicVault(address vault_) external view returns (bool);
Parameters
Name | Type | Description |
---|---|---|
vault_ | address | address of the address to check. |
Returns
Name | Type | Description |
---|---|---|
<none> | bool | isPublicVault 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
Name | Type | Description |
---|---|---|
startIndex_ | uint256 | start index |
endIndex_ | uint256 | end index |
Returns
Name | Type | Description |
---|---|---|
<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
Name | Type | Description |
---|---|---|
result | uint256 | total number of vaults deployed |
isPrivateVault
isPrivateVault check if the inputed vault is a private vault.
function isPrivateVault(address vault_)
external
view
returns (bool);
Parameters
Name | Type | Description |
---|---|---|
vault_ | address | address of the address to check. |
Returns
Name | Type | Description |
---|---|---|
<none> | bool | isPublicVault 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);
Public Vaults
Content
ArrakisMetaVaultPublic
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
Name | Type | Description |
---|---|---|
shares_ | uint256 | amount representing the part of the position owned by receiver. |
receiver_ | address | address where share token will be sent. |
Returns
Name | Type | Description |
---|---|---|
amount0 | uint256 | amount of token0 deposited. |
amount1 | uint256 | amount 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
Name | Type | Description |
---|---|---|
shares_ | uint256 | amount of share that will be burn. |
receiver_ | address | address where underlying tokens will be sent. |
Returns
Name | Type | Description |
---|---|---|
amount0 | uint256 | amount of token0 withdrawn. |
amount1 | uint256 | amount 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
Name | Type | Description |
---|---|---|
<none> | string | name 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
Name | Type | Description |
---|---|---|
<none> | string | symbol 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
Inherits: ICreationCode
Functions
getCreationCode
function getCreationCode() external pure returns (bytes memory);
Private Vaults
ArrakisMetaVaultPrivate
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
Name | Type | Description |
---|---|---|
amount0_ | uint256 | amount of token0 need to increase the position by proportion_; |
amount1_ | uint256 | amount 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
Name | Type | Description |
---|---|---|
proportion_ | uint256 | the proportion of position contraction. |
receiver_ | address | the address that will receive withdrawn tokens. |
Returns
Name | Type | Description |
---|---|---|
amount0 | uint256 | amount of token0 returned. |
amount1 | uint256 | amount of token1 returned. |
whitelistDepositors
function used to whitelist depositors.
function whitelistDepositors(address[] calldata depositors_)
external
onlyOwnerCustom;
Parameters
Name | Type | Description |
---|---|---|
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
Name | Type | Description |
---|---|---|
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
Name | Type | Description |
---|---|---|
<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
Inherits: ICreationCode
Functions
getCreationCode
function getCreationCode() external pure returns (bytes memory);
PrivateVaultNFT
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
Name | Type | Description |
---|---|---|
to_ | address | address where to send the NFT. |
tokenId_ | uint256 | id 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
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
Name | Type | Description |
---|---|---|
renderer_ | address | address 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
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
Name | Type | Description |
---|---|---|
factory_ | address | address 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
Name | Type | Description |
---|---|---|
<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
Name | Type | Description |
---|---|---|
beacon_ | address | beacon address to check |
guardian
function used to get the guardian address of arrakis protocol.
function guardian() external view returns (address);
Returns
Name | Type | Description |
---|---|---|
<none> | address | guardian address of the pauser. |
whitelistBeacons
function used to whitelist IBeacon that contain implementation of valid module.
function whitelistBeacons(address[] calldata beacons_)
external
onlyOwner;
Parameters
Name | Type | Description |
---|---|---|
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
Name | Type | Description |
---|---|---|
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
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
Name | Type | Description |
---|---|---|
vault_ | address | |
beacon_ | address | which whitelisted beacon's implementation we want to create an instance of. |
payload_ | bytes | payload to create the module. |
ModulePrivateRegistry
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
Name | Type | Description |
---|---|---|
vault_ | address | |
beacon_ | address | which whitelisted beacon's implementation we want to create an instance of. |
payload_ | bytes | payload to create the module. |
Implementations
Content
ValantisModule
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
Name | Type | Description |
---|---|---|
pool_ | address | address of the valantis sovereign pool. |
init0_ | uint256 | initial amount of token0 to provide to valantis module. |
init1_ | uint256 | initial amount of token1 to provide to valantis module. |
maxSlippage_ | uint24 | allowed to manager for rebalancing the inventory using swap. |
metaVault_ | address | address 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
Name | Type | Description |
---|---|---|
data_ | bytes | bytes 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
Name | Type | Description |
---|---|---|
alm_ | address | address of the valantis HOT ALM. |
oracle_ | address | address 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
Name | Type | Description |
---|---|---|
receiver_ | address | address that will receive tokens. |
proportion_ | uint256 | the proportion of the total position that need to be withdrawn. |
Returns
Name | Type | Description |
---|---|---|
amount0 | uint256 | amount of token0 withdrawn. |
amount1 | uint256 | amount 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
Name | Type | Description |
---|---|---|
amount0 | uint256 | amount of token0 sent to manager. |
amount1 | uint256 | amount of token1 sent to manager. |
setManagerFeePIPS
function used to set manager fees.
function setManagerFeePIPS(uint256 newFeePIPS_)
external
whenNotPaused
onlyManager;
Parameters
Name | Type | Description |
---|---|---|
newFeePIPS_ | uint256 | new 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
Name | Type | Description |
---|---|---|
sqrtPriceLowX96_ | uint160 | lower bound of the range in sqrt price. |
sqrtPriceHighX96_ | uint160 | upper bound of the range in sqrt price. |
expectedSqrtSpotPriceUpperX96_ | uint160 | expected lower limit of current spot price (to prevent sandwich attack and manipulation). |
expectedSqrtSpotPriceLowerX96_ | uint160 | expected 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
Name | Type | Description |
---|---|---|
zeroForOne_ | bool | boolean if true token0->token1, if false token1->token0. |
expectedMinReturn_ | uint256 | minimum amount of tokenOut expected. |
amountIn_ | uint256 | amount of tokenIn used during swap. |
router_ | address | address of smart contract that will execute swap. |
expectedSqrtSpotPriceUpperX96_ | uint160 | upper bound of current price. |
expectedSqrtSpotPriceLowerX96_ | uint160 | lower bound of current price. |
payload_ | bytes | data 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
Name | Type | Description |
---|---|---|
fees0 | uint256 | 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 fees1);
Returns
Name | Type | Description |
---|---|---|
fees1 | uint256 | amount 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
Name | Type | Description |
---|---|---|
oracle_ | IOracleWrapper | onchain oracle to check the current amm price against. |
maxDeviation_ | uint24 | maximum deviation tolerated by management. |
managerFeePIPS
function used to get manager fees.
function managerFeePIPS() external view returns (uint256);
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | managerFeePIPS 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
Name | Type | Description |
---|---|---|
init0 | uint256 | the amount of token0 needed to open a position. |
init1 | uint256 | the 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
Name | Type | Description |
---|---|---|
<none> | uint256 | amount0 the amount of token0 sitting on the position. |
<none> | uint256 | amount1 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
Name | Type | Description |
---|---|---|
priceX96_ | uint160 | price at which we want to simulate our tokens composition |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | amount0 the amount of token0 sitting on the position for priceX96. |
<none> | uint256 | amount1 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
Name | Type | Description |
---|---|---|
<none> | address | guardian 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
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
Name | Type | Description |
---|---|---|
params_ | AddLiquidityData | AddLiquidityData struct containing data for adding liquidity |
Returns
Name | Type | Description |
---|---|---|
amount0 | uint256 | amount of token0 transferred from msg.sender to mint mintAmount |
amount1 | uint256 | amount of token1 transferred from msg.sender to mint mintAmount |
sharesReceived | uint256 | amount 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
Name | Type | Description |
---|---|---|
params_ | SwapAndAddData | SwapAndAddData struct containing data for swap |
Returns
Name | Type | Description |
---|---|---|
amount0 | uint256 | amount of token0 transferred from msg.sender to mint mintAmount |
amount1 | uint256 | amount of token1 transferred from msg.sender to mint mintAmount |
sharesReceived | uint256 | amount of public vault tokens transferred to receiver |
amount0Diff | uint256 | token0 balance difference post swap |
amount1Diff | uint256 | token1 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
Name | Type | Description |
---|---|---|
params_ | RemoveLiquidityData | RemoveLiquidityData struct containing data for withdrawals |
Returns
Name | Type | Description |
---|---|---|
amount0 | uint256 | actual amount of token0 transferred to receiver for burning burnAmount |
amount1 | uint256 | actual 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
Name | Type | Description |
---|---|---|
params_ | AddLiquidityPermit2Data | AddLiquidityPermit2Data struct containing data for adding liquidity |
Returns
Name | Type | Description |
---|---|---|
amount0 | uint256 | amount of token0 transferred from msg.sender to mint mintAmount |
amount1 | uint256 | amount of token1 transferred from msg.sender to mint mintAmount |
sharesReceived | uint256 | amount 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
Name | Type | Description |
---|---|---|
params_ | SwapAndAddPermit2Data | SwapAndAddPermit2Data struct containing data for swap |
Returns
Name | Type | Description |
---|---|---|
amount0 | uint256 | amount of token0 transferred from msg.sender to mint mintAmount |
amount1 | uint256 | amount of token1 transferred from msg.sender to mint mintAmount |
sharesReceived | uint256 | amount of public vault tokens transferred to receiver |
amount0Diff | uint256 | token0 balance difference post swap |
amount1Diff | uint256 | token1 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
Name | Type | Description |
---|---|---|
params_ | RemoveLiquidityPermit2Data | RemoveLiquidityPermit2Data struct containing data for withdrawals |
Returns
Name | Type | Description |
---|---|---|
amount0 | uint256 | actual amount of token0 transferred to receiver for burning burnAmount |
amount1 | uint256 | actual 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
Name | Type | Description |
---|---|---|
params_ | AddLiquidityData | AddLiquidityData struct containing data for adding liquidity |
Returns
Name | Type | Description |
---|---|---|
amount0 | uint256 | amount of token0 transferred from msg.sender to mint mintAmount |
amount1 | uint256 | amount of token1 transferred from msg.sender to mint mintAmount |
sharesReceived | uint256 | amount 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
Name | Type | Description |
---|---|---|
params_ | SwapAndAddData | SwapAndAddData struct containing data for swap |
Returns
Name | Type | Description |
---|---|---|
amount0 | uint256 | amount of token0 transferred from msg.sender to mint mintAmount |
amount1 | uint256 | amount of token1 transferred from msg.sender to mint mintAmount |
sharesReceived | uint256 | amount of public vault tokens transferred to receiver |
amount0Diff | uint256 | token0 balance difference post swap |
amount1Diff | uint256 | token1 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
Name | Type | Description |
---|---|---|
params_ | AddLiquidityPermit2Data | AddLiquidityPermit2Data struct containing data for adding liquidity |
Returns
Name | Type | Description |
---|---|---|
amount0 | uint256 | amount of token0 transferred from msg.sender to mint mintAmount |
amount1 | uint256 | amount of token1 transferred from msg.sender to mint mintAmount |
sharesReceived | uint256 | amount 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
Name | Type | Description |
---|---|---|
params_ | SwapAndAddPermit2Data | SwapAndAddPermit2Data struct containing data for swap |
Returns
Name | Type | Description |
---|---|---|
amount0 | uint256 | amount of token0 transferred from msg.sender to mint mintAmount |
amount1 | uint256 | amount of token1 transferred from msg.sender to mint mintAmount |
sharesReceived | uint256 | amount of public vault tokens transferred to receiver |
amount0Diff | uint256 | token0 balance difference post swap |
amount1Diff | uint256 | token1 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
Name | Type | Description |
---|---|---|
vault_ | address | meta vault address. |
maxAmount0_ | uint256 | maximum amount of token0 user want to contribute. |
maxAmount1_ | uint256 | maximum amount of token1 user want to contribute. |
Returns
Name | Type | Description |
---|---|---|
shareToMint | uint256 | maximum amount of share user can get for 'maxAmount0*' and 'maxAmount1*'. |
amount0ToDeposit | uint256 | amount of token0 user should deposit into the vault for minting 'shareToMint'. |
amount1ToDeposit | uint256 | amount 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
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
Name | Type | Description |
---|---|---|
params_ | SwapAndAddData | struct containing all the informations for swapping. |
Returns
Name | Type | Description |
---|---|---|
amount0Diff | uint256 | the difference in token0 amount before and after the swap. |
amount1Diff | uint256 | the difference in token1 amount before and after the swap. |
receive
receive() external payable;
RouterSwapResolver
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
- AddLiquidityPermit2Data
- RemoveLiquidityData
- RemoveLiquidityPermit2Data
- SwapAndAddData
- SwapAndAddPermit2Data
- SwapData
AddLiquidityData
struct AddLiquidityData {
uint256 amount0Max;
uint256 amount1Max;
uint256 amount0Min;
uint256 amount1Min;
uint256 amountSharesMin;
address vault;
address receiver;
}
Variables
Name | Type | Description |
---|---|---|
amount0Max | uint256 | Maximum amount of token0 to be transferred from msg.sender to the vault |
amount1Max | uint256 | Maximum amount of token1 to be transferred from msg.sender to the vault |
amount0Min | uint256 | Minimum amount of token0 to be transferred from msg.sender to the vault |
amount1Min | uint256 | Minimum amount of token1 to be transferred from msg.sender to the vault |
amountSharesMin | uint256 | Minimum amount of vault shares to be received by receiver |
vault | address | Address of the vault to add liquidity to |
receiver | address | Address of the receiver of the vault shares |
AddLiquidityPermit2Data
struct AddLiquidityPermit2Data {
AddLiquidityData addData;
PermitBatchTransferFrom permit;
bytes signature;
}
Variables
Name | Type | Description |
---|---|---|
addData | AddLiquidityData | AddLiquidityData struct containing data for adding liquidity |
permit | PermitBatchTransferFrom | PermitBatchTransferFrom struct containing Permit2 approvals information |
signature | bytes | Data containing the signature of msg.sender to verify by Permit2 |
RemoveLiquidityData
struct RemoveLiquidityData {
uint256 burnAmount;
uint256 amount0Min;
uint256 amount1Min;
address vault;
address payable receiver;
}
Variables
Name | Type | Description |
---|---|---|
burnAmount | uint256 | Amount of vault shares to be burned by msg.sender |
amount0Min | uint256 | Minimum amount of token0 to be send to receiver |
amount1Min | uint256 | Minimum amount of token1 to be send to receiver |
vault | address | Address of the vault to remove liquidity from |
receiver | payable address | Address of the receiver of token0 and token1 |
RemoveLiquidityPermit2Data
struct RemoveLiquidityPermit2Data {
RemoveLiquidityData removeData;
PermitTransferFrom permit;
bytes signature;
}
Variables
Name | Type | Description |
---|---|---|
removeData | RemoveLiquidityData | RemoveLiquidityData struct containing data for removing liquidity |
permit | PermitTransferFrom | PermitTransferFrom struct of a signature containing Permit2 approval for vault token |
signature | bytes | Data containing the signature of msg.sender to verify by Permit2 |
SwapAndAddData
struct SwapAndAddData {
SwapData swapData;
AddLiquidityData addData;
}
Variables
Name | Type | Description |
---|---|---|
swapData | SwapData | SwapData struct containing data for swapping one of the tokens for the other |
addData | AddLiquidityData | AddLiquidityData struct containing data for adding liquidity |
SwapAndAddPermit2Data
struct SwapAndAddPermit2Data {
SwapAndAddData swapAndAddData;
PermitBatchTransferFrom permit;
bytes signature;
}
Name | Type | Description |
---|---|---|
swapAndAddData | SwapAndAddData | SwapAndAddData struct containing data for swapping one of the tokens for the other and adding liquidity |
permit | PermitBatchTransferFrom | PermitBatchTransferFrom struct of signatures containing Permit2 approvals |
signature | bytes | Data containing the signature of msg.sender to verify by Permit2 |
SwapData
struct SwapData {
bytes swapPayload;
uint256 amountInSwap;
uint256 amountOutSwap;
address swapRouter;
bool zeroForOne;
}
Variables
Name | Type | Description |
---|---|---|
swapPayload | bytes | Payload to use for a swap in an external venue. Transaction must be atomic |
amountInSwap | uint256 | Amount of token to be swapped |
amountOutSwap | uint256 | Minimum amount of the other token to be received from the swap |
swapRouter | address | Address of the router to be used for the swap |
zeroForOne | bool | Boolean to determine the direction of the swap. If true swaps token0 for token1 and viceversa |
Admin and Security
Content
ArrakisStandardManager
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
Name | Type | Description |
---|---|---|
owner_ | address | address of the owner of standard manager. |
defaultReceiver_ | address | address of the receiver of tokens (by default). |
factory_ | address | ArrakisMetaVaultFactory 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
Name | Type | Description |
---|---|---|
newDefaultReceiver_ | address | address 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
Name | Type | Description |
---|---|---|
vault_ | address | address of the meta vault that contain the specific token. |
isSetReceiverToken0_ | bool | boolean if true means that receiver is for token0 if not it's for token1. |
receiver_ | address | address 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
Name | Type | Description |
---|---|---|
vault_ | address | address of the vault. |
newFeePIPS_ | uint24 | fees 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
Name | Type | Description |
---|---|---|
vault_ | address | address 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
Name | Type | Description |
---|---|---|
vault_ | address | address of the vault where fees will be increase after timeLock. |
newFeePIPS_ | uint24 | fees 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
Name | Type | Description |
---|---|---|
vault_ | address | from which fees will be collected. |
Returns
Name | Type | Description |
---|---|---|
amount0 | uint256 | amount of token0 sent to receiver_ |
amount1 | uint256 | amount 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
Name | Type | Description |
---|---|---|
vault_ | address | address 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
Name | Type | Description |
---|---|---|
vault_ | address | address of the vault the manager want to change module. |
module_ | address | address 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
Name | Type | Description |
---|---|---|
params_ | SetupParams | struct 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
Name | Type | Description |
---|---|---|
params_ | SetupParams | struct 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
Name | Type | Description |
---|---|---|
vault_ | address | address of arrakis meta vault that will follow the strategy. |
strategy_ | string | string 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
Name | Type | Description |
---|---|---|
startIndex_ | uint256 | starting index from which the caller want to read the array of managed vaults. |
endIndex_ | uint256 | ending 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
Name | Type | Description |
---|---|---|
<none> | address | pauser 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
Name | Type | Description |
---|---|---|
vault_ | address | address of the meta vault the caller want to check. |
Returns
Name | Type | Description |
---|---|---|
<none> | bool | isManaged 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;
Guardian
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
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
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
- abstracts
- constants
- hooks
- interfaces
- modules
- structs
- utils
- ArrakisMetaVaultFactory
- ArrakisMetaVaultPrivate
- ArrakisMetaVaultPublic
- ArrakisPublicVaultRouter
- ArrakisStandardManager
- CreationCodePrivateVault
- CreationCodePublicVault
- Guardian
- ModulePrivateRegistry
- ModulePublicRegistry
- Pauser
- PrivateVaultNFT
- RenderController
- RouterSwapExecutor
- RouterSwapResolver
- TimeLock
Contents
ArrakisMetaVault
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
Name | Type | Description |
---|---|---|
module_ | address | address 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
Name | Type | Description |
---|---|---|
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
Name | Type | Description |
---|---|---|
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
Name | Type | Description |
---|---|---|
modules | address[] | 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
Name | Type | Description |
---|---|---|
init0 | uint256 | the amount of token0 needed to open a position. |
init1 | uint256 | the 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
Name | Type | Description |
---|---|---|
amount0 | uint256 | the amount of token0 sitting on the position. |
amount1 | uint256 | 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 amount0, uint256 amount1);
Parameters
Name | Type | Description |
---|---|---|
priceX96_ | uint160 | price at which we want to simulate our tokens composition |
Returns
Name | Type | Description |
---|---|---|
amount0 | uint256 | the amount of token0 sitting on the position for priceX96. |
amount1 | uint256 | the 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
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
Name | Type | Description |
---|---|---|
factory_ | address | address 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
Name | Type | Description |
---|---|---|
<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
Name | Type | Description |
---|---|---|
beacon_ | address | beacon address to check |
guardian
function used to get the guardian address of arrakis protocol.
function guardian() external view returns (address);
Returns
Name | Type | Description |
---|---|---|
<none> | address | guardian address of the pauser. |
whitelistBeacons
function used to whitelist IBeacon that contain implementation of valid module.
function whitelistBeacons(address[] calldata beacons_)
external
onlyOwner;
Parameters
Name | Type | Description |
---|---|---|
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
Name | Type | Description |
---|---|---|
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
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
Name | Type | Description |
---|---|---|
pool_ | address | address of the valantis sovereign pool. |
init0_ | uint256 | initial amount of token0 to provide to valantis module. |
init1_ | uint256 | initial amount of token1 to provide to valantis module. |
maxSlippage_ | uint24 | allowed to manager for rebalancing the inventory using swap. |
metaVault_ | address | address 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
Name | Type | Description |
---|---|---|
data_ | bytes | bytes 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
Name | Type | Description |
---|---|---|
alm_ | address | address of the valantis HOT ALM. |
oracle_ | address | address 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
Name | Type | Description |
---|---|---|
receiver_ | address | address that will receive tokens. |
proportion_ | uint256 | the proportion of the total position that need to be withdrawn. |
Returns
Name | Type | Description |
---|---|---|
amount0 | uint256 | amount of token0 withdrawn. |
amount1 | uint256 | amount 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
Name | Type | Description |
---|---|---|
amount0 | uint256 | amount of token0 sent to manager. |
amount1 | uint256 | amount of token1 sent to manager. |
setManagerFeePIPS
function used to set manager fees.
function setManagerFeePIPS(uint256 newFeePIPS_)
external
whenNotPaused
onlyManager;
Parameters
Name | Type | Description |
---|---|---|
newFeePIPS_ | uint256 | new 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
Name | Type | Description |
---|---|---|
sqrtPriceLowX96_ | uint160 | lower bound of the range in sqrt price. |
sqrtPriceHighX96_ | uint160 | upper bound of the range in sqrt price. |
expectedSqrtSpotPriceUpperX96_ | uint160 | expected lower limit of current spot price (to prevent sandwich attack and manipulation). |
expectedSqrtSpotPriceLowerX96_ | uint160 | expected 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
Name | Type | Description |
---|---|---|
zeroForOne_ | bool | boolean if true token0->token1, if false token1->token0. |
expectedMinReturn_ | uint256 | minimum amount of tokenOut expected. |
amountIn_ | uint256 | amount of tokenIn used during swap. |
router_ | address | address of smart contract that will execute swap. |
expectedSqrtSpotPriceUpperX96_ | uint160 | upper bound of current price. |
expectedSqrtSpotPriceLowerX96_ | uint160 | lower bound of current price. |
payload_ | bytes | data 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
Name | Type | Description |
---|---|---|
fees0 | uint256 | 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 fees1);
Returns
Name | Type | Description |
---|---|---|
fees1 | uint256 | amount 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
Name | Type | Description |
---|---|---|
oracle_ | IOracleWrapper | onchain oracle to check the current amm price against. |
maxDeviation_ | uint24 | maximum deviation tolerated by management. |
managerFeePIPS
function used to get manager fees.
function managerFeePIPS() external view returns (uint256);
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | managerFeePIPS 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
Name | Type | Description |
---|---|---|
init0 | uint256 | the amount of token0 needed to open a position. |
init1 | uint256 | the 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
Name | Type | Description |
---|---|---|
<none> | uint256 | amount0 the amount of token0 sitting on the position. |
<none> | uint256 | amount1 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
Name | Type | Description |
---|---|---|
priceX96_ | uint160 | price at which we want to simulate our tokens composition |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | amount0 the amount of token0 sitting on the position for priceX96. |
<none> | uint256 | amount1 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
Name | Type | Description |
---|---|---|
<none> | address | guardian 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
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
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
Name | Type | Description |
---|---|---|
sender | address | The 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
Name | Type | Description |
---|---|---|
sender | address | The 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
- IArrakisLPModule
- IArrakisLPModuleID
- IArrakisLPModulePrivate
- IArrakisLPModulePublic
- IArrakisMetaVault
- IArrakisMetaVaultFactory
- IArrakisMetaVaultPrivate
- IArrakisMetaVaultPublic
- IArrakisPrivateHook
- IArrakisPublicVaultRouter
- IArrakisStandardManager
- IBunkerModule
- ICreationCode
- IGuardian
- IHOTExecutor
- IManager
- IModulePrivateRegistry
- IModulePublicRegistry
- IModuleRegistry
- IOracleWrapper
- IOwnable
- IPausable
- IPauser
- IPermit2
- IPrivateVaultNFT
- IRenderController
- IResolver
- IRouterSwapExecutor
- IRouterSwapResolver
- ISovereignPool
- ITimeLock
- IValantisHOTModule
- IWETH9
AggregatorV3Interface
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
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
Name | Type | Description |
---|---|---|
data_ | bytes | bytes 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
Name | Type | Description |
---|---|---|
receiver_ | address | address that will receive tokens. |
proportion_ | uint256 | the proportion of the total position that need to be withdrawn. |
Returns
Name | Type | Description |
---|---|---|
amount0 | uint256 | amount of token0 withdrawn. |
amount1 | uint256 | amount of token1 withdrawn. |
withdrawManagerBalance
function used by metaVault or manager to get manager fees.
function withdrawManagerBalance()
external
returns (uint256 amount0, uint256 amount1);
Returns
Name | Type | Description |
---|---|---|
amount0 | uint256 | amount of token0 sent to manager. |
amount1 | uint256 | amount of token1 sent to manager. |
setManagerFeePIPS
function used to set manager fees.
function setManagerFeePIPS(uint256 newFeePIPS_) external;
Parameters
Name | Type | Description |
---|---|---|
newFeePIPS_ | uint256 | new fee that will be applied. |
metaVault
function used to get metaVault as IArrakisMetaVault.
function metaVault() external view returns (IArrakisMetaVault);
Returns
Name | Type | Description |
---|---|---|
<none> | IArrakisMetaVault | metaVault that implement IArrakisMetaVault. |
guardian
function used to get the address that can pause the module.
function guardian() external view returns (address);
Returns
Name | Type | Description |
---|---|---|
<none> | address | guardian 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
Name | Type | Description |
---|---|---|
<none> | uint256 | managerBalance0 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
Name | Type | Description |
---|---|---|
<none> | uint256 | managerBalance1 amount of token1 that manager earned. |
managerFeePIPS
function used to get manager fees.
function managerFeePIPS() external view returns (uint256);
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | managerFeePIPS amount of token1 that manager earned. |
token0
function used to get token0 as IERC20Metadata.
function token0() external view returns (IERC20Metadata);
Returns
Name | Type | Description |
---|---|---|
<none> | IERC20Metadata | token0 as IERC20Metadata. |
token1
function used to get token1 as IERC20Metadata.
function token1() external view returns (IERC20Metadata);
Returns
Name | Type | Description |
---|---|---|
<none> | IERC20Metadata | token1 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
Name | Type | Description |
---|---|---|
init0 | uint256 | the amount of token0 needed to open a position. |
init1 | uint256 | the 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
Name | Type | Description |
---|---|---|
amount0 | uint256 | the amount of token0 sitting on the position. |
amount1 | uint256 | 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 amount0, uint256 amount1);
Parameters
Name | Type | Description |
---|---|---|
priceX96_ | uint160 | price at which we want to simulate our tokens composition |
Returns
Name | Type | Description |
---|---|---|
amount0 | uint256 | the amount of token0 sitting on the position for priceX96. |
amount1 | uint256 | the 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
Name | Type | Description |
---|---|---|
oracle_ | IOracleWrapper | oracle that will used to check internal state. |
maxDeviation_ | uint24 | maximum 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
Name | Type | Description |
---|---|---|
receiver | address | address that will receive the tokens withdrawn. |
proportion | uint256 | percentage of the current position that user want to withdraw. |
amount0 | uint256 | amount of token0 send to "receiver" due to withdraw action. |
amount1 | uint256 | amount 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
Name | Type | Description |
---|---|---|
manager | address | address of the manager that will fees earned due to his fund management. |
amount0 | uint256 | amount of token0 that manager has earned and will be transfered. |
amount1 | uint256 | amount of token1 that manager has earned and will be transfered. |
LogSetManagerFeePIPS
Event describing manager set his fees.
event LogSetManagerFeePIPS(uint256 oldFee, uint256 newFee);
Parameters
Name | Type | Description |
---|---|---|
oldFee | uint256 | fees share that have been taken by manager. |
newFee | uint256 | fees 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
Functions
id
function id() external view returns (bytes32);
IArrakisLPModulePrivate
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
Name | Type | Description |
---|---|---|
depositor_ | address | address that will provide the tokens. |
amount0_ | uint256 | amount of token0 that depositor want to send to module. |
amount1_ | uint256 | amount 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
Name | Type | Description |
---|---|---|
depositor | address | address that are sending the tokens, the owner. |
amount0 | uint256 | amount of token0 sent by depositor. |
amount1 | uint256 | amount of token1 sent by depositor. |
Errors
DepositZero
error DepositZero();
IArrakisLPModulePublic
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
Name | Type | Description |
---|---|---|
depositor_ | address | address that will provide the tokens. |
proportion_ | uint256 | percentage of portfolio position vault want to expand. |
Returns
Name | Type | Description |
---|---|---|
amount0 | uint256 | amount of token0 needed to expand the portfolio by "proportion" percent. |
amount1 | uint256 | amount 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
Name | Type | Description |
---|---|---|
depositor | address | address of the tokens provider. |
proportion | uint256 | percentage of the current position that depositor want to increase. |
amount0 | uint256 | amount of token0 needed to increase the portfolio of "proportion" percent. |
amount1 | uint256 | amount of token1 needed to increase the portfolio of "proportion" percent. |
IArrakisMetaVault
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
Name | Type | Description |
---|---|---|
module_ | address | address of the default module. |
setModule
function used to set module
function setModule(
address module_,
bytes[] calldata payloads_
) external;
Parameters
Name | Type | Description |
---|---|---|
module_ | address | address 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
Name | Type | Description |
---|---|---|
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
Name | Type | Description |
---|---|---|
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
Name | Type | Description |
---|---|---|
modules | address[] | 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
Name | Type | Description |
---|---|---|
amount0 | uint256 | the amount of token0 sitting on the position. |
amount1 | uint256 | 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 amount0, uint256 amount1);
Parameters
Name | Type | Description |
---|---|---|
priceX96 | uint160 | price at which we want to simulate our tokens composition |
Returns
Name | Type | Description |
---|---|---|
amount0 | uint256 | the amount of token0 sitting on the position for priceX96. |
amount1 | uint256 | the 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
Name | Type | Description |
---|---|---|
init0 | uint256 | the amount of token0 needed to open a position. |
init1 | uint256 | the 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
Name | Type | Description |
---|---|---|
registry | address | address of module registry. |
Events
LogWithdrawManagerBalance
Event describing a manager fee withdrawal.
event LogWithdrawManagerBalance(uint256 amount0, uint256 amount1);
Parameters
Name | Type | Description |
---|---|---|
amount0 | uint256 | amount of token0 that manager has earned and will be transfered. |
amount1 | uint256 | amount of token1 that manager has earned and will be transfered. |
LogSetManager
Event describing owner setting the manager.
event LogSetManager(address manager);
Parameters
Name | Type | Description |
---|---|---|
manager | address | address of manager that will manage the portfolio. |
LogSetModule
Event describing manager setting the module.
event LogSetModule(address module, bytes[] payloads);
Parameters
Name | Type | Description |
---|---|---|
module | address | address of the new active module. |
payloads | bytes[] | 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
Name | Type | Description |
---|---|---|
module | address | address of the default module. |
LogWhiteListedModules
Event describing list of modules that has been whitelisted by owner.
event LogWhiteListedModules(address[] modules);
Parameters
Name | Type | Description |
---|---|---|
modules | address[] | 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
Name | Type | Description |
---|---|---|
module | address | default activation. |
LogBlackListedModules
Event describing blacklisting action of modules by owner.
event LogBlackListedModules(address[] modules);
Parameters
Name | Type | Description |
---|---|---|
modules | address[] | 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
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
Name | Type | Description |
---|---|---|
newManager_ | address | address 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
Name | Type | Description |
---|---|---|
salt_ | bytes32 | bytes32 used to get a deterministic all chains address. |
token0_ | address | address of the first token of the token pair. |
token1_ | address | address of the second token of the token pair. |
owner_ | address | address of the owner of the vault. |
beacon_ | address | address of the beacon that will be used to create the default module. |
moduleCreationPayload_ | bytes | payload for initializing the module. |
initManagementPayload_ | bytes | data for initialize management. |
Returns
Name | Type | Description |
---|---|---|
vault | address | address 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
Name | Type | Description |
---|---|---|
salt_ | bytes32 | bytes32 needed to compute vault address deterministic way. |
token0_ | address | address of the first token of the token pair. |
token1_ | address | address of the second token of the token pair. |
owner_ | address | address of the owner of the vault. |
beacon_ | address | address of the beacon that will be used to create the default module. |
moduleCreationPayload_ | bytes | payload for initializing the module. |
initManagementPayload_ | bytes | data for initialize management. |
Returns
Name | Type | Description |
---|---|---|
vault | address | address 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
Name | Type | Description |
---|---|---|
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
Name | Type | Description |
---|---|---|
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
Name | Type | Description |
---|---|---|
token0_ | address | address of the first token. |
token1_ | address | address of the second token. |
Returns
Name | Type | Description |
---|---|---|
<none> | string | name 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
Name | Type | Description |
---|---|---|
startIndex_ | uint256 | start index |
endIndex_ | uint256 | end index |
Returns
Name | Type | Description |
---|---|---|
<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
Name | Type | Description |
---|---|---|
result | uint256 | total number of vaults deployed |
isPublicVault
isPublicVault check if the inputed vault is a public vault.
function isPublicVault(address vault_) external view returns (bool);
Parameters
Name | Type | Description |
---|---|---|
vault_ | address | address of the address to check. |
Returns
Name | Type | Description |
---|---|---|
<none> | bool | isPublicVault 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
Name | Type | Description |
---|---|---|
startIndex_ | uint256 | start index |
endIndex_ | uint256 | end index |
Returns
Name | Type | Description |
---|---|---|
<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
Name | Type | Description |
---|---|---|
result | uint256 | total number of vaults deployed |
isPrivateVault
isPrivateVault check if the inputed vault is a private vault.
function isPrivateVault(address vault_)
external
view
returns (bool);
Parameters
Name | Type | Description |
---|---|---|
vault_ | address | address of the address to check. |
Returns
Name | Type | Description |
---|---|---|
<none> | bool | isPublicVault 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
Name | Type | Description |
---|---|---|
<none> | address | manager 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
Name | Type | Description |
---|---|---|
creator | address | address that is creating the public vault, a deployer. |
salt | bytes32 | salt used for create3. |
token0 | address | first token of the token pair. |
token1 | address | second token of the token pair. |
owner | address | address of the owner. |
module | address | default module that will be used by the meta vault. |
publicVault | address | address of the deployed meta vault. |
timeLock | address | timeLock 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
Name | Type | Description |
---|---|---|
creator | address | address that is deploying the vault. |
salt | bytes32 | salt used for create3. |
token0 | address | address of the first token of the pair. |
token1 | address | address of the second token of the pair. |
owner | address | address that will owned the private vault. |
module | address | address of the default module. |
privateVault | address | address of the deployed meta vault. |
LogWhitelistDeployers
event emitted when whitelisting an array of public vault deployers.
event LogWhitelistDeployers(address[] deployers);
Parameters
Name | Type | Description |
---|---|---|
deployers | address[] | list of deployers added to the whitelist. |
LogBlacklistDeployers
event emitted when blacklisting an array of public vault deployers.
event LogBlacklistDeployers(address[] deployers);
Parameters
Name | Type | Description |
---|---|---|
deployers | address[] | list of deployers removed from the whitelist. |
LogSetManager
event emitted when owner set a new manager.
event LogSetManager(address oldManager, address newManager);
Parameters
Name | Type | Description |
---|---|---|
oldManager | address | address of the previous manager. |
newManager | address | address 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
Functions
deposit
function used to deposit tokens or expand position inside the inherent strategy.
function deposit(
uint256 amount0_,
uint256 amount1_
) external payable;
Parameters
Name | Type | Description |
---|---|---|
amount0_ | uint256 | amount of token0 need to increase the position by proportion_; |
amount1_ | uint256 | amount 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
Name | Type | Description |
---|---|---|
proportion_ | uint256 | the proportion of position contraction. |
receiver_ | address | the address that will receive withdrawn tokens. |
Returns
Name | Type | Description |
---|---|---|
amount0 | uint256 | amount of token0 returned. |
amount1 | uint256 | amount of token1 returned. |
whitelistDepositors
function used to whitelist depositors.
function whitelistDepositors(address[] calldata depositors_)
external;
Parameters
Name | Type | Description |
---|---|---|
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
Name | Type | Description |
---|---|---|
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
Name | Type | Description |
---|---|---|
<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
Name | Type | Description |
---|---|---|
amount0 | uint256 | amount of token0 needed to increase the portfolio of "proportion" percent. |
amount1 | uint256 | amount 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
Name | Type | Description |
---|---|---|
proportion | uint256 | percentage of the current position that user want to withdraw. |
amount0 | uint256 | amount of token0 withdrawn due to withdraw action. |
amount1 | uint256 | amount of token1 withdrawn due to withdraw action. |
LogWhitelistDepositors
Event describing the whitelist of fund depositor.
event LogWhitelistDepositors(address[] depositors);
Parameters
Name | Type | Description |
---|---|---|
depositors | address[] | list of address that are granted to depositor role. |
LogBlacklistDepositors
Event describing the blacklist of fund depositor.
event LogBlacklistDepositors(address[] depositors);
Parameters
Name | Type | Description |
---|---|---|
depositors | address[] | 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
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
Name | Type | Description |
---|---|---|
shares_ | uint256 | amount representing the part of the position owned by receiver. |
receiver_ | address | address where share token will be sent. |
Returns
Name | Type | Description |
---|---|---|
amount0 | uint256 | amount of token0 deposited. |
amount1 | uint256 | amount 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
Name | Type | Description |
---|---|---|
shares_ | uint256 | amount of share that will be burn. |
receiver_ | address | address where underlying tokens will be sent. |
Returns
Name | Type | Description |
---|---|---|
amount0 | uint256 | amount of token0 withdrawn. |
amount1 | uint256 | amount 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
Name | Type | Description |
---|---|---|
shares | uint256 | amount of shares minted. |
receiver | address | address that will receive the LP token (shares). |
amount0 | uint256 | amount of token0 needed to mint shares. |
amount1 | uint256 | amount 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
Name | Type | Description |
---|---|---|
shares | uint256 | amount of share burned by the user. |
receiver | address | address that will receive amounts of tokens related to burning the shares. |
amount0 | uint256 | amount of token0 that is collected from burning shares. |
amount1 | uint256 | amount of token1 that is collected from burning shares. |
Errors
MintZero
error MintZero();
BurnZero
error BurnZero();
IArrakisPrivateHook
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
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
Name | Type | Description |
---|---|---|
params_ | AddLiquidityData | AddLiquidityData struct containing data for adding liquidity |
Returns
Name | Type | Description |
---|---|---|
amount0 | uint256 | amount of token0 transferred from msg.sender to mint mintAmount |
amount1 | uint256 | amount of token1 transferred from msg.sender to mint mintAmount |
sharesReceived | uint256 | amount 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
Name | Type | Description |
---|---|---|
params_ | SwapAndAddData | SwapAndAddData struct containing data for swap |
Returns
Name | Type | Description |
---|---|---|
amount0 | uint256 | amount of token0 transferred from msg.sender to mint mintAmount |
amount1 | uint256 | amount of token1 transferred from msg.sender to mint mintAmount |
sharesReceived | uint256 | amount of public vault tokens transferred to receiver |
amount0Diff | uint256 | token0 balance difference post swap |
amount1Diff | uint256 | token1 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
Name | Type | Description |
---|---|---|
params_ | RemoveLiquidityData | RemoveLiquidityData struct containing data for withdrawals |
Returns
Name | Type | Description |
---|---|---|
amount0 | uint256 | actual amount of token0 transferred to receiver for burning burnAmount |
amount1 | uint256 | actual 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
Name | Type | Description |
---|---|---|
params_ | AddLiquidityPermit2Data | AddLiquidityPermit2Data struct containing data for adding liquidity |
Returns
Name | Type | Description |
---|---|---|
amount0 | uint256 | amount of token0 transferred from msg.sender to mint mintAmount |
amount1 | uint256 | amount of token1 transferred from msg.sender to mint mintAmount |
sharesReceived | uint256 | amount 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
Name | Type | Description |
---|---|---|
params_ | SwapAndAddPermit2Data | SwapAndAddPermit2Data struct containing data for swap |
Returns
Name | Type | Description |
---|---|---|
amount0 | uint256 | amount of token0 transferred from msg.sender to mint mintAmount |
amount1 | uint256 | amount of token1 transferred from msg.sender to mint mintAmount |
sharesReceived | uint256 | amount of public vault tokens transferred to receiver |
amount0Diff | uint256 | token0 balance difference post swap |
amount1Diff | uint256 | token1 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
Name | Type | Description |
---|---|---|
params_ | RemoveLiquidityPermit2Data | RemoveLiquidityPermit2Data struct containing data for withdrawals |
Returns
Name | Type | Description |
---|---|---|
amount0 | uint256 | actual amount of token0 transferred to receiver for burning burnAmount |
amount1 | uint256 | actual 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
Name | Type | Description |
---|---|---|
params_ | AddLiquidityData | AddLiquidityData struct containing data for adding liquidity |
Returns
Name | Type | Description |
---|---|---|
amount0 | uint256 | amount of token0 transferred from msg.sender to mint mintAmount |
amount1 | uint256 | amount of token1 transferred from msg.sender to mint mintAmount |
sharesReceived | uint256 | amount 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
Name | Type | Description |
---|---|---|
params_ | SwapAndAddData | SwapAndAddData struct containing data for swap |
Returns
Name | Type | Description |
---|---|---|
amount0 | uint256 | amount of token0 transferred from msg.sender to mint mintAmount |
amount1 | uint256 | amount of token1 transferred from msg.sender to mint mintAmount |
sharesReceived | uint256 | amount of public vault tokens transferred to receiver |
amount0Diff | uint256 | token0 balance difference post swap |
amount1Diff | uint256 | token1 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
Name | Type | Description |
---|---|---|
params_ | AddLiquidityPermit2Data | AddLiquidityPermit2Data struct containing data for adding liquidity |
Returns
Name | Type | Description |
---|---|---|
amount0 | uint256 | amount of token0 transferred from msg.sender to mint mintAmount |
amount1 | uint256 | amount of token1 transferred from msg.sender to mint mintAmount |
sharesReceived | uint256 | amount 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
Name | Type | Description |
---|---|---|
params_ | SwapAndAddPermit2Data | SwapAndAddPermit2Data struct containing data for swap |
Returns
Name | Type | Description |
---|---|---|
amount0 | uint256 | amount of token0 transferred from msg.sender to mint mintAmount |
amount1 | uint256 | amount of token1 transferred from msg.sender to mint mintAmount |
sharesReceived | uint256 | amount of public vault tokens transferred to receiver |
amount0Diff | uint256 | token0 balance difference post swap |
amount1Diff | uint256 | token1 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
Name | Type | Description |
---|---|---|
vault_ | address | meta vault address. |
maxAmount0_ | uint256 | maximum amount of token0 user want to contribute. |
maxAmount1_ | uint256 | maximum amount of token1 user want to contribute. |
Returns
Name | Type | Description |
---|---|---|
shareToMint | uint256 | maximum amount of share user can get for 'maxAmount0*' and 'maxAmount1*'. |
amount0ToDeposit | uint256 | amount of token0 user should deposit into the vault for minting 'shareToMint'. |
amount1ToDeposit | uint256 | amount 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
Name | Type | Description |
---|---|---|
zeroForOne | bool | boolean indicating if we are swap token0 to token1 or the inverse. |
amount0Diff | uint256 | amount of token0 get or consumed by the swap. |
amount1Diff | uint256 | amount of token1 get or consumed by the swap. |
amountOutSwap | uint256 | minimum 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
Functions
initialize
function used to initialize standard manager proxy.
function initialize(
address owner_,
address defaultReceiver_,
address factory_
) external;
Parameters
Name | Type | Description |
---|---|---|
owner_ | address | address of the owner of standard manager. |
defaultReceiver_ | address | address of the receiver of tokens (by default). |
factory_ | address | ArrakisMetaVaultFactory 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
Name | Type | Description |
---|---|---|
newDefaultReceiver_ | address | address 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
Name | Type | Description |
---|---|---|
vault_ | address | address of the meta vault that contain the specific token. |
isSetReceiverToken0_ | bool | boolean if true means that receiver is for token0 if not it's for token1. |
receiver_ | address | address 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
Name | Type | Description |
---|---|---|
vault_ | address | address of the vault. |
newFeePIPS_ | uint24 | fees 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
Name | Type | Description |
---|---|---|
vault_ | address | address 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
Name | Type | Description |
---|---|---|
vault_ | address | address of the vault where fees will be increase after timeLock. |
newFeePIPS_ | uint24 | fees 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
Name | Type | Description |
---|---|---|
vault_ | address | from which fees will be collected. |
Returns
Name | Type | Description |
---|---|---|
amount0 | uint256 | amount of token0 sent to receiver_ |
amount1 | uint256 | amount of token1 sent to receiver_ |
rebalance
function used to manage vault's strategy.
function rebalance(
address vault_,
bytes[] calldata payloads_
) external;
Parameters
Name | Type | Description |
---|---|---|
vault_ | address | address 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
Name | Type | Description |
---|---|---|
vault_ | address | address of the vault the manager want to change module. |
module_ | address | address 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
Name | Type | Description |
---|---|---|
params_ | SetupParams | struct containing all the data for initialize the vault. |
updateVaultInfo
function used to update meta vault management informations.
function updateVaultInfo(SetupParams calldata params_) external;
Parameters
Name | Type | Description |
---|---|---|
params_ | SetupParams | struct 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
Name | Type | Description |
---|---|---|
vault_ | address | address of arrakis meta vault that will follow the strategy. |
strategy_ | string | string 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
Name | Type | Description |
---|---|---|
startIndex_ | uint256 | starting index from which the caller want to read the array of managed vaults. |
endIndex_ | uint256 | ending 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
Name | Type | Description |
---|---|---|
<none> | address | pauser address that can pause/unpause manager. |
factory
address of the vault factory.
function factory() external view returns (address);
Returns
Name | Type | Description |
---|---|---|
<none> | address | factory 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
Name | Type | Description |
---|---|---|
<none> | uint256 | defaultFeePIPS amount of default fees. |
nativeToken
function used to get the native token/coin of the chain.
function nativeToken() external view returns (address);
Returns
Name | Type | Description |
---|---|---|
<none> | address | nativeToken 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
Name | Type | Description |
---|---|---|
<none> | uint8 | nativeTokenDecimals 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
Name | Type | Description |
---|---|---|
<none> | address | defaultReceiver 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
Name | Type | Description |
---|---|---|
token_ | address | address of the ERC20 token that we want the receiver of |
Returns
Name | Type | Description |
---|---|---|
receiver | address | address 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
Name | Type | Description |
---|---|---|
vault_ | address | address of the metaVault. |
Returns
Name | Type | Description |
---|---|---|
lastRebalance | uint256 | timestamp when the last rebalance happen. |
cooldownPeriod | uint256 | minimum duration between two rebalance. |
oracle | IOracleWrapper | oracle used to check against price manipulation. |
maxDeviation | uint24 | maximum deviation from oracle price allowed. |
executor | address | address that can trigger a rebalance. |
stratAnnouncer | address | address that will announce a strategy to follow. |
maxSlippagePIPS | uint24 | maximum slippage authorized. |
managerFeePIPS | uint24 | fees 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
Functions
initialize
initialize function to delegate call onced the beacon proxy is deployed, for initializing the bunker module.
function initialize(address metaVault_) external;
Parameters
Name | Type | Description |
---|---|---|
metaVault_ | address | address of the meta vault |
Errors
NotImplemented
error NotImplemented();
AmountsZeros
error AmountsZeros();
ICreationCode
Functions
getCreationCode
function getCreationCode() external pure returns (bytes memory);
IGuardian
Functions
pauser
function to get the address of the pauser of arrakis protocol.
function pauser() external view returns (address);
Returns
Name | Type | Description |
---|---|---|
<none> | address | pauser 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
Name | Type | Description |
---|---|---|
oldPauser | address | address of the previous pauser. |
newPauser | address | address of the current pauser. |
Errors
AddressZero
error AddressZero();
SamePauser
error SamePauser();
IHOTExecutor
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
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
Name | Type | Description |
---|---|---|
vault_ | address | address of the meta vault the caller want to check. |
Returns
Name | Type | Description |
---|---|---|
isManaged | bool | boolean which is true if the vault is under management, false otherwise. |
IModulePrivateRegistry
Events
LogCreatePrivateModule
Log creation of a private module.
event LogCreatePrivateModule(
address beacon,
bytes payload,
address vault,
address creator,
address module
);
Parameters
Name | Type | Description |
---|---|---|
beacon | address | which beacon from who we get the implementation. |
payload | bytes | payload sent to the module constructor. |
vault | address | address of the Arrakis Meta Vault that will own this module |
creator | address | address that create the module. |
module | address | address of the newly created module. |
Errors
NotPrivateVault
error NotPrivateVault();
IModulePublicRegistry
Events
LogCreatePublicModule
Log creation of a public module.
event LogCreatePublicModule(
address beacon,
bytes payload,
address vault,
address creator,
address module
);
Parameters
Name | Type | Description |
---|---|---|
beacon | address | which beacon from who we get the implementation. |
payload | bytes | payload sent to the module constructor. |
vault | address | address of the Arrakis Meta Vault that will own this module |
creator | address | address that create the module. |
module | address | address of the newly created module. |
Errors
NotPublicVault
error NotPublicVault();
IModuleRegistry
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
Name | Type | Description |
---|---|---|
beacons | address[] | list of upgradeable beacon. |
beaconsContains
function to know if the beacons enumerableSet contain beacon_
function beaconsContains(address beacon_)
external
view
returns (bool isContained);
Parameters
Name | Type | Description |
---|---|---|
beacon_ | address | beacon address to check |
guardian
function used to get the guardian address of arrakis protocol.
function guardian() external view returns (address);
Returns
Name | Type | Description |
---|---|---|
<none> | address | guardian 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
Name | Type | Description |
---|---|---|
<none> | address | admin address that can upgrade beacon implementation. |
initialize
function used to initialize module registry.
function initialize(address factory_) external;
Parameters
Name | Type | Description |
---|---|---|
factory_ | address | address 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
Name | Type | Description |
---|---|---|
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
Name | Type | Description |
---|---|---|
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
Name | Type | Description |
---|---|---|
vault_ | address | |
beacon_ | address | which whitelisted beacon's implementation we want to create an instance of. |
payload_ | bytes | payload to create the module. |
Events
LogWhitelistBeacons
Log whitelist action of beacons.
event LogWhitelistBeacons(address[] beacons);
Parameters
Name | Type | Description |
---|---|---|
beacons | address[] | list of beacons whitelisted. |
LogBlacklistBeacons
Log blacklist action of beacons.
event LogBlacklistBeacons(address[] beacons);
Parameters
Name | Type | Description |
---|---|---|
beacons | address[] | 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
Functions
getPrice0
function used to get price0.
function getPrice0() external view returns (uint256 price0);
Returns
Name | Type | Description |
---|---|---|
price0 | uint256 | price of token0/token1. |
getPrice1
function used to get price1.
function getPrice1() external view returns (uint256 price1);
Returns
Name | Type | Description |
---|---|---|
price1 | uint256 | price of token1/token0. |
Errors
AddressZero
error AddressZero();
DecimalsToken0Zero
error DecimalsToken0Zero();
DecimalsToken1Zero
error DecimalsToken1Zero();
IOwnable
Functions
owner
function used to get the owner of this contract.
function owner() external view returns (address);
IPausable
Functions
pause
function pause() external;
unpause
function unpause() external;
IPauser
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
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
Functions
mint
function used to mint nft (representing a vault) and send it.
function mint(address to_, uint256 tokenId_) external;
Parameters
Name | Type | Description |
---|---|---|
to_ | address | address where to send the NFT. |
tokenId_ | uint256 | id 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
Functions
setRenderer
function used to set the renderer contract adress
only the owner can do it.
function setRenderer(address renderer_) external;
Parameters
Name | Type | Description |
---|---|---|
renderer_ | address | address 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
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
Name | Type | Description |
---|---|---|
vault_ | address | meta vault address. |
maxAmount0_ | uint256 | maximum amount of token0 user want to contribute. |
maxAmount1_ | uint256 | maximum amount of token1 user want to contribute. |
Returns
Name | Type | Description |
---|---|---|
shareToMint | uint256 | maximum amount of share user can get for 'maxAmount0*' and 'maxAmount1*'. |
amount0ToDeposit | uint256 | amount of token0 user should deposit into the vault for minting 'shareToMint'. |
amount1ToDeposit | uint256 | amount of token1 user should deposit into the vault for minting 'shareToMint'. |
IRouterSwapExecutor
Functions
swap
function used to swap tokens.
function swap(SwapAndAddData memory _swapData)
external
payable
returns (uint256 amount0Diff, uint256 amount1Diff);
Parameters
Name | Type | Description |
---|---|---|
_swapData | SwapAndAddData | struct containing all the informations for swapping. |
Returns
Name | Type | Description |
---|---|---|
amount0Diff | uint256 | the difference in token0 amount before and after the swap. |
amount1Diff | uint256 | the 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
Functions
calculateSwapAmount
function calculateSwapAmount(
IArrakisMetaVault vault,
uint256 amount0In,
uint256 amount1In,
uint256 price18Decimals
) external view returns (bool zeroForOne, uint256 swapAmount);
Errors
AddressZero
error AddressZero();
ISovereignPool
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
Errors
NotImplemented
error NotImplemented();
IValantisHOTModule
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
Name | Type | Description |
---|---|---|
pool_ | address | address of the valantis sovereign pool. |
init0_ | uint256 | initial amount of token0 to provide to valantis module. |
init1_ | uint256 | initial amount of token1 to provide to valantis module. |
maxSlippage_ | uint24 | allowed to manager for rebalancing the inventory using swap. |
metaVault_ | address | address of the meta vault |
setALMAndManagerFees
set HOT and initialize manager fees function.
function setALMAndManagerFees(
address alm_,
address oracle_
) external;
Parameters
Name | Type | Description |
---|---|---|
alm_ | address | address of the valantis HOT ALM. |
oracle_ | address | address 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
Name | Type | Description |
---|---|---|
_sqrtPriceLowX96 | uint160 | lower bound of the range in sqrt price. |
_sqrtPriceHighX96 | uint160 | upper bound of the range in sqrt price. |
_expectedSqrtSpotPriceLowerX96 | uint160 | expected upper limit of current spot price (to prevent sandwich attack and manipulation). |
_expectedSqrtSpotPriceUpperX96 | uint160 | expected 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
Name | Type | Description |
---|---|---|
zeroForOne_ | bool | boolean if true token0->token1, if false token1->token0. |
expectedMinReturn_ | uint256 | minimum amount of tokenOut expected. |
amountIn_ | uint256 | amount of tokenIn used during swap. |
router_ | address | address of smart contract that will execute swap. |
expectedSqrtSpotPriceUpperX96_ | uint160 | upper bound of current price. |
expectedSqrtSpotPriceLowerX96_ | uint160 | lower bound of current price. |
payload_ | bytes | data 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
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
Name | Type | Description |
---|---|---|
vault_ | address | meta vault address. |
maxAmount0_ | uint256 | maximum amount of token0 user want to contribute. |
maxAmount1_ | uint256 | maximum amount of token1 user want to contribute. |
Returns
Name | Type | Description |
---|---|---|
shareToMint | uint256 | maximum amount of share user can get for 'maxAmount0*' and 'maxAmount1*'. |
amount0ToDeposit | uint256 | amount of token0 user should deposit into the vault for minting 'shareToMint'. |
amount1ToDeposit | uint256 | amount of token1 user should deposit into the vault for minting 'shareToMint'. |
BunkerModule
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
Name | Type | Description |
---|---|---|
metaVault_ | address | address 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
Name | Type | Description |
---|---|---|
receiver_ | address | address that will receive tokens. |
proportion_ | uint256 | the proportion of the total position that need to be withdrawn. |
Returns
Name | Type | Description |
---|---|---|
amount0 | uint256 | amount of token0 withdrawn. |
amount1 | uint256 | amount of token1 withdrawn. |
withdrawManagerBalance
function used by metaVault or manager to get manager fees.
function withdrawManagerBalance()
external
returns (uint256 amount0, uint256 amount1);
Returns
Name | Type | Description |
---|---|---|
amount0 | uint256 | amount of token0 sent to manager. |
amount1 | uint256 | amount 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
Name | Type | Description |
---|---|---|
fees0 | uint256 | 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 fees1);
Returns
Name | Type | Description |
---|---|---|
fees1 | uint256 | amount 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
Name | Type | Description |
---|---|---|
amount0 | uint256 | the amount of token0 sitting on the position for priceX96. |
amount1 | uint256 | the 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
Name | Type | Description |
---|---|---|
amount0 | uint256 | the amount of token0 sitting on the position. |
amount1 | uint256 | the 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
Name | Type | Description |
---|---|---|
init0 | uint256 | the amount of token0 needed to open a position. |
init1 | uint256 | the amount of token1 needed to open a position. |
managerFeePIPS
function used to get manager fees.
function managerFeePIPS() external view returns (uint256);
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | managerFeePIPS 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
Name | Type | Description |
---|---|---|
<none> | address | guardian address of the pauser. |
HOTExecutor
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
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
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
Name | Type | Description |
---|---|---|
depositor_ | address | address that will provide the tokens. |
amount0_ | uint256 | amount of token0 that depositor want to send to module. |
amount1_ | uint256 | amount of token1 that depositor want to send to module. |
ValantisModulePublic
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
Name | Type | Description |
---|---|---|
depositor_ | address | address that will provide the tokens. |
proportion_ | uint256 | percentage of portfolio position vault want to expand. |
Returns
Name | Type | Description |
---|---|---|
amount0 | uint256 | amount of token0 needed to expand the portfolio by "proportion" percent. |
amount1 | uint256 | amount 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
Name | Type | Description |
---|---|---|
receiver_ | address | address that will receive tokens. |
proportion_ | uint256 | number of share needed to be withdrawn. |
Returns
Name | Type | Description |
---|---|---|
amount0 | uint256 | amount of token0 withdrawn. |
amount1 | uint256 | amount of token1 withdrawn. |
initializePosition
function initializePosition(bytes calldata data_)
external
override
onlyMetaVault;
Contents
- VaultInfo
- SetupParams
- FeeIncrease
- TokenPermissions
- PermitTransferFrom
- SignatureTransferDetails
- PermitBatchTransferFrom
- AddLiquidityData
- RemoveLiquidityData
- SwapData
- SwapAndAddData
- AddLiquidityPermit2Data
- RemoveLiquidityPermit2Data
- SwapAndAddPermit2Data
- SwapBalances
VaultInfo
struct VaultInfo {
uint256 lastRebalance;
uint256 cooldownPeriod;
IOracleWrapper oracle;
uint24 maxDeviation;
address executor;
address stratAnnouncer;
uint24 maxSlippagePIPS;
uint24 managerFeePIPS;
}
SetupParams
struct SetupParams {
address vault;
IOracleWrapper oracle;
uint24 maxDeviation;
uint256 cooldownPeriod;
address executor;
address stratAnnouncer;
uint24 maxSlippagePIPS;
}
FeeIncrease
struct FeeIncrease {
uint256 submitTimestamp;
uint24 newFeePIPS;
}
TokenPermissions
struct TokenPermissions {
address token;
uint256 amount;
}
PermitTransferFrom
struct PermitTransferFrom {
TokenPermissions permitted;
uint256 nonce;
uint256 deadline;
}
SignatureTransferDetails
struct SignatureTransferDetails {
address to;
uint256 requestedAmount;
}
PermitBatchTransferFrom
struct PermitBatchTransferFrom {
TokenPermissions[] permitted;
uint256 nonce;
uint256 deadline;
}
AddLiquidityData
struct AddLiquidityData {
uint256 amount0Max;
uint256 amount1Max;
uint256 amount0Min;
uint256 amount1Min;
uint256 amountSharesMin;
address vault;
address receiver;
}
RemoveLiquidityData
struct RemoveLiquidityData {
uint256 burnAmount;
uint256 amount0Min;
uint256 amount1Min;
address vault;
address payable receiver;
}
SwapData
struct SwapData {
bytes swapPayload;
uint256 amountInSwap;
uint256 amountOutSwap;
address swapRouter;
bool zeroForOne;
}
SwapAndAddData
struct SwapAndAddData {
SwapData swapData;
AddLiquidityData addData;
}
AddLiquidityPermit2Data
struct AddLiquidityPermit2Data {
AddLiquidityData addData;
PermitBatchTransferFrom permit;
bytes signature;
}
RemoveLiquidityPermit2Data
struct RemoveLiquidityPermit2Data {
RemoveLiquidityData removeData;
PermitTransferFrom permit;
bytes signature;
}
SwapAndAddPermit2Data
struct SwapAndAddPermit2Data {
SwapAndAddData swapAndAddData;
PermitBatchTransferFrom permit;
bytes signature;
}
SwapBalances
struct SwapBalances {
uint256 actual0;
uint256 actual1;
uint256 initBalance0;
uint256 initBalance1;
uint256 balance0;
uint256 balance1;
}
Contents
SVGParams
Parameters for generating the URI
struct SVGParams {
address vault;
uint256 amount0;
uint256 amount1;
uint8 decimals0;
uint8 decimals1;
string symbol0;
string symbol1;
}
INFTSVG
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
Name | Type | Description |
---|---|---|
params_ | SVGParams | Parameters for generating the URI |
generateFallbackURI
Generates a fallback URI for a given vault
function generateFallbackURI(SVGParams memory params_)
external
pure
returns (string memory);
Parameters
Name | Type | Description |
---|---|---|
params_ | SVGParams | Parameters for generating the URI |
NFTSVG
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
Name | Type | Description |
---|---|---|
params_ | SVGParams | Parameters for generating the URI |
generateFallbackURI
Generates a fallback URI for a given vault
function generateFallbackURI(SVGParams memory params_)
public
pure
returns (string memory);
Parameters
Name | Type | Description |
---|---|---|
params_ | SVGParams | Parameters 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
Name | Type | Description |
---|---|---|
params_ | SVGParams | Parameters 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
Name | Type | Description |
---|---|---|
params_ | SVGParams | Parameters 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
Name | Type | Description |
---|---|---|
vault_ | address | The 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
State Variables
HEX_DIGITS
bytes16 private constant HEX_DIGITS = "0123456789abcdef";
Functions
generateSVGLogo
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
Name | Type | Description |
---|---|---|
addr_ | address | address 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
Name | Type | Description |
---|---|---|
value_ | uint256 | uint to convert to string. |
decimals_ | uint8 | number 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
Name | Type | Description |
---|---|---|
value_ | uint256 | uint to convert to string. |
ArrakisMetaVaultFactory
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
Name | Type | Description |
---|---|---|
newManager_ | address | address 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
Name | Type | Description |
---|---|---|
salt_ | bytes32 | bytes32 used to get a deterministic all chains address. |
token0_ | address | address of the first token of the token pair. |
token1_ | address | address of the second token of the token pair. |
owner_ | address | address of the owner of the vault. |
beacon_ | address | address of the beacon that will be used to create the default module. |
moduleCreationPayload_ | bytes | payload for initializing the module. |
initManagementPayload_ | bytes | data for initialize management. |
Returns
Name | Type | Description |
---|---|---|
vault | address | address 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
Name | Type | Description |
---|---|---|
salt_ | bytes32 | bytes32 needed to compute vault address deterministic way. |
token0_ | address | address of the first token of the token pair. |
token1_ | address | address of the second token of the token pair. |
owner_ | address | address of the owner of the vault. |
beacon_ | address | address of the beacon that will be used to create the default module. |
moduleCreationPayload_ | bytes | payload for initializing the module. |
initManagementPayload_ | bytes | data for initialize management. |
Returns
Name | Type | Description |
---|---|---|
vault | address | address 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
Name | Type | Description |
---|---|---|
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
Name | Type | Description |
---|---|---|
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
Name | Type | Description |
---|---|---|
token0_ | address | address of the first token. |
token1_ | address | address of the second token. |
Returns
Name | Type | Description |
---|---|---|
<none> | string | name 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
Name | Type | Description |
---|---|---|
startIndex_ | uint256 | start index |
endIndex_ | uint256 | end index |
Returns
Name | Type | Description |
---|---|---|
<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
Name | Type | Description |
---|---|---|
result | uint256 | total number of vaults deployed |
isPublicVault
isPublicVault check if the inputed vault is a public vault.
function isPublicVault(address vault_) external view returns (bool);
Parameters
Name | Type | Description |
---|---|---|
vault_ | address | address of the address to check. |
Returns
Name | Type | Description |
---|---|---|
<none> | bool | isPublicVault 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
Name | Type | Description |
---|---|---|
startIndex_ | uint256 | start index |
endIndex_ | uint256 | end index |
Returns
Name | Type | Description |
---|---|---|
<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
Name | Type | Description |
---|---|---|
result | uint256 | total number of vaults deployed |
isPrivateVault
isPrivateVault check if the inputed vault is a private vault.
function isPrivateVault(address vault_)
external
view
returns (bool);
Parameters
Name | Type | Description |
---|---|---|
vault_ | address | address of the address to check. |
Returns
Name | Type | Description |
---|---|---|
<none> | bool | isPublicVault 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
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
Name | Type | Description |
---|---|---|
shares_ | uint256 | amount representing the part of the position owned by receiver. |
receiver_ | address | address where share token will be sent. |
Returns
Name | Type | Description |
---|---|---|
amount0 | uint256 | amount of token0 deposited. |
amount1 | uint256 | amount 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
Name | Type | Description |
---|---|---|
shares_ | uint256 | amount of share that will be burn. |
receiver_ | address | address where underlying tokens will be sent. |
Returns
Name | Type | Description |
---|---|---|
amount0 | uint256 | amount of token0 withdrawn. |
amount1 | uint256 | amount 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
Name | Type | Description |
---|---|---|
<none> | string | name 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
Name | Type | Description |
---|---|---|
<none> | string | symbol 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
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
Name | Type | Description |
---|---|---|
params_ | AddLiquidityData | AddLiquidityData struct containing data for adding liquidity |
Returns
Name | Type | Description |
---|---|---|
amount0 | uint256 | amount of token0 transferred from msg.sender to mint mintAmount |
amount1 | uint256 | amount of token1 transferred from msg.sender to mint mintAmount |
sharesReceived | uint256 | amount 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
Name | Type | Description |
---|---|---|
params_ | SwapAndAddData | SwapAndAddData struct containing data for swap |
Returns
Name | Type | Description |
---|---|---|
amount0 | uint256 | amount of token0 transferred from msg.sender to mint mintAmount |
amount1 | uint256 | amount of token1 transferred from msg.sender to mint mintAmount |
sharesReceived | uint256 | amount of public vault tokens transferred to receiver |
amount0Diff | uint256 | token0 balance difference post swap |
amount1Diff | uint256 | token1 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
Name | Type | Description |
---|---|---|
params_ | RemoveLiquidityData | RemoveLiquidityData struct containing data for withdrawals |
Returns
Name | Type | Description |
---|---|---|
amount0 | uint256 | actual amount of token0 transferred to receiver for burning burnAmount |
amount1 | uint256 | actual 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
Name | Type | Description |
---|---|---|
params_ | AddLiquidityPermit2Data | AddLiquidityPermit2Data struct containing data for adding liquidity |
Returns
Name | Type | Description |
---|---|---|
amount0 | uint256 | amount of token0 transferred from msg.sender to mint mintAmount |
amount1 | uint256 | amount of token1 transferred from msg.sender to mint mintAmount |
sharesReceived | uint256 | amount 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
Name | Type | Description |
---|---|---|
params_ | SwapAndAddPermit2Data | SwapAndAddPermit2Data struct containing data for swap |
Returns
Name | Type | Description |
---|---|---|
amount0 | uint256 | amount of token0 transferred from msg.sender to mint mintAmount |
amount1 | uint256 | amount of token1 transferred from msg.sender to mint mintAmount |
sharesReceived | uint256 | amount of public vault tokens transferred to receiver |
amount0Diff | uint256 | token0 balance difference post swap |
amount1Diff | uint256 | token1 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
Name | Type | Description |
---|---|---|
params_ | RemoveLiquidityPermit2Data | RemoveLiquidityPermit2Data struct containing data for withdrawals |
Returns
Name | Type | Description |
---|---|---|
amount0 | uint256 | actual amount of token0 transferred to receiver for burning burnAmount |
amount1 | uint256 | actual 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
Name | Type | Description |
---|---|---|
params_ | AddLiquidityData | AddLiquidityData struct containing data for adding liquidity |
Returns
Name | Type | Description |
---|---|---|
amount0 | uint256 | amount of token0 transferred from msg.sender to mint mintAmount |
amount1 | uint256 | amount of token1 transferred from msg.sender to mint mintAmount |
sharesReceived | uint256 | amount 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
Name | Type | Description |
---|---|---|
params_ | SwapAndAddData | SwapAndAddData struct containing data for swap |
Returns
Name | Type | Description |
---|---|---|
amount0 | uint256 | amount of token0 transferred from msg.sender to mint mintAmount |
amount1 | uint256 | amount of token1 transferred from msg.sender to mint mintAmount |
sharesReceived | uint256 | amount of public vault tokens transferred to receiver |
amount0Diff | uint256 | token0 balance difference post swap |
amount1Diff | uint256 | token1 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
Name | Type | Description |
---|---|---|
params_ | AddLiquidityPermit2Data | AddLiquidityPermit2Data struct containing data for adding liquidity |
Returns
Name | Type | Description |
---|---|---|
amount0 | uint256 | amount of token0 transferred from msg.sender to mint mintAmount |
amount1 | uint256 | amount of token1 transferred from msg.sender to mint mintAmount |
sharesReceived | uint256 | amount 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
Name | Type | Description |
---|---|---|
params_ | SwapAndAddPermit2Data | SwapAndAddPermit2Data struct containing data for swap |
Returns
Name | Type | Description |
---|---|---|
amount0 | uint256 | amount of token0 transferred from msg.sender to mint mintAmount |
amount1 | uint256 | amount of token1 transferred from msg.sender to mint mintAmount |
sharesReceived | uint256 | amount of public vault tokens transferred to receiver |
amount0Diff | uint256 | token0 balance difference post swap |
amount1Diff | uint256 | token1 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
Name | Type | Description |
---|---|---|
vault_ | address | meta vault address. |
maxAmount0_ | uint256 | maximum amount of token0 user want to contribute. |
maxAmount1_ | uint256 | maximum amount of token1 user want to contribute. |
Returns
Name | Type | Description |
---|---|---|
shareToMint | uint256 | maximum amount of share user can get for 'maxAmount0*' and 'maxAmount1*'. |
amount0ToDeposit | uint256 | amount of token0 user should deposit into the vault for minting 'shareToMint'. |
amount1ToDeposit | uint256 | amount 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
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
Name | Type | Description |
---|---|---|
owner_ | address | address of the owner of standard manager. |
defaultReceiver_ | address | address of the receiver of tokens (by default). |
factory_ | address | ArrakisMetaVaultFactory 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
Name | Type | Description |
---|---|---|
newDefaultReceiver_ | address | address 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
Name | Type | Description |
---|---|---|
vault_ | address | address of the meta vault that contain the specific token. |
isSetReceiverToken0_ | bool | boolean if true means that receiver is for token0 if not it's for token1. |
receiver_ | address | address 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
Name | Type | Description |
---|---|---|
vault_ | address | address of the vault. |
newFeePIPS_ | uint24 | fees 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
Name | Type | Description |
---|---|---|
vault_ | address | address 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
Name | Type | Description |
---|---|---|
vault_ | address | address of the vault where fees will be increase after timeLock. |
newFeePIPS_ | uint24 | fees 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
Name | Type | Description |
---|---|---|
vault_ | address | from which fees will be collected. |
Returns
Name | Type | Description |
---|---|---|
amount0 | uint256 | amount of token0 sent to receiver_ |
amount1 | uint256 | amount 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
Name | Type | Description |
---|---|---|
vault_ | address | address 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
Name | Type | Description |
---|---|---|
vault_ | address | address of the vault the manager want to change module. |
module_ | address | address 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
Name | Type | Description |
---|---|---|
params_ | SetupParams | struct 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
Name | Type | Description |
---|---|---|
params_ | SetupParams | struct 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
Name | Type | Description |
---|---|---|
vault_ | address | address of arrakis meta vault that will follow the strategy. |
strategy_ | string | string 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
Name | Type | Description |
---|---|---|
startIndex_ | uint256 | starting index from which the caller want to read the array of managed vaults. |
endIndex_ | uint256 | ending 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
Name | Type | Description |
---|---|---|
<none> | address | pauser 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
Name | Type | Description |
---|---|---|
vault_ | address | address of the meta vault the caller want to check. |
Returns
Name | Type | Description |
---|---|---|
<none> | bool | isManaged 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
Inherits: ICreationCode
Functions
getCreationCode
function getCreationCode() external pure returns (bytes memory);
CreationCodePublicVault
Inherits: ICreationCode
Functions
getCreationCode
function getCreationCode() external pure returns (bytes memory);
Guardian
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
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
Name | Type | Description |
---|---|---|
vault_ | address | |
beacon_ | address | which whitelisted beacon's implementation we want to create an instance of. |
payload_ | bytes | payload to create the module. |
ModulePublicRegistry
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
Name | Type | Description |
---|---|---|
vault_ | address | |
beacon_ | address | which whitelisted beacon's implementation we want to create an instance of. |
payload_ | bytes | payload to create the module. |
Pauser
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
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
Name | Type | Description |
---|---|---|
to_ | address | address where to send the NFT. |
tokenId_ | uint256 | id 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
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
Name | Type | Description |
---|---|---|
renderer_ | address | address of the contract that will render the tokenUri for the svg of the nft. |
isNFTSVG
function isNFTSVG(address renderer_) public view returns (bool);
RouterSwapExecutor
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
Name | Type | Description |
---|---|---|
params_ | SwapAndAddData | struct containing all the informations for swapping. |
Returns
Name | Type | Description |
---|---|---|
amount0Diff | uint256 | the difference in token0 amount before and after the swap. |
amount1Diff | uint256 | the difference in token1 amount before and after the swap. |
receive
receive() external payable;
RouterSwapResolver
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
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.
How HOT AMM works
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.
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 intents protocols.
HOT stands for Hybrid Order Type. HOT pools have two swap execution mechanisms:
- RfQ Quotes
- Permissionless AMM
RfQ Quotes
- Solvers compete for non-toxic uninformed order flow from intents protocols like CoW Swap, Uniswap X and 1inch Fusion.
- Permissioned solvers request quotes from an API, which calls the Arrakis off chain quoter and in turn issuing quotes as a signed intent. Solvers can use these signed quotes to fill order from the liquidity pool before the quotes expire.
- When executed, these signed quotes update the pool price playing a special role in keeping the price from becoming stale to mitigate against arbitrage.
Permissionless AMM
- A single concentrated liquidity position is used, akin to Uniswap v3. In addition a dynamic fee is implemented.
- 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.
Problem Statement
Loss-Versus-Rebalancing (LVR)
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 approach
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 about 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 is one of the two parallel order types that the liquidity pool supports, and it simply sidesteps the LVR problem completely by handling pricing offchain (within some bounds of an onchain oracle check). For the classical AMM swap mode of the liquidity pool, which is entirely onchain and thus subject to LVR, a combination of Dynamic Fees and using up-to-date info in swaps from the offchain execution allows it to have more performant pricing than other onchain AMMs and benefit from this hybrid execution modes setup.
Quoter
A crucial offchain component of the HOT AMM is the QuoteSigner
role which is set directly on the HOT.sol
smart contract containing the core liquidity pool logic of the HOT AMM.
Whoever holds the private key to the QuoteSigner
role has the authority to issue signed quotes that allow recipients to execute swaps directly against the funds in the liquidity pool at the prices determined in the signed quotes (subject to certain onchain safety checks on the price and volume of the quotes).
For Arrakis Public Vaults, the Quoter is a semi-trusted automated offchain process, which escrows the Public Vault QuoteSigner
key 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 from outside parties like solvers.
Quoter Market Making Strategy
The Public Vault Quoter uses an Avellaneda and Stoikov based approach to RfQ market making, where the goal is to converge to a target inventory ratio (e.g. the active ETH/USDC mainnet Public Vault targets a 50/50 inventory ratio).
Taking into account the current centralized exchange prices and curent orderflow, the quoter determines a robust market mid price at, as well as an estimate of the asset's volatility, at any time t. With the mid price and volatility, as well as the skew of the Vault inventory from the target ratio, the Avellaneda and Stoikov market making algorithm determines a best bid and ask for any time t that it is willing to accept. This is the criteria the Quoter uses for determining if we will sign requests from solvers for execution at or better than the desired prices in their requests.
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 one of these RfQ quotes 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 Quoter more transparently verifiable and trustless rather than make it a semi-trusted central point of failure for Arrakis Public Vaults.
Quickstart
Integrating as a Solver
For a complete overview on how to integrate as a solver to HOT AMM, please refer to Valantis Solver Guide.
Permissionless AMM
Here we describe the main actions that users can perform on the permissionless side of HOT AMM.
- Add Liquidty and Remove Liquidity: For Liquidity Providers that want to fuel HOT AMM and earn from trading fees and incentives. We refer to the Arrakis Modular guide for public vaults interactions.
- 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 (CPAMM) logic. For more details, we refer to the Valantis Sovereign Pool documentation.
Deployments
Mainnet
WETH/USDC
Contract | Address |
---|---|
Valantis Sovereign Pool | 0xD9a406DBC1a301B0D2eD5bA0d9398c4debe68202 |
HOT Module | 0x3269994964DFE4aa5f8dd0C99eD40e881562132A |
Meta Vault | 0xf790870ccF6aE66DdC69f68e6d05d446f1a6ad83 |
Arbitrum
WETH/USDC
Contract | Address |
---|---|
Valantis Sovereign Pool | 0xC0C80150750D7a2852147b06c4Fbc065bF1e0838 |
HOT Module | 0xC4c855095f5872BeC67d0916D49cf881d4fafe1e |
Meta Vault | 0xf790870ccF6aE66DdC69f68e6d05d446f1a6ad83 |
Base
WETH/USDC
Contract | Address |
---|---|
Valantis Sovereign Pool | 0x159DD549399811CD6247Fb457497414baF8BFb08 |
HOT Module | 0x6ca2D5dbA66BAf72eD10a5e9D7700263d5229Aff |
Meta Vault | 0xf790870ccF6aE66DdC69f68e6d05d446f1a6ad83 |
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.
Uniswap v4 Hook
Resources Overview
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