Skip to content

Commit

Permalink
TPF: draft implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
a17 committed Oct 27, 2024
1 parent 4b3f022 commit d218c4f
Show file tree
Hide file tree
Showing 7 changed files with 245 additions and 31 deletions.
22 changes: 17 additions & 5 deletions chains/RealLib.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {DiaAdapter} from "../src/adapters/DiaAdapter.sol";
import {ILiquidBoxFactory} from "../src/integrations/pearl/ILiquidBoxFactory.sol";
import {ILiquidBox} from "../src/integrations/pearl/ILiquidBox.sol";
import {IGaugeV2CL} from "../src/integrations/pearl/IGaugeV2CL.sol";
import {TridentPearlFarmStrategy} from "../src/strategies/TridentPearlFarmStrategy.sol";

/// @dev Re.al network [chainId: 111188] data library
/// ______ _
Expand Down Expand Up @@ -135,21 +136,30 @@ library RealLib {
ISwapper swapper = ISwapper(IPlatform(platform).swapper());
swapper.addBlueChipsPools(bcPools, false);
swapper.addPools(pools, false);
address[] memory tokenIn = new address[](1);
address[] memory tokenIn = new address[](3);
tokenIn[0] = TOKEN_USDC;
tokenIn[1] = TOKEN_PEARL;
tokenIn[2] = TOKEN_MORE;
// todo thresholds
uint[] memory thresholdAmount = new uint[](1);
thresholdAmount[0] = 1e3;
uint[] memory thresholdAmount = new uint[](3);
thresholdAmount[0] = 1e4;
thresholdAmount[1] = 1e15;
thresholdAmount[2] = 1e15;
swapper.setThresholds(tokenIn, thresholdAmount);
LogDeployLib.logSetupSwapper(platform, showLog);
}
//endregion -- Setup Swapper -----
//endregion ----- Setup Swapper -----

//region ----- Add farms -----
factory.addFarms(farms());
LogDeployLib.logAddedFarms(address(factory), showLog);
//endregion -- Add farms -----

//region ----- Deploy strategy logics -----
_addStrategyLogic(factory, StrategyIdLib.TRIDENT_PEARL_FARM, address(new TridentPearlFarmStrategy()), true);
LogDeployLib.logDeployStrategies(platform, showLog);
//endregion -- Deploy strategy logics -----

// ...
}

Expand Down Expand Up @@ -204,16 +214,18 @@ library RealLib {
function _makeTridentPearlFarm(address pool) internal view returns (IFactory.Farm memory) {
address alm = ILiquidBoxFactory(TRIDENT_LIQUID_BOX_FACTORY).getBoxByPool(pool);
address gauge = ILiquidBox(alm).gauge();
address boxManager = ILiquidBoxFactory(TRIDENT_LIQUID_BOX_FACTORY).boxManager();

IFactory.Farm memory farm;
farm.status = 0;
farm.pool = pool;
farm.strategyLogicId = StrategyIdLib.TRIDENT_PEARL_FARM;
farm.rewardAssets = new address[](1);
farm.rewardAssets[0] = IGaugeV2CL(gauge).rewardToken();
farm.addresses = new address[](2);
farm.addresses = new address[](3);
farm.addresses[0] = alm;
farm.addresses[1] = gauge;
farm.addresses[2] = boxManager;
farm.nums = new uint[](0);
farm.ticks = new int24[](0);
return farm;
Expand Down
13 changes: 12 additions & 1 deletion src/integrations/pearl/ILiquidBox.sol
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,13 @@ interface ILiquidBox {
* other words, how much of each token the vault would hold if it withdrew
* all its liquidity from Uniswap.
*/
function getTotalAmounts() external view returns (uint total0, uint total1, uint128 liquidity);
function getTotalAmounts() external view returns (
uint total0,
uint total1,
uint pool0,
uint pool1,
uint128 liquidity
);

/**
* @dev Returns the amount of tokens in existence.
Expand All @@ -57,4 +63,9 @@ interface ILiquidBox {
function token1() external view returns (address);

function gauge() external view returns (address);

function getRequiredAmountsForInput(
uint amount0,
uint amount1
) external view returns (uint, uint);
}
2 changes: 2 additions & 0 deletions src/integrations/pearl/ILiquidBoxFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@ pragma solidity ^0.8.23;

interface ILiquidBoxFactory {
function getBoxByPool(address pool) external view returns (address);

function boxManager() external view returns (address);
}
19 changes: 19 additions & 0 deletions src/integrations/pearl/ILiquidBoxManager.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.23;

interface ILiquidBoxManager {
function deposit(
address box,
uint deposit0,
uint deposit1,
uint amount0Min,
uint amount1Min
) external payable returns (uint shares);

function withdraw(
address box,
uint shares,
uint amount0Min,
uint amount1Min
) external returns (uint amount0, uint amount1);
}
Loading

0 comments on commit d218c4f

Please sign in to comment.