Skip to content

Commit

Permalink
Merge pull request #269 from skip-mev/smart-swap
Browse files Browse the repository at this point in the history
  • Loading branch information
codingki authored May 21, 2024
2 parents 324be15 + d730678 commit c28c5bb
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 38 deletions.
2 changes: 1 addition & 1 deletion chain-registry
Submodule chain-registry updated 159 files
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
"@radix-ui/react-switch": "^1.0.3",
"@radix-ui/react-tooltip": "^1.0.7",
"@sentry/nextjs": "^7.99.0",
"@skip-router/core": "^3.0.1",
"@skip-router/core": "4.0.0",
"@solana/spl-token": "^0.4.1",
"@solana/wallet-adapter-react": "^0.15.35",
"@solana/wallet-adapter-wallets": "^0.19.31",
Expand Down
2 changes: 1 addition & 1 deletion src/components/PreviewRoute/ChainStep.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ export const ChainStep = ({
)}
</div>
<div className="flex flex-1 flex-col space-y-0">
{swapAction && signRequired && !isSource ? (
{swapAction && signRequired && (!isSource || (isSource && route.chainIDs.length === 1)) ? (
<AssetSwap
in={{
amount: swapAction.amountIn,
Expand Down
43 changes: 13 additions & 30 deletions src/components/PreviewRoute/make-actions.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { BridgeType, RouteResponse, SwapVenue } from "@skip-router/core";
import { BridgeType, RouteResponse } from "@skip-router/core";

export interface TransferAction {
type: "TRANSFER";
Expand All @@ -19,7 +19,6 @@ export interface SwapAction {
denomIn: string;
denomOut: string;
chainID: string;
swapVenue: SwapVenue;
id: string;
signRequired: boolean;
amountIn: string;
Expand Down Expand Up @@ -48,34 +47,18 @@ export const makeActions = ({ route }: { route: RouteResponse }): Action[] => {
})();

if ("swap" in operation) {
if ("swapIn" in operation.swap) {
_actions.push({
type: "SWAP",
denomIn: operation.swap.denomIn,
denomOut: operation.swap.denomOut,
chainID: operation.swap.chainID,
id: `swap-${swapCount}-${transferCount}-${i}`,
swapVenue: operation.swap.swapIn.swapVenue,
signRequired,
amountIn: operation.amountIn,
amountOut: operation.amountOut,
txIndex: operation.txIndex,
});
}
if ("swapOut" in operation.swap) {
_actions.push({
type: "SWAP",
denomIn: operation.swap.denomIn,
denomOut: operation.swap.denomOut,
chainID: operation.swap.chainID,
id: `swap-${swapCount}-${transferCount}-${i}`,
swapVenue: operation.swap.swapOut.swapVenue,
signRequired,
amountIn: operation.amountIn,
amountOut: operation.amountOut,
txIndex: operation.txIndex,
});
}
_actions.push({
type: "SWAP",
denomIn: operation.swap.denomIn,
denomOut: operation.swap.denomOut,
chainID: operation.swap.chainID,
id: `swap-${swapCount}-${transferCount}-${i}`,
signRequired,
amountIn: operation.amountIn,
amountOut: operation.amountOut,
txIndex: operation.txIndex,
});

swapCount++;
return;
}
Expand Down
6 changes: 6 additions & 0 deletions src/solve/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,9 @@ export function useRoute({
allowUnsafe: true,
experimentalFeatures,
smartRelay: true,
smartSwapOptions: {
splitRoutes: true,
},
}
: {
amountOut: amount,
Expand All @@ -145,6 +148,9 @@ export function useRoute({
allowUnsafe: true,
experimentalFeatures,
smartRelay: true,
smartSwapOptions: {
splitRoutes: true,
},
},
);

Expand Down

0 comments on commit c28c5bb

Please sign in to comment.