Skip to content

Commit

Permalink
Merge pull request #327 from oraichain/fix/smart-route-ledger
Browse files Browse the repository at this point in the history
Fix/smart route ledger
  • Loading branch information
haunv3 authored Sep 9, 2024
2 parents ffb5731 + 8ce783e commit e02c87b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/universal-swap/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@oraichain/oraidex-universal-swap",
"version": "1.1.3",
"version": "1.1.4",
"main": "build/index.js",
"files": [
"build/"
Expand Down
16 changes: 14 additions & 2 deletions packages/universal-swap/src/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -636,7 +636,7 @@ export class UniversalSwapHandler {

async alphaSmartRouterSwap() {
const { cosmos } = this.swapData.sender;
const { alphaSmartRoutes, originalFromToken } = this.swapData;
const { alphaSmartRoutes, originalFromToken, originalToToken } = this.swapData;

const { client } = await this.config.cosmosWallet.getCosmWasmClient(
{
Expand All @@ -654,11 +654,23 @@ export class UniversalSwapHandler {
this.config.cosmosWallet.getKeplrAddr("injective-1")
]);

if (!oraiAddress || !injAddress) {
// Only support from cosmos <=> cosmos
if (!originalFromToken.cosmosBased || !originalToToken.cosmosBased) {
throw generateError(`There is a not cosmosbased. Should not using smart router swap!`);
}

if (!oraiAddress) {
throw generateError(`There is a mismatch address ${oraiAddress}. Should not using smart router swap!`);
}

// Check route has chainInjective => need has injective
const isInjectiveMismatch = routesFlatten.some((route) => route.chainId === "injective-1") && !injAddress;
if (isInjectiveMismatch) {
throw generateError(
`There is a mismatch address between ${oraiAddress} and ${injAddress}. Should not using smart router swap!`
);
}

const { messages, msgTransfers } = this.getMessagesAndMsgTransfers(routesFlatten, {
oraiAddress,
injAddress
Expand Down

0 comments on commit e02c87b

Please sign in to comment.