Skip to main content

Crate px_exchange_polymarket

Crate px_exchange_polymarket 

Source

Re-exports§

pub use signer::ExternalSigner;

Modules§

IERC20
Module containing a contract’s types and functions.
IERC20Balance
Module containing a contract’s types and functions.
IERC1155
Module containing a contract’s types and functions.
IGnosisSafe
Module containing a contract’s types and functions.
INativeUSDC
Module containing a contract’s types and functions.
ISwapERC20
Module containing a contract’s types and functions.
ISwapRouter
Module containing a contract’s types and functions.
ctf
CTF (Conditional Token Framework) calldata encoding for on-chain operations.
relayer
Gasless relayer client for Polymarket CTF operations.
signer

Structs§

AllowanceStatus
Status of a single allowance check
ApiCredentials
ApprovalRequest
Request for setting approvals
ApprovalResponse
Response from approval operations
ApprovalResult
Result of a single approval transaction
AuthConfig
Configuration for Polymarket authentication
BalanceAllowance
ClobOrderData
DetectedWallet
Result of auto-detecting the proxy wallet type from an EOA private key.
HttpClient
OrderArgs
OrderResponse
Polymarket
PolymarketConfig
PolymarketMarketFetcher
Market fetcher for Polymarket Bronze layer ingestion.
PolymarketWebSocket
SwapResult
Result of the native USDC → USDC.e swap attempt.
TokenApprover
Token approver for Polymarket contracts
WalletDiagnostics

Enums§

ApprovalTarget
Target contract for approval
ClobOrderSide
ClobOrderType
PolymarketError
PolymarketSignatureType
TokenType
Token type for approval

Constants§

BRIDGED_USDC_E_ADDRESS
Bridged USDC.e on Polygon (input to CollateralOnramp.wrap() in V2)
CLOB_API_URL
CLOB_URL
COLLATERAL_ONRAMP
CollateralOnramp — wraps USDC.e into pUSD (V2 trading collateral). API-only flow: approve USDC.e to this address, then call wrap(amount). Source: https://docs.polymarket.com/resources/contracts
CTF_ADDRESS
CTF_EXCHANGE
DATA_API_URL
DEFAULT_POLYGON_RPC
GAMMA_API_URL
MAX_APPROVAL
MIN_SWAP_BALANCE
Minimum balance to trigger swap (0.01 USDC = 10_000 units at 6 decimals)
NATIVE_USDC_ADDRESS
Native USDC on Polygon (what MetaMask shows as “USDC”)
NEG_RISK_ADAPTER
NEG_RISK_CTF_EXCHANGE
PUSD_ADDRESS
SLIPPAGE_BPS
Slippage tolerance: 0.5% for a 1:1 stablecoin peg

Functions§

check_erc20_balance
Check any ERC20 token balance for an address. Returns 0 on any error (fail-silent).
check_native_usdc_balance
Check native USDC balance for an address. Returns 0 on any error (fail-silent).
check_pol_balance
Check native POL (MATIC) balance for an address. Returns 0 on any error (fail-silent).
compute_swap_amounts
Compute the swap amount and min_out from a raw native USDC balance. Returns (amount_in, min_out) as (u128, u128) to avoid leaking alloy types.
detect_proxy_wallet
Auto-detect the Polymarket proxy wallet from an EOA private key.
detect_signature_type_from_env
Detect signature type from environment variables
diagnose_wallets
Diagnose potential Polymarket wallet mismatches.
encode_approval_calldata
Build ABI-encoded calldata for an approval pair. Returns (to_address, hex_calldata). Used by the link handler to build transactions for Privy-managed wallets.
encode_native_usdc_approval
Encode approve(router, amount) on native USDC. Returns (to, calldata).
encode_native_usdc_approval_u128
Convenience wrapper: encode approval from a u128 amount.
encode_swap_calldata
Encode Uniswap V3 exactInputSingle call. Returns (to, calldata).
encode_swap_calldata_u128
Convenience wrapper: encode swap calldata from u128 amounts.
encode_usdc_approval
Encode USDC ERC-20 approve(spender, MAX) for an arbitrary address. Used to approve the fee escrow contract during onboarding.
format_token_balance
Format a raw token balance as a human-readable string (e.g., 2000000 with 6 decimals → “2.00”).
get_orderbook_snapshot