1. Overview of Harvesting a Position
Get a quick quote on outstanding fees and rewards
There are use-cases where users would like to check the outstanding values before deciding to perform an on-chain update and harvest. In these cases, use the providedcollectFeesQuote and collectRewardsQuote in the Typescript SDK.
TypeScript
Update on-chain position with the latest accrued fees
Before you fetch your owed fees, you must update the on-chain position with the latest values by callingincrease_liquidity or decrease_liquidity. Alternatively, you can call update_fee_and_rewards to update without modifying liquidity.
If this step is skipped, the collect instructions will only fetch the last updated values of the position. In many cases, this will be 0.
Sample code on using update_fee_and_rewards:
TypeScript
Collect Fees and Rewards
Once the position has been updated, you can usecollect_fees and collect_reward to harvest the position.
Collect fee
TypeScript
Collect rewards
TypeScript
3. Usage Example
Suppose you are a developer creating a bot to manage investments for a group of investors. The bot periodically collects accumulated fees and rewards from liquidity positions to distribute profits among investors. By using the SDK, you can generate the instructions to collect earnings from each active position without closing it, allowing the liquidity to continue generating returns and potentially reinvest your earned fees into the position.4. Next Steps
After harvesting fees and rewards, you can:- Monitor Performance: Keep track of your position to evaluate future earnings and the overall performance.
- Reinvest Earnings: Use the harvested fees and rewards to add more liquidity or diversify your positions.
- Harvest Regularly: Regularly collect your earnings to maintain optimal capital efficiency while keeping your liquidity active.
