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

rollback unwrapping changes. #961

Closed
wants to merge 5 commits into from
Closed
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
4 changes: 3 additions & 1 deletion contracts/plugins/assets/compoundv2/CTokenWrapper.sol
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ contract CTokenWrapper is RewardableERC20Wrapper {
// === Overrides ===

function _claimAssetRewards() internal virtual override {
comptroller.claimComp(address(this));
address[] memory cTokens = new address[](1);
cTokens[0] = address(underlying);
comptroller.claimComp(address(this), cTokens);
}

// No overrides of _deposit()/_withdraw() necessary: no staking required
Expand Down
2 changes: 1 addition & 1 deletion contracts/plugins/assets/compoundv2/ICToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ interface ICToken is IERC20Metadata {

interface IComptroller {
/// Claim comp for an account, to an account
function claimComp(address account) external;
function claimComp(address account, address[] memory cTokens) external;

/// @return The address for COMP token
function getCompAddress() external view returns (address);
Expand Down
4 changes: 3 additions & 1 deletion contracts/plugins/mocks/CTokenWrapperMock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ contract CTokenWrapperMock is ERC20Mock, IRewardable {
revert("reverting claim rewards");
}
uint256 oldBal = comp.balanceOf(msg.sender);
comptroller.claimComp(msg.sender);
address[] memory cTokens = new address[](1);
cTokens[0] = address(underlying);
comptroller.claimComp(msg.sender, cTokens);
emit RewardsClaimed(IERC20(address(comp)), comp.balanceOf(msg.sender) - oldBal);
}

Expand Down
2 changes: 1 addition & 1 deletion contracts/plugins/mocks/ComptrollerMock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ contract ComptrollerMock is IComptroller {
compBalances[recipient] = amount;
}

function claimComp(address holder) external {
function claimComp(address holder, address[] memory) external {
// Mint amount and update internal balances
if (address(compToken) != address(0)) {
uint256 amount = compBalances[holder];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,27 @@ async function main() {
const deployedCollateral: string[] = []

/******** Deploy FToken Fiat Collateral - fUSDC **************************/
const FTokenFactory = await ethers.getContractFactory('CTokenWrapper')
const fUsdc = await ethers.getContractAt('IERC20Metadata', networkConfig[chainId].tokens.fUSDC!)

const fUsdcVault = await FTokenFactory.deploy(
networkConfig[chainId].tokens.fUSDC!,
`${await fUsdc.name()} Vault`,
`${await fUsdc.symbol()}-VAULT`,
networkConfig[chainId].FLUX_FINANCE_COMPTROLLER!
)

await fUsdcVault.deployed()

console.log(
`Deployed Vault for fUSDC on ${hre.network.name} (${chainId}): ${fUsdcVault.address} `
)

const { collateral: fUsdcCollateral } = await hre.run('deploy-ctoken-fiat-collateral', {
priceTimeout: priceTimeout.toString(),
priceFeed: networkConfig[chainId].chainlinkFeeds.USDC,
oracleError: fp('0.0025').toString(), // 0.25%
cToken: fUsdc.address,
cToken: fUsdcVault.address,
maxTradeVolume: fp('1e6').toString(), // $1m,
oracleTimeout: oracleTimeout(chainId, '86400').toString(), // 24 hr
targetName: hre.ethers.utils.formatBytes32String('USD'),
Expand All @@ -60,19 +74,32 @@ async function main() {
expect(await collateral.status()).to.equal(CollateralStatus.SOUND)

assetCollDeployments.collateral.fUSDC = fUsdcCollateral
assetCollDeployments.erc20s.fUSDC = fUsdc.address
assetCollDeployments.erc20s.fUSDC = fUsdcVault.address
deployedCollateral.push(fUsdcCollateral.toString())

fs.writeFileSync(assetCollDeploymentFilename, JSON.stringify(assetCollDeployments, null, 2))

/******** Deploy FToken Fiat Collateral - fUSDT **************************/
const fUsdt = await ethers.getContractAt('IERC20Metadata', networkConfig[chainId].tokens.fUSDT!)

const fUsdtVault = await FTokenFactory.deploy(
networkConfig[chainId].tokens.fUSDT!,
`${await fUsdt.name()} Vault`,
`${await fUsdt.symbol()}-VAULT`,
networkConfig[chainId].FLUX_FINANCE_COMPTROLLER!
)

await fUsdtVault.deployed()

console.log(
`Deployed Vault for fUSDT on ${hre.network.name} (${chainId}): ${fUsdtVault.address} `
)

const { collateral: fUsdtCollateral } = await hre.run('deploy-ctoken-fiat-collateral', {
priceTimeout: priceTimeout.toString(),
priceFeed: networkConfig[chainId].chainlinkFeeds.USDT,
oracleError: fp('0.0025').toString(), // 0.25%
cToken: fUsdt.address,
cToken: fUsdtVault.address,
maxTradeVolume: fp('1e6').toString(), // $1m,
oracleTimeout: oracleTimeout(chainId, '86400').toString(), // 24 hr
targetName: hre.ethers.utils.formatBytes32String('USD'),
Expand All @@ -85,19 +112,30 @@ async function main() {
expect(await collateral.status()).to.equal(CollateralStatus.SOUND)

assetCollDeployments.collateral.fUSDT = fUsdtCollateral
assetCollDeployments.erc20s.fUSDT = fUsdt.address
assetCollDeployments.erc20s.fUSDT = fUsdtVault.address
deployedCollateral.push(fUsdtCollateral.toString())

fs.writeFileSync(assetCollDeploymentFilename, JSON.stringify(assetCollDeployments, null, 2))

/******** Deploy FToken Fiat Collateral - fDAI **************************/
const fDai = await ethers.getContractAt('IERC20Metadata', networkConfig[chainId].tokens.fDAI!)

const fDaiVault = await FTokenFactory.deploy(
networkConfig[chainId].tokens.fDAI!,
`${await fDai.name()} Vault`,
`${await fDai.symbol()}-VAULT`,
networkConfig[chainId].FLUX_FINANCE_COMPTROLLER!
)

await fDaiVault.deployed()

console.log(`Deployed Vault for fDAI on ${hre.network.name} (${chainId}): ${fDaiVault.address} `)

const { collateral: fDaiCollateral } = await hre.run('deploy-ctoken-fiat-collateral', {
priceTimeout: priceTimeout.toString(),
priceFeed: networkConfig[chainId].chainlinkFeeds.DAI,
oracleError: fp('0.0025').toString(), // 0.25%
cToken: fDai.address,
cToken: fDaiVault.address,
maxTradeVolume: fp('1e6').toString(), // $1m,
oracleTimeout: oracleTimeout(chainId, '3600').toString(), // 1 hr
targetName: hre.ethers.utils.formatBytes32String('USD'),
Expand All @@ -110,19 +148,32 @@ async function main() {
expect(await collateral.status()).to.equal(CollateralStatus.SOUND)

assetCollDeployments.collateral.fDAI = fDaiCollateral
assetCollDeployments.erc20s.fDAI = fDai.address
assetCollDeployments.erc20s.fDAI = fDaiVault.address
deployedCollateral.push(fDaiCollateral.toString())

fs.writeFileSync(assetCollDeploymentFilename, JSON.stringify(assetCollDeployments, null, 2))

/******** Deploy FToken Fiat Collateral - fFRAX **************************/
const fFrax = await ethers.getContractAt('IERC20Metadata', networkConfig[chainId].tokens.fFRAX!)

const fFraxVault = await FTokenFactory.deploy(
networkConfig[chainId].tokens.fFRAX!,
`${await fFrax.name()} Vault`,
`${await fFrax.symbol()}-VAULT`,
networkConfig[chainId].FLUX_FINANCE_COMPTROLLER!
)

await fFraxVault.deployed()

console.log(
`Deployed Vault for fFRAX on ${hre.network.name} (${chainId}): ${fFraxVault.address} `
)

const { collateral: fFRAXCollateral } = await hre.run('deploy-ctoken-fiat-collateral', {
priceTimeout: priceTimeout.toString(),
priceFeed: networkConfig[chainId].chainlinkFeeds.FRAX,
oracleError: fp('0.01').toString(), // 1%
cToken: fFrax.address,
cToken: fFraxVault.address,
maxTradeVolume: fp('1e6').toString(), // $1m,
oracleTimeout: oracleTimeout(chainId, '3600').toString(), // 1 hr
targetName: hre.ethers.utils.formatBytes32String('USD'),
Expand All @@ -135,7 +186,7 @@ async function main() {
expect(await collateral.status()).to.equal(CollateralStatus.SOUND)

assetCollDeployments.collateral.fFRAX = fFRAXCollateral
assetCollDeployments.erc20s.fFRAX = fFrax.address
assetCollDeployments.erc20s.fFRAX = fFraxVault.address
deployedCollateral.push(fFRAXCollateral.toString())

fs.writeFileSync(assetCollDeploymentFilename, JSON.stringify(assetCollDeployments, null, 2))
Expand Down
Loading