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

CR Oracle + Timelock Ops #925

Merged
merged 5 commits into from
Jun 23, 2022
Merged
Changes from 1 commit
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
53 changes: 0 additions & 53 deletions test/integration/tests/buybacks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,57 +130,4 @@ describe('e2e-buybacks', function () {
expectApprox(afterStats[2], beforeStats[2].sub(beforeBalance));
});
});

describe('Collateralization Oracle Keeper', async function () {
it('can only call when deviation or time met', async function () {
const { namedStaticPCVDepositWrapper, collateralizationOracleWrapper, collateralizationOracleKeeper, fei } =
contracts;

const beforeBalance = await fei.balanceOf(deployAddress);

// set Chainlink ETHUSD to a fixed 4,000$ value
await overwriteChainlinkAggregator(contractAddresses.chainlinkEthUsdOracle, '400000000000', '8');

await collateralizationOracleWrapper.update();

// After updating everything should be up to date
expect(await collateralizationOracleWrapper.isOutdatedOrExceededDeviationThreshold()).to.be.false;

// After time increase, should be outdated
await increaseTime(await collateralizationOracleWrapper.remainingTime());

expect(await collateralizationOracleWrapper.isOutdatedOrExceededDeviationThreshold()).to.be.true;
expect(await collateralizationOracleWrapper.isOutdated()).to.be.true;
expect(await collateralizationOracleWrapper.isExceededDeviationThreshold()).to.be.false;

// UpdateIfOutdated succeeds
await collateralizationOracleWrapper.updateIfOutdated();

expect(await collateralizationOracleWrapper.isOutdatedOrExceededDeviationThreshold()).to.be.false;

// Increase PCV balance to exceed deviation threshold
const pcvStats = await collateralizationOracleWrapper.pcvStats();
await namedStaticPCVDepositWrapper.addDeposit({
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this test relies on named static PCV deposit which will be deprecated in this proposal. Erwan's #923 also deprecates the keeper

depositName: 'massive test deposit',
usdAmount: pcvStats[0],
feiAmount: 1,
underlyingTokenAmount: 1,
underlyingToken: ethers.constants.AddressZero
});

expect(await collateralizationOracleWrapper.isOutdatedOrExceededDeviationThreshold()).to.be.true;
expect(await collateralizationOracleWrapper.isOutdated()).to.be.false;
expect(await collateralizationOracleWrapper.isExceededDeviationThreshold()).to.be.true;

// Keeper is incentivized to update oracle
await increaseTime(await collateralizationOracleKeeper.MIN_MINT_FREQUENCY());

await collateralizationOracleKeeper.mint();

const incentive = await collateralizationOracleKeeper.incentiveAmount();
expect(beforeBalance.add(incentive)).to.be.equal(await fei.balanceOf(deployAddress));

expect(await collateralizationOracleWrapper.isOutdatedOrExceededDeviationThreshold()).to.be.false;
});
});
});