diff --git a/docs/FEES.md b/docs/FEES.md new file mode 100644 index 0000000..9ea4997 --- /dev/null +++ b/docs/FEES.md @@ -0,0 +1,150 @@ +# Fees + +Contractless transactions have base fees. These are the minimum fees required for validation. + +Wallet software may allow users to increase fees above the base minimum. Higher fees can make a transaction more attractive for miners when they are selecting pending transactions from the mempool. + +Fees are paid in the base coin for the network. On testnet this is usually displayed as `CLTC`. On mainnet this is usually displayed as `CLC`. + +## Base Fee Chart + +| Transaction | Base Fee | +| --- | ---: | +| Base coin transfer | `1%` of transfer amount | +| Token transfer | `1.00000000` | +| NFT transfer | `1.00000000` | +| Numbered NFT transfer | `1.00000000` | +| Create token | `500.00000000` | +| Issue more tokens | `100.00000000` | +| Create NFT | `0.50000000` | +| Marketing record | `1.00000000` | +| Swap | `1.00000000` per signer | +| Create loan | `3.00000000` | +| Loan payment | `0.01000000` | +| Collateral claim | `3.00000000` | +| Burn token or NFT | `0.00010000` | +| Vanity address registration/update | `5.00000000` | +| Create storage key | `500.00000000` | +| Write storage value | `1.00000000` | + +## Transfer Fees + +Base coin transfers use a percentage fee: + +```text +minimum fee = transfer amount * 1% +``` + +Token and NFT transfers use the fixed non-base transfer minimum: + +```text +1.00000000 +``` + +For numbered NFT collection transfers, the transfer amount must be exactly one NFT item, and the transfer fee is still the fixed non-base transfer fee. + +## Swap Fees and Tips + +Each swap signer pays the fixed swap base fee: + +```text +1.00000000 per signer +``` + +Swaps also include asset-denominated miner tips for the trade sides. + +Each side has two separate miner payments: + +| Field | Paid By | Paid In | Paid To | Notes | +| --- | --- | --- | --- | --- | +| `txfee1` | `sender1` | Base coin | Miner | Must be at least `1.00000000`. | +| `txfee2` | `sender2` | Base coin | Miner | Must be at least `1.00000000`. | +| `tip1` | `sender1` | `ticker1` / side 1 asset | Miner | For fungible assets, must be at least 1% of `value1`. For NFT sides, must be `0`. | +| `tip2` | `sender2` | `ticker2` / side 2 asset | Miner | For fungible assets, must be at least 1% of `value2`. For NFT sides, must be `0`. | + +The tips are not sent to the swap counterparty. They are paid to the miner who includes the swap in a block. + +For fungible swap sides, spendability is checked against the offered amount plus the tip: + +```text +sender1 must have value1 + tip1 of ticker1 +sender2 must have value2 + tip2 of ticker2 +``` + +Each sender must also have enough base coin for their own base transaction fee. + +## Loan Payment Fees and Tips + +Loan payments have a base fee: + +```text +0.01000000 +``` + +Loan payments also include an asset-denominated miner tip. + +| Field | Paid By | Paid In | Paid To | Notes | +| --- | --- | --- | --- | --- | +| `txfee` | Borrower / payer | Base coin | Miner | Must be at least `0.01000000`. | +| `payback_amount` | Borrower / payer | Loan asset | Lender | Counts toward the loan balance. | +| `tip` | Borrower / payer | Loan asset | Miner | Must be at least 1% of `payback_amount`. | + +The lender receives only the `payback_amount`. The miner receives the base fee and the tip. + +Spendability is checked against the payment amount plus the tip: + +```text +borrower must have payback_amount + tip of the loan asset +borrower must also have txfee in base coin +``` + +Pending loan payments in the mempool also reserve the tip amount. This prevents a borrower from creating multiple pending payments that appear valid only because the tips were ignored. + +## Storage Lookup Fees + +Storage write fees are normal transaction fees and are listed in the base fee chart. + +Storage lookups are different. A node operator may charge a per-byte lookup fee for returning app storage data through RPC. That fee is configured by the node operator in `settings.ini` and is not a fixed network-wide transaction fee. + +Use `lookup_storage_cost` to quote storage lookup fees before paying for a lookup. See [Data Storage](src/branch/main/docs/DATA_STORAGE.md). + +## lookup_largest_txfee + +`lookup_largest_txfee` asks a configured node for the largest transaction fee currently known from its mempool data. + +This can help users or wallet software understand what base fee level is currently competing for miner selection. + +For swaps, the lookup compares both base fee fields, `txfee1` and `txfee2`. It does not include asset-denominated swap tips. + +For loan payments, the lookup uses the base `txfee`. It does not include the asset-denominated loan payment tip. + +Usage: + +```bash +./lookup_largest_txfee +``` + +Interactive prompts: + +```text +Please enter the path to your wallet file: +What is your wallet decryption key? +``` + +Expected output: + +```json +{ + "largest_tx_fee": "1.00000000" +} +``` + +If the peer has no mempool transactions, the tool returns: + +```json +{ + "largest_tx_fee": "0.00000000" +} +``` + +The value is only a snapshot from the peer that answered the request. Different nodes may temporarily report different mempool fee data.