Skip to content

Commit

Permalink
Merge pull request #273 from oraichain/feat/smart-router-osmosis-pool
Browse files Browse the repository at this point in the history
pumb version 1.0.87 universal swap
  • Loading branch information
haunv3 authored May 27, 2024
2 parents 7b294ed + 5993d13 commit 0edb7d2
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 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.0.86",
"version": "1.0.87",
"main": "build/index.js",
"files": [
"build/"
Expand Down
24 changes: 16 additions & 8 deletions packages/universal-swap/src/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,6 @@ export class UniversalSwapHandler {

const msg = {
// TODO: need check address
contract: this.getReceiverIBCHooks(route.chainId),
msg: {
swap_and_action: {
user_swap: {
Expand All @@ -376,6 +375,7 @@ export class UniversalSwapHandler {
msgActionSwap: {
// TODO: need check address
sender: this.swapData.sender.cosmos,
contractAddress: this.getReceiverIBCHooks(route.chainId),
funds: [
{
denom: route.tokenIn,
Expand All @@ -390,6 +390,7 @@ export class UniversalSwapHandler {
return {
msgActionSwap: {
wasm: {
contract: this.getReceiverIBCHooks(route.chainId),
...msg
}
}
Expand Down Expand Up @@ -566,15 +567,22 @@ export class UniversalSwapHandler {
injAddress
});

const transferStringifyMemo = msgTransfers.map((transfer) => {
this.stringifyMemos(transfer);
return {
typeUrl: transfer.funds ? "/cosmwasm.wasm.v1.MsgExecuteContract" : "/ibc.applications.transfer.v1.MsgTransfer",
value: transfer
};
const messagesOsmosisStringifyMemo = [];
const transferStringifyMemo = [];

msgTransfers.forEach((msg) => {
this.stringifyMemos(msg);
if (msg?.funds) {
messagesOsmosisStringifyMemo.push(msg);
} else {
transferStringifyMemo.push({
typeUrl: "/ibc.applications.transfer.v1.MsgTransfer",
value: msg
});
}
});

const msgExecuteSwap = getEncodedExecuteContractMsgs(cosmos, messages);
const msgExecuteSwap = getEncodedExecuteContractMsgs(cosmos, [...messages, ...messagesOsmosisStringifyMemo]);
return client.signAndBroadcast(this.swapData.sender.cosmos, [...msgExecuteSwap, ...transferStringifyMemo], "auto");
}

Expand Down

0 comments on commit 0edb7d2

Please sign in to comment.