The underlying protocol has a main base vault and module contracts that manage the user’s liquidity according to the intents selected by the user.
Base contract has the integration with concentrated AMM and it implements the basic required actions to move the user’s liquidity for the intent selected by the user. Since all AMMs have some common functionalities e.g. mint, burn, collect & swap, all these functions are integrated in the base contract’s library PoolActions.sol.
All pools are managed in the base vault and it deploys strategies for each pool and multiple strategies can be created for each pool. Each strategy has multiple states which is explained in Strategy section below.
Base vault has separate fee-sharing mechanisms for compounding strategies and non-compounding strategies. All the data of users will be stored on the base vault i.e. mode selected by the user, liquidity delta, upper tick, lower tick, and fees earned by the user. NFT will be minted to users against all the above details since each user has custom strategies every time when they deposit a new strategy.
The strategy could be considered as a separate vault inside the base. Strategy owners can only select a single mode out of four rebalance intents (bull, bear, dynamic, static) during strategy creation. Strategy creators can also select other liquidity intents:
Auto-exit and Reinvest
Liquidity Distribution
Hedging
Rebalance intents have a variety of actions e.g. Rebase Inactivity, Price Preference, Active Rebalance. Similarly every intent can introduce new liquidity actions.
Strategy also has position ticks and preferences (depending on other intents) which are selected by owners. Soon after the current price goes outside the desired price range a new position will be minted with new ticks and the transaction is triggered by the bot (off chain bots are monitoring the modes of all the strategies).
Note: Bot does not have access to the funds of users inside any strategy; all the validation is handled in smart contract they are only used to initiate the transaction when specified prices are hit.
The identities of the strategies are set by their respective hashes. The users can create their own strategy or they can select any of the previously created strategies. A single strategy will have multiple users and fees will be distributed among them according to the compounding or non-compounding fee-sharing mechanism.
If any change happens in ticks of the strategy it will be reflected to all users having the same strategy ID. The state for the strategy consists of:
The hash of all mode IDs selected in this strategy
The hash of all inputs of their respective intent
The hash of additional data required for tracking any detail for intents
Compounding or no compounding
Balances left of users who joined this strategy
Total shares minted through this strategy
FeeGrowth for tracking of fees for non-compounding strategy
Every intent has some logic e.g. intent 1 implements the shifting of liquidity to the left with respect to current tick so this custom logic of Intent 1 will be in the modules contract that will perform actions according to the conditions of given intent.
Logic of all intents is implemented on chain. New actions for any intent could be introduced by governance. Every time any intent action is introduced through governance it’s respective ID will be stored in a base vault’s module contract that contains the logic for that particular ID.
When LPs directly deposit on AMM they only have a single position that is earning the fees so all the fees will be collected by that specific user only. In our architecture every user has a unique position and distribution of fees might be a hectic task.
Base vault has the feature that any user can join any strategy and there could be a higher probability that more than two strategies share the same ticks so in this case fee sharing is handled accordingly for compounding or non-compounding.
Single pool => contains multiple strategies => single strategy contains multiple users
So we need to take care the fee mechanism according to above hierarchy:
Single pool => fee will be distributed among each strategy => strategy will distribute the share of earned fee to their users
Base Vault Methods:
Create Strategy
Deposit
updatePositionLiquidity (increase liquidity)
collect (only non-compounders can call)
shiftLiqudity (re mint or hodl liquidity of strategy)
Strategy owner has the right to HODL the liquidity inside contract. For example, if market is very volatile then the assets of all the users in that strategy will sit idle in contract until the strategy owner unHODL the strategy with new ticks on AMM.
Note: Users have full authority to withdraw the strategy any time during the HODL period as well.
Protocol has different fee charge mechanisms that could be applied.
Protocol fee on strategy creation.
Protocol fee on automation on every rebalance of strategy (public & private strategies could have different fee percentage).
Protocol fee on strategy creator's performance fee.
Protocol fee on strategy creator's management fee.
All these fee percentages are handled by the GovernanceFeeHandler.sol contract. Protocol fee is not applied on any chain but can be activated any time.