Documentation Index
Fetch the complete documentation index at: https://mintlify.com/Polymarket/ctf-exchange/llms.txt
Use this file to discover all available pages before exploring further.
Overview
TheSignatures mixin provides comprehensive signature validation for orders. It supports multiple signature types to accommodate different wallet architectures used on Polymarket, including EOA wallets, Polymarket Proxy wallets, Polymarket Gnosis Safes, and EIP-1271 compatible smart contracts.
Source: src/exchange/mixins/Signatures.sol
Supported Signature Types
The CTF Exchange supports four distinct signature types:- EOA: ECDSA EIP712 signatures signed by externally owned accounts
- POLY_PROXY: EIP712 signatures signed by EOAs that own Polymarket Proxy wallets
- POLY_GNOSIS_SAFE: EIP712 signatures signed by EOAs that own Polymarket Gnosis Safes
- POLY_1271: Signatures from EIP-1271 compatible smart contracts
Constructor
PolyFactoryHelper constructor with factory addresses.
Parameters
_proxyFactory(address): The address of the Polymarket proxy factory_safeFactory(address): The address of the Polymarket Gnosis Safe factory
Functions
validateOrderSignature
isValidSignature and reverts if the signature is invalid.
Parameters
orderHash(bytes32): The hash of the orderorder(Order): The order object containing the signature and signature type
Reverts
InvalidSignature()if the signature validation fails
isValidSignature
Parameters
signer(address): Address of the signerassociated(address): Address associated with the signer- For
EOA: Must be the same as the signer address - For
POLY_PROXYandPOLY_GNOSIS_SAFE: The address of the proxy or safe - For
POLY_1271: The address of the smart contract
- For
structHash(bytes32): The hash of the struct being verifiedsignature(bytes): The signature to be verifiedsignatureType(SignatureType): The type of signature
Returns
bool:trueif the signature is valid,falseotherwise
verifyEOASignature
Verification Checks
- The signature is a valid ECDSA signature
- The signer and maker addresses are the same
Parameters
signer(address): The address of the signermaker(address): The address of the makerstructHash(bytes32): The hash of the struct being verifiedsignature(bytes): The signature to be verified
Returns
bool:trueif valid,falseotherwise
verifyECDSASignature
Parameters
signer(address): The expected signer addressstructHash(bytes32): The hash of the struct being verifiedsignature(bytes): The signature to be verified
Returns
bool:trueif the recovered signer matches the expected signer
verifyPolyProxySignature
Verification Checks
- The ECDSA signature is valid
- The proxy wallet is owned by the signer
Parameters
signer(address): Address of the signerproxyWallet(address): Address of the Polymarket proxy walletstructHash(bytes32): Hash of the struct being verifiedsignature(bytes): Signature to be verified
Returns
bool:trueif valid,falseotherwise
verifyPolySafeSignature
Verification Checks
- The ECDSA signature is valid
- The Safe is owned by the signer
Parameters
signer(address): Address of the signersafeAddress(address): Address of the Gnosis Safehash(bytes32): Hash of the struct being verifiedsignature(bytes): Signature to be verified
Returns
bool:trueif valid,falseotherwise
verifyPoly1271Signature
Verification Checks
- The signer and maker addresses are the same
- The maker address has contract code deployed
- The contract’s
isValidSignaturefunction returns success
Parameters
signer(address): Address of the smart contract signermaker(address): Address of the smart contract makerhash(bytes32): Hash of the struct being verifiedsignature(bytes): Signature to be verified
Returns
bool:trueif valid,falseotherwise
Errors
InvalidSignature
Implementation Details
The signature validation flow:validateOrderSignatureis called with an order hash and order- It calls
isValidSignaturewith the order’s signature details isValidSignatureroutes to the appropriate verification function based onsignatureType- The specific verification function performs validation checks and returns a boolean
- If validation fails,
InvalidSignature()error is thrown