-
Notifications
You must be signed in to change notification settings - Fork 145
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: brc-20 token balances as fiat, #4408
- Loading branch information
Showing
28 changed files
with
161 additions
and
121 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
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,30 +1,17 @@ | ||
import { useCallback, useMemo } from 'react'; | ||
import { useCallback } from 'react'; | ||
|
||
import { CryptoCurrencies } from '@shared/models/currencies.model'; | ||
import { createMarketData, createMarketPair } from '@shared/models/market.model'; | ||
import type { Money } from '@shared/models/money.model'; | ||
import { type Money } from '@shared/models/money.model'; | ||
|
||
import { useCryptoCurrencyMarketData } from '@app/query/common/market-data/market-data.hooks'; | ||
import { useCryptoCurrencyMarketDataMeanAverage } from '@app/query/common/market-data/market-data.hooks'; | ||
|
||
import { baseCurrencyAmountInQuote } from '../money/calculate-money'; | ||
|
||
export function useConvertCryptoCurrencyToFiatAmount(currency: CryptoCurrencies) { | ||
const cryptoCurrencyMarketData = useCryptoCurrencyMarketData(currency); | ||
const cryptoCurrencyMarketData = useCryptoCurrencyMarketDataMeanAverage(currency); | ||
|
||
return useCallback( | ||
(value: Money) => baseCurrencyAmountInQuote(value, cryptoCurrencyMarketData), | ||
[cryptoCurrencyMarketData] | ||
); | ||
} | ||
|
||
export function useConvertAlexSdkCurrencyToFiatAmount(currency: CryptoCurrencies, price: Money) { | ||
const alexCurrencyMarketData = useMemo( | ||
() => createMarketData(createMarketPair(currency, 'USD'), price), | ||
[currency, price] | ||
); | ||
|
||
return useCallback( | ||
(value: Money) => baseCurrencyAmountInQuote(value, alexCurrencyMarketData), | ||
[alexCurrencyMarketData] | ||
); | ||
} |
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,18 @@ | ||
import type { CryptoCurrencies } from '@shared/models/currencies.model'; | ||
import { createMarketData, createMarketPair } from '@shared/models/market.model'; | ||
import { type Money } from '@shared/models/money.model'; | ||
|
||
import { baseCurrencyAmountInQuote } from './calculate-money'; | ||
|
||
export function checkIsMoneyAmountGreaterThanZero(money: Money) { | ||
return !(money.amount.isNaN() || money.amount.isZero()); | ||
} | ||
|
||
export function convertCryptoCurrencyMoneyToFiat( | ||
currency: CryptoCurrencies, | ||
price: Money, | ||
money: Money | ||
) { | ||
const cryptoCurrencyMarketData = createMarketData(createMarketPair(currency, 'USD'), price); | ||
return baseCurrencyAmountInQuote(money, cryptoCurrencyMarketData); | ||
} |
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
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
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
Oops, something went wrong.