Proof of Liquidity Integration Guide for Non-ERC20 Protocols
Introduction
Users typically engage with Proof of Liquidity by staking ERC20 receipt tokens into Reward Vaults to earn$BGT. However, this approach may not be suitable for all protocols.
This guide demonstrates how to integrate Berachain’s Proof of Liquidity (PoL) system for protocols who don’t naturally produce stakeable ERC20 receipt tokens or otherwise need to track balances internally. For example, a perpetual futures exchange may wish to reward users who open trading positions with $BGT, and cease rewards when the position is closed.
By implementing this approach, such protocols can still participate in PoL, benefiting from the improved incentive efficiencies it provides.
:::warning
Note that this article provides only one possible workaround for integrating PoL with non-ERC20 protocols. The solution is not exhaustive and may not be suitable for all use cases.
:::
Description of Approach
The described approach involves the creation of a dummyStakingToken that is staked in a Reward Vault on behalf of users by a protocol. This dummy token is used to track the staked balances of users and is minted and burned by the protocol (operating through ProtocolContract) as users provide/withdraw their liquidity from the protocol.
The staked dummy token balance entitles users to earn $BGT as if they had staked an ERC20 receipt token in a PoL vault themselves. This approach is enabled by the delegateStake and delegateWithdraw methods in the RewardVault contract.
Requirements
Before beginning, make sure you have Foundry installed beforehand.Project Setup
- Initialize a new Forge project and install dependencies:
- Create a
remappings.txtfile for OpenZeppelin imports:
Implement Contracts
1. Create the dummy token contract at src/StakingToken.sol:
ProtocolContract) can mint and burn tokens.
2. Create a mock protocol contract at src/ProtocolContract.sol:
userActivityrepresents the internal accounting and logic specific to that protocol- The remainder of the
addActivityandremoveActivitymethods mint and burnStakingTokens, and interacts with the relevant RewardVault to stake/unstake on behalf of users
3. Add the PoL Interfaces at src/interfaces/IRewardVaults.sol:
Testing the Integration
Now, we wire everything together with tests to ensure that the integration works as expected. Below is an example test suite for theProtocolContract contract.
Feel free to look at each individual test to get a better idea on how successful scenarios are handled.