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

Fix DPI e2e tests #129

Merged
merged 1 commit into from
Aug 14, 2021
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
14 changes: 10 additions & 4 deletions end-to-end/e2e.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,9 @@ describe('e2e', function () {

// Seed bonding curve with dpi
const bondingCurve = contracts.dpiBondingCurve

// increase mint cap
await bondingCurve.setMintCap(tenPow18.mul(tenPow18));

await contracts.dpi.approve(bondingCurve.address, dpiSeedAmount.mul(toBN(2)));
await bondingCurve.purchase(deployAddress, dpiSeedAmount)
})
Expand Down Expand Up @@ -142,16 +144,20 @@ describe('e2e', function () {
const pcvAllocations = await bondingCurve.getAllocation()
expect(pcvAllocations[0].length).to.be.equal(2)

const pcvDepositBefore = await uniswapPCVDeposit.balance();
const fuseBalanceBefore = await fusePCVDeposit.balance();

const allocatedDpi = await bondingCurve.balance()
await bondingCurve.allocate()

const curveBalanceAfter = await bondingCurve.balance();
expect(curveBalanceAfter).to.be.bignumber.equal(toBN(0))
await expectApprox(curveBalanceAfter, toBN(0), '100')

const pcvDepositAfter = await uniswapPCVDeposit.balance()
await expectApprox(pcvDepositAfter, allocatedDpi.mul(toBN(9)).div(toBN(10)), '100')
await expectApprox(pcvDepositAfter.sub(pcvDepositBefore), allocatedDpi.mul(toBN(9)).div(toBN(10)), '10')

await expectApprox(await fusePCVDeposit.balance(), allocatedDpi.div(toBN(10)), '100')
const fuseBalanceAfter = await fusePCVDeposit.balance();
await expectApprox(fuseBalanceAfter.sub(fuseBalanceBefore), allocatedDpi.div(toBN(10)), '100')
})
});
});
Expand Down
2 changes: 1 addition & 1 deletion hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const config: HardhatUserConfig = {
chainId: 5777, // Any network (default: none)
forking: {
url: `https://eth-mainnet.alchemyapi.io/v2/${mainnetAlchemyApiKey}`,
blockNumber: 12974210
blockNumber: 13018540
}
},
localhost: {
Expand Down
8 changes: 0 additions & 8 deletions proposals/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,5 @@
"exec" : false,
"proposerAddress" : "",
"voterAddress" : ""
},
"fip_14" : {
"deploy" : false,
"exec" : true,
"validate" : false,
"proposal_calldata" : "0xda95691a00000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001600000000000000000000000000000000000000000000000000000000000000240000000000000000000000000000000000000000000000000000000000000032000000000000000000000000000000000000000000000000000000000000000020000000000000000000000008d5ed43dca8c2f7dfb20cf7b53cc7e593635d7b90000000000000000000000008d5ed43dca8c2f7dfb20cf7b53cc7e593635d7b900000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000146772616e744d696e74657228616464726573732900000000000000000000000000000000000000000000000000000000000000000000000000000000000000146772616e744d696e7465722861646472657373290000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000020000000000000000000000000bf5721c5e1c370f6f1a3e21b3972e0ace93a1e84000000000000000000000000000000000000000000000000000000000000002000000000000000000000000090fa375b75a58bb3a4842603f712db285cc82bf600000000000000000000000000000000000000000000000000000000000004d04649502d31343a204164642044504920426f6e64696e67204375727665200a546869732070726f706f73616c206f70656e73207570206120626f6e64696e6720637572766520616c6c6f77696e6720746865207075726368617365206f66204645492077697468204450492e204e657720626f6e64696e6720637572766573206f6666657220464549206174206120646973636f756e742072656c617469766520746f20746865206f7261636c65207072696365206265666f726520746865207363616c652074617267657420697320726561636865642e204265796f6e64207363616c652c2074686572652069732061207072656d69756d206173736f63696174656420776974682070757263686173696e672c207769746820616e206164646974696f6e616c206d696e74696e67206361702e0a0a546869732070726f706f73616c206861732074686520666f6c6c6f77696e6720706172616d65746572733a0a2d205363616c653a2031304d204645490a2d204d696e744361703a2031304d204645490a2d205072652d7363616c6520646973636f756e743a2031250a2d20506f73742d7363616c65207072656d69756d3a2032250a2d204f7261636c653a20436861696e6c696e6b204450492d5553442028322520646576696174696f6e207468726573686f6c64290a2d204b656570657220696e63656e7469766520616d6f756e743a20313030204645490a2d204b656570657220696e63656e74697665206672657175656e63793a2036303438303073202831207765656b290a0a5468652044504920504356207261697365642077696c6c2062652073706c697420393025206265747765656e206120537573686953776170204450492d46454920706f6f6c20616e642031302520746f2074686520496e64657820436f6f70204675736520506f6f6c2e0a0a466f72756d2044697363757373696f6e3a0a68747470733a2f2f74726962652e6665692e6d6f6e65792f742f70726f706f73616c2d627579696e672d646566692d70756c73652d696e6465782d6470692f33333438200a546869732070726f706f73616c206861732074686520666f6c6c6f77696e6720706172616d65746572733a0a2d205363616c653a2031304d204645490a2d204d696e744361703a2031304d204645490a2d205072652d7363616c6520646973636f756e743a2031250a2d20506f73742d7363616c65207072656d69756d3a2032250a2d204f7261636c653a20436861696e6c696e6b204450492d5553442028322520646576696174696f6e207468726573686f6c64290a2d204b656570657220696e63656e7469766520616d6f756e743a20313030204645490a2d204b656570657220696e63656e74697665206672657175656e63793a2036303438303073202831207765656b290a0a5468652044504920504356207261697365642077696c6c2062652073706c697420393025206265747765656e206120537573686953776170204450492d46454920706f6f6c20616e642031302520746f2074686520496e64657820436f6f70204675736520506f6f6c2e0a0a466f72756d2044697363757373696f6e3a0a68747470733a2f2f74726962652e6665692e6d6f6e65792f742f70726f706f73616c2d627579696e672d646566692d70756c73652d696e6465782d6470692f333334382000000000000000000000000000000000",
"proposerAddress" : "0xe0ac4559739bD36f0913FB0A3f5bFC19BCBaCD52",
"voterAddress" : "0xB8f482539F2d3Ae2C9ea6076894df36D1f632775"
}
}
6 changes: 5 additions & 1 deletion test/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,11 @@ async function forceEth(to, amount) {

async function expectApprox(actual, expected, magnitude = '1000') {
const delta = new BN(expected).div(new BN(magnitude));
expect(new BN(actual)).to.be.bignumber.closeTo(new BN(expected), delta);
if (delta.toString() === '0') {
expect(new BN(actual)).to.be.bignumber.closeTo(new BN(expected), new BN(magnitude));
} else {
expect(new BN(actual)).to.be.bignumber.closeTo(new BN(expected), delta);
}
}

module.exports = {
Expand Down