Skip to content

Commit

Permalink
hotfix: switch to swap network (#2426)
Browse files Browse the repository at this point in the history
creed-victor authored Oct 5, 2022

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 20300a9 commit 123a370
Showing 3 changed files with 32 additions and 36 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -17,8 +17,8 @@
"@reduxjs/toolkit": "1.5.1",
"@rsksmart/rsk3": "0.3.4",
"@sovryn/charting-library": "1.0.0",
"@sovryn/react-wallet": "2.2.15",
"@sovryn/perpetual-swap": "3.0.14",
"@sovryn/react-wallet": "2.2.15",
"@svgr/webpack": "4.3.3",
"@testing-library/jest-dom": "5.1.1",
"@testing-library/react": "10.0.1",
53 changes: 27 additions & 26 deletions src/app/pages/SpotTradingPage/components/TradeForm/MarketForm.tsx
Original file line number Diff line number Diff line change
@@ -13,7 +13,6 @@ import { OrderType } from 'app/components/OrderTypeTitle/types';
import { AssetRenderer } from 'app/components/AssetRenderer';
import { weiToFixed } from 'utils/blockchain/math-helpers';
import { useSlippage } from 'app/pages/BuySovPage/components/BuyForm/useSlippage';
import { Asset } from 'types/asset';
import { maxMinusFee } from 'utils/helpers';
import {
stringToFixedPrecision,
@@ -27,8 +26,6 @@ import { useSwapsExternal_getSwapExpectedReturn } from '../../../../hooks/swap-n
import styles from './index.module.scss';
import { TradeDialog } from '../TradeDialog';
import { OrderLabel } from '../OrderLabel';
import { useAccount } from 'app/hooks/useAccount';
import { useSwapsExternal_approveAndSwapExternal } from '../../../../hooks/swap-network/useSwapsExternal_approveAndSwapExternal';
import { useSwapNetwork_approveAndConvertByPath } from '../../../../hooks/swap-network/useSwapNetwork_approveAndConvertByPath';
import { useSwapNetwork_conversionPath } from 'app/hooks/swap-network/useSwapNetwork_conversionPath';
import classNames from 'classnames';
@@ -52,7 +49,7 @@ export const MarketForm: React.FC<ITradeFormProps> = ({
const { t } = useTranslation();
const { connected } = useWalletContext();
const { checkMaintenance, States } = useMaintenance();
const account = useAccount();
// const account = useAccount();
const spotLocked = checkMaintenance(States.SPOT_TRADES);

const [isTradingDialogOpen, setIsTradingDialogOpen] = useState(false);
@@ -67,19 +64,19 @@ export const MarketForm: React.FC<ITradeFormProps> = ({
weiAmount,
);
const { minReturn } = useSlippage(rateByPath, slippage);
const {
send: sendExternal,
...txExternal
} = useSwapsExternal_approveAndSwapExternal(
sourceToken,
targetToken,
account,
account,
weiAmount,
'0',
minReturn,
'0x',
);
// const {
// send: sendExternal,
// ...txExternal
// } = useSwapsExternal_approveAndSwapExternal(
// sourceToken,
// targetToken,
// account,
// account,
// weiAmount,
// '0',
// minReturn,
// '0x',
// );

const { value: path } = useSwapNetwork_conversionPath(
AssetsDictionary.get(sourceToken).getTokenContractAddress(),
@@ -104,16 +101,20 @@ export const MarketForm: React.FC<ITradeFormProps> = ({
);
}, [balance, minReturn, sourceToken, weiAmount]);

const tx = useMemo(() => (targetToken === Asset.RBTC ? txPath : txExternal), [
targetToken,
txExternal,
txPath,
]);
const tx = useMemo(() => txPath, [txPath]);

// const tx = useMemo(() => (targetToken === Asset.RBTC ? txPath : txExternal), [
// targetToken,
// txExternal,
// txPath,
// ]);

const send = useCallback(() => sendPath(), [sendPath]);
// const send = useCallback(
// () => (targetToken === Asset.RBTC ? sendPath() : sendExternal()),
// [targetToken, sendPath, sendExternal],
// );

const send = useCallback(
() => (targetToken === Asset.RBTC ? sendPath() : sendExternal()),
[targetToken, sendPath, sendExternal],
);
const showToast = useCallback(
(status: string) => {
Toast(
13 changes: 4 additions & 9 deletions yarn.lock
Original file line number Diff line number Diff line change
@@ -10259,15 +10259,10 @@ caniuse-api@^3.0.0:
lodash.memoize "^4.1.2"
lodash.uniq "^4.5.0"

caniuse-lite@^1.0.0, caniuse-lite@^1.0.30000981, caniuse-lite@^1.0.30001109, caniuse-lite@^1.0.30001125, caniuse-lite@^1.0.30001181, caniuse-lite@^1.0.30001248, caniuse-lite@^1.0.30001287:
version "1.0.30001319"
resolved "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001319.tgz"
integrity sha512-xjlIAFHucBRSMUo1kb5D4LYgcN1M45qdKP++lhqowDpwJwGkpIRTt5qQqnhxjj1vHcI7nrJxWhCC1ATrCEBTcw==

caniuse-lite@^1.0.30001317:
version "1.0.30001327"
resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001327.tgz#c1546d7d7bb66506f0ccdad6a7d07fc6d668c858"
integrity sha512-1/Cg4jlD9qjZzhbzkzEaAC2JHsP0WrOc8Rd/3a3LuajGzGWR/hD7TVyvq99VqmTy99eVh8Zkmdq213OgvgXx7w==
caniuse-lite@^1.0.0, caniuse-lite@^1.0.30000981, caniuse-lite@^1.0.30001109, caniuse-lite@^1.0.30001125, caniuse-lite@^1.0.30001181, caniuse-lite@^1.0.30001248, caniuse-lite@^1.0.30001287, caniuse-lite@^1.0.30001317:
version "1.0.30001416"
resolved "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001416.tgz"
integrity sha512-06wzzdAkCPZO+Qm4e/eNghZBDfVNDsCgw33T27OwBH9unE9S478OYw//Q2L7Npf/zBzs7rjZOszIFQkwQKAEqA==

capital-case@^1.0.4:
version "1.0.4"

0 comments on commit 123a370

Please sign in to comment.