Skip to content

Commit

Permalink
fix max premium
Browse files Browse the repository at this point in the history
  • Loading branch information
danoctavian committed Feb 14, 2023
1 parent a76176b commit 68f86e4
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions test/fork/migration-v2.js
Original file line number Diff line number Diff line change
Expand Up @@ -1085,10 +1085,14 @@ describe('V2 upgrade', function () {

const migratedPrice = await this.pooledStaking.getV1PriceForProduct(productId);

console.log({
migratedPrice: migratedPrice.toString(),
});

const coverAsset = 0; // ETH
const amount = parseEther('1');
const period = 364 * 24 * 3600; // 364 days to get a full percentage
const expectedPremium = amount.mul(migratedPrice).div((1e18).toString()).div(100);
const expectedPremium = amount.mul(migratedPrice).div((1e18).toString());
const paymentAsset = coverAsset;

const poolAllocationRequest = [{ poolId: this.armorAAAPoolId, coverAmountInAsset: amount }];
Expand Down Expand Up @@ -1117,9 +1121,11 @@ describe('V2 upgrade', function () {

const premiumSentToPool = poolEthBalanceAfter.sub(poolEthBalanceBefore);

console.log({
premiumSentToPool: premiumSentToPool.toString(),
});

expect(expectedPremium).to.be.greaterThanOrEqual(premiumSentToPool);
// 0.01% max tolerated error
expect(expectedPremium.sub(premiumSentToPool)).to.be.lessThan(BigNumber.from(amount.div(10000)));
});

// TODO review
Expand Down

0 comments on commit 68f86e4

Please sign in to comment.