Skip to content

Commit cbd19cf

Browse files
committed
feat: fixes after oracle report
1 parent 5b7d814 commit cbd19cf

4 files changed

Lines changed: 54 additions & 16 deletions

File tree

tests/base/testData/consts.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { getStandConfig } from '../config';
2+
13
export type TierParams = {
24
shareLimit: bigint;
35
reserveRatioBP: bigint;
@@ -9,9 +11,20 @@ export type TierParams = {
911

1012
export const DEFAULT_TIER_ID = 0;
1113

14+
const getShareLimitForChain = (): bigint => {
15+
// Hoodi (chainId: 560048) -> 100000000000000000000000
16+
// Mainnet (chainId: 1) -> 0
17+
const chainId = getStandConfig().networkConfig.chainId;
18+
if (chainId === 560048) {
19+
return BigInt('100000000000000000000000');
20+
} else if (chainId === 1) {
21+
return BigInt('0');
22+
}
23+
throw new Error(`Unsupported chainId: ${chainId}`);
24+
};
25+
1226
export const DEFAULT_TIER_PARAMS: TierParams = {
13-
// for Hoodi set 100000000000000000000000, for mainnet phase 0 = 0
14-
shareLimit: BigInt('100000000000000000000000'),
27+
shareLimit: getShareLimitForChain(),
1528
reserveRatioBP: BigInt('5000'),
1629
forcedRebalanceThresholdBP: BigInt('4975'),
1730
infraFeeBP: BigInt('100'),

tests/base/tests/scenarios/oneStepProcess.spec.ts

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -469,17 +469,25 @@ test.describe.serial('One step process', () => {
469469
).toBe(contractLiabilityStEth);
470470
expect(cliLiabilityStEthAfterRepay).toBe('0');
471471

472-
const calculatedRecipientStEthBalanceAfterRepay =
473-
parseFloat(recipientStEthBalanceBeforeRepay) -
474-
parseFloat(cliLiabilityStEthBeforeRepay);
475-
const recipientStEthBalanceAfterRepay = parseFloat(
476-
await getStEthBalance(repayRoleAddress),
472+
const recipientStEthBalanceAfterRepay =
473+
await getStEthBalance(repayRoleAddress);
474+
const recipientStEthBalanceBeforeRepayWei = parseEther(
475+
recipientStEthBalanceBeforeRepay,
476+
);
477+
const recipientStEthBalanceAfterRepayWei = parseEther(
478+
recipientStEthBalanceAfterRepay,
477479
);
480+
const cliLiabilityStEthBeforeRepayWei = parseEther(
481+
cliLiabilityStEthBeforeRepay,
482+
);
483+
484+
const actualBalanceReduction =
485+
recipientStEthBalanceBeforeRepayWei - recipientStEthBalanceAfterRepayWei;
478486

479487
expect(
480-
recipientStEthBalanceAfterRepay,
488+
actualBalanceReduction,
481489
'Expect recipient stEth address reduces correct amount after burn',
482-
).toBe(calculatedRecipientStEthBalanceAfterRepay);
490+
).toBe(cliLiabilityStEthBeforeRepayWei);
483491
});
484492

485493
test(`Withdraw ETH as ${ROLES.WITHDRAW}`, async ({ ethereumNodeService }) => {

tests/base/tests/scenarios/twoStepProcess.spec.ts

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -431,17 +431,24 @@ test.describe.serial('Two step process', () => {
431431
).toBe(contractLiabilityStEth);
432432
expect(cliLiabilityStEthAfterRepay).toBe('0');
433433

434-
const calculatedRecipientStEthBalanceAfterRepay =
435-
parseFloat(recipientStEthBalanceBeforeRepay) -
436-
parseFloat(cliLiabilityStEthBeforeRepay);
437-
const recipientStEthBalanceAfterRepay = parseFloat(
438-
await getStEthBalance(vmAddress),
434+
const recipientStEthBalanceAfterRepay = await getStEthBalance(vmAddress);
435+
const recipientStEthBalanceBeforeRepayWei = parseEther(
436+
recipientStEthBalanceBeforeRepay,
437+
);
438+
const recipientStEthBalanceAfterRepayWei = parseEther(
439+
recipientStEthBalanceAfterRepay,
439440
);
441+
const cliLiabilityStEthBeforeRepayWei = parseEther(
442+
cliLiabilityStEthBeforeRepay,
443+
);
444+
445+
const actualBalanceReduction =
446+
recipientStEthBalanceBeforeRepayWei - recipientStEthBalanceAfterRepayWei;
440447

441448
expect(
442-
recipientStEthBalanceAfterRepay,
449+
actualBalanceReduction,
443450
'Expect recipient stEth address reduces correct amount after burn',
444-
).toBe(calculatedRecipientStEthBalanceAfterRepay);
451+
).toBe(cliLiabilityStEthBeforeRepayWei);
445452
});
446453

447454
test(`Withdraw ETH as ${ROLES.DEFAULT_ADMIN}`, async ({

tests/base/utils/operatorGridMock.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,11 @@ export class OperatorGridMock {
7474
await test.step(`Register group for ${nodeOperator} with shareLimit=${shareLimit}`, async () => {
7575
const registry = await this.getRegistryRoleAddress();
7676

77+
await this.client.setBalance({
78+
address: registry,
79+
value: parseEther('10'),
80+
});
81+
7782
await this.client.impersonateAccount({ address: registry });
7883

7984
const hash = await this.operatorGridContract.write.registerGroup(
@@ -91,6 +96,11 @@ export class OperatorGridMock {
9196
await test.step(`Register tier for ${nodeOperator}`, async () => {
9297
const registry = await this.getRegistryRoleAddress();
9398

99+
await this.client.setBalance({
100+
address: registry,
101+
value: parseEther('10'),
102+
});
103+
94104
await this.client.impersonateAccount({ address: registry });
95105

96106
const hash = await this.operatorGridContract.write.registerTiers(

0 commit comments

Comments
 (0)