Skip to content

Commit

Permalink
fix: EUROC to EURC renaming on Coinbase (#254)
Browse files Browse the repository at this point in the history
  • Loading branch information
philbow61 authored Jun 25, 2024
1 parent 6477e88 commit f0d9f51
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/exchange_adapters/coinbase.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { BaseExchangeAdapter, ExchangeAdapter, ExchangeDataType, Ticker } from './base'
import { Currency, Exchange } from '../utils'
import { Currency, Exchange, ExternalCurrency } from '../utils'

import { CeloContract } from '@celo/contractkit'

Expand All @@ -12,12 +12,12 @@ export class CoinbaseAdapter extends BaseExchangeAdapter implements ExchangeAdap
readonly _exchangeName = Exchange.COINBASE

/**
* Coinbase is currently using `CGLD` as the symbol for CELO. This is likely
* to be changed at some point after listing.
* Coinbase is currently using `CGLD` as the symbol for CELO and `EURC` as the symbol for EUROC.
*/
private static readonly tokenSymbolMap = new Map<Currency, string>([
...CoinbaseAdapter.standardTokenSymbolMap,
[CeloContract.GoldToken, 'CGLD'],
[ExternalCurrency.EUROC, 'EURC'],
])

protected generatePairSymbol(): string {
Expand Down
23 changes: 23 additions & 0 deletions test/exchange_adapters/coinbase.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,29 @@ describe('CoinbaseAdapter', () => {
})
})

describe('using the non-standard symbol for EUROC', () => {
let coinbaseAdapter2: CoinbaseAdapter
const config2: ExchangeAdapterConfig = {
baseCurrency: ExternalCurrency.EUROC,
baseLogger,
quoteCurrency: ExternalCurrency.USD,
}

let fetchFromApiSpy: jest.SpyInstance
beforeEach(() => {
coinbaseAdapter2 = new CoinbaseAdapter(config2)
fetchFromApiSpy = jest.spyOn(coinbaseAdapter2, 'fetchFromApi')
})
it('uses the right symbols when fetching the ticker', async () => {
fetchFromApiSpy.mockReturnValue(Promise.resolve(mockTickerJson))
await coinbaseAdapter2.fetchTicker()
expect(fetchFromApiSpy).toHaveBeenCalledWith(
ExchangeDataType.TICKER,
'products/EURC-USD/ticker'
)
})
})

describe('parseTicker', () => {
it('handles a response that matches the documentation', () => {
const ticker = coinbaseAdapter.parseTicker(mockTickerJson)
Expand Down

0 comments on commit f0d9f51

Please sign in to comment.