( creds: L2Creds, proxyAddress: string, signerAddress: string )
| 113 | * proxyAddress: the Polymarket proxy wallet address (used as POLY_ADDRESS header). |
| 114 | */ |
| 115 | export 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. |
no test coverage detected