Expanding iFi DEX: Open Rewards on Althea L1
While the iFi DEX was initially forked from Ambient, we have made two major advancements. The first is integrating events for an ultra-fast backend and long-term operational stability. The second is introducing a first-of-its-kind open rewards system.
What Do You Mean by “Open Rewards”?
Many DEXes incorporate rewards mechanisms to incentivize liquidity providers and bootstrap liquidity. What makes the iFi DEX rewards system unique is its open interface for third-party reward contracts.
Instead of defining a series of incentive parameters and building them into the main contract, the iFi DEX tracks metrics, such as liquidity provided and fees collected, and exposes them to any third-party contract that wishes to use them.The typical drawback of read-only interfaces is that rewards contracts must be triggered at precise moments in order to capture reward data. However, we have developed innovative ways to mitigate this limitation, while maintaining the flexibility of an external rewards system.
Delegated Liquidity Position Ownership
Ambient DEX supports using various account abstractions and external routers. This makes it possible to layer this functionality with the iFi rewards system—delivering an experience that is as simple to operate as a native rewards system, yet infinitely more flexible.From a user’s perspective, they simply create their liquidity position through the rewards contract, and call their rewards claiming function there. This flow allows the rewards contract to trigger data storage and snapshotting as needed, throughout the entire lifetime of the liquidity position.
Dealing With In-Range and Out-of-Range Positions
Due to Ambient’s highly efficient architecture, it is impractical to track which concentrated liquidity positions are in range at all times. Instead, we use concentrated liquidity fee collection—an already optimized process—as a proxy to determine if a position is in range.
Though it adds significant complexity to the rewards contract implementation, by exposing both the amount of concentrated liquidity and fees collected (on a per account basis), API callers can determine if a position was in-range and reward them appropriately.
This approach keeps the gas cost of these incentive extensions low—an approximate 9% increase in swap gas and 16% increase on LP position operations.
Rewards Contracts
As part of these changes to the iFi DEX we have two simple rewards contract implementations, one that focuses on incentivizing ambient liquidity in a pool and one that focuses on concentrated liquidity. Neither of these take into account fee collection. They provide simple incentives for liquidity which has been locked for a duration.
The implementation of both is straightforward. The contract owner creates and funds a rewards program which enables liquidity providers to register all their concentrated or ambient liquidity at once, then rewards accumulate for each registered liquidity provider until they are claimed. Liquidity providers must claim their rewards before changing their positions, so that the rewards contract can be sure that no updates have been made to the liquidity provided and therefore can calculate rewards on the most recent liquidity amount.
In short, the flow is: Create LP -> register for rewards -> wait some time -> claim rewards -> modify LP if needed -> repeatThe concentrated liquidity rewards contract is only appropriate for stableswap pools, because it does not take into account fees or in-range positions. The ambient rewards can be applied to any type of pool.
The best thing about this split approach to rewards contracts is that rewards system upgrades are performed independently, without the need to upgrade to the main DEX contract. In fact, they do not require an upgrade to any contracts. The old rewards contracts are simply phased out and new ones are deployed. This design not only allows for faster iteration and greater flexibility, but also the power to run multiple distinct rewards programs, in parallel, on the same pool, to provide incentives for different types of behavior.
These reference contracts will be integrated with Althea L1 governance as part of the first-generation iFi DEX rewards program (after the proposal to operate a rewards program passes).
You can find these simple contracts here.
Conclusion
We’re nearing the final installment of our iFi DEX blog series. Next week, we’ll dive into our last topic: EIP-712 transaction support!