Skip to content
This repository was archived by the owner on Mar 11, 2025. It is now read-only.

Commit acd89e8

Browse files
authored
feat: add fee percentage to percentage fee details (#365)
<!--- Provide a general summary of your changes in the Title above --> ## Description <!--- Describe your changes in detail --> ## Related Issue Or Context <!--- If suggesting a new feature or change, please discuss it in an issue first --> <!--- If fixing a bug, there should be an issue describing it with steps to reproduce --> <!--- Otherwise, describe context and motivation for change herre --> Closes: #<issue> ## How Has This Been Tested? Testing details. <!--- Please describe in detail how you tested your changes. --> <!--- Include details of your testing environment, and the tests you ran to --> <!--- see how your change affects other areas of the code, etc. --> ## Types of changes <!--- What types of changes does your code introduce? Put an `x` in all the boxes that apply: --> - [ ] Bug fix (non-breaking change which fixes an issue) - [x] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to change) - [ ] Documentation ## Checklist: <!--- Go over all the following points, and put an `x` in all the boxes that apply. --> <!--- If you're unsure about any of these, don't hesitate to ask. We're here to help! --> - [ ] I have commented my code, particularly in hard-to-understand areas. - [ ] I have ensured that all acceptance criteria (or expected behavior) from issue are met - [ ] I have updated the documentation locally and in chainbridge-docs. - [ ] I have added tests to cover my changes. - [ ] I have ensured that all the checks are passing and green, I've signed the CLA bot --------- Signed-off-by: Marin Petrunic <[email protected]>
1 parent 6d125f8 commit acd89e8

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

packages/sdk/src/chains/EVM/fee/percentageFee.ts

+8
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ export const getPercentageFee = async ({
3232
precentageFeeHandlerAddress,
3333
provider,
3434
);
35+
3536
const calculatedFee = await percentageFeeHandlerContract.calculateFee(
3637
sender,
3738
fromDomainID,
@@ -40,10 +41,17 @@ export const getPercentageFee = async ({
4041
depositData,
4142
utils.formatBytes32String(''),
4243
);
44+
4345
const feeBounds = await percentageFeeHandlerContract._resourceIDToFeeBounds(resourceID);
46+
47+
const feePercentage = (
48+
await percentageFeeHandlerContract._domainResourceIDToFee(toDomainID, resourceID)
49+
).toNumber();
50+
const percentage = feePercentage / (await percentageFeeHandlerContract.HUNDRED_PERCENT());
4451
const [fee] = calculatedFee;
4552
return {
4653
fee,
54+
percentage,
4755
feeData: fee.toHexString(),
4856
type: FeeHandlerType.PERCENTAGE,
4957
handlerAddress: precentageFeeHandlerAddress,

packages/sdk/src/chains/EVM/types/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export type EvmFee = {
1212

1313
export type PercentageFee = EvmFee & {
1414
type: FeeHandlerType.PERCENTAGE;
15+
percentage: number;
1516
lowerBound: ethers.BigNumber;
1617
upperBound: ethers.BigNumber;
1718
};

0 commit comments

Comments
 (0)