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

Commit 3a71d4f

Browse files
committed
Update migrations for percentage fee handler
1 parent ae1f690 commit 3a71d4f

5 files changed

+38
-1
lines changed

migrations/2_deploy_contracts.js

+18
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ const PermissionedGenericHandlerContract = artifacts.require(
1919
const FeeRouterContract = artifacts.require("FeeHandlerRouter");
2020
const BasicFeeHandlerContract = artifacts.require("BasicFeeHandler");
2121
const DynamicFeeHandlerContract = artifacts.require("DynamicERC20FeeHandlerEVM");
22+
const PercentageFeeHandler = artifacts.require("PercentageERC20FeeHandlerEVM");
2223

2324
module.exports = async function (deployer, network) {
2425
const networksConfig = Utils.getNetworksConfig();
@@ -76,6 +77,11 @@ module.exports = async function (deployer, network) {
7677
bridgeInstance.address,
7778
feeRouterInstance.address
7879
);
80+
const percentageFeeHandlerInstance = await deployer.deploy(
81+
PercentageFeeHandler,
82+
bridgeInstance.address,
83+
feeRouterInstance.address
84+
)
7985

8086
// setup fee router and fee handlers
8187
await bridgeInstance.adminChangeFeeHandler(feeRouterInstance.address);
@@ -89,6 +95,9 @@ module.exports = async function (deployer, network) {
8995
await basicFeeHandlerInstance.changeFee(
9096
Ethers.utils.parseEther(currentNetworkConfig.fee.basic.fee).toString()
9197
);
98+
await percentageFeeHandlerInstance.changeFee(
99+
currentNetworkConfig.fee.percentage.fee
100+
)
92101

93102
console.table({
94103
"Deployer Address": deployerAddress,
@@ -101,6 +110,7 @@ module.exports = async function (deployer, network) {
101110
"FeeRouterContract Address": feeRouterInstance.address,
102111
"BasicFeeHandler Address": basicFeeHandlerInstance.address,
103112
"DynamicFeeHandler Address": dynamicFeeHandlerInstance.address,
113+
"PercentageFeeHandler Address": percentageFeeHandlerInstance.address
104114
});
105115

106116
// setup erc20 tokens
@@ -116,8 +126,14 @@ module.exports = async function (deployer, network) {
116126
feeRouterInstance,
117127
dynamicFeeHandlerInstance,
118128
basicFeeHandlerInstance,
129+
percentageFeeHandlerInstance,
119130
erc20
120131
);
132+
await percentageFeeHandlerInstance.changeFeeBounds(
133+
erc20.resourceID,
134+
Ethers.utils.parseEther(currentNetworkConfig.fee.percentage.lowerBound).toString(),
135+
Ethers.utils.parseEther(currentNetworkConfig.fee.percentage.upperBound).toString()
136+
)
121137

122138
console.log(
123139
"-------------------------------------------------------------------------------"
@@ -143,6 +159,7 @@ module.exports = async function (deployer, network) {
143159
feeRouterInstance,
144160
dynamicFeeHandlerInstance,
145161
basicFeeHandlerInstance,
162+
percentageFeeHandlerInstance,
146163
erc721
147164
);
148165

@@ -168,6 +185,7 @@ module.exports = async function (deployer, network) {
168185
feeRouterInstance,
169186
dynamicFeeHandlerInstance,
170187
basicFeeHandlerInstance,
188+
percentageFeeHandlerInstance,
171189
generic
172190
);
173191

migrations/3_deploy_permissionlessGenericHandler.js

+3
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ const PermissionlessGenericHandlerContract = artifacts.require(
1111
const FeeRouterContract = artifacts.require("FeeHandlerRouter");
1212
const BasicFeeHandlerContract = artifacts.require("BasicFeeHandler");
1313
const DynamicFeeHandlerContract = artifacts.require("DynamicERC20FeeHandlerEVM");
14+
const PercentageFeeHandler = artifacts.require("PercentageERC20FeeHandlerEVM");
1415

1516
module.exports = async function (deployer, network) {
1617
const networksConfig = Utils.getNetworksConfig();
@@ -23,6 +24,7 @@ module.exports = async function (deployer, network) {
2324
const bridgeInstance = await BridgeContract.deployed();
2425
const feeRouterInstance = await FeeRouterContract.deployed();
2526
const basicFeeHandlerInstance = await BasicFeeHandlerContract.deployed();
27+
const percentageFeeHandlerInstance = await PercentageFeeHandler.deployed();
2628
const dynamicFeeHandlerInstance =
2729
await DynamicFeeHandlerContract.deployed();
2830

@@ -71,6 +73,7 @@ module.exports = async function (deployer, network) {
7173
feeRouterInstance,
7274
dynamicFeeHandlerInstance,
7375
basicFeeHandlerInstance,
76+
percentageFeeHandlerInstance,
7477
currentNetworkConfig.permissionlessGeneric
7578
);
7679
}

migrations/4_deploy_xc20_contracts.js

+4
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ const XC20HandlerContract = artifacts.require("XC20Handler");
88
const FeeRouterContract = artifacts.require("FeeHandlerRouter");
99
const BasicFeeHandlerContract = artifacts.require("BasicFeeHandler");
1010
const DynamicFeeHandlerContract = artifacts.require("DynamicERC20FeeHandlerEVM");
11+
const PercentageFeeHandler = artifacts.require("PercentageERC20FeeHandlerEVM");
12+
1113

1214
module.exports = async function (deployer, network) {
1315
// trim suffix from network name and fetch current network config
@@ -29,6 +31,7 @@ module.exports = async function (deployer, network) {
2931
const basicFeeHandlerInstance = await BasicFeeHandlerContract.deployed();
3032
const dynamicFeeHandlerInstance =
3133
await DynamicFeeHandlerContract.deployed();
34+
const percentageFeeHandlerInstance = await PercentageFeeHandler.deployed();
3235

3336
// deploy XC20 contracts
3437
await deployer.deploy(XC20HandlerContract, bridgeInstance.address);
@@ -42,6 +45,7 @@ module.exports = async function (deployer, network) {
4245
feeRouterInstance,
4346
dynamicFeeHandlerInstance,
4447
basicFeeHandlerInstance,
48+
percentageFeeHandlerInstance,
4549
xc20
4650
);
4751

migrations/local.json

+5
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@
1010
},
1111
"basic": {
1212
"fee": "0.001"
13+
},
14+
"percentage":{
15+
"fee": "10000",
16+
"lowerBound": "10",
17+
"upperBound": "30"
1318
}
1419
},
1520
"access": {

migrations/utils.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ async function setupFee(
3131
feeRouterInstance,
3232
dynamicFeeHandlerInstance,
3333
basicFeeHandlerInstance,
34+
percentageFeeHandlerInstance,
3435
token
3536
) {
3637
for await (const network of Object.values(networksConfig)) {
@@ -40,12 +41,18 @@ async function setupFee(
4041
token.resourceID,
4142
dynamicFeeHandlerInstance.address
4243
);
43-
} else {
44+
} else if (token.feeType == "basic") {
4445
await feeRouterInstance.adminSetResourceHandler(
4546
network.domainID,
4647
token.resourceID,
4748
basicFeeHandlerInstance.address
4849
);
50+
} else {
51+
await feeRouterInstance.adminSetResourceHandler(
52+
network.domainID,
53+
token.resourceID,
54+
percentageFeeHandlerInstance.address
55+
)
4956
}
5057
}
5158
}

0 commit comments

Comments
 (0)