Skip to content

Commit 8c7537e

Browse files
authored
fix: remove settlement fee (#502)
closes #243
1 parent 3d6293b commit 8c7537e

File tree

6 files changed

+6
-81
lines changed

6 files changed

+6
-81
lines changed

docs/src/content/docs/developer-guides/payments/rails-settlement.mdx

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -130,27 +130,6 @@ Settlement is the process of executing the accumulated payments in a rail. Until
130130
- **Flexibility**: Allows validators to adjust payments if needed
131131
- **Finality**: Makes funds available for withdrawal
132132

133-
### Settlement Fee
134-
135-
:::warning[FIL Required for Settlement]
136-
**Every settlement operation requires 0.0013 FIL** in your wallet (separate from USDFC deposits). This fee is burned to the Filecoin network and is **NOT** returned. Ensure you have sufficient FIL balance before attempting settlement operations.
137-
:::
138-
139-
Settlement operations require a network fee that is burned (permanently removed from circulation), effectively paying the Filecoin network for providing the settlement service:
140-
141-
- **Amount**: 0.0013 FIL (defined as `SETTLEMENT_FEE` constant)
142-
- **Mechanism**: The fee is burned to Filecoin's burn actor, `f099` (also known as address `0xff00000000000000000000000000000000000063`), reducing FIL supply
143-
- **Purpose**: This burn mechanism compensates the network for processing and securing payment settlements
144-
- **Automatic**: The SDK automatically includes this fee when calling settlement methods
145-
146-
```ts twoslash
147-
import { ethers } from "ethers";
148-
// ---cut---
149-
import { SETTLEMENT_FEE } from "@filoz/synapse-sdk";
150-
console.log(`Settlement fee: ${ethers.formatEther(SETTLEMENT_FEE)} FIL`);
151-
// This fee is burned to the network, not paid to any party
152-
```
153-
154133
### Performing Settlement
155134

156135
#### Automatic Settlement (Recommended)

docs/src/content/docs/guides/rails-settlement.mdx

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -118,21 +118,6 @@ Settlement is the process of executing the accumulated payments in a rail. Until
118118
- **Flexibility**: Allows validators to adjust payments if needed
119119
- **Finality**: Makes funds available for withdrawal
120120

121-
### Settlement Fee
122-
123-
Settlement operations require a network fee that is burned (permanently removed from circulation), effectively paying the Filecoin network for providing the settlement service:
124-
125-
- **Amount**: 0.0013 FIL (defined as `SETTLEMENT_FEE` constant)
126-
- **Mechanism**: The fee is burned to Filecoin's burn actor, `f099` (also known as address `0xff00000000000000000000000000000000000063`), reducing FIL supply
127-
- **Purpose**: This burn mechanism compensates the network for processing and securing payment settlements
128-
- **Automatic**: The SDK automatically includes this fee when calling settlement methods
129-
130-
```typescript
131-
import { SETTLEMENT_FEE } from '@filoz/synapse-sdk'
132-
console.log(`Settlement fee: ${ethers.formatEther(SETTLEMENT_FEE)} FIL`)
133-
// This fee is burned to the network, not paid to any party
134-
```
135-
136121
### Performing Settlement
137122

138123
#### Automatic Settlement (Recommended)
@@ -159,7 +144,6 @@ For more control, you can use the specific settlement methods:
159144
Settle up to the current epoch:
160145

161146
```typescript
162-
// Settle a specific rail (requires settlement fee)
163147
const tx = await synapse.payments.settle(railId)
164148
await tx.wait()
165149
console.log('Rail settled successfully')
@@ -287,9 +271,7 @@ Common settlement errors and solutions:
287271
try {
288272
await synapse.payments.settle(railId)
289273
} catch (error) {
290-
if (error.message.includes('InsufficientNativeTokenForBurn')) {
291-
console.error('Insufficient FIL for settlement fee (0.0013 FIL required)')
292-
} else if (error.message.includes('NoProgressInSettlement')) {
274+
if (error.message.includes('NoProgressInSettlement')) {
293275
console.error('Rail already settled to current epoch')
294276
} else if (error.message.includes('RailNotActive')) {
295277
console.error('Rail is not active or already terminated')

packages/synapse-sdk/src/payments/service.ts

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import {
1313
EIP2612_PERMIT_TYPES,
1414
getCurrentEpoch,
1515
getFilecoinNetworkType,
16-
SETTLEMENT_FEE,
1716
TIMING_CONSTANTS,
1817
TOKENS,
1918
} from '../utils/index.ts'
@@ -861,7 +860,7 @@ export class PaymentsService {
861860

862861
/**
863862
* Settle a payment rail up to a specific epoch (sends a transaction)
864-
* Note: This method automatically includes the required network fee (FIL) for burning
863+
*
865864
* @param railId - The rail ID to settle
866865
* @param untilEpoch - The epoch to settle up to (must be <= current epoch; defaults to current).
867866
* Can be used for partial settlements to a past epoch.
@@ -881,9 +880,7 @@ export class PaymentsService {
881880
const paymentsContract = this._getPaymentsContract()
882881

883882
// Only set explicit nonce if NonceManager is disabled
884-
const txOptions: any = {
885-
value: SETTLEMENT_FEE, // Include the settlement fee (NETWORK_FEE in contract) as msg.value
886-
}
883+
const txOptions: any = {}
887884
if (this._disableNonceManager) {
888885
const currentNonce = await this._provider.getTransactionCount(signerAddress, 'pending')
889886
txOptions.nonce = currentNonce
@@ -904,7 +901,7 @@ export class PaymentsService {
904901

905902
/**
906903
* Get the expected settlement amounts for a rail (read-only simulation)
907-
* Note: The actual settlement will require a network fee (FIL) to be sent with the transaction
904+
*
908905
* @param railId - The rail ID to check
909906
* @param untilEpoch - The epoch to settle up to (must be <= current epoch; defaults to current).
910907
* Can be used to preview partial settlements to a past epoch.
@@ -921,7 +918,6 @@ export class PaymentsService {
921918

922919
try {
923920
// Use staticCall to simulate the transaction and get the return values
924-
// Include the settlement fee (NETWORK_FEE in contract) in the simulation
925921
const result = await paymentsContract.settleRail.staticCall(railIdBigint, untilEpochBigint)
926922

927923
return {
@@ -1026,7 +1022,7 @@ export class PaymentsService {
10261022
* Automatically settle a rail, detecting whether it's terminated or active
10271023
* This method checks the rail status and calls the appropriate settlement method:
10281024
* - For terminated rails: calls settleTerminatedRail()
1029-
* - For active rails: calls settle() with optional untilEpoch (requires settlement fee)
1025+
* - For active rails: calls settle() with optional untilEpoch
10301026
*
10311027
* @param railId - The rail ID to settle
10321028
* @param untilEpoch - The epoch to settle up to (must be <= current epoch for active rails; ignored for terminated rails)

packages/synapse-sdk/src/test/payments.test.ts

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -393,18 +393,6 @@ describe('PaymentsService', () => {
393393
})
394394
})
395395

396-
describe('SETTLEMENT_FEE constant', () => {
397-
it('should have correct settlement fee value', () => {
398-
// Import the constant
399-
const { SETTLEMENT_FEE } = require('../utils/constants.ts')
400-
401-
assert.exists(SETTLEMENT_FEE)
402-
assert.typeOf(SETTLEMENT_FEE, 'bigint')
403-
// Settlement fee should be 0.0013 FIL (1300000000000000 attoFIL)
404-
assert.equal(SETTLEMENT_FEE, 1300000000000000n)
405-
})
406-
})
407-
408396
describe('settle', () => {
409397
it('should settle a rail up to current epoch', async () => {
410398
server.use(JSONRPC(presets.basic))
@@ -417,9 +405,6 @@ describe('PaymentsService', () => {
417405
assert.exists(tx.from)
418406
assert.exists(tx.to)
419407
assert.exists(tx.data)
420-
// Check that the transaction includes the network fee as value
421-
assert.exists(tx.value)
422-
assert.isTrue(tx.value > 0n)
423408
})
424409

425410
it('should settle a rail up to specific epoch', async () => {
@@ -543,9 +528,6 @@ describe('PaymentsService', () => {
543528
assert.exists(tx)
544529
assert.exists(tx.hash)
545530
assert.typeOf(tx.hash, 'string')
546-
// Check that the transaction includes the settlement fee as value
547-
assert.exists(tx.value)
548-
assert.isTrue(tx.value > 0n)
549531
})
550532

551533
it('should settle terminated rail using settleTerminatedRail', async () => {
@@ -599,8 +581,6 @@ describe('PaymentsService', () => {
599581
assert.exists(tx)
600582
assert.exists(tx.hash)
601583
assert.typeOf(tx.hash, 'string')
602-
assert.exists(tx.value)
603-
assert.isTrue(tx.value > 0n)
604584
})
605585

606586
it('should accept bigint rail ID', async () => {

packages/synapse-sdk/src/utils/constants.ts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -302,16 +302,6 @@ export const TIMING_CONSTANTS = {
302302
PIECE_ADDITION_POLL_INTERVAL_MS: 1000, // 1 second
303303
} as const
304304

305-
/**
306-
* Settlement fee required for rail settlement operations
307-
* This is the NETWORK_FEE constant in the Payments contract that gets burned to the Filecoin network
308-
* Value: 0.0013 FIL (1300000000000000 attoFIL)
309-
*
310-
* IMPORTANT: This value must be kept in sync with the Payments contract's NETWORK_FEE constant.
311-
* If the contract is upgraded with a different fee, this constant must be updated accordingly.
312-
*/
313-
export const SETTLEMENT_FEE = 1300000000000000n // 0.0013 FIL in attoFIL
314-
315305
/**
316306
* Recommended RPC endpoints for Filecoin networks
317307
*/

utils/settle-dataset-rails.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
*/
1111

1212
import { ethers } from 'ethers'
13-
import { SETTLEMENT_FEE, Synapse } from '../packages/synapse-sdk/src/index.ts'
13+
import { Synapse } from '../packages/synapse-sdk/src/index.ts'
1414
import { getCurrentEpoch } from '../packages/synapse-sdk/src/utils/index.ts'
1515
import { WarmStorageService } from '../packages/synapse-sdk/src/warm-storage/index.ts'
1616

@@ -147,7 +147,6 @@ async function main() {
147147
}
148148

149149
console.log(`Checking settlement amounts for ${railsToSettle.length} rail(s)...`)
150-
console.log(`${DIM}Settlement fee: ${ethers.formatEther(SETTLEMENT_FEE)} FIL per transaction${RESET}`)
151150
console.log('')
152151

153152
let totalSettled = 0n
@@ -231,7 +230,6 @@ async function main() {
231230
// Check if it's the InsufficientNativeTokenForBurn error
232231
if (error.message.includes('InsufficientNativeTokenForBurn')) {
233232
console.log(` ${YELLOW}Insufficient FIL for network fee${RESET}`)
234-
console.log(` Required: ${ethers.formatEther(SETTLEMENT_FEE)} FIL`)
235233
}
236234

237235
console.log('')

0 commit comments

Comments
 (0)