From 33f51725473a03234b8d367389971ee05680c10a Mon Sep 17 00:00:00 2001 From: midnight-commit <43814957+midnight-commit@users.noreply.github.com> Date: Wed, 8 Feb 2023 11:22:49 +0100 Subject: [PATCH] add UspEchidnaStrategy --- .../VariableRewardsStrategyForSA.sol | 2 +- .../avalanche/echidna/UspEchidnaStrategy.sol | 29 +++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 contracts/strategies/avalanche/echidna/UspEchidnaStrategy.sol diff --git a/contracts/strategies/VariableRewardsStrategyForSA.sol b/contracts/strategies/VariableRewardsStrategyForSA.sol index d39d2c16..40b6a155 100644 --- a/contracts/strategies/VariableRewardsStrategyForSA.sol +++ b/contracts/strategies/VariableRewardsStrategyForSA.sol @@ -9,7 +9,7 @@ import "./VariableRewardsStrategy.sol"; * @notice Adapter strategy for VariableRewardsStrategy with SA deposit. */ abstract contract VariableRewardsStrategyForSA is VariableRewardsStrategy { - address private immutable swapPairDepositToken; + address internal immutable swapPairDepositToken; constructor( address _swapPairDepositToken, diff --git a/contracts/strategies/avalanche/echidna/UspEchidnaStrategy.sol b/contracts/strategies/avalanche/echidna/UspEchidnaStrategy.sol new file mode 100644 index 00000000..4ae3806f --- /dev/null +++ b/contracts/strategies/avalanche/echidna/UspEchidnaStrategy.sol @@ -0,0 +1,29 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.13; + +import "./EchidnaStrategy.sol"; + +contract UspEchidnaStrategy is EchidnaStrategy { + address public constant USP = 0xdaCDe03d7Ab4D81fEDdc3a20fAA89aBAc9072CE2; + IERC20 public constant USDC = IERC20(0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E); + + constructor( + EchidnaStrategySettings memory _echidnaStrategySettings, + VariableRewardsStrategySettings memory _variableRewardsStrategySettings, + StrategySettings memory _strategySettings + ) EchidnaStrategy(_echidnaStrategySettings, _variableRewardsStrategySettings, _strategySettings) {} + + function assignSwapPairSafely(address _swapPairDepositToken) internal override {} + + function _convertRewardTokenToDepositToken(uint256 _fromAmount) internal override returns (uint256 toAmount) { + // swap WAVAX to USDC + WAVAX.approve(address(swapPairDepositToken), _fromAmount); + uint256 usdcAmount = DexLibrary.swap(_fromAmount, address(WAVAX), address(USDC), IPair(swapPairDepositToken)); + WAVAX.approve(address(swapPairDepositToken), 0); + + // swap USDC to USP + USDC.approve(address(platypusPool), usdcAmount); + (toAmount, ) = platypusPool.swap(address(USDC), USP, usdcAmount, 0, address(this), type(uint256).max); + USDC.approve(address(platypusPool), 0); + } +}