> For the complete documentation index, see [llms.txt](https://docs.vulpefi.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.vulpefi.com/aggregation-protocol/limit-order-protocol/smart-contracts/ordermixin.md).

# OrderMixin

Regular Limit Order mixin

## Derives[​](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/OrderMixin#derives) <a href="#derives" id="derives"></a>

* [Permitable](broken://pages/DOO2eTZDAe5crCpeY8uu)
* [PredicateHelper](/aggregation-protocol/limit-order-protocol/smart-contracts/helpers/predicatehelper.md)
* [NonceManager](/aggregation-protocol/limit-order-protocol/smart-contracts/helpers/noncemanager.md)
* [ChainlinkCalculator](/aggregation-protocol/limit-order-protocol/smart-contracts/helpers/chainlinkcalculator.md)
* [AmountCalculator](/aggregation-protocol/limit-order-protocol/smart-contracts/helpers/amountcalculator.md)
* [EIP712](https://docs.openzeppelin.com/contracts/3.x/api/utils/cryptography#draft-EIP712)

## Functions[​](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/OrderMixin#functions) <a href="#functions" id="functions"></a>

### remaining[​](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/OrderMixin#remaining) <a href="#remaining" id="remaining"></a>

```javascript
function remaining(
  bytes32 orderHash
) external returns (uint256)
```

Returns unfilled amount for order. Throws if order does not exist

**Parameters:**[**​**](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/OrderMixin#parameters)

| Name        | Type    | Description |
| ----------- | ------- | ----------- |
| `orderHash` | bytes32 |             |

### remainingRaw[​](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/OrderMixin#remainingraw) <a href="#remainingraw" id="remainingraw"></a>

```javascript
function remainingRaw(
  bytes32 orderHash
) external returns (uint256)
```

Returns unfilled amount for order

**Parameters:**[**​**](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/OrderMixin#parameters-1)

| Name        | Type    | Description |
| ----------- | ------- | ----------- |
| `orderHash` | bytes32 |             |

**Return Values:**[**​**](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/OrderMixin#return-values)

| Name     | Type    | Description                                                    |
| -------- | ------- | -------------------------------------------------------------- |
| `Result` | uint256 | Unfilled amount of order plus one if order exists. Otherwise 0 |

### remainingsRaw[​](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/OrderMixin#remainingsraw) <a href="#remainingsraw" id="remainingsraw"></a>

```javascript
function remainingsRaw(
  bytes32[] orderHashes
) external returns (uint256[])
```

Same as `remainingRaw` but for multiple orders

**Parameters:**[**​**](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/OrderMixin#parameters-2)

| Name          | Type       | Description |
| ------------- | ---------- | ----------- |
| `orderHashes` | bytes32\[] |             |

### simulateCalls[​](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/OrderMixin#simulatecalls) <a href="#simulatecalls" id="simulatecalls"></a>

```javascript
function simulateCalls(
  address[] targets,
  bytes[] data
) external
```

Calls every target with corresponding data. Then reverts with CALL\_RESULTS\_0101011 where zeroes and ones denote failure or success of the corresponding call

**Parameters:**[**​**](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/OrderMixin#parameters-3)

| Name      | Type       | Description                                    |
| --------- | ---------- | ---------------------------------------------- |
| `targets` | address\[] | Array of addresses that will be called         |
| `data`    | bytes\[]   | Array of data that will be passed to each call |

### cancelOrder[​](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/OrderMixin#cancelorder) <a href="#cancelorder" id="cancelorder"></a>

```javascript
function cancelOrder(
  struct OrderLib.Order order
) external
```

Cancels order by setting remaining amount to zero

**Parameters:**[**​**](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/OrderMixin#parameters-4)

| Name    | Type                  | Description |
| ------- | --------------------- | ----------- |
| `order` | struct OrderLib.Order |             |

### fillOrder[​](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/OrderMixin#fillorder) <a href="#fillorder" id="fillorder"></a>

```javascript
function fillOrder(
  struct OrderLib.Order order,
  bytes signature,
  bytes interaction,
  uint256 makingAmount,
  uint256 takingAmount,
  uint256 thresholdAmount
) external returns (uint256, uint256)
```

Fills an order. If one doesn't exist (first fill) it will be created using order.makerAssetData

**Parameters:**[**​**](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/OrderMixin#parameters-5)

| Name              | Type                  | Description                                                                                                        |
| ----------------- | --------------------- | ------------------------------------------------------------------------------------------------------------------ |
| `order`           | struct OrderLib.Order | Order quote to fill                                                                                                |
| `signature`       | bytes                 | Signature to confirm quote ownership                                                                               |
| `interaction`     | bytes                 | Making amount                                                                                                      |
| `makingAmount`    | uint256               | Taking amount                                                                                                      |
| `takingAmount`    | uint256               | Specifies maximum allowed takingAmount when takingAmount is zero, otherwise specifies minimum allowed makingAmount |
| `thresholdAmount` | uint256               |                                                                                                                    |

### fillOrderToWithPermit[​](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/OrderMixin#fillordertowithpermit) <a href="#fillordertowithpermit" id="fillordertowithpermit"></a>

```javascript
function fillOrderToWithPermit(
  struct OrderLib.Order order,
  bytes signature,
  bytes interaction,
  uint256 makingAmount,
  uint256 takingAmount,
  uint256 thresholdAmount,
  address target,
  bytes permit
) external returns (uint256, uint256)
```

Same as `fillOrder` but calls permit first, allowing to approve token spending and make a swap in one transaction. Also allows to specify funds destination instead of `msg.sender`

See tests for examples

**Parameters:**[**​**](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/OrderMixin#parameters-6)

| Name              | Type                  | Description                                                                                                        |
| ----------------- | --------------------- | ------------------------------------------------------------------------------------------------------------------ |
| `order`           | struct OrderLib.Order | Order quote to fill                                                                                                |
| `signature`       | bytes                 | Signature to confirm quote ownership                                                                               |
| `interaction`     | bytes                 | Making amount                                                                                                      |
| `makingAmount`    | uint256               | Taking amount                                                                                                      |
| `takingAmount`    | uint256               | Specifies maximum allowed takingAmount when takingAmount is zero, otherwise specifies minimum allowed makingAmount |
| `thresholdAmount` | uint256               | Address that will receive swap funds                                                                               |
| `target`          | address               | Should consist of abiencoded token address and encoded `IERC20Permit.permit` call.                                 |
| `permit`          | bytes                 |                                                                                                                    |

### fillOrderTo[​](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/OrderMixin#fillorderto) <a href="#fillorderto" id="fillorderto"></a>

```javascript
function fillOrderTo(
  struct OrderLib.Order order_,
  bytes signature,
  bytes interaction,
  uint256 makingAmount,
  uint256 takingAmount,
  uint256 thresholdAmount,
  address target
) public returns (uint256, uint256)
```

Same as `fillOrder` but allows to specify funds destination instead of `msg.sender`

**Parameters:**[**​**](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/OrderMixin#parameters-7)

| Name              | Type                  | Description                                                                                                        |
| ----------------- | --------------------- | ------------------------------------------------------------------------------------------------------------------ |
| `order_`          | struct OrderLib.Order | Order quote to fill                                                                                                |
| `signature`       | bytes                 | Signature to confirm quote ownership                                                                               |
| `interaction`     | bytes                 | Making amount                                                                                                      |
| `makingAmount`    | uint256               | Taking amount                                                                                                      |
| `takingAmount`    | uint256               | Specifies maximum allowed takingAmount when takingAmount is zero, otherwise specifies minimum allowed makingAmount |
| `thresholdAmount` | uint256               | Address that will receive swap funds                                                                               |
| `target`          | address               |                                                                                                                    |

### checkPredicate[​](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/OrderMixin#checkpredicate) <a href="#checkpredicate" id="checkpredicate"></a>

```javascript
function checkPredicate(
  struct OrderLib.Order order
) public returns (bool)
```

Checks order predicate

**Parameters:**[**​**](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/OrderMixin#parameters-8)

| Name    | Type                  | Description |
| ------- | --------------------- | ----------- |
| `order` | struct OrderLib.Order |             |

### hashOrder[​](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/OrderMixin#hashorder) <a href="#hashorder" id="hashorder"></a>

```javascript
function hashOrder(
  struct OrderLib.Order order
) public returns (bytes32)
```

**Parameters:**[**​**](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/OrderMixin#parameters-9)

| Name    | Type                  | Description |
| ------- | --------------------- | ----------- |
| `order` | struct OrderLib.Order |             |

## Events[​](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/OrderMixin#events) <a href="#events" id="events"></a>

### OrderFilled[​](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/OrderMixin#orderfilled) <a href="#orderfilled" id="orderfilled"></a>

```javascript
event OrderFilled(
  address maker,
  bytes32 orderHash,
  uint256 remaining
)
```

Emitted every time order gets filled, including partial fills

**Parameters:**[**​**](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/OrderMixin#parameters-10)

| Name        | Type    | Description |
| ----------- | ------- | ----------- |
| `maker`     | address |             |
| `orderHash` | bytes32 |             |
| `remaining` | uint256 |             |

### OrderCanceled[​](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/OrderMixin#ordercanceled) <a href="#ordercanceled" id="ordercanceled"></a>

```javascript
event OrderCanceled(
  address maker,
  bytes32 orderHash,
  uint256 remainingRaw
)
```

Emitted when order gets cancelled

**Parameters:**[**​**](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/OrderMixin#parameters-11)

| Name           | Type    | Description |
| -------------- | ------- | ----------- |
| `maker`        | address |             |
| `orderHash`    | bytes32 |             |
| `remainingRaw` | uint256 |             |
