Skip to content

Commit

Permalink
Merge pull request #336 from oraichain/feat/add-pepe-cat
Browse files Browse the repository at this point in the history
fix checkBalanceIBCOraichain
  • Loading branch information
haunv3 authored Sep 25, 2024
2 parents f1e0406 + f651c8d commit 42bd213
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 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.7",
"version": "1.1.8",
"main": "build/index.js",
"files": [
"build/"
Expand Down
7 changes: 7 additions & 0 deletions packages/universal-swap/src/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -922,11 +922,18 @@ 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 burn) then return
if (to.denom && to.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(
Expand Down
10 changes: 9 additions & 1 deletion packages/universal-swap/tests/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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,
Expand Down

0 comments on commit 42bd213

Please sign in to comment.