Skip to content

Commit

Permalink
Merge pull request #308 from bnb-chain/wenty/aggregator
Browse files Browse the repository at this point in the history
feat: Add log for token price
  • Loading branch information
wenty22 authored Feb 7, 2025
2 parents 7dd874e + 273b819 commit d06b210
Show file tree
Hide file tree
Showing 9 changed files with 36 additions and 6 deletions.
5 changes: 5 additions & 0 deletions .release/.changeset/large-years-cover.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@bnb-chain/canonical-bridge-widget": patch
---

Fix issues
1 change: 1 addition & 0 deletions .release/.changeset/pre.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"blue-goats-shave",
"brown-suits-matter",
"curvy-dingos-end",
"large-years-cover",
"modern-toys-give",
"short-ants-love",
"smooth-vans-work",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,10 @@ export class TokenService {
tokenAddress,
);

this.logger.log(
`[token price] ${chainId} ${tokenAddress} ${tokenSymbol}, cmc platform: ${cmcPlatform}, llama platform: ${llamaPlatform}`,
);

const reqArr: Promise<any>[] = [];
if (cmcToken) {
reqArr.push(this.web3Service.getCryptoCurrencyQuotes(cmcToken.id.toString()));
Expand All @@ -187,12 +191,14 @@ export class TokenService {
const [cmcRes, llamaRes] = await Promise.allSettled(reqArr);
if (cmcRes.status === 'fulfilled') {
const price = cmcRes.value?.[0]?.quote?.USD?.price;
this.logger.log(`[cmc price] ${price}`);
if (price !== undefined) {
return Number(price);
}
}
if (llamaRes.status === 'fulfilled' && llamaRes.value?.coins) {
const price = Object.values<ICoinPrice>(llamaRes.value.coins ?? {})?.[0]?.price;
this.logger.log(`[llama price] ${price}`);
if (price !== undefined) {
return Number(price);
}
Expand All @@ -203,6 +209,7 @@ export class TokenService {
const key = `1:${tokenSymbol?.toLowerCase()}`;

const price = cmcPrices?.[key]?.price ?? llamaPrices?.[key]?.price;
this.logger.log(`[cache price] ${price}`);
return price;
}
}
6 changes: 6 additions & 0 deletions packages/canonical-bridge-widget/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @bnb-chain/canonical-bridge-widget

## 0.6.0-alpha.19

### Patch Changes

- d70611c: Fix issues

## 0.6.0-alpha.18

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/canonical-bridge-widget/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@bnb-chain/canonical-bridge-widget",
"version": "0.6.0-alpha.18",
"version": "0.6.0-alpha.19",
"description": "canonical bridge widget",
"author": "bnb-chain",
"private": false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ export function CanonicalBridgeProvider(props: CanonicalBridgeProviderProps) {
brandChains: [],
externalChains: [],

dollarUpperLimit: 500000,
dollarUpperLimit: 200000,

chainOrders: [],
tokenOrders: [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
setFromChain,
setSelectedToken,
setSendValue,
setToAccount,
setToChain,
setToToken,
setToTokens,
Expand Down Expand Up @@ -206,6 +207,7 @@ export function useSelection() {

const exchange = async () => {
dispatch(setSendValue(''));
dispatch(setToAccount({ address: '' }));

const fromChainId = toChain!.id;
const toChainId = fromChain!.id;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ import { MIN_SOL_TO_ENABLED_TX } from '@/core/constants';
import { FailedToGetQuoteModal } from '@/modules/transfer/components/Modal/FailedToGetQuoteModal';
import { FeeTimeoutModal } from '@/modules/transfer/components/Modal/FeeTimeoutModal';
import { useFailGetQuoteModal } from '@/modules/transfer/hooks/modal/useFailGetQuoteModal';
import { useAppSelector } from '@/modules/store/StoreProvider';
import { useAppDispatch, useAppSelector } from '@/modules/store/StoreProvider';
import { useSummaryModal } from '@/modules/transfer/hooks/modal/useSummaryModal';
import { useFeeLoadTimeout } from '@/modules/transfer/hooks/modal/useFeeLoadTimeout';
import { setSendValue } from '@/modules/transfer/action';

export const TransferButtonGroup = () => {
const [hash, setHash] = useState<string | null>(null);
Expand All @@ -28,6 +29,8 @@ export const TransferButtonGroup = () => {
const isFeeTimeoutModalOpen = useAppSelector((state) => state.transfer.isFeeTimeoutModalOpen);
const isSummaryModalOpen = useAppSelector((state) => state.transfer.isSummaryModalOpen);

const dispatch = useAppDispatch();

const {
isOpen: isSubmittedModalOpen,
onOpen: onOpenSubmittedModal,
Expand Down Expand Up @@ -103,7 +106,13 @@ export const TransferButtonGroup = () => {
isOpen={isFailedGetQuoteModalOpen}
onClose={onCloseFailedGetQuoteModal}
/>
<FeeTimeoutModal isOpen={isFeeTimeoutModalOpen} onClose={onCloseFeeTimeoutModal} />
<FeeTimeoutModal
isOpen={isFeeTimeoutModalOpen}
onClose={() => {
dispatch(setSendValue(''));
onCloseFeeTimeoutModal();
}}
/>
</>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@ export const useInputValidation = () => {
};
}

if (priceInfo?.upperLimit && Number(value) >= Number(priceInfo?.upperLimit)) {
if (priceInfo?.upperLimit && Number(value) > Number(priceInfo?.upperLimit)) {
return {
text: `Transfer value over $${formatNumber(dollarUpperLimit)} (${formatNumber(
priceInfo.upperLimit,
)} ${selectedToken?.symbol}) or equivalent is not allowed`,
)} ${selectedToken?.symbol}) is not allowed`,
isError: true,
};
}
Expand Down

0 comments on commit d06b210

Please sign in to comment.