MCPcopy Create free account
hub / github.com/AmazingAng/PolyWorld / createAuthenticatedClient

Function createAuthenticatedClient

src/lib/polymarketCLOB.ts:115–145  ·  view source on GitHub ↗
(
  creds: L2Creds,
  proxyAddress: string,
  signerAddress: string
)

Source from the content-addressed store, hash-verified

113 * proxyAddress: the Polymarket proxy wallet address (used as POLY_ADDRESS header).
114 */
115export function createAuthenticatedClient(
116 creds: L2Creds,
117 proxyAddress: string,
118 signerAddress: string
119): ClobClient {
120 // POLY_ADDRESS in L2 HMAC headers must match the address used to derive the API key (EOA).
121 // proxyAddress goes only as funderAddress (6th param) so orders use proxy as maker.
122 const stub = {
123 address: signerAddress,
124 getAddress: async () => signerAddress,
125 _signTypedData: async () => { throw new Error("L1 sign not available"); },
126 };
127 return new ClobClient(
128 CLOB_HOST,
129 CHAIN_ID,
130 // eslint-disable-next-line @typescript-eslint/no-explicit-any
131 stub as any,
132 {
133 key: creds.apiKey,
134 secret: creds.secret,
135 passphrase: creds.passphrase,
136 },
137 signerAddress.toLowerCase() === proxyAddress.toLowerCase()
138 ? SignatureType.EOA
139 : SignatureType.POLY_GNOSIS_SAFE,
140 proxyAddress, // funderAddress: order maker = proxy wallet
141 undefined,
142 false,
143 getBuilderConfig(),
144 );
145}
146
147/**
148 * Cancel an open order.

Callers 5

POSTFunction · 0.90
DELETEFunction · 0.90
cancelOrderFunction · 0.85
getOpenOrdersFunction · 0.85
getBalanceFunction · 0.85

Calls 1

getBuilderConfigFunction · 0.85

Tested by

no test coverage detected