Skip to content

Commit

Permalink
test: update curve validation tests
Browse files Browse the repository at this point in the history
  • Loading branch information
thomas-waite committed May 10, 2022
1 parent 840ad08 commit 792a50a
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 27 deletions.
3 changes: 1 addition & 2 deletions proposals/dao/fip_105.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ Description: Deploy a Fei skimmer for the DAI PSM
*/

const fipNumber = '105';

const skimThreshold = ethers.constants.WeiPerEther.mul(10_000_000);

const deploy: DeployUpgradeFunc = async (deployAddress: string, addresses: NamedAddresses, logging: boolean) => {
Expand All @@ -30,7 +29,7 @@ const deploy: DeployUpgradeFunc = async (deployAddress: string, addresses: Named
await daiFixedPricePSMFeiSkimmer.deployed();
logging && console.log('DAI PSM Fei Skimmer deployed at', daiFixedPricePSMFeiSkimmer.address);
return {
daiPSMFeiSkimmer: daiFixedPricePSMFeiSkimmer
daiFixedPricePSMFeiSkimmer
};
};

Expand Down
54 changes: 33 additions & 21 deletions proposals/dao/withdraw_d3_pool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,35 +52,47 @@ const validate: ValidateUpgradeFunc = async (addresses, oldContracts, contracts,
const convexPCVDeposit = contracts.d3poolConvexPCVDeposit;
const curvePCVDeposit = contracts.d3poolCurvePCVDeposit;
const daiFixedPricePSM = contracts.daiFixedPricePSM;

const LPWithdrawAmount = ethers.constants.WeiPerEther.mul(30_000_000);
const feiWithdrawAmount = ethers.constants.WeiPerEther.mul(10_000_000);

// 2. Validate withdraw convexPCVDeposit
// 2. Validate withdraw convexPCVDeposit - have pulled 30M LP tokens from Convex
const [convexResistantBalanceAfter, convexFeiBalanceAfter] = await convexPCVDeposit.resistantBalanceAndFei();
expect(convexFeiBalanceAfter).to.bignumber.equal(convexFeiBalanceBefore); // Fei balance shouldn't have changed

// Might need calculating
// expect(convexResistantBalanceAfter).to.bignumber.equal(convexResistantBalanceBefore.sub(LPWithdrawAmount));
// ~20M in resistantBalance (value of LP tokens?) has been withdrawn
expect(convexResistantBalanceAfter).to.bignumber.at.least(
convexResistantBalanceBefore.sub(ethers.constants.WeiPerEther.mul(20_100_000))
);
expect(convexResistantBalanceAfter).to.bignumber.at.most(
convexResistantBalanceBefore.sub(ethers.constants.WeiPerEther.mul(19_900_000))
);

// ~10M Fei has been withdrawn - would only expect LP tokens to be withdrawn?
expect(convexFeiBalanceAfter).to.bignumber.at.least(
convexFeiBalanceBefore.sub(ethers.constants.WeiPerEther.mul(10_100_000))
);
expect(convexFeiBalanceAfter).to.bignumber.at.most(
convexFeiBalanceBefore.sub(ethers.constants.WeiPerEther.mul(9_900_000))
);

// 3. Validate curvePCVDeposit
// 3. Validate curvePCVDeposit - have transferred 30M LP tokens here, but then withdrawn 10M. Net 20M inflow
const [curveResistantBalanceAfter, curveFeiBalanceAfter] = await curvePCVDeposit.resistantBalanceAndFei();
expect(curveFeiBalanceAfter).to.bignumber.equal(curveFeiBalanceBefore.sub(feiWithdrawAmount));

// Might need calculating
// expect(curveResistantBalanceAfter).to.bignumber.equal(curveResistantBalanceBefore.sub(feiWithdrawAmount));

console.log(
'convex balance before',
convexResistantBalanceBefore.toString(),
'convex balance afer',
convexResistantBalanceAfter.toString(),
'convex fei before',
convexFeiBalanceBefore.toString(),
'convex fei after',
convexFeiBalanceAfter.toString()

// ~13.6M in resistantBalance net inflow
expect(curveResistantBalanceAfter).to.bignumber.at.most(
curveResistantBalanceBefore.add(ethers.constants.WeiPerEther.mul(13_400_000))
);
expect(curveResistantBalanceAfter).to.bignumber.at.least(
curveResistantBalanceBefore.add(ethers.constants.WeiPerEther.mul(13_200_000))
);

// ~6.3M Fei net inflow
expect(curveFeiBalanceAfter).to.bignumber.at.most(
curveFeiBalanceBefore.add(ethers.constants.WeiPerEther.mul(6_700_000))
);
expect(curveFeiBalanceAfter).to.bignumber.at.least(
curveFeiBalanceBefore.add(ethers.constants.WeiPerEther.mul(6_500_000))
);

// 10M net flow into DAI PSM
const daiPSMFeiBalance = await daiFixedPricePSM.feiBalance();
expect(daiPSMFeiBalance).to.be.equal(daiInitialPSMFeiBalance.add(feiWithdrawAmount));
};
Expand Down
2 changes: 0 additions & 2 deletions proposals/description/withdraw_d3_pool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ const fip_x: ProposalDescription = {
Withdraw 30M USD worth of LP tokens from the d3 pool on Curve.
Send the LP tokens to the d3PoolCurvePCVDeposit and then withdraw 10M FEI from the pool to the DAI PSM.
Then skim all the FEI on the DAI PSM and burn it.
`
};

Expand Down
4 changes: 2 additions & 2 deletions test/integration/proposals_config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const proposals: ProposalsConfigMap = {
totalValue: 0, // amount of ETH to send to DAO execution
proposal: fip_105, // full proposal file, imported from '@proposals/description/fip_xx.ts'
proposalId: '',
affectedContractSignoff: ['daiPSMFeiSkimmer'],
affectedContractSignoff: ['daiFixedPricePSMFeiSkimmer'],
deprecatedContractSignoff: [''],
category: ProposalCategory.DAO
},
Expand All @@ -18,7 +18,7 @@ const proposals: ProposalsConfigMap = {
totalValue: 0, // amount of ETH to send to DAO execution
proposal: withdrawD3Pool, // full proposal file, imported from '@proposals/description/fip_xx.ts'
proposalId: '',
affectedContractSignoff: ['d3poolCurvePCVDeposit', 'd3poolConvexPCVDeposit'],
affectedContractSignoff: ['pcvGuardianNew', 'd3poolCurvePCVDeposit', 'd3poolConvexPCVDeposit', 'daiFixedPricePSM'],
deprecatedContractSignoff: [''],
category: ProposalCategory.TC
}
Expand Down

0 comments on commit 792a50a

Please sign in to comment.