Skip to content
Merged
Show file tree
Hide file tree
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
8 changes: 4 additions & 4 deletions contracts/UFragmentsPolicy.sol
Original file line number Diff line number Diff line change
Expand Up @@ -244,11 +244,11 @@ contract UFragmentsPolicy is Ownable {
Ownable.initialize(owner_);

// deviationThreshold = 0.05e18 = 5e16
deviationThreshold = 5 * 10**(DECIMALS - 2);
deviationThreshold = 25 * 10**(DECIMALS - 3);

rebaseFunctionGrowth = int256(3 * (10**DECIMALS));
rebaseFunctionUpperPercentage = int256(10 * (10**(DECIMALS - 2))); // 0.1
rebaseFunctionLowerPercentage = int256((-10) * int256(10**(DECIMALS - 2))); // -0.1
rebaseFunctionGrowth = int256(45 * (10**DECIMALS));
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We decided in the previous PR to keep it here this way and switch it to 45 in the next deployment

rebaseFunctionUpperPercentage = int256(5 * (10**(DECIMALS - 2))); // 0.05
rebaseFunctionLowerPercentage = int256((-77) * int256(10**(DECIMALS - 3))); // -0.77

minRebaseTimeIntervalSec = 1 days;
rebaseWindowOffsetSec = 7200; // 2AM UTC
Expand Down
31 changes: 15 additions & 16 deletions test/unit/UFragmentsPolicy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { ethers, upgrades, waffle } from 'hardhat'
import { Contract, Signer, BigNumber, BigNumberish, Event } from 'ethers'
import { TransactionResponse } from '@ethersproject/providers'
import { expect } from 'chai'
import { Result } from 'ethers/lib/utils'
import { imul, increaseTime } from '../utils/utils'

let uFragmentsPolicy: Contract,
Expand All @@ -20,8 +19,8 @@ const INITIAL_TARGET_RATE_25P_LESS = imul(INITIAL_TARGET_RATE, '0.75', 1)
const INITIAL_RATE = ethers.utils.parseUnits('1.05', 18)
const INITIAL_RATE_30P_MORE = imul(INITIAL_RATE, '1.3', 1)
const INITIAL_RATE_30P_LESS = imul(INITIAL_RATE, '0.7', 1)
const INITIAL_RATE_2P_MORE = imul(INITIAL_RATE, '1.02', 1)
const INITIAL_RATE_2P_LESS = imul(INITIAL_RATE, '0.98', 1)
const INITIAL_RATE_2_5_P_MORE = imul(INITIAL_RATE, '1.025', 1)
const INITIAL_RATE_2_5_P_LESS = imul(INITIAL_RATE, '0.975', 1)
const INITIAL_RATE_60P_MORE = imul(INITIAL_RATE, '1.6', 1)
const INITIAL_RATE_50P_LESS = imul(INITIAL_RATE, '0.5', 1)
const INITIAL_RATE_2X = INITIAL_RATE.mul(2)
Expand Down Expand Up @@ -149,7 +148,7 @@ describe('UFragmentsPolicy:initialize', async function () {

it('deviationThreshold', async function () {
expect(await uFragmentsPolicy.deviationThreshold()).to.eq(
ethers.utils.parseUnits('5', 16),
ethers.utils.parseUnits('25', 15),
)
})
it('rebaseLag', async function () {
Expand Down Expand Up @@ -399,8 +398,8 @@ describe('UFragmentsPolicy:CurveParameters', async function () {

describe('when rebaseFunctionGrowth is more than 0', async function () {
it('should setRebaseFunctionGrowth', async function () {
await uFragmentsPolicy.connect(deployer).setRebaseFunctionGrowth(1000)
expect(await uFragmentsPolicy.rebaseFunctionGrowth()).to.eq(1000)
await uFragmentsPolicy.connect(deployer).setRebaseFunctionGrowth('42000000000000000000')
expect(await uFragmentsPolicy.rebaseFunctionGrowth()).to.eq('42000000000000000000')
})
})

Expand Down Expand Up @@ -702,7 +701,7 @@ describe('UFragmentsPolicy:Rebase', async function () {
await increaseTime(60)

await mockExternalData(
INITIAL_RATE_2P_MORE.sub(2),
INITIAL_RATE_2_5_P_MORE.sub(2),
INITIAL_TARGET_RATE,
1000,
)
Expand All @@ -716,7 +715,7 @@ describe('UFragmentsPolicy:Rebase', async function () {
await increaseTime(60)

await mockExternalData(
INITIAL_RATE_2P_LESS.add(2),
INITIAL_RATE_2_5_P_LESS.add(2),
INITIAL_TARGET_RATE,
1000,
)
Expand Down Expand Up @@ -991,7 +990,7 @@ describe('UFragmentsPolicy:Rebase', async function () {
prevEpoch.add(1),
INITIAL_RATE_60P_MORE,
INITIAL_TARGET_RATE,
55,
50,
)
})

Expand All @@ -1014,7 +1013,7 @@ describe('UFragmentsPolicy:Rebase', async function () {
.withArgs('UFragments', 'rebase', uFragmentsPolicy.address)
await expect(r)
.to.emit(mockUFragments, 'FunctionArguments')
.withArgs([prevEpoch.add(1)], [55])
.withArgs([prevEpoch.add(1)], [50])
})
})
})
Expand Down Expand Up @@ -1045,7 +1044,7 @@ describe('UFragmentsPolicy:Rebase', async function () {
uFragmentsPolicy.connect(orchestrator).rebase(),
)
).requestedSupplyAdjustment,
).to.eq(-29)
).to.eq(-76)
})
})

Expand All @@ -1065,7 +1064,7 @@ describe('UFragmentsPolicy:Rebase', async function () {
uFragmentsPolicy.connect(orchestrator).rebase(),
)
).requestedSupplyAdjustment,
).to.eq(100)
).to.eq(50)
})
})

Expand All @@ -1085,7 +1084,7 @@ describe('UFragmentsPolicy:Rebase', async function () {
uFragmentsPolicy.connect(orchestrator).rebase(),
)
).requestedSupplyAdjustment,
).to.eq(-100)
).to.eq(-77)
})
})

Expand All @@ -1105,7 +1104,7 @@ describe('UFragmentsPolicy:Rebase', async function () {
uFragmentsPolicy.connect(orchestrator).rebase(),
)
).requestedSupplyAdjustment,
).to.eq(-100)
).to.eq(-77)
})
})
})
Expand Down Expand Up @@ -1137,7 +1136,7 @@ describe('UFragmentsPolicy:Rebase', async function () {
uFragmentsPolicy.connect(orchestrator).rebase(),
)
).requestedSupplyAdjustment,
).to.eq(-20)
).to.eq(-76)
})
})
})
Expand Down Expand Up @@ -1169,7 +1168,7 @@ describe('UFragmentsPolicy:Rebase', async function () {
uFragmentsPolicy.connect(orchestrator).rebase(),
)
).requestedSupplyAdjustment,
).to.eq(32)
).to.eq(49)
})
})
})
Expand Down