Skip to content
Closed
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
4 changes: 2 additions & 2 deletions src/integration/exchange/services/exchange.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export abstract class ExchangeService extends PricingProvider implements OnModul
protected abstract readonly networks: { [b in Blockchain]: string | false };
protected readonly exchange: Exchange;

private markets: Market[];
protected markets: Market[];

@Inject() private readonly registry: ExchangeRegistryService;

Expand Down Expand Up @@ -225,7 +225,7 @@ export abstract class ExchangeService extends PricingProvider implements OnModul

// --- Helper Methods --- //
// currency pairs
private async getMarkets(): Promise<Market[]> {
protected async getMarkets(): Promise<Market[]> {
if (!this.markets) {
this.markets = await this.callApi((e) => e.fetchMarkets());
}
Expand Down
53 changes: 52 additions & 1 deletion src/integration/exchange/services/mexc.service.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Injectable } from '@nestjs/common';
import { Method } from 'axios';
import { mexc, Transaction } from 'ccxt';
import { Market, mexc, Transaction } from 'ccxt';
import { Config, GetConfig } from 'src/config/config';
import { Blockchain } from 'src/integration/blockchain/shared/enums/blockchain.enum';
import { DfxLogger } from 'src/shared/services/dfx-logger';
Expand Down Expand Up @@ -49,6 +49,33 @@ export class MexcService extends ExchangeService {
Yapeal: undefined,
};

// Assessment Zone pairs - require API whitelisting from MEXC
// See: https://www.mexc.com/announcements/article/api-access-changes-for-assessment-zone-trading-pairs-17827791522788
private readonly assessmentZonePairs: Partial<Market>[] = [
{
id: 'ZCHFUSDT',
symbol: 'ZCHF/USDT',
base: 'ZCHF',
quote: 'USDT',
baseId: 'ZCHF',
quoteId: 'USDT',
active: true,
type: 'spot',
spot: true,
margin: false,
future: false,
swap: false,
option: false,
contract: false,
limits: {
amount: { min: 1, max: undefined },
price: { min: 0.0001, max: undefined },
cost: { min: 1, max: undefined },
},
precision: { amount: 2, price: 4 },
},
];

constructor(private readonly http: HttpService) {
super(mexc, GetConfig().mexc);
}
Expand All @@ -59,6 +86,30 @@ export class MexcService extends ExchangeService {
return 'MEXC';
}

protected async getMarkets(): Promise<Market[]> {
const markets = await super.getMarkets();

// Inject Assessment Zone pairs that are hidden from public API
for (const azPair of this.assessmentZonePairs) {
if (!markets.find((m) => m.symbol === azPair.symbol)) {
markets.push(azPair as Market);

// Also inject into ccxt's internal caches for methods like fetchOrderBook/createOrder
if (this.exchange.markets && !this.exchange.markets[azPair.symbol]) {
this.exchange.markets[azPair.symbol] = azPair as Market;
}
if (this.exchange.markets_by_id && azPair.id && !this.exchange.markets_by_id[azPair.id]) {
this.exchange.markets_by_id[azPair.id] = azPair as Market;
}
if (this.exchange.symbols && !this.exchange.symbols.includes(azPair.symbol)) {
this.exchange.symbols.push(azPair.symbol);
}
}
}

return markets;
}

async getDeposits(token: string, from: Date): Promise<Transaction[]> {
const startTime = from.getTime().toString();
const endTime = new Date().getTime().toString();
Expand Down
Loading