Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add universal swap 1.1.27-beta.1 #390

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.44",
"version": "1.1.45",
"main": "build/index.js",
"files": [
"build/"
Expand Down
72 changes: 63 additions & 9 deletions packages/oraidex-common/src/network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -668,16 +668,70 @@ export const oraichainNetwork: CustomChainInfo = {
coinDecimals: 6,
coinImageUrl:
"https://pump.mypinata.cloud/ipfs/QmcGwYebsQfYbNSM9QDAMS2wKZ8fZNEiMbezJah1zgEWWS?img-width=256&img-dpr=2"
},
{
coinDenom: "RACKS",
coinMinimalDenom:
"factory/orai1wuvhex9xqs3r539mvc6mtm7n20fcj3qr2m0y9khx6n5vtlngfzes3k0rq9/D7yP4ycfsRWUGYionGpi64sLF2ddZ2JXxuRAti2M7uck",
coinDecimals: 6,
bridgeTo: ["solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp"],
coinGeckoId: "blackrack",
coinImageUrl: "https://ipfs.io/ipfs/QmVRPsBSHpamDzcDzVL9wsbB9gr4frtNrrFF7g44Xa9FuS"
},
{
coinDenom: "GNRT",
coinMinimalDenom:
"factory/orai1wuvhex9xqs3r539mvc6mtm7n20fcj3qr2m0y9khx6n5vtlngfzes3k0rq9/oraiJP7H3LAt57DkFXNLDbLdBFNRRPvS8jg2j5AZkd9",
coinDecimals: 6,
bridgeTo: ["solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp"],
coinGeckoId: "degenerator-project",
coinImageUrl: "https://ipfs.io/ipfs/QmNu1YU842i2imMX9bTV5kFK8ndUpUwxHD9ipRRXoBakD6"
},
{
coinDenom: "LEE",
coinMinimalDenom:
"factory/orai1wuvhex9xqs3r539mvc6mtm7n20fcj3qr2m0y9khx6n5vtlngfzes3k0rq9/oraix39mVDGnusyjag97Tz5H8GvGriSZmhVvkvXRoc4",
coinDecimals: 6,
bridgeTo: ["solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp"],
coinGeckoId: "lee-quid",
coinImageUrl: "https://ipfs.io/ipfs/QmWh89Xh8bVMD1vP4VLtkazQjM7TyYxfoufMn5SZHuEJY1"
},
{
coinDenom: "TRUMP",
coinMinimalDenom:
"factory/orai1wuvhex9xqs3r539mvc6mtm7n20fcj3qr2m0y9khx6n5vtlngfzes3k0rq9/6p6xgHyF7AeE6TZkSmFsko444wqoP15icUSqi2jfGiPN",
coinDecimals: 6,
bridgeTo: ["solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp"],
coinGeckoId: "official-trump",
coinImageUrl: "https://assets.coingecko.com/coins/images/53746/standard/trump.png?1737171561"
},
{
coinDenom: "JPOW",
coinMinimalDenom:
"factory/orai1wuvhex9xqs3r539mvc6mtm7n20fcj3qr2m0y9khx6n5vtlngfzes3k0rq9/orairHM3Yw2PbTfCty1PXy7tEUx3uBMfjouNbm4KnRJ",
coinDecimals: 6,
bridgeTo: ["solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp"],
coinGeckoId: "jpow",
coinImageUrl: "https://ipfs.io/ipfs/QmTNx93FdeSwBxsqbZF5NuhVU9AWwodpwqjuHtGEMRTV38"
},
{
coinDenom: "CRISIS",
coinMinimalDenom:
"factory/orai1wuvhex9xqs3r539mvc6mtm7n20fcj3qr2m0y9khx6n5vtlngfzes3k0rq9/moonznxqtXdzA81shGf6EQ8Rw36hgaoqRUeWREDYiVe",
coinDecimals: 6,
bridgeTo: ["solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp"],
coinGeckoId: "crisis",
coinImageUrl: "https://ipfs.io/ipfs/QmcJAjUjP4ruDBx4hgc1DG5BZVzSUQ13JGFSEFtibwwdcJ"
},
{
coinDenom: "MOOBS",
coinMinimalDenom:
"factory/orai1wuvhex9xqs3r539mvc6mtm7n20fcj3qr2m0y9khx6n5vtlngfzes3k0rq9/moonGvQw19jXedkQFf5qgdzSRCZvNv2eNbmvR6ZwSkk",
coinDecimals: 6,
bridgeTo: ["solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp"],
coinGeckoId: "moobs",
coinImageUrl: "https://ipfs.io/ipfs/QmQgDDuxwG5Ds5EfWbP7YgYi1BGFcGDv3c3D5NRU3wExes"
}
// {
// coinDenom: "RACKS",
// coinGeckoId: "black-rack",
// coinMinimalDenom: RACKS_ORAICHAIN_DENOM,
// bridgeTo: [solChainId],
// coinDecimals: 6,
// coinImageUrl:
// "https://pump.mypinata.cloud/ipfs/QmcGwYebsQfYbNSM9QDAMS2wKZ8fZNEiMbezJah1zgEWWS?img-width=256&img-dpr=2"
// }
]
};

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.26",
"version": "1.1.27",
"main": "build/index.js",
"files": [
"build/"
Expand Down
14 changes: 11 additions & 3 deletions packages/universal-swap/src/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -704,7 +704,8 @@ export class UniversalSwapHandler {
minimumReceive,
userSlippage,
this.config.swapOptions,
alphaSmartRoutes
alphaSmartRoutes,
this.swapData.affiliates
);
const swapRouteSplit = completeSwapRoute.split(":");
const swapRoute = swapRouteSplit.length === 1 ? "" : swapRouteSplit[1];
Expand Down Expand Up @@ -807,7 +808,13 @@ export class UniversalSwapHandler {
}

const msgs = alphaSmartRoutes.routes.map((route) => {
return generateMsgSwap(route, userSlippage / 100, receiverAddresses, recipientAddress);
return generateMsgSwap(
route,
userSlippage / 100,
receiverAddresses,
recipientAddress,
this.swapData.affiliates
);
});

const { client } = await this.config.cosmosWallet.getCosmWasmClient(
Expand Down Expand Up @@ -999,7 +1006,8 @@ export class UniversalSwapHandler {
minimumReceive,
userSlippage,
this.config.swapOptions,
alphaSmartRoutes
alphaSmartRoutes,
this.swapData.affiliates
);

if (swapOptions?.isAlphaIbcWasm) {
Expand Down
6 changes: 4 additions & 2 deletions packages/universal-swap/src/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,8 @@ export class UniversalSwapHelper {
ibcInfoTestMode?: boolean;
isAlphaIbcWasm?: boolean;
},
alphaSmartRoute?: RouterResponse
alphaSmartRoute?: RouterResponse,
affiliate?: Affiliate[]
): Promise<SwapRoute> => {
// TODO: recheck cosmos address undefined (other-chain -> oraichain)
if (!addresses.sourceReceiver) throw generateError(`Cannot get source if the sourceReceiver is empty!`);
Expand Down Expand Up @@ -490,7 +491,8 @@ export class UniversalSwapHelper {
userSlippage / 100,
receiverAddresses,
addresses.recipientAddress,
alphaRoutes.paths[0].chainId
alphaRoutes.paths[0].chainId,
affiliate
);

swapRoute = memo;
Expand Down
4 changes: 3 additions & 1 deletion packages/universal-swap/src/msg/chains/chain.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Affiliate } from "@oraichain/oraidex-contracts-sdk/build/OraiswapMixedRouter.types";
import { Path } from "../../types";
import { validatePath, validateReceiver } from "../common";

Expand All @@ -7,7 +8,8 @@ export class ChainMsg {
protected minimumReceive: string,
protected receiver: string,
protected currentChainAddress: string,
protected memo: string = ""
protected memo: string = "",
protected affiliates: Affiliate[] = []
) {
// validate path
validatePath(path);
Expand Down
12 changes: 10 additions & 2 deletions packages/universal-swap/src/msg/chains/cosmos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,18 @@ import {

import { EncodeObject } from "@cosmjs/proto-signing";
import { ChainMsg } from "./chain";
import { Affiliate } from "@oraichain/oraidex-contracts-sdk/build/OraiswapMixedRouter.types";

export class CosmosMsg extends ChainMsg {
constructor(path: Path, minimumReceive: string, receiver: string, currentChainAddress: string, memo: string = "") {
super(path, minimumReceive, receiver, currentChainAddress, memo);
constructor(
path: Path,
minimumReceive: string,
receiver: string,
currentChainAddress: string,
memo: string = "",
affiliates: Affiliate[]
) {
super(path, minimumReceive, receiver, currentChainAddress, memo, affiliates);
}

setMinimumReceiveForSwap(slippage: number = 0.01) {
Expand Down
10 changes: 6 additions & 4 deletions packages/universal-swap/src/msg/chains/oraichain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { MsgExecuteContract } from "cosmjs-types/cosmwasm/wasm/v1/tx";
import { TransferBackMsg } from "@oraichain/common-contracts-sdk/build/CwIcs20Latest.types";
import { toUtf8 } from "@cosmjs/encoding";
import { ChainMsg } from "./chain";
import { Affiliate } from "@oraichain/oraidex-contracts-sdk/build/OraiswapMixedRouter.types";

export class OraichainMsg extends ChainMsg {
SWAP_VENUE_NAME = "oraidex";
Expand All @@ -36,9 +37,10 @@ export class OraichainMsg extends ChainMsg {
currentChainAddress: string,
memo: string = "",
protected destPrefix: string = undefined,
protected obridgeAddress: string = undefined
protected obridgeAddress: string = undefined,
affiliates: Affiliate[] = []
) {
super(path, minimumReceive, receiver, currentChainAddress, memo);
super(path, minimumReceive, receiver, currentChainAddress, memo, affiliates);
// check chainId = "Oraichain"
if (path.chainId !== "Oraichain") {
throw generateError("This path must be on Oraichain");
Expand Down Expand Up @@ -443,7 +445,7 @@ export class OraichainMsg extends ChainMsg {
min_asset: min_asset,
timeout_timestamp: +calculateTimeoutTimestamp(IBC_TRANSFER_TIMEOUT),
post_swap_action: this.getPostAction(bridgeInfo),
affiliates: []
affiliates: this.affiliates
}
};

Expand Down Expand Up @@ -613,7 +615,7 @@ export class OraichainMsg extends ChainMsg {
// swap and action
let msg: ExecuteMsg = {
swap_and_action: {
affiliates: [],
affiliates: this.affiliates,
min_asset,
post_swap_action: this.getPostAction(bridgeInfo),
timeout_timestamp: +calculateTimeoutTimestamp(IBC_TRANSFER_TIMEOUT),
Expand Down
16 changes: 12 additions & 4 deletions packages/universal-swap/src/msg/chains/osmosis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,21 @@ import { EncodeObject } from "@cosmjs/proto-signing";
import { MsgExecuteContract } from "cosmjs-types/cosmwasm/wasm/v1/tx";
import { toUtf8 } from "@cosmjs/encoding";
import { ChainMsg } from "./chain";
import { Affiliate } from "@oraichain/oraidex-contracts-sdk/build/OraiswapMixedRouter.types";

export class OsmosisMsg extends ChainMsg {
SWAP_VENUE_NAME = "osmosis-poolmanager";
ENTRY_POINT_CONTRACT = "osmo1h3jkejkcpthl45xrrm5geed3eq75p5rgfce9taufkwfr89k63muqweu2y7";

constructor(path: Path, minimumReceive: string, receiver: string, currentChainAddress: string, memo: string = "") {
super(path, minimumReceive, receiver, currentChainAddress, memo);
constructor(
path: Path,
minimumReceive: string,
receiver: string,
currentChainAddress: string,
memo: string = "",
affiliates: Affiliate[] = []
) {
super(path, minimumReceive, receiver, currentChainAddress, memo, affiliates);
// check chainId = "osmosis-1"
if (path.chainId !== "osmosis-1") {
throw generateError("This path must be on Osmosis");
Expand Down Expand Up @@ -190,7 +198,7 @@ export class OsmosisMsg extends ChainMsg {
min_asset: min_asset,
timeout_timestamp: +calculateTimeoutTimestamp(IBC_TRANSFER_TIMEOUT),
post_swap_action: this.getPostAction(bridgeInfo),
affiliates: []
affiliates: this.affiliates
}
};

Expand Down Expand Up @@ -257,7 +265,7 @@ export class OsmosisMsg extends ChainMsg {
// swap and action
let msg: ExecuteMsg = {
swap_and_action: {
affiliates: [],
affiliates: this.affiliates,
min_asset,
post_swap_action: this.getPostAction(bridgeInfo),
timeout_timestamp: +calculateTimeoutTimestamp(IBC_TRANSFER_TIMEOUT),
Expand Down
Loading
Loading