-
Notifications
You must be signed in to change notification settings - Fork 7
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
1efab18
commit 684f2bb
Showing
8 changed files
with
79 additions
and
0 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
17 changes: 17 additions & 0 deletions
17
packages/shared/src/lib/auxiliary/transak/actions/getTransakPrice.ts
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,17 @@ | ||
import { TransakApi } from '../apis' | ||
import { ITransakApiPriceParams } from '../interfaces' | ||
|
||
export async function getTransakPrice( | ||
params: ITransakApiPriceParams | ||
): Promise<{ fiatAmount: number; cryptoAmount: number } | undefined> { | ||
const transakApi = new TransakApi() | ||
const { response } = (await transakApi.getPrices(params)) ?? {} | ||
|
||
if (!response) { | ||
return | ||
} | ||
|
||
const { cryptoAmount, fiatAmount } = response | ||
|
||
return { fiatAmount, cryptoAmount } | ||
} |
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,2 +1,3 @@ | ||
export * from './getTransakPrice' | ||
export * from './updateTransakCryptoCurrencies' | ||
export * from './updateTransakFiatCurrencies' |
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
1 change: 1 addition & 0 deletions
1
packages/shared/src/lib/auxiliary/transak/enums/transak-api-endpoint.enum.ts
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,4 +1,5 @@ | ||
export enum TransakApiEndpoint { | ||
CryptoCurrencies = 'api/v2/currencies/crypto-currencies', | ||
FiatCurrencies = 'fiat/public/v1/currencies/fiat-currencies', | ||
Price = 'api/v1/pricing/public/quotes', | ||
} |
2 changes: 2 additions & 0 deletions
2
packages/shared/src/lib/auxiliary/transak/interfaces/index.ts
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,2 +1,4 @@ | ||
export * from './transak-api-crypto-currencies-response.interface' | ||
export * from './transak-api-fiat-currencies-response.interface' | ||
export * from './transak-api-price-params.interface' | ||
export * from './transak-api-price-response.interface' |
10 changes: 10 additions & 0 deletions
10
packages/shared/src/lib/auxiliary/transak/interfaces/transak-api-price-params.interface.ts
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,10 @@ | ||
import { FiatCurrency } from '@core/market/enums' | ||
|
||
export interface ITransakApiPriceParams { | ||
fiatCurrency: keyof typeof FiatCurrency | ||
cryptoCurrency: string | ||
isBuyOrSell: 'BUY' | 'SELL' | ||
networkName: string | ||
paymentMethod: string | ||
fiatAmount: number | ||
} |
30 changes: 30 additions & 0 deletions
30
packages/shared/src/lib/auxiliary/transak/interfaces/transak-api-price-response.interface.ts
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,30 @@ | ||
interface ITransakApiPriceResponseFeeBreakdown { | ||
name: string | ||
value: number | ||
id: string | ||
ids: string[] | ||
} | ||
|
||
interface ITransakApiPriceResponseContent { | ||
quoteId: string | ||
conversionPrice: number | ||
marketConversionPrice: number | ||
slippage: number | ||
fiatCurrency: string | ||
cryptoCurrency: string | ||
paymentMethod: string | ||
fiatAmount: number | ||
cryptoAmount: number | ||
isBuyOrSell: 'BUY' | 'SELL' | ||
network: string | ||
feeDecimal: number | ||
totalFee: number | ||
feeBreakdown: ITransakApiPriceResponseFeeBreakdown[] | ||
nonce: number | ||
cryptoLiquidityProvider: string | ||
notes: string[] | ||
} | ||
|
||
export interface ITransakApiPriceResponse { | ||
response: ITransakApiPriceResponseContent | ||
} |