Skip to content
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
18 changes: 8 additions & 10 deletions contracts/pcv/utils/PCVDepositWrapper.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,20 @@ import "../IPCVDepositBalances.sol";
*/
contract PCVDepositWrapper is IPCVDepositBalances {
/// @notice the referenced PCV Deposit
IPCVDepositBalances public pcvDeposit;
IPCVDepositBalances public immutable pcvDeposit;

/// @notice the balance reported in token
address public token;
address public immutable token;

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

constructor(
IPCVDepositBalances _pcvDeposit,
address _token,
bool _isProtocolFeiDeposit
) {
address public constant FEI = 0x956F47F50A910163D8BF957Cf5846D573E7f87CA;

constructor(IPCVDepositBalances _pcvDeposit) {
pcvDeposit = _pcvDeposit;
token = _token;
isProtocolFeiDeposit = _isProtocolFeiDeposit;
token = _pcvDeposit.balanceReportedIn();
isProtocolFeiDeposit = token == FEI;
}

/// @notice returns total balance of PCV in the Deposit
Expand Down
23 changes: 23 additions & 0 deletions scripts/deploy/wrapper.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { DeployUpgradeFunc } from '@custom-types/types';
import { ethers } from 'hardhat';

export const deploy: DeployUpgradeFunc = async (deployAddress: string, addresses, logging = false) => {
const { core } = addresses;

const DEPOSIT = process.env.DEPOSIT;

if (!DEPOSIT) {
throw new Error('DEPOSIT environment variable contract address is not set');
}

if (!core) {
throw new Error('An environment variable contract address is not set');
}

const wrapperFactory = await ethers.getContractFactory('PCVDepositWrapper');
const wrapper = await wrapperFactory.deploy(DEPOSIT);

logging && console.log('wrapperFactory deployed to: ', wrapper.address);

return { wrapper };
};
20 changes: 1 addition & 19 deletions test/unit/pcv/utils/PCVDepositWrapper.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,7 @@ describe('PCVDepositWrapper', function () {
});

it('normal PCV deposit', async function () {
const pcvDepositWrapper = await (
await ethers.getContractFactory('PCVDepositWrapper')
).deploy(deposit.address, token.address, false);
const pcvDepositWrapper = await (await ethers.getContractFactory('PCVDepositWrapper')).deploy(deposit.address);

await token.mint(deposit.address, ethers.utils.parseEther('2000'));
await deposit.deposit();
Expand All @@ -65,20 +63,4 @@ describe('PCVDepositWrapper', function () {
expect(resistantBalances[0]).to.be.equal(balance);
expect(resistantBalances[1]).to.be.equal('0');
});

it('Protocol owned FEI PCV deposit', async function () {
const pcvDepositWrapper = await (
await ethers.getContractFactory('PCVDepositWrapper')
).deploy(deposit.address, token.address, true);

await token.mint(deposit.address, ethers.utils.parseEther('2000'));
await deposit.deposit();

expect(await pcvDepositWrapper.balanceReportedIn()).to.be.equal(token.address);
expect(await pcvDepositWrapper.balance()).to.be.equal(balance);
const resistantBalances = await pcvDepositWrapper.resistantBalanceAndFei();

expect(resistantBalances[0]).to.be.equal(balance);
expect(resistantBalances[1]).to.be.equal(balance);
});
});