Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Feat/universal swap ton #328

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
8 changes: 5 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
"type": "module",
"scripts": {
"postinstall": "patch-package",
"test": "yarn build:test && vitest run --silent=false --coverage --no-file-parallelism --no-isolate --pool=threads",
"test": "yarn build && vitest run --silent=false --coverage --no-file-parallelism --no-isolate --pool=threads",
"docs": "typedoc --entryPointStrategy expand --name 'Oraidex SDK' --readme none --tsconfig packages/contracts-sdk/tsconfig.json packages/contracts-sdk/src",
"clean": "lerna clean --yes && lerna exec -- rimraf build/ dist/ cache/ && nx reset",
"build": "lerna run build --concurrency 1",
"build:test": "lerna run build:test --concurrency 1",
"build:test": "lerna run build --concurrency 1",
"build-tsc": "tsc -p",
"deploy": "yarn publish --access public",
"deploy:beta": "yarn publish --access public --tag beta",
Expand All @@ -30,7 +30,9 @@
"@cosmjs/stargate": "0.31.3",
"@cosmjs/tendermint-rpc": "0.31.3",
"@oraichain/common-contracts-build": "1.0.35",
"@oraichain/common-contracts-sdk": "1.0.31"
"@oraichain/common-contracts-sdk": "1.0.31",
"@oraichain/tonbridge-sdk": "^1.3.6",
"@ton/crypto": "^3.3.0"
},
"devDependencies": {
"@babel/traverse": "7.24.1",
Expand Down
11 changes: 0 additions & 11 deletions packages/contracts-build/tsconfig.test.json

This file was deleted.

11 changes: 0 additions & 11 deletions packages/contracts-sdk/tsconfig.test.json

This file was deleted.

15 changes: 0 additions & 15 deletions packages/ibc-routing/tsconfig.test.json

This file was deleted.

2 changes: 1 addition & 1 deletion packages/oraidex-common-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"types": "dist/umd/types/index.d.ts",
"scripts": {
"build": "yarn && rimraf dist/umd && webpack && tsc",
"build:test": "yarn && rimraf dist/umd && webpack && tsc -p tsconfig.test.json",
"build:test": "yarn && rimraf dist/umd && webpack && tsc -p tsconfig.json",
"storybook": "storybook dev -p 6006",
"build-storybook": "storybook build"
},
Expand Down
13 changes: 0 additions & 13 deletions packages/oraidex-common-ui/tsconfig.test.json

This file was deleted.

4 changes: 2 additions & 2 deletions packages/oraidex-common/package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"name": "@oraichain/oraidex-common",
"version": "1.1.6",
"version": "1.1.7",
"main": "build/index.js",
"files": [
"build/"
],
"scripts": {
"build": "tsc -p tsconfig.json",
"build:test": "tsc --project tsconfig.test.json"
"build:test": "tsc --project tsconfig.json"
},
"license": "MIT",
"dependencies": {
Expand Down
15 changes: 14 additions & 1 deletion packages/oraidex-common/src/alpha-network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,17 @@ export const InjOsmosisToken: BridgeAppCurrency = {
}
};

export const listOsmosisToken = [AtomOsmosisToken, OraiOsmosisToken, TiaOsmosisToken, InjOsmosisToken];
export const TonOsmosisToken: BridgeAppCurrency = {
coinDenom: "TON",
coinMinimalDenom: "ibc/905889A7F0B94F1CE1506D9BADF13AE9141E4CBDBCD565E1DFC7AE418B3E3E98",
coinDecimals: 9,
coinGeckoId: "the-open-network",
coinImageUrl: "https://raw.githubusercontent.com/cosmos/chain-registry/master/_non-cosmos/ton/images/ton.png",
gasPriceStep: {
low: 0,
average: 0.025,
high: 0.04
}
};

export const listOsmosisToken = [AtomOsmosisToken, OraiOsmosisToken, TiaOsmosisToken, TonOsmosisToken];
14 changes: 14 additions & 0 deletions packages/oraidex-common/src/constant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ export const MULTIPLIER = 1.6;
export const HIGH_GAS_PRICE = 0.007;
export const AVERAGE_COSMOS_GAS_PRICE = 0.025; // average based on Keplr

// config ton
export const MIN_TON_FOR_EXECUTE = 20000001; // min ton for execute is 20000000, contract requires sent_funds > amount in body + MIN_TON_FOR_EXECUTE

export const SEC_PER_YEAR = 60 * 60 * 24 * 365;

export const BROADCAST_POLL_INTERVAL = 600;
Expand Down Expand Up @@ -112,6 +115,17 @@ export const WETH_CONTRACT = "orai1dqa52a7hxxuv8ghe7q5v0s36ra0cthea960q2cukznleq
export const BTC_CONTRACT = "orai10g6frpysmdgw5tdqke47als6f97aqmr8s3cljsvjce4n5enjftcqtamzsd";
export const OCH_CONTRACT = "orai1hn8w33cqvysun2aujk5sv33tku4pgcxhhnsxmvnkfvdxagcx0p8qa4l98q";

// config for Ton Token
export const TON20_USDT_CONTRACT = "EQCxE6mUtQJKFnGfaROTKOt1lZbDiiX1kCixRv7Nw2Id_sDs";
export const TON_CONTRACT = "EQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAM9c";
export const TON_BRIDGE_ADAPTER = "EQC-aFP0rJXwTgKZQJPbPfTSpBFc8wxOgKHWD9cPvOl_DnaY";
export const TON_LIGHT_CLIENT = "EQDzy_POlimFDyzrHd3OQsb9sZCngyG3O7Za4GRFzM-rrO93";
export const TON_WHITE_LIST = "EQATDM6mfPZjPDMD9TVa6D9dlbmAKY5w6xOJiTXJ9Nqj_dsu";
export const TON_NATIVE_DENOM = "ton";

export const TON_BRIDGE_ADAPTER_ORAICHAIN = "orai159l8l9c5ckhqpuwdfgs9p4v599nqt3cjlfahalmtrhfuncnec2ms5mz60e";
export const TOKEN_FACTORY = "orai1wuvhex9xqs3r539mvc6mtm7n20fcj3qr2m0y9khx6n5vtlngfzes3k0rq9";

// config for oraichain contract
export const FACTORY_CONTRACT = "orai1hemdkz4xx9kukgrunxu3yw0nvpyxf34v82d2c8";
export const FACTORY_V2_CONTRACT = "orai167r4ut7avvgpp3rlzksz6vw5spmykluzagvmj3ht845fjschwugqjsqhst";
Expand Down
4 changes: 3 additions & 1 deletion packages/oraidex-common/src/interface/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,7 @@ export enum ChainIdEnum {
BNBChainTestNet = "0x61",
TRON = "0x2b6653dc",
BitcoinTestnet = "bitcoinTestnet",
Bitcoin = "bitcoin"
Bitcoin = "bitcoin",
Ton = "ton",
TonTestnet = "ton_testnet"
}
67 changes: 62 additions & 5 deletions packages/oraidex-common/src/network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ import {
ORAIDEX_BID_POOL_CONTRACT,
ORAIX_ETH_CONTRACT,
MIXED_ROUTER,
AMM_V3_CONTRACT
AMM_V3_CONTRACT,
TON20_USDT_CONTRACT,
TON_CONTRACT
} from "./constant";
import { listOsmosisToken } from "./alpha-network";

Expand All @@ -70,7 +72,8 @@ export type NetworkName =
| "Tron Network"
| "Injective"
| "Noble"
| "Neutaro";
| "Neutaro"
| "Ton";

export type CosmosChainId =
| "Oraichain" // oraichain
Expand All @@ -88,7 +91,9 @@ export type EvmChainId =
| "0x1ae6" // kawaii
| "0x2b6653dc"; // tron

export type NetworkChainId = CosmosChainId | EvmChainId;
export type TonChainId = "ton";

export type NetworkChainId = CosmosChainId | EvmChainId | TonChainId;

export type CoinGeckoId =
| "oraichain-token"
Expand All @@ -115,7 +120,7 @@ export type CoinGeckoId =
| "celestia"
| "the-open-network";

export type NetworkType = "cosmos" | "evm";
export type NetworkType = "cosmos" | "evm" | "ton";
export interface NetworkConfig {
coinType?: number;
explorer: string;
Expand Down Expand Up @@ -149,7 +154,7 @@ export type BridgeAppCurrency = FeeCurrency & {
readonly prefixToken?: string;
};

export type CoinType = 118 | 60 | 195;
export type CoinType = 118 | 60 | 195 | 607;

/**
* A list of Cosmos chain infos. If we need to add / remove any chains, just directly update this variable.
Expand Down Expand Up @@ -506,9 +511,61 @@ export const oraichainNetwork: CustomChainInfo = {
]
};

export const tonNetworkMainnet: CustomChainInfo = {
rest: "https://toncenter.com/api/v2/jsonRPC",
rpc: "https://toncenter.com/api/v2/jsonRPC",
chainId: "ton",
chainName: "Ton",
bip44: {
coinType: 607
},
coinType: 607,
stakeCurrency: {
coinDenom: "TON",
coinMinimalDenom: "ton",
coinDecimals: 9,
coinGeckoId: "the-open-network",
coinImageUrl: "https://assets.coingecko.com/coins/images/17980/standard/ton_symbol.png"
},
bech32Config: defaultBech32Config("ton"),
networkType: "ton",
currencies: [
{
coinDenom: "TON",
coinMinimalDenom: "ton",
coinDecimals: 9,
bridgeTo: ["Oraichain"],
prefixToken: "ton20_",
contractAddress: TON_CONTRACT,
coinGeckoId: "the-open-network",
coinImageUrl: "https://assets.coingecko.com/coins/images/17980/standard/ton_symbol.png"
},
{
coinDenom: "USDT",
coinMinimalDenom: "ton20_usdt",
coinDecimals: 6,
bridgeTo: ["Oraichain"],
contractAddress: TON20_USDT_CONTRACT,
prefixToken: "ton20_",
coinGeckoId: "tether",
coinImageUrl: "https://s2.coinmarketcap.com/static/img/coins/64x64/825.png"
}
],
get feeCurrencies() {
return this.currencies;
},
features: ["isTon"],
txExplorer: {
name: "BlockStream",
txUrl: "https://tonviewer.com/transaction/{txHash}",
accountUrl: `https://tonviewer.com/transaction/{address}`
}
};

export const chainInfos: CustomChainInfo[] = [
// networks to add on keplr
oraichainNetwork,
tonNetworkMainnet,
{
rpc: "https://bridge-v2.rpc.orai.io",
rest: "https://bridge-v2.lcd.orai.io",
Expand Down
12 changes: 0 additions & 12 deletions packages/oraidex-common/tsconfig.test.json

This file was deleted.

4 changes: 2 additions & 2 deletions packages/universal-swap/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
],
"scripts": {
"build": "tsc -p tsconfig.json",
"build:test": "tsc --project tsconfig.test.json"
"build:test": "tsc --project tsconfig.json"
},
"license": "MIT",
"dependencies": {
"@oraichain/oraidex-common": "^1.0.91",
"@oraichain/oraidex-common": "^1.1.3",
"@oraichain/oraidex-contracts-sdk": "^1.0.49",
"bech32": "1.1.4",
"ethers": "^5.0.15",
Expand Down
Loading