# G-UNI Valuation Function Task ## Context Here's the original `BondingCalculator.sol` module in OlympusDAO v1.1: https://github.com/OlympusDAO/olympus-contracts/blob/Version-1.1/contracts/StandardBondingCalculator.sol#L262 In OlympusDAO, this module used Uniswap v2 for liquidity pools and thus uses the Uniswap v2 protocol's API for valuation, and can assume LP tokens are fungible within a given pool. These LP tokens form a currency for a bond market. Barnbridge needs a modified version of this code thats compatibable with Uniswap v3. However, Uniswap v3's LP tokens are NFTs (ERC721 to be specific). Therefore, we can use Gelato's G-UNI (now called [Arakis](https://docs.arrakis.fi/developer-docs)) service to turn the Uniswap v3 LP positions into fungible, ERC20 tokens. This is reflected in Linum's Barnbridge codebase, here: https://github.com/LinumLabs/barnbridge-v2-chain/blob/main/contracts/BondCalculator.sol#L319 ## To Do The steps below are a guideline, but use your own experience and knowledge to complete the overarching goals here: 1) **completing the LP Token bond logic in the contracts**, and 2) **writing tests for LP Token bonds.** 1. Make sure these funcitons in the contract have been sufficiently changed to reflect the G-UNI API: [getKValue (there is already progress on a G-Uni version of this function below in the codebase, check it and modify it if necessary)](https://github.com/LinumLabs/barnbridge-v2-chain/blob/main/contracts/BondCalculator.sol#L289) [getTotalValue (which depends on getKValue)](https://github.com/LinumLabs/barnbridge-v2-chain/blob/main/contracts/BondCalculator.sol#L307) [valuation (which has some logic, but needs to incorporate the modified getTotalValue function, see the commented out original version of the valuation function below)](https://github.com/LinumLabs/barnbridge-v2-chain/blob/main/contracts/BondCalculator.sol#L319) 2. The `Treasury` module uses the BondCalculator logic above, over [here](https://github.com/OlympusDAO/olympus-contracts/blob/Version-1.1/contracts/Treasury.sol#L471) - consider this when writing tests. 3. Write unit tests for the functions in the `BondCalculator` contract, that have been changed compared to the original OlympusDAO v1.1 code. Also write 1 or 2 scenario tests that go through the process of setting up an LP token bond market and involve a user buying BARN bonds using that LP token. This [test file](https://github.com/LinumLabs/barnbridge-v2-chain/blob/main/test/LP_bonds.test.ts#L65) is a good starting point.