-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c4f0991
commit 416e532
Showing
5 changed files
with
28 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import type BigNumber from 'bignumber.js'; | ||
|
||
import type { Currency } from '../../../common/index'; | ||
import type { ExchangeService } from '../../exchangeService'; | ||
import type { Quote } from '../../models/index'; | ||
import type { RatesProvider } from '../ratesProvider'; | ||
|
||
export class AtomexRatesProvider implements RatesProvider { | ||
constructor( | ||
private readonly exchangeService: ExchangeService | ||
) { } | ||
|
||
async getPrice(quoteCurrency: Currency['id'], baseCurrency: Currency['id']): Promise<BigNumber | undefined> { | ||
const quote = (await this.exchangeService.getTopOfBook([{ from: quoteCurrency, to: baseCurrency }]))?.[0]; | ||
|
||
return quote ? this.getMiddlePrice(quote) : undefined; | ||
} | ||
|
||
private getMiddlePrice(quote: Quote): BigNumber { | ||
return quote.ask.plus(quote.bid).div(2); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { AtomexRatesProvider } from './atomexRatesProvider'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
export type { RatesProvider } from './ratesProvider'; | ||
export type { AggregatedRatesProvider } from './aggregatedRatesProvider'; | ||
export { AtomexRatesProvider } from './atomex/index'; | ||
export { BinanceRatesProvider } from './binance/index'; | ||
export { KrakenRatesProvider } from './kraken/index'; | ||
export { MixedRatesProvider } from './mixedRatesProvider/index'; |