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

Seed Turbo Fuse pool with Fei #702

Merged
merged 7 commits into from
Apr 16, 2022
Merged
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
8 changes: 7 additions & 1 deletion contracts/pcv/PCVDeposit.sol
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,19 @@ abstract contract PCVDeposit is IPCVDeposit, CoreRef {

function balance() public view virtual override returns (uint256);

function balanceReportedIn() public view virtual override returns (address);

function resistantBalanceAndFei()
public
view
virtual
override
returns (uint256, uint256)
{
return (balance(), 0);
uint256 tokenBalance = balance();
return (
tokenBalance,
balanceReportedIn() == address(fei()) ? tokenBalance : 0
);
}
}
13 changes: 7 additions & 6 deletions contracts/pcv/liquity/BAMMDeposit.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@ import "@openzeppelin/contracts/utils/math/Math.sol";
contract BAMMDeposit is PCVDeposit {
using SafeERC20 for IERC20;

/// @notice LUSD, the reported token for BAMM
address public constant override balanceReportedIn =
address(0x5f98805A4E8be255a32880FDeC7F6728C6568bA0);

/// @notice B. Protocol BAMM address
IBAMM public constant BAMM =
IBAMM(0x0d3AbAA7E088C2c82f54B2f47613DA438ea8C598);
Expand All @@ -31,7 +27,7 @@ contract BAMMDeposit is PCVDeposit {

/// @notice deposit into B Protocol BAMM
function deposit() external override whenNotPaused {
IERC20 lusd = IERC20(balanceReportedIn);
IERC20 lusd = IERC20(balanceReportedIn());
uint256 amount = lusd.balanceOf(address(this));

lusd.safeApprove(address(BAMM), amount);
Expand All @@ -53,10 +49,15 @@ contract BAMMDeposit is PCVDeposit {
// Withdraw the LUSD from BAMM (also withdraws LQTY and dust ETH)
BAMM.withdraw(shares);

IERC20(balanceReportedIn).safeTransfer(to, amount);
IERC20(balanceReportedIn()).safeTransfer(to, amount);
emit Withdrawal(msg.sender, to, amount);
}

/// @notice LUSD, the reported token for BAMM
function balanceReportedIn() public pure override returns (address) {
return address(0x5f98805A4E8be255a32880FDeC7F6728C6568bA0);
}

/// @notice report LUSD balance of BAMM
// proportional amount of BAMM USD value held by this contract
function balance() public view override returns (uint256) {
Expand Down
2 changes: 1 addition & 1 deletion contracts/peg/PegStabilityModule.sol
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ contract PegStabilityModule is
}

/// @notice returns address of token this contracts balance is reported in
function balanceReportedIn() external view override returns (address) {
function balanceReportedIn() public view override returns (address) {
return address(underlyingToken);
}

Expand Down
67 changes: 67 additions & 0 deletions proposals/dao/fip_97.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import { ethers } from 'hardhat';
import { expect } from 'chai';
import {
DeployUpgradeFunc,
NamedAddresses,
SetupUpgradeFunc,
TeardownUpgradeFunc,
ValidateUpgradeFunc
} from '@custom-types/types';
import { getImpersonatedSigner } from '@test/helpers';

/*

OA Proposal 97

Description:

Steps:
1. Deploy Turbo Fuse pool PCV deposit
2. Transfer $10 million Fei to the PCV Deposit
3. Deposit the Fei into the pool
*/

const fipNumber = '97'; // Change me!

// Do any deployments
// This should exclusively include new contract deployments
const deploy: DeployUpgradeFunc = async (deployAddress: string, addresses: NamedAddresses, logging: boolean) => {
// 1. Deploy compound PCV deposit
const erc20CompoundPCVDepositFactory = await ethers.getContractFactory('ERC20CompoundPCVDeposit');
const turboFusePCVDeposit = await erc20CompoundPCVDepositFactory.deploy(addresses.core, addresses.rariTurboFusePool);
await turboFusePCVDeposit.deployTransaction.wait();
logging && console.log('Turbo PCV Deposit deployed to: ', turboFusePCVDeposit.address);

return {
turboFusePCVDeposit
};
};

// Do any setup necessary for running the test.
// This could include setting up Hardhat to impersonate accounts,
// ensuring contracts have a specific state, etc.
const setup: SetupUpgradeFunc = async (addresses, oldContracts, contracts, logging) => {
// feiDAOTimelock is TURBO_ADMIN_ROLE
const governorSigner = await getImpersonatedSigner(addresses.feiDAOTimelock);

const turboAdminABI = ['function _setWhitelistStatuses(address[] calldata suppliers, bool[] calldata statuses)'];
const turboAdmin = new ethers.Contract(addresses.turboAdmin, turboAdminABI, governorSigner);
await turboAdmin._setWhitelistStatuses([contracts.turboFusePCVDeposit.address], [true]);
};

// Tears down any changes made in setup() that need to be
// cleaned up before doing any validation checks.
const teardown: TeardownUpgradeFunc = async (addresses, oldContracts, contracts, logging) => {
console.log(`No actions to complete in teardown for fip${fipNumber}`);
};

// Run any validations required on the fip using mocha or console logging
// IE check balances, check state of contracts, etc.
const validate: ValidateUpgradeFunc = async (addresses, oldContracts, contracts, logging) => {
// Validate 10M Fei was seeded
const seedAmount = ethers.constants.WeiPerEther.mul(10_000_000); // 10 M
const pcvBalance = await contracts.turboFusePCVDeposit.balance();
expect(pcvBalance).to.equal(seedAmount);
};

export { deploy, setup, teardown, validate };
34 changes: 34 additions & 0 deletions proposals/description/fip_97.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { ProposalDescription } from '@custom-types/types';

const fip_97: ProposalDescription = {
title: 'FIP-97: Seed Turbo fuse pool with 10M Fei',
commands: [
{
target: 'fei',
values: '0',
method: 'transfer',
arguments: ['{turboFusePCVDeposit}', '10000000000000000000000000'], // 10M
description: 'Transfer $10M FEI from optimistic timelock to the Turbo Fuse PCV deposit'
},
{
target: 'turboFusePCVDeposit',
values: '0',
method: 'deposit()',
arguments: [],
description: 'Deposit ~$10M of Fei into Turbo Fuse Pool'
},
{
target: 'collateralizationOracle',
values: '0',
method: 'addDeposits(address[])',
arguments: [['{turboFusePCVDeposit}']],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah. You'll need to do a wrapper because the PCV deposit doesn't accurately report FEI

description: 'Add new PCV Deposits to CR oracle'
}
],
description: `
OA action to seed Turbo fuse pool with $10M Fei. Transfer $10M Fei from the OA multisig to the Turbo Fuse PCV deposit
and then deposit. Update the collaterization oracle to include the new deposit.
`
};

export default fip_97;
5 changes: 4 additions & 1 deletion protocol-configuration/collateralizationOracle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ const collateralizationAddresses = {
'rariPool72FeiPCVDepositWrapper',
'rariPool128FeiPCVDepositWrapper',
'rariPool22FeiPCVDepositWrapper',
'feiBuybackLensNoFee'
'feiBuybackLensNoFee',
'convexPoolPCVDepositWrapper',
'compoundPCVDepositWrapper',
'turboFusePCVDeposit'
],
lusd: [
'liquityFusePoolLusdPCVDeposit',
Expand Down
20 changes: 20 additions & 0 deletions protocol-configuration/mainnetAddresses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1855,6 +1855,26 @@ const MainnetAddresses: MainnetAddresses = {
artifactName: 'RariGovernanceTokenUniswapDistributor',
address: '0x1fa69a416bcf8572577d3949b742fbb0a9cd98c7',
category: AddressCategory.Governance
},
rariTurboFusePool: {
artifactName: 'unknown',
address: '0x081E7C60bCB8A2e7E43076a2988068c0a6e69e27',
category: AddressCategory.Turbo
},
turboAdmin: {
artifactName: 'unknown',
address: '0x18413D61b335D2F46235E9E1256Fd5ec8AD03757',
category: AddressCategory.Turbo
},
convexPoolPCVDepositWrapper: {
artifactName: 'PCVDepositWrapper',
address: '0x1370CA8655C255948d6c6110066d78680601B7c2',
category: AddressCategory.PCV
},
compoundPCVDepositWrapper: {
artifactName: 'PCVDepositWrapper',
address: '0xB80B3dc4F8B30589477b2bA0e4EF2b8224bDf0a5',
category: AddressCategory.PCV
}
};

Expand Down
12 changes: 6 additions & 6 deletions test/integration/proposals_config.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import { ProposalCategory, ProposalsConfigMap } from '@custom-types/types';

import fip_94 from '@proposals/description/fip_94';
import fip_97 from '@proposals/description/fip_97';

const proposals: ProposalsConfigMap = {
fip_94: {
deploy: false,
fip_97: {
deploy: true,
proposalId: null,
affectedContractSignoff: ['rariTimelock'],
affectedContractSignoff: ['turboFusePCVDeposit'],
deprecatedContractSignoff: [],
category: ProposalCategory.DAO,
category: ProposalCategory.OA,
totalValue: 0,
proposal: fip_94
proposal: fip_97
}
};

Expand Down
2 changes: 1 addition & 1 deletion test/integration/tests/fip-38-tokemak.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const TOKEMAK_MANAGER_ROLLOVER_ADDRESS = '0x90b6C61B102eA260131aB48377E143D6EB3A
const TOKEMAK_MANAGER_ADDRESS = '0xa86e412109f77c45a3bc1c5870b880492fb86a14'; // tokemak manager
const IPFS_JSON_FILE_HASH = 'QmP4Vzg45jExr3mcNsx9xxV1fNft95uVzgZGeLtkBXgpkx';

describe.only('e2e-fip-38-tokemak', function () {
describe('e2e-fip-38-tokemak', function () {
let contracts: NamedContracts;
let deployAddress: string;
let e2eCoord: TestEndtoEndCoordinator;
Expand Down
1 change: 1 addition & 0 deletions types/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ export enum AddressCategory {
Keeper = 'Keeper',
Rewards = 'Rewards',
FeiRari = 'FeiRari',
Turbo = 'Turbo',
External = 'External',
Deprecated = 'Deprecated',
TBD = 'TBD'
Expand Down