Documentation Index
Fetch the complete documentation index at: https://tech.ramses.xyz/llms.txt
Use this file to discover all available pages before exploring further.
Introduction
This guide will cover how to collect fees from a liquidity position on the Ramses V3 protocol. It is based on the collecting fees code example, found in the Uniswap code examples repository. To run this example, check out the examples’s README and follow the setup instructions.If you need a briefer on the SDK and to learn more about how these guides connect to the examples repository, please visit our background page!
NonfungiblePositionManager class to help us mint a liquidity position for the USDC - DAI pair. We will then attempt to collect any fees that the position has accrued from those trading against our provisioned liquidity. The inputs to our guide are the two tokens that we are pooling for, the amount of each token we are pooling for, the Pool fee and the max amount of accrued fees we want to collect for each token.
The guide will cover:
- Setting up our fee collection
- Submitting our fee collection transaction
collectFees().
This guide assumes you are familiar with our Minting a Position guide. A minted position is required to add or remove liquidity from, so the buttons will be disabled until a position is minted.Also note that we do not need to give approval to the
RamsesV3PositionManager to transfer our tokens as we will have already done that when minting our position.Setting up our fee collection
All of the fee collecting logic can be found in thecollectFees function. Notice how the Collect Fees button is disabled until a position is minted. This happens because there will be no fees to collect unless there is a position whose liquidity has been traded against.
To start, we fetch the position from the RamsesV3PositionManager Contract to get the fees we are owed:
CollectOptions that holds the data about the fees we want to collect:
RamsesV3PositionManager, we pass the tokenId and the recipient of the fees, which in this case is our function’s input position id and our wallet’s address.
The other two CurrencyAmount parameters (expectedCurrencyOwed0 and expectedCurrencyOwed1) define the maximum amount of currency we expect to get collect through accrued fees of each token in the pool. We set these through our guide’s configuration.
In a real world scenario, we can fetch the amount of fees that are owed to the Position through the positions() function of the RamsesV3PositionManager Contract.
We fetch the position info like in this code snippet taken from the Fetching Positions guide:
tokensOwed0 and tokensOwed1 values are the fees owed.
In this example, we have the values hardcoded in the config.ts file.
Submitting our fee collection transaction
Next, we get the call parameters for collecting our fees from ourRamsesV3PositionManager using the constructed CollectOptions:
