Skip to content

Commit 5a94ad1

Browse files
committed
format
1 parent 1f23e98 commit 5a94ad1

3 files changed

Lines changed: 21 additions & 25 deletions

File tree

contracts/src/FeeVault.sol

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@
22
pragma solidity ^0.8.24;
33

44
interface IHypNativeMinter {
5-
function transferRemote(
6-
uint32 _destination,
7-
bytes32 _recipient,
8-
uint256 _amount
9-
) external payable returns (bytes32 messageId);
5+
function transferRemote(uint32 _destination, bytes32 _recipient, uint256 _amount)
6+
external
7+
payable
8+
returns (bytes32 messageId);
109
}
1110

1211
contract FeeVault {
@@ -47,9 +46,9 @@ contract FeeVault {
4746

4847
function sendToCelestia() external payable {
4948
require(msg.value >= callFee, "FeeVault: insufficient fee");
50-
49+
5150
uint256 currentBalance = address(this).balance;
52-
51+
5352
// Calculate split
5453
uint256 bridgeAmount = (currentBalance * bridgeShareBps) / 10000;
5554
uint256 otherAmount = currentBalance - bridgeAmount;
@@ -61,16 +60,13 @@ contract FeeVault {
6160
// Send other amount if any
6261
if (otherAmount > 0) {
6362
require(otherRecipient != address(0), "FeeVault: other recipient not set");
64-
(bool success, ) = otherRecipient.call{value: otherAmount}("");
63+
(bool success,) = otherRecipient.call{value: otherAmount}("");
6564
require(success, "FeeVault: transfer failed");
6665
}
6766

6867
// Bridge the bridge amount
69-
bytes32 messageId = hypNativeMinter.transferRemote{value: bridgeAmount}(
70-
destinationDomain,
71-
recipientAddress,
72-
bridgeAmount
73-
);
68+
bytes32 messageId =
69+
hypNativeMinter.transferRemote{value: bridgeAmount}(destinationDomain, recipientAddress, bridgeAmount);
7470

7571
emit SentToCelestia(bridgeAmount, recipientAddress, messageId);
7672
}

contracts/test/FeeVault.t.sol

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ import {FeeVault} from "../src/FeeVault.sol";
77
contract MockHypNativeMinter {
88
event TransferRemoteCalled(uint32 destination, bytes32 recipient, uint256 amount);
99

10-
function transferRemote(
11-
uint32 _destination,
12-
bytes32 _recipient,
13-
uint256 _amount
14-
) external payable returns (bytes32 messageId) {
10+
function transferRemote(uint32 _destination, bytes32 _recipient, uint256 _amount)
11+
external
12+
payable
13+
returns (bytes32 messageId)
14+
{
1515
require(msg.value == _amount, "MockHypNativeMinter: value mismatch");
1616
emit TransferRemoteCalled(_destination, _recipient, _amount);
1717
return bytes32(uint256(1)); // Return a dummy messageId
@@ -47,14 +47,14 @@ contract FeeVaultTest is Test {
4747

4848
function test_Receive() public {
4949
uint256 amount = 1 ether;
50-
(bool success, ) = address(feeVault).call{value: amount}("");
50+
(bool success,) = address(feeVault).call{value: amount}("");
5151
assertTrue(success, "Transfer failed");
5252
assertEq(address(feeVault).balance, amount, "Balance mismatch");
5353
}
5454

5555
function test_SendToCelestia_100PercentBridge() public {
5656
// Fund with minAmount
57-
(bool success, ) = address(feeVault).call{value: minAmount}("");
57+
(bool success,) = address(feeVault).call{value: minAmount}("");
5858
require(success);
5959

6060
uint256 totalAmount = minAmount + fee;
@@ -77,13 +77,13 @@ contract FeeVaultTest is Test {
7777
// Set split to 50%
7878
feeVault.setBridgeShare(5000);
7979

80-
// Fund with 2 ether.
80+
// Fund with 2 ether.
8181
// Fee is 0.1 ether.
8282
// Total new funds = 2.1 ether.
8383
// Bridge = 1.05 ether. Other = 1.05 ether.
8484
// Min amount is 1 ether, so 1.05 >= 1.0 is OK.
8585
uint256 fundAmount = 2 ether;
86-
(bool success, ) = address(feeVault).call{value: fundAmount}("");
86+
(bool success,) = address(feeVault).call{value: fundAmount}("");
8787
require(success);
8888

8989
uint256 totalNew = fundAmount + fee;
@@ -111,11 +111,11 @@ contract FeeVaultTest is Test {
111111

112112
function test_SendToCelestia_BelowMinAmount_AfterSplit() public {
113113
feeVault.setBridgeShare(1000); // 10% bridge
114-
114+
115115
// Fund with 2 ether. Total 2.1.
116116
// Bridge = 0.21. Other = 1.89.
117117
// Min amount is 1.0. 0.21 < 1.0. Should revert.
118-
(bool success, ) = address(feeVault).call{value: 2 ether}("");
118+
(bool success,) = address(feeVault).call{value: 2 ether}("");
119119
require(success);
120120

121121
vm.prank(user);

docs/contracts/fee_vault.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# FeeVault Design & Use Case
22

33
## Overview
4-
The `FeeVault` is a specialized smart contract designed to accumulate native tokens (ETH or gas tokens) and automatically split them between bridging to a specific destination chain (e.g., Celestia) and sending to a secondary recipient.
4+
The `FeeVault` is a specialized smart contract designed to accumulate native tokens (gas tokens) and automatically split them between bridging to a specific destination chain (e.g., Celestia) and sending to a secondary recipient.
55

66
## Use Case
77
This contract serves as a **fee sink** and **bridging mechanism** for a rollup or chain that wants to redirect collected fees (e.g., EIP-1559 base fees) to another ecosystem while retaining a portion for other purposes (e.g., developer rewards, treasury).

0 commit comments

Comments
 (0)