Skip to content

Commit

Permalink
Merge pull request #160 from oraichain/feat/add-neutaro
Browse files Browse the repository at this point in the history
Feat/add neutaro
  • Loading branch information
haunv3 authored Feb 17, 2024
2 parents 2067f95 + 2709008 commit bd676cc
Show file tree
Hide file tree
Showing 4 changed files with 98 additions and 4 deletions.
2 changes: 1 addition & 1 deletion packages/oraidex-common/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@oraichain/oraidex-common",
"version": "1.0.65",
"version": "1.0.66",
"main": "build/index.js",
"files": [
"build/"
Expand Down
2 changes: 1 addition & 1 deletion packages/oraidex-common/src/constant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export const KWT_ORAICHAIN_CHANNELS = "channel-0 channel-21";
export const INJECTIVE_ORAICHAIN_CHANNELS = "channel-147 channel-146";
export const NOBLE_ORAICHAIN_CHANNELS = "channel-34 channel-147";
export const NOBLE_ORAICHAIN_CHANNELS_TEST = "channel-35 channel-148";
export const NEUTARO_ORAICHAIN_CHANNELS = "channel-189 channel-1";
export const NEUTARO_ORAICHAIN_CHANNELS = "channel-1 channel-189";

// config for ibc denom
export const ATOM_ORAICHAIN_DENOM = "ibc/A2E2EEC9057A4A1C2C0A6A4C78B0239118DF5F278830F50B4A6BDD7A66506B78";
Expand Down
51 changes: 49 additions & 2 deletions packages/oraidex-common/src/network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ import {
WRAP_ETH_CONTRACT,
WRAP_TRON_TRX_CONTRACT,
USDT_ETH_CONTRACT,
BTC_CONTRACT
BTC_CONTRACT,
NEUTARO_ORAICHAIN_DENOM
} from "./constant";

export type NetworkName =
Expand All @@ -60,7 +61,8 @@ export type NetworkName =
| "Kawaiiverse EVM"
| "Tron Network"
| "Injective"
| "Noble";
| "Noble"
| "Neutaro";

export type CosmosChainId =
| "Oraichain" // oraichain
Expand Down Expand Up @@ -309,6 +311,14 @@ export const oraichainNetwork: CustomChainInfo = {
coinDecimals: 6,
coinImageUrl: "https://dhj8dql1kzq2v.cloudfront.net/white/atom.png"
},
{
coinDenom: "NEUTARO",
coinGeckoId: "neutaro",
coinMinimalDenom: NEUTARO_ORAICHAIN_DENOM,
bridgeTo: ["Neutaro-1"],
coinDecimals: 6,
coinImageUrl: "https://raw.githubusercontent.com/chainapsis/keplr-chain-registry/main/images/Neutaro/chain.png"
},
// {
// coinDenom: 'BEP20 AIRI',
// coinGeckoId: 'airight',
Expand Down Expand Up @@ -722,6 +732,43 @@ export const chainInfos: CustomChainInfo[] = [
txUrl: "https://www.mintscan.io/cosmos/txs/{txHash}"
}
},
{
// rpc: 'http://rpc.neutaro.tech:26657/',
rpc: "https://neutaro.rpc.orai.io/",
rest: "http://api.neutaro.tech:1317/",
chainId: "Neutaro-1",
chainName: "Neutaro",
networkType: "cosmos",
bip44: {
coinType: 118
},
bech32Config: defaultBech32Config("neutaro"),
stakeCurrency: {
coinDenom: "neutaro",
coinMinimalDenom: "uneutaro",
coinDecimals: 6,
coinImageUrl: "https://raw.githubusercontent.com/chainapsis/keplr-chain-registry/main/images/Neutaro/chain.png"
},
feeCurrencies: [
{
coinDenom: "neutaro",
coinMinimalDenom: "uneutaro",
coinDecimals: 6,
coinImageUrl: "https://raw.githubusercontent.com/chainapsis/keplr-chain-registry/main/images/Neutaro/chain.png",
gasPriceStep: {
low: 0.01,
average: 0.025,
high: 0.03
}
}
],
currencies: [
{
...NeutaroToken,
bridgeTo: ["Oraichain"]
}
]
},
{
rpc: "https://rpc.cosmos.directory/noble",
rest: "https://rest.cosmos.directory/noble",
Expand Down
47 changes: 47 additions & 0 deletions packages/universal-swap/src/universal-demos/neutaro-ibc-demo.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import "dotenv/config";
import { CosmosWalletImpl } from "./offline-wallet";
import { UniversalSwapHandler } from "../handler";
import { NEUTARO_ORAICHAIN_DENOM, cosmosTokens, generateError, toAmount } from "@oraichain/oraidex-common";

const neutaroUsdcToOraiUsdc = async (chainId: "Neutaro-1" | "Oraichain") => {
const wallet = new CosmosWalletImpl(process.env.MNEMONIC);
const sender = await wallet.getKeplrAddr(chainId);
const fromAmount = 0.01;
let originalFromToken = cosmosTokens.find((t) => t.chainId === "Neutaro-1" && t.denom === "uneutaro");

let originalToToken = cosmosTokens.find(
(t) => t.chainId === "Oraichain" && t.denom && t.denom === NEUTARO_ORAICHAIN_DENOM
);

// if we bridge from Oraichain -> Neutaro then we reverse order
if (chainId === "Oraichain") {
const temp = originalFromToken;
originalFromToken = originalToToken;
originalToToken = temp;
}

if (!originalFromToken) throw generateError("Could not find original from token");
if (!originalToToken) throw generateError("Could not find original to token");
const universalHandler = new UniversalSwapHandler(
{
originalFromToken,
originalToToken,
sender: { cosmos: sender },
fromAmount,
simulateAmount: toAmount(fromAmount, originalToToken.decimals).toString()
},
{ cosmosWallet: wallet, ibcInfoTestMode: true }
);

try {
const result = await universalHandler.processUniversalSwap();
console.log("result: ", result);
} catch (error) {
console.log("error: ", error);
}
};

(() => {
if (process.env.FORWARD) return neutaroUsdcToOraiUsdc("Neutaro-1");
return neutaroUsdcToOraiUsdc("Oraichain");
})();

0 comments on commit bd676cc

Please sign in to comment.