167 lines
3.4 KiB
Markdown
167 lines
3.4 KiB
Markdown
|
|
# Relayer Fees Documentation
|
||
|
|
|
||
|
|
## Overview
|
||
|
|
|
||
|
|
This document describes the relayer fee mechanism for the trustless bridge system. Currently, there are no relayer fees, but this document outlines potential fee structures for future implementation.
|
||
|
|
|
||
|
|
## Current State
|
||
|
|
|
||
|
|
### No Relayer Fees
|
||
|
|
|
||
|
|
- Relayers currently receive no fees
|
||
|
|
- Revenue: None
|
||
|
|
- Costs: Gas fees + bond capital
|
||
|
|
- Profitability: Dependent on future fee implementation
|
||
|
|
|
||
|
|
## Proposed Fee Structure
|
||
|
|
|
||
|
|
### Option 1: Percentage of Deposit
|
||
|
|
|
||
|
|
**Structure**:
|
||
|
|
- Fee: 0.1% of deposit amount
|
||
|
|
- Paid by: Recipient (deducted from bridge amount)
|
||
|
|
- Example: 10 ETH deposit → 0.01 ETH fee
|
||
|
|
|
||
|
|
**Implementation**:
|
||
|
|
```solidity
|
||
|
|
uint256 relayerFee = (amount * relayerFeeBps) / 10000;
|
||
|
|
uint256 bridgeAmount = amount - relayerFee;
|
||
|
|
```
|
||
|
|
|
||
|
|
### Option 2: Fixed Fee
|
||
|
|
|
||
|
|
**Structure**:
|
||
|
|
- Fee: Fixed amount (e.g., 0.001 ETH)
|
||
|
|
- Paid by: Recipient
|
||
|
|
- Example: All deposits → 0.001 ETH fee
|
||
|
|
|
||
|
|
**Implementation**:
|
||
|
|
```solidity
|
||
|
|
uint256 relayerFee = fixedRelayerFee;
|
||
|
|
uint256 bridgeAmount = amount - relayerFee;
|
||
|
|
```
|
||
|
|
|
||
|
|
### Option 3: Tiered Fee
|
||
|
|
|
||
|
|
**Structure**:
|
||
|
|
- Small deposits (< 1 ETH): 0.2% fee
|
||
|
|
- Medium deposits (1-10 ETH): 0.1% fee
|
||
|
|
- Large deposits (> 10 ETH): 0.05% fee
|
||
|
|
|
||
|
|
**Implementation**:
|
||
|
|
```solidity
|
||
|
|
uint256 relayerFeeBps;
|
||
|
|
if (amount < 1 ether) {
|
||
|
|
relayerFeeBps = 20; // 0.2%
|
||
|
|
} else if (amount < 10 ether) {
|
||
|
|
relayerFeeBps = 10; // 0.1%
|
||
|
|
} else {
|
||
|
|
relayerFeeBps = 5; // 0.05%
|
||
|
|
}
|
||
|
|
uint256 relayerFee = (amount * relayerFeeBps) / 10000;
|
||
|
|
```
|
||
|
|
|
||
|
|
## Fee Recipient
|
||
|
|
|
||
|
|
### Option 1: Relayer (Claim Submitter)
|
||
|
|
|
||
|
|
- Fee goes to relayer who submitted claim
|
||
|
|
- Incentivizes fast claim submission
|
||
|
|
- Simple implementation
|
||
|
|
|
||
|
|
### Option 2: Fee Pool
|
||
|
|
|
||
|
|
- Fees collected in pool
|
||
|
|
- Distributed to relayers based on activity
|
||
|
|
- More complex but fairer
|
||
|
|
|
||
|
|
### Option 3: Split
|
||
|
|
|
||
|
|
- 50% to relayer
|
||
|
|
- 50% to fee pool
|
||
|
|
- Balance individual and collective incentives
|
||
|
|
|
||
|
|
## Implementation Considerations
|
||
|
|
|
||
|
|
### Contract Changes
|
||
|
|
|
||
|
|
**InboxETH.sol**:
|
||
|
|
- Add fee calculation
|
||
|
|
- Add fee recipient tracking
|
||
|
|
- Update `submitClaim` to handle fees
|
||
|
|
|
||
|
|
**Example**:
|
||
|
|
```solidity
|
||
|
|
uint256 public relayerFeeBps = 10; // 0.1%
|
||
|
|
|
||
|
|
function submitClaim(...) external payable {
|
||
|
|
// Calculate fee
|
||
|
|
uint256 fee = (amount * relayerFeeBps) / 10000;
|
||
|
|
uint256 bridgeAmount = amount - fee;
|
||
|
|
|
||
|
|
// Store fee recipient
|
||
|
|
relayerFees[depositId] = RelayerFee({
|
||
|
|
relayer: msg.sender,
|
||
|
|
amount: fee
|
||
|
|
});
|
||
|
|
|
||
|
|
// Continue with claim submission using bridgeAmount
|
||
|
|
}
|
||
|
|
```
|
||
|
|
|
||
|
|
### User Impact
|
||
|
|
|
||
|
|
- Recipients receive slightly less (fee deducted)
|
||
|
|
- Transparent fee structure
|
||
|
|
- Competitive with other bridges
|
||
|
|
|
||
|
|
## Economics
|
||
|
|
|
||
|
|
### Relayer Economics
|
||
|
|
|
||
|
|
**With Fees**:
|
||
|
|
- Revenue: Relayer fees
|
||
|
|
- Costs: Gas + bond capital
|
||
|
|
- Profit: Revenue - Costs
|
||
|
|
|
||
|
|
**Example**:
|
||
|
|
- Deposit: 10 ETH
|
||
|
|
- Fee: 0.01 ETH (0.1%)
|
||
|
|
- Gas: 0.001 ETH
|
||
|
|
- Bond: 11 ETH (locked)
|
||
|
|
- Net: 0.009 ETH profit (if no challenge)
|
||
|
|
|
||
|
|
### User Economics
|
||
|
|
|
||
|
|
**With Fees**:
|
||
|
|
- Receive: Deposit - Fee
|
||
|
|
- Example: 10 ETH deposit → 9.99 ETH received
|
||
|
|
- Fee: 0.01 ETH (0.1%)
|
||
|
|
|
||
|
|
## Recommendations
|
||
|
|
|
||
|
|
### Phase 1: Optional Fees
|
||
|
|
|
||
|
|
- Implement fee mechanism
|
||
|
|
- Set fee to 0% initially
|
||
|
|
- Allow enabling via governance/multisig
|
||
|
|
|
||
|
|
### Phase 2: Gradual Rollout
|
||
|
|
|
||
|
|
- Start with low fees (0.05%)
|
||
|
|
- Monitor relayer participation
|
||
|
|
- Adjust based on data
|
||
|
|
|
||
|
|
### Phase 3: Optimization
|
||
|
|
|
||
|
|
- Analyze optimal fee rate
|
||
|
|
- Consider tiered structure
|
||
|
|
- Optimize for relayer incentives
|
||
|
|
|
||
|
|
## References
|
||
|
|
|
||
|
|
- InboxETH Contract: `contracts/bridge/trustless/InboxETH.sol`
|
||
|
|
- Relayer Guide: `docs/operations/RELAYER_GUIDE.md`
|
||
|
|
- Economics: `docs/bridge/trustless/ARCHITECTURE.md`
|
||
|
|
|