Skip to content

Commit af20f22

Browse files
authored
Merge pull request #584 from fei-protocol/feat/wrapperImprovements
wrapper
2 parents 2d9a77d + 30530d2 commit af20f22

File tree

3 files changed

+32
-29
lines changed

3 files changed

+32
-29
lines changed

contracts/pcv/utils/PCVDepositWrapper.sol

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,20 @@ import "../IPCVDepositBalances.sol";
1414
*/
1515
contract PCVDepositWrapper is IPCVDepositBalances {
1616
/// @notice the referenced PCV Deposit
17-
IPCVDepositBalances public pcvDeposit;
17+
IPCVDepositBalances public immutable pcvDeposit;
1818

1919
/// @notice the balance reported in token
20-
address public token;
20+
address public immutable token;
2121

2222
/// @notice a flag for whether to report the balance as protocol owned FEI
23-
bool public isProtocolFeiDeposit;
23+
bool public immutable isProtocolFeiDeposit;
2424

25-
constructor(
26-
IPCVDepositBalances _pcvDeposit,
27-
address _token,
28-
bool _isProtocolFeiDeposit
29-
) {
25+
address public constant FEI = 0x956F47F50A910163D8BF957Cf5846D573E7f87CA;
26+
27+
constructor(IPCVDepositBalances _pcvDeposit) {
3028
pcvDeposit = _pcvDeposit;
31-
token = _token;
32-
isProtocolFeiDeposit = _isProtocolFeiDeposit;
29+
token = _pcvDeposit.balanceReportedIn();
30+
isProtocolFeiDeposit = token == FEI;
3331
}
3432

3533
/// @notice returns total balance of PCV in the Deposit

scripts/deploy/wrapper.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { DeployUpgradeFunc } from '@custom-types/types';
2+
import { ethers } from 'hardhat';
3+
4+
export const deploy: DeployUpgradeFunc = async (deployAddress: string, addresses, logging = false) => {
5+
const { core } = addresses;
6+
7+
const DEPOSIT = process.env.DEPOSIT;
8+
9+
if (!DEPOSIT) {
10+
throw new Error('DEPOSIT environment variable contract address is not set');
11+
}
12+
13+
if (!core) {
14+
throw new Error('An environment variable contract address is not set');
15+
}
16+
17+
const wrapperFactory = await ethers.getContractFactory('PCVDepositWrapper');
18+
const wrapper = await wrapperFactory.deploy(DEPOSIT);
19+
20+
logging && console.log('wrapperFactory deployed to: ', wrapper.address);
21+
22+
return { wrapper };
23+
};

test/unit/pcv/utils/PCVDepositWrapper.test.ts

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,7 @@ describe('PCVDepositWrapper', function () {
5151
});
5252

5353
it('normal PCV deposit', async function () {
54-
const pcvDepositWrapper = await (
55-
await ethers.getContractFactory('PCVDepositWrapper')
56-
).deploy(deposit.address, token.address, false);
54+
const pcvDepositWrapper = await (await ethers.getContractFactory('PCVDepositWrapper')).deploy(deposit.address);
5755

5856
await token.mint(deposit.address, ethers.utils.parseEther('2000'));
5957
await deposit.deposit();
@@ -65,20 +63,4 @@ describe('PCVDepositWrapper', function () {
6563
expect(resistantBalances[0]).to.be.equal(balance);
6664
expect(resistantBalances[1]).to.be.equal('0');
6765
});
68-
69-
it('Protocol owned FEI PCV deposit', async function () {
70-
const pcvDepositWrapper = await (
71-
await ethers.getContractFactory('PCVDepositWrapper')
72-
).deploy(deposit.address, token.address, true);
73-
74-
await token.mint(deposit.address, ethers.utils.parseEther('2000'));
75-
await deposit.deposit();
76-
77-
expect(await pcvDepositWrapper.balanceReportedIn()).to.be.equal(token.address);
78-
expect(await pcvDepositWrapper.balance()).to.be.equal(balance);
79-
const resistantBalances = await pcvDepositWrapper.resistantBalanceAndFei();
80-
81-
expect(resistantBalances[0]).to.be.equal(balance);
82-
expect(resistantBalances[1]).to.be.equal(balance);
83-
});
8466
});

0 commit comments

Comments
 (0)