diff --git a/components/page/bridge/hooks/useGetFee.ts b/components/page/bridge/hooks/useGetFee.ts index e064e0e..350a39f 100644 --- a/components/page/bridge/hooks/useGetFee.ts +++ b/components/page/bridge/hooks/useGetFee.ts @@ -55,20 +55,31 @@ const useGetFee = ({ token }: { token: TokenType }) => { useEffect(() => { (async () => { - const tonBridgeClient = new TonbridgeBridgeClient( - window.client, - oraiAddress, - network.CW_TON_BRIDGE - ); + if (token) { + const tokenInTon = TonTokenList(TonNetwork.Mainnet).find( + (tk) => tk.coingeckoId === token.coingeckoId + ); + if (!tokenInTon) { + return; + } + + const tonBridgeClient = new TonbridgeBridgeClient( + window.client, + oraiAddress, + network.CW_TON_BRIDGE + ); - const config = await tonBridgeClient.config(); - if (config) { - const { relayer_fee } = config; + const config = await tonBridgeClient.pairMapping({ + key: tokenInTon?.contractAddress, + }); + const pairMapping = config.pair_mapping; - setBridgeFee(toDisplay(relayer_fee)); + setBridgeFee( + parseInt(pairMapping.relayer_fee) / 10 ** pairMapping.remote_decimals + ); } })(); - }, []); + }, [token, oraiAddress]); return { bridgeFee, diff --git a/components/page/bridge/index.tsx b/components/page/bridge/index.tsx index a626895..1a7bbb3 100644 --- a/components/page/bridge/index.tsx +++ b/components/page/bridge/index.tsx @@ -96,6 +96,7 @@ const Bridge = () => { ? oraiAddress || "" : tonAddress || ""; + console.log("Read token:", { token }); const { bridgeFee, tokenFee } = useGetFee({ token, }); @@ -618,7 +619,7 @@ const Bridge = () => { {numberWithCommas(bridgeFee || 0, undefined, { maximumFractionDigits: CW20_DECIMALS, })}{" "} - ORAI + {token?.symbol}