Skip to content

getExecutionPrice is synchronous in TS core but async in TS SDK #454

@realfishsam

Description

@realfishsam

Inconsistency

getExecutionPrice is defined as a synchronous method in BaseExchange (it operates only on the provided OrderBook object, making no I/O calls), but the TypeScript SDK wraps it as async, returning a Promise<number>. Callers cannot treat the two implementations uniformly.

Current (PMXT)

Core — core/src/BaseExchange.ts line ~970:

getExecutionPrice(orderBook: OrderBook, side: 'buy' | 'sell', amount: number): number
// ← synchronous, returns number directly

TypeScript SDK — sdks/typescript/pmxt/client.ts line ~2018:

async getExecutionPrice(orderBook: OrderBook, side: 'buy' | 'sell', amount: number): Promise<number>
// ← async, returns Promise<number>

Expected (CCXT convention)

CCXT does not have an getExecutionPrice equivalent, but the CCXT convention is that pure calculation helpers are synchronous. Since getExecutionPrice takes an already-fetched OrderBook as input and performs only arithmetic, there is no reason for it to be async. The SDK should match the core and return number directly.

Impact

Code written against the core that uses const price = exchange.getExecutionPrice(book, 'buy', 10) will break when run against the SDK client, which requires await. The unnecessary Promise wrapping adds overhead and forces callers to use await for a pure computation.


Found by automated PMXT ↔ CCXT API consistency audit

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions