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

[WIP] Replace DAI with USDS #2417

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from
Draft
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
2 changes: 1 addition & 1 deletion contracts/contracts/harvest/OETHHarvesterSimple.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-License-Identifier: BUSL-1.1
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import { Strategizable } from "../governance/Strategizable.sol";
Expand Down
2 changes: 1 addition & 1 deletion contracts/contracts/harvest/SuperOETHHarvester.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-License-Identifier: BUSL-1.1
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import { OETHHarvesterSimple, IERC20, IStrategy, SafeERC20 } from "./OETHHarvesterSimple.sol";
Expand Down
2 changes: 1 addition & 1 deletion contracts/contracts/interfaces/IVault.sol
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ interface IVault {
function setOracleSlippage(address _asset, uint16 _allowedOracleSlippageBps)
external;

function supportAsset(address _asset, uint8 _supportsAsset) external;
function supportAsset(address _asset, uint8 _unitConversion) external;

function approveStrategy(address _addr) external;

Expand Down
11 changes: 11 additions & 0 deletions contracts/contracts/oracle/OracleRouter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,17 @@ contract OracleRouter is AbstractOracleRouter {
// Chainlink: DAI/USD
feedAddress = 0xAed0c38402a5d19df6E4c03F4E2DceD6e29c1ee9;
maxStaleness = 1 hours + STALENESS_BUFFER;
} else if (asset == 0xdC035D45d973E3EC169d2276DDab16f1e407384F) {
// https://data.chain.link/ethereum/mainnet/stablecoins/dai-usd
// Chainlink: DAI/USD
feedAddress = 0xAed0c38402a5d19df6E4c03F4E2DceD6e29c1ee9;
maxStaleness = 1 hours + STALENESS_BUFFER;
// } else if (asset == 0xdC035D45d973E3EC169d2276DDab16f1e407384F) {
// solhint-disable-next-line
// // https://chroniclelabs.org/dashboard/oracle/USDS/USD?blockchain=ETH&txn=0x963edc177ee0cb8e5ecdb39b535b800c5037b2e2fc20b335e44a95a979d4719a&contract=0x74661a9ea74fD04975c6eBc6B155Abf8f885636c
// // Chronicle: USDS/USD
// feedAddress = 0x74661a9ea74fD04975c6eBc6B155Abf8f885636c;
// maxStaleness = 1 hours + STALENESS_BUFFER;
} else if (asset == 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48) {
// https://data.chain.link/ethereum/mainnet/stablecoins/usdc-usd
// Chainlink: USDC/USD
Expand Down
2 changes: 1 addition & 1 deletion contracts/contracts/proxies/BaseProxies.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-License-Identifier: BUSL-1.1
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import { InitializeGovernedUpgradeabilityProxy } from "./InitializeGovernedUpgradeabilityProxy.sol";
Expand Down
9 changes: 8 additions & 1 deletion contracts/contracts/proxies/Proxies.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-License-Identifier: BUSL-1.1
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import { InitializeGovernedUpgradeabilityProxy } from "./InitializeGovernedUpgradeabilityProxy.sol";
Expand Down Expand Up @@ -332,3 +332,10 @@ contract PoolBoostCentralRegistryProxy is
{

}

/**
* @notice MakerSSRStrategyProxy delegates calls to a Generalized4626Strategy implementation
*/
contract MakerSSRStrategyProxy is InitializeGovernedUpgradeabilityProxy {

}
126 changes: 126 additions & 0 deletions contracts/contracts/strategies/DAIMigratorStrategy.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import { InitializableAbstractStrategy } from "../utils/InitializableAbstractStrategy.sol";
import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";

interface IDaiUsdsMigrationContract {
function daiToUsds(address usr, uint256 wad) external;

function usdsToDai(address usr, uint256 wad) external;
}

contract DAIMigrationStrategy is InitializableAbstractStrategy {
address public immutable dai;
address public immutable usds;

constructor(
BaseStrategyConfig memory _baseConfig,
address _dai,
address _usds
) InitializableAbstractStrategy(_baseConfig) {
dai = _dai;
usds = _usds;
}

function initialize(address _governorAddr)
external
onlyGovernor
initializer
{
_setGovernor(_governorAddr);

address[] memory rewardTokens = new address[](0);
address[] memory assets = new address[](2);
address[] memory pTokens = new address[](2);

assets[0] = address(dai);
assets[1] = address(usds);
pTokens[0] = address(dai);
pTokens[1] = address(usds);

InitializableAbstractStrategy._initialize(
rewardTokens,
assets,
pTokens
);
}

function deposit(address _asset, uint256 _amount)
external
override
onlyVault
nonReentrant
{
_deposit(_asset, _amount);
}

function depositAll() external override onlyVault nonReentrant {
_deposit(dai, IERC20(dai).balanceOf(address(this)));
}

function _deposit(address _asset, uint256 _amount) internal {
// You can only deposit DAI
require(_asset == dai, "Only DAI can be deposited");
require(_amount > 0, "Must deposit something");

IERC20(dai).approve(platformAddress, _amount);
IDaiUsdsMigrationContract(platformAddress).daiToUsds(
address(this),
_amount
);
}

function withdraw(
address _recipient,
address _asset,
uint256 _amount
) external override onlyVault nonReentrant {
_withdraw(_recipient, _asset, _amount);
}

function withdrawAll() external override onlyVaultOrGovernor nonReentrant {
_withdraw(vaultAddress, usds, IERC20(usds).balanceOf(address(this)));
}

function _withdraw(
address _recipient,
address _asset,
uint256 _amount
) internal {
// You can only withdraw USDS
require(_asset == usds, "Unsupported asset");
require(_amount > 0, "Must withdraw something");
require(_recipient == vaultAddress, "Only the vault can withdraw");
IERC20(usds).transfer(_recipient, _amount);
}

function checkBalance(address _asset)
external
view
override
returns (uint256 balance)
{
if (_asset == dai) {
// Contract should not have any DAI at any point of time.
return 0;
} else if (_asset == usds) {
balance = IERC20(usds).balanceOf(address(this));
} else {
revert("Unsupported asset");
}
}

function supportsAsset(address _asset) public view override returns (bool) {
return _asset == dai || _asset == usds;
}

function collectRewardTokens() external override {}

function _abstractSetPToken(address _asset, address _pToken)
internal
override
{}

function safeApproveAllTokens() external override {}
}
Loading
Loading