Skip to main content
Execute an atomic swap between option tokens and USDC on the ConvallaxRFQSettlement contract. The taker calls this function with the signed Order and makerSignature received from POST /execute. Contract: ConvallaxRFQSettlement0xC6Eb814Cc01189e20B2DB2D2a22Ed2DcAC404992

Function Signature

function fill(Order calldata order, bytes calldata makerSignature) external

Parameters

order
Order
required
The EIP-712 Order struct signed by the market maker.
makerSignature
bytes
required
EIP-712 signature from the maker over the Order struct.

Behavior

makerSellingOptions flowUSDC flow
trueMaker → TakerTaker → Maker
falseTaker → MakerMaker → Taker
The swap is atomic — both transfers execute in a single transaction or the entire call reverts. The nonce is consumed to prevent replay.

Prerequisites

Before calling fill(), ensure:
  1. USDC approval — The paying party must have approved ConvallaxRFQSettlement to spend their USDC
  2. ERC-1155 approval — The party sending options must have called setApprovalForAll on ConvallaxOptionToken for ConvallaxRFQSettlement
  3. Sufficient balances — Both parties must hold the required token amounts

Example

import { ethers } from 'ethers';

const settlement = new ethers.Contract(
  '0xC6Eb814Cc01189e20B2DB2D2a22Ed2DcAC404992',
  ['function fill(tuple(address maker, uint256 seriesId, uint256 optionAmount, uint256 premiumAmount, bool makerSelling, address taker, uint256 validUntil, uint256 nonce) order, bytes makerSignature) external'],
  signer
);

// order and makerSignature from POST /execute response
const tx = await settlement.fill(order, makerSignature);
await tx.wait();

Nonce Cancellation

Makers can pre-emptively cancel a nonce to prevent a pending order from being filled:
function cancelNonce(uint256 nonce) external
This marks the nonce as used, so any order signed with that nonce will revert with NonceAlreadyUsed if someone tries to fill it.

Reverts

ConditionReason
optionAmount or premiumAmount is zeroInvalidAmount
Nonce already used or cancelledNonceAlreadyUsed
block.timestamp > validUntilOrderExpired
Recovered signer ≠ order.makerInvalidSignature
order.takeraddress(0) and ≠ msg.senderInvalidTaker
Insufficient balanceERC-20/ERC-1155 revert