> ## Documentation Index
> Fetch the complete documentation index at: https://developers.circle.com/llms.txt
> Use this file to discover all available pages before exploring further.

# StableFX contract interfaces

> User-facing methods of the StableFX contract

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.

## Contract address

The `FxEscrow` contract is deployed at
[`0x867650F5eAe8df91445971f14d89fd84F0C9a9f8`](https://testnet.arcscan.app/address/0x867650F5eAe8df91445971f14d89fd84F0C9a9f8)
on the [Arc testnet](https://docs.arc.io).

## Interfaces

### `recordTrade`

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

```solidity theme={null}
function recordTrade(
  address taker,
  TraderDetails calldata takerDetails,
  bytes calldata takerSignature,
  address maker,
  TraderDetails calldata makerDetails,
  bytes calldata makerSignature
) external returns (uint256);
```

**Parameters**

| Name             | Type            | Description                |
| ---------------- | --------------- | -------------------------- |
| `taker`          | `address`       | The address of the taker   |
| `takerDetails`   | `TraderDetails` | The details of the taker   |
| `takerSignature` | `bytes`         | The signature of the taker |
| `maker`          | `address`       | The address of the maker   |
| `makerDetails`   | `TraderDetails` | The details of the maker   |
| `makerSignature` | `bytes`         | The signature of the maker |

**Returns**

| Name | Type      | Description                  |
| ---- | --------- | ---------------------------- |
| `id` | `uint256` | The contract ID of the trade |

### `takerDeliver`

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

```solidity theme={null}
function takerDeliver(uint256 id, IPermit2.PermitTransferFrom memory permit, bytes calldata signature) external;
```

**Parameters**

| Name        | Type                                    | Description                             |
| ----------- | --------------------------------------- | --------------------------------------- |
| `id`        | `uint256`                               | The ID of the trade                     |
| `permit`    | [`IPermit2.PermitTransferFrom`][permit] | The `Permit2`-compliant transfer permit |
| `signature` | `bytes`                                 | The signature for the transfer permit   |

[permit]: https://github.com/Uniswap/permit2/blob/cc56ad0f3439c502c246fc5cfcc3db92bb8b7219/src/interfaces/ISignatureTransfer.sol#L30

### `takerBatchDeliver`

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

```solidity theme={null}
function takerBatchDeliver(uint256[] calldata ids, IPermit2.PermitBatchTransferFrom memory permit, bytes calldata signature) external;
```

**Parameters**

| Name        | Type                                               | Description                                   |
| ----------- | -------------------------------------------------- | --------------------------------------------- |
| `ids`       | `uint256[]`                                        | An array of trade IDs                         |
| `permit`    | [`IPermit2.PermitBatchTransferFrom`][permit_batch] | The `Permit2`-compliant batch transfer permit |
| `signature` | `bytes`                                            | The signature for the batch permit            |

[permit_batch]: https://github.com/Uniswap/permit2/blob/cc56ad0f3439c502c246fc5cfcc3db92bb8b7219/src/interfaces/ISignatureTransfer.sol#L51

### `makerDeliver`

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

```solidity theme={null}
function makerDeliver(uint256 id, IPermit2.PermitTransferFrom memory permit, bytes calldata signature) external
```

**Parameters**

| Name        | Type                                    | Description                             |
| ----------- | --------------------------------------- | --------------------------------------- |
| `id`        | `uint256`                               | The ID of the trade                     |
| `permit`    | [`IPermit2.PermitTransferFrom`][permit] | The `Permit2`-compliant transfer permit |
| `signature` | `bytes`                                 | The signature for the transfer permit   |

### `makerBatchDeliver`

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

```solidity theme={null}
function makerBatchDeliver(uint256[] calldata ids, IPermit2.PermitBatchTransferFrom memory permit, bytes calldata signature) external;
```

**Parameters**

| Name        | Type                                               | Description                                   |
| ----------- | -------------------------------------------------- | --------------------------------------------- |
| `ids`       | `uint256[]`                                        | An array of trade IDs                         |
| `permit`    | [`IPermit2.PermitBatchTransferFrom`][permit_batch] | The `Permit2`-compliant batch transfer permit |
| `signature` | `bytes`                                            | The signature for the batch permit            |

### `makerNetDeliver`

Net settlement for multiple trades on the maker side.

```solidity theme={null}
function makerNetDeliver(uint256[] calldata ids, IPermit2.PermitBatchTransferFrom memory permit, bytes calldata signature) external
```

**Parameters**

| Name        | Type                                               | Description                                   |
| ----------- | -------------------------------------------------- | --------------------------------------------- |
| `ids`       | `uint256[]`                                        | An array of trade IDs                         |
| `permit`    | [`IPermit2.PermitBatchTransferFrom`][permit_batch] | The `Permit2`-compliant batch transfer permit |
| `signature` | `bytes`                                            | The signature for the batch permit            |

### `breach`

Marks a trade as breached after maturity.

```solidity theme={null}
function breach(uint256 id) external;
```

**Parameters**

| Name | Type      | Description         |
| ---- | --------- | ------------------- |
| `id` | `uint256` | The ID of the trade |

### `breach` (batch)

Marks multiple trades as breached after maturity.

```solidity theme={null}
function breach(uint256[] ids) external;
```

**Parameters**

| Name  | Type        | Description           |
| ----- | ----------- | --------------------- |
| `ids` | `uint256[]` | An array of trade IDs |

### `calculateMakerNet`

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

```solidity theme={null}
function calculateMakerNet(address maker, uint256[] calldata ids) public view returns (Balance[] memory balances);
```

**Parameters**

| Name    | Type        | Description              |
| ------- | ----------- | ------------------------ |
| `maker` | `address`   | The address of the maker |
| `ids`   | `uint256[]` | An array of trade IDs    |

**Returns**

| Name       | Type        | Description                                            |
| ---------- | ----------- | ------------------------------------------------------ |
| `balances` | `Balance[]` | An array of Balance structs representing net positions |
