Skip to content

Commit 925d729

Browse files
authored
Merge pull request #702 from fei-protocol/feat-seed-turbo
Seed Turbo Fuse pool with Fei
2 parents 24b9c02 + a98b59c commit 925d729

File tree

10 files changed

+148
-16
lines changed

10 files changed

+148
-16
lines changed

contracts/pcv/PCVDeposit.sol

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,19 @@ abstract contract PCVDeposit is IPCVDeposit, CoreRef {
4646

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

49+
function balanceReportedIn() public view virtual override returns (address);
50+
4951
function resistantBalanceAndFei()
5052
public
5153
view
5254
virtual
5355
override
5456
returns (uint256, uint256)
5557
{
56-
return (balance(), 0);
58+
uint256 tokenBalance = balance();
59+
return (
60+
tokenBalance,
61+
balanceReportedIn() == address(fei()) ? tokenBalance : 0
62+
);
5763
}
5864
}

contracts/pcv/liquity/BAMMDeposit.sol

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,6 @@ import "@openzeppelin/contracts/utils/math/Math.sol";
1212
contract BAMMDeposit is PCVDeposit {
1313
using SafeERC20 for IERC20;
1414

15-
/// @notice LUSD, the reported token for BAMM
16-
address public constant override balanceReportedIn =
17-
address(0x5f98805A4E8be255a32880FDeC7F6728C6568bA0);
18-
1915
/// @notice B. Protocol BAMM address
2016
IBAMM public constant BAMM =
2117
IBAMM(0x0d3AbAA7E088C2c82f54B2f47613DA438ea8C598);
@@ -31,7 +27,7 @@ contract BAMMDeposit is PCVDeposit {
3127

3228
/// @notice deposit into B Protocol BAMM
3329
function deposit() external override whenNotPaused {
34-
IERC20 lusd = IERC20(balanceReportedIn);
30+
IERC20 lusd = IERC20(balanceReportedIn());
3531
uint256 amount = lusd.balanceOf(address(this));
3632

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

56-
IERC20(balanceReportedIn).safeTransfer(to, amount);
52+
IERC20(balanceReportedIn()).safeTransfer(to, amount);
5753
emit Withdrawal(msg.sender, to, amount);
5854
}
5955

56+
/// @notice LUSD, the reported token for BAMM
57+
function balanceReportedIn() public pure override returns (address) {
58+
return address(0x5f98805A4E8be255a32880FDeC7F6728C6568bA0);
59+
}
60+
6061
/// @notice report LUSD balance of BAMM
6162
// proportional amount of BAMM USD value held by this contract
6263
function balance() public view override returns (uint256) {

contracts/peg/PegStabilityModule.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ contract PegStabilityModule is
390390
}
391391

392392
/// @notice returns address of token this contracts balance is reported in
393-
function balanceReportedIn() external view override returns (address) {
393+
function balanceReportedIn() public view override returns (address) {
394394
return address(underlyingToken);
395395
}
396396

proposals/dao/fip_97.ts

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
import { ethers } from 'hardhat';
2+
import { expect } from 'chai';
3+
import {
4+
DeployUpgradeFunc,
5+
NamedAddresses,
6+
SetupUpgradeFunc,
7+
TeardownUpgradeFunc,
8+
ValidateUpgradeFunc
9+
} from '@custom-types/types';
10+
import { getImpersonatedSigner } from '@test/helpers';
11+
12+
/*
13+
14+
OA Proposal 97
15+
16+
Description:
17+
18+
Steps:
19+
1. Deploy Turbo Fuse pool PCV deposit
20+
2. Transfer $10 million Fei to the PCV Deposit
21+
3. Deposit the Fei into the pool
22+
*/
23+
24+
const fipNumber = '97'; // Change me!
25+
26+
// Do any deployments
27+
// This should exclusively include new contract deployments
28+
const deploy: DeployUpgradeFunc = async (deployAddress: string, addresses: NamedAddresses, logging: boolean) => {
29+
// 1. Deploy compound PCV deposit
30+
const erc20CompoundPCVDepositFactory = await ethers.getContractFactory('ERC20CompoundPCVDeposit');
31+
const turboFusePCVDeposit = await erc20CompoundPCVDepositFactory.deploy(addresses.core, addresses.rariTurboFusePool);
32+
await turboFusePCVDeposit.deployTransaction.wait();
33+
logging && console.log('Turbo PCV Deposit deployed to: ', turboFusePCVDeposit.address);
34+
35+
return {
36+
turboFusePCVDeposit
37+
};
38+
};
39+
40+
// Do any setup necessary for running the test.
41+
// This could include setting up Hardhat to impersonate accounts,
42+
// ensuring contracts have a specific state, etc.
43+
const setup: SetupUpgradeFunc = async (addresses, oldContracts, contracts, logging) => {
44+
// feiDAOTimelock is TURBO_ADMIN_ROLE
45+
const governorSigner = await getImpersonatedSigner(addresses.feiDAOTimelock);
46+
47+
const turboAdminABI = ['function _setWhitelistStatuses(address[] calldata suppliers, bool[] calldata statuses)'];
48+
const turboAdmin = new ethers.Contract(addresses.turboAdmin, turboAdminABI, governorSigner);
49+
await turboAdmin._setWhitelistStatuses([contracts.turboFusePCVDeposit.address], [true]);
50+
};
51+
52+
// Tears down any changes made in setup() that need to be
53+
// cleaned up before doing any validation checks.
54+
const teardown: TeardownUpgradeFunc = async (addresses, oldContracts, contracts, logging) => {
55+
console.log(`No actions to complete in teardown for fip${fipNumber}`);
56+
};
57+
58+
// Run any validations required on the fip using mocha or console logging
59+
// IE check balances, check state of contracts, etc.
60+
const validate: ValidateUpgradeFunc = async (addresses, oldContracts, contracts, logging) => {
61+
// Validate 10M Fei was seeded
62+
const seedAmount = ethers.constants.WeiPerEther.mul(10_000_000); // 10 M
63+
const pcvBalance = await contracts.turboFusePCVDeposit.balance();
64+
expect(pcvBalance).to.equal(seedAmount);
65+
};
66+
67+
export { deploy, setup, teardown, validate };

proposals/description/fip_97.ts

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import { ProposalDescription } from '@custom-types/types';
2+
3+
const fip_97: ProposalDescription = {
4+
title: 'FIP-97: Seed Turbo fuse pool with 10M Fei',
5+
commands: [
6+
{
7+
target: 'fei',
8+
values: '0',
9+
method: 'transfer',
10+
arguments: ['{turboFusePCVDeposit}', '10000000000000000000000000'], // 10M
11+
description: 'Transfer $10M FEI from optimistic timelock to the Turbo Fuse PCV deposit'
12+
},
13+
{
14+
target: 'turboFusePCVDeposit',
15+
values: '0',
16+
method: 'deposit()',
17+
arguments: [],
18+
description: 'Deposit ~$10M of Fei into Turbo Fuse Pool'
19+
},
20+
{
21+
target: 'collateralizationOracle',
22+
values: '0',
23+
method: 'addDeposits(address[])',
24+
arguments: [['{turboFusePCVDeposit}']],
25+
description: 'Add new PCV Deposits to CR oracle'
26+
}
27+
],
28+
description: `
29+
OA action to seed Turbo fuse pool with $10M Fei. Transfer $10M Fei from the OA multisig to the Turbo Fuse PCV deposit
30+
and then deposit. Update the collaterization oracle to include the new deposit.
31+
`
32+
};
33+
34+
export default fip_97;

protocol-configuration/collateralizationOracle.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@ const collateralizationAddresses = {
1515
'rariPool72FeiPCVDepositWrapper',
1616
'rariPool128FeiPCVDepositWrapper',
1717
'rariPool22FeiPCVDepositWrapper',
18-
'feiBuybackLensNoFee'
18+
'feiBuybackLensNoFee',
19+
'convexPoolPCVDepositWrapper',
20+
'compoundPCVDepositWrapper',
21+
'turboFusePCVDeposit'
1922
],
2023
lusd: [
2124
'liquityFusePoolLusdPCVDeposit',

protocol-configuration/mainnetAddresses.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1855,6 +1855,26 @@ const MainnetAddresses: MainnetAddresses = {
18551855
artifactName: 'RariGovernanceTokenUniswapDistributor',
18561856
address: '0x1fa69a416bcf8572577d3949b742fbb0a9cd98c7',
18571857
category: AddressCategory.Governance
1858+
},
1859+
rariTurboFusePool: {
1860+
artifactName: 'unknown',
1861+
address: '0x081E7C60bCB8A2e7E43076a2988068c0a6e69e27',
1862+
category: AddressCategory.Turbo
1863+
},
1864+
turboAdmin: {
1865+
artifactName: 'unknown',
1866+
address: '0x18413D61b335D2F46235E9E1256Fd5ec8AD03757',
1867+
category: AddressCategory.Turbo
1868+
},
1869+
convexPoolPCVDepositWrapper: {
1870+
artifactName: 'PCVDepositWrapper',
1871+
address: '0x1370CA8655C255948d6c6110066d78680601B7c2',
1872+
category: AddressCategory.PCV
1873+
},
1874+
compoundPCVDepositWrapper: {
1875+
artifactName: 'PCVDepositWrapper',
1876+
address: '0xB80B3dc4F8B30589477b2bA0e4EF2b8224bDf0a5',
1877+
category: AddressCategory.PCV
18581878
}
18591879
};
18601880

test/integration/proposals_config.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
import { ProposalCategory, ProposalsConfigMap } from '@custom-types/types';
22

3-
import fip_94 from '@proposals/description/fip_94';
3+
import fip_97 from '@proposals/description/fip_97';
44

55
const proposals: ProposalsConfigMap = {
6-
fip_94: {
7-
deploy: false,
6+
fip_97: {
7+
deploy: true,
88
proposalId: null,
9-
affectedContractSignoff: ['rariTimelock'],
9+
affectedContractSignoff: ['turboFusePCVDeposit'],
1010
deprecatedContractSignoff: [],
11-
category: ProposalCategory.DAO,
11+
category: ProposalCategory.OA,
1212
totalValue: 0,
13-
proposal: fip_94
13+
proposal: fip_97
1414
}
1515
};
1616

test/integration/tests/fip-38-tokemak.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const TOKEMAK_MANAGER_ROLLOVER_ADDRESS = '0x90b6C61B102eA260131aB48377E143D6EB3A
1414
const TOKEMAK_MANAGER_ADDRESS = '0xa86e412109f77c45a3bc1c5870b880492fb86a14'; // tokemak manager
1515
const IPFS_JSON_FILE_HASH = 'QmP4Vzg45jExr3mcNsx9xxV1fNft95uVzgZGeLtkBXgpkx';
1616

17-
describe.only('e2e-fip-38-tokemak', function () {
17+
describe('e2e-fip-38-tokemak', function () {
1818
let contracts: NamedContracts;
1919
let deployAddress: string;
2020
let e2eCoord: TestEndtoEndCoordinator;

types/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ export enum AddressCategory {
124124
Keeper = 'Keeper',
125125
Rewards = 'Rewards',
126126
FeiRari = 'FeiRari',
127+
Turbo = 'Turbo',
127128
External = 'External',
128129
Deprecated = 'Deprecated',
129130
TBD = 'TBD'

0 commit comments

Comments
 (0)