Skip to content

Commit

Permalink
feat: add usdc
Browse files Browse the repository at this point in the history
  • Loading branch information
perfogic committed Sep 6, 2024
1 parent ba3b615 commit e3fc53a
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 4 deletions.
19 changes: 17 additions & 2 deletions components/page/bridge/hooks/useGetFee.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { useAuthOraiAddress } from "@/stores/authentication/selector";
import { BigDecimal } from "@oraichain/oraidex-common";
import { TonbridgeBridgeClient } from "@oraichain/tonbridge-contracts-sdk";
import { useEffect, useState } from "react";
import { MappingJettonWalletAddress } from "@/constants/contract";

const useGetFee = ({ token }: { token: TokenType }) => {
const oraiAddress = useAuthOraiAddress();
Expand All @@ -29,8 +30,22 @@ const useGetFee = ({ token }: { token: TokenType }) => {
network.CW_TON_BRIDGE
);

// TODO: change to jetton wallet address of bridge adapter instead

console.log(
MappingJettonWalletAddress[tokenInTon?.contractAddress] ==
"EQAacZPtQpnIHS1PlQgVaceb_I4v2HE3rvrZC91ynSRqXd9d"
);
if (
MappingJettonWalletAddress[tokenInTon?.contractAddress] ==
"EQAacZPtQpnIHS1PlQgVaceb_I4v2HE3rvrZC91ynSRqXd9d"
) {
setTokenFee(15);
return;
}
const tokenFeeConfig = await tonBridgeClient.tokenFee({
remoteTokenDenom: tokenInTon?.contractAddress,
remoteTokenDenom:
MappingJettonWalletAddress[tokenInTon?.contractAddress],
});

if (tokenFeeConfig) {
Expand Down Expand Up @@ -71,7 +86,7 @@ const useGetFee = ({ token }: { token: TokenType }) => {
);

const config = await tonBridgeClient.pairMapping({
key: tokenInTon?.contractAddress,
key: MappingJettonWalletAddress[tokenInTon?.contractAddress],
});
const pairMapping = config.pair_mapping;

Expand Down
11 changes: 11 additions & 0 deletions constants/contract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,32 @@ export const TonInteractionContract = {
export const TonTokensContract = {
[Environment.Mainnet]: {
usdt: "EQCxE6mUtQJKFnGfaROTKOt1lZbDiiX1kCixRv7Nw2Id_sDs",
jUSDC: "EQB-MPwrd1G6WKNkLz_VnV6WqBDd142KMQv-g1O-8QUA3728",
// jUSDT: "EQBynBO23ywHy_CgarY9NK9FTz0yDsG82PtcbSTQgGoXwiuA",
ton: TON_ZERO_ADDRESS,
},
[Environment.Staging]: {
usdt: "EQCxE6mUtQJKFnGfaROTKOt1lZbDiiX1kCixRv7Nw2Id_sDs",
jUSDT: "EQBynBO23ywHy_CgarY9NK9FTz0yDsG82PtcbSTQgGoXwiuA",
jUSDC: "EQB-MPwrd1G6WKNkLz_VnV6WqBDd142KMQv-g1O-8QUA3728",
ton: TON_ZERO_ADDRESS,
},
[Environment.Testnet]: {
usdt: "EQA5FnPP13uZPJQq7aj6UHLEukJJZSZW053cU1Wu6R6BpYYB",
jUSDT: "EQA5FnPP13uZPJQq7aj6UHLEukJJZSZW053cU1Wu6R6BpYYB",
jUSDC: "EQB-MPwrd1G6WKNkLz_VnV6WqBDd142KMQv-g1O-8QUA3728",
ton: TON_ZERO_ADDRESS,
},
};

export const MappingJettonWalletAddress = {
"EQB-MPwrd1G6WKNkLz_VnV6WqBDd142KMQv-g1O-8QUA3728":
"EQAacZPtQpnIHS1PlQgVaceb_I4v2HE3rvrZC91ynSRqXd9d",
EQCxE6mUtQJKFnGfaROTKOt1lZbDiiX1kCixRv7Nw2Id_sDs:
"EQCxE6mUtQJKFnGfaROTKOt1lZbDiiX1kCixRv7Nw2Id_sDs",
EQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAM9c: TON_ZERO_ADDRESS,
};

export const CwInteractionContract = {
[Environment.Mainnet]: {
cosmwasmBridge:
Expand Down
23 changes: 21 additions & 2 deletions constants/tokens.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Environment } from "./ton";
import { TonTokensContract } from "./contract";
import { UsdtIcon, TetherIcon } from "@/assets/icons/token";
import { USDT_CONTRACT } from "@oraichain/oraidex-common";
import { UsdtIcon, TetherIcon, UsdcIcon } from "@/assets/icons/token";
import { USDC_CONTRACT, USDT_CONTRACT } from "@oraichain/oraidex-common";
import { TonNetworkICon } from "@/assets/icons/network";

export type TokenType = {
Expand All @@ -28,6 +28,16 @@ export const OraichainTokenList: TokenType[] = [
coingeckoId: "tether",
decimal: 6,
},
{
chainId: "Oraichain",
name: "USD Coin",
symbol: "USDC",
Icon: UsdcIcon,
contractAddress: USDC_CONTRACT,
denom: "usdc",
coingeckoId: "bridged-usd-coin-ton-bridge",
decimal: 6,
},
// {
// chainId: "Oraichain",
// name: "Tether",
Expand Down Expand Up @@ -82,6 +92,15 @@ export const TonTokenList = (network: Environment): TokenType[] => [
coingeckoId: "tether",
decimal: 6,
},
{
name: "USD Coin",
symbol: "USDC",
Icon: UsdcIcon,
contractAddress: TonTokensContract[network]?.jUSDC,
denom: "ton20_usdc",
coingeckoId: "bridged-usd-coin-ton-bridge",
decimal: 6,
},
// {
// name: "Jetton USDT",
// symbol: "jUSDT",
Expand Down
3 changes: 3 additions & 0 deletions hooks/useLoadToken.ts
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,9 @@ export const useLoadTonBalance = ({
const token = TonTokenList(tonNetwork).find(
(e) => e.contractAddress === data.token
);
console.log({
data: data,
});

amountDetail = {
...amountDetail,
Expand Down

0 comments on commit e3fc53a

Please sign in to comment.