Skip to main content
Risk buffers add a layer of protection to StableFX trades. During trade execution, StableFX holds a proportional amount of the trade as buffer from both the taker and maker in escrow. This buffer manages counterparty risk, meaning one party fails to fund the trade after agreeing to it. By holding funds in escrow upfront, StableFX ensures both sides commit to the trade. This reduces exposure and improves settlement integrity.

Risk buffer calculation

StableFX defines risk buffer settings per maker and currency pair. Each setting controls how much of the taker’s and maker’s notional amounts are reserved as buffers for that trading pair.
ParameterDescription
Taker risk buffer %Percentage of the sell currency amount held as the taker’s buffer.
Taker risk buffer minMinimum value of the taker’s risk buffer in absolute terms.
Maker risk buffer %Percentage of the buy currency amount held as the maker’s buffer.
Maker risk buffer minMinimum value of the maker’s risk buffer in absolute terms.
A value of 0% is valid for any risk buffer. If no setting exists for a given maker-taker pair, both risk buffers default to 0. When a taker requests a quote, StableFX:
  1. Retrieves the risk buffer configuration for the maker and currency pair.
  2. Calculates both taker and maker risk buffers based on the configuration parameters.
  3. Returns the taker’s risk buffer in the quote response as the collateral parameter.
This gives the taker full visibility into the total funds required before trade execution.

Trade broadcast

After StableFX registers signatures for both the taker and maker, it broadcasts the recordTrade function to the settlement contract. This function withdraws trade collateral from each trader’s wallet using the Permit2 protocol.
Both traders must have sufficient balance for their collateral amount specified on the quote and Permit2 approval for their funding token to successfully record the trade onchain.

Where to find the risk buffer

The risk buffer amount appears in several places:
  • Create Quote API response: Returned as the collateral field for the taker. See Create a quote.
  • Get Trade API response: Makers can find the collateral field in the trade response. See Get a trade.
  • Typed data for signing: Available in the message.permitted.amount field of the EIP-712 typed data.
The currency of the collateral is always the currency that the trader is responsible for funding.

How risk buffers affect settlement

Breach scenarios

If a trade reaches maturity but remains unsettled, StableFX calls the escrow contract’s breach function to expire the trade. The outcome depends on which party has funded: Neither party funds If neither the taker nor the maker funds before expiry, the smart contract returns both parties’ risk buffers from escrow. No breach compensation is applied. One party funds If only one party funds the trade before expiry, the non-funding party is treated as the breaching party. The contract:
  • Awards the non-funding party’s risk buffer to the funding party as compensation.
  • Returns the funding party’s own buffer and trade funds to them.
This keeps the process fair regardless of which side funds first. The party who funds is protected, while the party who doesn’t bears the cost of their collateral.

Funding

Parties are only required to fund the difference between their collateral and the trade amount. This calculation is built into the StableFX Fund APIs.