-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #160 from oraichain/feat/add-neutaro
Feat/add neutaro
- Loading branch information
Showing
4 changed files
with
98 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
packages/universal-swap/src/universal-demos/neutaro-ibc-demo.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); | ||
})(); |