diff --git a/packages/oraidex-common/package.json b/packages/oraidex-common/package.json index 95bdc37f..f4f28f28 100644 --- a/packages/oraidex-common/package.json +++ b/packages/oraidex-common/package.json @@ -1,6 +1,6 @@ { "name": "@oraichain/oraidex-common", - "version": "1.1.18", + "version": "1.1.19", "main": "build/index.js", "files": [ "build/" diff --git a/packages/oraidex-common/src/network.ts b/packages/oraidex-common/src/network.ts index b3e4ff33..071751d9 100644 --- a/packages/oraidex-common/src/network.ts +++ b/packages/oraidex-common/src/network.ts @@ -504,7 +504,7 @@ export const oraichainNetwork: CustomChainInfo = { coinMinimalDenom: "usat", type: "cw20", contractAddress: BTC_CONTRACT, - // bridgeTo: ["bitcoinTestnet"], + bridgeTo: ["bitcoin"] as any, coinDecimals: 6, coinImageUrl: "https://s2.coinmarketcap.com/static/img/coins/64x64/1.png" }, diff --git a/packages/universal-swap/package.json b/packages/universal-swap/package.json index dee6d1fd..a5d6baa5 100644 --- a/packages/universal-swap/package.json +++ b/packages/universal-swap/package.json @@ -1,6 +1,6 @@ { "name": "@oraichain/oraidex-universal-swap", - "version": "1.1.6-beta.2", + "version": "1.1.9", "main": "build/index.js", "files": [ "build/" diff --git a/packages/universal-swap/src/helper.ts b/packages/universal-swap/src/helper.ts index c13115c7..c28bb355 100644 --- a/packages/universal-swap/src/helper.ts +++ b/packages/universal-swap/src/helper.ts @@ -868,6 +868,8 @@ export class UniversalSwapHelper { if ("native" in balance) { const pairMapping = await ics20Client.pairMapping({ key: pairKey }); + // @ts-ignore + if (pairMapping.pair_mapping?.is_mint_burn) return; const trueBalance = toDisplay(balance.native.amount, pairMapping.pair_mapping.remote_decimals); let _toAmount = toDisplay(toSimulateAmount, toToken.decimals); if (fromToken.coinGeckoId !== toToken.coinGeckoId) { @@ -920,11 +922,21 @@ export class UniversalSwapHelper { // always check from token in ibc wasm should have enough tokens to swap / send to destination const token = getTokenOnOraichain(from.coinGeckoId); if (!token) return; + + // hardcode if is token factory ( mint) then return + if ( + token.denom && + token.denom.includes("factory/orai1wuvhex9xqs3r539mvc6mtm7n20fcj3qr2m0y9khx6n5vtlngfzes3k0rq9") + ) { + return; + } + let ibcWasmContractAddr = ibcWasmContract; // TODO: check balance with kawaii token and milky token if (["kawaii-islands", "milky-token"].includes(from.coinGeckoId) && ["0x38"].includes(from.chainId)) { ibcWasmContractAddr = network.converter; } + const { balance } = await UniversalSwapHelper.getBalanceIBCOraichain(token, client, ibcWasmContractAddr); if (balance < fromAmount) { throw generateError( diff --git a/packages/universal-swap/tests/index.spec.ts b/packages/universal-swap/tests/index.spec.ts index 1beb8d99..13b32eb4 100644 --- a/packages/universal-swap/tests/index.spec.ts +++ b/packages/universal-swap/tests/index.spec.ts @@ -667,6 +667,13 @@ describe("test universal swap handler functions", () => { 10000000, "10000000", false + ], + [ + flattenTokens.find((t) => t.coinGeckoId === "pepe" && t.chainId === "0x38")!, // PEPE (BSC) + flattenTokens.find((t) => t.coinGeckoId === "pepe" && t.chainId === "Oraichain")!, // PEPE (ORAICHAIN) + 0, + "0", + false ] ])( "test-universal-swap-checkBalanceIBCOraichain", @@ -675,9 +682,10 @@ describe("test universal swap handler functions", () => { vi.spyOn(UniversalSwapHelper, "getBalanceIBCOraichain").mockReturnValue( new Promise((resolve) => resolve({ balance: +toAmount })) ); + checkBalanceIBCOraichain( - from, to, + from, fromAmount, simulateAmount, ics20Contract.client,