From f2d1689e6ddfd3ff089b8864dc4a182c1e0fd468 Mon Sep 17 00:00:00 2001 From: Hau Nguyen Van Date: Mon, 2 Dec 2024 22:04:30 +0700 Subject: [PATCH 1/3] add solana network --- packages/oraidex-common/package.json | 2 +- packages/oraidex-common/src/constant.ts | 7 +++ packages/oraidex-common/src/network.ts | 84 +++++++++++++++++++++++-- 3 files changed, 86 insertions(+), 7 deletions(-) diff --git a/packages/oraidex-common/package.json b/packages/oraidex-common/package.json index d54fe875..0eef02af 100644 --- a/packages/oraidex-common/package.json +++ b/packages/oraidex-common/package.json @@ -1,6 +1,6 @@ { "name": "@oraichain/oraidex-common", - "version": "1.1.34", + "version": "1.1.35", "main": "build/index.js", "files": [ "build/" diff --git a/packages/oraidex-common/src/constant.ts b/packages/oraidex-common/src/constant.ts index fe61618d..87637054 100644 --- a/packages/oraidex-common/src/constant.ts +++ b/packages/oraidex-common/src/constant.ts @@ -108,6 +108,8 @@ export const DOGE_BNB_ORAICHAIN_DENOM = "factory/orai1wuvhex9xqs3r539mvc6mtm7n20fcj3qr2m0y9khx6n5vtlngfzes3k0rq9/DogeBNB"; export const WSOL_WORMHOLE_BNB_ORAICHAIN_DENOM = "factory/orai1wuvhex9xqs3r539mvc6mtm7n20fcj3qr2m0y9khx6n5vtlngfzes3k0rq9/oraib0x4VH72cCsNwZwLtHtBnXuCxHWf4mB"; +export const MAX_ORAICHAIN_DENOM = + "factory/orai1wuvhex9xqs3r539mvc6mtm7n20fcj3qr2m0y9khx6n5vtlngfzes3k0rq9/oraim8c9d1nkfuQk9EzGYEUGxqL3MHQYndRw1huVo5h"; // config for oraichain token export const AIRI_CONTRACT = "orai10ldgzued6zjp0mkqwsv2mux3ml50l97c74x8sg"; @@ -164,6 +166,9 @@ export const BASE_API_URL = "https://api.oraidex.io"; // alpha smart router export const OSMOSIS_ROUTER_CONTRACT = "osmo1h3jkejkcpthl45xrrm5geed3eq75p5rgfce9taufkwfr89k63muqweu2y7"; +// Sol +export const MAX_SOL_CONTRACT_ADDRESS = "oraim8c9d1nkfuQk9EzGYEUGxqL3MHQYndRw1huVo5h"; + // websocket consts export const WEBSOCKET_RECONNECT_ATTEMPTS = 5; export const WEBSOCKET_RECONNECT_INTERVAL = 20000; @@ -238,3 +243,5 @@ export const gravityContracts: Omit, "0x1ae6"> = { "0x01": GRAVITY_EVM_CONTRACT, "0x2b6653dc": GRAVITY_TRON_CONTRACT }; + +export const solChainId = "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp"; diff --git a/packages/oraidex-common/src/network.ts b/packages/oraidex-common/src/network.ts index 7964bf05..1498328a 100644 --- a/packages/oraidex-common/src/network.ts +++ b/packages/oraidex-common/src/network.ts @@ -65,7 +65,10 @@ import { DOGE_BNB_ORAICHAIN_DENOM, DOGE_BSC_CONTRACT, WSOL_WORMHOLE_BNB_ORAICHAIN_DENOM, - WSOL_WORMHOLE_BSC_CONTRACT + WSOL_WORMHOLE_BSC_CONTRACT, + solChainId, + MAX_SOL_CONTRACT_ADDRESS, + MAX_ORAICHAIN_DENOM } from "./constant"; import { listOsmosisToken } from "./alpha-network"; import { celestiaNetwork } from "./celestia-network"; @@ -83,7 +86,8 @@ export type NetworkName = | "Injective" | "Noble" | "Neutaro" - | "Celestia"; + | "Celestia" + | "Solana"; export type CosmosChainId = | "Oraichain" // oraichain @@ -102,7 +106,9 @@ export type EvmChainId = | "0x1ae6" // kawaii | "0x2b6653dc"; // tron -export type NetworkChainId = CosmosChainId | EvmChainId; +export type SolChainId = "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp"; + +export type NetworkChainId = CosmosChainId | EvmChainId | SolChainId; export type CoinGeckoId = | "oraichain-token" @@ -132,9 +138,10 @@ export type CoinGeckoId = | "simon-s-cat" | "hamster-kombat" | "dogecoin" - | "solana"; + | "solana" + | "max.clan"; -export type NetworkType = "cosmos" | "evm"; +export type NetworkType = "cosmos" | "evm" | "svm"; export interface NetworkConfig { coinType?: number; explorer: string; @@ -168,7 +175,7 @@ export type BridgeAppCurrency = FeeCurrency & { readonly prefixToken?: string; }; -export type CoinType = 118 | 60 | 195; +export type CoinType = 118 | 60 | 195 | 501; /** * A list of Cosmos chain infos. If we need to add / remove any chains, just directly update this variable. @@ -568,14 +575,79 @@ export const oraichainNetwork: CustomChainInfo = { coinDecimals: 9, coinGeckoId: "hamster-kombat", coinImageUrl: "https://assets.coingecko.com/coins/images/39102/standard/hamster-removebg-preview.png?1720514486" + }, + { + coinDenom: "MAX", + coinGeckoId: "max.clan", + coinMinimalDenom: MAX_ORAICHAIN_DENOM, + bridgeTo: [solChainId], + coinDecimals: 6, + coinImageUrl: + "https://pump.mypinata.cloud/ipfs/QmcGwYebsQfYbNSM9QDAMS2wKZ8fZNEiMbezJah1zgEWWS?img-width=256&img-dpr=2" } ] }; +export const solanaMainnet: CustomChainInfo = { + rpc: "https://swr.xnftdata.com/rpc-proxy/", + rest: "https://swr.xnftdata.com/rpc-proxy/", + chainId: solChainId, + chainName: "Solana", + bip44: { + coinType: 501 + }, + bech32Config: defaultBech32Config("sol"), + stakeCurrency: { + coinDenom: "SOL", + coinMinimalDenom: "sol", + coinDecimals: 9, + coinGeckoId: "solana", + coinImageUrl: "https://assets.coingecko.com/coins/images/4128/standard/solana.png?1718769756" + }, + chainSymbolImageUrl: "https://upload.wikimedia.org/wikipedia/en/b/b9/Solana_logo.png", + networkType: "svm", + currencies: [ + { + coinDenom: "MAX", + coinMinimalDenom: "max", + coinDecimals: 6, + bridgeTo: ["Oraichain"], + contractAddress: MAX_SOL_CONTRACT_ADDRESS, + coinGeckoId: "max.clan", + coinImageUrl: + "https://pump.mypinata.cloud/ipfs/QmcGwYebsQfYbNSM9QDAMS2wKZ8fZNEiMbezJah1zgEWWS?img-width=256&img-dpr=2" + } + ], + get feeCurrencies() { + return [ + { + coinDenom: "SOL", + coinMinimalDenom: "sol", + coinDecimals: 9, + coinGeckoId: "solana", + coinImageUrl: "https://assets.coingecko.com/coins/images/4128/standard/solana.png?1718769756", + gasPriceStep: { + low: 1, + average: 1.25, + high: 1.5 + } + } + ]; + }, + + features: [], + txExplorer: { + name: "Sol Scan", + txUrl: "https://solscan.io/tx/{txHash}", + accountUrl: "https://solscan.io/address/{address}" + } +}; + export const chainInfos: CustomChainInfo[] = [ // networks to add on keplr oraichainNetwork, celestiaNetwork, + solanaMainnet, { rpc: "https://bridge-v2.rpc.orai.io", rest: "https://bridge-v2.lcd.orai.io", From 0021e57dd76d5fd51c7136ff2b9a1ecda539d67f Mon Sep 17 00:00:00 2001 From: Hau Nguyen Van Date: Tue, 3 Dec 2024 17:11:54 +0700 Subject: [PATCH 2/3] add config solana --- packages/oraidex-common/src/constant.ts | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/packages/oraidex-common/src/constant.ts b/packages/oraidex-common/src/constant.ts index 87637054..bad5c614 100644 --- a/packages/oraidex-common/src/constant.ts +++ b/packages/oraidex-common/src/constant.ts @@ -38,6 +38,13 @@ export const ETHEREUM_SCAN = "https://etherscan.io"; export const BSC_SCAN = "https://bscscan.com"; export const TRON_SCAN = "https://tronscan.org"; export const KWT_SCAN = "https://scan.kawaii.global"; +export const SOL_SCAN = "https://solscan.io"; + +// sol information +export const commitmentLevel = "confirmed"; +export const TOKEN_RESERVES = 1_000_000_000_000_000; +export const LAMPORT_RESERVES = 1_000_000_000; +export const INIT_BONDING_CURVE = 95; export const ORAI_BRIDGE_UDENOM = "uoraib"; export const ORAI_BRIDGE_EVM_DENOM_PREFIX = "oraib"; @@ -111,6 +118,15 @@ export const WSOL_WORMHOLE_BNB_ORAICHAIN_DENOM = export const MAX_ORAICHAIN_DENOM = "factory/orai1wuvhex9xqs3r539mvc6mtm7n20fcj3qr2m0y9khx6n5vtlngfzes3k0rq9/oraim8c9d1nkfuQk9EzGYEUGxqL3MHQYndRw1huVo5h"; +// config solana +export const ORAICHAIN_RELAYER_ADDRESS = "orai1ehmhqcn8erf3dgavrca69zgp4rtxj5kqgtcnyd"; +export const SOL_RELAYER_ADDRESS = "4k7xvinq6nB221iBhcP9uMFCPFh29MxQ6LieMH7cqw45"; +export const MAX_SOL_CONTRACT_ADDRESS = "oraim8c9d1nkfuQk9EzGYEUGxqL3MHQYndRw1huVo5h"; +export const SOLANA_RPC = "https://swr.xnftdata.com/rpc-proxy/"; +export const SOLANA_WEBSOCKET = "wss://go.getblock.io/52d75331a9b74f9fa4a0056f15a1c022"; +export const MEMO_PROGRAM_ID = "MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr"; +export const MEMO_PROGRAM_ID_AMOUNT = "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"; + // config for oraichain token export const AIRI_CONTRACT = "orai10ldgzued6zjp0mkqwsv2mux3ml50l97c74x8sg"; export const ORAIX_CONTRACT = "orai1lus0f0rhx8s03gdllx2n6vhkmf0536dv57wfge"; @@ -166,9 +182,6 @@ export const BASE_API_URL = "https://api.oraidex.io"; // alpha smart router export const OSMOSIS_ROUTER_CONTRACT = "osmo1h3jkejkcpthl45xrrm5geed3eq75p5rgfce9taufkwfr89k63muqweu2y7"; -// Sol -export const MAX_SOL_CONTRACT_ADDRESS = "oraim8c9d1nkfuQk9EzGYEUGxqL3MHQYndRw1huVo5h"; - // websocket consts export const WEBSOCKET_RECONNECT_ATTEMPTS = 5; export const WEBSOCKET_RECONNECT_INTERVAL = 20000; From b254843d88e3efd952463a585bb673846ac70bec Mon Sep 17 00:00:00 2001 From: Hau Nguyen Van Date: Tue, 3 Dec 2024 17:13:22 +0700 Subject: [PATCH 3/3] add config solana --- packages/universal-swap/src/handler.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/universal-swap/src/handler.ts b/packages/universal-swap/src/handler.ts index 105a0336..bddc473d 100644 --- a/packages/universal-swap/src/handler.ts +++ b/packages/universal-swap/src/handler.ts @@ -102,7 +102,7 @@ export class UniversalSwapHandler { if (tronWeb && tronWeb.defaultAddress?.base58) return tronToEthAddress(tronWeb.defaultAddress.base58); throw generateError("Cannot find tron web to nor tron address to send to Tron network"); } - return this.config.cosmosWallet.getKeplrAddr(toChainId); + return this.config.cosmosWallet.getKeplrAddr(toChainId as CosmosChainId); } /**