Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add estimated APR to the baseStrategy as common to all strat #64

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -857,7 +857,7 @@ contract AaveFlashloanStrategy is BaseStrategyUpgradeable, IERC3156FlashBorrower
borrow = uint256(ComputeProfitability.computeProfitability(parameters)) / normalizationFactor;
}

function estimatedAPR() public view returns (uint256) {
function estimatedAPR() public view override returns (uint256) {
(
,
,
Expand Down
3 changes: 3 additions & 0 deletions contracts/strategies/BaseStrategyUpgradeable.sol
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,9 @@ abstract contract BaseStrategyUpgradeable is BaseStrategyEvents, AccessControlAn
/// mechanisms).
function estimatedTotalAssets() public view virtual returns (uint256);

/// @notice Returns the strategy estimated apr
function estimatedAPR() external view virtual returns (uint256);

/// @notice Provides an indication of whether this strategy is currently "active"
/// in that it is managing an active position, or will manage a position in
/// the future. This should correlate to `harvest()` activity, so that Harvest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ contract OptimizerAPRGreedyStrategy is BaseStrategyUpgradeable {
}

/// @notice The weighted apr of all lenders. sum(nav * apr)/totalNav
function estimatedAPR() external view returns (uint256) {
function estimatedAPR() external view override returns (uint256) {
uint256 bal = estimatedTotalAssets();
if (bal == 0) {
return 0;
Expand Down
2 changes: 1 addition & 1 deletion contracts/strategies/OptimizerAPR/OptimizerAPRStrategy.sol
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ contract OptimizerAPRStrategy is BaseStrategyUpgradeable {

/// @notice Returns the weighted apr of all lenders
/// @dev It's computed by doing: `sum(nav * apr) / totalNav`
function estimatedAPR() external view returns (uint256) {
function estimatedAPR() external view override returns (uint256) {
uint256 bal = estimatedTotalAssets();
if (bal == 0) {
return 0;
Expand Down
2 changes: 1 addition & 1 deletion contracts/strategies/StETHStrategy/StETHStrategy.sol
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ contract StETHStrategy is BaseStrategyUpgradeable {
}

/// @notice The ETH APR of owning stETH
function estimatedAPR() external view returns (uint256) {
function estimatedAPR() external view override returns (uint256) {
return apr;
}

Expand Down
20 changes: 16 additions & 4 deletions test/foundry/DebugTest.test.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import "./BaseTest.test.sol";
import { IEuler, IEulerMarkets, IEulerEToken, IEulerDToken } from "../../contracts/interfaces/external/euler/IEuler.sol";
import { IReserveInterestRateStrategy } from "../../contracts/interfaces/external/aave/IAave.sol";
import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import { GenericEuler } from "../../contracts/strategies/OptimizerAPR/genericLender/euler/GenericEuler.sol";

interface IBaseIRM {
function baseRate() external view returns (uint256);
Expand All @@ -19,6 +20,8 @@ interface IBaseIRM {
contract DebugTest is BaseTest {
using stdStorage for StdStorage;

error Err();

function setUp() public override {
_ethereum = vm.createFork(vm.envString("ETH_NODE_URI_ETH_FOUNDRY"));
vm.selectFork(_ethereum);
Expand All @@ -29,15 +32,24 @@ contract DebugTest is BaseTest {
// ================================== DEPOSIT ==================================

function testBorrow() public {
address payable sender = payable(0x120afC8541F58cf78bE57553Adabe73CA0ee4B5d);
address payable sender = payable(0xcC617C6f9725eACC993ac626C7efC6B96476916E);
IERC20 asset = IERC20(0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48);
address _contract = 0x4579709627CA36BCe92f51ac975746f431890930;
address _contract = 0xa0062b7A5e494d569059E2f1A98B5f6C99BFAAfe;
bytes
memory data = hex"848c48da000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000900000000000000000000000000000000000000000000000000000000000000090000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000e00000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000060000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000e1a6d84604c5b17f5fd1fccba4c385a8b9670266000000000000000000000000000000000000000000000000000000174876e8000000000000000000000000000000000000000000000000000000000000000900000000000000000000000000c68421f20bf6f0eb475f00b9c5484f7d0ac0331e0000000000000000000000000652b4b3d205300f9848f0431296d67ca4397f3b000000000000000000000000e1a6d84604c5b17f5fd1fccba4c385a8b9670266000000000000000000000000e1a6d84604c5b17f5fd1fccba4c385a8b967026600000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000000000000000000000000000000000000000016000000000000000000000000000000000000000000000000000000000000002e000000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000050000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000120afc8541f58cf78be57553adabe73ca0ee4b5d00000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004380df26d30c14b5d3e000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002b19210715ad62a3c0010000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000005600000000000000000000000000000000000000000000000000000000000000001000000000000000000000000e1a6d84604c5b17f5fd1fccba4c385a8b9670266000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000004e0000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000004c00000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004200000000000000000000000001a7e4e63778b4f12a199c062f3efdd288afcbce8000000000000000000000000000000000000000000000000000000333227c0b10000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000038812aa3caf0000000000000000000000007122db0ebe4eb9b434a9f2ffe6760bc03bfbd0e00000000000000000000000001a7e4e63778b4f12a199c062f3efdd288afcbce8000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000000000000000000000007122db0ebe4eb9b434a9f2ffe6760bc03bfbd0e0000000000000000000000000e1a6d84604c5b17f5fd1fccba4c385a8b9670266000000000000000000000000000000000000000000002b19210715ad62a3c00000000000000000000000000000000000000000000000000000000033152e91fa000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000001400000000000000000000000000000000000000000000000000000000000000160000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001e30000000000000000000000000000000000000000000001c500019700014d00a0c9e75c480000000000000000240e00000000000000000000000000000000000000000000000000011f0000d051005addc89785d75c86ab939e9e15bfbbb7fc086a871a7e4e63778b4f12a199c062f3efdd288afcbce800046d10421600000000000000000000000000000000000000000000000000000000000000000000000000000000000000007122db0ebe4eb9b434a9f2ffe6760bc03bfbd0e00000000000000000000000007122db0ebe4eb9b434a9f2ffe6760bc03bfbd0e0000000000000000000000000e9f183fc656656f1f17af1f2b0df79b8ff9ad8ed000000000000000000000000000000000000000000000000000000000000000102a000000000000000000000000000000000000000000000000000000024cc4c56bfee63c1e501735a26a57a0a0069dfabd41595a970faf5e1ee8b1a7e4e63778b4f12a199c062f3efdd288afcbce800a0f2fa6b66a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000000000000000000000000000000000000000000000000000003399465038000000000000000000000000004c687c80a06c4eca27a0b86991c6218b36c1d19d4a2e9eb0ce3606eb481111111254eeb25477b68fb85ed929f73a9605820000000000000000000000000000000000000000000000000000000000cfee7c08000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001e0000000000000000000000000c68421f20bf6f0eb475f00b9c5484f7d0ac0331e0000000000000000000000000652b4b3d205300f9848f0431296d67ca4397f3b000000000000000000000000120afc8541f58cf78be57553adabe73ca0ee4b5d000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000000000000000000000000000000000000000012000000000000000000000000000000000000000000000000000000000000001c0000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000000000000000000000000000000000000000000000000000000000000000";
memory data = hex"5cca04a400000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000024000000000000000000000000000000000000000000000000000000000000003c00000000000000000000000000000000000000000000000000000000000000460000000000000000000000000000000000000000000000000000000000000050000000000000000000000000000000000000000000000000000000000000005a00000000000000000000000005577f822a979b7456ca08c5e311067d777e734c40000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e4ce5c7f61000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000270f0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000bfa4459868c60da9edd835f0be684edec054557b0000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e4ce5c7f61000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000206a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006a6000000000000000000000000000000000000000000000000000000000000000000000000000000002d78b6f5dc8985d90145f27c8f5a3782eb9deb2e0000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000044641257d00000000000000000000000000000000000000000000000000000000000000000000000000000000c9daabc677f3d1301006e723bd21c60be57a591500000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000419106b6700000000000000000000000000000000000000000000000000000000000000000000000000000000e9f183fc656656f1f17af1f2b0df79b8ff9ad8ed00000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000419106b67000000000000000000000000000000000000000000000000000000000000000000000000000000006b4ee7352406707003bc6f6b96595fd35925af4800000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000419106b6700000000000000000000000000000000000000000000000000000000";

vm.prank(_GUARDIAN);
GenericEuler(0xf5aD02F3DbBF4b42DEE1f1255607f929CA2a7c5a).emergencyWithdraw(1);
vm.startPrank(sender);
asset.approve(_contract, type(uint256).max);
// asset.approve(_contract, type(uint256).max);

(bool success, bytes memory result) = _contract.call(data);
if (!success) revert Err();

console.log("aave ", GenericEuler(0xe4377620697Be18E6d6aa911CA488571EeB3f081).nav());
console.log("compound ", GenericEuler(0xE2773fB045e53De5344f245E03eA614AF1064Ce3).nav());
console.log("euler ", GenericEuler(0xf5aD02F3DbBF4b42DEE1f1255607f929CA2a7c5a).nav());

vm.stopPrank();
}

Expand Down