Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion sdks/typescript/pmxt/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,9 @@ export interface ExchangeOptions {
/** Venue-specific API key (e.g. Polymarket CLOB key). Optional. */
apiKey?: string;

/** Venue-specific API secret for HMAC/CLOB-authenticated exchanges. Optional. */
apiSecret?: string;

/** Venue-specific private key. Optional. */
privateKey?: string;

Expand Down Expand Up @@ -320,6 +323,7 @@ export abstract class Exchange {
public exchangeName: string;
public pmxtApiKey?: string;
protected apiKey?: string;
protected apiSecret?: string;
protected privateKey?: string;
protected proxyAddress?: string;
protected signatureType?: number;
Expand Down Expand Up @@ -357,6 +361,7 @@ export abstract class Exchange {
constructor(exchangeName: string, options: ExchangeOptions = {}) {
this.exchangeName = exchangeName.toLowerCase();
this.apiKey = options.apiKey;
this.apiSecret = options.apiSecret;
this.privateKey = options.privateKey;
this.proxyAddress = options.proxyAddress;
this.signatureType = options.signatureType;
Expand Down Expand Up @@ -462,11 +467,12 @@ export abstract class Exchange {
}

protected getCredentials(): ExchangeCredentials | undefined {
if (!this.apiKey && !this.privateKey) {
if (!this.apiKey && !this.apiSecret && !this.privateKey) {
return undefined;
}
return {
apiKey: this.apiKey,
apiSecret: this.apiSecret,
privateKey: this.privateKey,
funderAddress: this.proxyAddress,
signatureType: this.signatureType,
Expand Down
26 changes: 26 additions & 0 deletions sdks/typescript/tests/exchange-credentials.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { Exchange, ExchangeOptions } from "../pmxt/client";

class TestExchange extends Exchange {
public exposedCredentials() {
return this.getCredentials();
}
}

describe("exchange credentials", () => {
it("accepts and forwards apiSecret with sidecar credentials", () => {
const options = {
apiKey: "api-key",
apiSecret: "api-secret",
privateKey: "private-key",
autoStartServer: false,
} satisfies ExchangeOptions;

const exchange = new TestExchange("polymarket", options);

expect(exchange.exposedCredentials()).toMatchObject({
apiKey: "api-key",
apiSecret: "api-secret",
privateKey: "private-key",
});
});
});
Loading