- Fees apply only on successful trades.
- Fees change net proceeds, not execution.
Fee Models
Builders choose one of two fee models.Fixed Platform Fees
Charge a fixed percentage of the trade amount.- Fees are specified in basis points (bps).
- 1 bps = 0.01%.
- Example:
platformFeeBps: 50means a 0.5% fee.
platformFeeMode.
Dynamic Platform Fees (Prediction Markets)
Builders charge a price-dependent fee on prediction market outcome token trades by settingplatformFeeScale.
DFlow calculates the fee as:
kisplatformFeeScalewith 3 decimals of precision (example:50means0.050).pis the all-in price (includes all fees + filled price).cis the contract size.
p = 1). This means apps do not charge a platform fee for outcome token redemption.
Platform Fee Parameters
Configure platform fees using three parameters.platformFeeMode
UseplatformFeeMode to choose which token users pay the fee in:
outputMint(default): fee is collected from the output token.inputMint: fee is collected from the input token.
inputMint or outputMint.
For declarative trades, they can currently only be paid in the outputMint.
For prediction markets outcome token trades, they can only be paid in the settlementMint.
platformFeeBps
UseplatformFeeBps to set a fixed platform fee in basis points.
- The fee is calculated as a percentage of the trade amount.
- The fee is collected from the input or output token based on
platformFeeMode.
platformFeeScale
UseplatformFeeScale only for outcome token trades to enable dynamic fees.
- The fee scales with price and contract size using the formula above.
- The fee is zero at redemption for winning outcomes (
p = 1).
Fee Accounts
Platform fees are transferred to a builder-controlled token account. You need a separate token account (ATA) for each token you collect fees in. For example, if your app collects fees in both USDC and SOL, you need a USDC fee account and a SOL fee account.Using feeAccount
Pass feeAccount to specify the token account that receives the fee. The account must:
- Be a valid SPL token account for the token being collected.
- Already exist before the trade executes.
- Input token account when collecting from
inputMint - Output token account when collecting from
outputMint - Settlement token account when collecting from prediction market outcome token trades
How Platform Fees Affect Trades
Platform fees change net economics, not trade behavior.- Routing stays the same.
- Slippage enforcement stays the same.
- Execution timing stays the same.
When To Use Platform Fees
Use platform fees if you want to:- Monetize trading volume.
- Fund product development.
- Align incentives with usage.
Code Recipes
Need Help?
Join Our Discord
Connect with other developers, get help, and stay updated on the latest
DFlow developments.
Dev Notifications
Join the DFlow Dev Notifications Telegram group to stay in the loop on
new features and other announcements.