Skip to content

feat(commission): add configurable base fees for fundsIn and fundsOut - #140

Open
sh3ifu wants to merge 5 commits into
devfrom
base-fee-commission
Open

feat(commission): add configurable base fees for fundsIn and fundsOut#140
sh3ifu wants to merge 5 commits into
devfrom
base-fee-commission

Conversation

@sh3ifu

@sh3ifu sh3ifu commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Summary

Commissions previously supported only a proportional component. This could not reliably cover fixed per-operation costs, such as a Bitcoin transaction fee, especially for small transfers.
Commission rules now support an optional flat baseFee:
fee = amount × stablePercent / multiplier² + baseFee

Changes

Added baseFee to global defaults and per-route commission configurations. It applies to both fundsIn and fundsOut; either the proportional or flat component may be zero, and setting both to zero disables the commission.

Added separate configurable minFundsInAmount and minFundsOutAmount limits. Bridge rejects operations below the corresponding minimum.

CommissionManager validates that the combined fee at the applicable minimum leaves a positive net amount:
percentageFee(minAmount) + baseFee < minAmount

This is checked during configuration and again during quoting because Bridge minimums can be changed later.

FUNDS_IN supports token or native commission; for native commission, the complete proportional plus flat fee is converted through the ETH/USD feed. FUNDS_OUT remains token-only.

Also: added calculateTotalFee, exposed the Bridge deposit/release floors, included baseFee in getGlobalDefaults, and updated deployment scripts, environment variables, tests, interfaces, and README documentation.

@Yuliya-YKO

Copy link
Copy Markdown

Heads-up for the bridge side, @gutmann03: this changes getGlobalDefaults()
from 4 return values to 5, with baseFee inserted second.

bridge-utexo decodes the old four at
internal/contracts/evm/commissionmanager/client.go:95. The selector
0x9f05119a is unchanged (it's derived from inputs only), so the call won't
revert — it will decode baseFee into the multiplier slot: a decode error
when baseFee > 255, silently shifted fields otherwise.

Current callers only read StablePercent, so impact is limited, but the
bridge decode needs to land in the same release as this PR.

Found during the signer audit; no action needed on the contract side.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants