Skip to content

Commit

Permalink
Merge branch 'feat/add-pepe-cat' into feat/oraidex-universal-swap
Browse files Browse the repository at this point in the history
  • Loading branch information
haunv3 committed Sep 25, 2024
2 parents 1cbd65c + 2f415ee commit 9a57804
Show file tree
Hide file tree
Showing 5 changed files with 24 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.1.18",
"version": "1.1.19",
"main": "build/index.js",
"files": [
"build/"
Expand Down
2 changes: 1 addition & 1 deletion packages/oraidex-common/src/network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down
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.6-beta.2",
"version": "1.1.9",
"main": "build/index.js",
"files": [
"build/"
Expand Down
12 changes: 12 additions & 0 deletions packages/universal-swap/src/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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(
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 9a57804

Please sign in to comment.