diff --git a/src/peripheral/BaseUniV2Compounder.sol b/src/peripheral/BaseUniV2Compounder.sol index c6f8bfb4..3dd3379a 100644 --- a/src/peripheral/BaseUniV2Compounder.sol +++ b/src/peripheral/BaseUniV2Compounder.sol @@ -5,6 +5,7 @@ pragma solidity ^0.8.25; import {UniswapV2TradeLibrary, IUniswapRouterV2} from "./UniswapV2TradeLibrary.sol"; import {IERC20} from "openzeppelin-contracts/token/ERC20/IERC20.sol"; +import {IERC20Metadata} from "openzeppelin-contracts/token/ERC20/extensions/IERC20Metadata.sol"; import {SafeERC20} from "openzeppelin-contracts/token/ERC20/utils/SafeERC20.sol"; import {Math} from "openzeppelin-contracts/utils/math/Math.sol"; @@ -32,8 +33,15 @@ abstract contract BaseUniV2Compounder { uint256 totAmount = IERC20(sellTokens[i]).balanceOf(address(this)); // sell half for tokenA + uint256 decimals = IERC20Metadata(sellTokens[i]).decimals(); + uint256 amount = totAmount.mulDiv( + 10**decimals, + 20**decimals, + Math.Rounding.Floor + ); + swap = sellSwaps[2 * i]; - uint256 amount = totAmount.mulDiv(1e18, 2e18, Math.Rounding.Floor); + if (amount > 0) { UniswapV2TradeLibrary.trade(router, swap.path, address(this), block.timestamp, amount, 0); } diff --git a/src/strategies/peapods/PeapodsBalancerUniV2Compounder.sol b/src/strategies/peapods/PeapodsBalancerUniV2Compounder.sol index 29d4cf41..931ddc80 100644 --- a/src/strategies/peapods/PeapodsBalancerUniV2Compounder.sol +++ b/src/strategies/peapods/PeapodsBalancerUniV2Compounder.sol @@ -43,7 +43,7 @@ contract PeapodsDepositorBalancerUniV2Compounder is PeapodsDepositor, BaseBalanc /// @notice The token rewarded from the pendle market function rewardTokens() external view override returns (address[] memory) { - return _getRewardTokens(); + return sellTokens; } /*////////////////////////////////////////////////////////////// @@ -82,9 +82,4 @@ contract PeapodsDepositorBalancerUniV2Compounder is PeapodsDepositor, BaseBalanc setUniswapTradeValues(newUniswapRouter, rewTokens, newSwapSteps); setBalancerLpCompounderValues(newBalancerVault, newTradePaths, harvestValues_); } - - function _getRewardTokens() internal view returns (address[] memory tokens) { - tokens = new address[](1); - tokens[0] = poolRewards.rewardsToken(); - } } diff --git a/src/strategies/peapods/PeapodsUniswapV2Compounder.sol b/src/strategies/peapods/PeapodsUniswapV2Compounder.sol index b4b4ef61..2f19e9bd 100644 --- a/src/strategies/peapods/PeapodsUniswapV2Compounder.sol +++ b/src/strategies/peapods/PeapodsUniswapV2Compounder.sol @@ -42,7 +42,7 @@ contract PeapodsDepositorUniswapV2Compounder is PeapodsDepositor, BaseUniV2LpCom /// @notice The token rewarded from the pendle market function rewardTokens() external view override returns (address[] memory) { - return _getRewardTokens(); + return sellTokens; } /*////////////////////////////////////////////////////////////// @@ -66,11 +66,12 @@ contract PeapodsDepositorUniswapV2Compounder is PeapodsDepositor, BaseUniV2LpCom } function setHarvestValues( + address[] memory rewTokens, address newRouter, address[2] memory newDepositAssets, SwapStep[] memory newSwaps ) external onlyOwner { - setUniswapLpCompounderValues(newRouter, newDepositAssets, _getRewardTokens(), newSwaps); + setUniswapLpCompounderValues(newRouter, newDepositAssets, rewTokens, newSwaps); } // allow owner to withdraw eventual dust amount of tokens @@ -81,9 +82,4 @@ contract PeapodsDepositorUniswapV2Compounder is PeapodsDepositor, BaseUniV2LpCom IERC20(token).safeTransfer(owner, IERC20(token).balanceOf(address(this))); } - - function _getRewardTokens() internal view returns (address[] memory tokens) { - tokens = new address[](1); - tokens[0] = poolRewards.rewardsToken(); - } } diff --git a/test/strategies/peapods/PeapodsUniV2Compounder.json b/test/strategies/peapods/PeapodsUniV2Compounder.json index 8b151f0e..db6abf22 100644 --- a/test/strategies/peapods/PeapodsUniV2Compounder.json +++ b/test/strategies/peapods/PeapodsUniV2Compounder.json @@ -24,6 +24,12 @@ "0x3a590132Da355fdf36656807e9DB8ea1c9f4a431", "0x6B175474E89094C44Da98b954EedeAC495271d0F" ], + "rewards": { + "length": 1, + "tokens": [ + "0x02f92800F57BCD74066F5709F1Daa1A4302Df875" + ] + }, "tradePaths": [ { "length": "4", diff --git a/test/strategies/peapods/PeapodsUniswapV2Compounder.t.sol b/test/strategies/peapods/PeapodsUniswapV2Compounder.t.sol index 129eeed5..edcd0a05 100644 --- a/test/strategies/peapods/PeapodsUniswapV2Compounder.t.sol +++ b/test/strategies/peapods/PeapodsUniswapV2Compounder.t.sol @@ -74,7 +74,16 @@ contract PeapodsUniswapV2CompounderTest is BaseStrategyTest { swaps[0] = SwapStep(swap0); swaps[1] = SwapStep(swap1); - strategy.setHarvestValues(router, depositAssets, swaps); + // rewards + uint256 rewLen = json_.readUint(string.concat(".configs[", index_, "].specific.harvest.rewards.length")); + address[] memory rewardTokens = new address[](rewLen); + for(uint256 i=0; i