Skip to content

Commit

Permalink
Merge pull request #545 from oraichain/feat/add-erc20-usdt
Browse files Browse the repository at this point in the history
Add erc20 usdt
  • Loading branch information
trung2891 authored Jan 12, 2024
2 parents 33d18c4 + b4bd88f commit f8d28de
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 22 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"@oraichain/kawaiiverse-txs": "^0.0.3",
"@oraichain/oraidex-common-ui": "^1.0.3",
"@oraichain/oraidex-contracts-sdk": "^1.0.26",
"@oraichain/oraidex-universal-swap": "^1.0.48",
"@oraichain/oraidex-universal-swap": "^1.0.49",
"@leapwallet/cosmos-snap-provider": "0.1.25",
"@reduxjs/toolkit": "^1.9.3",
"@sentry/react": "^7.47.0",
Expand Down
24 changes: 22 additions & 2 deletions src/config/chainInfos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ import {
WRAP_BNB_CONTRACT,
WRAP_ETH_CONTRACT,
WRAP_TRON_TRX_CONTRACT,
WETH_CONTRACT
WETH_CONTRACT,
USDT_ETH_CONTRACT
} from '@oraichain/oraidex-common';
import { BridgeAppCurrency, CustomChainInfo, defaultBech32Config } from '@oraichain/oraidex-common';
import { flatten } from 'lodash';
Expand Down Expand Up @@ -330,7 +331,7 @@ export const oraichainNetwork: CustomChainInfo = {
coinMinimalDenom: 'usdt',
type: 'cw20',
contractAddress: USDT_CONTRACT,
bridgeTo: ['0x38', '0x2b6653dc'],
bridgeTo: ['0x38', '0x2b6653dc', '0x01'],
coinDecimals: 6,
Icon: UsdtIcon
},
Expand Down Expand Up @@ -534,6 +535,15 @@ export const chainInfos: CustomChainInfo[] = [
coinGeckoId: 'airight',
Icon: AiriIcon
},
{
coinDenom: 'USDT',
coinMinimalDenom: ORAI_BRIDGE_EVM_ETH_DENOM_PREFIX + USDT_ETH_CONTRACT,
bridgeNetworkIdentifier: '0x01',
coinDecimals: 6,
coinGeckoId: 'tether',
prefixToken: ORAI_BRIDGE_EVM_ETH_DENOM_PREFIX,
Icon: UsdtIcon
},
{
coinDenom: 'USDT',
coinMinimalDenom: ORAI_BRIDGE_EVM_DENOM_PREFIX + USDT_BSC_CONTRACT,
Expand Down Expand Up @@ -826,6 +836,16 @@ export const chainInfos: CustomChainInfo[] = [
bridgeTo: ['Oraichain'],
coinGeckoId: 'ethereum',
Icon: EthIcon
},
{
coinDenom: 'USDT',
coinMinimalDenom: 'erc20_usdt',
contractAddress: USDT_ETH_CONTRACT,
coinDecimals: 6,
bridgeTo: ['Oraichain'],
coinGeckoId: 'tether',
prefixToken: ORAI_BRIDGE_EVM_ETH_DENOM_PREFIX,
Icon: UsdtIcon
}
]
},
Expand Down
6 changes: 3 additions & 3 deletions src/pages/UniversalSwap/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ export function filterNonPoolEvmTokens(
) {
// basic filter. Dont include itself & only collect tokens with searched letters
const listTokens = direction === SwapDirection.From ? swapFromTokens : swapToTokens;
let filteredToTokens = listTokens
.filter((token) => token.denom !== denom && token.name.toLowerCase().includes(searchTokenName.toLowerCase()))
.filter((e) => !(e.chainId === '0x01' && e.coinGeckoId === 'tether')); // TODO: fix ether usdt
let filteredToTokens = listTokens.filter(
(token) => token.denom !== denom && token.name.toLowerCase().includes(searchTokenName.toLowerCase())
);

// special case for tokens not having a pool on Oraichain
if (isSupportedNoPoolSwapEvm(coingeckoId)) {
Expand Down
23 changes: 11 additions & 12 deletions src/tests/universal-swap.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,17 @@ import {
} from 'pages/UniversalSwap/helpers';

describe('universal-swap', () => {
// TODO: skip test version ether
// it.each<[string, CoinGeckoId, string, string, SwapDirection, number]>([
// ['0x38', 'wbnb', 'bep20_bnb', '', SwapDirection.From, 5],
// ['Oraichain', 'tether', 'usdt', '', SwapDirection.From, 20],
// ['Oraichain', 'oraichain-token', 'orai', '', SwapDirection.To, 20],
// ['0x38', 'oraichain-token', 'bep20_orai', '', SwapDirection.To, 22],
// ['0x38', 'wbnb', 'bep20_bnb', '', SwapDirection.To, 8],
// ['0x38', 'oraichain-token', 'oraichain-token', 'AIRI', SwapDirection.From, 2]
// ])('test-filterNonPoolEvmTokens', (chainId, coinGeckoId, denom, searchTokenName, direction, expectedLength) => {
// const tokens = filterNonPoolEvmTokens(chainId, coinGeckoId, denom, searchTokenName, direction);
// expect(tokens.length).toEqual(expectedLength);
// });
it.each<[string, CoinGeckoId, string, string, SwapDirection, number]>([
['0x38', 'wbnb', 'bep20_bnb', '', SwapDirection.From, 5],
['Oraichain', 'tether', 'usdt', '', SwapDirection.From, 22],
['Oraichain', 'oraichain-token', 'orai', '', SwapDirection.To, 21],
['0x38', 'oraichain-token', 'bep20_orai', '', SwapDirection.To, 23],
['0x38', 'wbnb', 'bep20_bnb', '', SwapDirection.To, 8],
['0x38', 'oraichain-token', 'oraichain-token', 'AIRI', SwapDirection.From, 2]
])('test-filterNonPoolEvmTokens', (chainId, coinGeckoId, denom, searchTokenName, direction, expectedLength) => {
const tokens = filterNonPoolEvmTokens(chainId, coinGeckoId, denom, searchTokenName, direction);
expect(tokens.length).toEqual(expectedLength);
});

describe('checkEvmAddress', () => {
const testCases = [
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3007,10 +3007,10 @@
resolved "https://registry.yarnpkg.com/@oraichain/oraidex-contracts-sdk/-/oraidex-contracts-sdk-1.0.31.tgz#98e5eb3a8d995febb40fcd188709255e3ecd624c"
integrity sha512-bwOs9+xKtlGVOy5vM1oNw54MeoRYLTY+3f4K2oNyAv0Y8QCEeQFt0g2l7LkpzyjXh5OVyu8nOKzx70XW5zajlA==

"@oraichain/oraidex-universal-swap@^1.0.48":
version "1.0.48"
resolved "https://registry.yarnpkg.com/@oraichain/oraidex-universal-swap/-/oraidex-universal-swap-1.0.48.tgz#9a0602475d88a540b0c7e04c3f638ac2755bbfcd"
integrity sha512-cdAB71P2pYE2BDMh7bOUIM2U0Qgf9WpGzuz5yrKNf7PhX36o9FBVljuk5A6yyDMkK2G/Ifp6GqTRZQG7HNhfng==
"@oraichain/oraidex-universal-swap@^1.0.49":
version "1.0.49"
resolved "https://registry.yarnpkg.com/@oraichain/oraidex-universal-swap/-/oraidex-universal-swap-1.0.49.tgz#94d1d5549236ea2f3ef73143be31d58374b768e3"
integrity sha512-UB3ExIkzVlLqqPDDFWFW673nNrJXDINo1FZpdhxhqNE2oU/H1q2Q2JnnfbGILsoQ79RH+FLEKdd+X0taPQElzw==
dependencies:
"@oraichain/oraidex-common" "^1.0.45"
"@oraichain/oraidex-contracts-sdk" "^1.0.24"
Expand Down

0 comments on commit f8d28de

Please sign in to comment.