StableFX

StableFX Contract Interfaces

The StableFX smart contract (FxEscrow) has a set of interfaces you can use to execute trades either as a maker or a taker. This page describes the user-facing methods of the StableFX contract.

recordTrade

Records a trade agreement onchain. Returns the contract ID of the trade.

Solidity
function recordTrade(
  address taker,
  TakerDetails calldata takerDetails,
  bytes calldata takerSignature,
  address maker,
  MakerDetails calldata makerDetails,
  bytes calldata makerSignature
) external returns (uint256);

Parameters

NameTypeDescription
takeraddressThe address of the taker
takerDetailsTakerDetailsThe details of the taker
takerSignaturebytesThe signature of the taker
makeraddressThe address of the maker
makerDetailsMakerDetailsThe details of the maker
makerSignaturebytesThe signature of the maker

Returns

NameTypeDescription
iduint256The contract ID of the trade

takerDeliver

Delivers quote currency for a single trade using Permit2 on the taker side.

Solidity
function takerDeliver(uint256 id, IPermit2.PermitTransferFrom memory permit, bytes calldata signature) external;

Parameters

NameTypeDescription
iduint256The ID of the trade
permitIPermit2.PermitTransferFromThe Permit2-compliant transfer permit
signaturebytesThe signature for the transfer permit

takerBatchDeliver

Delivers quote currency for multiple trades using Permit2 on the taker side.

Solidity
function takerBatchDeliver(uint256[] calldata ids, IPermit2.PermitBatchTransferFrom memory permit, bytes calldata signature) external;

Parameters

NameTypeDescription
idsuint256[]An array of trade IDs
permitIPermit2.PermitBatchTransferFromThe Permit2-compliant batch transfer permit
signaturebytesThe signature for the batch permit

makerDeliver

Delivers base currency for a single trade using Permit2 on the maker side.

Solidity
function makerDeliver(uint256 id, IPermit2.PermitTransferFrom memory permit, bytes calldata signature) external

Parameters

NameTypeDescription
iduint256The ID of the trade
permitIPermit2.PermitTransferFromThe Permit2-compliant transfer permit
signaturebytesThe signature for the transfer permit

makerBatchDeliver

Delivers quote currency for multiple trades using Permit2 on the maker side.

Solidity
function makerBatchDeliver(uint256[] calldata ids, IPermit2.PermitBatchTransferFrom memory permit, bytes calldata signature) external;

Parameters

NameTypeDescription
idsuint256[]An array of trade IDs
permitIPermit2.PermitBatchTransferFromThe Permit2-compliant batch transfer permit
signaturebytesThe signature for the batch permit

makerNetDeliver

Net settlement for multiple trades on the maker side.

Solidity
function makerNetDeliver(uint256[] calldata ids, IPermit2.PermitBatchTransferFrom memory permit, bytes calldata signature) external

Parameters

NameTypeDescription
idsuint256[]An array of trade IDs
permitIPermit2.PermitBatchTransferFromThe Permit2-compliant batch transfer permit
signaturebytesThe signature for the batch permit

breach

Marks a trade as breached after maturity.

Solidity
function breach(uint256 id) external;

Parameters

NameTypeDescription
iduint256The ID of the trade

breach (batch)

Marks multiple trades as breached after maturity.

Solidity
function breach(uint256[] ids) external;

Parameters

NameTypeDescription
idsuint256[]An array of trade IDs

calculateMakerNet

Calculate maker net token positions for batch operations. Returns an array of Balance structs representing net positions.

Solidity
function calculateMakerNet(address maker, uint256[] calldata ids) public view returns (Balance[] memory balances);

Parameters

NameTypeDescription
makeraddressThe address of the maker
idsuint256[]An array of trade IDs

Returns

NameTypeDescription
balancesBalance[]An array of Balance structs representing net positions
Did this page help you?
© 2023-2025 Circle Technology Services, LLC. All rights reserved.