Polymarket.Clob.DepositWallet (Polymarket v0.1.1)

Copy Markdown View Source

Derives a wallet's deposit-wallet address — the contract wallet Polymarket trades through on a user's behalf.

Polymarket does not let a bare EOA be an order's maker; orders are made by a deposit wallet deterministically derived from the EOA via CREATE2. Two kinds exist, matching how the account was created:

  • a proxy wallet (EIP-1167 minimal proxy) for Magic/email accounts — signatureType :proxy; and
  • a Gnosis Safe (1-of-1) for browser-wallet accounts — :gnosis_safe.

To place such an order, set the order's maker to the derived address, keep signer as the EOA, and sign with the matching signature_type.

Addresses are derived as keccak256(0xff ‖ factory ‖ salt ‖ initCodeHash)[12..], with the factory contracts and init-code hashes taken from the reference rs-clob-client-v2. Proxy wallets exist only on Polygon; Safe wallets on both Polygon and Amoy.

Summary

Functions

Derives the Polymarket proxy wallet (signatureType :proxy) for eoa on chain_id.

Derives the Polymarket Gnosis Safe wallet (signatureType :gnosis_safe) for eoa on chain_id.

Functions

derive_proxy_wallet(eoa, chain_id)

@spec derive_proxy_wallet(<<_::160>>, integer()) :: {:ok, <<_::160>>} | :error

Derives the Polymarket proxy wallet (signatureType :proxy) for eoa on chain_id.

The CREATE2 salt is keccak256(eoa) (the 20 address bytes, unpadded). Proxy wallets are only deployed on Polygon (137); other chains return :error.

derive_safe_wallet(eoa, chain_id)

@spec derive_safe_wallet(<<_::160>>, integer()) :: {:ok, <<_::160>>} | :error

Derives the Polymarket Gnosis Safe wallet (signatureType :gnosis_safe) for eoa on chain_id.

The CREATE2 salt is keccak256(eoa left-padded to 32 bytes). Safe wallets are configured on Polygon (137) and Amoy (80002); other chains return :error.