Skip to content

Commit

Permalink
bk
Browse files Browse the repository at this point in the history
  • Loading branch information
alistair-singh committed Apr 12, 2024
1 parent e3b08b1 commit 8d85828
Show file tree
Hide file tree
Showing 6 changed files with 4 additions and 30 deletions.
2 changes: 0 additions & 2 deletions contracts/src/Gateway.sol
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,6 @@ contract Gateway is IGateway, IInitializable {
$.assetHubCreateAssetFee = params.assetHubCreateAssetFee;
$.assetHubReserveTransferFee = params.assetHubReserveTransferFee;
$.registerTokenFee = params.registerTokenFee;
$.destinationMaxTransferFee = params.destinationMaxTransferFee;
emit TokenTransferFeesChanged();
}

Expand Down Expand Up @@ -632,6 +631,5 @@ contract Gateway is IGateway, IInitializable {
assets.registerTokenFee = config.registerTokenFee;
assets.assetHubCreateAssetFee = config.assetHubCreateAssetFee;
assets.assetHubReserveTransferFee = config.assetHubReserveTransferFee;
assets.destinationMaxTransferFee = config.destinationMaxTransferFee;
}
}
2 changes: 0 additions & 2 deletions contracts/src/Params.sol
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,6 @@ struct SetTokenTransferFeesParams {
uint128 assetHubReserveTransferFee;
/// @dev extra fee to register an asset and discourage spamming (Ether)
uint256 registerTokenFee;
/// @dev The maximum fee (DOT) that can be sent to a destination parachain during a reserve transfer
uint128 destinationMaxTransferFee;
}

// Payload for SetPricingParameters
Expand Down
9 changes: 2 additions & 7 deletions contracts/src/upgrades/rococo/GatewayV2.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import "../../Gateway.sol";

import {UD60x18, convert} from "prb/math/src/UD60x18.sol";
import {PricingStorage} from "../../storage/PricingStorage.sol";
import {AssetsStorage} from "../../storage/AssetsStorage.sol";

contract GatewayV2 is Gateway {
constructor(
Expand All @@ -24,15 +23,11 @@ contract GatewayV2 is Gateway {
}

PricingStorage.Layout storage pricing = PricingStorage.layout();
AssetsStorage.Layout storage assets = AssetsStorage.layout();

if (pricing.multiplier != convert(0) || assets.destinationMaxTransferFee != 0) {
if (pricing.multiplier != convert(0)) {
revert AlreadyInitialized();
}

(UD60x18 multiplier, uint128 maxDestinationFee) = abi.decode(data, (UD60x18, uint128));

pricing.multiplier = multiplier;
assets.destinationMaxTransferFee = maxDestinationFee;
pricing.multiplier = abi.decode(data, (UD60x18));
}
}
16 changes: 2 additions & 14 deletions contracts/test/Gateway.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -861,25 +861,13 @@ contract GatewayTest is Test {
SetTokenTransferFeesParams({
assetHubCreateAssetFee: createTokenFee * 2,
registerTokenFee: registerTokenFee,
assetHubReserveTransferFee: sendTokenFee * 3,
destinationMaxTransferFee: maxDestinationFee + 1
assetHubReserveTransferFee: sendTokenFee * 3
})
)
);
fee = IGateway(address(gateway)).quoteRegisterTokenFee();
// since deliveryCost not changed, so the total fee increased only by 50%
assertEq(fee, 7500000000000000);
// register token first
IGateway(address(gateway)).registerToken{value: fee}(address(token));

fee = IGateway(address(gateway)).quoteSendTokenFee(address(token), assetHubParaID, 0);
// Fee should increase
assertEq(fee, 10000000000000000);

ParaID destPara = ParaID.wrap(2043);
fee = IGateway(address(gateway)).quoteSendTokenFee(address(token), destPara, maxDestinationFee + 1);
// Max fee should increase
assertEq(fee, 35000000000250003);
}

bytes32 public expectChannelIDBytes = bytes32(0xc173fac324158e77fb5840738a1a541f633cbec8884c6a601c567d2b376a0539);
Expand Down Expand Up @@ -937,7 +925,7 @@ contract GatewayTest is Test {
uint256 fee = IGateway(address(gateway)).quoteRegisterTokenFee();
IGateway(address(gateway)).registerToken{value: fee}(address(token));

uint128 largeFee = 1e11 + 1; // greater than 10 DOT, 10 decimal places
uint128 largeFee = maxDestinationFee + 1; // greater than 10 DOT, 10 decimal places

vm.expectRevert(Assets.InvalidDestinationFee.selector);
fee = IGateway(address(gateway)).quoteSendTokenFee(address(token), destPara, largeFee);
Expand Down
4 changes: 0 additions & 4 deletions smoketest/src/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,6 @@ lazy_static! {
.unwrap_or("20000000000".to_string())
.parse()
.unwrap();
pub static ref RESERVE_TRANSFER_MAX_DESTINATION_FEE: u128 = env::var("RESERVE_TRANSFER_MAX_DESTINATION_FEE")
.unwrap_or("10000000000000".to_string())
.parse()
.unwrap();
pub static ref EXCHANGE_RATE: u128 = env::var("EXCHANGE_RATE")
.unwrap_or("2500000000000000".to_string())
.parse()
Expand Down
1 change: 0 additions & 1 deletion smoketest/tests/set_token_transfer_fees.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ async fn set_token_transfer_fees() {
*CREATE_ASSET_FEE,
*RESERVE_TRANSFER_FEE,
U256([*REGISTER_TOKEN_FEE, 0, 0, 0]),
*RESERVE_TRANSFER_MAX_DESTINATION_FEE,
)
.encode_call_data(&test_clients.bridge_hub_client.metadata())
.expect("encoded call");
Expand Down

0 comments on commit 8d85828

Please sign in to comment.