From 8e1615aeb028c9d45b20884f80fc68d1540e3b88 Mon Sep 17 00:00:00 2001 From: swiftcc624 Date: Sun, 22 Dec 2024 12:03:04 +0800 Subject: [PATCH 01/33] refactor icon balances --- .../LiquidityDetails/WithdrawPanel.tsx | 5 +- apps/web/src/store/mint/hooks.tsx | 2 +- apps/web/src/store/wallet/hooks.ts | 243 ++++-------------- packages/xwagmi/src/hooks/useXBalances.ts | 2 +- .../src/xchains/icon/IconXPublicClient.ts | 34 +++ 5 files changed, 87 insertions(+), 199 deletions(-) diff --git a/apps/web/src/app/pages/trade/supply/_components/LiquidityDetails/WithdrawPanel.tsx b/apps/web/src/app/pages/trade/supply/_components/LiquidityDetails/WithdrawPanel.tsx index a43409c73..291b063f6 100644 --- a/apps/web/src/app/pages/trade/supply/_components/LiquidityDetails/WithdrawPanel.tsx +++ b/apps/web/src/app/pages/trade/supply/_components/LiquidityDetails/WithdrawPanel.tsx @@ -107,10 +107,7 @@ export function getShareReward( export const WithdrawPanel = ({ pair, balance, poolId }: { pair: Pair; balance: BalanceData; poolId: number }) => { const { account } = useIconReact(); - const balances = useCurrencyBalances( - account ?? undefined, - useMemo(() => [pair.token0, pair.token1], [pair]), - ); + const balances = useCurrencyBalances(useMemo(() => [pair.token0, pair.token1], [pair])); const onChangeWithdrawnValue = useChangeWithdrawnValue(); const [{ typedValue, independentField, inputType, portion }, setState] = React.useState<{ diff --git a/apps/web/src/store/mint/hooks.tsx b/apps/web/src/store/mint/hooks.tsx index 02dc72f68..72ffea86f 100644 --- a/apps/web/src/store/mint/hooks.tsx +++ b/apps/web/src/store/mint/hooks.tsx @@ -189,7 +189,7 @@ export function useDerivedMintInfo( // balances const currencyArr = React.useMemo(() => [currencies[Field.CURRENCY_A], currencies[Field.CURRENCY_B]], [currencies]); - const balances = useCurrencyBalances(account ?? undefined, currencyArr); + const balances = useCurrencyBalances(currencyArr); const currencyBalances: { [field in Field]?: CurrencyAmount } = React.useMemo(() => { const currencyABalance = balances[0]; const currencyBBalance = balances[1]; diff --git a/apps/web/src/store/wallet/hooks.ts b/apps/web/src/store/wallet/hooks.ts index b03b6d2e4..5311e2970 100644 --- a/apps/web/src/store/wallet/hooks.ts +++ b/apps/web/src/store/wallet/hooks.ts @@ -1,25 +1,15 @@ -import React, { useMemo } from 'react'; +import React, { useEffect, useMemo } from 'react'; import { useIconReact } from '@/packages/icon-react'; import { BalancedJs, CallData } from '@balancednetwork/balanced-js'; import { Currency, CurrencyAmount, Token } from '@balancednetwork/sdk-core'; import { Pair } from '@balancednetwork/v1-sdk'; -import { useQuery } from '@tanstack/react-query'; import BigNumber from 'bignumber.js'; -import { Validator } from 'icon-sdk-js'; import { forEach } from 'lodash-es'; import { useDispatch, useSelector } from 'react-redux'; import { MINIMUM_ICX_FOR_TX } from '@/constants/index'; -import { BIGINT_ZERO } from '@/constants/misc'; -import { - COMBINED_TOKENS_LIST, - SUPPORTED_TOKENS_LIST, - SUPPORTED_TOKENS_MAP_BY_ADDRESS, - isBALN, - isFIN, - isNativeCurrency, -} from '@/constants/tokens'; +import { COMBINED_TOKENS_LIST, SUPPORTED_TOKENS_LIST } from '@/constants/tokens'; import { useBnJsContractQuery } from '@/queries/utils'; import { useTokenListConfig } from '@/store/lists/hooks'; import { useAllTransactions } from '@/store/transactions/hooks'; @@ -66,65 +56,30 @@ export function useWalletBalances(xChainId: XChainId): { [address: string]: Curr return useSelector((state: AppState) => state.wallet[xChainId]); } -export function useAvailableBalances( - account: string | undefined, - tokens: Token[], -): { - [key: string]: CurrencyAmount; -} { - const balances = useCurrencyBalances(account || undefined, tokens); - - return React.useMemo(() => { - return balances.reduce((acc, balance) => { - if (!balance) return acc; - if (!(balance.quotient > BIGINT_ZERO) && balance.currency.wrapped.address !== bnJs.BALN.address) { - return acc; - } - acc[balance.currency.wrapped.address] = balance; - - return acc; - }, {}); - }, [balances]); -} - export function useWalletFetchBalances() { const dispatch = useDispatch(); + + // fetch balances on icon const tokenListConfig = useTokenListConfig(); const userAddedTokens = useUserAddedTokens(); - - const tokens = useMemo(() => { + const iconTokens = useMemo(() => { return tokenListConfig.community ? [...COMBINED_TOKENS_LIST, ...userAddedTokens] : [...SUPPORTED_TOKENS_LIST, ...userAddedTokens]; }, [userAddedTokens, tokenListConfig]); - - // fetch balances on icon - const { account } = useIconReact(); - const balances = useAvailableBalances(account || undefined, tokens); - //convert balances to {[key: string]: CurrencyAmount} - const xBalances = React.useMemo(() => { - return Object.entries(balances).reduce( - (acc, [address, balance]) => { - const currency = balance.currency as Token; - acc[address] = CurrencyAmount.fromRawAmount( - new XToken( - '0x1.icon', - currency.chainId, - currency.address, - balance.currency.decimals, - balance.currency.symbol, - ), - balance.quotient.toString(), - ); - return acc; - }, - {} as { [key: string]: CurrencyAmount }, - ); - }, [balances]); - - React.useEffect(() => { - dispatch(changeBalances({ xChainId: '0x1.icon', balances: xBalances })); - }, [xBalances, dispatch]); + const iconXTokens = useMemo( + () => iconTokens.map(token => new XToken('0x1.icon', token.chainId, token.address, token.decimals, token.symbol)), + [iconTokens], + ); + const { account: accountIcon } = useIconReact(); + const { data: balancesIcon } = useXBalances({ + xChainId: '0x1.icon', + xTokens: iconXTokens, + address: accountIcon, + }); + useEffect(() => { + balancesIcon && dispatch(changeBalances({ xChainId: '0x1.icon', balances: balancesIcon })); + }, [balancesIcon, dispatch]); // fetch balances on havah const { address: accountHavah } = useXAccount('HAVAH'); @@ -134,7 +89,7 @@ export function useWalletFetchBalances() { xTokens: havahTokens, address: accountHavah, }); - React.useEffect(() => { + useEffect(() => { balancesHavah && dispatch(changeBalances({ xChainId: '0x100.icon', balances: balancesHavah })); }, [balancesHavah, dispatch]); @@ -147,7 +102,7 @@ export function useWalletFetchBalances() { address: accountArch, }); - React.useEffect(() => { + useEffect(() => { balancesArch && dispatch(changeBalances({ xChainId: 'archway-1', balances: balancesArch })); }, [balancesArch, dispatch]); @@ -159,7 +114,7 @@ export function useWalletFetchBalances() { xTokens: avaxTokens, address, }); - React.useEffect(() => { + useEffect(() => { avaxBalances && dispatch(changeBalances({ xChainId: '0xa86a.avax', balances: avaxBalances })); }, [avaxBalances, dispatch]); @@ -170,7 +125,7 @@ export function useWalletFetchBalances() { xTokens: bscTokens, address, }); - React.useEffect(() => { + useEffect(() => { bscBalances && dispatch(changeBalances({ xChainId: '0x38.bsc', balances: bscBalances })); }, [bscBalances, dispatch]); @@ -181,7 +136,7 @@ export function useWalletFetchBalances() { xTokens: arbTokens, address, }); - React.useEffect(() => { + useEffect(() => { arbBalances && dispatch(changeBalances({ xChainId: '0xa4b1.arbitrum', balances: arbBalances })); }, [arbBalances, dispatch]); @@ -192,7 +147,7 @@ export function useWalletFetchBalances() { xTokens: optTokens, address, }); - React.useEffect(() => { + useEffect(() => { optBalances && dispatch(changeBalances({ xChainId: '0xa.optimism', balances: optBalances })); }, [optBalances, dispatch]); @@ -203,7 +158,7 @@ export function useWalletFetchBalances() { xTokens: baseTokens, address, }); - React.useEffect(() => { + useEffect(() => { baseBalances && dispatch(changeBalances({ xChainId: '0x2105.base', balances: baseBalances })); }, [baseBalances, dispatch]); @@ -215,7 +170,7 @@ export function useWalletFetchBalances() { xTokens: injectiveTokens, address: accountInjective, }); - React.useEffect(() => { + useEffect(() => { injectiveBalances && dispatch(changeBalances({ xChainId: 'injective-1', balances: injectiveBalances })); }, [injectiveBalances, dispatch]); @@ -227,7 +182,7 @@ export function useWalletFetchBalances() { xTokens: stellarTokens, address: accountStellar, }); - React.useEffect(() => { + useEffect(() => { stellarBalances && dispatch(changeBalances({ xChainId: stellar.xChainId, balances: stellarBalances })); }, [stellarBalances, dispatch]); @@ -239,7 +194,7 @@ export function useWalletFetchBalances() { xTokens: suiTokens, address: accountSui, }); - React.useEffect(() => { + useEffect(() => { suiBalances && dispatch(changeBalances({ xChainId: 'sui', balances: suiBalances })); }, [suiBalances, dispatch]); @@ -251,7 +206,7 @@ export function useWalletFetchBalances() { xTokens: solanaTokens, address: accountSolana, }); - React.useEffect(() => { + useEffect(() => { solanaBalances && dispatch(changeBalances({ xChainId: 'solana', balances: solanaBalances })); }, [solanaBalances, dispatch]); } @@ -262,7 +217,7 @@ export const useBALNDetails = (): { [key in string]?: BigNumber } => { const [details, setDetails] = React.useState({}); // biome-ignore lint/correctness/useExhaustiveDependencies: - React.useEffect(() => { + useEffect(() => { const fetchDetails = async () => { if (account) { const result = await bnJs.BALN.balanceOf(account); @@ -285,48 +240,22 @@ export const useHasEnoughICX = () => { return balances[icxAddress] && balances[icxAddress].greaterThan(MINIMUM_ICX_FOR_TX); }; -export function useTokenBalances( - account: string | undefined, - tokens: Token[], -): { [address: string]: CurrencyAmount | undefined } { - const { data } = useQuery<{ [address: string]: CurrencyAmount } | undefined>({ - queryKey: [account, tokens], - queryFn: async () => { - if (!account) return; - if (tokens.length === 0) return; - - const cds: CallData[] = tokens.map(token => { - return { - target: token.address, - method: 'balanceOf', - params: [account], - }; - }); - - const data: any[] = await bnJs.Multicall.getAggregateData(cds.filter(cd => cd.target.startsWith('cx'))); - - return tokens.reduce((agg, token, idx) => { - const balance = data[idx]; - - if (balance) agg[token.address] = CurrencyAmount.fromRawAmount(token, String(balance)); - else agg[token.address] = CurrencyAmount.fromRawAmount(token, 0); - - return agg; - }, {}); - }, - enabled: Boolean(account && tokens && tokens.length > 0), - refetchInterval: 5_000, - }); - - return useMemo(() => data || {}, [data]); -} - export function useAllTokenBalances(account: string | undefined | null): { - [tokenAddress: string]: CurrencyAmount | undefined; + [tokenAddress: string]: CurrencyAmount | undefined; } { const allTokens = useAllTokens(); const allTokensArray = useMemo(() => Object.values(allTokens ?? {}), [allTokens]); - const balances = useTokenBalances(account ?? undefined, allTokensArray); + const iconXTokens = useMemo( + () => + allTokensArray.map(token => new XToken('0x1.icon', token.chainId, token.address, token.decimals, token.symbol)), + [allTokensArray], + ); + + const { data: balances } = useXBalances({ + xChainId: '0x1.icon', + xTokens: iconXTokens, + address: account ?? undefined, + }); return balances ?? {}; } @@ -358,87 +287,15 @@ export const useXCurrencyBalance = ( }, [xBalances, currency, selectedChainId]); }; -export function useCurrencyBalances( - account: string | undefined, - currencies: (Currency | undefined)[], -): (CurrencyAmount | undefined)[] { - const tokens = useMemo( - () => - (currencies?.filter((currency): currency is Token => currency?.isToken ?? false) ?? []).filter( - (token: Token) => !isNativeCurrency(token), - ), - [currencies], - ); - - const tokenBalances = useTokenBalances(account, tokens); - - const containsICX: boolean = useMemo( - () => currencies?.some(currency => isNativeCurrency(currency)) ?? false, - [currencies], - ); - const accounts = useMemo(() => (containsICX ? [account] : []), [containsICX, account]); - const icxBalance = useICXBalances(accounts); - - return React.useMemo( - () => - currencies.map(currency => { - if (!account || !currency) return undefined; - if (isNativeCurrency(currency)) return icxBalance[account]; - if (currency.isToken) return tokenBalances[currency.address]; - return undefined; - }), - [currencies, tokenBalances, icxBalance, account], - ); -} +export function useCurrencyBalances(currencies: (Currency | undefined)[]): (CurrencyAmount | undefined)[] { + const crossChainBalances = useCrossChainWalletBalances(); -export function useCurrencyBalance(account?: string, currency?: Currency): CurrencyAmount | undefined { - return useCurrencyBalances( - account, - useMemo(() => [currency], [currency]), - )[0]; -} - -export function useICXBalances(uncheckedAddresses: (string | undefined)[]): { - [address: string]: CurrencyAmount; -} { - const addresses: string[] = useMemo( - () => - uncheckedAddresses - ? uncheckedAddresses - .filter(Validator.isAddress) - .filter((a): a is string => a !== undefined) - .sort() - : [], - [uncheckedAddresses], - ); - - const ICX = SUPPORTED_TOKENS_MAP_BY_ADDRESS[bnJs.ICX.address]; - - const { data } = useQuery({ - queryKey: ['ICXBalances', addresses], - queryFn: async () => { - const balances = await Promise.all( - addresses.map(async address => { - return bnJs.ICX.balanceOf(address).then(res => res.toFixed()); - }), - ); - - return addresses.reduce( - (agg, address, idx) => { - const balance = balances[idx]; - - if (balance) agg[address] = CurrencyAmount.fromRawAmount(ICX, balance); - else agg[address] = CurrencyAmount.fromRawAmount(ICX, 0); - - return agg; - }, - {} as { [address: string]: CurrencyAmount }, - ); - }, - refetchInterval: 5_000, - }); - - return useMemo(() => data || {}, [data]); + return useMemo(() => { + return currencies.map(currency => { + if (!currency) return undefined; + return crossChainBalances['0x1.icon']?.[currency.address]; + }); + }, [crossChainBalances, currencies]); } export function useLiquidityTokenBalance(account: string | undefined | null, pair: Pair | undefined | null) { diff --git a/packages/xwagmi/src/hooks/useXBalances.ts b/packages/xwagmi/src/hooks/useXBalances.ts index 43025729d..e18f78d57 100644 --- a/packages/xwagmi/src/hooks/useXBalances.ts +++ b/packages/xwagmi/src/hooks/useXBalances.ts @@ -12,7 +12,7 @@ export function useXBalances({ }> { const xPublicClient = useXPublicClient(xChainId); return useQuery({ - queryKey: [`xBalances`, xChainId, xTokens, address], + queryKey: [`xBalances`, xChainId, xTokens.map(x => x.symbol), address], queryFn: async () => { if (!xPublicClient) { return {}; diff --git a/packages/xwagmi/src/xchains/icon/IconXPublicClient.ts b/packages/xwagmi/src/xchains/icon/IconXPublicClient.ts index 2e03b070c..62b45f9ff 100644 --- a/packages/xwagmi/src/xchains/icon/IconXPublicClient.ts +++ b/packages/xwagmi/src/xchains/icon/IconXPublicClient.ts @@ -5,6 +5,7 @@ import bnJs from './bnJs'; import { XPublicClient } from '@/core/XPublicClient'; import { XChainId, XToken } from '@/types'; import { sleep } from '@/utils'; +import { CallData } from '@balancednetwork/balanced-js'; import { CurrencyAmount } from '@balancednetwork/sdk-core'; import { TransactionStatus, @@ -54,6 +55,39 @@ export class IconXPublicClient extends XPublicClient { return Promise.resolve(undefined); } + async getBalances(address: string | undefined, xTokens: XToken[]): Promise>> { + if (!address) return {}; + + const balances = {}; + + const nativeXToken = xTokens.find(xToken => xToken.isNativeToken); + const nonNativeXTokens = xTokens.filter(xToken => !xToken.isNativeToken); + + if (nativeXToken) { + const balance = await bnJs.ICX.balanceOf(address).then(res => res.toFixed()); + balances[nativeXToken.address] = CurrencyAmount.fromRawAmount(nativeXToken, balance || 0); + } + + const cds: CallData[] = nonNativeXTokens.map(token => { + return { + target: token.address, + method: 'balanceOf', + params: [address], + }; + }); + + const data: any[] = await bnJs.Multicall.getAggregateData(cds.filter(cd => cd.target.startsWith('cx'))); + + return nonNativeXTokens.reduce((agg, token, idx) => { + const balance = data[idx]; + + if (balance) agg[token.address] = CurrencyAmount.fromRawAmount(token, String(balance)); + else agg[token.address] = CurrencyAmount.fromRawAmount(token, 0); + + return agg; + }, balances); + } + async getXCallFee(xChainId: XChainId, nid: XChainId, rollback: boolean, sources?: string[]) { const res = await bnJs.XCall.getFee(nid, rollback, sources); return BigInt(res); From e6bbcface684fc960c817fc37a0a2667b8155d21 Mon Sep 17 00:00:00 2001 From: swiftcc624 Date: Tue, 24 Dec 2024 18:10:01 +0800 Subject: [PATCH 02/33] WIP: crosschain lp - LP Panel --- .../components/CurrencyInputPanel/index.tsx | 10 +- .../trade/supply/_components/LPPanel.tsx | 25 ++- apps/web/src/app/pages/trade/supply/page.tsx | 4 +- apps/web/src/hooks/useXCallGasChecker.tsx | 3 +- apps/web/src/store/mint/hooks.tsx | 173 +++++++++++------- apps/web/src/store/mint/reducer.ts | 43 +++-- apps/web/src/store/wallet/hooks.ts | 18 +- packages/sdk-core/src/entities/xToken.ts | 29 --- packages/xwagmi/src/constants/xTokens.ts | 19 ++ 9 files changed, 184 insertions(+), 140 deletions(-) diff --git a/apps/web/src/app/components/CurrencyInputPanel/index.tsx b/apps/web/src/app/components/CurrencyInputPanel/index.tsx index b2e60fbd2..e2b3e941c 100644 --- a/apps/web/src/app/components/CurrencyInputPanel/index.tsx +++ b/apps/web/src/app/components/CurrencyInputPanel/index.tsx @@ -179,10 +179,7 @@ export default function CurrencyInputPanel({ const [xChainOptionsOpen, setXChainOptionsOpen] = React.useState(false); const xChains = useMemo( () => - currencySelectionType === CurrencySelectionType.TRADE_MINT_BASE || - currencySelectionType === CurrencySelectionType.TRADE_MINT_QUOTE - ? [] - : getSupportedXChainForToken(currency), + currencySelectionType === CurrencySelectionType.TRADE_MINT_QUOTE ? [] : getSupportedXChainForToken(currency), [currency, currencySelectionType], ); @@ -192,10 +189,7 @@ export default function CurrencyInputPanel({ if (setDefaultChain && currency?.symbol) { const xChains = - currencySelectionType === CurrencySelectionType.TRADE_MINT_BASE || - currencySelectionType === CurrencySelectionType.TRADE_MINT_QUOTE - ? [] - : getSupportedXChainForToken(currency); + currencySelectionType === CurrencySelectionType.TRADE_MINT_QUOTE ? [] : getSupportedXChainForToken(currency); const defaultXChainId = DEFAULT_TOKEN_CHAIN[currency.symbol]; if (defaultXChainId && (xChains?.length ?? 0) > 1) { onChainSelect && onChainSelect(defaultXChainId); diff --git a/apps/web/src/app/pages/trade/supply/_components/LPPanel.tsx b/apps/web/src/app/pages/trade/supply/_components/LPPanel.tsx index 1565ea48f..03a06be43 100644 --- a/apps/web/src/app/pages/trade/supply/_components/LPPanel.tsx +++ b/apps/web/src/app/pages/trade/supply/_components/LPPanel.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import React, { useCallback } from 'react'; import { useIconReact } from '@/packages/icon-react'; import Nouislider from '@/packages/nouislider-react'; @@ -134,8 +134,10 @@ export default function LPPanel() { pairState, liquidityMinted, mintableLiquidity, + lpXChainId, } = useDerivedMintInfo(crossChainCurrencyA, crossChainCurrencyB); - const { onFieldAInput, onFieldBInput, onSlide, onCurrencySelection } = useMintActionHandlers(noLiquidity); + const { onFieldAInput, onFieldBInput, onSlide, onCurrencySelection, onChainSelection } = + useMintActionHandlers(noLiquidity); const sliderInstance = React.useRef(null); @@ -177,7 +179,8 @@ export default function LPPanel() { if (balanceA && balanceB && pair && pair.reserve0 && pair.reserve1) { const p = new Percent(Math.floor(percent * 100), 10_000); - if (isNativeCurrency(currencies[Field.CURRENCY_A])) { + if (currencies[Field.CURRENCY_A]?.isNativeToken) { + // TODO: is ICX? onSlide(Field.CURRENCY_A, percent !== 0 ? balanceA.multiply(p).toFixed() : ''); } else { const field = balanceA.multiply(pair?.reserve1).lessThan(balanceB.multiply(pair?.reserve0)) @@ -213,7 +216,7 @@ export default function LPPanel() { (accumulator, field) => { return { ...accumulator, - [field]: maxAmountSpend(currencyBalances[field]), + [field]: maxAmountSpend(currencyBalances[field], lpXChainId), }; }, {}, @@ -244,6 +247,13 @@ export default function LPPanel() { const isQueue = isNativeCurrency(currencies[Field.CURRENCY_A]); + const handleLPChainSelection = useCallback( + (xChainId: XChainId) => { + onChainSelection(Field.CURRENCY_A, xChainId); + }, + [onChainSelection], + ); + return ( <> @@ -272,9 +282,10 @@ export default function LPPanel() { onUserInput={handleTypeAInput} onCurrencySelect={handleCurrencyASelect} onPercentSelect={handlePercentSelect(Field.CURRENCY_A)} - xChainId={'0x1.icon'} + xChainId={currencies[Field.CURRENCY_A]?.xChainId} + onChainSelect={handleLPChainSelection} showCrossChainOptions={true} - showCrossChainBreakdown={false} + showCrossChainBreakdown={true} selectorType={SelectorType.SUPPLY_BASE} /> @@ -290,7 +301,7 @@ export default function LPPanel() { onUserInput={handleTypeBInput} onCurrencySelect={handleCurrencyBSelect} onPercentSelect={handlePercentSelect(Field.CURRENCY_B)} - xChainId={'0x1.icon'} + xChainId={currencies[Field.CURRENCY_B]?.xChainId} showCrossChainOptions={true} showCrossChainBreakdown={false} selectorType={SelectorType.SUPPLY_QUOTE} diff --git a/apps/web/src/app/pages/trade/supply/page.tsx b/apps/web/src/app/pages/trade/supply/page.tsx index 8bc2416fe..0ed4f56c7 100644 --- a/apps/web/src/app/pages/trade/supply/page.tsx +++ b/apps/web/src/app/pages/trade/supply/page.tsx @@ -3,11 +3,11 @@ import React, { useMemo } from 'react'; import { useIconReact } from '@/packages/icon-react'; import LPPanel from './_components/LPPanel'; -import { PoolPanelContext } from './_components/PoolPanelContext'; import LiquidityPoolsPanel from './_components/LiquidityPoolsPanel'; +import { PoolPanelContext } from './_components/PoolPanelContext'; -import { useTrackedTokenPairs } from '@/store/user/hooks'; import { useAvailablePairs, useBalances } from '@/hooks/useV2Pairs'; +import { useTrackedTokenPairs } from '@/store/user/hooks'; export function SupplyPage() { const { account } = useIconReact(); diff --git a/apps/web/src/hooks/useXCallGasChecker.tsx b/apps/web/src/hooks/useXCallGasChecker.tsx index 37e1e9bc3..2cdb227c3 100644 --- a/apps/web/src/hooks/useXCallGasChecker.tsx +++ b/apps/web/src/hooks/useXCallGasChecker.tsx @@ -1,8 +1,9 @@ import { useCrossChainWalletBalances } from '@/store/wallet/hooks'; -import { Currency, CurrencyAmount, XToken } from '@balancednetwork/sdk-core'; +import { Currency, CurrencyAmount } from '@balancednetwork/sdk-core'; import { XChain, XChainId, + XToken, formatBigNumber, getNetworkDisplayName, xChainMap, diff --git a/apps/web/src/store/mint/hooks.tsx b/apps/web/src/store/mint/hooks.tsx index 72ffea86f..337ca0448 100644 --- a/apps/web/src/store/mint/hooks.tsx +++ b/apps/web/src/store/mint/hooks.tsx @@ -1,4 +1,4 @@ -import React, { useCallback, ReactNode } from 'react'; +import React, { useCallback, ReactNode, useEffect, useMemo } from 'react'; import { useIconReact } from '@/packages/icon-react'; import { Currency, CurrencyAmount, Percent, Price, Token } from '@balancednetwork/sdk-core'; @@ -8,18 +8,18 @@ import BigNumber from 'bignumber.js'; import { useDispatch, useSelector } from 'react-redux'; import { useNavigate, useParams } from 'react-router-dom'; -import { isNativeCurrency, useICX } from '@/constants/tokens'; +import { useICX } from '@/constants/tokens'; import { useAllTokens, useCommonBases } from '@/hooks/Tokens'; import { useQueuePair } from '@/hooks/useQueuePair'; import { PairState, useV2Pair } from '@/hooks/useV2Pairs'; import { tryParseAmount } from '@/store/swap/hooks'; import { useAllTransactions } from '@/store/transactions/hooks'; -import { useCurrencyBalances } from '@/store/wallet/hooks'; +import { useXTokenBalances } from '@/store/wallet/hooks'; import { formatSymbol } from '@/utils/formatter'; -import { XChainId } from '@balancednetwork/xwagmi'; +import { XChainId, XToken, xTokenMap, xTokenMapBySymbol } from '@balancednetwork/xwagmi'; import { bnJs } from '@balancednetwork/xwagmi'; import { AppDispatch, AppState } from '../index'; -import { Field, INITIAL_MINT, InputType, selectCurrency, typeInput } from './reducer'; +import { Field, INITIAL_MINT, InputType, selectChain, selectCurrency, typeInput } from './reducer'; export function useMintState(): AppState['mint'] { return useSelector(state => state.mint); @@ -30,37 +30,20 @@ export function useMintActionHandlers(noLiquidity: boolean | undefined): { onFieldAInput: (typedValue: string) => void; onFieldBInput: (typedValue: string) => void; onSlide: (field: Field, typedValue: string) => void; + onChainSelection: (field: Field, xChainId: XChainId) => void; } { const dispatch = useDispatch(); - const navigate = useNavigate(); - const { pair = '' } = useParams<{ pair: string }>(); const onCurrencySelection = useCallback( (field: Field, currency: Currency) => { dispatch( selectCurrency({ field, - currency: currency, + currency: currency instanceof XToken ? currency : xTokenMapBySymbol['0x1.icon'][currency.symbol], }), ); - - if (field === Field.CURRENCY_A) { - if (currency.symbol === 'ICX') { - // history.replace(`/trade/supply/${currency.symbol}`); - navigate(`/trade/supply/${currency.symbol}`, { replace: true }); - } else { - const currentQuote = pair.split('_')[1]; - // history.replace(`/trade/supply/${currency.symbol}` + (currentQuote ? `_${currentQuote}` : '')); - navigate(`/trade/supply/${currency.symbol}` + (currentQuote ? `_${currentQuote}` : ''), { replace: true }); - } - } - if (field === Field.CURRENCY_B) { - const currentBase = pair.split('_')[0]; - // history.replace(`/trade/supply/${currentBase}_${currency.symbol}`); - navigate(`/trade/supply/${currentBase}_${currency.symbol}`, { replace: true }); - } }, - [dispatch, pair, navigate], + [dispatch], ); const onFieldAInput = useCallback( @@ -98,11 +81,24 @@ export function useMintActionHandlers(noLiquidity: boolean | undefined): { [dispatch, noLiquidity], ); + const onChainSelection = useCallback( + (field: Field, xChainId: XChainId) => { + dispatch( + selectChain({ + field, + xChainId, + }), + ); + }, + [dispatch], + ); + return { onCurrencySelection, onFieldAInput, onFieldBInput, onSlide, + onChainSelection, }; } @@ -136,7 +132,7 @@ export function useDerivedMintInfo( BChain: XChainId = '0x1.icon', ): { dependentField: Field; - currencies: { [field in Field]?: Currency }; + currencies: { [field in Field]?: XToken }; pair?: Pair | null; pairState: PairState; currencyBalances: { [field in Field]?: CurrencyAmount }; @@ -149,6 +145,7 @@ export function useDerivedMintInfo( poolTokenPercentage?: Percent; error?: ReactNode; minQuoteTokenAmount?: BigNumber | null; + lpXChainId: XChainId; } { const { account } = useIconReact(); @@ -162,7 +159,7 @@ export function useDerivedMintInfo( const dependentField = independentField === Field.CURRENCY_A ? Field.CURRENCY_B : Field.CURRENCY_A; // tokens - const currencies: { [field in Field]?: Currency } = React.useMemo( + const currencies: { [field in Field]?: XToken } = React.useMemo( () => ({ [Field.CURRENCY_A]: currencyA ?? undefined, [Field.CURRENCY_B]: currencyB ?? undefined, @@ -170,12 +167,27 @@ export function useDerivedMintInfo( [currencyA, currencyB], ); + const currencyAOnIcon = useMemo(() => { + return currencyA ? xTokenMapBySymbol['0x1.icon'][currencyA.symbol] : undefined; + }, [currencyA]); + + const currencyBOnIcon = useMemo(() => { + return currencyB ? xTokenMapBySymbol['0x1.icon'][currencyB.symbol] : undefined; + }, [currencyB]); + + const currenciesOnIcon: { [field in Field]?: XToken } = React.useMemo(() => { + return { + [Field.CURRENCY_A]: currencyAOnIcon ?? undefined, + [Field.CURRENCY_B]: currencyBOnIcon ?? undefined, + }; + }, [currencyAOnIcon, currencyBOnIcon]); + // pair - const isQueue = isNativeCurrency(currencies[Field.CURRENCY_A]); + const isQueue = currencies[Field.CURRENCY_A]?.isNativeToken && currencies[Field.CURRENCY_A]?.xChainId === '0x1.icon'; // For queue, currencies[Field.CURRENCY_A] = ICX and currencies[Field.CURRENCY_B] = undefined // so used `useQueuePair` in addition to `useV2Pair`. - const [pairState1, pair1] = useV2Pair(currencies[Field.CURRENCY_A], currencies[Field.CURRENCY_B]); + const [pairState1, pair1] = useV2Pair(currencyAOnIcon, currencyBOnIcon); const [pairState2, pair2] = useQueuePair(); const [pairState, pair] = isQueue ? [pairState2, pair2] : [pairState1, pair1]; @@ -189,8 +201,13 @@ export function useDerivedMintInfo( // balances const currencyArr = React.useMemo(() => [currencies[Field.CURRENCY_A], currencies[Field.CURRENCY_B]], [currencies]); - const balances = useCurrencyBalances(currencyArr); - const currencyBalances: { [field in Field]?: CurrencyAmount } = React.useMemo(() => { + + const lpXChainId = useMemo(() => { + return currencies[Field.CURRENCY_A]?.xChainId || '0x1.icon'; + }, [currencies]); + + const balances = useXTokenBalances(currencyArr); + const currencyBalances: { [field in Field]?: CurrencyAmount } = React.useMemo(() => { const currencyABalance = balances[0]; const currencyBBalance = balances[1]; return { @@ -200,8 +217,8 @@ export function useDerivedMintInfo( }, [balances]); // deposits - const depositA = useCurrencyDeposit(account ?? undefined, currencyA); - const depositB = useCurrencyDeposit(account ?? undefined, currencyB); + const depositA = useCurrencyDeposit(account ?? undefined, currencyAOnIcon); + const depositB = useCurrencyDeposit(account ?? undefined, currencyBOnIcon); const currencyDeposits: { [field in Field]?: CurrencyAmount } = React.useMemo( () => ({ [Field.CURRENCY_A]: depositA, @@ -213,29 +230,27 @@ export function useDerivedMintInfo( // amounts const independentAmount: CurrencyAmount | undefined = tryParseAmount( typedValue, - currencies[independentField], + currenciesOnIcon[independentField], ); const dependentAmount: CurrencyAmount | undefined = React.useMemo(() => { if (noLiquidity) { - if (otherTypedValue && currencies[dependentField]) { - return tryParseAmount(otherTypedValue, currencies[dependentField]); + if (otherTypedValue && currenciesOnIcon[dependentField]) { + return tryParseAmount(otherTypedValue, currenciesOnIcon[dependentField]); } return undefined; } else if (independentAmount) { - // we wrap the currencies just to get the price in terms of the other token - const wrappedIndependentAmount = independentAmount?.wrapped; - const [tokenA, tokenB] = [currencyA?.wrapped, currencyB?.wrapped]; - if (tokenA && tokenB && wrappedIndependentAmount && pair) { - const dependentCurrency = dependentField === Field.CURRENCY_B ? currencyB : currencyA; + if (currencyAOnIcon && currencyBOnIcon && independentAmount && pair) { + const dependentCurrency = dependentField === Field.CURRENCY_B ? currencyBOnIcon : currencyAOnIcon; const dependentTokenAmount = dependentField === Field.CURRENCY_B - ? pair.involvesToken(tokenA) - ? pair.priceOf(tokenA).quote(wrappedIndependentAmount) - : CurrencyAmount.fromRawAmount(tokenB, 0) - : pair.involvesToken(tokenB) - ? pair.priceOf(tokenB).quote(wrappedIndependentAmount) - : CurrencyAmount.fromRawAmount(tokenA, 0); - return dependentCurrency?.isNative + ? pair.involvesToken(currencyAOnIcon) + ? pair.priceOf(currencyAOnIcon).quote(independentAmount) + : CurrencyAmount.fromRawAmount(currencyBOnIcon, 0) + : pair.involvesToken(currencyBOnIcon) + ? pair.priceOf(currencyBOnIcon).quote(independentAmount) + : CurrencyAmount.fromRawAmount(currencyAOnIcon, 0); + + return dependentCurrency.isNativeToken ? CurrencyAmount.fromRawAmount(dependentCurrency, dependentTokenAmount.quotient) : dependentTokenAmount; } @@ -243,7 +258,16 @@ export function useDerivedMintInfo( } else { return undefined; } - }, [noLiquidity, otherTypedValue, currencies, dependentField, independentAmount, currencyA, currencyB, pair]); + }, [ + noLiquidity, + otherTypedValue, + dependentField, + independentAmount, + pair, + currenciesOnIcon, + currencyAOnIcon, + currencyBOnIcon, + ]); const parsedAmounts: { [field in Field]: CurrencyAmount | undefined } = React.useMemo(() => { return { @@ -261,12 +285,9 @@ export function useDerivedMintInfo( } return undefined; } else { - const wrappedCurrencyA = currencyA?.wrapped; - return pair && wrappedCurrencyA && pair.involvesToken(wrappedCurrencyA) - ? pair.priceOf(wrappedCurrencyA) - : undefined; + return pair && currencyAOnIcon && pair.involvesToken(currencyAOnIcon) ? pair.priceOf(currencyAOnIcon) : undefined; } - }, [currencyA, noLiquidity, pair, parsedAmounts]); + }, [currencyAOnIcon, noLiquidity, pair, parsedAmounts]); // liquidity minted const liquidityMinted = React.useMemo(() => { @@ -298,15 +319,22 @@ export function useDerivedMintInfo( // mintable liquidity by using balances const mintableLiquidity = React.useMemo(() => { - const { [Field.CURRENCY_A]: currencyAAmount, [Field.CURRENCY_B]: currencyBAmount } = currencyBalances; + const { [Field.CURRENCY_A]: currencyAAmount, [Field.CURRENCY_B]: currencyBAmount } = { + [Field.CURRENCY_A]: currencyBalances[Field.CURRENCY_A] + ? CurrencyAmount.fromRawAmount(currencyAOnIcon, currencyBalances[Field.CURRENCY_A]?.quotient) + : undefined, + [Field.CURRENCY_B]: currencyBalances[Field.CURRENCY_B] + ? CurrencyAmount.fromRawAmount(currencyBOnIcon, currencyBalances[Field.CURRENCY_B]?.quotient) + : undefined, + }; + const [tokenAmountA, tokenAmountB] = [currencyAAmount?.wrapped, currencyBAmount?.wrapped]; if ( pair && totalSupply && tokenAmountA && tokenAmountB && - ((pair.token0.symbol as string) === (tokenAmountA.currency.symbol as string) || - (pair.token1.symbol as string) === (tokenAmountA.currency.symbol as string)) && + pair.involvesToken(tokenAmountA.currency) && pair.involvesToken(tokenAmountB.currency) && !tokenAmountA.currency.equals(tokenAmountB.currency) ) { @@ -323,7 +351,7 @@ export function useDerivedMintInfo( } else { return undefined; } - }, [currencyBalances, pair, totalSupply]); + }, [currencyBalances, pair, totalSupply, currencyAOnIcon, currencyBOnIcon]); const poolTokenPercentage = React.useMemo(() => { if (liquidityMinted && totalSupply) { @@ -382,6 +410,7 @@ export function useDerivedMintInfo( mintableLiquidity, poolTokenPercentage, error, + lpXChainId, }; } @@ -399,26 +428,34 @@ export function useInitialSupplyLoad(): void { if (firstLoad && Object.values(tokens).length > 0 && Object.values(bases).length > 0) { const tokensArray = Object.values(tokens); const basesArray = Object.values(bases); - const currentCurrA = pair.split('_')[0]; + + const validXChainIds = Object.keys(xTokenMap); + + const [currentCurrA, xChainIdStr] = pair.split('_')[0].split(':'); + const xChainId: XChainId = validXChainIds.includes(xChainIdStr) ? (xChainIdStr as XChainId) : '0x1.icon'; const currentCurrB = pair.split('_')[1]; const currencyB = currentCurrB && basesArray.find(token => token.symbol?.toLowerCase() === currentCurrB?.toLocaleLowerCase()); const currencyA = currentCurrA && tokensArray.find(token => token.symbol?.toLowerCase() === currentCurrA?.toLowerCase()); if (currencyB && currencyA) { - onCurrencySelection(Field.CURRENCY_A, currencyA); - onCurrencySelection(Field.CURRENCY_B, currencyB); + onCurrencySelection(Field.CURRENCY_A, xTokenMapBySymbol[xChainId][currencyA.symbol]); + onCurrencySelection(Field.CURRENCY_B, xTokenMapBySymbol[xChainId][currencyB.symbol]); } else if (currentCurrA?.toLowerCase() === 'icx') { - ICX && onCurrencySelection(Field.CURRENCY_A, ICX); + ICX && onCurrencySelection(Field.CURRENCY_A, xTokenMapBySymbol[xChainId][ICX.symbol]); } else { if (currencies.CURRENCY_A && currencies.CURRENCY_B) { - // history.replace(`/trade/supply/${currencies.CURRENCY_A.symbol}_${currencies.CURRENCY_B.symbol}`); - navigate(`/trade/supply/${currencies.CURRENCY_A.symbol}_${currencies.CURRENCY_B.symbol}`, { replace: true }); + navigate( + `/trade/supply/${currencies.CURRENCY_A.symbol}:${currencies.CURRENCY_A.xChainId}_${currencies.CURRENCY_B.symbol}`, + { replace: true }, + ); } else { - // history.replace(`/trade/supply/${INITIAL_MINT.currencyA.symbol}_${INITIAL_MINT.currencyB.symbol}`); - navigate(`/trade/supply/${INITIAL_MINT.currencyA.symbol}_${INITIAL_MINT.currencyB.symbol}`, { - replace: true, - }); + navigate( + `/trade/supply/${INITIAL_MINT.currencyA.symbol}:${INITIAL_MINT.currencyA.xChainId}_${INITIAL_MINT.currencyB.symbol}`, + { + replace: true, + }, + ); } } setFirstLoad(false); diff --git a/apps/web/src/store/mint/reducer.ts b/apps/web/src/store/mint/reducer.ts index 6c819cea7..a69017856 100644 --- a/apps/web/src/store/mint/reducer.ts +++ b/apps/web/src/store/mint/reducer.ts @@ -1,8 +1,8 @@ -import { Currency } from '@balancednetwork/sdk-core'; +import { XChainId } from '@balancednetwork/sdk-core'; import { createSlice } from '@reduxjs/toolkit'; -import { NETWORK_ID } from '@/constants/config'; -import { bnUSD, sICX } from '@/constants/tokens'; +import { getXTokenBySymbol } from '@/utils/xTokens'; +import { XToken, xTokenMapBySymbol } from '@balancednetwork/xwagmi'; export enum Field { CURRENCY_A = 'CURRENCY_A', @@ -20,17 +20,17 @@ export interface MintState { readonly otherTypedValue: string; readonly inputType: InputType; readonly [Field.CURRENCY_A]: { - readonly currency: Currency | undefined; + readonly currency: XToken | undefined; readonly percent: number; }; readonly [Field.CURRENCY_B]: { - readonly currency: Currency | undefined; + readonly currency: XToken | undefined; }; } export const INITIAL_MINT = { - currencyA: sICX[NETWORK_ID], - currencyB: bnUSD[NETWORK_ID], + currencyA: xTokenMapBySymbol['0x1.icon']['sICX'], + currencyB: xTokenMapBySymbol['0x1.icon']['bnUSD'], }; const initialState: MintState = { @@ -85,28 +85,27 @@ const mintSlice = createSlice({ } }, ), - selectCurrency: create.reducer<{ currency: Currency; field: Field }>((state, { payload: { currency, field } }) => { - // const otherField = field === Field.CURRENCY_A ? Field.CURRENCY_B : Field.CURRENCY_A; - - // if (currency === state[otherField].currency) { - // // the case where we have to swap the order - // return { - // ...state, - // independentField: state.independentField === Field.CURRENCY_A ? Field.CURRENCY_B : Field.CURRENCY_A, - // [field]: { ...state[field], currency: currency, percent: 0 }, - // [otherField]: { ...state[otherField], currency: state[field].currency, percent: 0 }, - // }; - // } else { - // the normal case + selectCurrency: create.reducer<{ currency: XToken; field: Field }>((state, { payload: { currency, field } }) => { return { ...state, [field]: { ...state[field], currency: currency, percent: 0 }, }; - // } + }), + + selectChain: create.reducer<{ field: Field; xChainId: XChainId }>((state, { payload: { field, xChainId } }) => { + const updatedCurrencyA = getXTokenBySymbol(xChainId, state[Field.CURRENCY_A].currency?.symbol); + if (updatedCurrencyA) { + state[Field.CURRENCY_A].currency = updatedCurrencyA; + + const updatedCurrencyB = getXTokenBySymbol(xChainId, state[Field.CURRENCY_B].currency?.symbol); + if (updatedCurrencyB.xChainId !== state[Field.CURRENCY_B].currency?.xChainId) { + state[Field.CURRENCY_B].currency = updatedCurrencyB; + } + } }), }), }); -export const { resetMintState, typeInput, selectCurrency } = mintSlice.actions; +export const { resetMintState, typeInput, selectCurrency, selectChain } = mintSlice.actions; export default mintSlice.reducer; diff --git a/apps/web/src/store/wallet/hooks.ts b/apps/web/src/store/wallet/hooks.ts index 5311e2970..4512d4bb1 100644 --- a/apps/web/src/store/wallet/hooks.ts +++ b/apps/web/src/store/wallet/hooks.ts @@ -287,15 +287,27 @@ export const useXCurrencyBalance = ( }, [xBalances, currency, selectedChainId]); }; +export function useXTokenBalances(xTokens: (XToken | undefined)[]): (CurrencyAmount | undefined)[] { + const walletState = useSelector((state: AppState) => state.wallet); + + return useMemo(() => { + return xTokens.map(xToken => { + if (!xToken) return undefined; + return walletState[xToken.xChainId]?.[xToken.address]; + }); + }, [xTokens, walletState]); +} + +// TODO: deprecate export function useCurrencyBalances(currencies: (Currency | undefined)[]): (CurrencyAmount | undefined)[] { - const crossChainBalances = useCrossChainWalletBalances(); + const walletState = useSelector((state: AppState) => state.wallet); return useMemo(() => { return currencies.map(currency => { if (!currency) return undefined; - return crossChainBalances['0x1.icon']?.[currency.address]; + return walletState['0x1.icon']?.[currency.address]; }); - }, [crossChainBalances, currencies]); + }, [walletState, currencies]); } export function useLiquidityTokenBalance(account: string | undefined | null, pair: Pair | undefined | null) { diff --git a/packages/sdk-core/src/entities/xToken.ts b/packages/sdk-core/src/entities/xToken.ts index 3ddc65377..1a719b5d5 100644 --- a/packages/sdk-core/src/entities/xToken.ts +++ b/packages/sdk-core/src/entities/xToken.ts @@ -1,5 +1,3 @@ -import { Token } from './token'; - export type XChainId = | 'archway-1' | 'archway' @@ -18,30 +16,3 @@ export type XChainId = | 'solana'; export type XChainType = 'ICON' | 'EVM' | 'ARCHWAY' | 'HAVAH' | 'INJECTIVE' | 'SUI' | 'STELLAR' | 'SOLANA'; - -export class XToken extends Token { - xChainId: XChainId; - identifier: string; - - public constructor( - xChainId: XChainId, - chainId: number | string, - address: string, - decimals: number, - symbol: string, - name?: string, - identifier?: string, - ) { - super(chainId, address, decimals, symbol, name); - this.xChainId = xChainId; - this.identifier = identifier || symbol; - } - - static getXToken(xChainId: XChainId, token: Token) { - return new XToken(xChainId, token.chainId, token.address, token.decimals, token.symbol, token.name); - } - - isNativeXToken() { - return this.address.includes('native'); - } -} diff --git a/packages/xwagmi/src/constants/xTokens.ts b/packages/xwagmi/src/constants/xTokens.ts index 832bdbac2..c64d700d4 100644 --- a/packages/xwagmi/src/constants/xTokens.ts +++ b/packages/xwagmi/src/constants/xTokens.ts @@ -311,6 +311,25 @@ export const xTokenMap: { [key in XChainId]: XToken[] } = { ], }; +type XTokenMapBySymbol = { + [key in XChainId]: { + [symbol: string]: XToken; + }; +}; + +export const xTokenMapBySymbol: XTokenMapBySymbol = Object.fromEntries( + Object.entries(xTokenMap).map(([chainId, tokens]) => [ + chainId, + tokens.reduce( + (acc, token) => { + acc[token.symbol] = token; + return acc; + }, + {} as { [symbol: string]: XToken }, + ), + ]), +) as XTokenMapBySymbol; + export const allXTokens = Object.values(xTokenMap).reduce((acc, xTokens) => { return acc.concat(xTokens); }, []); From 833f39cb4fd5f0d887fa645ea90cb3464e461211 Mon Sep 17 00:00:00 2001 From: swiftcc624 Date: Fri, 3 Jan 2025 23:38:59 +0800 Subject: [PATCH 03/33] crosschain lp - send/remove token, add liquidity --- .../trade/supply/_components/LPPanel.tsx | 2 - .../supply/_components/SendRemoveXToken.tsx | 191 +++++++++ .../_components/SupplyLiquidityModal.tsx | 382 ++++-------------- packages/balanced-js/src/contracts/Dex.ts | 11 + packages/xwagmi/src/core/XLiquidityService.ts | 14 + packages/xwagmi/src/hooks/index.ts | 2 + packages/xwagmi/src/hooks/liquidity/index.ts | 4 + .../src/hooks/liquidity/useDepositXToken.ts | 34 ++ .../src/hooks/liquidity/useWithdrawXToken.ts | 34 ++ .../src/hooks/liquidity/useXAddLiquidity.ts | 31 ++ .../hooks/liquidity/useXTokenDepositAmount.ts | 37 ++ .../xwagmi/src/hooks/useSendXTransaction.ts | 82 ++++ packages/xwagmi/src/index.ts | 1 + packages/xwagmi/src/xcall/types.ts | 9 + .../src/xcall/zustand/useTransactionStore.tsx | 2 +- .../src/xchains/evm/EvmXLiquidityService.ts | 165 ++++++++ .../src/xchains/evm/EvmXWalletClient.ts | 83 ++-- packages/xwagmi/src/xchains/evm/index.ts | 3 + packages/xwagmi/src/xchains/evm/utils.ts | 0 19 files changed, 744 insertions(+), 343 deletions(-) create mode 100644 apps/web/src/app/pages/trade/supply/_components/SendRemoveXToken.tsx create mode 100644 packages/xwagmi/src/core/XLiquidityService.ts create mode 100644 packages/xwagmi/src/hooks/liquidity/index.ts create mode 100644 packages/xwagmi/src/hooks/liquidity/useDepositXToken.ts create mode 100644 packages/xwagmi/src/hooks/liquidity/useWithdrawXToken.ts create mode 100644 packages/xwagmi/src/hooks/liquidity/useXAddLiquidity.ts create mode 100644 packages/xwagmi/src/hooks/liquidity/useXTokenDepositAmount.ts create mode 100644 packages/xwagmi/src/hooks/useSendXTransaction.ts create mode 100644 packages/xwagmi/src/xchains/evm/EvmXLiquidityService.ts create mode 100644 packages/xwagmi/src/xchains/evm/utils.ts diff --git a/apps/web/src/app/pages/trade/supply/_components/LPPanel.tsx b/apps/web/src/app/pages/trade/supply/_components/LPPanel.tsx index 03a06be43..ed2124171 100644 --- a/apps/web/src/app/pages/trade/supply/_components/LPPanel.tsx +++ b/apps/web/src/app/pages/trade/supply/_components/LPPanel.tsx @@ -387,8 +387,6 @@ export default function LPPanel() { onClose={handleSupplyConfirmDismiss} parsedAmounts={amounts} currencies={currencies} - AChain={crossChainCurrencyA} - BChain={crossChainCurrencyB} /> ); diff --git a/apps/web/src/app/pages/trade/supply/_components/SendRemoveXToken.tsx b/apps/web/src/app/pages/trade/supply/_components/SendRemoveXToken.tsx new file mode 100644 index 000000000..db817dabd --- /dev/null +++ b/apps/web/src/app/pages/trade/supply/_components/SendRemoveXToken.tsx @@ -0,0 +1,191 @@ +import React, { useEffect } from 'react'; + +import { useIconReact } from '@/packages/icon-react'; +import { t } from '@lingui/macro'; +import { Box, Flex } from 'rebass/styled-components'; +import styled from 'styled-components'; + +import { Button } from '@/app/components/Button'; +import { Typography } from '@/app/theme'; +import CheckIcon from '@/assets/icons/tick.svg'; +import { useEditState } from '@/store/liveVoting/hooks'; +import { Field } from '@/store/mint/reducer'; +import { Currency, CurrencyAmount } from '@balancednetwork/sdk-core'; +import { + XToken, + XTransactionStatus, + getXChainType, + useDepositXToken, + useWithdrawXToken, + useXAccount, + useXTokenDepositAmount, + useXTransactionStore, +} from '@balancednetwork/xwagmi'; + +interface SendRemoveXTokenProps { + field: Field; + parsedAmounts: { [field in Field]?: CurrencyAmount }; + currencies: { [field in Field]?: XToken }; +} + +export function SendRemoveXToken({ field, currencies, parsedAmounts }: SendRemoveXTokenProps) { + const [isPending, setIsPending] = React.useState(false); + const [pendingTx, setPendingTx] = React.useState(''); + + const currentXTransaction = useXTransactionStore(state => state.transactions[pendingTx]); + + useEffect(() => { + if ( + currentXTransaction?.status === XTransactionStatus.success || + currentXTransaction?.status === XTransactionStatus.failure + ) { + refetchDepositAmount() + .then(() => { + setIsPending(false); + }) + .catch(() => { + setIsPending(false); + }); + } + }, [currentXTransaction]); + + const xToken = currencies[field]; + const parsedAmount = parsedAmounts[field]; + + const xAccount = useXAccount(getXChainType(xToken?.xChainId)); + + const { depositAmount, refetchDepositAmount } = useXTokenDepositAmount(xAccount.address, xToken); + + const depositXToken = useDepositXToken(); + const withdrawXToken = useWithdrawXToken(); + + const handleAdd = async () => { + console.log('add'); + + if (!parsedAmount || !xToken || !xAccount) { + return; + } + + setIsPending(true); + + try { + const txHash = await depositXToken(xAccount.address, parsedAmount, xToken); + if (txHash) setPendingTx(txHash); + else setIsPending(false); + } catch (error) { + console.error('error', error); + setIsPending(false); + } + + // setIsPending(false); + }; + + const handleRemove = async () => { + console.log('remove'); + if (!parsedAmount || !xToken || !xAccount) { + return; + } + + setIsPending(true); + + try { + const txHash = await withdrawXToken(xAccount.address, parsedAmount, xToken); + if (txHash) setPendingTx(txHash); + else setIsPending(false); + } catch (error) { + console.error('error', error); + setIsPending(false); + } + }; + + const isDeposited = depositAmount && depositAmount.greaterThan(0); + + return ( + + ); +} + +const SupplyButton = styled(Button)` + padding: 5px 10px; + font-size: 12px; +`; + +const RemoveButton = styled(SupplyButton)` + background-color: transparent; + font-size: 14px; + color: #fb6a6a; + padding-top: 4px; + padding-bottom: 4px; + margin-top: 6px; + margin-bottom: 4px; + + &:hover { + background-color: transparent; + } + + &:disabled { + color: #fb6a6a; + background-color: transparent; + } +`; + +const StyledDL = styled.dl` + margin: 15px 0 15px 0; + text-align: center; +`; + +const StyledEmpty = styled.dl` + padding: 18px 0 18px 0; + text-align: center; +`; + +const CheckIconWrapper = styled.div` + padding-top: 16px; + padding-bottom: 16px; + display: block; + margin: auto; + width: 25px; +`; diff --git a/apps/web/src/app/pages/trade/supply/_components/SupplyLiquidityModal.tsx b/apps/web/src/app/pages/trade/supply/_components/SupplyLiquidityModal.tsx index 44897d4fd..4713341bc 100644 --- a/apps/web/src/app/pages/trade/supply/_components/SupplyLiquidityModal.tsx +++ b/apps/web/src/app/pages/trade/supply/_components/SupplyLiquidityModal.tsx @@ -1,7 +1,6 @@ import React from 'react'; import { useIconReact } from '@/packages/icon-react'; -import { BalancedJs } from '@balancednetwork/balanced-js'; import { Currency, CurrencyAmount, Token } from '@balancednetwork/sdk-core'; import { Trans, t } from '@lingui/macro'; import { Box, Flex } from 'rebass/styled-components'; @@ -9,9 +8,8 @@ import styled from 'styled-components'; import { Button, TextButton } from '@/app/components/Button'; import Modal from '@/app/components/Modal'; -import ModalContent, { ModalContentWrapper } from '@/app/components/ModalContent'; +import ModalContent from '@/app/components/ModalContent'; import { Typography } from '@/app/theme'; -import CheckIcon from '@/assets/icons/tick.svg'; import { DEFAULT_SLIPPAGE_LP } from '@/constants/index'; import { useDerivedMintInfo } from '@/store/mint/hooks'; import { Field } from '@/store/mint/reducer'; @@ -19,135 +17,81 @@ import { TransactionStatus, useTransactionAdder, useTransactionStatus } from '@/ import { useHasEnoughICX } from '@/store/wallet/hooks'; import { toDec } from '@/utils'; import { showMessageOnBeforeUnload } from '@/utils/messages'; -import { XChainId } from '@balancednetwork/xwagmi'; -import { bnJs } from '@balancednetwork/xwagmi'; -import { depositMessage, supplyMessage } from './utils'; +import { + XToken, + bnJs, + getXChainType, + useXAccount, + useXAddLiquidity, + useXTokenDepositAmount, +} from '@balancednetwork/xwagmi'; +import { SendRemoveXToken } from './SendRemoveXToken'; +import { supplyMessage } from './utils'; interface ModalProps { isOpen: boolean; onClose: () => void; children?: React.ReactNode; parsedAmounts: { [field in Field]?: CurrencyAmount }; - currencies: { [field in Field]?: Currency }; - AChain: XChainId; - BChain: XChainId; + currencies: { [field in Field]?: XToken }; } const getPairName = (currencies: { [field in Field]?: Currency }) => { return `${currencies[Field.CURRENCY_A]?.symbol} / ${currencies[Field.CURRENCY_B]?.symbol}`; }; -export default function SupplyLiquidityModal({ - isOpen, - onClose, - parsedAmounts, - currencies, - AChain, - BChain, -}: ModalProps) { - const { account } = useIconReact(); - - const { currencyDeposits, pair } = useDerivedMintInfo(); +export default function SupplyLiquidityModal({ isOpen, onClose, parsedAmounts, currencies }: ModalProps) { const addTransaction = useTransactionAdder(); - const [addingTxs, setAddingTxs] = React.useState({ [Field.CURRENCY_A]: '', [Field.CURRENCY_B]: '' }); - const [shouldAddAssets, setShouldAddAssets] = React.useState({ - [Field.CURRENCY_A]: false, - [Field.CURRENCY_B]: false, - }); - - const [removingTxs, setRemovingTxs] = React.useState({ [Field.CURRENCY_A]: '', [Field.CURRENCY_B]: '' }); - const [shouldRemoveAssets, setShouldRemoveAssets] = React.useState({ - [Field.CURRENCY_A]: false, - [Field.CURRENCY_B]: false, - }); - - const handleRemove = (field: Field, amountWithdraw?: CurrencyAmount) => async () => { - window.addEventListener('beforeunload', showMessageOnBeforeUnload); - - const token = currencies[field] as Token; - - try { - const res: any = await bnJs.inject({ account }).Dex.withdraw(token.address, toDec(amountWithdraw)); - addTransaction( - { hash: res.result }, - { - pending: t`Withdrawing ${token.symbol}`, - summary: t`${amountWithdraw?.toSignificant(6)} ${token.symbol} added to your wallet`, - }, - ); - - setRemovingTxs(state => ({ ...state, [field]: res.result })); - } catch (error) { - console.error('error', error); - setRemovingTxs(state => ({ ...state, [field]: '' })); - } finally { - window.removeEventListener('beforeunload', showMessageOnBeforeUnload); - setShouldRemoveAssets({ ...shouldRemoveAssets, [field]: false }); - } - }; + const { pair } = useDerivedMintInfo(); const [confirmTx, setConfirmTx] = React.useState(''); - const handleSupplyConfirm = () => { - window.addEventListener('beforeunload', showMessageOnBeforeUnload); + const xAccount = useXAccount(getXChainType(currencies[Field.CURRENCY_A]?.xChainId)); + const { depositAmount: depositAmountA } = useXTokenDepositAmount(xAccount.address, currencies[Field.CURRENCY_A]); + const { depositAmount: depositAmountB } = useXTokenDepositAmount(xAccount.address, currencies[Field.CURRENCY_B]); - if (isQueue) { - const t = parsedAmounts[Field.CURRENCY_A]; + const xAddLiquidity = useXAddLiquidity(); - bnJs - .inject({ account }) - .Dex.transferICX(toDec(t)) - .then((res: any) => { - addTransaction( - { hash: res.result }, - { - pending: supplyMessage(currencies[Field.CURRENCY_A]?.symbol!).pendingMessage, - summary: supplyMessage(currencies[Field.CURRENCY_A]?.symbol!).successMessage, - }, - ); - if (confirmTxStatus === TransactionStatus.failure) { - setConfirmTx(''); - } else { - setConfirmTx(res.result); - } - }) - .catch(e => { - console.error('errors', e); - }) - .finally(() => { - window.removeEventListener('beforeunload', showMessageOnBeforeUnload); - }); - } else { - const baseToken = currencies[Field.CURRENCY_A] as Token; - const quoteToken = currencies[Field.CURRENCY_B] as Token; - bnJs - .inject({ account }) - .Dex.add( - baseToken.address, - quoteToken.address, - toDec(currencyDeposits[Field.CURRENCY_A]), - toDec(currencyDeposits[Field.CURRENCY_B]), - DEFAULT_SLIPPAGE_LP, - ) - .then((res: any) => { - addTransaction( - { hash: res.result }, - { - pending: supplyMessage(getPairName(currencies)).pendingMessage, - summary: supplyMessage(getPairName(currencies)).successMessage, - }, - ); + const handleSupplyConfirm = async () => { + window.addEventListener('beforeunload', showMessageOnBeforeUnload); - setConfirmTx(res.result); - }) - .catch(e => { - console.error('error', e); - }) - .finally(() => { - window.removeEventListener('beforeunload', showMessageOnBeforeUnload); - }); + if (depositAmountA && depositAmountB) { + await xAddLiquidity(xAccount.address, depositAmountA, depositAmountB); } + + window.removeEventListener('beforeunload', showMessageOnBeforeUnload); + + // { + // const baseToken = currencies[Field.CURRENCY_A] as Token; + // const quoteToken = currencies[Field.CURRENCY_B] as Token; + // bnJs + // .inject({ account }) + // .Dex.add( + // baseToken.address, + // quoteToken.address, + // toDec(currencyDeposits[Field.CURRENCY_A]), + // toDec(currencyDeposits[Field.CURRENCY_B]), + // DEFAULT_SLIPPAGE_LP, + // ) + // .then((res: any) => { + // addTransaction( + // { hash: res.result }, + // { + // pending: supplyMessage(getPairName(currencies)).pendingMessage, + // summary: supplyMessage(getPairName(currencies)).successMessage, + // }, + // ); + + // setConfirmTx(res.result); + // }) + // .catch(e => { + // console.error('error', e); + // }) + // .finally(() => { + // window.removeEventListener('beforeunload', showMessageOnBeforeUnload); + // }); + // } }; const confirmTxStatus = useTransactionStatus(confirmTx); @@ -161,50 +105,16 @@ export default function SupplyLiquidityModal({ // biome-ignore lint/correctness/useExhaustiveDependencies: React.useEffect(() => { if (!isOpen) { - setAddingTxs({ [Field.CURRENCY_A]: '', [Field.CURRENCY_B]: '' }); - setRemovingTxs({ [Field.CURRENCY_A]: '', [Field.CURRENCY_B]: '' }); setConfirmTx(''); setHasErrorMessage(false); } }, [isOpen, pair]); - const addingATxStatus: TransactionStatus | undefined = useTransactionStatus(addingTxs[Field.CURRENCY_A]); - const addingBTxStatus: TransactionStatus | undefined = useTransactionStatus(addingTxs[Field.CURRENCY_B]); - - const removingATxStatus: TransactionStatus | undefined = useTransactionStatus(removingTxs[Field.CURRENCY_A]); - const removingBTxStatus: TransactionStatus | undefined = useTransactionStatus(removingTxs[Field.CURRENCY_B]); - - const isQueue = !!(pair && pair.poolId === BalancedJs.utils.POOL_IDS.sICXICX); - - const isEnabled = isQueue - ? true - : !!currencyDeposits[Field.CURRENCY_A]?.greaterThan(0) && !!currencyDeposits[Field.CURRENCY_B]?.greaterThan(0); - - const UIStatus = React.useMemo( - () => ({ - [Field.CURRENCY_A]: { - shouldSend: !!!currencyDeposits[Field.CURRENCY_A]?.greaterThan(0), - // isAddPending: !!addingTxs[Field.CURRENCY_A], - isAddPending: addingATxStatus === TransactionStatus.pending, - // isRemovePending: !!removingTxs[Field.CURRENCY_A], - isRemovePending: removingATxStatus === TransactionStatus.pending, - chain: AChain, - }, - [Field.CURRENCY_B]: { - shouldSend: !!!currencyDeposits[Field.CURRENCY_B]?.greaterThan(0), - // isAddPending: !!addingTxs[Field.CURRENCY_B], - isAddPending: addingBTxStatus === TransactionStatus.pending, - // isRemovePending: !!removingTxs[Field.CURRENCY_B], - isRemovePending: removingBTxStatus === TransactionStatus.pending, - chain: BChain, - }, - }), - [AChain, BChain, addingATxStatus, addingBTxStatus, currencyDeposits, removingATxStatus, removingBTxStatus], - ); + const isEnabled = !!depositAmountA?.greaterThan(0) && !!depositAmountB?.greaterThan(0); const [hasErrorMessage, setHasErrorMessage] = React.useState(false); const handleCancelSupply = () => { - if (UIStatus[Field.CURRENCY_A].shouldSend && UIStatus[Field.CURRENCY_B].shouldSend) { + if (!depositAmountA?.greaterThan(0) && !depositAmountB?.greaterThan(0)) { onClose(); } else { setHasErrorMessage(true); @@ -213,45 +123,6 @@ export default function SupplyLiquidityModal({ const hasEnoughICX = useHasEnoughICX(); - const handleAddArchway = async (field: Field) => {}; - - const handleAddICON = async (field: Field) => { - window.addEventListener('beforeunload', showMessageOnBeforeUnload); - - const token = currencies[field] as Token; - - try { - const res: any = await bnJs.inject({ account }).getContract(token.address).deposit(toDec(parsedAmounts[field])); - - addTransaction( - { hash: res.result }, - { - pending: depositMessage(token.symbol!, getPairName(currencies)).pendingMessage, - summary: depositMessage(token.symbol!, getPairName(currencies)).successMessage, - }, - ); - - setAddingTxs(state => ({ ...state, [field]: res.result })); - } catch (error) { - console.error('error', error); - setAddingTxs(state => ({ ...state, [field]: '' })); - } finally { - window.removeEventListener('beforeunload', showMessageOnBeforeUnload); - setShouldAddAssets({ ...shouldAddAssets, [field]: false }); - } - }; - - const handleAdd = (field: Field) => () => { - if (UIStatus[field].chain === 'archway-1') { - handleAddArchway(field); - } else if (UIStatus[field].chain === '0x1.icon') { - handleAddICON(field); - } - }; - - const isXCallModalOpen = - false && UIStatus[Field.CURRENCY_A].chain !== '0x1.icon' && !UIStatus[Field.CURRENCY_A].isAddPending; - return ( <> undefined}> @@ -259,99 +130,32 @@ export default function SupplyLiquidityModal({ {pair ? t`Supply liquidity?` : t`Create liquidity pool?`} - - - {UIStatus[Field.CURRENCY_A].chain !== '0x1.icon' && ( - {}}> - - - {t`Transfer ${currencies[Field.CURRENCY_A]?.symbol} to ICON.`} - - - - )} ); } -const SupplyButton = styled(Button)` - padding: 5px 10px; - font-size: 12px; -`; - -const RemoveButton = styled(SupplyButton)` - background-color: transparent; - font-size: 14px; - color: #fb6a6a; - padding-top: 4px; - padding-bottom: 4px; - margin-top: 6px; - margin-bottom: 4px; - - &:hover { - background-color: transparent; - } - - &:disabled { - color: #fb6a6a; - background-color: transparent; - } -`; - const StyledDL = styled.dl` margin: 15px 0 15px 0; text-align: center; `; - -const StyledEmpty = styled.dl` - padding: 18px 0 18px 0; - text-align: center; -`; - -const CheckIconWrapper = styled.div` - padding-top: 16px; - padding-bottom: 16px; - display: block; - margin: auto; - width: 25px; -`; diff --git a/packages/balanced-js/src/contracts/Dex.ts b/packages/balanced-js/src/contracts/Dex.ts index 54e88675d..90d0b8453 100644 --- a/packages/balanced-js/src/contracts/Dex.ts +++ b/packages/balanced-js/src/contracts/Dex.ts @@ -126,6 +126,17 @@ export default class Dex extends Contract { return this.call(callParams); } + getDepositV2(tokenAddress: string, user: string) { + const callParams = this.paramsBuilder({ + method: 'getDepositV2', + params: { + _tokenAddress: tokenAddress, + _user: user, + }, + }); + + return this.call(callParams); + } transferICX(value: string) { const payload = this.transferICXParamsBuilder({ diff --git a/packages/xwagmi/src/core/XLiquidityService.ts b/packages/xwagmi/src/core/XLiquidityService.ts new file mode 100644 index 000000000..5b859e66f --- /dev/null +++ b/packages/xwagmi/src/core/XLiquidityService.ts @@ -0,0 +1,14 @@ +import { XTransactionInput } from '@/xcall/types'; +import { XWalletClient } from './XWalletClient'; + +export class XLiquidityService { + constructor(private client: XWalletClient) {} + + depositXToken(xTransactionInput: XTransactionInput) {} + async withdrawXToken(xTransactionInput: XTransactionInput) {} + async addLiquidity(xTransactionInput: XTransactionInput) {} + async removeLiquidity(xTransactionInput: XTransactionInput) {} + async stake(xTransactionInput: XTransactionInput) {} + async unstake(xTransactionInput: XTransactionInput) {} + async claimRewards(xTransactionInput: XTransactionInput) {} +} diff --git a/packages/xwagmi/src/hooks/index.ts b/packages/xwagmi/src/hooks/index.ts index 6b62ab3cc..7dbfc9656 100644 --- a/packages/xwagmi/src/hooks/index.ts +++ b/packages/xwagmi/src/hooks/index.ts @@ -13,3 +13,5 @@ export { useXEstimateSwapGas } from './useXEstimateSwapGas'; export { useXPublicClient } from './useXPublicClient'; export { useXService } from './useXService'; export { useXWalletClient } from './useXWalletClient'; + +export * from './liquidity'; diff --git a/packages/xwagmi/src/hooks/liquidity/index.ts b/packages/xwagmi/src/hooks/liquidity/index.ts new file mode 100644 index 000000000..95de34c6f --- /dev/null +++ b/packages/xwagmi/src/hooks/liquidity/index.ts @@ -0,0 +1,4 @@ +export { useXTokenDepositAmount } from './useXTokenDepositAmount'; +export { useDepositXToken } from './useDepositXToken'; +export { useWithdrawXToken } from './useWithdrawXToken'; +export { useXAddLiquidity } from './useXAddLiquidity'; diff --git a/packages/xwagmi/src/hooks/liquidity/useDepositXToken.ts b/packages/xwagmi/src/hooks/liquidity/useDepositXToken.ts new file mode 100644 index 000000000..ed496cdb6 --- /dev/null +++ b/packages/xwagmi/src/hooks/liquidity/useDepositXToken.ts @@ -0,0 +1,34 @@ +import { XToken } from '@/types'; +import { XTransactionInput, XTransactionType } from '@/xcall/types'; +import { CurrencyAmount, Token } from '@balancednetwork/sdk-core'; +import BigNumber from 'bignumber.js'; +import { useMemo } from 'react'; +import { useSendXTransaction } from '../useSendXTransaction'; + +export const useDepositXToken = () => { + const { sendXTransaction } = useSendXTransaction(); + + const depositXToken = useMemo( + () => async (account, currencyAmount: CurrencyAmount, xToken: XToken) => { + const inputAmount = CurrencyAmount.fromRawAmount( + xToken, + new BigNumber(currencyAmount.toFixed()).times((10n ** BigInt(xToken.decimals)).toString()).toFixed(0), + ); + const xTransactionInput: XTransactionInput = { + type: XTransactionType.LP_DEPOSIT_XTOKEN, + account: account, + inputAmount: inputAmount, + xCallFee: { rollback: 60000000000000n, noRollback: 0n }, + direction: { + from: xToken.xChainId, + to: '0x1.icon', + }, + }; + + return await sendXTransaction(xTransactionInput); + }, + [sendXTransaction], + ); + + return depositXToken; +}; diff --git a/packages/xwagmi/src/hooks/liquidity/useWithdrawXToken.ts b/packages/xwagmi/src/hooks/liquidity/useWithdrawXToken.ts new file mode 100644 index 000000000..90d6cabdb --- /dev/null +++ b/packages/xwagmi/src/hooks/liquidity/useWithdrawXToken.ts @@ -0,0 +1,34 @@ +import { XToken } from '@/types'; +import { XTransactionInput, XTransactionType } from '@/xcall/types'; +import { CurrencyAmount, Token } from '@balancednetwork/sdk-core'; +import BigNumber from 'bignumber.js'; +import { useMemo } from 'react'; +import { useSendXTransaction } from '../useSendXTransaction'; + +export const useWithdrawXToken = () => { + const { sendXTransaction } = useSendXTransaction(); + + const withdrawXToken = useMemo( + () => async (account, currencyAmount: CurrencyAmount, xToken: XToken) => { + const inputAmount = CurrencyAmount.fromRawAmount( + xToken, + new BigNumber(currencyAmount.toFixed()).times((10n ** BigInt(xToken.decimals)).toString()).toFixed(0), + ); + const xTransactionInput: XTransactionInput = { + type: XTransactionType.LP_WITHDRAW_XTOKEN, + account: account, + inputAmount: inputAmount, + xCallFee: { rollback: 60000000000000n, noRollback: 0n }, + direction: { + from: xToken.xChainId, + to: '0x1.icon', + }, + }; + + return await sendXTransaction(xTransactionInput); + }, + [sendXTransaction], + ); + + return withdrawXToken; +}; diff --git a/packages/xwagmi/src/hooks/liquidity/useXAddLiquidity.ts b/packages/xwagmi/src/hooks/liquidity/useXAddLiquidity.ts new file mode 100644 index 000000000..fc2c13671 --- /dev/null +++ b/packages/xwagmi/src/hooks/liquidity/useXAddLiquidity.ts @@ -0,0 +1,31 @@ +import { XToken } from '@/types'; +import { XTransactionInput, XTransactionType } from '@/xcall/types'; +import { CurrencyAmount, Token } from '@balancednetwork/sdk-core'; +import BigNumber from 'bignumber.js'; +import { useMemo } from 'react'; +import { useSendXTransaction } from '../useSendXTransaction'; + +export const useXAddLiquidity = () => { + const { sendXTransaction } = useSendXTransaction(); + + const xAddLiquidity = useMemo( + () => async (account, inputAmount: CurrencyAmount, outputAmount: CurrencyAmount) => { + const xTransactionInput: XTransactionInput = { + type: XTransactionType.LP_ADD_LIQUIDITY, + account: account, + inputAmount, + outputAmount, + xCallFee: { rollback: 60000000000000n, noRollback: 0n }, + direction: { + from: inputAmount.currency.xChainId, + to: '0x1.icon', + }, + }; + + return await sendXTransaction(xTransactionInput); + }, + [sendXTransaction], + ); + + return xAddLiquidity; +}; diff --git a/packages/xwagmi/src/hooks/liquidity/useXTokenDepositAmount.ts b/packages/xwagmi/src/hooks/liquidity/useXTokenDepositAmount.ts new file mode 100644 index 000000000..89bbcc68b --- /dev/null +++ b/packages/xwagmi/src/hooks/liquidity/useXTokenDepositAmount.ts @@ -0,0 +1,37 @@ +import { xTokenMapBySymbol } from '@/constants'; +import { XToken } from '@/types'; +import { bnJs } from '@/xchains/icon'; +import { CurrencyAmount } from '@balancednetwork/sdk-core'; +import { useCallback, useEffect, useMemo, useState } from 'react'; + +export const useXTokenDepositAmount = ( + account: string | undefined | null, + xToken: XToken | undefined, +): { + depositAmount: CurrencyAmount | undefined; + refetchDepositAmount: () => Promise; +} => { + const [result, setResult] = useState(); + + const fetch = useMemo(() => { + return async (xToken, account) => { + if (xToken && account) { + const xTokenOnIcon = xTokenMapBySymbol['0x1.icon'][xToken.symbol]; + const res = await bnJs.Dex.getDepositV2(xTokenOnIcon.address, `${xToken.xChainId}/${account}`); + setResult(res); + } + }; + }, []); + + useEffect(() => { + fetch(xToken, account); + }, [fetch, xToken, account]); + + const depositAmount = useMemo(() => { + return xToken && result ? CurrencyAmount.fromRawAmount(xToken, BigInt(result)) : undefined; + }, [xToken, result]); + + const refetch = useCallback(() => fetch(xToken, account), [fetch, xToken, account]); + + return { depositAmount, refetchDepositAmount: refetch }; +}; diff --git a/packages/xwagmi/src/hooks/useSendXTransaction.ts b/packages/xwagmi/src/hooks/useSendXTransaction.ts new file mode 100644 index 000000000..cb7a3fab1 --- /dev/null +++ b/packages/xwagmi/src/hooks/useSendXTransaction.ts @@ -0,0 +1,82 @@ +import { getXWalletClient } from '@/actions'; +import { ICON_XCALL_NETWORK_ID, xChainMap } from '@/constants'; +import { transactionActions, xChainHeightActions, xMessageActions, xTransactionActions } from '@/xcall'; +import { XMessage, XMessageStatus, XTransaction, XTransactionInput, XTransactionStatus } from '@/xcall/types'; +import { useSignTransaction } from '@mysten/dapp-kit'; +import { useMemo } from 'react'; + +const sendXTransaction = async (xTransactionInput: XTransactionInput, options: any) => { + const { direction } = xTransactionInput; + const sourceChainId = direction.from; + + const srcXWalletClient = getXWalletClient(sourceChainId); + if (!srcXWalletClient) { + throw new Error('WalletXService for source chain is not found'); + } + + console.log('xTransactionInput', xTransactionInput); + + const sourceTransactionHash = await srcXWalletClient.executeTransaction(xTransactionInput, options); + if (!sourceTransactionHash) { + return; + } + + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + xTransactionInput?.callback?.(); + + const sourceTransaction = transactionActions.add(sourceChainId, { + hash: sourceTransactionHash, + }); + + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + const finalDestinationChainId = direction.to; + const primaryDestinationChainId = + sourceChainId === ICON_XCALL_NETWORK_ID ? finalDestinationChainId : ICON_XCALL_NETWORK_ID; + + const primaryDestinationChainInitialBlockHeight = + xChainHeightActions.getXChainHeight(primaryDestinationChainId) - 20n; + const finalDestinationChainInitialBlockHeight = xChainHeightActions.getXChainHeight(finalDestinationChainId); + + const now = Date.now(); + const xTransaction: XTransaction = { + id: `${sourceChainId}/${sourceTransactionHash}`, + type: xTransactionInput.type, + status: XTransactionStatus.pending, + secondaryMessageRequired: primaryDestinationChainId !== finalDestinationChainId, + sourceChainId: sourceChainId, + finalDestinationChainId: finalDestinationChainId, + finalDestinationChainInitialBlockHeight, + attributes: {}, + createdAt: now, + }; + xTransactionActions.add(xTransaction); + + const xMessage: XMessage = { + id: `${sourceChainId}/${sourceTransactionHash}`, + xTransactionId: xTransaction.id, + sourceChainId: sourceChainId, + destinationChainId: primaryDestinationChainId, + sourceTransactionHash, + status: XMessageStatus.REQUESTED, + events: {}, + destinationChainInitialBlockHeight: primaryDestinationChainInitialBlockHeight, + isPrimary: true, + createdAt: now, + useXCallScanner: xChainMap[primaryDestinationChainId].useXCallScanner || xChainMap[sourceChainId].useXCallScanner, + }; + xMessageActions.add(xMessage); + + return xTransaction.id; +}; + +export const useSendXTransaction = () => { + const { mutateAsync: signTransaction } = useSignTransaction(); + + return useMemo( + () => ({ + sendXTransaction: (xTransactionInput: XTransactionInput) => + sendXTransaction(xTransactionInput, { signTransaction }), + }), + [signTransaction], + ); +}; diff --git a/packages/xwagmi/src/index.ts b/packages/xwagmi/src/index.ts index 39e0cc76a..e1e001d7f 100644 --- a/packages/xwagmi/src/index.ts +++ b/packages/xwagmi/src/index.ts @@ -23,3 +23,4 @@ export type * from './xcall/types'; export { useAccount, useSwitchChain } from 'wagmi'; export { useSignTransaction, useCurrentAccount, useCurrentWallet, useSuiClient } from '@mysten/dapp-kit'; +export { RLP } from '@ethereumjs/rlp'; diff --git a/packages/xwagmi/src/xcall/types.ts b/packages/xwagmi/src/xcall/types.ts index ab6990d30..18c461835 100644 --- a/packages/xwagmi/src/xcall/types.ts +++ b/packages/xwagmi/src/xcall/types.ts @@ -38,6 +38,14 @@ export enum XTransactionType { BORROW = 'borrow', REPAY = 'repay', SWAP_ON_ICON = 'swap_on_icon', + //liquidity + LP_DEPOSIT_XTOKEN = 'lp_deposit_xtoken', + LP_WITHDRAW_XTOKEN = 'lp_withdraw_xtoken', + LP_ADD_LIQUIDITY = 'lp_add_liquidity', + LP_REMOVE_LIQUIDITY = 'lp_remove_liquidity', + LP_STAKE = 'lp_stake', + LP_UNSTAKE = 'lp_unstake', + LP_CLAIM_REWARDS = 'lp_claim_rewards', } export enum XMessageStatus { @@ -59,6 +67,7 @@ export type XTransactionInput = { }; type: XTransactionType; inputAmount: CurrencyAmount; + outputAmount?: CurrencyAmount; // quote token for liquidity account: string; xCallFee: IXCallFee; callback?: () => void; diff --git a/packages/xwagmi/src/xcall/zustand/useTransactionStore.tsx b/packages/xwagmi/src/xcall/zustand/useTransactionStore.tsx index 7ac368a58..c5390301c 100644 --- a/packages/xwagmi/src/xcall/zustand/useTransactionStore.tsx +++ b/packages/xwagmi/src/xcall/zustand/useTransactionStore.tsx @@ -156,7 +156,7 @@ export const useFetchTransaction = (hash: string) => { const xPublicClient = getXPublicClient(xChainId); try { const rawTx = await xPublicClient.getTxReceipt(hash); - return rawTx; + return rawTx || null; } catch (err: any) { console.error(`failed to check transaction hash: ${hash}`, err); throw new Error(err?.message); diff --git a/packages/xwagmi/src/xchains/evm/EvmXLiquidityService.ts b/packages/xwagmi/src/xchains/evm/EvmXLiquidityService.ts new file mode 100644 index 000000000..dd2ae403f --- /dev/null +++ b/packages/xwagmi/src/xchains/evm/EvmXLiquidityService.ts @@ -0,0 +1,165 @@ +import { + FROM_SOURCES, + ICON_XCALL_NETWORK_ID, + TO_SOURCES, + bnJs, + bnUSDContractAbi, + isSpokeToken, + uintToBytes, + xCallContractAbi, + xChainMap, + xTokenMapBySymbol, +} from '@/index'; +import { XTransactionInput } from '@/xcall/types'; +import { RLP } from '@ethereumjs/rlp'; +import { Address, toHex } from 'viem'; +import { EvmXWalletClient } from './EvmXWalletClient'; + +export class EvmXLiquidityService { + constructor(private client: EvmXWalletClient) {} + + async depositXToken(xTransactionInput: XTransactionInput) { + const { account, inputAmount, xCallFee } = xTransactionInput; + + const publicClient = this.client.getPublicClient(); + const walletClient = await this.client.getWalletClient(); + + const destination = `${ICON_XCALL_NETWORK_ID}/${bnJs.Dex.address}`; + const amount = BigInt(inputAmount.quotient.toString()); + const data = toHex( + JSON.stringify({ + method: '_deposit', + params: {}, + }), + ); + + const _isSpokeToken = isSpokeToken(inputAmount.currency); + const isNative = inputAmount.currency.isNativeToken; + + let hash; + if (_isSpokeToken) { + const res = await publicClient.simulateContract({ + account: account as Address, + address: xTokenMapBySymbol[this.client.xChainId][inputAmount.currency.symbol].address as Address, + abi: bnUSDContractAbi, + functionName: 'crossTransfer', + args: [destination, amount, data], + value: xCallFee.rollback, + }); + hash = await walletClient.writeContract(res.request); + } else { + if (!isNative) { + throw new Error('not implemented'); + } else { + throw new Error('not implemented'); + } + } + + return hash; + } + + async withdrawXToken(xTransactionInput: XTransactionInput) { + const { account, inputAmount, xCallFee } = xTransactionInput; + + const publicClient = this.client.getPublicClient(); + const walletClient = await this.client.getWalletClient(); + + const destination = `${ICON_XCALL_NETWORK_ID}/${bnJs.Dex.address}`; + const amount = BigInt(inputAmount.quotient.toString()); + const xTokenOnIcon = xTokenMapBySymbol[ICON_XCALL_NETWORK_ID][inputAmount.currency.symbol]; + const data = toHex( + RLP.encode([ + 'xWithdraw', + xTokenOnIcon.address, // + uintToBytes(amount), + ]), + ); + + const envelope = toHex( + RLP.encode([ + Buffer.from([0]), + data, + FROM_SOURCES[this.client.xChainId]?.map(Buffer.from), + TO_SOURCES[this.client.xChainId]?.map(Buffer.from), + ]), + ); + + const _isSpokeToken = isSpokeToken(inputAmount.currency); + const isNative = inputAmount.currency.isNativeToken; + + let hash; + if (_isSpokeToken) { + const res = await publicClient.simulateContract({ + account: account as Address, + address: xChainMap[this.client.xChainId].contracts.xCall as Address, + abi: xCallContractAbi, + functionName: 'sendCall', + args: [destination, envelope], + value: xCallFee.rollback, + }); + hash = await walletClient.writeContract(res.request); + } else { + if (!isNative) { + throw new Error('not implemented'); + } else { + throw new Error('not implemented'); + } + } + + return hash; + } + + async addLiquidity(xTransactionInput: XTransactionInput) { + const { account, inputAmount, outputAmount, xCallFee } = xTransactionInput; + + if (!outputAmount) { + throw new Error('outputAmount is required'); + } + + const publicClient = this.client.getPublicClient(); + const walletClient = await this.client.getWalletClient(); + + const destination = `${ICON_XCALL_NETWORK_ID}/${bnJs.Dex.address}`; + const amountA = BigInt(inputAmount.quotient.toString()); + const amountB = BigInt(outputAmount.quotient.toString()); + const xTokenAOnIcon = xTokenMapBySymbol[ICON_XCALL_NETWORK_ID][inputAmount.currency.symbol]; + const xTokenBOnIcon = xTokenMapBySymbol[ICON_XCALL_NETWORK_ID][outputAmount.currency.symbol]; + const data = toHex( + RLP.encode([ + 'xAdd', + xTokenAOnIcon.address, + xTokenBOnIcon.address, + uintToBytes(amountA), + uintToBytes(amountB), + uintToBytes(1n), + uintToBytes(1_000n), + ]), + ); + + const envelope = toHex( + RLP.encode([ + Buffer.from([0]), + data, + FROM_SOURCES[this.client.xChainId]?.map(Buffer.from), + TO_SOURCES[this.client.xChainId]?.map(Buffer.from), + ]), + ); + + const res = await publicClient.simulateContract({ + account: account as Address, + address: xChainMap[this.client.xChainId].contracts.xCall as Address, + abi: xCallContractAbi, + functionName: 'sendCall', + args: [destination, envelope], + value: xCallFee.rollback, + }); + + const hash = await walletClient.writeContract(res.request); + return hash; + } + + async removeLiquidity(xTransactionInput: XTransactionInput) {} + async stake(xTransactionInput: XTransactionInput) {} + async unstake(xTransactionInput: XTransactionInput) {} + async claimRewards(xTransactionInput: XTransactionInput) {} +} diff --git a/packages/xwagmi/src/xchains/evm/EvmXWalletClient.ts b/packages/xwagmi/src/xchains/evm/EvmXWalletClient.ts index ab693451e..dd29cb2c4 100644 --- a/packages/xwagmi/src/xchains/evm/EvmXWalletClient.ts +++ b/packages/xwagmi/src/xchains/evm/EvmXWalletClient.ts @@ -11,12 +11,15 @@ import { uintToBytes } from '@/utils'; import { XTransactionInput, XTransactionType } from '../../xcall/types'; import { getRlpEncodedSwapData, toICONDecimals } from '../../xcall/utils'; import { isSpokeToken } from '../archway/utils'; +import { EvmXLiquidityService } from './EvmXLiquidityService'; import { EvmXService } from './EvmXService'; import { assetManagerContractAbi } from './abis/assetManagerContractAbi'; import { bnUSDContractAbi } from './abis/bnUSDContractAbi'; import { xCallContractAbi } from './abis/xCallContractAbi'; export class EvmXWalletClient extends XWalletClient { + private liquidityService = new EvmXLiquidityService(this); + getXService(): EvmXService { return EvmXService.getInstance(); } @@ -45,7 +48,7 @@ export class EvmXWalletClient extends XWalletClient { async approve(amountToApprove: CurrencyAmount, spender: string, owner: string) { const xToken = amountToApprove.currency; - const publicClient = await this.getPublicClient(); + const publicClient = this.getPublicClient(); const walletClient = await this.getWalletClient(); const tokenContract = getContract({ @@ -67,41 +70,66 @@ export class EvmXWalletClient extends XWalletClient { const { type, direction, inputAmount, recipient, account, xCallFee, executionTrade, slippageTolerance } = xTransactionInput; + console.log('type', type); + const receiver = `${direction.to}/${recipient}`; const tokenAddress = inputAmount.wrapped.currency.address; const amount = BigInt(inputAmount.quotient.toString()); const destination = `${ICON_XCALL_NETWORK_ID}/${bnJs.Router.address}`; let data: Address; - if (type === XTransactionType.SWAP) { - if (!executionTrade || !slippageTolerance) { - return; + switch (type) { + case XTransactionType.SWAP: { + if (!executionTrade || !slippageTolerance) { + return; + } + const minReceived = executionTrade.minimumAmountOut(new Percent(slippageTolerance, 10_000)); + const rlpEncodedData = getRlpEncodedSwapData(executionTrade, '_swap', receiver, minReceived).toString('hex'); + data = `0x${rlpEncodedData}`; + break; } - const minReceived = executionTrade.minimumAmountOut(new Percent(slippageTolerance, 10_000)); - const rlpEncodedData = getRlpEncodedSwapData(executionTrade, '_swap', receiver, minReceived).toString('hex'); - data = `0x${rlpEncodedData}`; - } else if (type === XTransactionType.BRIDGE) { - data = toHex( - JSON.stringify({ - method: '_swap', - params: { - path: [], - receiver: receiver, - }, - }), - ); - } else if (type === XTransactionType.DEPOSIT) { - return await this.executeDepositCollateral(xTransactionInput); - } else if (type === XTransactionType.WITHDRAW) { - return await this.executeWithdrawCollateral(xTransactionInput); - } else if (type === XTransactionType.BORROW) { - return await this.executeBorrow(xTransactionInput); - } else if (type === XTransactionType.REPAY) { - return await this.executeRepay(xTransactionInput); - } else { - throw new Error('Invalid XTransactionType'); + case XTransactionType.BRIDGE: + data = toHex( + JSON.stringify({ + method: '_swap', + params: { + path: [], + receiver: receiver, + }, + }), + ); + break; + case XTransactionType.DEPOSIT: + return await this.executeDepositCollateral(xTransactionInput); + case XTransactionType.WITHDRAW: + return await this.executeWithdrawCollateral(xTransactionInput); + case XTransactionType.BORROW: + return await this.executeBorrow(xTransactionInput); + case XTransactionType.REPAY: + return await this.executeRepay(xTransactionInput); + + case XTransactionType.LP_DEPOSIT_XTOKEN: + return await this.liquidityService.depositXToken(xTransactionInput); + case XTransactionType.LP_WITHDRAW_XTOKEN: + return await this.liquidityService.withdrawXToken(xTransactionInput); + case XTransactionType.LP_ADD_LIQUIDITY: + return await this.liquidityService.addLiquidity(xTransactionInput); + case XTransactionType.LP_REMOVE_LIQUIDITY: + return await this.liquidityService.removeLiquidity(xTransactionInput); + case XTransactionType.LP_STAKE: + return await this.liquidityService.stake(xTransactionInput); + case XTransactionType.LP_UNSTAKE: + return await this.liquidityService.unstake(xTransactionInput); + case XTransactionType.LP_CLAIM_REWARDS: + return await this.liquidityService.claimRewards(xTransactionInput); + + default: + throw new Error('Invalid XTransactionType'); } + const publicClient = this.getPublicClient(); + const walletClient = await this.getWalletClient(); + const _isSpokeToken = isSpokeToken(inputAmount.currency); const isNative = inputAmount.currency.isNativeToken; @@ -141,7 +169,6 @@ export class EvmXWalletClient extends XWalletClient { } } - const walletClient = await this.getWalletClient(); const hash = await walletClient.writeContract(request); if (hash) { diff --git a/packages/xwagmi/src/xchains/evm/index.ts b/packages/xwagmi/src/xchains/evm/index.ts index 35f6c4a2f..ebb95edf7 100644 --- a/packages/xwagmi/src/xchains/evm/index.ts +++ b/packages/xwagmi/src/xchains/evm/index.ts @@ -2,3 +2,6 @@ export { EvmXService } from './EvmXService'; export { EvmXConnector } from './EvmXConnector'; export { EvmXPublicClient } from './EvmXPublicClient'; export { EvmXWalletClient } from './EvmXWalletClient'; +export { assetManagerContractAbi } from './abis/assetManagerContractAbi'; +export { bnUSDContractAbi } from './abis/bnUSDContractAbi'; +export { xCallContractAbi } from './abis/xCallContractAbi'; diff --git a/packages/xwagmi/src/xchains/evm/utils.ts b/packages/xwagmi/src/xchains/evm/utils.ts new file mode 100644 index 000000000..e69de29bb From 4afaafe2bad80bea3aa3158e7710e9720bd92b89 Mon Sep 17 00:00:00 2001 From: swiftcc624 Date: Wed, 8 Jan 2025 10:05:44 +0800 Subject: [PATCH 04/33] update balanced sdk --- packages/balanced-js/src/addresses.ts | 2 +- packages/balanced-js/src/contracts/Dex.ts | 11 +++++++++++ packages/balanced-js/src/contracts/StakedLP.ts | 12 ++++++++++++ 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/packages/balanced-js/src/addresses.ts b/packages/balanced-js/src/addresses.ts index b907c75c4..dec35141c 100644 --- a/packages/balanced-js/src/addresses.ts +++ b/packages/balanced-js/src/addresses.ts @@ -17,7 +17,7 @@ const MAINNET_ADDRESSES = { bnusd: 'cx88fd7df7ddff82f7cc735c871dc519838cb235bb', baln: 'cxf61cd5a45dc9f91c15aa65831a30a90d59a09619', bwt: 'cxcfe9d1f83fa871e903008471cca786662437e58d', - multicall: 'cxa4aa9185e23558cff990f494c1fd2845f6cbf741', + multicall: 'cx152b6b51a17c0ab929fc811c50bd2a5ace1b8782', disbursement: 'cxe3905591929d17fc8496ae28ee3b9c144579228e', stabilityfund: 'cxa09dbb60dcb62fffbd232b6eae132d730a2aafa6', stakedLp: 'cx8dc674ce709c518bf1a6058a2722a59f94b6fb7f', diff --git a/packages/balanced-js/src/contracts/Dex.ts b/packages/balanced-js/src/contracts/Dex.ts index 90d0b8453..e47a1013e 100644 --- a/packages/balanced-js/src/contracts/Dex.ts +++ b/packages/balanced-js/src/contracts/Dex.ts @@ -58,6 +58,17 @@ export default class Dex extends Contract { }); return this.call(callParams); } + xBalanceOf(owner: string, id: number, blockHeight?: number) { + const callParams = this.paramsBuilder({ + method: 'xBalanceOf', + blockHeight: blockHeight, + params: { + _owner: owner, + _id: IconConverter.toHex(id), + }, + }); + return this.call(callParams); + } totalSupply(id: number) { const callParams = this.paramsBuilder({ diff --git a/packages/balanced-js/src/contracts/StakedLP.ts b/packages/balanced-js/src/contracts/StakedLP.ts index 46a00053f..f942a0003 100644 --- a/packages/balanced-js/src/contracts/StakedLP.ts +++ b/packages/balanced-js/src/contracts/StakedLP.ts @@ -22,6 +22,18 @@ export default class StakedLP extends Contract { return this.call(callParams); } + xBalanceOf(owner: string, poolId: number, blockHeight?: number) { + const callParams = this.paramsBuilder({ + method: 'xBalanceOf', + blockHeight: blockHeight, + params: { + _id: IconConverter.toHex(poolId), + _owner: owner, + }, + }); + + return this.call(callParams); + } totalSupply(poolId: number) { const callParams = this.paramsBuilder({ From 20438ff1a2203fb7cddf718348720ad36336a79f Mon Sep 17 00:00:00 2001 From: swiftcc624 Date: Wed, 8 Jan 2025 17:40:37 +0800 Subject: [PATCH 05/33] crosschain lp - remove liquidity --- .../supply/_components/LiquidityDetails.tsx | 215 ++++------------ .../LiquidityDetails/PoolRecord.tsx | 230 ++++++++++++++++++ .../LiquidityDetails/WithdrawPanel.tsx | 101 ++++---- .../_components/LiquidityDetails/shared.tsx | 71 +++++- .../pages/trade/supply/_components/utils.tsx | 4 +- apps/web/src/hooks/useV2Pairs.ts | 108 +++++++- packages/xwagmi/src/hooks/liquidity/index.ts | 1 + .../hooks/liquidity/useXRemoveLiquidity.ts | 39 +++ packages/xwagmi/src/xcall/types.ts | 1 + .../src/xchains/evm/EvmXLiquidityService.ts | 37 ++- packages/xwagmi/src/xchains/evm/utils.ts | 50 ++++ 11 files changed, 629 insertions(+), 228 deletions(-) create mode 100644 apps/web/src/app/pages/trade/supply/_components/LiquidityDetails/PoolRecord.tsx create mode 100644 packages/xwagmi/src/hooks/liquidity/useXRemoveLiquidity.ts diff --git a/apps/web/src/app/pages/trade/supply/_components/LiquidityDetails.tsx b/apps/web/src/app/pages/trade/supply/_components/LiquidityDetails.tsx index b9dada277..8c7dcd431 100644 --- a/apps/web/src/app/pages/trade/supply/_components/LiquidityDetails.tsx +++ b/apps/web/src/app/pages/trade/supply/_components/LiquidityDetails.tsx @@ -16,29 +16,25 @@ import { Typography } from '@/app/theme'; import ArrowDownIcon from '@/assets/icons/arrow-line.svg'; import { MINIMUM_B_BALANCE_TO_SHOW_POOL } from '@/constants/index'; import { BIGINT_ZERO } from '@/constants/misc'; -import { BalanceData, useBalance, useSuppliedTokens } from '@/hooks/useV2Pairs'; -import { PairData, useAllPairsById } from '@/queries/backendv2'; -import { Source, useBBalnAmount, useSources, useTotalSupply } from '@/store/bbaln/hooks'; +import { BalanceData, usePools } from '@/hooks/useV2Pairs'; +import { useAllPairsById } from '@/queries/backendv2'; +import { Source, useSources } from '@/store/bbaln/hooks'; import { useTokenListConfig } from '@/store/lists/hooks'; import { useMintActionHandlers } from '@/store/mint/hooks'; import { Field } from '@/store/mint/reducer'; import { useRewards } from '@/store/reward/hooks'; -import { useStakedLPPercent, useWithdrawnPercent } from '@/store/stakedLP/hooks'; import { QuestionWrapper } from '@/app/components/QuestionHelper'; -import Skeleton from '@/app/components/Skeleton'; import { MouseoverTooltip } from '@/app/components/Tooltip'; import QuestionIcon from '@/assets/icons/question.svg'; -import { formatBigNumber } from '@/utils'; -import { getFormattedNumber } from '@/utils/formatter'; import { Banner } from '../../../../components/Banner'; import Spinner from '../../../../components/Spinner'; import { StyledAccordionButton, StyledAccordionItem, StyledAccordionPanel } from './LiquidityDetails/Accordion'; +import { PoolRecord } from './LiquidityDetails/PoolRecord'; import StakeLPPanel from './LiquidityDetails/StakeLPPanel'; -import { WithdrawPanel, WithdrawPanelQ, getABBalance, getShareReward } from './LiquidityDetails/WithdrawPanel'; +import { WithdrawPanel, WithdrawPanelQ, getShareReward } from './LiquidityDetails/WithdrawPanel'; import { StyledBoxPanel } from './LiquidityDetails/shared'; import { usePoolPanelContext } from './PoolPanelContext'; -import { getFormattedRewards, stakedFraction, totalSupply } from './utils'; export default function LiquidityDetails() { const upSmall = useMedia('(min-width: 800px)'); @@ -65,30 +61,38 @@ export default function LiquidityDetails() { const pairsWithoutQ = omit(pairs, [BalancedJs.utils.POOL_IDS.sICXICX]); const balancesWithoutQ = omit(balances, [BalancedJs.utils.POOL_IDS.sICXICX]); - const userPools = Object.keys(pairsWithoutQ).filter( - poolId => - balances[poolId] && - (Number(balances[poolId].balance.toFixed()) > MINIMUM_B_BALANCE_TO_SHOW_POOL || - Number(balances[poolId].stakedLPBalance.toFixed()) > MINIMUM_B_BALANCE_TO_SHOW_POOL), - ); - const sortedPairs: { [key: string]: Pair } = userPools - .map(poolId => { - const pair: Pair = pairsWithoutQ[poolId]; - - if (pair.baseAddress === pair.token0.address) return pair; - return new Pair(pair.reserve1, pair.reserve0, { - poolId: pair.poolId, - totalSupply: pair.totalSupply?.quotient.toString(), - baseAddress: pair.baseAddress, - }); - }) - .reduce((acc, pair) => { - if (pair.poolId && pair.poolId > 0) acc[pair.poolId] = pair; - return acc; - }, {}); - - const hasLiquidity = shouldShowQueue || userPools.length; + const pools = usePools(pairs, [ + `0x1.icon/hxe25ae17a21883803185291baddac0120493ff706`, + `0xa4b1.arbitrum/0x6C5F91FD68Dd7b3A1aedB0F09946659272f523a4`, + ]); + + const userPools = pools?.filter(x => x.balance.greaterThan(0) || x.stakedLPBalance?.greaterThan(0)) || []; + + // const userPools = Object.keys(pairsWithoutQ).filter( + // poolId => + // balances[poolId] && + // (Number(balances[poolId].balance.toFixed()) > MINIMUM_B_BALANCE_TO_SHOW_POOL || + // Number(balances[poolId].stakedLPBalance.toFixed()) > MINIMUM_B_BALANCE_TO_SHOW_POOL), + // ); + + // const sortedPairs: { [key: string]: Pair } = userPools + // .map(poolId => { + // const pair: Pair = pairsWithoutQ[poolId]; + + // if (pair.baseAddress === pair.token0.address) return pair; + // return new Pair(pair.reserve1, pair.reserve0, { + // poolId: pair.poolId, + // totalSupply: pair.totalSupply?.quotient.toString(), + // baseAddress: pair.baseAddress, + // }); + // }) + // .reduce((acc, pair) => { + // if (pair.poolId && pair.poolId > 0) acc[pair.poolId] = pair; + // return acc; + // }, {}); + + const hasLiquidity = shouldShowQueue || !!userPools.length; const isLiquidityInfoLoading = shouldShowQueue === undefined; return ( @@ -176,13 +180,13 @@ export default function LiquidityDetails() { )} {balancesWithoutQ && - userPools.map((poolId, index, arr) => ( - + userPools.map(({ poolId }, index) => ( + setIsHided(false)}> x.poolId === poolId)!} + pair={pairs[poolId]} pairData={allPairs && allPairs[poolId]} //hotfix due to the fact that sICX/BTCB pair has wrong name on contract side totalReward={ @@ -191,13 +195,17 @@ export default function LiquidityDetails() { : new BigNumber(0) } boostData={sources} - apy={allPairs && allPairs[parseInt(poolId)] ? allPairs[parseInt(poolId)].balnApy : 0} + apy={allPairs && allPairs[poolId] ? allPairs[poolId].balnApy : 0} /> @@ -277,133 +285,6 @@ const APYItem = styled(Flex)` line-height: 25px; `; -const PoolRecord = ({ - poolId, - pair, - pairData, - balance, - totalReward, - boostData, - apy, -}: { - pair: Pair; - pairData?: PairData; - balance: BalanceData; - poolId: number; - totalReward: BigNumber; - boostData: { [key in string]: Source } | undefined; - apy: number | null; -}) => { - const upSmall = useMedia('(min-width: 800px)'); - const stakedLPPercent = useStakedLPPercent(poolId); - const [aBalance, bBalance] = getABBalance(pair, balance); - const pairName = `${aBalance.currency.symbol || '...'}/${bBalance.currency.symbol || '...'}`; - const sourceName = pairName === 'sICX/BTCB' ? 'BTCB/sICX' : pairName; - const { baseValue, quoteValue } = useWithdrawnPercent(poolId) || {}; - const balances = useBalance(poolId); - const stakedFractionValue = stakedFraction(stakedLPPercent); - const totalbBaln = useTotalSupply(); - const userBbaln = useBBalnAmount(); - const reward = getShareReward( - totalReward, - boostData && boostData[sourceName], - balances, - stakedFractionValue, - totalbBaln, - userBbaln, - ); - const lpBalance = useSuppliedTokens(poolId, aBalance.currency, bBalance.currency); - - const baseCurrencyTotalSupply = totalSupply(baseValue, lpBalance?.base); - const quoteCurrencyTotalSupply = totalSupply(quoteValue, lpBalance?.quote); - - const { onCurrencySelection } = useMintActionHandlers(false); - - const handlePoolClick = () => { - if (pairData) { - onCurrencySelection(Field.CURRENCY_A, pairData.info.baseToken); - onCurrencySelection(Field.CURRENCY_B, pairData.info.quoteToken); - } else { - onCurrencySelection(Field.CURRENCY_A, pair.reserve0.currency); - onCurrencySelection(Field.CURRENCY_B, pair.reserve1.currency); - } - }; - - return ( - <> - - - {pairName} - - - - {baseCurrencyTotalSupply ? ( - {`${formatBigNumber( - new BigNumber(baseCurrencyTotalSupply?.toFixed() || 0), - 'currency', - )} ${aBalance.currency.symbol}`} - ) : ( - - )} - {quoteCurrencyTotalSupply ? ( - {`${formatBigNumber( - new BigNumber(quoteCurrencyTotalSupply?.toFixed() || 0), - 'currency', - )} ${bBalance.currency.symbol}`} - ) : ( - - )} - - - {upSmall && ( - - {boostData ? ( - apy && - boostData[pairName === 'sICX/BTCB' ? 'BTCB/sICX' : pairName] && - boostData[pairName === 'sICX/BTCB' ? 'BTCB/sICX' : pairName].balance.isGreaterThan(0) ? ( - <> - - - BALN: - - {new BigNumber(apy) - .times( - //hotfix pairName due to wrong source name on contract side - boostData[pairName === 'sICX/BTCB' ? 'BTCB/sICX' : pairName].workingBalance.dividedBy( - boostData[pairName === 'sICX/BTCB' ? 'BTCB/sICX' : pairName].balance, - ), - ) - .times(100) - .toFormat(2)} - % - - - {pairData?.feesApy && ( - - - Fees: - - {getFormattedNumber(pairData.feesApy, 'percent2')} - - )} - - ) : ( - '-' - ) - ) : ( - - )} - - )} - {upSmall && ( - //hotfix pairName due to wrong source name on contract side - {getFormattedRewards(reward)} - )} - - - ); -}; - const PoolRecordQ = ({ balance, pair, diff --git a/apps/web/src/app/pages/trade/supply/_components/LiquidityDetails/PoolRecord.tsx b/apps/web/src/app/pages/trade/supply/_components/LiquidityDetails/PoolRecord.tsx new file mode 100644 index 000000000..d0059d973 --- /dev/null +++ b/apps/web/src/app/pages/trade/supply/_components/LiquidityDetails/PoolRecord.tsx @@ -0,0 +1,230 @@ +import React, { useState } from 'react'; + +import { BalancedJs } from '@balancednetwork/balanced-js'; +import { Pair } from '@balancednetwork/v1-sdk'; +import { Trans } from '@lingui/macro'; +import { Accordion } from '@reach/accordion'; +import BigNumber from 'bignumber.js'; +import { AnimatePresence, motion } from 'framer-motion'; +import { omit } from 'lodash-es'; +import { useMedia } from 'react-use'; +import { Flex } from 'rebass/styled-components'; +import styled from 'styled-components'; + +import Message from '@/app/Message'; +import { Typography } from '@/app/theme'; +import ArrowDownIcon from '@/assets/icons/arrow-line.svg'; +import { MINIMUM_B_BALANCE_TO_SHOW_POOL } from '@/constants/index'; +import { BIGINT_ZERO } from '@/constants/misc'; +import { BalanceData, Pool, useBalance, usePoolTokenAmounts, useSuppliedTokens } from '@/hooks/useV2Pairs'; +import { PairData, useAllPairsById } from '@/queries/backendv2'; +import { Source, useBBalnAmount, useSources, useTotalSupply } from '@/store/bbaln/hooks'; +import { useTokenListConfig } from '@/store/lists/hooks'; +import { useMintActionHandlers } from '@/store/mint/hooks'; +import { Field } from '@/store/mint/reducer'; +import { useRewards } from '@/store/reward/hooks'; +import { useStakedLPPercent, useWithdrawnPercent } from '@/store/stakedLP/hooks'; + +import { QuestionWrapper } from '@/app/components/QuestionHelper'; +import Skeleton from '@/app/components/Skeleton'; +import { MouseoverTooltip } from '@/app/components/Tooltip'; +import QuestionIcon from '@/assets/icons/question.svg'; +import { formatBigNumber } from '@/utils'; +import { getFormattedNumber } from '@/utils/formatter'; +import { XChainId } from '@balancednetwork/sdk-core'; +import { getFormattedRewards, stakedFraction, totalSupply } from '../utils'; +import { WithdrawPanel, WithdrawPanelQ, getABBalance, getShareReward } from './WithdrawPanel'; +import { StyledBoxPanel } from './shared'; + +const TableWrapper = styled.div``; + +const DashGrid = styled.div` + display: grid; + grid-template-columns: 4fr 5fr; + gap: 10px; + grid-template-areas: 'name supply action'; + align-items: center; + + & > * { + justify-content: flex-end; + text-align: right; + + &:first-child { + justify-content: flex-start; + text-align: left; + } + } + + ${({ theme }) => theme.mediaWidth.upSmall` + grid-template-columns: 1fr 1fr 1fr 1fr; + grid-template-areas: 'name supply share rewards action'; + `} +`; + +export const HeaderText = styled(Typography)` + font-size: 14px; + text-transform: uppercase; + letter-spacing: 3px; + display: flex; + gap: 5px; + align-items: center; +`; + +const DataText = styled(Flex)` + font-size: 16px; + justify-content: center; + align-items: end; + flex-direction: column; +`; + +const StyledArrowDownIcon = styled(ArrowDownIcon)` + width: 10px; + margin-left: 10px; + margin-top: 10px; + transition: transform 0.3s ease; +`; + +const StyledDataText = styled(Flex)` + font-weight: bold; +`; + +const ListItem = styled(DashGrid)` + padding: 20px 0; + color: #ffffff; +`; + +const APYItem = styled(Flex)` + align-items: flex-end; + line-height: 25px; +`; + +export const PoolRecord = ({ + poolId, + pool, + pair, + pairData, + totalReward, + boostData, + apy, +}: { + pool: Pool; + pair: Pair; + pairData?: PairData; + poolId: number; + totalReward: BigNumber; + boostData: { [key in string]: Source } | undefined; + apy: number | null; +}) => { + const { xChainId } = pool; + const [baseAmount, quoteAmount] = usePoolTokenAmounts(pool); + + const upSmall = useMedia('(min-width: 800px)'); + const stakedLPPercent = useStakedLPPercent(poolId); // TODO + const pairName = `${baseAmount.currency.symbol || '...'}/${quoteAmount.currency.symbol || '...'}`; + const sourceName = pairName === 'sICX/BTCB' ? 'BTCB/sICX' : pairName; + + const { baseValue: baseWithdrawValue, quoteValue: quoteWithdrawValue } = useWithdrawnPercent(poolId) || {}; + const balances = useBalance(poolId); + const stakedFractionValue = stakedFraction(stakedLPPercent); + const totalbBaln = useTotalSupply(); + const userBbaln = useBBalnAmount(); + const reward = getShareReward( + totalReward, + boostData && boostData[sourceName], + balances, + stakedFractionValue, + totalbBaln, + userBbaln, + ); + + const baseSupplyAmount = totalSupply(baseWithdrawValue, baseAmount); + const quoteSupplyAmount = totalSupply(quoteWithdrawValue, quoteAmount); + + const { onCurrencySelection } = useMintActionHandlers(false); + + const handlePoolClick = () => { + if (pairData) { + onCurrencySelection(Field.CURRENCY_A, pairData.info.baseToken); + onCurrencySelection(Field.CURRENCY_B, pairData.info.quoteToken); + } else { + onCurrencySelection(Field.CURRENCY_A, pair.reserve0.currency); + onCurrencySelection(Field.CURRENCY_B, pair.reserve1.currency); + } + }; + + return ( + <> + + + + {poolId}-{xChainId}-{pairName} + + + + + {baseSupplyAmount ? ( + {`${formatBigNumber( + new BigNumber(baseSupplyAmount?.toFixed() || 0), + 'currency', + )} ${baseAmount.currency.symbol}`} + ) : ( + + )} + {quoteSupplyAmount ? ( + {`${formatBigNumber( + new BigNumber(quoteSupplyAmount?.toFixed() || 0), + 'currency', + )} ${quoteAmount.currency.symbol}`} + ) : ( + + )} + + + {upSmall && ( + + {boostData ? ( + apy && + boostData[pairName === 'sICX/BTCB' ? 'BTCB/sICX' : pairName] && + boostData[pairName === 'sICX/BTCB' ? 'BTCB/sICX' : pairName].balance.isGreaterThan(0) ? ( + <> + + + BALN: + + {new BigNumber(apy) + .times( + //hotfix pairName due to wrong source name on contract side + boostData[pairName === 'sICX/BTCB' ? 'BTCB/sICX' : pairName].workingBalance.dividedBy( + boostData[pairName === 'sICX/BTCB' ? 'BTCB/sICX' : pairName].balance, + ), + ) + .times(100) + .toFormat(2)} + % + + + {pairData?.feesApy && ( + + + Fees: + + {getFormattedNumber(pairData.feesApy, 'percent2')} + + )} + + ) : ( + '-' + ) + ) : ( + + )} + + )} + {upSmall && ( + //hotfix pairName due to wrong source name on contract side + {getFormattedRewards(reward)} + )} + + + ); +}; diff --git a/apps/web/src/app/pages/trade/supply/_components/LiquidityDetails/WithdrawPanel.tsx b/apps/web/src/app/pages/trade/supply/_components/LiquidityDetails/WithdrawPanel.tsx index 291b063f6..3a05a95ca 100644 --- a/apps/web/src/app/pages/trade/supply/_components/LiquidityDetails/WithdrawPanel.tsx +++ b/apps/web/src/app/pages/trade/supply/_components/LiquidityDetails/WithdrawPanel.tsx @@ -17,16 +17,16 @@ import Modal from '@/app/components/Modal'; import ModalContent from '@/app/components/ModalContent'; import { Typography } from '@/app/theme'; import { BIGINT_ZERO, FRACTION_ONE, FRACTION_ZERO } from '@/constants/misc'; -import { BalanceData } from '@/hooks/useV2Pairs'; +import { BalanceData, Pool, usePoolTokenAmounts } from '@/hooks/useV2Pairs'; import { Source } from '@/store/bbaln/hooks'; import { Field } from '@/store/mint/reducer'; import { useChangeWithdrawnValue, useStakedLPPercent } from '@/store/stakedLP/hooks'; import { tryParseAmount } from '@/store/swap/hooks'; import { useTransactionAdder } from '@/store/transactions/hooks'; -import { useCurrencyBalances, useHasEnoughICX } from '@/store/wallet/hooks'; +import { useHasEnoughICX } from '@/store/wallet/hooks'; import { formatBigNumber, multiplyCABN, toDec } from '@/utils'; import { showMessageOnBeforeUnload } from '@/utils/messages'; -import { bnJs } from '@balancednetwork/xwagmi'; +import { bnJs, getXChainType, useXAccount, useXRemoveLiquidity } from '@balancednetwork/xwagmi'; import { EXA, WEIGHT } from '@/app/components/home/BBaln/utils'; import { withdrawMessage } from '../utils'; @@ -105,9 +105,8 @@ export function getShareReward( return new BigNumber(0); } -export const WithdrawPanel = ({ pair, balance, poolId }: { pair: Pair; balance: BalanceData; poolId: number }) => { +export const WithdrawPanel = ({ pair, pool, poolId }: { pair: Pair; pool: Pool; poolId: number }) => { const { account } = useIconReact(); - const balances = useCurrencyBalances(useMemo(() => [pair.token0, pair.token1], [pair])); const onChangeWithdrawnValue = useChangeWithdrawnValue(); const [{ typedValue, independentField, inputType, portion }, setState] = React.useState<{ @@ -130,7 +129,7 @@ export const WithdrawPanel = ({ pair, balance, poolId }: { pair: Pair; balance: const percent = useMemo(() => new Percent(Math.floor(portion * 100), 10_000), [portion]); const stakedLPPercent = useStakedLPPercent(poolId); - const [aBalance, bBalance] = getABBalance(pair, balance); + const [aBalance, bBalance] = usePoolTokenAmounts(pool); const availablePercent = new BigNumber(100).minus(stakedLPPercent).abs(); const availableBase = aBalance.multiply(availablePercent.toFixed(0)).divide(100); const availableQuote = bBalance.multiply(availablePercent.toFixed(0)).divide(100); @@ -229,47 +228,53 @@ export const WithdrawPanel = ({ pair, balance, poolId }: { pair: Pair; balance: setState({ typedValue, independentField, inputType: 'slider', portion: 0 }); }; - const handleWithdraw = () => { - if (!account) return; + const xAccount = useXAccount(getXChainType(pool.xChainId)); + const xRemoveLiquidity = useXRemoveLiquidity(); + const handleWithdraw = async () => { window.addEventListener('beforeunload', showMessageOnBeforeUnload); const numPortion = new BigNumber(portion / 100); - - const t = multiplyCABN(balance.balance, numPortion); - - const aT = multiplyCABN(availableBase, numPortion); - const bT = multiplyCABN(availableQuote, numPortion); - - bnJs - .inject({ account }) - .Dex.remove(poolId, toDec(t)) - .then(result => { - addTransaction( - { hash: result.result }, - { - pending: withdrawMessage( - aT.toFixed(2, { groupSeparator: ',' }), - aT.currency.symbol ?? '', - bT.toFixed(2, { groupSeparator: ',' }), - bT.currency.symbol ?? '', - ).pendingMessage, - summary: withdrawMessage( - aT.toFixed(2, { groupSeparator: ',' }), - aT.currency.symbol ?? '', - bT.toFixed(2, { groupSeparator: ',' }), - bT.currency.symbol ?? '', - ).successMessage, - }, - ); - toggleOpen(); - }) - .catch(e => { - console.error('error', e); - }) - .finally(() => { - window.removeEventListener('beforeunload', showMessageOnBeforeUnload); - resetValue(); - }); + const withdrawAmount = multiplyCABN(pool.balance, numPortion); + await xRemoveLiquidity(xAccount.address, poolId, pool.xChainId, withdrawAmount); + + window.removeEventListener('beforeunload', showMessageOnBeforeUnload); + + // if (!account) return; + // window.addEventListener('beforeunload', showMessageOnBeforeUnload); + // const numPortion = new BigNumber(portion / 100); + // const t = multiplyCABN(pool.balance, numPortion); + // const aT = multiplyCABN(availableBase, numPortion); + // const bT = multiplyCABN(availableQuote, numPortion); + // bnJs + // .inject({ account }) + // .Dex.remove(poolId, toDec(t)) + // .then(result => { + // addTransaction( + // { hash: result.result }, + // { + // pending: withdrawMessage( + // aT.toFixed(2, { groupSeparator: ',' }), + // aT.currency.symbol ?? '', + // bT.toFixed(2, { groupSeparator: ',' }), + // bT.currency.symbol ?? '', + // ).pendingMessage, + // summary: withdrawMessage( + // aT.toFixed(2, { groupSeparator: ',' }), + // aT.currency.symbol ?? '', + // bT.toFixed(2, { groupSeparator: ',' }), + // bT.currency.symbol ?? '', + // ).successMessage, + // }, + // ); + // toggleOpen(); + // }) + // .catch(e => { + // console.error('error', e); + // }) + // .finally(() => { + // window.removeEventListener('beforeunload', showMessageOnBeforeUnload); + // resetValue(); + // }); }; const handleShowConfirm = () => { @@ -278,10 +283,6 @@ export const WithdrawPanel = ({ pair, balance, poolId }: { pair: Pair; balance: const hasEnoughICX = useHasEnoughICX(); - const availableCurrency = (stakedValue, suppliedValue) => - (!!stakedValue ? suppliedValue?.subtract(stakedValue) : suppliedValue)?.toFixed(2, { groupSeparator: ',' }) || - '...'; - const isValid = formattedAmounts[Field.CURRENCY_A] && formattedAmounts[Field.CURRENCY_B] && @@ -324,7 +325,7 @@ export const WithdrawPanel = ({ pair, balance, poolId }: { pair: Pair; balance: : availableBase?.toFixed() || 0, ), 'currency', - )} ${balances[0]?.currency.symbol || '...'} / + )} ${pair.token0.symbol || '...'} / ${formatBigNumber( new BigNumber( parsedAmount[Field.CURRENCY_B] @@ -332,7 +333,7 @@ export const WithdrawPanel = ({ pair, balance, poolId }: { pair: Pair; balance: : availableQuote?.toFixed() || 0, ), 'currency', - )} ${balances[1]?.currency.symbol || '...'}`} + )} ${pair.token1.symbol || '...'}`} {hasUnstakedLP && ( diff --git a/apps/web/src/app/pages/trade/supply/_components/LiquidityDetails/shared.tsx b/apps/web/src/app/pages/trade/supply/_components/LiquidityDetails/shared.tsx index 666a34d56..f66d509e6 100644 --- a/apps/web/src/app/pages/trade/supply/_components/LiquidityDetails/shared.tsx +++ b/apps/web/src/app/pages/trade/supply/_components/LiquidityDetails/shared.tsx @@ -1,11 +1,12 @@ -import { BalancedJs } from '@balancednetwork/balanced-js'; -import { omit } from 'lodash-es'; -import styled from 'styled-components'; - import { BoxPanel } from '@/app/components/Panel'; +import { Typography } from '@/app/theme'; +import ArrowDownIcon from '@/assets/icons/arrow-line.svg'; import { MINIMUM_B_BALANCE_TO_SHOW_POOL } from '@/constants/index'; import { BIGINT_ZERO } from '@/constants/misc'; - +import { BalancedJs } from '@balancednetwork/balanced-js'; +import { omit } from 'lodash-es'; +import { Flex } from 'rebass/styled-components'; +import styled from 'styled-components'; import { usePoolPanelContext } from '../PoolPanelContext'; export const useHasLiquidity = (): boolean => { @@ -40,3 +41,63 @@ export const StyledBoxPanel = styled(BoxPanel)` flex-direction: row; `} `; + +export const DashGrid = styled.div` + display: grid; + grid-template-columns: 4fr 5fr; + gap: 10px; + grid-template-areas: 'name supply action'; + align-items: center; + + & > * { + justify-content: flex-end; + text-align: right; + + &:first-child { + justify-content: flex-start; + text-align: left; + } + } + + ${({ theme }) => theme.mediaWidth.upSmall` + grid-template-columns: 1fr 1fr 1fr 1fr; + grid-template-areas: 'name supply share rewards action'; + `} +`; + +export const HeaderText = styled(Typography)` + font-size: 14px; + text-transform: uppercase; + letter-spacing: 3px; + display: flex; + gap: 5px; + align-items: center; +`; + +export const DataText = styled(Flex)` + font-size: 16px; + justify-content: center; + align-items: end; + flex-direction: column; +`; + +export const StyledArrowDownIcon = styled(ArrowDownIcon)` + width: 10px; + margin-left: 10px; + margin-top: 10px; + transition: transform 0.3s ease; +`; + +export const StyledDataText = styled(Flex)` + font-weight: bold; +`; + +export const ListItem = styled(DashGrid)` + padding: 20px 0; + color: #ffffff; +`; + +export const APYItem = styled(Flex)` + align-items: flex-end; + line-height: 25px; +`; diff --git a/apps/web/src/app/pages/trade/supply/_components/utils.tsx b/apps/web/src/app/pages/trade/supply/_components/utils.tsx index 96f69fabd..0558944dc 100644 --- a/apps/web/src/app/pages/trade/supply/_components/utils.tsx +++ b/apps/web/src/app/pages/trade/supply/_components/utils.tsx @@ -54,8 +54,8 @@ export const stakedFraction = stakedLPPercent => { return stakedFraction; }; -export const totalSupply = (stakedValue: CurrencyAmount, suppliedValue?: CurrencyAmount) => - !!stakedValue ? suppliedValue?.subtract(stakedValue) : suppliedValue; +export const totalSupply = (withdrawValue: CurrencyAmount, suppliedValue?: CurrencyAmount) => + !!withdrawValue ? suppliedValue?.subtract(withdrawValue) : suppliedValue; export const getFormattedRewards = (reward: BigNumber): string => { return reward?.isEqualTo(ZERO) ? 'N/A' : `~ ${formatBigNumber(reward, 'currency')} BALN`; diff --git a/apps/web/src/hooks/useV2Pairs.ts b/apps/web/src/hooks/useV2Pairs.ts index d84a431df..26816c374 100644 --- a/apps/web/src/hooks/useV2Pairs.ts +++ b/apps/web/src/hooks/useV2Pairs.ts @@ -1,8 +1,8 @@ -import { useQuery } from '@tanstack/react-query'; +import { keepPreviousData, useQuery } from '@tanstack/react-query'; import { useEffect, useMemo, useState } from 'react'; import { BalancedJs, CallData } from '@balancednetwork/balanced-js'; -import { Currency, CurrencyAmount, Fraction, Token } from '@balancednetwork/sdk-core'; +import { Currency, CurrencyAmount, Fraction, Token, XChainId } from '@balancednetwork/sdk-core'; import { Pair } from '@balancednetwork/v1-sdk'; import BigNumber from 'bignumber.js'; @@ -12,7 +12,7 @@ import { BIGINT_ZERO, FRACTION_ZERO } from '@/constants/misc'; import { bnUSD } from '@/constants/tokens'; import { fetchStabilityFundBalances, getAcceptedTokens } from '@/store/stabilityFund/hooks'; import { getPair } from '@/utils'; -import { bnJs } from '@balancednetwork/xwagmi'; +import { XToken, bnJs } from '@balancednetwork/xwagmi'; import { NETWORK_ID } from '@/constants/config'; import useLastCount from './useLastCount'; @@ -328,3 +328,105 @@ export function useBalance(poolId: number) { const { balances } = usePoolPanelContext(); return balances[poolId]; } + +////////////////////////////////////////////////////////////////////////////////////////// +export interface Pool { + poolId: number; + xChainId: XChainId; + account: string; // TODO: name to owner? + balance: CurrencyAmount; + stakedLPBalance?: CurrencyAmount; + suppliedLP?: CurrencyAmount; + pair: Pair; +} + +export function usePools(pairs: { [poolId: number]: Pair }, accounts: string[]): Pool[] | undefined { + const { data: balances } = useQuery({ + queryKey: ['lpBalances', pairs, accounts], + queryFn: async (): Promise => { + if (!accounts.length) return []; + + const poolKeys = Object.keys(pairs); + + const cds = poolKeys.flatMap(poolId => { + return accounts.flatMap(account => [ + { + target: bnJs.Dex.address, + method: 'xBalanceOf', + params: [account, `0x${(+poolId).toString(16)}`], + }, + { + target: bnJs.Dex.address, + method: 'totalSupply', + params: [`0x${(+poolId).toString(16)}`], + }, + { + target: bnJs.StakedLP.address, + method: 'xBalanceOf', + params: [account, `0x${(+poolId).toString(16)}`], + }, + ]); + }); + // const data: any[] = await bnJs.Multicall.getAggregateData(cds.slice(0, 100)); + // console.log('data', data); + + const chunks = chunkArray(cds, MULTI_CALL_BATCH_SIZE); + const chunkedData = await Promise.all(chunks.map(async chunk => await bnJs.Multicall.getAggregateData(chunk))); + const data: any[] = chunkedData.flat(); + + const pools = poolKeys.map((poolId, poolIndex) => { + const pair = pairs[+poolId]; + + const accountPools = accounts.map((account, accountIndex) => { + const _startIndex = poolIndex * accounts.length * 3 + accountIndex * 3; + const balance = data[_startIndex]; + const totalSupply = data[_startIndex + 1]; + const stakedLPBalance = data[_startIndex + 2]; + + const xChainId = account.split('/')[0] as XChainId; + return { + poolId: +poolId, + xChainId, + account, + balance: CurrencyAmount.fromRawAmount(pair.liquidityToken, new BigNumber(balance || 0, 16).toFixed()), + suppliedLP: CurrencyAmount.fromRawAmount( + pair.liquidityToken, + new BigNumber(totalSupply || 0, 16).toFixed(), + ), + stakedLPBalance: CurrencyAmount.fromRawAmount( + pair.liquidityToken, + new BigNumber(stakedLPBalance || 0, 16).toFixed(), + ), + pair, + }; + }); + + return accountPools; + }); + + return pools.flat(); + }, + refetchInterval: 10_000, + placeholderData: keepPreviousData, + }); + + return balances; +} + +export const usePoolTokenAmounts = (pool: Pool) => { + const { balance, stakedLPBalance, pair } = pool; + + const rate = useMemo(() => { + if (pair.totalSupply && pair.totalSupply.quotient > BIGINT_ZERO) { + const amount = (stakedLPBalance ? balance.add(stakedLPBalance) : balance).divide(pair.totalSupply); + return new Fraction(amount.numerator, amount.denominator); + } + return FRACTION_ZERO; + }, [balance, pair, stakedLPBalance]); + + const [base, quote] = useMemo(() => { + return [pair.reserve0.multiply(rate), pair.reserve1.multiply(rate)]; + }, [pair, rate]); + + return [base, quote]; +}; diff --git a/packages/xwagmi/src/hooks/liquidity/index.ts b/packages/xwagmi/src/hooks/liquidity/index.ts index 95de34c6f..2abca5dd7 100644 --- a/packages/xwagmi/src/hooks/liquidity/index.ts +++ b/packages/xwagmi/src/hooks/liquidity/index.ts @@ -2,3 +2,4 @@ export { useXTokenDepositAmount } from './useXTokenDepositAmount'; export { useDepositXToken } from './useDepositXToken'; export { useWithdrawXToken } from './useWithdrawXToken'; export { useXAddLiquidity } from './useXAddLiquidity'; +export { useXRemoveLiquidity } from './useXRemoveLiquidity'; diff --git a/packages/xwagmi/src/hooks/liquidity/useXRemoveLiquidity.ts b/packages/xwagmi/src/hooks/liquidity/useXRemoveLiquidity.ts new file mode 100644 index 000000000..5498f6883 --- /dev/null +++ b/packages/xwagmi/src/hooks/liquidity/useXRemoveLiquidity.ts @@ -0,0 +1,39 @@ +import { xTokenMapBySymbol } from '@/constants'; +import { XTransactionInput, XTransactionType } from '@/xcall/types'; +import { CurrencyAmount, Token, XChainId } from '@balancednetwork/sdk-core'; +import BigNumber from 'bignumber.js'; +import { useMemo } from 'react'; +import { useSendXTransaction } from '../useSendXTransaction'; + +export const useXRemoveLiquidity = () => { + const { sendXTransaction } = useSendXTransaction(); + + const xRemoveLiquidity = useMemo( + () => async (account, poolId: number, xChainId: XChainId, withdrawAmount: CurrencyAmount) => { + const BALN = xTokenMapBySymbol[xChainId]['BALN']; + const inputAmount = CurrencyAmount.fromRawAmount( + BALN, + new BigNumber(withdrawAmount.toFixed()) + .times((10n ** BigInt(withdrawAmount.currency.decimals)).toString()) + .toFixed(0), + ); + + const xTransactionInput: XTransactionInput = { + type: XTransactionType.LP_REMOVE_LIQUIDITY, + account: account, + inputAmount, + poolId, + xCallFee: { rollback: 60000000000000n, noRollback: 0n }, + direction: { + from: xChainId, + to: '0x1.icon', + }, + }; + + return await sendXTransaction(xTransactionInput); + }, + [sendXTransaction], + ); + + return xRemoveLiquidity; +}; diff --git a/packages/xwagmi/src/xcall/types.ts b/packages/xwagmi/src/xcall/types.ts index 18c461835..0c9d2c6ed 100644 --- a/packages/xwagmi/src/xcall/types.ts +++ b/packages/xwagmi/src/xcall/types.ts @@ -68,6 +68,7 @@ export type XTransactionInput = { type: XTransactionType; inputAmount: CurrencyAmount; outputAmount?: CurrencyAmount; // quote token for liquidity + poolId?: number; // liquidity pool id account: string; xCallFee: IXCallFee; callback?: () => void; diff --git a/packages/xwagmi/src/xchains/evm/EvmXLiquidityService.ts b/packages/xwagmi/src/xchains/evm/EvmXLiquidityService.ts index dd2ae403f..c03823acb 100644 --- a/packages/xwagmi/src/xchains/evm/EvmXLiquidityService.ts +++ b/packages/xwagmi/src/xchains/evm/EvmXLiquidityService.ts @@ -14,6 +14,7 @@ import { XTransactionInput } from '@/xcall/types'; import { RLP } from '@ethereumjs/rlp'; import { Address, toHex } from 'viem'; import { EvmXWalletClient } from './EvmXWalletClient'; +import { getXRemoveData } from './utils'; export class EvmXLiquidityService { constructor(private client: EvmXWalletClient) {} @@ -158,7 +159,41 @@ export class EvmXLiquidityService { return hash; } - async removeLiquidity(xTransactionInput: XTransactionInput) {} + async removeLiquidity(xTransactionInput: XTransactionInput) { + const { account, inputAmount, poolId, xCallFee } = xTransactionInput; + + if (!poolId) { + throw new Error('poolId is required'); + } + + const publicClient = this.client.getPublicClient(); + const walletClient = await this.client.getWalletClient(); + + const destination = `${ICON_XCALL_NETWORK_ID}/${bnJs.Dex.address}`; + const amount = BigInt(inputAmount.quotient.toString()); + const data = toHex(getXRemoveData(poolId, amount, true)); + + const envelope = toHex( + RLP.encode([ + Buffer.from([0]), + data, + FROM_SOURCES[this.client.xChainId]?.map(Buffer.from), + TO_SOURCES[this.client.xChainId]?.map(Buffer.from), + ]), + ); + + const res = await publicClient.simulateContract({ + account: account as Address, + address: xChainMap[this.client.xChainId].contracts.xCall as Address, + abi: xCallContractAbi, + functionName: 'sendCall', + args: [destination, envelope], + value: xCallFee.rollback, + }); + + const hash = await walletClient.writeContract(res.request); + return hash; + } async stake(xTransactionInput: XTransactionInput) {} async unstake(xTransactionInput: XTransactionInput) {} async claimRewards(xTransactionInput: XTransactionInput) {} diff --git a/packages/xwagmi/src/xchains/evm/utils.ts b/packages/xwagmi/src/xchains/evm/utils.ts index e69de29bb..0cfe60bc9 100644 --- a/packages/xwagmi/src/xchains/evm/utils.ts +++ b/packages/xwagmi/src/xchains/evm/utils.ts @@ -0,0 +1,50 @@ +import { uintToBytes } from '@/utils'; +import { RLP } from '@ethereumjs/rlp'; + +// // add liquidity +// function getAddLPData( +// baseToken: string, +// quoteToken: string, +// baseValue: number, +// quoteValue: number, +// withdrawUnused: boolean, +// slippagePercentage: number, +// ): Uint8Array { +// let rlpInput: rlp.Input = [ +// 'xAdd', +// baseToken, +// quoteToken, +// baseValue, +// quoteValue, +// withdrawUnused ? 1 : 0, +// slippagePercentage, +// ]; +// return rlp.encode(rlpInput); +// } + +// stake +export function getStakeData(to: string, amount: bigint, poolId: number): Uint8Array { + return RLP.encode(['xhubtransfer', Buffer.from(to, 'utf-8'), amount, poolId, Buffer.alloc(0)]); +} + +// // claim rewards +// function getClaimRewardData(to: string, sources: string[]): Uint8Array { +// let rlpInput: rlp.Input = ['xclaimrewards', to, sources]; +// return rlp.encode(rlpInput); +// } + +// unstake +export function getUnStakeData(poolId: number, amount: number): Uint8Array { + return RLP.encode(['xunstake', poolId, amount]); +} + +// remove liquidity +export function getXRemoveData(poolId: number, lpTokenBalance: bigint, withdraw: boolean): Uint8Array { + return RLP.encode(['xRemove', poolId, uintToBytes(lpTokenBalance), withdraw ? uintToBytes(1n) : uintToBytes(0n)]); +} + +// // withdraw the deposited amount +// function getWithdrawData(token: string, amount: number): Uint8Array { +// let rlpInput: rlp.Input = ['xwithdraw', token, amount]; +// return rlp.encode(rlpInput); +// } From be32b51f3b78f8fea695ac8edcbedb03d978cf0a Mon Sep 17 00:00:00 2001 From: swiftcc624 Date: Wed, 8 Jan 2025 17:52:40 +0800 Subject: [PATCH 06/33] update url search params when pair is changed in supply page --- apps/web/src/store/mint/hooks.tsx | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/apps/web/src/store/mint/hooks.tsx b/apps/web/src/store/mint/hooks.tsx index 337ca0448..dbcc91c2e 100644 --- a/apps/web/src/store/mint/hooks.tsx +++ b/apps/web/src/store/mint/hooks.tsx @@ -444,6 +444,7 @@ export function useInitialSupplyLoad(): void { } else if (currentCurrA?.toLowerCase() === 'icx') { ICX && onCurrencySelection(Field.CURRENCY_A, xTokenMapBySymbol[xChainId][ICX.symbol]); } else { + // TODO: is this necessary? if (currencies.CURRENCY_A && currencies.CURRENCY_B) { navigate( `/trade/supply/${currencies.CURRENCY_A.symbol}:${currencies.CURRENCY_A.xChainId}_${currencies.CURRENCY_B.symbol}`, @@ -471,4 +472,18 @@ export function useInitialSupplyLoad(): void { pair, navigate, ]); + + useEffect(() => { + if (!firstLoad && currencies && currencies[Field.CURRENCY_A] && currencies[Field.CURRENCY_B]) { + const xChainId = currencies[Field.CURRENCY_A]?.xChainId; + + const inputCurrency = `${currencies[Field.CURRENCY_A].symbol}${xChainId ? `:${xChainId}` : ''}`; + const outputCurrency = `${currencies[Field.CURRENCY_B].symbol}`; + const newPair = `${inputCurrency}_${outputCurrency}`; + + if (pair !== newPair) { + navigate(`/trade/supply/${newPair}`, { replace: true }); + } + } + }, [currencies, pair, navigate, firstLoad]); } From 89d67493ee4bcb429aafedd02d30a3b965f053b2 Mon Sep 17 00:00:00 2001 From: swiftcc624 Date: Wed, 8 Jan 2025 19:02:10 +0800 Subject: [PATCH 07/33] crosschain lp - stake, unstake --- .../supply/_components/LiquidityDetails.tsx | 8 +- .../LiquidityDetails/StakeLPPanel.tsx | 146 ++++++++++-------- .../LiquidityDetails/WithdrawPanel.tsx | 4 +- packages/xwagmi/src/hooks/liquidity/index.ts | 2 + .../src/hooks/liquidity/useXStakeLPToken.ts | 37 +++++ .../src/hooks/liquidity/useXUnstakeLPToken.ts | 37 +++++ .../src/xchains/evm/EvmXLiquidityService.ts | 78 +++++++++- packages/xwagmi/src/xchains/evm/utils.ts | 10 +- 8 files changed, 242 insertions(+), 80 deletions(-) create mode 100644 packages/xwagmi/src/hooks/liquidity/useXStakeLPToken.ts create mode 100644 packages/xwagmi/src/hooks/liquidity/useXUnstakeLPToken.ts diff --git a/apps/web/src/app/pages/trade/supply/_components/LiquidityDetails.tsx b/apps/web/src/app/pages/trade/supply/_components/LiquidityDetails.tsx index 8c7dcd431..3b619d49b 100644 --- a/apps/web/src/app/pages/trade/supply/_components/LiquidityDetails.tsx +++ b/apps/web/src/app/pages/trade/supply/_components/LiquidityDetails.tsx @@ -200,12 +200,8 @@ export default function LiquidityDetails() { diff --git a/apps/web/src/app/pages/trade/supply/_components/LiquidityDetails/StakeLPPanel.tsx b/apps/web/src/app/pages/trade/supply/_components/LiquidityDetails/StakeLPPanel.tsx index 4e25b4237..87082ea1e 100644 --- a/apps/web/src/app/pages/trade/supply/_components/LiquidityDetails/StakeLPPanel.tsx +++ b/apps/web/src/app/pages/trade/supply/_components/LiquidityDetails/StakeLPPanel.tsx @@ -2,7 +2,6 @@ import React, { useEffect, useCallback, useMemo } from 'react'; import { useIconReact } from '@/packages/icon-react'; import Nouislider from '@/packages/nouislider-react'; -import { Pair } from '@balancednetwork/v1-sdk'; import { Trans } from '@lingui/macro'; import BigNumber from 'bignumber.js'; import { useMedia } from 'react-use'; @@ -14,36 +13,32 @@ import Modal from '@/app/components/Modal'; import ModalContent from '@/app/components/ModalContent'; import { Typography } from '@/app/theme'; import { SLIDER_RANGE_MAX_BOTTOM_THRESHOLD, ZERO } from '@/constants/index'; -import { useBalance } from '@/hooks/useV2Pairs'; +import { Pool, usePoolTokenAmounts } from '@/hooks/useV2Pairs'; import { useAllPairsById } from '@/queries/backendv2'; import { useIncentivisedPairs } from '@/queries/reward'; import { useBBalnAmount, useSources, useTotalSupply } from '@/store/bbaln/hooks'; import { useRewards } from '@/store/reward/hooks'; -import { useChangeStakedLPPercent, useStakedLPPercent, useTotalStaked } from '@/store/stakedLP/hooks'; +import { useChangeStakedLPPercent, useStakedLPPercent } from '@/store/stakedLP/hooks'; import { useTransactionAdder } from '@/store/transactions/hooks'; import { useHasEnoughICX } from '@/store/wallet/hooks'; import { formatBigNumber, parseUnits } from '@/utils'; import { showMessageOnBeforeUnload } from '@/utils/messages'; -import { bnJs } from '@balancednetwork/xwagmi'; +import { getXChainType, useXAccount, useXStakeLPToken, useXUnstakeLPToken } from '@balancednetwork/xwagmi'; import Skeleton from '@/app/components/Skeleton'; import { getFormattedRewards, stakedFraction } from '../utils'; -import { getABBalance, getShareReward } from './WithdrawPanel'; +import { getShareReward } from './WithdrawPanel'; -export default function StakeLPPanel({ pair }: { pair: Pair }) { - const { account } = useIconReact(); - const poolId = pair.poolId!; +export default function StakeLPPanel({ pool }: { pool: Pool }) { + const { poolId, pair, balance: lpBalance, stakedLPBalance } = pool; const sources = useSources(); const { data: allPairs } = useAllPairsById(); const { data: incentivisedPairs } = useIncentivisedPairs(); - const balance = useBalance(poolId); - const stakedBalance = useMemo( - () => new BigNumber(balance?.stakedLPBalance?.toFixed() || 0), - [balance?.stakedLPBalance], - ); + const stakedBalance = useMemo(() => new BigNumber(stakedLPBalance?.toFixed() || 0), [stakedLPBalance]); - const totalStaked = useTotalStaked(poolId); + // TODO: rename to totalLPBalance + const totalStaked = new BigNumber(stakedBalance.toFixed()).plus(lpBalance.toFixed()); const onStakedLPPercentSelected = useChangeStakedLPPercent(); const stakedPercent = useStakedLPPercent(poolId); @@ -94,57 +89,78 @@ export default function StakeLPPanel({ pair }: { pair: Pair }) { const addTransaction = useTransactionAdder(); - const handleConfirm = () => { + const xStakeLPToken = useXStakeLPToken(); + const xUnstakeLPToken = useXUnstakeLPToken(); + const xAccount = useXAccount(getXChainType(pool.xChainId)); + + const handleConfirm = async () => { window.addEventListener('beforeunload', showMessageOnBeforeUnload); - const decimals = Math.ceil((pair.token0.decimals + pair.token1.decimals) / 2); - if (shouldStake) { - bnJs - .inject({ account: account }) - .Dex.stake(poolId, parseUnits(differenceAmount.toFixed(), decimals)) - .then(res => { - if (res.result) { - addTransaction( - { hash: res.result }, - { - pending: 'Staking LP tokens...', - summary: `Staked ${differenceAmount.abs().dp(2).toFormat()} LP tokens.`, - }, - ); - - toggleOpen(); - handleCancel(); - } else { - console.error(res); - } - }) - .finally(() => { - window.removeEventListener('beforeunload', showMessageOnBeforeUnload); - }); - } else { - bnJs - .inject({ account: account }) - .StakedLP.unstake(poolId, parseUnits(differenceAmount.abs().toFixed(), decimals)) - .then(res => { - if (res.result) { - addTransaction( - { hash: res.result }, - { - pending: 'Unstaking LP tokens...', - summary: `Unstaked ${differenceAmount.abs().dp(2).toFormat()} LP tokens.`, - }, - ); - - toggleOpen(); - handleCancel(); - } else { - console.error(res); - } - }) - .finally(() => { - window.removeEventListener('beforeunload', showMessageOnBeforeUnload); - }); + try { + const decimals = Math.ceil((pair.token0.decimals + pair.token1.decimals) / 2); + if (shouldStake) { + await xStakeLPToken(xAccount.address, poolId, pool.xChainId, differenceAmount.toFixed(), decimals); + } else { + console.log('differenceAmount.toFixed()', differenceAmount.toFixed()); + await xUnstakeLPToken(xAccount.address, poolId, pool.xChainId, differenceAmount.abs().toFixed(), decimals); + } + + toggleOpen(); + handleCancel(); + } catch (e) { + console.error(e); } + + window.removeEventListener('beforeunload', showMessageOnBeforeUnload); + + // const decimals = Math.ceil((pair.token0.decimals + pair.token1.decimals) / 2); + // if (shouldStake) { + // bnJs + // .inject({ account: account }) + // .Dex.stake(poolId, parseUnits(differenceAmount.toFixed(), decimals)) + // .then(res => { + // if (res.result) { + // addTransaction( + // { hash: res.result }, + // { + // pending: 'Staking LP tokens...', + // summary: `Staked ${differenceAmount.abs().dp(2).toFormat()} LP tokens.`, + // }, + // ); + + // toggleOpen(); + // handleCancel(); + // } else { + // console.error(res); + // } + // }) + // .finally(() => { + // window.removeEventListener('beforeunload', showMessageOnBeforeUnload); + // }); + // } else { + // bnJs + // .inject({ account: account }) + // .StakedLP.unstake(poolId, parseUnits(differenceAmount.abs().toFixed(), decimals)) + // .then(res => { + // if (res.result) { + // addTransaction( + // { hash: res.result }, + // { + // pending: 'Unstaking LP tokens...', + // summary: `Unstaked ${differenceAmount.abs().dp(2).toFormat()} LP tokens.`, + // }, + // ); + + // toggleOpen(); + // handleCancel(); + // } else { + // console.error(res); + // } + // }) + // .finally(() => { + // window.removeEventListener('beforeunload', showMessageOnBeforeUnload); + // }); + // } }; const description = shouldStake ? "You'll earn BALN until you unstake them." : "You'll stop earning BALN from them."; @@ -154,17 +170,19 @@ export default function StakeLPPanel({ pair }: { pair: Pair }) { const upSmall = useMedia('(min-width: 800px)'); const rewards = useRewards(); - const [aBalance, bBalance] = getABBalance(pair, balance); + const [aBalance, bBalance] = usePoolTokenAmounts(pool); const pairName = `${aBalance.currency.symbol || '...'}/${bBalance.currency.symbol || '...'}`; const sourceName = pairName === 'sICX/BTCB' ? 'BTCB/sICX' : pairName; const totalReward = rewards[sourceName]; const stakedFractionValue = stakedFraction(stakedPercent); const totalBbaln = useTotalSupply(); const userBbaln = useBBalnAmount(); + + // TODO: understand and rewrite to support crosschain const reward = getShareReward( totalReward, sources && sources[sourceName], - balance, + pool, stakedFractionValue, totalBbaln, userBbaln, diff --git a/apps/web/src/app/pages/trade/supply/_components/LiquidityDetails/WithdrawPanel.tsx b/apps/web/src/app/pages/trade/supply/_components/LiquidityDetails/WithdrawPanel.tsx index 3a05a95ca..e8903515c 100644 --- a/apps/web/src/app/pages/trade/supply/_components/LiquidityDetails/WithdrawPanel.tsx +++ b/apps/web/src/app/pages/trade/supply/_components/LiquidityDetails/WithdrawPanel.tsx @@ -105,8 +105,8 @@ export function getShareReward( return new BigNumber(0); } -export const WithdrawPanel = ({ pair, pool, poolId }: { pair: Pair; pool: Pool; poolId: number }) => { - const { account } = useIconReact(); +export const WithdrawPanel = ({ pool }: { pool: Pool }) => { + const { pair, poolId } = pool; const onChangeWithdrawnValue = useChangeWithdrawnValue(); const [{ typedValue, independentField, inputType, portion }, setState] = React.useState<{ diff --git a/packages/xwagmi/src/hooks/liquidity/index.ts b/packages/xwagmi/src/hooks/liquidity/index.ts index 2abca5dd7..93d4f0618 100644 --- a/packages/xwagmi/src/hooks/liquidity/index.ts +++ b/packages/xwagmi/src/hooks/liquidity/index.ts @@ -3,3 +3,5 @@ export { useDepositXToken } from './useDepositXToken'; export { useWithdrawXToken } from './useWithdrawXToken'; export { useXAddLiquidity } from './useXAddLiquidity'; export { useXRemoveLiquidity } from './useXRemoveLiquidity'; +export { useXStakeLPToken } from './useXStakeLPToken'; +export { useXUnstakeLPToken } from './useXUnstakeLPToken'; diff --git a/packages/xwagmi/src/hooks/liquidity/useXStakeLPToken.ts b/packages/xwagmi/src/hooks/liquidity/useXStakeLPToken.ts new file mode 100644 index 000000000..42afab9ce --- /dev/null +++ b/packages/xwagmi/src/hooks/liquidity/useXStakeLPToken.ts @@ -0,0 +1,37 @@ +import { xTokenMapBySymbol } from '@/constants'; +import { XTransactionInput, XTransactionType } from '@/xcall/types'; +import { CurrencyAmount, XChainId } from '@balancednetwork/sdk-core'; +import BigNumber from 'bignumber.js'; +import { useMemo } from 'react'; +import { useSendXTransaction } from '../useSendXTransaction'; + +export const useXStakeLPToken = () => { + const { sendXTransaction } = useSendXTransaction(); + + const xStakeLPToken = useMemo( + () => async (account, poolId: number, xChainId: XChainId, rawStakeAmount: string, decimals: number) => { + const BALN = xTokenMapBySymbol[xChainId]['BALN']; + const inputAmount = CurrencyAmount.fromRawAmount( + BALN, + new BigNumber(rawStakeAmount).times((10n ** BigInt(decimals)).toString()).toFixed(0), + ); + + const xTransactionInput: XTransactionInput = { + type: XTransactionType.LP_STAKE, + account: account, + inputAmount, + poolId, + xCallFee: { rollback: 60000000000000n, noRollback: 0n }, + direction: { + from: xChainId, + to: '0x1.icon', + }, + }; + + return await sendXTransaction(xTransactionInput); + }, + [sendXTransaction], + ); + + return xStakeLPToken; +}; diff --git a/packages/xwagmi/src/hooks/liquidity/useXUnstakeLPToken.ts b/packages/xwagmi/src/hooks/liquidity/useXUnstakeLPToken.ts new file mode 100644 index 000000000..24acd0343 --- /dev/null +++ b/packages/xwagmi/src/hooks/liquidity/useXUnstakeLPToken.ts @@ -0,0 +1,37 @@ +import { xTokenMapBySymbol } from '@/constants'; +import { XTransactionInput, XTransactionType } from '@/xcall/types'; +import { CurrencyAmount, XChainId } from '@balancednetwork/sdk-core'; +import BigNumber from 'bignumber.js'; +import { useMemo } from 'react'; +import { useSendXTransaction } from '../useSendXTransaction'; + +export const useXUnstakeLPToken = () => { + const { sendXTransaction } = useSendXTransaction(); + + const xUnstakeLPToken = useMemo( + () => async (account, poolId: number, xChainId: XChainId, rawUnstakeAmount: string, decimals: number) => { + const BALN = xTokenMapBySymbol[xChainId]['BALN']; + const inputAmount = CurrencyAmount.fromRawAmount( + BALN, + new BigNumber(rawUnstakeAmount).times((10n ** BigInt(decimals)).toString()).toFixed(0), + ); + + const xTransactionInput: XTransactionInput = { + type: XTransactionType.LP_UNSTAKE, + account: account, + inputAmount, + poolId, + xCallFee: { rollback: 60000000000000n, noRollback: 0n }, + direction: { + from: xChainId, + to: '0x1.icon', + }, + }; + + return await sendXTransaction(xTransactionInput); + }, + [sendXTransaction], + ); + + return xUnstakeLPToken; +}; diff --git a/packages/xwagmi/src/xchains/evm/EvmXLiquidityService.ts b/packages/xwagmi/src/xchains/evm/EvmXLiquidityService.ts index c03823acb..fbd02116c 100644 --- a/packages/xwagmi/src/xchains/evm/EvmXLiquidityService.ts +++ b/packages/xwagmi/src/xchains/evm/EvmXLiquidityService.ts @@ -14,7 +14,7 @@ import { XTransactionInput } from '@/xcall/types'; import { RLP } from '@ethereumjs/rlp'; import { Address, toHex } from 'viem'; import { EvmXWalletClient } from './EvmXWalletClient'; -import { getXRemoveData } from './utils'; +import { getStakeData, getUnStakeData, getXRemoveData } from './utils'; export class EvmXLiquidityService { constructor(private client: EvmXWalletClient) {} @@ -194,7 +194,79 @@ export class EvmXLiquidityService { const hash = await walletClient.writeContract(res.request); return hash; } - async stake(xTransactionInput: XTransactionInput) {} - async unstake(xTransactionInput: XTransactionInput) {} + + async stake(xTransactionInput: XTransactionInput) { + const { account, inputAmount, poolId, xCallFee } = xTransactionInput; + + if (!poolId) { + throw new Error('poolId is required'); + } + + const publicClient = this.client.getPublicClient(); + const walletClient = await this.client.getWalletClient(); + + const destination = `${ICON_XCALL_NETWORK_ID}/${bnJs.Dex.address}`; + const amount = BigInt(inputAmount.quotient.toString()); + + const data = toHex(getStakeData(`${ICON_XCALL_NETWORK_ID}/${bnJs.StakedLP.address}`, poolId, amount)); + + const envelope = toHex( + RLP.encode([ + Buffer.from([0]), + data, + FROM_SOURCES[this.client.xChainId]?.map(Buffer.from), + TO_SOURCES[this.client.xChainId]?.map(Buffer.from), + ]), + ); + + const res = await publicClient.simulateContract({ + account: account as Address, + address: xChainMap[this.client.xChainId].contracts.xCall as Address, + abi: xCallContractAbi, + functionName: 'sendCall', + args: [destination, envelope], + value: xCallFee.rollback, + }); + + const hash = await walletClient.writeContract(res.request); + return hash; + } + + async unstake(xTransactionInput: XTransactionInput) { + const { account, inputAmount, poolId, xCallFee } = xTransactionInput; + + if (!poolId) { + throw new Error('poolId is required'); + } + + const publicClient = this.client.getPublicClient(); + const walletClient = await this.client.getWalletClient(); + + const destination = `${ICON_XCALL_NETWORK_ID}/${bnJs.StakedLP.address}`; + const amount = BigInt(inputAmount.quotient.toString()); + const data = toHex(getUnStakeData(poolId, amount)); + + const envelope = toHex( + RLP.encode([ + Buffer.from([0]), + data, + FROM_SOURCES[this.client.xChainId]?.map(Buffer.from), + TO_SOURCES[this.client.xChainId]?.map(Buffer.from), + ]), + ); + + const res = await publicClient.simulateContract({ + account: account as Address, + address: xChainMap[this.client.xChainId].contracts.xCall as Address, + abi: xCallContractAbi, + functionName: 'sendCall', + args: [destination, envelope], + value: xCallFee.rollback, + }); + + const hash = await walletClient.writeContract(res.request); + return hash; + } + async claimRewards(xTransactionInput: XTransactionInput) {} } diff --git a/packages/xwagmi/src/xchains/evm/utils.ts b/packages/xwagmi/src/xchains/evm/utils.ts index 0cfe60bc9..b0c88044f 100644 --- a/packages/xwagmi/src/xchains/evm/utils.ts +++ b/packages/xwagmi/src/xchains/evm/utils.ts @@ -23,8 +23,8 @@ import { RLP } from '@ethereumjs/rlp'; // } // stake -export function getStakeData(to: string, amount: bigint, poolId: number): Uint8Array { - return RLP.encode(['xhubtransfer', Buffer.from(to, 'utf-8'), amount, poolId, Buffer.alloc(0)]); +export function getStakeData(to: string, poolId: number, amount: bigint): Uint8Array { + return RLP.encode(['xhubtransfer', Buffer.from(to, 'utf-8'), uintToBytes(amount), poolId, Buffer.alloc(0)]); } // // claim rewards @@ -34,13 +34,13 @@ export function getStakeData(to: string, amount: bigint, poolId: number): Uint8A // } // unstake -export function getUnStakeData(poolId: number, amount: number): Uint8Array { - return RLP.encode(['xunstake', poolId, amount]); +export function getUnStakeData(poolId: number, amount: bigint): Uint8Array { + return RLP.encode(['xunstake', poolId, uintToBytes(amount)]); } // remove liquidity export function getXRemoveData(poolId: number, lpTokenBalance: bigint, withdraw: boolean): Uint8Array { - return RLP.encode(['xRemove', poolId, uintToBytes(lpTokenBalance), withdraw ? uintToBytes(1n) : uintToBytes(0n)]); + return RLP.encode(['xremove', poolId, uintToBytes(lpTokenBalance), withdraw ? uintToBytes(1n) : uintToBytes(0n)]); } // // withdraw the deposited amount From 5a8e5faa348715c80cfc830766365ddf9b8fadab Mon Sep 17 00:00:00 2001 From: swiftcc624 Date: Wed, 8 Jan 2025 23:35:28 +0800 Subject: [PATCH 08/33] useXTokenDepositAmount refactor --- .../supply/_components/SendRemoveXToken.tsx | 21 ++++------ .../_components/SupplyLiquidityModal.tsx | 4 +- .../src/hooks/liquidity/useWithdrawXToken.ts | 10 ++--- .../hooks/liquidity/useXTokenDepositAmount.ts | 42 +++++++------------ 4 files changed, 28 insertions(+), 49 deletions(-) diff --git a/apps/web/src/app/pages/trade/supply/_components/SendRemoveXToken.tsx b/apps/web/src/app/pages/trade/supply/_components/SendRemoveXToken.tsx index db817dabd..828f00a38 100644 --- a/apps/web/src/app/pages/trade/supply/_components/SendRemoveXToken.tsx +++ b/apps/web/src/app/pages/trade/supply/_components/SendRemoveXToken.tsx @@ -1,6 +1,5 @@ import React, { useEffect } from 'react'; -import { useIconReact } from '@/packages/icon-react'; import { t } from '@lingui/macro'; import { Box, Flex } from 'rebass/styled-components'; import styled from 'styled-components'; @@ -8,7 +7,6 @@ import styled from 'styled-components'; import { Button } from '@/app/components/Button'; import { Typography } from '@/app/theme'; import CheckIcon from '@/assets/icons/tick.svg'; -import { useEditState } from '@/store/liveVoting/hooks'; import { Field } from '@/store/mint/reducer'; import { Currency, CurrencyAmount } from '@balancednetwork/sdk-core'; import { @@ -21,6 +19,7 @@ import { useXTokenDepositAmount, useXTransactionStore, } from '@balancednetwork/xwagmi'; +import { useQueryClient } from '@tanstack/react-query'; interface SendRemoveXTokenProps { field: Field; @@ -29,6 +28,7 @@ interface SendRemoveXTokenProps { } export function SendRemoveXToken({ field, currencies, parsedAmounts }: SendRemoveXTokenProps) { + const queryClient = useQueryClient(); const [isPending, setIsPending] = React.useState(false); const [pendingTx, setPendingTx] = React.useState(''); @@ -39,22 +39,17 @@ export function SendRemoveXToken({ field, currencies, parsedAmounts }: SendRemov currentXTransaction?.status === XTransactionStatus.success || currentXTransaction?.status === XTransactionStatus.failure ) { - refetchDepositAmount() - .then(() => { - setIsPending(false); - }) - .catch(() => { - setIsPending(false); - }); + queryClient.invalidateQueries({ queryKey: ['XTokenDepositAmount'] }); + setIsPending(false); } - }, [currentXTransaction]); + }, [currentXTransaction, queryClient]); const xToken = currencies[field]; const parsedAmount = parsedAmounts[field]; const xAccount = useXAccount(getXChainType(xToken?.xChainId)); - const { depositAmount, refetchDepositAmount } = useXTokenDepositAmount(xAccount.address, xToken); + const { data: depositAmount } = useXTokenDepositAmount(xAccount.address, xToken); const depositXToken = useDepositXToken(); const withdrawXToken = useWithdrawXToken(); @@ -82,14 +77,14 @@ export function SendRemoveXToken({ field, currencies, parsedAmounts }: SendRemov const handleRemove = async () => { console.log('remove'); - if (!parsedAmount || !xToken || !xAccount) { + if (!depositAmount || !xToken || !xAccount) { return; } setIsPending(true); try { - const txHash = await withdrawXToken(xAccount.address, parsedAmount, xToken); + const txHash = await withdrawXToken(xAccount.address, depositAmount); if (txHash) setPendingTx(txHash); else setIsPending(false); } catch (error) { diff --git a/apps/web/src/app/pages/trade/supply/_components/SupplyLiquidityModal.tsx b/apps/web/src/app/pages/trade/supply/_components/SupplyLiquidityModal.tsx index 4713341bc..5c43f84c8 100644 --- a/apps/web/src/app/pages/trade/supply/_components/SupplyLiquidityModal.tsx +++ b/apps/web/src/app/pages/trade/supply/_components/SupplyLiquidityModal.tsx @@ -48,8 +48,8 @@ export default function SupplyLiquidityModal({ isOpen, onClose, parsedAmounts, c const [confirmTx, setConfirmTx] = React.useState(''); const xAccount = useXAccount(getXChainType(currencies[Field.CURRENCY_A]?.xChainId)); - const { depositAmount: depositAmountA } = useXTokenDepositAmount(xAccount.address, currencies[Field.CURRENCY_A]); - const { depositAmount: depositAmountB } = useXTokenDepositAmount(xAccount.address, currencies[Field.CURRENCY_B]); + const { data: depositAmountA } = useXTokenDepositAmount(xAccount.address, currencies[Field.CURRENCY_A]); + const { data: depositAmountB } = useXTokenDepositAmount(xAccount.address, currencies[Field.CURRENCY_B]); const xAddLiquidity = useXAddLiquidity(); diff --git a/packages/xwagmi/src/hooks/liquidity/useWithdrawXToken.ts b/packages/xwagmi/src/hooks/liquidity/useWithdrawXToken.ts index 90d6cabdb..85aa9bd91 100644 --- a/packages/xwagmi/src/hooks/liquidity/useWithdrawXToken.ts +++ b/packages/xwagmi/src/hooks/liquidity/useWithdrawXToken.ts @@ -9,18 +9,14 @@ export const useWithdrawXToken = () => { const { sendXTransaction } = useSendXTransaction(); const withdrawXToken = useMemo( - () => async (account, currencyAmount: CurrencyAmount, xToken: XToken) => { - const inputAmount = CurrencyAmount.fromRawAmount( - xToken, - new BigNumber(currencyAmount.toFixed()).times((10n ** BigInt(xToken.decimals)).toString()).toFixed(0), - ); + () => async (account, currencyAmount: CurrencyAmount) => { const xTransactionInput: XTransactionInput = { type: XTransactionType.LP_WITHDRAW_XTOKEN, account: account, - inputAmount: inputAmount, + inputAmount: currencyAmount, xCallFee: { rollback: 60000000000000n, noRollback: 0n }, direction: { - from: xToken.xChainId, + from: currencyAmount.currency.xChainId, to: '0x1.icon', }, }; diff --git a/packages/xwagmi/src/hooks/liquidity/useXTokenDepositAmount.ts b/packages/xwagmi/src/hooks/liquidity/useXTokenDepositAmount.ts index 89bbcc68b..a3d4a5b7c 100644 --- a/packages/xwagmi/src/hooks/liquidity/useXTokenDepositAmount.ts +++ b/packages/xwagmi/src/hooks/liquidity/useXTokenDepositAmount.ts @@ -2,36 +2,24 @@ import { xTokenMapBySymbol } from '@/constants'; import { XToken } from '@/types'; import { bnJs } from '@/xchains/icon'; import { CurrencyAmount } from '@balancednetwork/sdk-core'; -import { useCallback, useEffect, useMemo, useState } from 'react'; +import { UseQueryResult, useQuery } from '@tanstack/react-query'; export const useXTokenDepositAmount = ( account: string | undefined | null, xToken: XToken | undefined, -): { - depositAmount: CurrencyAmount | undefined; - refetchDepositAmount: () => Promise; -} => { - const [result, setResult] = useState(); +): UseQueryResult | undefined, Error> => { + const fetchDepositAmount = async () => { + if (xToken && account) { + const xTokenOnIcon = xTokenMapBySymbol['0x1.icon'][xToken.symbol]; + const res = await bnJs.Dex.getDepositV2(xTokenOnIcon.address, `${xToken.xChainId}/${account}`); + return res ? CurrencyAmount.fromRawAmount(xToken, BigInt(res)) : undefined; + } + return undefined; + }; - const fetch = useMemo(() => { - return async (xToken, account) => { - if (xToken && account) { - const xTokenOnIcon = xTokenMapBySymbol['0x1.icon'][xToken.symbol]; - const res = await bnJs.Dex.getDepositV2(xTokenOnIcon.address, `${xToken.xChainId}/${account}`); - setResult(res); - } - }; - }, []); - - useEffect(() => { - fetch(xToken, account); - }, [fetch, xToken, account]); - - const depositAmount = useMemo(() => { - return xToken && result ? CurrencyAmount.fromRawAmount(xToken, BigInt(result)) : undefined; - }, [xToken, result]); - - const refetch = useCallback(() => fetch(xToken, account), [fetch, xToken, account]); - - return { depositAmount, refetchDepositAmount: refetch }; + return useQuery({ + queryKey: ['XTokenDepositAmount', xToken, account], + queryFn: fetchDepositAmount, + enabled: !!xToken && !!account, + }); }; From bbecdf0a774089f2bd368d615fc80bd6a5bc082b Mon Sep 17 00:00:00 2001 From: swiftcc624 Date: Thu, 9 Jan 2025 00:16:46 +0800 Subject: [PATCH 09/33] select the correct xchain id in LP Panel when click a pool record --- .../LiquidityDetails/PoolRecord.tsx | 38 +++++-------------- 1 file changed, 9 insertions(+), 29 deletions(-) diff --git a/apps/web/src/app/pages/trade/supply/_components/LiquidityDetails/PoolRecord.tsx b/apps/web/src/app/pages/trade/supply/_components/LiquidityDetails/PoolRecord.tsx index d0059d973..0508af8f0 100644 --- a/apps/web/src/app/pages/trade/supply/_components/LiquidityDetails/PoolRecord.tsx +++ b/apps/web/src/app/pages/trade/supply/_components/LiquidityDetails/PoolRecord.tsx @@ -1,42 +1,26 @@ -import React, { useState } from 'react'; +import React from 'react'; -import { BalancedJs } from '@balancednetwork/balanced-js'; import { Pair } from '@balancednetwork/v1-sdk'; import { Trans } from '@lingui/macro'; -import { Accordion } from '@reach/accordion'; import BigNumber from 'bignumber.js'; -import { AnimatePresence, motion } from 'framer-motion'; -import { omit } from 'lodash-es'; import { useMedia } from 'react-use'; import { Flex } from 'rebass/styled-components'; import styled from 'styled-components'; -import Message from '@/app/Message'; import { Typography } from '@/app/theme'; import ArrowDownIcon from '@/assets/icons/arrow-line.svg'; -import { MINIMUM_B_BALANCE_TO_SHOW_POOL } from '@/constants/index'; -import { BIGINT_ZERO } from '@/constants/misc'; -import { BalanceData, Pool, useBalance, usePoolTokenAmounts, useSuppliedTokens } from '@/hooks/useV2Pairs'; -import { PairData, useAllPairsById } from '@/queries/backendv2'; -import { Source, useBBalnAmount, useSources, useTotalSupply } from '@/store/bbaln/hooks'; -import { useTokenListConfig } from '@/store/lists/hooks'; +import { Pool, useBalance, usePoolTokenAmounts } from '@/hooks/useV2Pairs'; +import { PairData } from '@/queries/backendv2'; +import { Source, useBBalnAmount, useTotalSupply } from '@/store/bbaln/hooks'; import { useMintActionHandlers } from '@/store/mint/hooks'; import { Field } from '@/store/mint/reducer'; -import { useRewards } from '@/store/reward/hooks'; import { useStakedLPPercent, useWithdrawnPercent } from '@/store/stakedLP/hooks'; -import { QuestionWrapper } from '@/app/components/QuestionHelper'; import Skeleton from '@/app/components/Skeleton'; -import { MouseoverTooltip } from '@/app/components/Tooltip'; -import QuestionIcon from '@/assets/icons/question.svg'; import { formatBigNumber } from '@/utils'; import { getFormattedNumber } from '@/utils/formatter'; -import { XChainId } from '@balancednetwork/sdk-core'; import { getFormattedRewards, stakedFraction, totalSupply } from '../utils'; -import { WithdrawPanel, WithdrawPanelQ, getABBalance, getShareReward } from './WithdrawPanel'; -import { StyledBoxPanel } from './shared'; - -const TableWrapper = styled.div``; +import { getShareReward } from './WithdrawPanel'; const DashGrid = styled.div` display: grid; @@ -140,16 +124,12 @@ export const PoolRecord = ({ const baseSupplyAmount = totalSupply(baseWithdrawValue, baseAmount); const quoteSupplyAmount = totalSupply(quoteWithdrawValue, quoteAmount); - const { onCurrencySelection } = useMintActionHandlers(false); + const { onCurrencySelection, onChainSelection } = useMintActionHandlers(false); const handlePoolClick = () => { - if (pairData) { - onCurrencySelection(Field.CURRENCY_A, pairData.info.baseToken); - onCurrencySelection(Field.CURRENCY_B, pairData.info.quoteToken); - } else { - onCurrencySelection(Field.CURRENCY_A, pair.reserve0.currency); - onCurrencySelection(Field.CURRENCY_B, pair.reserve1.currency); - } + onCurrencySelection(Field.CURRENCY_A, pair.reserve0.currency); + onCurrencySelection(Field.CURRENCY_B, pair.reserve1.currency); + onChainSelection(Field.CURRENCY_A, xChainId); }; return ( From 2cabfb20a6f3b9375c593257acf0284b2c38894d Mon Sep 17 00:00:00 2001 From: swiftcc624 Date: Thu, 9 Jan 2025 11:16:59 +0800 Subject: [PATCH 10/33] lp panel description - supply amount --- .../supply/_components/LPDescription.tsx | 17 ++++++++++------ .../supply/_components/LiquidityDetails.tsx | 7 +------ .../LiquidityDetails/WithdrawPanel.tsx | 2 ++ .../supply/_components/PoolPanelContext.ts | 4 +++- apps/web/src/app/pages/trade/supply/page.tsx | 10 ++++++++-- apps/web/src/hooks/useV2Pairs.ts | 20 ++++++++++++------- apps/web/src/store/wallet/hooks.ts | 2 +- 7 files changed, 39 insertions(+), 23 deletions(-) diff --git a/apps/web/src/app/pages/trade/supply/_components/LPDescription.tsx b/apps/web/src/app/pages/trade/supply/_components/LPDescription.tsx index 3ecaad900..1232419c1 100644 --- a/apps/web/src/app/pages/trade/supply/_components/LPDescription.tsx +++ b/apps/web/src/app/pages/trade/supply/_components/LPDescription.tsx @@ -9,7 +9,7 @@ import { useMedia } from 'react-use'; import { Box, Flex } from 'rebass/styled-components'; import { Typography } from '@/app/theme'; -import { PairState, useBalance, useSuppliedTokens } from '@/hooks/useV2Pairs'; +import { PairState, useBalance, usePool, usePoolTokenAmounts, useSuppliedTokens } from '@/hooks/useV2Pairs'; import { useAllPairsByName } from '@/queries/backendv2'; import { useICXConversionFee, useRatesWithOracle } from '@/queries/reward'; import { useBBalnAmount, useResponsivePoolRewardShare, useSources } from '@/store/bbaln/hooks'; @@ -24,16 +24,20 @@ import { formatBigNumber } from '@/utils'; import QuestionHelper, { QuestionWrapper } from '@/app/components/QuestionHelper'; import { MAX_BOOST } from '@/app/components/home/BBaln/utils'; import { formatBalance } from '@/utils/formatter'; +import { getXChainType, useXAccount } from '@balancednetwork/xwagmi'; export default function LPDescription() { - const { currencies, pair, pairState, dependentField, noLiquidity, parsedAmounts } = useDerivedMintInfo(); + const { currencies, pair, pairState, dependentField, noLiquidity, parsedAmounts, lpXChainId } = useDerivedMintInfo(); + const xAccount = useXAccount(getXChainType(lpXChainId)); + const pool = usePool(pair?.poolId, `${lpXChainId}/${xAccount?.address}`); + const { independentField, typedValue, otherTypedValue } = useMintState(); const sources = useSources(); const getResponsiveRewardShare = useResponsivePoolRewardShare(); const { account } = useIconReact(); const upSmall = useMedia('(min-width: 600px)'); const { data: icxConversionFee } = useICXConversionFee(); - const userPoolBalance = useLiquidityTokenBalance(account, pair); + const userPoolBalance = useLiquidityTokenBalance(`${lpXChainId}/${xAccount?.address}`, pair); const totalPoolTokens = pair?.totalSupply; const token0Deposited = !!pair && @@ -65,6 +69,7 @@ export default function LPDescription() { currencies[Field.CURRENCY_A], pair?.isQueue ? pair?.token1 : currencies[Field.CURRENCY_B], ); + const [baseAmount, quoteAmount] = usePoolTokenAmounts(pool); const userPoolBalances = useBalance(pair?.poolId || -1); @@ -105,10 +110,10 @@ export default function LPDescription() { }, []); const baseCurrencyTotalSupply = useMemo( - () => new BigNumber(totalSupply(baseValue, balances?.base)?.toFixed() || '0'), - [totalSupply, baseValue, balances?.base], + () => new BigNumber(totalSupply(baseValue, baseAmount)?.toFixed() || '0'), + [totalSupply, baseValue, baseAmount], ); - const quoteCurrencyTotalSupply = new BigNumber(totalSupply(quoteValue, balances?.quote)?.toFixed() || '0'); + const quoteCurrencyTotalSupply = new BigNumber(totalSupply(quoteValue, quoteAmount)?.toFixed() || '0'); const responsiveRewardShare = useMemo( () => diff --git a/apps/web/src/app/pages/trade/supply/_components/LiquidityDetails.tsx b/apps/web/src/app/pages/trade/supply/_components/LiquidityDetails.tsx index 3b619d49b..a6989fc1b 100644 --- a/apps/web/src/app/pages/trade/supply/_components/LiquidityDetails.tsx +++ b/apps/web/src/app/pages/trade/supply/_components/LiquidityDetails.tsx @@ -42,7 +42,7 @@ export default function LiquidityDetails() { const { data: allPairs } = useAllPairsById(); const sources = useSources(); - const { pairs, balances } = usePoolPanelContext(); + const { pairs, balances, pools } = usePoolPanelContext(); const rewards = useRewards(); @@ -62,11 +62,6 @@ export default function LiquidityDetails() { const pairsWithoutQ = omit(pairs, [BalancedJs.utils.POOL_IDS.sICXICX]); const balancesWithoutQ = omit(balances, [BalancedJs.utils.POOL_IDS.sICXICX]); - const pools = usePools(pairs, [ - `0x1.icon/hxe25ae17a21883803185291baddac0120493ff706`, - `0xa4b1.arbitrum/0x6C5F91FD68Dd7b3A1aedB0F09946659272f523a4`, - ]); - const userPools = pools?.filter(x => x.balance.greaterThan(0) || x.stakedLPBalance?.greaterThan(0)) || []; // const userPools = Object.keys(pairsWithoutQ).filter( diff --git a/apps/web/src/app/pages/trade/supply/_components/LiquidityDetails/WithdrawPanel.tsx b/apps/web/src/app/pages/trade/supply/_components/LiquidityDetails/WithdrawPanel.tsx index e8903515c..f46963833 100644 --- a/apps/web/src/app/pages/trade/supply/_components/LiquidityDetails/WithdrawPanel.tsx +++ b/apps/web/src/app/pages/trade/supply/_components/LiquidityDetails/WithdrawPanel.tsx @@ -236,6 +236,8 @@ export const WithdrawPanel = ({ pool }: { pool: Pool }) => { const numPortion = new BigNumber(portion / 100); const withdrawAmount = multiplyCABN(pool.balance, numPortion); await xRemoveLiquidity(xAccount.address, poolId, pool.xChainId, withdrawAmount); + toggleOpen(); + resetValue(); window.removeEventListener('beforeunload', showMessageOnBeforeUnload); diff --git a/apps/web/src/app/pages/trade/supply/_components/PoolPanelContext.ts b/apps/web/src/app/pages/trade/supply/_components/PoolPanelContext.ts index 6cd876c4a..fd4243565 100644 --- a/apps/web/src/app/pages/trade/supply/_components/PoolPanelContext.ts +++ b/apps/web/src/app/pages/trade/supply/_components/PoolPanelContext.ts @@ -3,16 +3,18 @@ import React from 'react'; import { Token } from '@balancednetwork/sdk-core'; import { Pair } from '@balancednetwork/v1-sdk'; -import { BalanceData } from '@/hooks/useV2Pairs'; +import { BalanceData, Pool } from '@/hooks/useV2Pairs'; export const PoolPanelContext = React.createContext<{ trackedTokenPairs: [Token, Token][]; pairs: { [poolId: number]: Pair }; balances: { [poolId: number]: BalanceData }; + pools: Pool[]; }>({ trackedTokenPairs: [], pairs: {}, balances: {}, + pools: [], }); export const usePoolPanelContext = () => React.useContext(PoolPanelContext); diff --git a/apps/web/src/app/pages/trade/supply/page.tsx b/apps/web/src/app/pages/trade/supply/page.tsx index 0ed4f56c7..2e67e1ab7 100644 --- a/apps/web/src/app/pages/trade/supply/page.tsx +++ b/apps/web/src/app/pages/trade/supply/page.tsx @@ -6,7 +6,7 @@ import LPPanel from './_components/LPPanel'; import LiquidityPoolsPanel from './_components/LiquidityPoolsPanel'; import { PoolPanelContext } from './_components/PoolPanelContext'; -import { useAvailablePairs, useBalances } from '@/hooks/useV2Pairs'; +import { useAvailablePairs, useBalances, usePools } from '@/hooks/useV2Pairs'; import { useTrackedTokenPairs } from '@/store/user/hooks'; export function SupplyPage() { @@ -20,13 +20,19 @@ export function SupplyPage() { // fetch the user's balances of all tracked V2 LP tokens const balances = useBalances(account, pairs); + const pools = usePools(pairs, [ + `0x1.icon/hxe25ae17a21883803185291baddac0120493ff706`, + `0xa4b1.arbitrum/0x6C5F91FD68Dd7b3A1aedB0F09946659272f523a4`, + ]); + const data = useMemo( () => ({ trackedTokenPairs, pairs, balances, + pools: pools || [], }), - [trackedTokenPairs, pairs, balances], + [trackedTokenPairs, pairs, balances, pools], ); return ( diff --git a/apps/web/src/hooks/useV2Pairs.ts b/apps/web/src/hooks/useV2Pairs.ts index 26816c374..aa49720c0 100644 --- a/apps/web/src/hooks/useV2Pairs.ts +++ b/apps/web/src/hooks/useV2Pairs.ts @@ -367,8 +367,6 @@ export function usePools(pairs: { [poolId: number]: Pair }, accounts: string[]): }, ]); }); - // const data: any[] = await bnJs.Multicall.getAggregateData(cds.slice(0, 100)); - // console.log('data', data); const chunks = chunkArray(cds, MULTI_CALL_BATCH_SIZE); const chunkedData = await Promise.all(chunks.map(async chunk => await bnJs.Multicall.getAggregateData(chunk))); @@ -413,20 +411,28 @@ export function usePools(pairs: { [poolId: number]: Pair }, accounts: string[]): return balances; } -export const usePoolTokenAmounts = (pool: Pool) => { - const { balance, stakedLPBalance, pair } = pool; +export const usePoolTokenAmounts = (pool?: Pool) => { + const { balance, stakedLPBalance, pair } = pool || {}; const rate = useMemo(() => { - if (pair.totalSupply && pair.totalSupply.quotient > BIGINT_ZERO) { - const amount = (stakedLPBalance ? balance.add(stakedLPBalance) : balance).divide(pair.totalSupply); + if (pair?.totalSupply && pair.totalSupply.quotient > BIGINT_ZERO) { + const amount = (stakedLPBalance ? balance!.add(stakedLPBalance) : balance!).divide(pair.totalSupply); return new Fraction(amount.numerator, amount.denominator); } return FRACTION_ZERO; }, [balance, pair, stakedLPBalance]); const [base, quote] = useMemo(() => { - return [pair.reserve0.multiply(rate), pair.reserve1.multiply(rate)]; + if (pair) { + return [pair.reserve0.multiply(rate), pair.reserve1.multiply(rate)]; + } + return [CurrencyAmount.fromRawAmount(bnUSD[NETWORK_ID], '0'), CurrencyAmount.fromRawAmount(bnUSD[NETWORK_ID], '0')]; }, [pair, rate]); return [base, quote]; }; + +export const usePool = (poolId: number | undefined, account: string): Pool | undefined => { + const { pools } = usePoolPanelContext(); + return pools.find(pool => pool.poolId === poolId && pool.account === account); +}; diff --git a/apps/web/src/store/wallet/hooks.ts b/apps/web/src/store/wallet/hooks.ts index 4512d4bb1..a2eea1c0e 100644 --- a/apps/web/src/store/wallet/hooks.ts +++ b/apps/web/src/store/wallet/hooks.ts @@ -311,7 +311,7 @@ export function useCurrencyBalances(currencies: (Currency | undefined)[]): (Curr } export function useLiquidityTokenBalance(account: string | undefined | null, pair: Pair | undefined | null) { - const query = useBnJsContractQuery('Dex', 'balanceOf', [account, pair?.poolId]); + const query = useBnJsContractQuery('Dex', 'xBalanceOf', [account, pair?.poolId]); const { data } = query; return pair && data ? CurrencyAmount.fromRawAmount(pair.liquidityToken, data) : undefined; } From c91ea3e74d0549bbe3ef467b962a8966838dc6fd Mon Sep 17 00:00:00 2001 From: swiftcc624 Date: Thu, 9 Jan 2025 16:41:56 +0800 Subject: [PATCH 11/33] rewrite XWalletClient classes to support crosschain lp --- packages/xwagmi/package.json | 1 + packages/xwagmi/src/core/XLiquidityService.ts | 14 - packages/xwagmi/src/core/XWalletClient.ts | 52 +- packages/xwagmi/src/useXWagmiStore.tsx | 14 +- .../xchains/archway/ArchwayXWalletClient.ts | 40 +- .../src/xchains/evm/EvmXLiquidityService.ts | 272 --- .../src/xchains/evm/EvmXWalletClient.ts | 286 ++- .../src/xchains/havah/HavahXWalletClient.ts | 40 +- .../src/xchains/icon/IconXWalletClient.ts | 84 +- .../injective/InjectiveXWalletClient.ts | 32 +- .../src/xchains/solana/SolanaXWalletClient.ts | 40 +- .../xchains/stellar/StellarXWalletClient.ts | 42 + .../xwagmi/src/xchains/sui/SuiXService.ts | 2 + .../src/xchains/sui/SuiXWalletClient.ts | 104 +- pnpm-lock.yaml | 2020 ++++++++++++++--- 15 files changed, 2327 insertions(+), 716 deletions(-) delete mode 100644 packages/xwagmi/src/core/XLiquidityService.ts delete mode 100644 packages/xwagmi/src/xchains/evm/EvmXLiquidityService.ts diff --git a/packages/xwagmi/package.json b/packages/xwagmi/package.json index eed94ca1a..838cc2249 100644 --- a/packages/xwagmi/package.json +++ b/packages/xwagmi/package.json @@ -37,6 +37,7 @@ "@keplr-wallet/types": "0.12.18", "@mysten/dapp-kit": "0.14.18", "@mysten/sui": "1.8.0", + "@mysten/wallet-standard": "^0.13.20", "@solana/spl-token": "0.4.9", "@solana/wallet-adapter-base": "0.9.23", "@solana/wallet-adapter-react": "0.15.35", diff --git a/packages/xwagmi/src/core/XLiquidityService.ts b/packages/xwagmi/src/core/XLiquidityService.ts deleted file mode 100644 index 5b859e66f..000000000 --- a/packages/xwagmi/src/core/XLiquidityService.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { XTransactionInput } from '@/xcall/types'; -import { XWalletClient } from './XWalletClient'; - -export class XLiquidityService { - constructor(private client: XWalletClient) {} - - depositXToken(xTransactionInput: XTransactionInput) {} - async withdrawXToken(xTransactionInput: XTransactionInput) {} - async addLiquidity(xTransactionInput: XTransactionInput) {} - async removeLiquidity(xTransactionInput: XTransactionInput) {} - async stake(xTransactionInput: XTransactionInput) {} - async unstake(xTransactionInput: XTransactionInput) {} - async claimRewards(xTransactionInput: XTransactionInput) {} -} diff --git a/packages/xwagmi/src/core/XWalletClient.ts b/packages/xwagmi/src/core/XWalletClient.ts index 4fff0e55f..0c58b2fd8 100644 --- a/packages/xwagmi/src/core/XWalletClient.ts +++ b/packages/xwagmi/src/core/XWalletClient.ts @@ -1,4 +1,4 @@ -import { XTransactionInput } from '@/xcall/types'; +import { XTransactionInput, XTransactionType } from '@/xcall/types'; import { CurrencyAmount } from '@balancednetwork/sdk-core'; import { XChainId, XToken } from '../types'; export abstract class XWalletClient { @@ -14,5 +14,53 @@ export abstract class XWalletClient { owner: string, ): Promise; - abstract executeTransaction(xTransactionInput: XTransactionInput, options?: any): Promise; + async executeTransaction(xTransactionInput: XTransactionInput, options?: any): Promise { + const { type } = xTransactionInput; + switch (type) { + case XTransactionType.SWAP: + case XTransactionType.BRIDGE: + case XTransactionType.SWAP_ON_ICON: // only for icon + return await this.executeSwapOrBridge(xTransactionInput); + case XTransactionType.DEPOSIT: + return await this.executeDepositCollateral(xTransactionInput); + case XTransactionType.WITHDRAW: + return await this.executeWithdrawCollateral(xTransactionInput); + case XTransactionType.BORROW: + return await this.executeBorrow(xTransactionInput); + case XTransactionType.REPAY: + return await this.executeRepay(xTransactionInput); + + case XTransactionType.LP_DEPOSIT_XTOKEN: + return await this.depositXToken(xTransactionInput); + case XTransactionType.LP_WITHDRAW_XTOKEN: + return await this.withdrawXToken(xTransactionInput); + case XTransactionType.LP_ADD_LIQUIDITY: + return await this.addLiquidity(xTransactionInput); + case XTransactionType.LP_REMOVE_LIQUIDITY: + return await this.removeLiquidity(xTransactionInput); + case XTransactionType.LP_STAKE: + return await this.stake(xTransactionInput); + case XTransactionType.LP_UNSTAKE: + return await this.unstake(xTransactionInput); + case XTransactionType.LP_CLAIM_REWARDS: + return await this.claimRewards(xTransactionInput); + + default: + throw new Error('Invalid XTransactionType'); + } + } + + abstract executeSwapOrBridge(xTransactionInput: XTransactionInput): Promise; + abstract executeDepositCollateral(xTransactionInput: XTransactionInput): Promise; + abstract executeWithdrawCollateral(xTransactionInput: XTransactionInput): Promise; + abstract executeBorrow(xTransactionInput: XTransactionInput): Promise; + abstract executeRepay(xTransactionInput: XTransactionInput): Promise; + + abstract depositXToken(xTransactionInput: XTransactionInput): Promise; + abstract withdrawXToken(xTransactionInput: XTransactionInput): Promise; + abstract addLiquidity(xTransactionInput: XTransactionInput): Promise; + abstract removeLiquidity(xTransactionInput: XTransactionInput): Promise; + abstract stake(xTransactionInput: XTransactionInput): Promise; + abstract unstake(xTransactionInput: XTransactionInput): Promise; + abstract claimRewards(xTransactionInput: XTransactionInput): Promise; } diff --git a/packages/xwagmi/src/useXWagmiStore.tsx b/packages/xwagmi/src/useXWagmiStore.tsx index 79f9c3a04..e19079908 100644 --- a/packages/xwagmi/src/useXWagmiStore.tsx +++ b/packages/xwagmi/src/useXWagmiStore.tsx @@ -1,7 +1,7 @@ import { xChains } from '@/constants/xChains'; import { XChainId, XChainType } from '@/types'; import { BalancedJs } from '@balancednetwork/balanced-js'; -import { useSuiClient } from '@mysten/dapp-kit'; +import { useCurrentAccount, useCurrentWallet, useSuiClient } from '@mysten/dapp-kit'; import { useConnection, useWallet } from '@solana/wallet-adapter-react'; import { useEffect } from 'react'; import { create } from 'zustand'; @@ -222,6 +222,18 @@ export const useInitXWagmiStore = () => { suiXService.suiClient = suiClient; } }, [suiClient]); + const { currentWallet: suiWallet } = useCurrentWallet(); + useEffect(() => { + if (suiWallet) { + suiXService.suiWallet = suiWallet; + } + }, [suiWallet]); + const suiAccount = useCurrentAccount(); + useEffect(() => { + if (suiAccount) { + suiXService.suiAccount = suiAccount; + } + }, [suiAccount]); const { connection: solanaConnection } = useConnection(); const solanaWallet = useWallet(); diff --git a/packages/xwagmi/src/xchains/archway/ArchwayXWalletClient.ts b/packages/xwagmi/src/xchains/archway/ArchwayXWalletClient.ts index b6ea26716..6b5fc49e5 100644 --- a/packages/xwagmi/src/xchains/archway/ArchwayXWalletClient.ts +++ b/packages/xwagmi/src/xchains/archway/ArchwayXWalletClient.ts @@ -43,7 +43,7 @@ export class ArchwayXWalletClient extends XWalletClient { } } - async executeTransaction(xTransactionInput: XTransactionInput) { + async executeSwapOrBridge(xTransactionInput: XTransactionInput) { const { type, direction, inputAmount, executionTrade, account, recipient, xCallFee, slippageTolerance } = xTransactionInput; @@ -69,8 +69,6 @@ export class ArchwayXWalletClient extends XWalletClient { }, }), ); - } else if (type === XTransactionType.REPAY) { - return await this._executeRepay(xTransactionInput); } else { throw new Error('Invalid XTransactionType'); } @@ -142,7 +140,19 @@ export class ArchwayXWalletClient extends XWalletClient { } } - async _executeRepay(xTransactionInput: XTransactionInput) { + async executeDepositCollateral(xTransactionInput: XTransactionInput): Promise { + throw new Error('Method not implemented.'); + } + + async executeWithdrawCollateral(xTransactionInput: XTransactionInput): Promise { + throw new Error('Method not implemented.'); + } + + async executeBorrow(xTransactionInput: XTransactionInput): Promise { + throw new Error('Method not implemented.'); + } + + async executeRepay(xTransactionInput: XTransactionInput) { const { account, inputAmount, recipient, xCallFee, usedCollateral } = xTransactionInput; if (!inputAmount || !usedCollateral) { @@ -173,4 +183,26 @@ export class ArchwayXWalletClient extends XWalletClient { ); return hash; } + + async depositXToken(xTransactionInput: XTransactionInput): Promise { + throw new Error('Method not implemented.'); + } + async withdrawXToken(xTransactionInput: XTransactionInput): Promise { + throw new Error('Method not implemented.'); + } + async addLiquidity(xTransactionInput: XTransactionInput): Promise { + throw new Error('Method not implemented.'); + } + async removeLiquidity(xTransactionInput: XTransactionInput): Promise { + throw new Error('Method not implemented.'); + } + async stake(xTransactionInput: XTransactionInput): Promise { + throw new Error('Method not implemented.'); + } + async unstake(xTransactionInput: XTransactionInput): Promise { + throw new Error('Method not implemented.'); + } + async claimRewards(xTransactionInput: XTransactionInput): Promise { + throw new Error('Method not implemented.'); + } } diff --git a/packages/xwagmi/src/xchains/evm/EvmXLiquidityService.ts b/packages/xwagmi/src/xchains/evm/EvmXLiquidityService.ts deleted file mode 100644 index fbd02116c..000000000 --- a/packages/xwagmi/src/xchains/evm/EvmXLiquidityService.ts +++ /dev/null @@ -1,272 +0,0 @@ -import { - FROM_SOURCES, - ICON_XCALL_NETWORK_ID, - TO_SOURCES, - bnJs, - bnUSDContractAbi, - isSpokeToken, - uintToBytes, - xCallContractAbi, - xChainMap, - xTokenMapBySymbol, -} from '@/index'; -import { XTransactionInput } from '@/xcall/types'; -import { RLP } from '@ethereumjs/rlp'; -import { Address, toHex } from 'viem'; -import { EvmXWalletClient } from './EvmXWalletClient'; -import { getStakeData, getUnStakeData, getXRemoveData } from './utils'; - -export class EvmXLiquidityService { - constructor(private client: EvmXWalletClient) {} - - async depositXToken(xTransactionInput: XTransactionInput) { - const { account, inputAmount, xCallFee } = xTransactionInput; - - const publicClient = this.client.getPublicClient(); - const walletClient = await this.client.getWalletClient(); - - const destination = `${ICON_XCALL_NETWORK_ID}/${bnJs.Dex.address}`; - const amount = BigInt(inputAmount.quotient.toString()); - const data = toHex( - JSON.stringify({ - method: '_deposit', - params: {}, - }), - ); - - const _isSpokeToken = isSpokeToken(inputAmount.currency); - const isNative = inputAmount.currency.isNativeToken; - - let hash; - if (_isSpokeToken) { - const res = await publicClient.simulateContract({ - account: account as Address, - address: xTokenMapBySymbol[this.client.xChainId][inputAmount.currency.symbol].address as Address, - abi: bnUSDContractAbi, - functionName: 'crossTransfer', - args: [destination, amount, data], - value: xCallFee.rollback, - }); - hash = await walletClient.writeContract(res.request); - } else { - if (!isNative) { - throw new Error('not implemented'); - } else { - throw new Error('not implemented'); - } - } - - return hash; - } - - async withdrawXToken(xTransactionInput: XTransactionInput) { - const { account, inputAmount, xCallFee } = xTransactionInput; - - const publicClient = this.client.getPublicClient(); - const walletClient = await this.client.getWalletClient(); - - const destination = `${ICON_XCALL_NETWORK_ID}/${bnJs.Dex.address}`; - const amount = BigInt(inputAmount.quotient.toString()); - const xTokenOnIcon = xTokenMapBySymbol[ICON_XCALL_NETWORK_ID][inputAmount.currency.symbol]; - const data = toHex( - RLP.encode([ - 'xWithdraw', - xTokenOnIcon.address, // - uintToBytes(amount), - ]), - ); - - const envelope = toHex( - RLP.encode([ - Buffer.from([0]), - data, - FROM_SOURCES[this.client.xChainId]?.map(Buffer.from), - TO_SOURCES[this.client.xChainId]?.map(Buffer.from), - ]), - ); - - const _isSpokeToken = isSpokeToken(inputAmount.currency); - const isNative = inputAmount.currency.isNativeToken; - - let hash; - if (_isSpokeToken) { - const res = await publicClient.simulateContract({ - account: account as Address, - address: xChainMap[this.client.xChainId].contracts.xCall as Address, - abi: xCallContractAbi, - functionName: 'sendCall', - args: [destination, envelope], - value: xCallFee.rollback, - }); - hash = await walletClient.writeContract(res.request); - } else { - if (!isNative) { - throw new Error('not implemented'); - } else { - throw new Error('not implemented'); - } - } - - return hash; - } - - async addLiquidity(xTransactionInput: XTransactionInput) { - const { account, inputAmount, outputAmount, xCallFee } = xTransactionInput; - - if (!outputAmount) { - throw new Error('outputAmount is required'); - } - - const publicClient = this.client.getPublicClient(); - const walletClient = await this.client.getWalletClient(); - - const destination = `${ICON_XCALL_NETWORK_ID}/${bnJs.Dex.address}`; - const amountA = BigInt(inputAmount.quotient.toString()); - const amountB = BigInt(outputAmount.quotient.toString()); - const xTokenAOnIcon = xTokenMapBySymbol[ICON_XCALL_NETWORK_ID][inputAmount.currency.symbol]; - const xTokenBOnIcon = xTokenMapBySymbol[ICON_XCALL_NETWORK_ID][outputAmount.currency.symbol]; - const data = toHex( - RLP.encode([ - 'xAdd', - xTokenAOnIcon.address, - xTokenBOnIcon.address, - uintToBytes(amountA), - uintToBytes(amountB), - uintToBytes(1n), - uintToBytes(1_000n), - ]), - ); - - const envelope = toHex( - RLP.encode([ - Buffer.from([0]), - data, - FROM_SOURCES[this.client.xChainId]?.map(Buffer.from), - TO_SOURCES[this.client.xChainId]?.map(Buffer.from), - ]), - ); - - const res = await publicClient.simulateContract({ - account: account as Address, - address: xChainMap[this.client.xChainId].contracts.xCall as Address, - abi: xCallContractAbi, - functionName: 'sendCall', - args: [destination, envelope], - value: xCallFee.rollback, - }); - - const hash = await walletClient.writeContract(res.request); - return hash; - } - - async removeLiquidity(xTransactionInput: XTransactionInput) { - const { account, inputAmount, poolId, xCallFee } = xTransactionInput; - - if (!poolId) { - throw new Error('poolId is required'); - } - - const publicClient = this.client.getPublicClient(); - const walletClient = await this.client.getWalletClient(); - - const destination = `${ICON_XCALL_NETWORK_ID}/${bnJs.Dex.address}`; - const amount = BigInt(inputAmount.quotient.toString()); - const data = toHex(getXRemoveData(poolId, amount, true)); - - const envelope = toHex( - RLP.encode([ - Buffer.from([0]), - data, - FROM_SOURCES[this.client.xChainId]?.map(Buffer.from), - TO_SOURCES[this.client.xChainId]?.map(Buffer.from), - ]), - ); - - const res = await publicClient.simulateContract({ - account: account as Address, - address: xChainMap[this.client.xChainId].contracts.xCall as Address, - abi: xCallContractAbi, - functionName: 'sendCall', - args: [destination, envelope], - value: xCallFee.rollback, - }); - - const hash = await walletClient.writeContract(res.request); - return hash; - } - - async stake(xTransactionInput: XTransactionInput) { - const { account, inputAmount, poolId, xCallFee } = xTransactionInput; - - if (!poolId) { - throw new Error('poolId is required'); - } - - const publicClient = this.client.getPublicClient(); - const walletClient = await this.client.getWalletClient(); - - const destination = `${ICON_XCALL_NETWORK_ID}/${bnJs.Dex.address}`; - const amount = BigInt(inputAmount.quotient.toString()); - - const data = toHex(getStakeData(`${ICON_XCALL_NETWORK_ID}/${bnJs.StakedLP.address}`, poolId, amount)); - - const envelope = toHex( - RLP.encode([ - Buffer.from([0]), - data, - FROM_SOURCES[this.client.xChainId]?.map(Buffer.from), - TO_SOURCES[this.client.xChainId]?.map(Buffer.from), - ]), - ); - - const res = await publicClient.simulateContract({ - account: account as Address, - address: xChainMap[this.client.xChainId].contracts.xCall as Address, - abi: xCallContractAbi, - functionName: 'sendCall', - args: [destination, envelope], - value: xCallFee.rollback, - }); - - const hash = await walletClient.writeContract(res.request); - return hash; - } - - async unstake(xTransactionInput: XTransactionInput) { - const { account, inputAmount, poolId, xCallFee } = xTransactionInput; - - if (!poolId) { - throw new Error('poolId is required'); - } - - const publicClient = this.client.getPublicClient(); - const walletClient = await this.client.getWalletClient(); - - const destination = `${ICON_XCALL_NETWORK_ID}/${bnJs.StakedLP.address}`; - const amount = BigInt(inputAmount.quotient.toString()); - const data = toHex(getUnStakeData(poolId, amount)); - - const envelope = toHex( - RLP.encode([ - Buffer.from([0]), - data, - FROM_SOURCES[this.client.xChainId]?.map(Buffer.from), - TO_SOURCES[this.client.xChainId]?.map(Buffer.from), - ]), - ); - - const res = await publicClient.simulateContract({ - account: account as Address, - address: xChainMap[this.client.xChainId].contracts.xCall as Address, - abi: xCallContractAbi, - functionName: 'sendCall', - args: [destination, envelope], - value: xCallFee.rollback, - }); - - const hash = await walletClient.writeContract(res.request); - return hash; - } - - async claimRewards(xTransactionInput: XTransactionInput) {} -} diff --git a/packages/xwagmi/src/xchains/evm/EvmXWalletClient.ts b/packages/xwagmi/src/xchains/evm/EvmXWalletClient.ts index dd29cb2c4..f175d5d3b 100644 --- a/packages/xwagmi/src/xchains/evm/EvmXWalletClient.ts +++ b/packages/xwagmi/src/xchains/evm/EvmXWalletClient.ts @@ -3,7 +3,7 @@ import { RLP } from '@ethereumjs/rlp'; import { Address, PublicClient, WalletClient, WriteContractParameters, erc20Abi, getContract, toHex } from 'viem'; import bnJs from '../icon/bnJs'; -import { ICON_XCALL_NETWORK_ID, xTokenMap } from '@/constants'; +import { ICON_XCALL_NETWORK_ID, xTokenMap, xTokenMapBySymbol } from '@/constants'; import { FROM_SOURCES, TO_SOURCES, xChainMap } from '@/constants/xChains'; import { XWalletClient } from '@/core/XWalletClient'; import { XToken } from '@/types'; @@ -11,15 +11,13 @@ import { uintToBytes } from '@/utils'; import { XTransactionInput, XTransactionType } from '../../xcall/types'; import { getRlpEncodedSwapData, toICONDecimals } from '../../xcall/utils'; import { isSpokeToken } from '../archway/utils'; -import { EvmXLiquidityService } from './EvmXLiquidityService'; import { EvmXService } from './EvmXService'; import { assetManagerContractAbi } from './abis/assetManagerContractAbi'; import { bnUSDContractAbi } from './abis/bnUSDContractAbi'; import { xCallContractAbi } from './abis/xCallContractAbi'; +import { getStakeData, getUnStakeData, getXRemoveData } from './utils'; export class EvmXWalletClient extends XWalletClient { - private liquidityService = new EvmXLiquidityService(this); - getXService(): EvmXService { return EvmXService.getInstance(); } @@ -66,7 +64,7 @@ export class EvmXWalletClient extends XWalletClient { return hash; } - async executeTransaction(xTransactionInput: XTransactionInput) { + async executeSwapOrBridge(xTransactionInput: XTransactionInput) { const { type, direction, inputAmount, recipient, account, xCallFee, executionTrade, slippageTolerance } = xTransactionInput; @@ -99,30 +97,6 @@ export class EvmXWalletClient extends XWalletClient { }), ); break; - case XTransactionType.DEPOSIT: - return await this.executeDepositCollateral(xTransactionInput); - case XTransactionType.WITHDRAW: - return await this.executeWithdrawCollateral(xTransactionInput); - case XTransactionType.BORROW: - return await this.executeBorrow(xTransactionInput); - case XTransactionType.REPAY: - return await this.executeRepay(xTransactionInput); - - case XTransactionType.LP_DEPOSIT_XTOKEN: - return await this.liquidityService.depositXToken(xTransactionInput); - case XTransactionType.LP_WITHDRAW_XTOKEN: - return await this.liquidityService.withdrawXToken(xTransactionInput); - case XTransactionType.LP_ADD_LIQUIDITY: - return await this.liquidityService.addLiquidity(xTransactionInput); - case XTransactionType.LP_REMOVE_LIQUIDITY: - return await this.liquidityService.removeLiquidity(xTransactionInput); - case XTransactionType.LP_STAKE: - return await this.liquidityService.stake(xTransactionInput); - case XTransactionType.LP_UNSTAKE: - return await this.liquidityService.unstake(xTransactionInput); - case XTransactionType.LP_CLAIM_REWARDS: - return await this.liquidityService.claimRewards(xTransactionInput); - default: throw new Error('Invalid XTransactionType'); } @@ -342,4 +316,258 @@ export class EvmXWalletClient extends XWalletClient { } return undefined; } + + // liquidity related + async depositXToken(xTransactionInput: XTransactionInput) { + const { account, inputAmount, xCallFee } = xTransactionInput; + + const publicClient = this.getPublicClient(); + const walletClient = await this.getWalletClient(); + + const destination = `${ICON_XCALL_NETWORK_ID}/${bnJs.Dex.address}`; + const amount = BigInt(inputAmount.quotient.toString()); + const data = toHex( + JSON.stringify({ + method: '_deposit', + params: {}, + }), + ); + + const _isSpokeToken = isSpokeToken(inputAmount.currency); + const isNative = inputAmount.currency.isNativeToken; + + let hash; + if (_isSpokeToken) { + const res = await publicClient.simulateContract({ + account: account as Address, + address: xTokenMapBySymbol[this.xChainId][inputAmount.currency.symbol].address as Address, + abi: bnUSDContractAbi, + functionName: 'crossTransfer', + args: [destination, amount, data], + value: xCallFee.rollback, + }); + hash = await walletClient.writeContract(res.request); + } else { + if (!isNative) { + throw new Error('not implemented'); + } else { + throw new Error('not implemented'); + } + } + + return hash; + } + + async withdrawXToken(xTransactionInput: XTransactionInput) { + const { account, inputAmount, xCallFee } = xTransactionInput; + + const publicClient = this.getPublicClient(); + const walletClient = await this.getWalletClient(); + + const destination = `${ICON_XCALL_NETWORK_ID}/${bnJs.Dex.address}`; + const amount = BigInt(inputAmount.quotient.toString()); + const xTokenOnIcon = xTokenMapBySymbol[ICON_XCALL_NETWORK_ID][inputAmount.currency.symbol]; + const data = toHex( + RLP.encode([ + 'xWithdraw', + xTokenOnIcon.address, // + uintToBytes(amount), + ]), + ); + + const envelope = toHex( + RLP.encode([ + Buffer.from([0]), + data, + FROM_SOURCES[this.xChainId]?.map(Buffer.from), + TO_SOURCES[this.xChainId]?.map(Buffer.from), + ]), + ); + + const _isSpokeToken = isSpokeToken(inputAmount.currency); + const isNative = inputAmount.currency.isNativeToken; + + let hash; + if (_isSpokeToken) { + const res = await publicClient.simulateContract({ + account: account as Address, + address: xChainMap[this.xChainId].contracts.xCall as Address, + abi: xCallContractAbi, + functionName: 'sendCall', + args: [destination, envelope], + value: xCallFee.rollback, + }); + hash = await walletClient.writeContract(res.request); + } else { + if (!isNative) { + throw new Error('not implemented'); + } else { + throw new Error('not implemented'); + } + } + + return hash; + } + + async addLiquidity(xTransactionInput: XTransactionInput) { + const { account, inputAmount, outputAmount, xCallFee } = xTransactionInput; + + if (!outputAmount) { + throw new Error('outputAmount is required'); + } + + const publicClient = this.getPublicClient(); + const walletClient = await this.getWalletClient(); + + const destination = `${ICON_XCALL_NETWORK_ID}/${bnJs.Dex.address}`; + const amountA = BigInt(inputAmount.quotient.toString()); + const amountB = BigInt(outputAmount.quotient.toString()); + const xTokenAOnIcon = xTokenMapBySymbol[ICON_XCALL_NETWORK_ID][inputAmount.currency.symbol]; + const xTokenBOnIcon = xTokenMapBySymbol[ICON_XCALL_NETWORK_ID][outputAmount.currency.symbol]; + const data = toHex( + RLP.encode([ + 'xAdd', + xTokenAOnIcon.address, + xTokenBOnIcon.address, + uintToBytes(amountA), + uintToBytes(amountB), + uintToBytes(1n), + uintToBytes(1_000n), + ]), + ); + + const envelope = toHex( + RLP.encode([ + Buffer.from([0]), + data, + FROM_SOURCES[this.xChainId]?.map(Buffer.from), + TO_SOURCES[this.xChainId]?.map(Buffer.from), + ]), + ); + + const res = await publicClient.simulateContract({ + account: account as Address, + address: xChainMap[this.xChainId].contracts.xCall as Address, + abi: xCallContractAbi, + functionName: 'sendCall', + args: [destination, envelope], + value: xCallFee.rollback, + }); + + const hash = await walletClient.writeContract(res.request); + return hash; + } + + async removeLiquidity(xTransactionInput: XTransactionInput) { + const { account, inputAmount, poolId, xCallFee } = xTransactionInput; + + if (!poolId) { + throw new Error('poolId is required'); + } + + const publicClient = this.getPublicClient(); + const walletClient = await this.getWalletClient(); + + const destination = `${ICON_XCALL_NETWORK_ID}/${bnJs.Dex.address}`; + const amount = BigInt(inputAmount.quotient.toString()); + const data = toHex(getXRemoveData(poolId, amount, true)); + + const envelope = toHex( + RLP.encode([ + Buffer.from([0]), + data, + FROM_SOURCES[this.xChainId]?.map(Buffer.from), + TO_SOURCES[this.xChainId]?.map(Buffer.from), + ]), + ); + + const res = await publicClient.simulateContract({ + account: account as Address, + address: xChainMap[this.xChainId].contracts.xCall as Address, + abi: xCallContractAbi, + functionName: 'sendCall', + args: [destination, envelope], + value: xCallFee.rollback, + }); + + const hash = await walletClient.writeContract(res.request); + return hash; + } + + async stake(xTransactionInput: XTransactionInput) { + const { account, inputAmount, poolId, xCallFee } = xTransactionInput; + + if (!poolId) { + throw new Error('poolId is required'); + } + + const publicClient = this.getPublicClient(); + const walletClient = await this.getWalletClient(); + + const destination = `${ICON_XCALL_NETWORK_ID}/${bnJs.Dex.address}`; + const amount = BigInt(inputAmount.quotient.toString()); + + const data = toHex(getStakeData(`${ICON_XCALL_NETWORK_ID}/${bnJs.StakedLP.address}`, poolId, amount)); + + const envelope = toHex( + RLP.encode([ + Buffer.from([0]), + data, + FROM_SOURCES[this.xChainId]?.map(Buffer.from), + TO_SOURCES[this.xChainId]?.map(Buffer.from), + ]), + ); + + const res = await publicClient.simulateContract({ + account: account as Address, + address: xChainMap[this.xChainId].contracts.xCall as Address, + abi: xCallContractAbi, + functionName: 'sendCall', + args: [destination, envelope], + value: xCallFee.rollback, + }); + + const hash = await walletClient.writeContract(res.request); + return hash; + } + + async unstake(xTransactionInput: XTransactionInput) { + const { account, inputAmount, poolId, xCallFee } = xTransactionInput; + + if (!poolId) { + throw new Error('poolId is required'); + } + + const publicClient = this.getPublicClient(); + const walletClient = await this.getWalletClient(); + + const destination = `${ICON_XCALL_NETWORK_ID}/${bnJs.StakedLP.address}`; + const amount = BigInt(inputAmount.quotient.toString()); + const data = toHex(getUnStakeData(poolId, amount)); + + const envelope = toHex( + RLP.encode([ + Buffer.from([0]), + data, + FROM_SOURCES[this.xChainId]?.map(Buffer.from), + TO_SOURCES[this.xChainId]?.map(Buffer.from), + ]), + ); + + const res = await publicClient.simulateContract({ + account: account as Address, + address: xChainMap[this.xChainId].contracts.xCall as Address, + abi: xCallContractAbi, + functionName: 'sendCall', + args: [destination, envelope], + value: xCallFee.rollback, + }); + + const hash = await walletClient.writeContract(res.request); + return hash; + } + + async claimRewards(xTransactionInput: XTransactionInput): Promise { + throw new Error('Method not implemented.'); + } } diff --git a/packages/xwagmi/src/xchains/havah/HavahXWalletClient.ts b/packages/xwagmi/src/xchains/havah/HavahXWalletClient.ts index cddf1c49a..1b8e92d3e 100644 --- a/packages/xwagmi/src/xchains/havah/HavahXWalletClient.ts +++ b/packages/xwagmi/src/xchains/havah/HavahXWalletClient.ts @@ -18,7 +18,7 @@ export class HavahXWalletClient extends XWalletClient { return Promise.resolve(undefined); } - async executeTransaction(xTransactionInput: XTransactionInput) { + async executeSwapOrBridge(xTransactionInput: XTransactionInput) { const { type, executionTrade, account, direction, inputAmount, recipient, slippageTolerance, xCallFee } = xTransactionInput; @@ -46,8 +46,6 @@ export class HavahXWalletClient extends XWalletClient { }, }), ); - } else if (type === XTransactionType.REPAY) { - return await this._executeRepay(xTransactionInput); } else { throw new Error('Invalid XTransactionType'); } @@ -77,7 +75,19 @@ export class HavahXWalletClient extends XWalletClient { } } - async _executeRepay(xTransactionInput: XTransactionInput) { + async executeDepositCollateral(xTransactionInput: XTransactionInput): Promise { + throw new Error('Method not implemented.'); + } + + async executeWithdrawCollateral(xTransactionInput: XTransactionInput): Promise { + throw new Error('Method not implemented.'); + } + + async executeBorrow(xTransactionInput: XTransactionInput): Promise { + throw new Error('Method not implemented.'); + } + + async executeRepay(xTransactionInput: XTransactionInput) { const { account, inputAmount, recipient, xCallFee, usedCollateral } = xTransactionInput; if (!inputAmount || !usedCollateral) { @@ -101,4 +111,26 @@ export class HavahXWalletClient extends XWalletClient { return hash; } } + + async depositXToken(xTransactionInput: XTransactionInput): Promise { + throw new Error('Method not implemented.'); + } + async withdrawXToken(xTransactionInput: XTransactionInput): Promise { + throw new Error('Method not implemented.'); + } + async addLiquidity(xTransactionInput: XTransactionInput): Promise { + throw new Error('Method not implemented.'); + } + async removeLiquidity(xTransactionInput: XTransactionInput): Promise { + throw new Error('Method not implemented.'); + } + async stake(xTransactionInput: XTransactionInput): Promise { + throw new Error('Method not implemented.'); + } + async unstake(xTransactionInput: XTransactionInput): Promise { + throw new Error('Method not implemented.'); + } + async claimRewards(xTransactionInput: XTransactionInput): Promise { + throw new Error('Method not implemented.'); + } } diff --git a/packages/xwagmi/src/xchains/icon/IconXWalletClient.ts b/packages/xwagmi/src/xchains/icon/IconXWalletClient.ts index 408cb92cf..ff94968a2 100644 --- a/packages/xwagmi/src/xchains/icon/IconXWalletClient.ts +++ b/packages/xwagmi/src/xchains/icon/IconXWalletClient.ts @@ -98,29 +98,6 @@ export class IconXWalletClient extends XWalletClient { } } - async _executeBorrow(xTransactionInput: XTransactionInput) { - const { inputAmount, account, xCallFee, usedCollateral, recipient } = xTransactionInput; - - if (!inputAmount || !usedCollateral) { - return; - } - - if (account && xCallFee) { - window.addEventListener('beforeunload', showMessageOnBeforeUnload); - - const txResult = await bnJs - .inject({ account: account }) - .Loans.borrow(inputAmount.quotient.toString(), usedCollateral, 'bnUSD', recipient); - - const { result: hash } = txResult || {}; - - if (hash) { - return hash; - } - } - return undefined; - } - async _executeSwapOnIcon(xTransactionInput: XTransactionInput) { const { executionTrade, account, direction, recipient, slippageTolerance } = xTransactionInput; if (!executionTrade || !slippageTolerance) { @@ -153,7 +130,7 @@ export class IconXWalletClient extends XWalletClient { } } - async executeTransaction(xTransactionInput: XTransactionInput) { + async executeSwapOrBridge(xTransactionInput: XTransactionInput) { const { type } = xTransactionInput; if (type === XTransactionType.SWAP_ON_ICON) { @@ -162,10 +139,65 @@ export class IconXWalletClient extends XWalletClient { return this._executeSwap(xTransactionInput); } else if (type === XTransactionType.BRIDGE) { return this._executeBridge(xTransactionInput); - } else if (type === XTransactionType.BORROW) { - return this._executeBorrow(xTransactionInput); } else { throw new Error('Invalid XTransactionType'); } } + + async executeDepositCollateral(xTransactionInput: XTransactionInput): Promise { + throw new Error('Method not implemented.'); + } + + async executeWithdrawCollateral(xTransactionInput: XTransactionInput): Promise { + throw new Error('Method not implemented.'); + } + + async executeBorrow(xTransactionInput: XTransactionInput) { + const { inputAmount, account, xCallFee, usedCollateral, recipient } = xTransactionInput; + + if (!inputAmount || !usedCollateral) { + return; + } + + if (account && xCallFee) { + window.addEventListener('beforeunload', showMessageOnBeforeUnload); + + const txResult = await bnJs + .inject({ account: account }) + .Loans.borrow(inputAmount.quotient.toString(), usedCollateral, 'bnUSD', recipient); + + const { result: hash } = txResult || {}; + + if (hash) { + return hash; + } + } + return undefined; + } + + async executeRepay(xTransactionInput: XTransactionInput): Promise { + throw new Error('Method not implemented.'); + } + + async depositXToken(xTransactionInput: XTransactionInput): Promise { + throw new Error('Method not implemented.'); + } + async withdrawXToken(xTransactionInput: XTransactionInput): Promise { + throw new Error('Method not implemented.'); + } + async addLiquidity(xTransactionInput: XTransactionInput): Promise { + throw new Error('Method not implemented.'); + } + async removeLiquidity(xTransactionInput: XTransactionInput): Promise { + throw new Error('Method not implemented.'); + } + async stake(xTransactionInput: XTransactionInput): Promise { + throw new Error('Method not implemented.'); + } + async unstake(xTransactionInput: XTransactionInput): Promise { + throw new Error('Method not implemented.'); + } + async claimRewards(xTransactionInput: XTransactionInput): Promise { + throw new Error('Method not implemented.'); + } } diff --git a/packages/xwagmi/src/xchains/injective/InjectiveXWalletClient.ts b/packages/xwagmi/src/xchains/injective/InjectiveXWalletClient.ts index 2707e7717..04a922b95 100644 --- a/packages/xwagmi/src/xchains/injective/InjectiveXWalletClient.ts +++ b/packages/xwagmi/src/xchains/injective/InjectiveXWalletClient.ts @@ -24,7 +24,7 @@ export class InjectiveXWalletClient extends XWalletClient { return Promise.resolve(undefined); } - async executeTransaction(xTransactionInput: XTransactionInput) { + async executeSwapOrBridge(xTransactionInput: XTransactionInput) { const { type, direction, inputAmount, executionTrade, account, recipient, xCallFee, slippageTolerance } = xTransactionInput; @@ -50,14 +50,6 @@ export class InjectiveXWalletClient extends XWalletClient { }, }), ); - } else if (type === XTransactionType.DEPOSIT) { - return await this.executeDepositCollateral(xTransactionInput); - } else if (type === XTransactionType.WITHDRAW) { - return await this.executeWithdrawCollateral(xTransactionInput); - } else if (type === XTransactionType.BORROW) { - return await this.executeBorrow(xTransactionInput); - } else if (type === XTransactionType.REPAY) { - return await this.executeRepay(xTransactionInput); } else { throw new Error('Invalid XTransactionType'); } @@ -314,4 +306,26 @@ export class InjectiveXWalletClient extends XWalletClient { return txResult.txHash; } + + async depositXToken(xTransactionInput: XTransactionInput): Promise { + throw new Error('Method not implemented.'); + } + async withdrawXToken(xTransactionInput: XTransactionInput): Promise { + throw new Error('Method not implemented.'); + } + async addLiquidity(xTransactionInput: XTransactionInput): Promise { + throw new Error('Method not implemented.'); + } + async removeLiquidity(xTransactionInput: XTransactionInput): Promise { + throw new Error('Method not implemented.'); + } + async stake(xTransactionInput: XTransactionInput): Promise { + throw new Error('Method not implemented.'); + } + async unstake(xTransactionInput: XTransactionInput): Promise { + throw new Error('Method not implemented.'); + } + async claimRewards(xTransactionInput: XTransactionInput): Promise { + throw new Error('Method not implemented.'); + } } diff --git a/packages/xwagmi/src/xchains/solana/SolanaXWalletClient.ts b/packages/xwagmi/src/xchains/solana/SolanaXWalletClient.ts index ccf87204d..dbf04e27b 100644 --- a/packages/xwagmi/src/xchains/solana/SolanaXWalletClient.ts +++ b/packages/xwagmi/src/xchains/solana/SolanaXWalletClient.ts @@ -45,7 +45,7 @@ export class SolanaXWalletClient extends XWalletClient { return Promise.resolve(undefined); } - async executeTransaction(xTransactionInput: XTransactionInput) { + async executeSwapOrBridge(xTransactionInput: XTransactionInput) { const wallet = this.getXService().wallet; const connection = this.getXService().connection; const provider = this.getXService().provider; @@ -76,14 +76,6 @@ export class SolanaXWalletClient extends XWalletClient { }, }), ); - } else if (type === XTransactionType.DEPOSIT) { - return await this._executeDepositCollateral(xTransactionInput); - } else if (type === XTransactionType.WITHDRAW) { - return await this._executeWithdrawCollateral(xTransactionInput); - } else if (type === XTransactionType.BORROW) { - return await this._executeBorrow(xTransactionInput); - } else if (type === XTransactionType.REPAY) { - return await this._executeRepay(xTransactionInput); } else { throw new Error('Invalid XTransactionType'); } @@ -253,7 +245,7 @@ export class SolanaXWalletClient extends XWalletClient { } } - async _executeDepositCollateral(xTransactionInput: XTransactionInput) { + async executeDepositCollateral(xTransactionInput: XTransactionInput) { const wallet = this.getXService().wallet; const connection = this.getXService().connection; const provider = this.getXService().provider; @@ -387,7 +379,7 @@ export class SolanaXWalletClient extends XWalletClient { } } - async _executeWithdrawCollateral(xTransactionInput: XTransactionInput) { + async executeWithdrawCollateral(xTransactionInput: XTransactionInput) { const wallet = this.getXService().wallet; const connection = this.getXService().connection; const provider = this.getXService().provider; @@ -445,7 +437,7 @@ export class SolanaXWalletClient extends XWalletClient { } } - async _executeBorrow(xTransactionInput: XTransactionInput) { + async executeBorrow(xTransactionInput: XTransactionInput) { const wallet = this.getXService().wallet; const connection = this.getXService().connection; const provider = this.getXService().provider; @@ -507,7 +499,7 @@ export class SolanaXWalletClient extends XWalletClient { } } - async _executeRepay(xTransactionInput: XTransactionInput) { + async executeRepay(xTransactionInput: XTransactionInput) { const wallet = this.getXService().wallet; const connection = this.getXService().connection; const provider = this.getXService().provider; @@ -572,4 +564,26 @@ export class SolanaXWalletClient extends XWalletClient { return txSignature; } } + + async depositXToken(xTransactionInput: XTransactionInput): Promise { + throw new Error('Method not implemented.'); + } + async withdrawXToken(xTransactionInput: XTransactionInput): Promise { + throw new Error('Method not implemented.'); + } + async addLiquidity(xTransactionInput: XTransactionInput): Promise { + throw new Error('Method not implemented.'); + } + async removeLiquidity(xTransactionInput: XTransactionInput): Promise { + throw new Error('Method not implemented.'); + } + async stake(xTransactionInput: XTransactionInput): Promise { + throw new Error('Method not implemented.'); + } + async unstake(xTransactionInput: XTransactionInput): Promise { + throw new Error('Method not implemented.'); + } + async claimRewards(xTransactionInput: XTransactionInput): Promise { + throw new Error('Method not implemented.'); + } } diff --git a/packages/xwagmi/src/xchains/stellar/StellarXWalletClient.ts b/packages/xwagmi/src/xchains/stellar/StellarXWalletClient.ts index 8e756e9ab..093456ad9 100644 --- a/packages/xwagmi/src/xchains/stellar/StellarXWalletClient.ts +++ b/packages/xwagmi/src/xchains/stellar/StellarXWalletClient.ts @@ -306,4 +306,46 @@ export class StellarXWalletClient extends XWalletClient { throw new Error('Invalid currency for Stellar repay loan'); } } + + async executeSwapOrBridge(xTransactionInput: XTransactionInput): Promise { + throw new Error('Method not implemented.'); + } + + async executeDepositCollateral(xTransactionInput: XTransactionInput): Promise { + throw new Error('Method not implemented.'); + } + + async executeWithdrawCollateral(xTransactionInput: XTransactionInput): Promise { + throw new Error('Method not implemented.'); + } + + async executeBorrow(xTransactionInput: XTransactionInput): Promise { + throw new Error('Method not implemented.'); + } + + async executeRepay(xTransactionInput: XTransactionInput): Promise { + throw new Error('Method not implemented.'); + } + + async depositXToken(xTransactionInput: XTransactionInput): Promise { + throw new Error('Method not implemented.'); + } + async withdrawXToken(xTransactionInput: XTransactionInput): Promise { + throw new Error('Method not implemented.'); + } + async addLiquidity(xTransactionInput: XTransactionInput): Promise { + throw new Error('Method not implemented.'); + } + async removeLiquidity(xTransactionInput: XTransactionInput): Promise { + throw new Error('Method not implemented.'); + } + async stake(xTransactionInput: XTransactionInput): Promise { + throw new Error('Method not implemented.'); + } + async unstake(xTransactionInput: XTransactionInput): Promise { + throw new Error('Method not implemented.'); + } + async claimRewards(xTransactionInput: XTransactionInput): Promise { + throw new Error('Method not implemented.'); + } } diff --git a/packages/xwagmi/src/xchains/sui/SuiXService.ts b/packages/xwagmi/src/xchains/sui/SuiXService.ts index ab26adbd2..334bdadd7 100644 --- a/packages/xwagmi/src/xchains/sui/SuiXService.ts +++ b/packages/xwagmi/src/xchains/sui/SuiXService.ts @@ -4,6 +4,8 @@ export class SuiXService extends XService { private static instance: SuiXService; public suiClient: any; // TODO: define suiClient type + public suiWallet: any; // TODO: define suiWallet type + public suiAccount: any; // TODO: define suiAccount type private constructor() { super('SUI'); diff --git a/packages/xwagmi/src/xchains/sui/SuiXWalletClient.ts b/packages/xwagmi/src/xchains/sui/SuiXWalletClient.ts index 5e95b3691..6c58d113c 100644 --- a/packages/xwagmi/src/xchains/sui/SuiXWalletClient.ts +++ b/packages/xwagmi/src/xchains/sui/SuiXWalletClient.ts @@ -9,6 +9,7 @@ import { uintToBytes } from '@/utils'; import { RLP } from '@ethereumjs/rlp'; import { bcs } from '@mysten/sui/bcs'; import { Transaction } from '@mysten/sui/transactions'; +import { signTransaction } from '@mysten/wallet-standard'; import { toBytes, toHex } from 'viem'; import { XTransactionInput, XTransactionType } from '../../xcall/types'; import { getRlpEncodedSwapData, toICONDecimals } from '../../xcall/utils'; @@ -37,8 +38,7 @@ export class SuiXWalletClient extends XWalletClient { return Promise.resolve(undefined); } - async executeTransaction(xTransactionInput: XTransactionInput, options) { - const { signTransaction } = options; + async executeSwapOrBridge(xTransactionInput: XTransactionInput) { if (!signTransaction) { throw new Error('signTransaction is required'); } @@ -69,14 +69,6 @@ export class SuiXWalletClient extends XWalletClient { }, }), ); - } else if (type === XTransactionType.DEPOSIT) { - return await this.executeDepositCollateral(xTransactionInput, options); - } else if (type === XTransactionType.WITHDRAW) { - return await this.executeWithdrawCollateral(xTransactionInput, options); - } else if (type === XTransactionType.BORROW) { - return await this.executeBorrow(xTransactionInput, options); - } else if (type === XTransactionType.REPAY) { - return await this.executeRepay(xTransactionInput, options); } else { throw new Error('Invalid XTransactionType'); } @@ -104,8 +96,10 @@ export class SuiXWalletClient extends XWalletClient { typeArguments: ['0x2::sui::SUI'], }); - const { bytes, signature, reportTransactionEffects } = await signTransaction({ + const { bytes, signature } = await signTransaction(this.getXService().suiWallet, { transaction: txb, + account: this.getXService().suiAccount, + chain: this.getXService().suiAccount.chains[0], }); txResult = await this.getXService().suiClient.executeTransactionBlock({ @@ -115,10 +109,6 @@ export class SuiXWalletClient extends XWalletClient { showRawEffects: true, }, }); - - // Always report transaction effects to the wallet after execution - // @ts-ignore - reportTransactionEffects(txResult.rawEffects!); } else if (isBnUSD) { const coins = ( await this.getXService().suiClient.getCoins({ @@ -155,8 +145,10 @@ export class SuiXWalletClient extends XWalletClient { // typeArguments: [], }); - const { bytes, signature, reportTransactionEffects } = await signTransaction({ + const { bytes, signature } = await signTransaction(this.getXService().suiWallet, { transaction: txb, + account: this.getXService().suiAccount, + chain: this.getXService().suiAccount.chains[0], }); txResult = await this.getXService().suiClient.executeTransactionBlock({ @@ -166,10 +158,6 @@ export class SuiXWalletClient extends XWalletClient { showRawEffects: true, }, }); - - // Always report transaction effects to the wallet after execution - // @ts-ignore - reportTransactionEffects(txResult.rawEffects!); } else { // USDC const coins = ( @@ -207,8 +195,10 @@ export class SuiXWalletClient extends XWalletClient { typeArguments: [inputAmount.currency.wrapped.address], }); - const { bytes, signature, reportTransactionEffects } = await signTransaction({ + const { bytes, signature } = await signTransaction(this.getXService().suiWallet, { transaction: txb, + account: this.getXService().suiAccount, + chain: this.getXService().suiAccount.chains[0], }); txResult = await this.getXService().suiClient.executeTransactionBlock({ @@ -218,10 +208,6 @@ export class SuiXWalletClient extends XWalletClient { showRawEffects: true, }, }); - - // Always report transaction effects to the wallet after execution - // @ts-ignore - reportTransactionEffects(txResult.rawEffects!); } const { digest: hash } = txResult || {}; @@ -231,8 +217,7 @@ export class SuiXWalletClient extends XWalletClient { } } - async executeDepositCollateral(xTransactionInput: XTransactionInput, options) { - const { signTransaction } = options; + async executeDepositCollateral(xTransactionInput: XTransactionInput) { const { inputAmount, account, xCallFee } = xTransactionInput; if (!inputAmount) { @@ -263,8 +248,10 @@ export class SuiXWalletClient extends XWalletClient { typeArguments: ['0x2::sui::SUI'], }); - const { bytes, signature, reportTransactionEffects } = await signTransaction({ + const { bytes, signature } = await signTransaction(this.getXService().suiWallet, { transaction: txb, + account: this.getXService().suiAccount, + chain: this.getXService().suiAccount.chains[0], }); txResult = await this.getXService().suiClient.executeTransactionBlock({ @@ -314,8 +301,10 @@ export class SuiXWalletClient extends XWalletClient { typeArguments: [inputAmount.currency.wrapped.address], }); - const { bytes, signature, reportTransactionEffects } = await signTransaction({ + const { bytes, signature } = await signTransaction(this.getXService().suiWallet, { transaction: txb, + account: this.getXService().suiAccount, + chain: this.getXService().suiAccount.chains[0], }); txResult = await this.getXService().suiClient.executeTransactionBlock({ @@ -338,8 +327,7 @@ export class SuiXWalletClient extends XWalletClient { } } - async executeWithdrawCollateral(xTransactionInput: XTransactionInput, options) { - const { signTransaction } = options; + async executeWithdrawCollateral(xTransactionInput: XTransactionInput) { const { inputAmount, account, xCallFee, usedCollateral, direction } = xTransactionInput; if (!inputAmount || !usedCollateral) { @@ -376,8 +364,10 @@ export class SuiXWalletClient extends XWalletClient { // typeArguments: ['0x2::sui::SUI'], }); - const { bytes, signature, reportTransactionEffects } = await signTransaction({ + const { bytes, signature } = await signTransaction(this.getXService().suiWallet, { transaction: txb, + account: this.getXService().suiAccount, + chain: this.getXService().suiAccount.chains[0], }); const txResult = await this.getXService().suiClient.executeTransactionBlock({ @@ -388,10 +378,6 @@ export class SuiXWalletClient extends XWalletClient { }, }); - // Always report transaction effects to the wallet after execution - // @ts-ignore - reportTransactionEffects(txResult.rawEffects!); - const { digest: hash } = txResult || {}; if (hash) { @@ -399,9 +385,7 @@ export class SuiXWalletClient extends XWalletClient { } } - async executeBorrow(xTransactionInput: XTransactionInput, options) { - const { signTransaction } = options; - + async executeBorrow(xTransactionInput: XTransactionInput) { const { inputAmount, account, xCallFee, usedCollateral, recipient, direction } = xTransactionInput; if (!inputAmount || !usedCollateral) { @@ -444,8 +428,10 @@ export class SuiXWalletClient extends XWalletClient { // typeArguments: ['0x2::sui::SUI'], }); - const { bytes, signature, reportTransactionEffects } = await signTransaction({ + const { bytes, signature } = await signTransaction(this.getXService().suiWallet, { transaction: txb, + account: this.getXService().suiAccount, + chain: this.getXService().suiAccount.chains[0], }); const txResult = await this.getXService().suiClient.executeTransactionBlock({ @@ -456,19 +442,13 @@ export class SuiXWalletClient extends XWalletClient { }, }); - // Always report transaction effects to the wallet after execution - // @ts-ignore - reportTransactionEffects(txResult.rawEffects!); - const { digest: hash } = txResult || {}; if (hash) { return hash; } } - async executeRepay(xTransactionInput: XTransactionInput, options) { - const { signTransaction } = options; - + async executeRepay(xTransactionInput: XTransactionInput) { const { inputAmount, account, xCallFee, usedCollateral, recipient, direction } = xTransactionInput; if (!inputAmount || !usedCollateral) { @@ -527,8 +507,10 @@ export class SuiXWalletClient extends XWalletClient { // typeArguments: [], }); - const { bytes, signature, reportTransactionEffects } = await signTransaction({ + const { bytes, signature } = await signTransaction(this.getXService().suiWallet, { transaction: txb, + account: this.getXService().suiAccount, + chain: this.getXService().suiAccount.chains[0], }); const txResult = await this.getXService().suiClient.executeTransactionBlock({ @@ -539,14 +521,32 @@ export class SuiXWalletClient extends XWalletClient { }, }); - // Always report transaction effects to the wallet after execution - // @ts-ignore - reportTransactionEffects(txResult.rawEffects!); - const { digest: hash } = txResult || {}; if (hash) { return hash; } } + + async depositXToken(xTransactionInput: XTransactionInput): Promise { + throw new Error('Method not implemented.'); + } + async withdrawXToken(xTransactionInput: XTransactionInput): Promise { + throw new Error('Method not implemented.'); + } + async addLiquidity(xTransactionInput: XTransactionInput): Promise { + throw new Error('Method not implemented.'); + } + async removeLiquidity(xTransactionInput: XTransactionInput): Promise { + throw new Error('Method not implemented.'); + } + async stake(xTransactionInput: XTransactionInput): Promise { + throw new Error('Method not implemented.'); + } + async unstake(xTransactionInput: XTransactionInput): Promise { + throw new Error('Method not implemented.'); + } + async claimRewards(xTransactionInput: XTransactionInput): Promise { + throw new Error('Method not implemented.'); + } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index ac9ff05fe..51de812e7 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -40,7 +40,7 @@ importers: version: link:../../packages/xwagmi '@injectivelabs/wallet-ts': specifier: 1.14.13 - version: 1.14.13(@babel/runtime@7.26.0)(@react-native-async-storage/async-storage@1.23.1(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@5.0.10)))(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10))(@types/react@18.2.67)(bs58@5.0.0)(bufferutil@4.0.8)(expo@51.0.29(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(utf-8-validate@5.0.10))(google-protobuf@3.21.4)(react-dom@18.2.0(react@18.2.0))(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@5.0.10))(react@18.2.0)(tslib@2.6.2)(utf-8-validate@5.0.10) + version: 1.14.13(@babel/runtime@7.26.0)(@react-native-async-storage/async-storage@1.23.1(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@5.0.10)))(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10))(@types/react@18.2.67)(bufferutil@4.0.8)(expo@51.0.29(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(utf-8-validate@5.0.10))(google-protobuf@3.21.4)(react-dom@18.2.0(react@18.2.0))(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@5.0.10))(react@18.2.0)(tslib@2.6.2)(utf-8-validate@5.0.10) '@lingui/conf': specifier: 4.7.1 version: 4.7.1(typescript@5.5.4) @@ -393,10 +393,10 @@ importers: version: 5.3.3 '@types/rebass': specifier: 4.0.7 - version: 4.0.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@6.0.5) + version: 4.0.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@5.0.10) '@types/styled-components': specifier: 5.1.3 - version: 5.1.3(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@6.0.5) + version: 5.1.3(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@5.0.10) '@vitejs/plugin-react': specifier: 4.2.1 version: 4.2.1(vite@5.4.0(@types/node@22.9.3)(terser@5.30.3)) @@ -453,7 +453,7 @@ importers: version: 5.4.0 '@injectivelabs/wallet-ts': specifier: 1.14.13 - version: 1.14.13(@babel/runtime@7.26.0)(@react-native-async-storage/async-storage@1.23.1(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@5.0.10)))(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10))(@types/react@18.2.67)(bs58@5.0.0)(bufferutil@4.0.8)(expo@51.0.29(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(utf-8-validate@5.0.10))(google-protobuf@3.21.4)(react-dom@18.2.0(react@18.2.0))(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@5.0.10))(react@18.2.0)(tslib@2.6.2)(utf-8-validate@5.0.10) + version: 1.14.13(@babel/runtime@7.26.0)(@react-native-async-storage/async-storage@1.23.1(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@5.0.10)))(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10))(@types/react@18.2.67)(bufferutil@4.0.8)(expo@51.0.29(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(utf-8-validate@5.0.10))(google-protobuf@3.21.4)(react-dom@18.2.0(react@18.2.0))(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@5.0.10))(react@18.2.0)(tslib@2.6.2)(utf-8-validate@5.0.10) '@lingui/conf': specifier: 4.7.1 version: 4.7.1(typescript@5.5.4) @@ -740,7 +740,7 @@ importers: devDependencies: tsup: specifier: ^8.0.2 - version: 8.0.2(@swc/core@1.4.8)(postcss@8.4.41)(typescript@5.7.2) + version: 8.0.2(@swc/core@1.4.8(@swc/helpers@0.5.12))(postcss@8.4.41)(typescript@5.7.2) packages/intents-sdk: dependencies: @@ -802,7 +802,7 @@ importers: version: 6.2.2 tsup: specifier: ^8.0.2 - version: 8.0.2(@swc/core@1.4.8)(postcss@8.4.41)(typescript@5.7.2) + version: 8.0.2(@swc/core@1.4.8(@swc/helpers@0.5.12))(postcss@8.4.41)(typescript@5.7.2) packages/v1-sdk: dependencies: @@ -824,13 +824,13 @@ importers: devDependencies: tsup: specifier: ^8.0.2 - version: 8.0.2(@swc/core@1.4.8)(postcss@8.4.41)(typescript@5.7.2) + version: 8.0.2(@swc/core@1.4.8(@swc/helpers@0.5.12))(postcss@8.4.41)(typescript@5.7.2) packages/xwagmi: dependencies: '@archwayhq/arch3.js': specifier: 0.7.0 - version: 0.7.0(bufferutil@4.0.8)(utf-8-validate@5.0.10) + version: 0.7.0(bufferutil@4.0.8)(utf-8-validate@6.0.5) '@balancednetwork/balanced-js': specifier: workspace:* version: link:../balanced-js @@ -842,10 +842,10 @@ importers: version: link:../v1-sdk '@coral-xyz/anchor': specifier: 0.30.1 - version: 0.30.1(bufferutil@4.0.8)(utf-8-validate@5.0.10) + version: 0.30.1(bufferutil@4.0.8)(utf-8-validate@6.0.5) '@cosmjs/cosmwasm-stargate': specifier: 0.32.2 - version: 0.32.2(bufferutil@4.0.8)(utf-8-validate@5.0.10) + version: 0.32.2(bufferutil@4.0.8)(utf-8-validate@6.0.5) '@cosmjs/encoding': specifier: 0.32.3 version: 0.32.3 @@ -854,10 +854,10 @@ importers: version: 0.32.3 '@cosmjs/tendermint-rpc': specifier: 0.32.3 - version: 0.32.3(bufferutil@4.0.8)(utf-8-validate@5.0.10) + version: 0.32.3(bufferutil@4.0.8)(utf-8-validate@6.0.5) '@creit.tech/stellar-wallets-kit': specifier: 1.2.1 - version: 1.2.1(@react-native-async-storage/async-storage@1.23.1(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@5.0.10)))(@types/react@18.2.67)(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@5.0.10) + version: 1.2.1(@react-native-async-storage/async-storage@1.23.1(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@6.0.5)))(@types/react@18.2.67)(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@6.0.5) '@ethereumjs/rlp': specifier: 5.0.0 version: 5.0.0 @@ -866,13 +866,13 @@ importers: version: 1.14.13(google-protobuf@3.21.4) '@injectivelabs/sdk-ts': specifier: 1.14.13 - version: 1.14.13(@types/react@18.2.67)(bufferutil@4.0.8)(react-dom@18.2.0(react@18.2.0))(react@18.2.0)(utf-8-validate@5.0.10) + version: 1.14.13(@types/react@18.2.67)(bufferutil@4.0.8)(react-dom@18.2.0(react@18.2.0))(react@18.2.0)(utf-8-validate@6.0.5) '@injectivelabs/ts-types': specifier: 1.14.13 version: 1.14.13 '@injectivelabs/wallet-ts': specifier: 1.14.13 - version: 1.14.13(@babel/runtime@7.26.0)(@react-native-async-storage/async-storage@1.23.1(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@5.0.10)))(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10))(@types/react@18.2.67)(bs58@5.0.0)(bufferutil@4.0.8)(expo@51.0.29(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(utf-8-validate@5.0.10))(google-protobuf@3.21.4)(react-dom@18.2.0(react@18.2.0))(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@5.0.10))(react@18.2.0)(tslib@2.6.2)(utf-8-validate@5.0.10) + version: 1.14.13(@babel/runtime@7.26.0)(@react-native-async-storage/async-storage@1.23.1(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@6.0.5)))(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5))(@types/react@18.2.67)(bs58@5.0.0)(bufferutil@4.0.8)(expo@51.0.29(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(utf-8-validate@6.0.5))(google-protobuf@3.21.4)(react-dom@18.2.0(react@18.2.0))(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@6.0.5))(react@18.2.0)(tslib@2.6.2)(utf-8-validate@6.0.5) '@keplr-wallet/types': specifier: 0.12.18 version: 0.12.18 @@ -882,21 +882,24 @@ importers: '@mysten/sui': specifier: 1.8.0 version: 1.8.0(typescript@5.5.4) + '@mysten/wallet-standard': + specifier: ^0.13.20 + version: 0.13.20(typescript@5.5.4) '@solana/spl-token': specifier: 0.4.9 - version: 0.4.9(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10))(bufferutil@4.0.8)(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.5.4)(utf-8-validate@5.0.10) + version: 0.4.9(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5))(bufferutil@4.0.8)(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.5.4)(utf-8-validate@6.0.5) '@solana/wallet-adapter-base': specifier: 0.9.23 - version: 0.9.23(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10)) + version: 0.9.23(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5)) '@solana/wallet-adapter-react': specifier: 0.15.35 - version: 0.15.35(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10))(bs58@5.0.0)(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@5.0.10))(react@18.2.0) + version: 0.15.35(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5))(bs58@5.0.0)(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@6.0.5))(react@18.2.0) '@solana/wallet-adapter-wallets': specifier: 0.19.32 - version: 0.19.32(@babel/runtime@7.26.0)(@react-native-async-storage/async-storage@1.23.1(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@5.0.10)))(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10))(bs58@5.0.0)(bufferutil@4.0.8)(expo@51.0.29(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(utf-8-validate@5.0.10))(react-dom@18.2.0(react@18.2.0))(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@5.0.10))(react@18.2.0)(tslib@2.6.2)(utf-8-validate@5.0.10) + version: 0.19.32(@babel/runtime@7.26.0)(@react-native-async-storage/async-storage@1.23.1(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@6.0.5)))(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5))(bs58@5.0.0)(bufferutil@4.0.8)(expo@51.0.29(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(utf-8-validate@6.0.5))(react-dom@18.2.0(react@18.2.0))(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@6.0.5))(react@18.2.0)(tslib@2.6.2)(utf-8-validate@6.0.5) '@solana/web3.js': specifier: 1.95.4 - version: 1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10) + version: 1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5) '@stellar/stellar-sdk': specifier: 12.3.0 version: 12.3.0 @@ -917,7 +920,7 @@ importers: version: 0.9.0 ethers: specifier: 5.6.1 - version: 5.6.1(bufferutil@4.0.8)(utf-8-validate@5.0.10) + version: 5.6.1(bufferutil@4.0.8)(utf-8-validate@6.0.5) icon-sdk-js: specifier: 1.5.3 version: 1.5.3 @@ -941,10 +944,10 @@ importers: version: 3.0.0 viem: specifier: 2.x - version: 2.21.50(bufferutil@4.0.8)(typescript@5.5.4)(utf-8-validate@5.0.10)(zod@3.23.8) + version: 2.21.50(bufferutil@4.0.8)(typescript@5.5.4)(utf-8-validate@6.0.5)(zod@3.23.8) wagmi: specifier: 2.5.20 - version: 2.5.20(@react-native-async-storage/async-storage@1.23.1(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@5.0.10)))(@swc/core@1.4.8)(@tanstack/query-core@5.29.0)(@tanstack/react-query@5.29.2(react@18.2.0))(@types/react@18.2.67)(bufferutil@4.0.8)(immer@10.1.1)(react-dom@18.2.0(react@18.2.0))(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@5.0.10))(react@18.2.0)(rollup@4.13.0)(typescript@5.5.4)(utf-8-validate@5.0.10)(viem@2.21.50(bufferutil@4.0.8)(typescript@5.5.4)(utf-8-validate@5.0.10)(zod@3.23.8))(zod@3.23.8) + version: 2.5.20(@react-native-async-storage/async-storage@1.23.1(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@6.0.5)))(@swc/core@1.4.8)(@tanstack/query-core@5.29.0)(@tanstack/react-query@5.29.2(react@18.2.0))(@types/react@18.2.67)(bufferutil@4.0.8)(esbuild@0.19.12)(immer@10.1.1)(react-dom@18.2.0(react@18.2.0))(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@6.0.5))(react@18.2.0)(rollup@4.13.0)(typescript@5.5.4)(utf-8-validate@6.0.5)(viem@2.21.50(bufferutil@4.0.8)(typescript@5.5.4)(utf-8-validate@6.0.5)(zod@3.23.8))(zod@3.23.8) zustand: specifier: 4.5.2 version: 4.5.2(@types/react@18.2.67)(immer@10.1.1)(react@18.2.0) @@ -3488,6 +3491,9 @@ packages: '@mysten/bcs@1.1.1': resolution: {integrity: sha512-8X3IwmVfkwgHnNHR4izpi7f7aD0iVDU2B8p2KoIzCA9sCGcl9O2RnFDezHbNGgT+yBT+dKVDpTAczhnwZ6eUkQ==} + '@mysten/bcs@1.2.0': + resolution: {integrity: sha512-LuKonrGdGW7dq/EM6U2L9/as7dFwnhZnsnINzB/vu08Xfrj0qzWwpLOiXagAa5yZOPLK7anRZydMonczFkUPzA==} + '@mysten/dapp-kit@0.14.18': resolution: {integrity: sha512-r83LEEslaAWKFPcL+FC4SbnY6GktKPUeUady1Y1/um7+J0A06o1189A4FIkcwGm54O2QXsVmpYHxpTd4+NizVw==} peerDependencies: @@ -3502,6 +3508,10 @@ packages: resolution: {integrity: sha512-KI4richLtbq4RYbv5SmhWMIFD5BRW0tNOSGxZMLxjDBqBwkTqkQ4WBvmxjpbG/2WsLw0SCNrc7JYmoiaB58aLA==} engines: {node: '>=18'} + '@mysten/sui@1.18.0': + resolution: {integrity: sha512-cFh5LxXZrXb/ZAD1dkKeQxzhgRYFXreyFGmI7w/JQWwdl+/0FrHJBwaWyTmGxJ/6ZC9SlaOPOk63flN7DbUurg==} + engines: {node: '>=18'} + '@mysten/sui@1.8.0': resolution: {integrity: sha512-iL7yztpePS/GWFZ7yiD/Pl7ciuOD2ySyogJZmLFu4WxZfiIcXJX+U/U+Egq9VHvELk8+m+Z1OvvPlNQfuowMIg==} engines: {node: '>=18'} @@ -3509,6 +3519,9 @@ packages: '@mysten/wallet-standard@0.13.16': resolution: {integrity: sha512-0UEsEmQ/JzYFfba4enKyzv4VOqFSZx6XJmmPrQZxPNqShDq0EI60q5K7P91gWMmMlK3Dxq7nOUJASWZL12Yb4g==} + '@mysten/wallet-standard@0.13.20': + resolution: {integrity: sha512-k9nDnZ/ZkCr4wFRxiP984k/T2ZUfwd/+RfYnwbMHv6MW91no2VKb53fVxbkhqc39qGKAvrXeMonNrm37Iz0JFw==} + '@mysten/wallet-standard@0.13.3': resolution: {integrity: sha512-aLxhLIM6uzsfBZ5HbOLrvw1WrzHGPzysUmiFrXRizNpclz2DqxeqngDiDq8VogKM2bXCjhF0SxSc+Bj+relp7w==} @@ -4718,6 +4731,10 @@ packages: '@sideway/pinpoint@2.0.0': resolution: {integrity: sha512-RNiOoTPkptFtSVzQevY/yWtZwf/RxyVnPy/OcA9HBM3MlGDnBEYL5B41H0MTn0Uec8Hi+2qUtTfG2WWZBmMejQ==} + '@simplewebauthn/typescript-types@7.4.0': + resolution: {integrity: sha512-8/ZjHeUPe210Bt5oyaOIGx4h8lHdsQs19BiOT44gi/jBEgK7uBGA0Fy7NRsyh777al3m6WM0mBf0UR7xd4R7WQ==} + deprecated: This package has been renamed to @simplewebauthn/types. Please install @simplewebauthn/types instead to ensure you receive future updates. + '@sinclair/typebox@0.27.8': resolution: {integrity: sha512-+Fj43pSMwJs4KRrH/938Uf+uAELIgVBmQzg/q1YG10djyfA3TnrU8N8XzqCh/okZdszqBQTZf96idMfE5lnwTA==} @@ -13782,37 +13799,37 @@ snapshots: transitivePeerDependencies: - '@types/react' - '@archwayhq/arch3-core@0.7.0(bufferutil@4.0.8)(utf-8-validate@5.0.10)': + '@archwayhq/arch3-core@0.7.0(bufferutil@4.0.8)(utf-8-validate@6.0.5)': dependencies: - '@archwayhq/arch3-proto': 0.7.0(bufferutil@4.0.8)(utf-8-validate@5.0.10) + '@archwayhq/arch3-proto': 0.7.0(bufferutil@4.0.8)(utf-8-validate@6.0.5) '@cosmjs/amino': 0.32.4 - '@cosmjs/cosmwasm-stargate': 0.32.2(bufferutil@4.0.8)(utf-8-validate@5.0.10) + '@cosmjs/cosmwasm-stargate': 0.32.2(bufferutil@4.0.8)(utf-8-validate@6.0.5) '@cosmjs/math': 0.32.4 '@cosmjs/proto-signing': 0.32.3 - '@cosmjs/stargate': 0.32.4(bufferutil@4.0.8)(utf-8-validate@5.0.10) - '@cosmjs/tendermint-rpc': 0.32.3(bufferutil@4.0.8)(utf-8-validate@5.0.10) + '@cosmjs/stargate': 0.32.4(bufferutil@4.0.8)(utf-8-validate@6.0.5) + '@cosmjs/tendermint-rpc': 0.32.3(bufferutil@4.0.8)(utf-8-validate@6.0.5) lodash: 4.17.21 transitivePeerDependencies: - bufferutil - debug - utf-8-validate - '@archwayhq/arch3-proto@0.7.0(bufferutil@4.0.8)(utf-8-validate@5.0.10)': + '@archwayhq/arch3-proto@0.7.0(bufferutil@4.0.8)(utf-8-validate@6.0.5)': dependencies: '@cosmjs/amino': 0.32.4 '@cosmjs/proto-signing': 0.32.3 - '@cosmjs/stargate': 0.32.4(bufferutil@4.0.8)(utf-8-validate@5.0.10) - '@cosmjs/tendermint-rpc': 0.32.3(bufferutil@4.0.8)(utf-8-validate@5.0.10) + '@cosmjs/stargate': 0.32.4(bufferutil@4.0.8)(utf-8-validate@6.0.5) + '@cosmjs/tendermint-rpc': 0.32.3(bufferutil@4.0.8)(utf-8-validate@6.0.5) protobufjs: 7.2.6 transitivePeerDependencies: - bufferutil - debug - utf-8-validate - '@archwayhq/arch3.js@0.7.0(bufferutil@4.0.8)(utf-8-validate@5.0.10)': + '@archwayhq/arch3.js@0.7.0(bufferutil@4.0.8)(utf-8-validate@6.0.5)': dependencies: - '@archwayhq/arch3-core': 0.7.0(bufferutil@4.0.8)(utf-8-validate@5.0.10) - '@archwayhq/arch3-proto': 0.7.0(bufferutil@4.0.8)(utf-8-validate@5.0.10) + '@archwayhq/arch3-core': 0.7.0(bufferutil@4.0.8)(utf-8-validate@6.0.5) + '@archwayhq/arch3-proto': 0.7.0(bufferutil@4.0.8)(utf-8-validate@6.0.5) transitivePeerDependencies: - bufferutil - debug @@ -15132,12 +15149,12 @@ snapshots: '@coral-xyz/anchor-errors@0.30.1': {} - '@coral-xyz/anchor@0.30.1(bufferutil@4.0.8)(utf-8-validate@5.0.10)': + '@coral-xyz/anchor@0.30.1(bufferutil@4.0.8)(utf-8-validate@6.0.5)': dependencies: '@coral-xyz/anchor-errors': 0.30.1 - '@coral-xyz/borsh': 0.30.1(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10)) + '@coral-xyz/borsh': 0.30.1(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5)) '@noble/hashes': 1.5.0 - '@solana/web3.js': 1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10) + '@solana/web3.js': 1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5) bn.js: 5.2.1 bs58: 4.0.1 buffer-layout: 1.2.2 @@ -15154,9 +15171,9 @@ snapshots: - encoding - utf-8-validate - '@coral-xyz/borsh@0.30.1(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10))': + '@coral-xyz/borsh@0.30.1(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5))': dependencies: - '@solana/web3.js': 1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10) + '@solana/web3.js': 1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5) bn.js: 5.2.1 buffer-layout: 1.2.2 @@ -15174,15 +15191,15 @@ snapshots: '@cosmjs/math': 0.32.4 '@cosmjs/utils': 0.32.4 - '@cosmjs/cosmwasm-stargate@0.32.2(bufferutil@4.0.8)(utf-8-validate@5.0.10)': + '@cosmjs/cosmwasm-stargate@0.32.2(bufferutil@4.0.8)(utf-8-validate@6.0.5)': dependencies: '@cosmjs/amino': 0.32.4 '@cosmjs/crypto': 0.32.4 '@cosmjs/encoding': 0.32.3 '@cosmjs/math': 0.32.4 '@cosmjs/proto-signing': 0.32.3 - '@cosmjs/stargate': 0.32.4(bufferutil@4.0.8)(utf-8-validate@5.0.10) - '@cosmjs/tendermint-rpc': 0.32.3(bufferutil@4.0.8)(utf-8-validate@5.0.10) + '@cosmjs/stargate': 0.32.4(bufferutil@4.0.8)(utf-8-validate@6.0.5) + '@cosmjs/tendermint-rpc': 0.32.3(bufferutil@4.0.8)(utf-8-validate@6.0.5) '@cosmjs/utils': 0.32.4 cosmjs-types: 0.9.0 pako: 2.1.0 @@ -15294,6 +15311,16 @@ snapshots: - bufferutil - utf-8-validate + '@cosmjs/socket@0.32.4(bufferutil@4.0.8)(utf-8-validate@6.0.5)': + dependencies: + '@cosmjs/stream': 0.32.4 + isomorphic-ws: 4.0.1(ws@7.5.10(bufferutil@4.0.8)(utf-8-validate@6.0.5)) + ws: 7.5.10(bufferutil@4.0.8)(utf-8-validate@6.0.5) + xstream: 11.14.0 + transitivePeerDependencies: + - bufferutil + - utf-8-validate + '@cosmjs/stargate@0.32.4(bufferutil@4.0.8)(utf-8-validate@5.0.10)': dependencies: '@confio/ics23': 0.6.8 @@ -15311,17 +15338,34 @@ snapshots: - debug - utf-8-validate + '@cosmjs/stargate@0.32.4(bufferutil@4.0.8)(utf-8-validate@6.0.5)': + dependencies: + '@confio/ics23': 0.6.8 + '@cosmjs/amino': 0.32.4 + '@cosmjs/encoding': 0.32.4 + '@cosmjs/math': 0.32.4 + '@cosmjs/proto-signing': 0.32.4 + '@cosmjs/stream': 0.32.4 + '@cosmjs/tendermint-rpc': 0.32.4(bufferutil@4.0.8)(utf-8-validate@6.0.5) + '@cosmjs/utils': 0.32.4 + cosmjs-types: 0.9.0 + xstream: 11.14.0 + transitivePeerDependencies: + - bufferutil + - debug + - utf-8-validate + '@cosmjs/stream@0.32.4': dependencies: xstream: 11.14.0 - '@cosmjs/tendermint-rpc@0.32.3(bufferutil@4.0.8)(utf-8-validate@5.0.10)': + '@cosmjs/tendermint-rpc@0.32.3(bufferutil@4.0.8)(utf-8-validate@6.0.5)': dependencies: '@cosmjs/crypto': 0.32.4 '@cosmjs/encoding': 0.32.3 '@cosmjs/json-rpc': 0.32.4 '@cosmjs/math': 0.32.4 - '@cosmjs/socket': 0.32.4(bufferutil@4.0.8)(utf-8-validate@5.0.10) + '@cosmjs/socket': 0.32.4(bufferutil@4.0.8)(utf-8-validate@6.0.5) '@cosmjs/stream': 0.32.4 '@cosmjs/utils': 0.32.4 axios: 1.7.9 @@ -15349,13 +15393,30 @@ snapshots: - debug - utf-8-validate + '@cosmjs/tendermint-rpc@0.32.4(bufferutil@4.0.8)(utf-8-validate@6.0.5)': + dependencies: + '@cosmjs/crypto': 0.32.4 + '@cosmjs/encoding': 0.32.4 + '@cosmjs/json-rpc': 0.32.4 + '@cosmjs/math': 0.32.4 + '@cosmjs/socket': 0.32.4(bufferutil@4.0.8)(utf-8-validate@6.0.5) + '@cosmjs/stream': 0.32.4 + '@cosmjs/utils': 0.32.4 + axios: 1.7.9 + readonly-date: 1.0.0 + xstream: 11.14.0 + transitivePeerDependencies: + - bufferutil + - debug + - utf-8-validate + '@cosmjs/utils@0.27.1': {} '@cosmjs/utils@0.32.4': {} '@cosmostation/extension-client@0.1.15': {} - '@creit.tech/stellar-wallets-kit@1.2.1(@react-native-async-storage/async-storage@1.23.1(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@5.0.10)))(@types/react@18.2.67)(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@5.0.10)': + '@creit.tech/stellar-wallets-kit@1.2.1(@react-native-async-storage/async-storage@1.23.1(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@6.0.5)))(@types/react@18.2.67)(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@6.0.5)': dependencies: '@albedo-link/intent': 0.12.0 '@creit.tech/xbull-wallet-connect': 0.3.0 @@ -15366,7 +15427,7 @@ snapshots: '@ngneat/elf-persist-state': 1.2.1(rxjs@7.8.1) '@stellar/freighter-api': 3.0.0 '@walletconnect/modal': 2.6.2(@types/react@18.2.67)(react@18.2.0) - '@walletconnect/sign-client': 2.11.2(@react-native-async-storage/async-storage@1.23.1(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@5.0.10)))(bufferutil@4.0.8)(utf-8-validate@5.0.10) + '@walletconnect/sign-client': 2.11.2(@react-native-async-storage/async-storage@1.23.1(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@6.0.5)))(bufferutil@4.0.8)(utf-8-validate@6.0.5) events: 3.3.0 lit: 3.2.0 rxjs: 7.8.1 @@ -16132,6 +16193,31 @@ snapshots: - bufferutil - utf-8-validate + '@ethersproject/providers@5.6.1(bufferutil@4.0.8)(utf-8-validate@6.0.5)': + dependencies: + '@ethersproject/abstract-provider': 5.7.0 + '@ethersproject/abstract-signer': 5.7.0 + '@ethersproject/address': 5.7.0 + '@ethersproject/basex': 5.7.0 + '@ethersproject/bignumber': 5.7.0 + '@ethersproject/bytes': 5.7.0 + '@ethersproject/constants': 5.7.0 + '@ethersproject/hash': 5.7.0 + '@ethersproject/logger': 5.7.0 + '@ethersproject/networks': 5.7.1 + '@ethersproject/properties': 5.7.0 + '@ethersproject/random': 5.7.0 + '@ethersproject/rlp': 5.7.0 + '@ethersproject/sha2': 5.7.0 + '@ethersproject/strings': 5.7.0 + '@ethersproject/transactions': 5.7.0 + '@ethersproject/web': 5.7.1 + bech32: 1.1.4 + ws: 7.4.6(bufferutil@4.0.8)(utf-8-validate@6.0.5) + transitivePeerDependencies: + - bufferutil + - utf-8-validate + '@ethersproject/providers@5.7.2(bufferutil@4.0.8)(utf-8-validate@5.0.10)': dependencies: '@ethersproject/abstract-provider': 5.7.0 @@ -16158,6 +16244,32 @@ snapshots: - bufferutil - utf-8-validate + '@ethersproject/providers@5.7.2(bufferutil@4.0.8)(utf-8-validate@6.0.5)': + dependencies: + '@ethersproject/abstract-provider': 5.7.0 + '@ethersproject/abstract-signer': 5.7.0 + '@ethersproject/address': 5.7.0 + '@ethersproject/base64': 5.7.0 + '@ethersproject/basex': 5.7.0 + '@ethersproject/bignumber': 5.7.0 + '@ethersproject/bytes': 5.7.0 + '@ethersproject/constants': 5.7.0 + '@ethersproject/hash': 5.7.0 + '@ethersproject/logger': 5.7.0 + '@ethersproject/networks': 5.7.1 + '@ethersproject/properties': 5.7.0 + '@ethersproject/random': 5.7.0 + '@ethersproject/rlp': 5.7.0 + '@ethersproject/sha2': 5.7.0 + '@ethersproject/strings': 5.7.0 + '@ethersproject/transactions': 5.7.0 + '@ethersproject/web': 5.7.1 + bech32: 1.1.4 + ws: 7.4.6(bufferutil@4.0.8)(utf-8-validate@6.0.5) + transitivePeerDependencies: + - bufferutil + - utf-8-validate + '@ethersproject/random@5.6.0': dependencies: '@ethersproject/bytes': 5.7.0 @@ -16440,6 +16552,92 @@ snapshots: - supports-color - utf-8-validate + '@expo/cli@0.18.29(bufferutil@4.0.8)(expo-modules-autolinking@1.11.2)(utf-8-validate@6.0.5)': + dependencies: + '@babel/runtime': 7.26.0 + '@expo/code-signing-certificates': 0.0.5 + '@expo/config': 9.0.3 + '@expo/config-plugins': 8.0.8 + '@expo/devcert': 1.1.4 + '@expo/env': 0.3.0 + '@expo/image-utils': 0.5.1 + '@expo/json-file': 8.3.3 + '@expo/metro-config': 0.18.11 + '@expo/osascript': 2.1.3 + '@expo/package-manager': 1.5.2 + '@expo/plist': 0.1.3 + '@expo/prebuild-config': 7.0.8(expo-modules-autolinking@1.11.2) + '@expo/rudder-sdk-node': 1.1.1 + '@expo/spawn-async': 1.7.2 + '@expo/xcpretty': 4.3.1 + '@react-native/dev-middleware': 0.74.85(bufferutil@4.0.8)(utf-8-validate@6.0.5) + '@urql/core': 2.3.6(graphql@15.8.0) + '@urql/exchange-retry': 0.3.0(graphql@15.8.0) + accepts: 1.3.8 + arg: 5.0.2 + better-opn: 3.0.2 + bplist-creator: 0.0.7 + bplist-parser: 0.3.2 + cacache: 18.0.4 + chalk: 4.1.0 + ci-info: 3.9.0 + connect: 3.7.0 + debug: 4.3.7 + env-editor: 0.4.2 + fast-glob: 3.3.2 + find-yarn-workspace-root: 2.0.0 + form-data: 3.0.1 + freeport-async: 2.0.0 + fs-extra: 8.1.0 + getenv: 1.0.0 + glob: 7.2.3 + graphql: 15.8.0 + graphql-tag: 2.12.6(graphql@15.8.0) + https-proxy-agent: 5.0.1 + internal-ip: 4.3.0 + is-docker: 2.2.1 + is-wsl: 2.2.0 + js-yaml: 3.14.1 + json-schema-deref-sync: 0.13.0 + lodash.debounce: 4.0.8 + md5hex: 1.0.0 + minimatch: 3.1.2 + node-fetch: 2.7.0 + node-forge: 1.3.1 + npm-package-arg: 7.0.0 + open: 8.4.2 + ora: 3.4.0 + picomatch: 3.0.1 + pretty-bytes: 5.6.0 + progress: 2.0.3 + prompts: 2.4.2 + qrcode-terminal: 0.11.0 + require-from-string: 2.0.2 + requireg: 0.2.2 + resolve: 1.22.8 + resolve-from: 5.0.0 + resolve.exports: 2.0.2 + semver: 7.6.0 + send: 0.18.0 + slugify: 1.6.6 + source-map-support: 0.5.21 + stacktrace-parser: 0.1.10 + structured-headers: 0.4.1 + tar: 6.2.1 + temp-dir: 2.0.0 + tempy: 0.7.1 + terminal-link: 2.1.1 + text-table: 0.2.0 + url-join: 4.0.0 + wrap-ansi: 7.0.0 + ws: 8.18.0(bufferutil@4.0.8)(utf-8-validate@6.0.5) + transitivePeerDependencies: + - bufferutil + - encoding + - expo-modules-autolinking + - supports-color + - utf-8-validate + '@expo/code-signing-certificates@0.0.5': dependencies: node-forge: 1.3.1 @@ -16716,6 +16914,16 @@ snapshots: - react - react-dom + '@fractalwagmi/solana-wallet-adapter@0.1.1(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5))(react-dom@18.2.0(react@18.2.0))(react@18.2.0)': + dependencies: + '@fractalwagmi/popup-connection': 1.1.1(react-dom@18.2.0(react@18.2.0))(react@18.2.0) + '@solana/wallet-adapter-base': 0.9.23(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5)) + bs58: 5.0.0 + transitivePeerDependencies: + - '@solana/web3.js' + - react + - react-dom + '@gql.tada/cli-utils@1.6.1(@0no-co/graphqlsp@1.12.13(graphql@16.9.0)(typescript@5.5.4))(graphql@16.9.0)(typescript@5.5.4)': dependencies: '@0no-co/graphqlsp': 1.12.13(graphql@16.9.0)(typescript@5.5.4) @@ -16852,6 +17060,53 @@ snapshots: - subscriptions-transport-ws - utf-8-validate + '@injectivelabs/sdk-ts@1.14.13(@types/react@18.2.67)(bufferutil@4.0.8)(react-dom@18.2.0(react@18.2.0))(react@18.2.0)(utf-8-validate@6.0.5)': + dependencies: + '@apollo/client': 3.11.4(@types/react@18.2.67)(graphql@16.9.0)(react-dom@18.2.0(react@18.2.0))(react@18.2.0) + '@cosmjs/amino': 0.32.4 + '@cosmjs/proto-signing': 0.32.3 + '@cosmjs/stargate': 0.32.4(bufferutil@4.0.8)(utf-8-validate@6.0.5) + '@ethersproject/bytes': 5.7.0 + '@injectivelabs/core-proto-ts': 0.0.21 + '@injectivelabs/dmm-proto-ts': 1.0.20 + '@injectivelabs/exceptions': 1.14.13(google-protobuf@3.21.4) + '@injectivelabs/grpc-web': 0.0.1(google-protobuf@3.21.4) + '@injectivelabs/grpc-web-node-http-transport': 0.0.2(@injectivelabs/grpc-web@0.0.1(google-protobuf@3.21.4)) + '@injectivelabs/grpc-web-react-native-transport': 0.0.2(@injectivelabs/grpc-web@0.0.1(google-protobuf@3.21.4)) + '@injectivelabs/indexer-proto-ts': 1.11.42 + '@injectivelabs/mito-proto-ts': 1.0.65 + '@injectivelabs/networks': 1.14.13(google-protobuf@3.21.4) + '@injectivelabs/test-utils': 1.14.13 + '@injectivelabs/ts-types': 1.14.13 + '@injectivelabs/utils': 1.14.13(google-protobuf@3.21.4) + '@metamask/eth-sig-util': 4.0.1 + '@noble/curves': 1.6.0 + axios: 1.7.9 + bech32: 2.0.0 + bip39: 3.1.0 + cosmjs-types: 0.9.0 + ethereumjs-util: 7.1.5 + ethers: 6.13.2(bufferutil@4.0.8)(utf-8-validate@6.0.5) + google-protobuf: 3.21.4 + graphql: 16.9.0 + http-status-codes: 2.3.0 + js-sha3: 0.8.0 + jscrypto: 1.0.3 + keccak256: 1.0.6 + link-module-alias: 1.2.0 + secp256k1: 4.0.3 + shx: 0.3.4 + snakecase-keys: 5.5.0 + transitivePeerDependencies: + - '@types/react' + - bufferutil + - debug + - graphql-ws + - react + - react-dom + - subscriptions-transport-ws + - utf-8-validate + '@injectivelabs/test-utils@1.14.13': dependencies: axios: 1.7.9 @@ -16883,7 +17138,7 @@ snapshots: - debug - google-protobuf - '@injectivelabs/wallet-ts@1.14.13(@babel/runtime@7.26.0)(@react-native-async-storage/async-storage@1.23.1(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@5.0.10)))(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10))(@types/react@18.2.67)(bs58@5.0.0)(bufferutil@4.0.8)(expo@51.0.29(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(utf-8-validate@5.0.10))(google-protobuf@3.21.4)(react-dom@18.2.0(react@18.2.0))(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@5.0.10))(react@18.2.0)(tslib@2.6.2)(utf-8-validate@5.0.10)': + '@injectivelabs/wallet-ts@1.14.13(@babel/runtime@7.26.0)(@react-native-async-storage/async-storage@1.23.1(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@5.0.10)))(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10))(@types/react@18.2.67)(bufferutil@4.0.8)(expo@51.0.29(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(utf-8-validate@5.0.10))(google-protobuf@3.21.4)(react-dom@18.2.0(react@18.2.0))(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@5.0.10))(react@18.2.0)(tslib@2.6.2)(utf-8-validate@5.0.10)': dependencies: '@cosmjs/launchpad': 0.27.1 '@cosmjs/proto-signing': 0.32.2 @@ -16904,7 +17159,7 @@ snapshots: '@ledgerhq/hw-transport-webhid': 6.28.4 '@ledgerhq/hw-transport-webusb': 6.28.4 '@metamask/eth-sig-util': 4.0.1 - '@solana/wallet-adapter-wallets': 0.19.30(@babel/runtime@7.26.0)(@react-native-async-storage/async-storage@1.23.1(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@5.0.10)))(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10))(bs58@5.0.0)(bufferutil@4.0.8)(expo@51.0.29(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(utf-8-validate@5.0.10))(react-dom@18.2.0(react@18.2.0))(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@5.0.10))(react@18.2.0)(tslib@2.6.2)(utf-8-validate@5.0.10) + '@solana/wallet-adapter-wallets': 0.19.30(@babel/runtime@7.26.0)(@react-native-async-storage/async-storage@1.23.1(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@5.0.10)))(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10))(bufferutil@4.0.8)(expo@51.0.29(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(utf-8-validate@5.0.10))(react-dom@18.2.0(react@18.2.0))(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@5.0.10))(react@18.2.0)(tslib@2.6.2)(utf-8-validate@5.0.10) '@toruslabs/torus-embed': 1.41.3(@babel/runtime@7.26.0) '@trezor/connect-web': 9.2.1(bufferutil@4.0.8)(expo@51.0.29(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(utf-8-validate@5.0.10))(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@5.0.10))(tslib@2.6.2)(utf-8-validate@5.0.10) '@walletconnect/ethereum-provider': 2.17.0(@react-native-async-storage/async-storage@1.23.1(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@5.0.10)))(@types/react@18.2.67)(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@5.0.10) @@ -16952,26 +17207,95 @@ snapshots: - uWebSockets.js - utf-8-validate - '@isaacs/cliui@8.0.2': - dependencies: - string-width: 5.1.2 - string-width-cjs: string-width@4.2.3 - strip-ansi: 7.1.0 - strip-ansi-cjs: strip-ansi@6.0.1 - wrap-ansi: 8.1.0 - wrap-ansi-cjs: wrap-ansi@7.0.0 - - '@isaacs/ttlcache@1.4.1': {} - - '@jest/create-cache-key-function@29.7.0': - dependencies: - '@jest/types': 29.6.3 - - '@jest/environment@29.7.0': + '@injectivelabs/wallet-ts@1.14.13(@babel/runtime@7.26.0)(@react-native-async-storage/async-storage@1.23.1(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@6.0.5)))(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5))(@types/react@18.2.67)(bs58@5.0.0)(bufferutil@4.0.8)(expo@51.0.29(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(utf-8-validate@6.0.5))(google-protobuf@3.21.4)(react-dom@18.2.0(react@18.2.0))(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@6.0.5))(react@18.2.0)(tslib@2.6.2)(utf-8-validate@6.0.5)': dependencies: - '@jest/fake-timers': 29.7.0 - '@jest/types': 29.6.3 - '@types/node': 22.9.3 + '@cosmjs/launchpad': 0.27.1 + '@cosmjs/proto-signing': 0.32.2 + '@cosmjs/stargate': 0.32.4(bufferutil@4.0.8)(utf-8-validate@6.0.5) + '@cosmostation/extension-client': 0.1.15 + '@ethereumjs/common': 3.2.0 + '@ethereumjs/tx': 4.2.0 + '@injectivelabs/exceptions': 1.14.13(google-protobuf@3.21.4) + '@injectivelabs/networks': 1.14.13(google-protobuf@3.21.4) + '@injectivelabs/sdk-ts': 1.14.13(@types/react@18.2.67)(bufferutil@4.0.8)(react-dom@18.2.0(react@18.2.0))(react@18.2.0)(utf-8-validate@6.0.5) + '@injectivelabs/ts-types': 1.14.13 + '@injectivelabs/utils': 1.14.13(google-protobuf@3.21.4) + '@keplr-wallet/cosmos': 0.12.122 + '@keplr-wallet/types': 0.12.122 + '@ledgerhq/hw-app-cosmos': 6.30.2 + '@ledgerhq/hw-app-eth': 6.35.6(bufferutil@4.0.8)(utf-8-validate@6.0.5) + '@ledgerhq/hw-transport': 6.30.4 + '@ledgerhq/hw-transport-webhid': 6.28.4 + '@ledgerhq/hw-transport-webusb': 6.28.4 + '@metamask/eth-sig-util': 4.0.1 + '@solana/wallet-adapter-wallets': 0.19.30(@babel/runtime@7.26.0)(@react-native-async-storage/async-storage@1.23.1(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@6.0.5)))(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5))(bs58@5.0.0)(bufferutil@4.0.8)(expo@51.0.29(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(utf-8-validate@6.0.5))(react-dom@18.2.0(react@18.2.0))(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@6.0.5))(react@18.2.0)(tslib@2.6.2)(utf-8-validate@6.0.5) + '@toruslabs/torus-embed': 1.41.3(@babel/runtime@7.26.0) + '@trezor/connect-web': 9.2.1(bufferutil@4.0.8)(expo@51.0.29(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(utf-8-validate@6.0.5))(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@6.0.5))(tslib@2.6.2)(utf-8-validate@6.0.5) + '@walletconnect/ethereum-provider': 2.17.0(@react-native-async-storage/async-storage@1.23.1(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@6.0.5)))(@types/react@18.2.67)(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@6.0.5) + alchemy-sdk: 2.12.0(bufferutil@4.0.8)(utf-8-validate@6.0.5) + eip1193-provider: 1.0.1(bufferutil@4.0.8)(utf-8-validate@6.0.5) + eth-sig-util: 3.0.1 + ethereumjs-util: 7.1.5 + ethers: 6.13.2(bufferutil@4.0.8)(utf-8-validate@6.0.5) + hdkey: 2.1.0 + link-module-alias: 1.2.0 + long: 5.2.3 + shx: 0.3.4 + transitivePeerDependencies: + - '@azure/app-configuration' + - '@azure/cosmos' + - '@azure/data-tables' + - '@azure/identity' + - '@azure/keyvault-secrets' + - '@azure/storage-blob' + - '@babel/runtime' + - '@capacitor/preferences' + - '@netlify/blobs' + - '@planetscale/database' + - '@react-native-async-storage/async-storage' + - '@sentry/types' + - '@solana/web3.js' + - '@types/react' + - '@upstash/redis' + - '@vercel/kv' + - bs58 + - bufferutil + - debug + - encoding + - expo + - expo-localization + - google-protobuf + - graphql-ws + - ioredis + - react + - react-dom + - react-native + - subscriptions-transport-ws + - supports-color + - tslib + - uWebSockets.js + - utf-8-validate + + '@isaacs/cliui@8.0.2': + dependencies: + string-width: 5.1.2 + string-width-cjs: string-width@4.2.3 + strip-ansi: 7.1.0 + strip-ansi-cjs: strip-ansi@6.0.1 + wrap-ansi: 8.1.0 + wrap-ansi-cjs: wrap-ansi@7.0.0 + + '@isaacs/ttlcache@1.4.1': {} + + '@jest/create-cache-key-function@29.7.0': + dependencies: + '@jest/types': 29.6.3 + + '@jest/environment@29.7.0': + dependencies: + '@jest/fake-timers': 29.7.0 + '@jest/types': 29.6.3 + '@types/node': 22.9.3 jest-mock: 29.7.0 '@jest/fake-timers@29.7.0': @@ -17035,6 +17359,31 @@ snapshots: - uWebSockets.js - utf-8-validate + '@jnwng/walletconnect-solana@0.2.0(@react-native-async-storage/async-storage@1.23.1(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@6.0.5)))(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5))(bufferutil@4.0.8)(utf-8-validate@6.0.5)': + dependencies: + '@solana/web3.js': 1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5) + '@walletconnect/qrcode-modal': 1.8.0 + '@walletconnect/sign-client': 2.17.0(@react-native-async-storage/async-storage@1.23.1(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@6.0.5)))(bufferutil@4.0.8)(utf-8-validate@6.0.5) + '@walletconnect/utils': 2.17.0(@react-native-async-storage/async-storage@1.23.1(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@6.0.5))) + bs58: 5.0.0 + transitivePeerDependencies: + - '@azure/app-configuration' + - '@azure/cosmos' + - '@azure/data-tables' + - '@azure/identity' + - '@azure/keyvault-secrets' + - '@azure/storage-blob' + - '@capacitor/preferences' + - '@netlify/blobs' + - '@planetscale/database' + - '@react-native-async-storage/async-storage' + - '@upstash/redis' + - '@vercel/kv' + - bufferutil + - ioredis + - uWebSockets.js + - utf-8-validate + '@jridgewell/gen-mapping@0.3.5': dependencies: '@jridgewell/set-array': 1.2.1 @@ -17070,6 +17419,17 @@ snapshots: - debug - utf-8-validate + '@json-rpc-tools/provider@1.7.6(bufferutil@4.0.8)(utf-8-validate@6.0.5)': + dependencies: + '@json-rpc-tools/utils': 1.7.6 + axios: 0.21.3 + safe-json-utils: 1.1.1 + ws: 7.5.10(bufferutil@4.0.8)(utf-8-validate@6.0.5) + transitivePeerDependencies: + - bufferutil + - debug + - utf-8-validate + '@json-rpc-tools/types@1.7.6': dependencies: keyvaluestorage-interface: 1.0.0 @@ -17172,6 +17532,19 @@ snapshots: - encoding - utf-8-validate + '@keystonehq/sol-keyring@0.3.1(bufferutil@4.0.8)(utf-8-validate@6.0.5)': + dependencies: + '@keystonehq/bc-ur-registry': 0.5.5 + '@keystonehq/bc-ur-registry-sol': 0.3.1 + '@keystonehq/sdk': 0.13.1 + '@solana/web3.js': 1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5) + bs58: 5.0.0 + uuid: 8.3.2 + transitivePeerDependencies: + - bufferutil + - encoding + - utf-8-validate + '@ledgerhq/cryptoassets@11.4.1': dependencies: axios: 1.7.9 @@ -17228,6 +17601,18 @@ snapshots: - debug - utf-8-validate + '@ledgerhq/evm-tools@1.2.0(bufferutil@4.0.8)(utf-8-validate@6.0.5)': + dependencies: + '@ledgerhq/cryptoassets': 13.3.0 + '@ledgerhq/live-env': 2.2.0 + axios: 1.7.9 + crypto-js: 4.2.0 + ethers: 5.7.2(bufferutil@4.0.8)(utf-8-validate@6.0.5) + transitivePeerDependencies: + - bufferutil + - debug + - utf-8-validate + '@ledgerhq/hw-app-cosmos@6.30.2': dependencies: '@ledgerhq/errors': 6.18.0 @@ -17253,6 +17638,25 @@ snapshots: - debug - utf-8-validate + '@ledgerhq/hw-app-eth@6.35.6(bufferutil@4.0.8)(utf-8-validate@6.0.5)': + dependencies: + '@ethersproject/abi': 5.7.0 + '@ethersproject/rlp': 5.7.0 + '@ledgerhq/cryptoassets': 11.4.1 + '@ledgerhq/domain-service': 1.2.3 + '@ledgerhq/errors': 6.18.0 + '@ledgerhq/evm-tools': 1.2.0(bufferutil@4.0.8)(utf-8-validate@6.0.5) + '@ledgerhq/hw-transport': 6.31.2 + '@ledgerhq/hw-transport-mocker': 6.29.2 + '@ledgerhq/logs': 6.12.0 + '@ledgerhq/types-live': 6.50.0 + axios: 1.7.9 + bignumber.js: 9.1.2 + transitivePeerDependencies: + - bufferutil + - debug + - utf-8-validate + '@ledgerhq/hw-transport-mocker@6.29.2': dependencies: '@ledgerhq/hw-transport': 6.31.2 @@ -17516,14 +17920,14 @@ snapshots: transitivePeerDependencies: - supports-color - '@metamask/providers@10.2.1(@swc/core@1.4.8)': + '@metamask/providers@10.2.1(@swc/core@1.4.8)(esbuild@0.19.12)': dependencies: '@metamask/object-multiplex': 1.3.0 '@metamask/safe-event-emitter': 2.0.0 '@types/chrome': 0.0.136 detect-browser: 5.3.0 eth-rpc-errors: 4.0.3 - extension-port-stream: 2.1.1(@swc/core@1.4.8) + extension-port-stream: 2.1.1(@swc/core@1.4.8)(esbuild@0.19.12) fast-deep-equal: 2.0.1 is-stream: 2.0.1 json-rpc-engine: 6.1.0 @@ -17608,7 +18012,7 @@ snapshots: transitivePeerDependencies: - supports-color - '@metamask/sdk-install-modal-web@0.14.1(@types/react@18.2.67)(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@5.0.10))': + '@metamask/sdk-install-modal-web@0.14.1(@types/react@18.2.67)(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@6.0.5))': dependencies: '@emotion/react': 11.13.5(@types/react@18.2.67)(react@18.2.0) '@emotion/styled': 11.13.5(@emotion/react@11.13.5(@types/react@18.2.67)(react@18.2.0))(@types/react@18.2.67)(react@18.2.0) @@ -17616,7 +18020,7 @@ snapshots: qr-code-styling: 1.8.4 react: 18.2.0 react-dom: 18.2.0(react@18.2.0) - react-i18next: 13.5.0(i18next@22.5.1)(react-dom@18.2.0(react@18.2.0))(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@5.0.10))(react@18.2.0) + react-i18next: 13.5.0(i18next@22.5.1)(react-dom@18.2.0(react@18.2.0))(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@6.0.5))(react@18.2.0) transitivePeerDependencies: - '@types/react' - react-native @@ -17626,36 +18030,36 @@ snapshots: dependencies: '@paulmillr/qr': 0.2.1 - '@metamask/sdk@0.14.3(@swc/core@1.4.8)(@types/react@18.2.67)(bufferutil@4.0.8)(react-dom@18.2.0(react@18.2.0))(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@5.0.10))(react@18.2.0)(rollup@4.13.0)(utf-8-validate@5.0.10)': + '@metamask/sdk@0.14.3(@swc/core@1.4.8)(@types/react@18.2.67)(bufferutil@4.0.8)(esbuild@0.19.12)(react-dom@18.2.0(react@18.2.0))(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@6.0.5))(react@18.2.0)(rollup@4.13.0)(utf-8-validate@6.0.5)': dependencies: '@metamask/onboarding': 1.0.1 '@metamask/post-message-stream': 6.2.0 - '@metamask/providers': 10.2.1(@swc/core@1.4.8) + '@metamask/providers': 10.2.1(@swc/core@1.4.8)(esbuild@0.19.12) '@metamask/sdk-communication-layer': 0.14.3 - '@metamask/sdk-install-modal-web': 0.14.1(@types/react@18.2.67)(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@5.0.10)) - '@react-native-async-storage/async-storage': 1.23.1(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@5.0.10)) + '@metamask/sdk-install-modal-web': 0.14.1(@types/react@18.2.67)(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@6.0.5)) + '@react-native-async-storage/async-storage': 1.23.1(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@6.0.5)) '@types/dom-screen-wake-lock': 1.0.3 bowser: 2.11.0 cross-fetch: 4.0.0 eciesjs: 0.3.21 eth-rpc-errors: 4.0.3 eventemitter2: 6.4.9 - extension-port-stream: 2.1.1(@swc/core@1.4.8) + extension-port-stream: 2.1.1(@swc/core@1.4.8)(esbuild@0.19.12) i18next: 22.5.1 i18next-browser-languagedetector: 7.2.1 obj-multiplex: 1.0.0 pump: 3.0.0 qrcode-terminal-nooctal: 0.12.1 - react-i18next: 13.5.0(i18next@22.5.1)(react-dom@18.2.0(react@18.2.0))(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@5.0.10))(react@18.2.0) - react-native-webview: 11.26.1(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@5.0.10))(react@18.2.0) + react-i18next: 13.5.0(i18next@22.5.1)(react-dom@18.2.0(react@18.2.0))(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@6.0.5))(react@18.2.0) + react-native-webview: 11.26.1(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@6.0.5))(react@18.2.0) readable-stream: 2.3.8 rollup-plugin-visualizer: 5.12.0(rollup@4.13.0) - socket.io-client: 4.7.5(bufferutil@4.0.8)(utf-8-validate@5.0.10) + socket.io-client: 4.7.5(bufferutil@4.0.8)(utf-8-validate@6.0.5) util: 0.12.5 uuid: 8.3.2 optionalDependencies: react: 18.2.0 - react-native: 0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@5.0.10) + react-native: 0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@6.0.5) transitivePeerDependencies: - '@swc/core' - '@types/react' @@ -17798,6 +18202,10 @@ snapshots: dependencies: bs58: 6.0.0 + '@mysten/bcs@1.2.0': + dependencies: + bs58: 6.0.0 + '@mysten/dapp-kit@0.14.18(@tanstack/react-query@5.29.2(react@18.2.0))(@types/react-dom@18.2.22)(@types/react@18.2.67)(babel-plugin-macros@3.1.0)(immer@10.1.1)(react-dom@18.2.0(react@18.2.0))(react@18.2.0)(typescript@5.5.4)': dependencies: '@mysten/sui': 1.8.0(typescript@5.5.4) @@ -17863,6 +18271,27 @@ snapshots: - '@gql.tada/vue-support' - typescript + '@mysten/sui@1.18.0(typescript@5.5.4)': + dependencies: + '@graphql-typed-document-node/core': 3.2.0(graphql@16.9.0) + '@mysten/bcs': 1.2.0 + '@noble/curves': 1.6.0 + '@noble/hashes': 1.5.0 + '@scure/bip32': 1.5.0 + '@scure/bip39': 1.4.0 + '@simplewebauthn/typescript-types': 7.4.0 + '@suchipi/femver': 1.0.0 + bech32: 2.0.0 + gql.tada: 1.8.6(graphql@16.9.0)(typescript@5.5.4) + graphql: 16.9.0 + jose: 5.9.6 + poseidon-lite: 0.2.1 + valibot: 0.36.0 + transitivePeerDependencies: + - '@gql.tada/svelte-support' + - '@gql.tada/vue-support' + - typescript + '@mysten/sui@1.8.0(typescript@5.5.4)': dependencies: '@graphql-typed-document-node/core': 3.2.0(graphql@16.9.0) @@ -17891,6 +18320,15 @@ snapshots: - '@gql.tada/vue-support' - typescript + '@mysten/wallet-standard@0.13.20(typescript@5.5.4)': + dependencies: + '@mysten/sui': 1.18.0(typescript@5.5.4) + '@wallet-standard/core': 1.0.3 + transitivePeerDependencies: + - '@gql.tada/svelte-support' + - '@gql.tada/vue-support' + - typescript + '@mysten/wallet-standard@0.13.3(typescript@5.5.4)': dependencies: '@mysten/sui': 1.8.0(typescript@5.5.4) @@ -18054,10 +18492,15 @@ snapshots: crypto-js: 4.2.0 uuidv4: 6.2.13 - '@particle-network/solana-wallet@1.3.2(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10))(bs58@5.0.0)': + '@particle-network/solana-wallet@1.3.2(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10))': dependencies: '@particle-network/auth': 1.3.1 '@solana/web3.js': 1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10) + + '@particle-network/solana-wallet@1.3.2(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5))(bs58@5.0.0)': + dependencies: + '@particle-network/auth': 1.3.1 + '@solana/web3.js': 1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5) bs58: 5.0.0 '@paulmillr/qr@0.2.1': {} @@ -18077,6 +18520,12 @@ snapshots: bs58: 4.0.1 eventemitter3: 4.0.7 + '@project-serum/sol-wallet-adapter@0.2.6(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5))': + dependencies: + '@solana/web3.js': 1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5) + bs58: 4.0.1 + eventemitter3: 4.0.7 + '@protobufjs/aspromise@1.1.2': {} '@protobufjs/base64@1.1.2': {} @@ -18800,6 +19249,12 @@ snapshots: dependencies: merge-options: 3.0.4 react-native: 0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@5.0.10) + optional: true + + '@react-native-async-storage/async-storage@1.23.1(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@6.0.5))': + dependencies: + merge-options: 3.0.4 + react-native: 0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@6.0.5) '@react-native-community/cli-clean@12.3.6': dependencies: @@ -19229,6 +19684,27 @@ snapshots: - supports-color - utf-8-validate + '@react-native/dev-middleware@0.74.85(bufferutil@4.0.8)(utf-8-validate@6.0.5)': + dependencies: + '@isaacs/ttlcache': 1.4.1 + '@react-native/debugger-frontend': 0.74.85 + '@rnx-kit/chromium-edge-launcher': 1.0.0 + chrome-launcher: 0.15.2 + connect: 3.7.0 + debug: 2.6.9 + node-fetch: 2.7.0 + nullthrows: 1.1.1 + open: 7.4.2 + selfsigned: 2.4.1 + serve-static: 1.15.0 + temp-dir: 2.0.0 + ws: 6.2.2(bufferutil@4.0.8)(utf-8-validate@6.0.5) + transitivePeerDependencies: + - bufferutil + - encoding + - supports-color + - utf-8-validate + '@react-native/gradle-plugin@0.73.4': {} '@react-native/js-polyfills@0.73.1': {} @@ -19353,9 +19829,9 @@ snapshots: '@rollup/rollup-win32-x64-msvc@4.13.0': optional: true - '@safe-global/safe-apps-provider@0.18.1(bufferutil@4.0.8)(typescript@5.5.4)(utf-8-validate@5.0.10)(zod@3.23.8)': + '@safe-global/safe-apps-provider@0.18.1(bufferutil@4.0.8)(typescript@5.5.4)(utf-8-validate@6.0.5)(zod@3.23.8)': dependencies: - '@safe-global/safe-apps-sdk': 8.1.0(bufferutil@4.0.8)(typescript@5.5.4)(utf-8-validate@5.0.10)(zod@3.23.8) + '@safe-global/safe-apps-sdk': 8.1.0(bufferutil@4.0.8)(typescript@5.5.4)(utf-8-validate@6.0.5)(zod@3.23.8) events: 3.3.0 transitivePeerDependencies: - bufferutil @@ -19373,10 +19849,10 @@ snapshots: - utf-8-validate - zod - '@safe-global/safe-apps-sdk@8.1.0(bufferutil@4.0.8)(typescript@5.5.4)(utf-8-validate@5.0.10)(zod@3.23.8)': + '@safe-global/safe-apps-sdk@8.1.0(bufferutil@4.0.8)(typescript@5.5.4)(utf-8-validate@6.0.5)(zod@3.23.8)': dependencies: '@safe-global/safe-gateway-typescript-sdk': 3.20.0 - viem: 1.21.4(bufferutil@4.0.8)(typescript@5.5.4)(utf-8-validate@5.0.10)(zod@3.23.8) + viem: 1.21.4(bufferutil@4.0.8)(typescript@5.5.4)(utf-8-validate@6.0.5)(zod@3.23.8) transitivePeerDependencies: - bufferutil - typescript @@ -19443,6 +19919,8 @@ snapshots: '@sideway/pinpoint@2.0.0': {} + '@simplewebauthn/typescript-types@7.4.0': {} + '@sinclair/typebox@0.27.8': {} '@sinclair/typebox@0.31.28': {} @@ -19465,10 +19943,10 @@ snapshots: '@socket.io/component-emitter@3.1.1': {} - '@solana-mobile/mobile-wallet-adapter-protocol-web3js@2.1.4(@solana/wallet-adapter-base@0.9.23(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10)))(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10))(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@5.0.10))(react@18.2.0)': + '@solana-mobile/mobile-wallet-adapter-protocol-web3js@2.1.4(@solana/wallet-adapter-base@0.9.23(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5)))(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5))(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@6.0.5))(react@18.2.0)': dependencies: - '@solana-mobile/mobile-wallet-adapter-protocol': 2.1.4(@solana/wallet-adapter-base@0.9.23(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10)))(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10))(bs58@5.0.0)(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@5.0.10))(react@18.2.0) - '@solana/web3.js': 1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10) + '@solana-mobile/mobile-wallet-adapter-protocol': 2.1.4(@solana/wallet-adapter-base@0.9.23(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5)))(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5))(bs58@5.0.0)(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@6.0.5))(react@18.2.0) + '@solana/web3.js': 1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5) bs58: 5.0.0 js-base64: 3.7.7 transitivePeerDependencies: @@ -19476,37 +19954,37 @@ snapshots: - react - react-native - '@solana-mobile/mobile-wallet-adapter-protocol@2.1.4(@solana/wallet-adapter-base@0.9.23(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10)))(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10))(bs58@5.0.0)(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@5.0.10))(react@18.2.0)': + '@solana-mobile/mobile-wallet-adapter-protocol@2.1.4(@solana/wallet-adapter-base@0.9.23(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5)))(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5))(bs58@5.0.0)(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@6.0.5))(react@18.2.0)': dependencies: - '@solana/wallet-standard': 1.1.2(@solana/wallet-adapter-base@0.9.23(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10)))(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10))(bs58@5.0.0)(react@18.2.0) + '@solana/wallet-standard': 1.1.2(@solana/wallet-adapter-base@0.9.23(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5)))(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5))(bs58@5.0.0)(react@18.2.0) '@solana/wallet-standard-util': 1.1.1 - '@solana/web3.js': 1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10) + '@solana/web3.js': 1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5) '@wallet-standard/core': 1.0.3 js-base64: 3.7.7 - react-native: 0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@5.0.10) + react-native: 0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@6.0.5) transitivePeerDependencies: - '@solana/wallet-adapter-base' - bs58 - react - '@solana-mobile/wallet-adapter-mobile@2.1.4(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10))(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@5.0.10))(react@18.2.0)': + '@solana-mobile/wallet-adapter-mobile@2.1.4(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5))(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@6.0.5))(react@18.2.0)': dependencies: - '@solana-mobile/mobile-wallet-adapter-protocol-web3js': 2.1.4(@solana/wallet-adapter-base@0.9.23(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10)))(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10))(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@5.0.10))(react@18.2.0) - '@solana/wallet-adapter-base': 0.9.23(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10)) + '@solana-mobile/mobile-wallet-adapter-protocol-web3js': 2.1.4(@solana/wallet-adapter-base@0.9.23(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5)))(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5))(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@6.0.5))(react@18.2.0) + '@solana/wallet-adapter-base': 0.9.23(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5)) '@solana/wallet-standard-features': 1.2.0 - '@solana/web3.js': 1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10) + '@solana/web3.js': 1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5) js-base64: 3.7.7 qrcode: 1.5.4 optionalDependencies: - '@react-native-async-storage/async-storage': 1.23.1(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@5.0.10)) + '@react-native-async-storage/async-storage': 1.23.1(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@6.0.5)) transitivePeerDependencies: - react - react-native - '@solana/buffer-layout-utils@0.2.0(bufferutil@4.0.8)(utf-8-validate@5.0.10)': + '@solana/buffer-layout-utils@0.2.0(bufferutil@4.0.8)(utf-8-validate@6.0.5)': dependencies: '@solana/buffer-layout': 4.0.1 - '@solana/web3.js': 1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10) + '@solana/web3.js': 1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5) bigint-buffer: 1.1.5 bignumber.js: 9.0.1 transitivePeerDependencies: @@ -19572,29 +20050,29 @@ snapshots: transitivePeerDependencies: - fastestsmallesttextencoderdecoder - '@solana/spl-token-group@0.0.7(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10))(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.5.4)': + '@solana/spl-token-group@0.0.7(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5))(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.5.4)': dependencies: '@solana/codecs': 2.0.0-rc.1(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.5.4) - '@solana/web3.js': 1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10) + '@solana/web3.js': 1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5) transitivePeerDependencies: - fastestsmallesttextencoderdecoder - typescript - '@solana/spl-token-metadata@0.1.6(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10))(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.5.4)': + '@solana/spl-token-metadata@0.1.6(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5))(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.5.4)': dependencies: '@solana/codecs': 2.0.0-rc.1(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.5.4) - '@solana/web3.js': 1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10) + '@solana/web3.js': 1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5) transitivePeerDependencies: - fastestsmallesttextencoderdecoder - typescript - '@solana/spl-token@0.4.9(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10))(bufferutil@4.0.8)(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.5.4)(utf-8-validate@5.0.10)': + '@solana/spl-token@0.4.9(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5))(bufferutil@4.0.8)(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.5.4)(utf-8-validate@6.0.5)': dependencies: '@solana/buffer-layout': 4.0.1 - '@solana/buffer-layout-utils': 0.2.0(bufferutil@4.0.8)(utf-8-validate@5.0.10) - '@solana/spl-token-group': 0.0.7(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10))(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.5.4) - '@solana/spl-token-metadata': 0.1.6(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10))(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.5.4) - '@solana/web3.js': 1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10) + '@solana/buffer-layout-utils': 0.2.0(bufferutil@4.0.8)(utf-8-validate@6.0.5) + '@solana/spl-token-group': 0.0.7(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5))(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.5.4) + '@solana/spl-token-metadata': 0.1.6(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5))(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.5.4) + '@solana/web3.js': 1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5) buffer: 6.0.3 transitivePeerDependencies: - bufferutil @@ -19608,11 +20086,21 @@ snapshots: '@solana/wallet-adapter-base': 0.9.23(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10)) '@solana/web3.js': 1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10) + '@solana/wallet-adapter-alpha@0.1.10(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5))': + dependencies: + '@solana/wallet-adapter-base': 0.9.23(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5)) + '@solana/web3.js': 1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5) + '@solana/wallet-adapter-avana@0.1.13(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10))': dependencies: '@solana/wallet-adapter-base': 0.9.23(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10)) '@solana/web3.js': 1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10) + '@solana/wallet-adapter-avana@0.1.13(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5))': + dependencies: + '@solana/wallet-adapter-base': 0.9.23(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5)) + '@solana/web3.js': 1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5) + '@solana/wallet-adapter-base@0.9.23(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10))': dependencies: '@solana/wallet-standard-features': 1.2.0 @@ -19621,37 +20109,76 @@ snapshots: '@wallet-standard/features': 1.0.3 eventemitter3: 4.0.7 + '@solana/wallet-adapter-base@0.9.23(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5))': + dependencies: + '@solana/wallet-standard-features': 1.2.0 + '@solana/web3.js': 1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5) + '@wallet-standard/base': 1.0.1 + '@wallet-standard/features': 1.0.3 + eventemitter3: 4.0.7 + '@solana/wallet-adapter-bitkeep@0.3.20(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10))': dependencies: '@solana/wallet-adapter-base': 0.9.23(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10)) '@solana/web3.js': 1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10) + '@solana/wallet-adapter-bitkeep@0.3.20(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5))': + dependencies: + '@solana/wallet-adapter-base': 0.9.23(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5)) + '@solana/web3.js': 1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5) + '@solana/wallet-adapter-bitpie@0.5.18(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10))': dependencies: '@solana/wallet-adapter-base': 0.9.23(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10)) '@solana/web3.js': 1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10) + '@solana/wallet-adapter-bitpie@0.5.18(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5))': + dependencies: + '@solana/wallet-adapter-base': 0.9.23(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5)) + '@solana/web3.js': 1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5) + '@solana/wallet-adapter-clover@0.4.19(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10))': dependencies: '@solana/wallet-adapter-base': 0.9.23(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10)) '@solana/web3.js': 1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10) + '@solana/wallet-adapter-clover@0.4.19(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5))': + dependencies: + '@solana/wallet-adapter-base': 0.9.23(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5)) + '@solana/web3.js': 1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5) + '@solana/wallet-adapter-coin98@0.5.20(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10))': dependencies: '@solana/wallet-adapter-base': 0.9.23(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10)) '@solana/web3.js': 1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10) bs58: 4.0.1 + '@solana/wallet-adapter-coin98@0.5.20(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5))': + dependencies: + '@solana/wallet-adapter-base': 0.9.23(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5)) + '@solana/web3.js': 1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5) + bs58: 4.0.1 + '@solana/wallet-adapter-coinbase@0.1.19(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10))': dependencies: '@solana/wallet-adapter-base': 0.9.23(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10)) '@solana/web3.js': 1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10) + '@solana/wallet-adapter-coinbase@0.1.19(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5))': + dependencies: + '@solana/wallet-adapter-base': 0.9.23(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5)) + '@solana/web3.js': 1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5) + '@solana/wallet-adapter-coinhub@0.3.18(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10))': dependencies: '@solana/wallet-adapter-base': 0.9.23(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10)) '@solana/web3.js': 1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10) + '@solana/wallet-adapter-coinhub@0.3.18(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5))': + dependencies: + '@solana/wallet-adapter-base': 0.9.23(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5)) + '@solana/web3.js': 1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5) + '@solana/wallet-adapter-fractal@0.1.8(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10))(react-dom@18.2.0(react@18.2.0))(react@18.2.0)': dependencies: '@fractalwagmi/solana-wallet-adapter': 0.1.1(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10))(react-dom@18.2.0(react@18.2.0))(react@18.2.0) @@ -19661,16 +20188,35 @@ snapshots: - react - react-dom + '@solana/wallet-adapter-fractal@0.1.8(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5))(react-dom@18.2.0(react@18.2.0))(react@18.2.0)': + dependencies: + '@fractalwagmi/solana-wallet-adapter': 0.1.1(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5))(react-dom@18.2.0(react@18.2.0))(react@18.2.0) + '@solana/wallet-adapter-base': 0.9.23(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5)) + '@solana/web3.js': 1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5) + transitivePeerDependencies: + - react + - react-dom + '@solana/wallet-adapter-huobi@0.1.15(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10))': dependencies: '@solana/wallet-adapter-base': 0.9.23(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10)) '@solana/web3.js': 1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10) + '@solana/wallet-adapter-huobi@0.1.15(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5))': + dependencies: + '@solana/wallet-adapter-base': 0.9.23(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5)) + '@solana/web3.js': 1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5) + '@solana/wallet-adapter-hyperpay@0.1.14(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10))': dependencies: '@solana/wallet-adapter-base': 0.9.23(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10)) '@solana/web3.js': 1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10) + '@solana/wallet-adapter-hyperpay@0.1.14(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5))': + dependencies: + '@solana/wallet-adapter-base': 0.9.23(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5)) + '@solana/web3.js': 1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5) + '@solana/wallet-adapter-keystone@0.1.15(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10))(bufferutil@4.0.8)(utf-8-validate@5.0.10)': dependencies: '@keystonehq/sol-keyring': 0.3.1(bufferutil@4.0.8)(utf-8-validate@5.0.10) @@ -19681,11 +20227,26 @@ snapshots: - encoding - utf-8-validate + '@solana/wallet-adapter-keystone@0.1.15(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5))(bufferutil@4.0.8)(utf-8-validate@6.0.5)': + dependencies: + '@keystonehq/sol-keyring': 0.3.1(bufferutil@4.0.8)(utf-8-validate@6.0.5) + '@solana/wallet-adapter-base': 0.9.23(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5)) + '@solana/web3.js': 1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5) + transitivePeerDependencies: + - bufferutil + - encoding + - utf-8-validate + '@solana/wallet-adapter-krystal@0.1.12(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10))': dependencies: '@solana/wallet-adapter-base': 0.9.23(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10)) '@solana/web3.js': 1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10) + '@solana/wallet-adapter-krystal@0.1.12(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5))': + dependencies: + '@solana/wallet-adapter-base': 0.9.23(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5)) + '@solana/web3.js': 1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5) + '@solana/wallet-adapter-ledger@0.9.25(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10))': dependencies: '@ledgerhq/devices': 6.27.1 @@ -19695,50 +20256,97 @@ snapshots: '@solana/web3.js': 1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10) buffer: 6.0.3 + '@solana/wallet-adapter-ledger@0.9.25(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5))': + dependencies: + '@ledgerhq/devices': 6.27.1 + '@ledgerhq/hw-transport': 6.27.1 + '@ledgerhq/hw-transport-webhid': 6.27.1 + '@solana/wallet-adapter-base': 0.9.23(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5)) + '@solana/web3.js': 1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5) + buffer: 6.0.3 + '@solana/wallet-adapter-mathwallet@0.9.18(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10))': dependencies: '@solana/wallet-adapter-base': 0.9.23(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10)) '@solana/web3.js': 1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10) + '@solana/wallet-adapter-mathwallet@0.9.18(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5))': + dependencies: + '@solana/wallet-adapter-base': 0.9.23(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5)) + '@solana/web3.js': 1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5) + '@solana/wallet-adapter-neko@0.2.12(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10))': dependencies: '@solana/wallet-adapter-base': 0.9.23(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10)) '@solana/web3.js': 1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10) + '@solana/wallet-adapter-neko@0.2.12(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5))': + dependencies: + '@solana/wallet-adapter-base': 0.9.23(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5)) + '@solana/web3.js': 1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5) + '@solana/wallet-adapter-nightly@0.1.16(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10))': dependencies: '@solana/wallet-adapter-base': 0.9.23(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10)) '@solana/web3.js': 1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10) + '@solana/wallet-adapter-nightly@0.1.16(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5))': + dependencies: + '@solana/wallet-adapter-base': 0.9.23(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5)) + '@solana/web3.js': 1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5) + '@solana/wallet-adapter-nufi@0.1.17(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10))': dependencies: '@solana/wallet-adapter-base': 0.9.23(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10)) '@solana/web3.js': 1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10) + '@solana/wallet-adapter-nufi@0.1.17(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5))': + dependencies: + '@solana/wallet-adapter-base': 0.9.23(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5)) + '@solana/web3.js': 1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5) + '@solana/wallet-adapter-onto@0.1.7(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10))': dependencies: '@solana/wallet-adapter-base': 0.9.23(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10)) '@solana/web3.js': 1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10) - '@solana/wallet-adapter-particle@0.1.12(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10))(bs58@5.0.0)': + '@solana/wallet-adapter-onto@0.1.7(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5))': + dependencies: + '@solana/wallet-adapter-base': 0.9.23(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5)) + '@solana/web3.js': 1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5) + + '@solana/wallet-adapter-particle@0.1.12(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10))': dependencies: - '@particle-network/solana-wallet': 1.3.2(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10))(bs58@5.0.0) + '@particle-network/solana-wallet': 1.3.2(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10)) '@solana/wallet-adapter-base': 0.9.23(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10)) '@solana/web3.js': 1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10) transitivePeerDependencies: - bs58 + '@solana/wallet-adapter-particle@0.1.12(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5))(bs58@5.0.0)': + dependencies: + '@particle-network/solana-wallet': 1.3.2(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5))(bs58@5.0.0) + '@solana/wallet-adapter-base': 0.9.23(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5)) + '@solana/web3.js': 1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5) + transitivePeerDependencies: + - bs58 + '@solana/wallet-adapter-phantom@0.9.24(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10))': dependencies: '@solana/wallet-adapter-base': 0.9.23(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10)) '@solana/web3.js': 1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10) - '@solana/wallet-adapter-react@0.15.35(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10))(bs58@5.0.0)(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@5.0.10))(react@18.2.0)': + '@solana/wallet-adapter-phantom@0.9.24(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5))': dependencies: - '@solana-mobile/wallet-adapter-mobile': 2.1.4(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10))(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@5.0.10))(react@18.2.0) - '@solana/wallet-adapter-base': 0.9.23(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10)) - '@solana/wallet-standard-wallet-adapter-react': 1.1.2(@solana/wallet-adapter-base@0.9.23(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10)))(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10))(bs58@5.0.0)(react@18.2.0) - '@solana/web3.js': 1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10) + '@solana/wallet-adapter-base': 0.9.23(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5)) + '@solana/web3.js': 1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5) + + '@solana/wallet-adapter-react@0.15.35(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5))(bs58@5.0.0)(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@6.0.5))(react@18.2.0)': + dependencies: + '@solana-mobile/wallet-adapter-mobile': 2.1.4(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5))(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@6.0.5))(react@18.2.0) + '@solana/wallet-adapter-base': 0.9.23(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5)) + '@solana/wallet-standard-wallet-adapter-react': 1.1.2(@solana/wallet-adapter-base@0.9.23(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5)))(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5))(bs58@5.0.0)(react@18.2.0) + '@solana/web3.js': 1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5) react: 18.2.0 transitivePeerDependencies: - bs58 @@ -19749,22 +20357,43 @@ snapshots: '@solana/wallet-adapter-base': 0.9.23(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10)) '@solana/web3.js': 1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10) + '@solana/wallet-adapter-safepal@0.5.18(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5))': + dependencies: + '@solana/wallet-adapter-base': 0.9.23(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5)) + '@solana/web3.js': 1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5) + '@solana/wallet-adapter-saifu@0.1.15(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10))': dependencies: '@solana/wallet-adapter-base': 0.9.23(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10)) '@solana/web3.js': 1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10) + '@solana/wallet-adapter-saifu@0.1.15(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5))': + dependencies: + '@solana/wallet-adapter-base': 0.9.23(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5)) + '@solana/web3.js': 1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5) + '@solana/wallet-adapter-salmon@0.1.14(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10))': dependencies: '@solana/wallet-adapter-base': 0.9.23(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10)) '@solana/web3.js': 1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10) salmon-adapter-sdk: 1.1.1(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10)) + '@solana/wallet-adapter-salmon@0.1.14(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5))': + dependencies: + '@solana/wallet-adapter-base': 0.9.23(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5)) + '@solana/web3.js': 1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5) + salmon-adapter-sdk: 1.1.1(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5)) + '@solana/wallet-adapter-sky@0.1.15(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10))': dependencies: '@solana/wallet-adapter-base': 0.9.23(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10)) '@solana/web3.js': 1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10) + '@solana/wallet-adapter-sky@0.1.15(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5))': + dependencies: + '@solana/wallet-adapter-base': 0.9.23(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5)) + '@solana/web3.js': 1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5) + '@solana/wallet-adapter-solflare@0.6.28(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10))': dependencies: '@solana/wallet-adapter-base': 0.9.23(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10)) @@ -19774,26 +20403,55 @@ snapshots: '@solflare-wallet/sdk': 1.4.2(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10)) '@wallet-standard/wallet': 1.0.1 + '@solana/wallet-adapter-solflare@0.6.28(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5))': + dependencies: + '@solana/wallet-adapter-base': 0.9.23(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5)) + '@solana/wallet-standard-chains': 1.1.0 + '@solana/web3.js': 1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5) + '@solflare-wallet/metamask-sdk': 1.0.3(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5)) + '@solflare-wallet/sdk': 1.4.2(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5)) + '@wallet-standard/wallet': 1.0.1 + '@solana/wallet-adapter-solong@0.9.18(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10))': dependencies: '@solana/wallet-adapter-base': 0.9.23(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10)) '@solana/web3.js': 1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10) + '@solana/wallet-adapter-solong@0.9.18(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5))': + dependencies: + '@solana/wallet-adapter-base': 0.9.23(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5)) + '@solana/web3.js': 1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5) + '@solana/wallet-adapter-spot@0.1.15(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10))': dependencies: '@solana/wallet-adapter-base': 0.9.23(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10)) '@solana/web3.js': 1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10) + '@solana/wallet-adapter-spot@0.1.15(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5))': + dependencies: + '@solana/wallet-adapter-base': 0.9.23(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5)) + '@solana/web3.js': 1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5) + '@solana/wallet-adapter-tokenary@0.1.12(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10))': dependencies: '@solana/wallet-adapter-base': 0.9.23(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10)) '@solana/web3.js': 1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10) + '@solana/wallet-adapter-tokenary@0.1.12(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5))': + dependencies: + '@solana/wallet-adapter-base': 0.9.23(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5)) + '@solana/web3.js': 1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5) + '@solana/wallet-adapter-tokenpocket@0.4.19(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10))': dependencies: '@solana/wallet-adapter-base': 0.9.23(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10)) '@solana/web3.js': 1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10) + '@solana/wallet-adapter-tokenpocket@0.4.19(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5))': + dependencies: + '@solana/wallet-adapter-base': 0.9.23(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5)) + '@solana/web3.js': 1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5) + '@solana/wallet-adapter-torus@0.11.28(@babel/runtime@7.26.0)(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10))(bufferutil@4.0.8)(utf-8-validate@5.0.10)': dependencies: '@solana/wallet-adapter-base': 0.9.23(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10)) @@ -19811,6 +20469,23 @@ snapshots: - supports-color - utf-8-validate + '@solana/wallet-adapter-torus@0.11.28(@babel/runtime@7.26.0)(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5))(bufferutil@4.0.8)(utf-8-validate@6.0.5)': + dependencies: + '@solana/wallet-adapter-base': 0.9.23(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5)) + '@solana/web3.js': 1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5) + '@toruslabs/solana-embed': 0.3.4(@babel/runtime@7.26.0)(bufferutil@4.0.8)(utf-8-validate@6.0.5) + assert: 2.1.0 + crypto-browserify: 3.12.0 + process: 0.11.10 + stream-browserify: 3.0.0 + transitivePeerDependencies: + - '@babel/runtime' + - '@sentry/types' + - bufferutil + - encoding + - supports-color + - utf-8-validate + '@solana/wallet-adapter-trezor@0.1.2(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10))(bufferutil@4.0.8)(expo@51.0.29(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(utf-8-validate@5.0.10))(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@5.0.10))(tslib@2.6.2)(utf-8-validate@5.0.10)': dependencies: '@solana/wallet-adapter-base': 0.9.23(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10)) @@ -19827,11 +20502,32 @@ snapshots: - tslib - utf-8-validate + '@solana/wallet-adapter-trezor@0.1.2(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5))(bufferutil@4.0.8)(expo@51.0.29(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(utf-8-validate@6.0.5))(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@6.0.5))(tslib@2.6.2)(utf-8-validate@6.0.5)': + dependencies: + '@solana/wallet-adapter-base': 0.9.23(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5)) + '@solana/web3.js': 1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5) + '@trezor/connect-web': 9.2.1(bufferutil@4.0.8)(expo@51.0.29(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(utf-8-validate@6.0.5))(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@6.0.5))(tslib@2.6.2)(utf-8-validate@6.0.5) + buffer: 6.0.3 + transitivePeerDependencies: + - bufferutil + - encoding + - expo + - expo-localization + - react-native + - supports-color + - tslib + - utf-8-validate + '@solana/wallet-adapter-trust@0.1.13(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10))': dependencies: '@solana/wallet-adapter-base': 0.9.23(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10)) '@solana/web3.js': 1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10) + '@solana/wallet-adapter-trust@0.1.13(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5))': + dependencies: + '@solana/wallet-adapter-base': 0.9.23(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5)) + '@solana/web3.js': 1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5) + '@solana/wallet-adapter-unsafe-burner@0.1.7(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10))': dependencies: '@noble/curves': 1.6.0 @@ -19840,6 +20536,14 @@ snapshots: '@solana/wallet-standard-util': 1.1.1 '@solana/web3.js': 1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10) + '@solana/wallet-adapter-unsafe-burner@0.1.7(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5))': + dependencies: + '@noble/curves': 1.6.0 + '@solana/wallet-adapter-base': 0.9.23(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5)) + '@solana/wallet-standard-features': 1.2.0 + '@solana/wallet-standard-util': 1.1.1 + '@solana/web3.js': 1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5) + '@solana/wallet-adapter-walletconnect@0.1.16(@react-native-async-storage/async-storage@1.23.1(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@5.0.10)))(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10))(bufferutil@4.0.8)(utf-8-validate@5.0.10)': dependencies: '@jnwng/walletconnect-solana': 0.2.0(@react-native-async-storage/async-storage@1.23.1(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@5.0.10)))(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10))(bufferutil@4.0.8)(utf-8-validate@5.0.10) @@ -19863,7 +20567,30 @@ snapshots: - uWebSockets.js - utf-8-validate - '@solana/wallet-adapter-wallets@0.19.30(@babel/runtime@7.26.0)(@react-native-async-storage/async-storage@1.23.1(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@5.0.10)))(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10))(bs58@5.0.0)(bufferutil@4.0.8)(expo@51.0.29(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(utf-8-validate@5.0.10))(react-dom@18.2.0(react@18.2.0))(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@5.0.10))(react@18.2.0)(tslib@2.6.2)(utf-8-validate@5.0.10)': + '@solana/wallet-adapter-walletconnect@0.1.16(@react-native-async-storage/async-storage@1.23.1(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@6.0.5)))(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5))(bufferutil@4.0.8)(utf-8-validate@6.0.5)': + dependencies: + '@jnwng/walletconnect-solana': 0.2.0(@react-native-async-storage/async-storage@1.23.1(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@6.0.5)))(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5))(bufferutil@4.0.8)(utf-8-validate@6.0.5) + '@solana/wallet-adapter-base': 0.9.23(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5)) + '@solana/web3.js': 1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5) + transitivePeerDependencies: + - '@azure/app-configuration' + - '@azure/cosmos' + - '@azure/data-tables' + - '@azure/identity' + - '@azure/keyvault-secrets' + - '@azure/storage-blob' + - '@capacitor/preferences' + - '@netlify/blobs' + - '@planetscale/database' + - '@react-native-async-storage/async-storage' + - '@upstash/redis' + - '@vercel/kv' + - bufferutil + - ioredis + - uWebSockets.js + - utf-8-validate + + '@solana/wallet-adapter-wallets@0.19.30(@babel/runtime@7.26.0)(@react-native-async-storage/async-storage@1.23.1(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@5.0.10)))(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10))(bufferutil@4.0.8)(expo@51.0.29(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(utf-8-validate@5.0.10))(react-dom@18.2.0(react@18.2.0))(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@5.0.10))(react@18.2.0)(tslib@2.6.2)(utf-8-validate@5.0.10)': dependencies: '@solana/wallet-adapter-alpha': 0.1.10(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10)) '@solana/wallet-adapter-avana': 0.1.13(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10)) @@ -19884,7 +20611,7 @@ snapshots: '@solana/wallet-adapter-nightly': 0.1.16(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10)) '@solana/wallet-adapter-nufi': 0.1.17(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10)) '@solana/wallet-adapter-onto': 0.1.7(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10)) - '@solana/wallet-adapter-particle': 0.1.12(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10))(bs58@5.0.0) + '@solana/wallet-adapter-particle': 0.1.12(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10)) '@solana/wallet-adapter-phantom': 0.9.24(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10)) '@solana/wallet-adapter-safepal': 0.5.18(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10)) '@solana/wallet-adapter-saifu': 0.1.15(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10)) @@ -19931,45 +20658,113 @@ snapshots: - uWebSockets.js - utf-8-validate - '@solana/wallet-adapter-wallets@0.19.32(@babel/runtime@7.26.0)(@react-native-async-storage/async-storage@1.23.1(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@5.0.10)))(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10))(bs58@5.0.0)(bufferutil@4.0.8)(expo@51.0.29(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(utf-8-validate@5.0.10))(react-dom@18.2.0(react@18.2.0))(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@5.0.10))(react@18.2.0)(tslib@2.6.2)(utf-8-validate@5.0.10)': - dependencies: - '@solana/wallet-adapter-alpha': 0.1.10(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10)) - '@solana/wallet-adapter-avana': 0.1.13(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10)) - '@solana/wallet-adapter-bitkeep': 0.3.20(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10)) - '@solana/wallet-adapter-bitpie': 0.5.18(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10)) - '@solana/wallet-adapter-clover': 0.4.19(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10)) - '@solana/wallet-adapter-coin98': 0.5.20(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10)) - '@solana/wallet-adapter-coinbase': 0.1.19(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10)) - '@solana/wallet-adapter-coinhub': 0.3.18(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10)) - '@solana/wallet-adapter-fractal': 0.1.8(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10))(react-dom@18.2.0(react@18.2.0))(react@18.2.0) - '@solana/wallet-adapter-huobi': 0.1.15(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10)) - '@solana/wallet-adapter-hyperpay': 0.1.14(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10)) - '@solana/wallet-adapter-keystone': 0.1.15(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10))(bufferutil@4.0.8)(utf-8-validate@5.0.10) - '@solana/wallet-adapter-krystal': 0.1.12(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10)) - '@solana/wallet-adapter-ledger': 0.9.25(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10)) - '@solana/wallet-adapter-mathwallet': 0.9.18(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10)) - '@solana/wallet-adapter-neko': 0.2.12(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10)) - '@solana/wallet-adapter-nightly': 0.1.16(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10)) - '@solana/wallet-adapter-nufi': 0.1.17(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10)) - '@solana/wallet-adapter-onto': 0.1.7(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10)) - '@solana/wallet-adapter-particle': 0.1.12(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10))(bs58@5.0.0) - '@solana/wallet-adapter-phantom': 0.9.24(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10)) - '@solana/wallet-adapter-safepal': 0.5.18(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10)) - '@solana/wallet-adapter-saifu': 0.1.15(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10)) - '@solana/wallet-adapter-salmon': 0.1.14(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10)) - '@solana/wallet-adapter-sky': 0.1.15(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10)) - '@solana/wallet-adapter-solflare': 0.6.28(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10)) - '@solana/wallet-adapter-solong': 0.9.18(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10)) - '@solana/wallet-adapter-spot': 0.1.15(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10)) - '@solana/wallet-adapter-tokenary': 0.1.12(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10)) - '@solana/wallet-adapter-tokenpocket': 0.4.19(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10)) - '@solana/wallet-adapter-torus': 0.11.28(@babel/runtime@7.26.0)(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10))(bufferutil@4.0.8)(utf-8-validate@5.0.10) - '@solana/wallet-adapter-trezor': 0.1.2(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10))(bufferutil@4.0.8)(expo@51.0.29(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(utf-8-validate@5.0.10))(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@5.0.10))(tslib@2.6.2)(utf-8-validate@5.0.10) - '@solana/wallet-adapter-trust': 0.1.13(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10)) - '@solana/wallet-adapter-unsafe-burner': 0.1.7(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10)) - '@solana/wallet-adapter-walletconnect': 0.1.16(@react-native-async-storage/async-storage@1.23.1(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@5.0.10)))(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10))(bufferutil@4.0.8)(utf-8-validate@5.0.10) - '@solana/wallet-adapter-xdefi': 0.1.7(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10)) - '@solana/web3.js': 1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10) + '@solana/wallet-adapter-wallets@0.19.30(@babel/runtime@7.26.0)(@react-native-async-storage/async-storage@1.23.1(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@6.0.5)))(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5))(bs58@5.0.0)(bufferutil@4.0.8)(expo@51.0.29(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(utf-8-validate@6.0.5))(react-dom@18.2.0(react@18.2.0))(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@6.0.5))(react@18.2.0)(tslib@2.6.2)(utf-8-validate@6.0.5)': + dependencies: + '@solana/wallet-adapter-alpha': 0.1.10(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5)) + '@solana/wallet-adapter-avana': 0.1.13(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5)) + '@solana/wallet-adapter-bitkeep': 0.3.20(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5)) + '@solana/wallet-adapter-bitpie': 0.5.18(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5)) + '@solana/wallet-adapter-clover': 0.4.19(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5)) + '@solana/wallet-adapter-coin98': 0.5.20(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5)) + '@solana/wallet-adapter-coinbase': 0.1.19(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5)) + '@solana/wallet-adapter-coinhub': 0.3.18(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5)) + '@solana/wallet-adapter-fractal': 0.1.8(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5))(react-dom@18.2.0(react@18.2.0))(react@18.2.0) + '@solana/wallet-adapter-huobi': 0.1.15(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5)) + '@solana/wallet-adapter-hyperpay': 0.1.14(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5)) + '@solana/wallet-adapter-keystone': 0.1.15(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5))(bufferutil@4.0.8)(utf-8-validate@6.0.5) + '@solana/wallet-adapter-krystal': 0.1.12(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5)) + '@solana/wallet-adapter-ledger': 0.9.25(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5)) + '@solana/wallet-adapter-mathwallet': 0.9.18(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5)) + '@solana/wallet-adapter-neko': 0.2.12(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5)) + '@solana/wallet-adapter-nightly': 0.1.16(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5)) + '@solana/wallet-adapter-nufi': 0.1.17(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5)) + '@solana/wallet-adapter-onto': 0.1.7(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5)) + '@solana/wallet-adapter-particle': 0.1.12(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5))(bs58@5.0.0) + '@solana/wallet-adapter-phantom': 0.9.24(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5)) + '@solana/wallet-adapter-safepal': 0.5.18(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5)) + '@solana/wallet-adapter-saifu': 0.1.15(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5)) + '@solana/wallet-adapter-salmon': 0.1.14(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5)) + '@solana/wallet-adapter-sky': 0.1.15(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5)) + '@solana/wallet-adapter-solflare': 0.6.28(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5)) + '@solana/wallet-adapter-solong': 0.9.18(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5)) + '@solana/wallet-adapter-spot': 0.1.15(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5)) + '@solana/wallet-adapter-tokenary': 0.1.12(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5)) + '@solana/wallet-adapter-tokenpocket': 0.4.19(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5)) + '@solana/wallet-adapter-torus': 0.11.28(@babel/runtime@7.26.0)(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5))(bufferutil@4.0.8)(utf-8-validate@6.0.5) + '@solana/wallet-adapter-trezor': 0.1.2(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5))(bufferutil@4.0.8)(expo@51.0.29(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(utf-8-validate@6.0.5))(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@6.0.5))(tslib@2.6.2)(utf-8-validate@6.0.5) + '@solana/wallet-adapter-trust': 0.1.13(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5)) + '@solana/wallet-adapter-unsafe-burner': 0.1.7(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5)) + '@solana/wallet-adapter-walletconnect': 0.1.16(@react-native-async-storage/async-storage@1.23.1(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@6.0.5)))(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5))(bufferutil@4.0.8)(utf-8-validate@6.0.5) + '@solana/wallet-adapter-xdefi': 0.1.7(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5)) + '@solana/web3.js': 1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5) + transitivePeerDependencies: + - '@azure/app-configuration' + - '@azure/cosmos' + - '@azure/data-tables' + - '@azure/identity' + - '@azure/keyvault-secrets' + - '@azure/storage-blob' + - '@babel/runtime' + - '@capacitor/preferences' + - '@netlify/blobs' + - '@planetscale/database' + - '@react-native-async-storage/async-storage' + - '@sentry/types' + - '@upstash/redis' + - '@vercel/kv' + - bs58 + - bufferutil + - encoding + - expo + - expo-localization + - ioredis + - react + - react-dom + - react-native + - supports-color + - tslib + - uWebSockets.js + - utf-8-validate + + '@solana/wallet-adapter-wallets@0.19.32(@babel/runtime@7.26.0)(@react-native-async-storage/async-storage@1.23.1(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@6.0.5)))(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5))(bs58@5.0.0)(bufferutil@4.0.8)(expo@51.0.29(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(utf-8-validate@6.0.5))(react-dom@18.2.0(react@18.2.0))(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@6.0.5))(react@18.2.0)(tslib@2.6.2)(utf-8-validate@6.0.5)': + dependencies: + '@solana/wallet-adapter-alpha': 0.1.10(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5)) + '@solana/wallet-adapter-avana': 0.1.13(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5)) + '@solana/wallet-adapter-bitkeep': 0.3.20(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5)) + '@solana/wallet-adapter-bitpie': 0.5.18(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5)) + '@solana/wallet-adapter-clover': 0.4.19(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5)) + '@solana/wallet-adapter-coin98': 0.5.20(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5)) + '@solana/wallet-adapter-coinbase': 0.1.19(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5)) + '@solana/wallet-adapter-coinhub': 0.3.18(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5)) + '@solana/wallet-adapter-fractal': 0.1.8(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5))(react-dom@18.2.0(react@18.2.0))(react@18.2.0) + '@solana/wallet-adapter-huobi': 0.1.15(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5)) + '@solana/wallet-adapter-hyperpay': 0.1.14(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5)) + '@solana/wallet-adapter-keystone': 0.1.15(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5))(bufferutil@4.0.8)(utf-8-validate@6.0.5) + '@solana/wallet-adapter-krystal': 0.1.12(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5)) + '@solana/wallet-adapter-ledger': 0.9.25(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5)) + '@solana/wallet-adapter-mathwallet': 0.9.18(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5)) + '@solana/wallet-adapter-neko': 0.2.12(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5)) + '@solana/wallet-adapter-nightly': 0.1.16(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5)) + '@solana/wallet-adapter-nufi': 0.1.17(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5)) + '@solana/wallet-adapter-onto': 0.1.7(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5)) + '@solana/wallet-adapter-particle': 0.1.12(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5))(bs58@5.0.0) + '@solana/wallet-adapter-phantom': 0.9.24(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5)) + '@solana/wallet-adapter-safepal': 0.5.18(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5)) + '@solana/wallet-adapter-saifu': 0.1.15(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5)) + '@solana/wallet-adapter-salmon': 0.1.14(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5)) + '@solana/wallet-adapter-sky': 0.1.15(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5)) + '@solana/wallet-adapter-solflare': 0.6.28(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5)) + '@solana/wallet-adapter-solong': 0.9.18(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5)) + '@solana/wallet-adapter-spot': 0.1.15(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5)) + '@solana/wallet-adapter-tokenary': 0.1.12(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5)) + '@solana/wallet-adapter-tokenpocket': 0.4.19(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5)) + '@solana/wallet-adapter-torus': 0.11.28(@babel/runtime@7.26.0)(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5))(bufferutil@4.0.8)(utf-8-validate@6.0.5) + '@solana/wallet-adapter-trezor': 0.1.2(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5))(bufferutil@4.0.8)(expo@51.0.29(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(utf-8-validate@6.0.5))(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@6.0.5))(tslib@2.6.2)(utf-8-validate@6.0.5) + '@solana/wallet-adapter-trust': 0.1.13(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5)) + '@solana/wallet-adapter-unsafe-burner': 0.1.7(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5)) + '@solana/wallet-adapter-walletconnect': 0.1.16(@react-native-async-storage/async-storage@1.23.1(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@6.0.5)))(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5))(bufferutil@4.0.8)(utf-8-validate@6.0.5) + '@solana/wallet-adapter-xdefi': 0.1.7(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5)) + '@solana/web3.js': 1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5) transitivePeerDependencies: - '@azure/app-configuration' - '@azure/cosmos' @@ -20004,6 +20799,11 @@ snapshots: '@solana/wallet-adapter-base': 0.9.23(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10)) '@solana/web3.js': 1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10) + '@solana/wallet-adapter-xdefi@0.1.7(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5))': + dependencies: + '@solana/wallet-adapter-base': 0.9.23(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5)) + '@solana/web3.js': 1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5) + '@solana/wallet-standard-chains@1.1.0': dependencies: '@wallet-standard/base': 1.0.1 @@ -20025,23 +20825,23 @@ snapshots: '@solana/wallet-standard-chains': 1.1.0 '@solana/wallet-standard-features': 1.2.0 - '@solana/wallet-standard-wallet-adapter-base@1.1.2(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10))(bs58@5.0.0)': + '@solana/wallet-standard-wallet-adapter-base@1.1.2(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5))(bs58@5.0.0)': dependencies: - '@solana/wallet-adapter-base': 0.9.23(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10)) + '@solana/wallet-adapter-base': 0.9.23(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5)) '@solana/wallet-standard-chains': 1.1.0 '@solana/wallet-standard-features': 1.2.0 '@solana/wallet-standard-util': 1.1.1 - '@solana/web3.js': 1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10) + '@solana/web3.js': 1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5) '@wallet-standard/app': 1.0.1 '@wallet-standard/base': 1.0.1 '@wallet-standard/features': 1.0.3 '@wallet-standard/wallet': 1.0.1 bs58: 5.0.0 - '@solana/wallet-standard-wallet-adapter-react@1.1.2(@solana/wallet-adapter-base@0.9.23(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10)))(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10))(bs58@5.0.0)(react@18.2.0)': + '@solana/wallet-standard-wallet-adapter-react@1.1.2(@solana/wallet-adapter-base@0.9.23(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5)))(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5))(bs58@5.0.0)(react@18.2.0)': dependencies: - '@solana/wallet-adapter-base': 0.9.23(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10)) - '@solana/wallet-standard-wallet-adapter-base': 1.1.2(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10))(bs58@5.0.0) + '@solana/wallet-adapter-base': 0.9.23(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5)) + '@solana/wallet-standard-wallet-adapter-base': 1.1.2(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5))(bs58@5.0.0) '@wallet-standard/app': 1.0.1 '@wallet-standard/base': 1.0.1 react: 18.2.0 @@ -20049,20 +20849,20 @@ snapshots: - '@solana/web3.js' - bs58 - '@solana/wallet-standard-wallet-adapter@1.1.2(@solana/wallet-adapter-base@0.9.23(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10)))(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10))(bs58@5.0.0)(react@18.2.0)': + '@solana/wallet-standard-wallet-adapter@1.1.2(@solana/wallet-adapter-base@0.9.23(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5)))(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5))(bs58@5.0.0)(react@18.2.0)': dependencies: - '@solana/wallet-standard-wallet-adapter-base': 1.1.2(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10))(bs58@5.0.0) - '@solana/wallet-standard-wallet-adapter-react': 1.1.2(@solana/wallet-adapter-base@0.9.23(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10)))(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10))(bs58@5.0.0)(react@18.2.0) + '@solana/wallet-standard-wallet-adapter-base': 1.1.2(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5))(bs58@5.0.0) + '@solana/wallet-standard-wallet-adapter-react': 1.1.2(@solana/wallet-adapter-base@0.9.23(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5)))(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5))(bs58@5.0.0)(react@18.2.0) transitivePeerDependencies: - '@solana/wallet-adapter-base' - '@solana/web3.js' - bs58 - react - '@solana/wallet-standard@1.1.2(@solana/wallet-adapter-base@0.9.23(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10)))(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10))(bs58@5.0.0)(react@18.2.0)': + '@solana/wallet-standard@1.1.2(@solana/wallet-adapter-base@0.9.23(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5)))(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5))(bs58@5.0.0)(react@18.2.0)': dependencies: '@solana/wallet-standard-core': 1.1.1 - '@solana/wallet-standard-wallet-adapter': 1.1.2(@solana/wallet-adapter-base@0.9.23(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10)))(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10))(bs58@5.0.0)(react@18.2.0) + '@solana/wallet-standard-wallet-adapter': 1.1.2(@solana/wallet-adapter-base@0.9.23(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5)))(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5))(bs58@5.0.0)(react@18.2.0) transitivePeerDependencies: - '@solana/wallet-adapter-base' - '@solana/web3.js' @@ -20091,6 +20891,28 @@ snapshots: - encoding - utf-8-validate + '@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5)': + dependencies: + '@babel/runtime': 7.26.0 + '@noble/curves': 1.6.0 + '@noble/hashes': 1.5.0 + '@solana/buffer-layout': 4.0.1 + agentkeepalive: 4.5.0 + bigint-buffer: 1.1.5 + bn.js: 5.2.1 + borsh: 0.7.0 + bs58: 4.0.1 + buffer: 6.0.3 + fast-stable-stringify: 1.0.0 + jayson: 4.1.1(bufferutil@4.0.8)(utf-8-validate@6.0.5) + node-fetch: 2.7.0 + rpc-websockets: 9.0.2 + superstruct: 2.0.2 + transitivePeerDependencies: + - bufferutil + - encoding + - utf-8-validate + '@solflare-wallet/metamask-sdk@1.0.3(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10))': dependencies: '@solana/wallet-standard-features': 1.2.0 @@ -20100,6 +20922,15 @@ snapshots: eventemitter3: 5.0.1 uuid: 9.0.0 + '@solflare-wallet/metamask-sdk@1.0.3(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5))': + dependencies: + '@solana/wallet-standard-features': 1.2.0 + '@solana/web3.js': 1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5) + '@wallet-standard/base': 1.0.1 + bs58: 5.0.0 + eventemitter3: 5.0.1 + uuid: 9.0.0 + '@solflare-wallet/sdk@1.4.2(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10))': dependencies: '@solana/web3.js': 1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10) @@ -20107,6 +20938,13 @@ snapshots: eventemitter3: 5.0.1 uuid: 9.0.0 + '@solflare-wallet/sdk@1.4.2(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5))': + dependencies: + '@solana/web3.js': 1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5) + bs58: 5.0.0 + eventemitter3: 5.0.1 + uuid: 9.0.0 + '@stablelib/aead@1.0.1': {} '@stablelib/binary@1.0.1': @@ -20456,6 +21294,26 @@ snapshots: - supports-color - utf-8-validate + '@toruslabs/base-controllers@2.9.0(@babel/runtime@7.26.0)(bufferutil@4.0.8)(utf-8-validate@6.0.5)': + dependencies: + '@babel/runtime': 7.26.0 + '@ethereumjs/util': 8.1.0 + '@toruslabs/broadcast-channel': 6.3.1(bufferutil@4.0.8)(utf-8-validate@6.0.5) + '@toruslabs/http-helpers': 3.4.0(@babel/runtime@7.26.0) + '@toruslabs/openlogin-jrpc': 4.7.2(@babel/runtime@7.26.0) + async-mutex: 0.4.1 + bignumber.js: 9.1.2 + bowser: 2.11.0 + eth-rpc-errors: 4.0.3 + json-rpc-random-id: 1.0.1 + lodash: 4.17.21 + loglevel: 1.9.1 + transitivePeerDependencies: + - '@sentry/types' + - bufferutil + - supports-color + - utf-8-validate + '@toruslabs/broadcast-channel@6.3.1(bufferutil@4.0.8)(utf-8-validate@5.0.10)': dependencies: '@babel/runtime': 7.26.0 @@ -20472,6 +21330,22 @@ snapshots: - supports-color - utf-8-validate + '@toruslabs/broadcast-channel@6.3.1(bufferutil@4.0.8)(utf-8-validate@6.0.5)': + dependencies: + '@babel/runtime': 7.26.0 + '@toruslabs/eccrypto': 2.2.1 + '@toruslabs/metadata-helpers': 3.2.0(@babel/runtime@7.26.0) + bowser: 2.11.0 + loglevel: 1.9.1 + oblivious-set: 1.1.1 + socket.io-client: 4.7.5(bufferutil@4.0.8)(utf-8-validate@6.0.5) + unload: 2.4.1 + transitivePeerDependencies: + - '@sentry/types' + - bufferutil + - supports-color + - utf-8-validate + '@toruslabs/eccrypto@2.2.1': dependencies: elliptic: 6.6.1 @@ -20551,6 +21425,26 @@ snapshots: - supports-color - utf-8-validate + '@toruslabs/solana-embed@0.3.4(@babel/runtime@7.26.0)(bufferutil@4.0.8)(utf-8-validate@6.0.5)': + dependencies: + '@babel/runtime': 7.26.0 + '@solana/web3.js': 1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5) + '@toruslabs/base-controllers': 2.9.0(@babel/runtime@7.26.0)(bufferutil@4.0.8)(utf-8-validate@6.0.5) + '@toruslabs/http-helpers': 3.4.0(@babel/runtime@7.26.0) + '@toruslabs/openlogin-jrpc': 3.2.0(@babel/runtime@7.26.0) + eth-rpc-errors: 4.0.3 + fast-deep-equal: 3.1.3 + is-stream: 2.0.1 + lodash-es: 4.17.21 + loglevel: 1.9.1 + pump: 3.0.0 + transitivePeerDependencies: + - '@sentry/types' + - bufferutil + - encoding + - supports-color + - utf-8-validate + '@toruslabs/torus-embed@1.41.3(@babel/runtime@7.26.0)': dependencies: '@babel/runtime': 7.26.0 @@ -20581,6 +21475,17 @@ snapshots: - react-native - supports-color + '@trezor/analytics@1.0.15(expo@51.0.29(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(utf-8-validate@6.0.5))(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@6.0.5))(tslib@2.6.2)': + dependencies: + '@trezor/env-utils': 1.0.14(expo@51.0.29(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(utf-8-validate@6.0.5))(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@6.0.5))(tslib@2.6.2) + '@trezor/utils': 9.0.22(tslib@2.6.2) + tslib: 2.6.2 + transitivePeerDependencies: + - expo + - expo-localization + - react-native + - supports-color + '@trezor/blockchain-link-types@1.0.14(bufferutil@4.0.8)(tslib@2.6.2)(utf-8-validate@5.0.10)': dependencies: '@solana/web3.js': 1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10) @@ -20594,6 +21499,19 @@ snapshots: - tslib - utf-8-validate + '@trezor/blockchain-link-types@1.0.14(bufferutil@4.0.8)(tslib@2.6.2)(utf-8-validate@6.0.5)': + dependencies: + '@solana/web3.js': 1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5) + '@trezor/type-utils': 1.0.5 + '@trezor/utxo-lib': 2.0.7(tslib@2.6.2) + socks-proxy-agent: 6.1.1 + transitivePeerDependencies: + - bufferutil + - encoding + - supports-color + - tslib + - utf-8-validate + '@trezor/blockchain-link-utils@1.0.15(bufferutil@4.0.8)(tslib@2.6.2)(utf-8-validate@5.0.10)': dependencies: '@mobily/ts-belt': 3.13.1 @@ -20606,6 +21524,18 @@ snapshots: - encoding - utf-8-validate + '@trezor/blockchain-link-utils@1.0.15(bufferutil@4.0.8)(tslib@2.6.2)(utf-8-validate@6.0.5)': + dependencies: + '@mobily/ts-belt': 3.13.1 + '@solana/web3.js': 1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5) + '@trezor/utils': 9.0.22(tslib@2.6.2) + bignumber.js: 9.1.2 + tslib: 2.6.2 + transitivePeerDependencies: + - bufferutil + - encoding + - utf-8-validate + '@trezor/blockchain-link@2.1.27(bufferutil@4.0.8)(tslib@2.6.2)(utf-8-validate@5.0.10)': dependencies: '@solana/buffer-layout': 4.0.1 @@ -20625,11 +21555,53 @@ snapshots: - bufferutil - encoding - supports-color - - utf-8-validate + - utf-8-validate + + '@trezor/blockchain-link@2.1.27(bufferutil@4.0.8)(tslib@2.6.2)(utf-8-validate@6.0.5)': + dependencies: + '@solana/buffer-layout': 4.0.1 + '@solana/web3.js': 1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5) + '@trezor/blockchain-link-types': 1.0.14(bufferutil@4.0.8)(tslib@2.6.2)(utf-8-validate@6.0.5) + '@trezor/blockchain-link-utils': 1.0.15(bufferutil@4.0.8)(tslib@2.6.2)(utf-8-validate@6.0.5) + '@trezor/utils': 9.0.22(tslib@2.6.2) + '@trezor/utxo-lib': 2.0.7(tslib@2.6.2) + '@types/web': 0.0.138 + bignumber.js: 9.1.2 + events: 3.3.0 + ripple-lib: 1.10.1(bufferutil@4.0.8)(utf-8-validate@6.0.5) + socks-proxy-agent: 6.1.1 + tslib: 2.6.2 + ws: 8.18.0(bufferutil@4.0.8)(utf-8-validate@6.0.5) + transitivePeerDependencies: + - bufferutil + - encoding + - supports-color + - utf-8-validate + + '@trezor/connect-analytics@1.0.13(expo@51.0.29(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(utf-8-validate@5.0.10))(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@5.0.10))(tslib@2.6.2)': + dependencies: + '@trezor/analytics': 1.0.15(expo@51.0.29(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(utf-8-validate@5.0.10))(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@5.0.10))(tslib@2.6.2) + tslib: 2.6.2 + transitivePeerDependencies: + - expo + - expo-localization + - react-native + - supports-color + + '@trezor/connect-analytics@1.0.13(expo@51.0.29(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(utf-8-validate@6.0.5))(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@6.0.5))(tslib@2.6.2)': + dependencies: + '@trezor/analytics': 1.0.15(expo@51.0.29(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(utf-8-validate@6.0.5))(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@6.0.5))(tslib@2.6.2) + tslib: 2.6.2 + transitivePeerDependencies: + - expo + - expo-localization + - react-native + - supports-color - '@trezor/connect-analytics@1.0.13(expo@51.0.29(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(utf-8-validate@5.0.10))(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@5.0.10))(tslib@2.6.2)': + '@trezor/connect-common@0.0.30(expo@51.0.29(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(utf-8-validate@5.0.10))(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@5.0.10))(tslib@2.6.2)': dependencies: - '@trezor/analytics': 1.0.15(expo@51.0.29(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(utf-8-validate@5.0.10))(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@5.0.10))(tslib@2.6.2) + '@trezor/env-utils': 1.0.14(expo@51.0.29(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(utf-8-validate@5.0.10))(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@5.0.10))(tslib@2.6.2) + '@trezor/utils': 9.0.22(tslib@2.6.2) tslib: 2.6.2 transitivePeerDependencies: - expo @@ -20637,9 +21609,9 @@ snapshots: - react-native - supports-color - '@trezor/connect-common@0.0.30(expo@51.0.29(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(utf-8-validate@5.0.10))(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@5.0.10))(tslib@2.6.2)': + '@trezor/connect-common@0.0.30(expo@51.0.29(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(utf-8-validate@6.0.5))(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@6.0.5))(tslib@2.6.2)': dependencies: - '@trezor/env-utils': 1.0.14(expo@51.0.29(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(utf-8-validate@5.0.10))(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@5.0.10))(tslib@2.6.2) + '@trezor/env-utils': 1.0.14(expo@51.0.29(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(utf-8-validate@6.0.5))(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@6.0.5))(tslib@2.6.2) '@trezor/utils': 9.0.22(tslib@2.6.2) tslib: 2.6.2 transitivePeerDependencies: @@ -20664,6 +21636,22 @@ snapshots: - supports-color - utf-8-validate + '@trezor/connect-web@9.2.1(bufferutil@4.0.8)(expo@51.0.29(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(utf-8-validate@6.0.5))(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@6.0.5))(tslib@2.6.2)(utf-8-validate@6.0.5)': + dependencies: + '@trezor/connect': 9.2.1(bufferutil@4.0.8)(expo@51.0.29(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(utf-8-validate@6.0.5))(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@6.0.5))(tslib@2.6.2)(utf-8-validate@6.0.5) + '@trezor/connect-common': 0.0.30(expo@51.0.29(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(utf-8-validate@6.0.5))(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@6.0.5))(tslib@2.6.2) + '@trezor/utils': 9.0.22(tslib@2.6.2) + events: 3.3.0 + tslib: 2.6.2 + transitivePeerDependencies: + - bufferutil + - encoding + - expo + - expo-localization + - react-native + - supports-color + - utf-8-validate + '@trezor/connect@9.2.1(bufferutil@4.0.8)(expo@51.0.29(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(utf-8-validate@5.0.10))(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@5.0.10))(tslib@2.6.2)(utf-8-validate@5.0.10)': dependencies: '@ethereumjs/common': 4.4.0 @@ -20695,6 +21683,37 @@ snapshots: - supports-color - utf-8-validate + '@trezor/connect@9.2.1(bufferutil@4.0.8)(expo@51.0.29(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(utf-8-validate@6.0.5))(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@6.0.5))(tslib@2.6.2)(utf-8-validate@6.0.5)': + dependencies: + '@ethereumjs/common': 4.4.0 + '@ethereumjs/tx': 5.4.0 + '@fivebinaries/coin-selection': 2.2.1 + '@trezor/blockchain-link': 2.1.27(bufferutil@4.0.8)(tslib@2.6.2)(utf-8-validate@6.0.5) + '@trezor/blockchain-link-types': 1.0.14(bufferutil@4.0.8)(tslib@2.6.2)(utf-8-validate@6.0.5) + '@trezor/connect-analytics': 1.0.13(expo@51.0.29(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(utf-8-validate@6.0.5))(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@6.0.5))(tslib@2.6.2) + '@trezor/connect-common': 0.0.30(expo@51.0.29(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(utf-8-validate@6.0.5))(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@6.0.5))(tslib@2.6.2) + '@trezor/protobuf': 1.0.10(tslib@2.6.2) + '@trezor/protocol': 1.0.6(tslib@2.6.2) + '@trezor/schema-utils': 1.0.2 + '@trezor/transport': 1.1.26(tslib@2.6.2) + '@trezor/utils': 9.0.22(tslib@2.6.2) + '@trezor/utxo-lib': 2.0.7(tslib@2.6.2) + bignumber.js: 9.1.2 + blakejs: 1.2.1 + bs58: 5.0.0 + bs58check: 3.0.1 + cross-fetch: 4.0.0 + events: 3.3.0 + tslib: 2.6.2 + transitivePeerDependencies: + - bufferutil + - encoding + - expo + - expo-localization + - react-native + - supports-color + - utf-8-validate + '@trezor/env-utils@1.0.14(expo@51.0.29(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(utf-8-validate@5.0.10))(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@5.0.10))(tslib@2.6.2)': dependencies: expo-constants: 15.4.5(expo@51.0.29(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(utf-8-validate@5.0.10)) @@ -20706,6 +21725,17 @@ snapshots: - expo - supports-color + '@trezor/env-utils@1.0.14(expo@51.0.29(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(utf-8-validate@6.0.5))(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@6.0.5))(tslib@2.6.2)': + dependencies: + expo-constants: 15.4.5(expo@51.0.29(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(utf-8-validate@6.0.5)) + tslib: 2.6.2 + ua-parser-js: 1.0.37 + optionalDependencies: + react-native: 0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@6.0.5) + transitivePeerDependencies: + - expo + - supports-color + '@trezor/protobuf@1.0.10(tslib@2.6.2)': dependencies: '@trezor/schema-utils': 1.0.2 @@ -20976,18 +22006,6 @@ snapshots: - supports-color - utf-8-validate - '@types/react-native@0.73.0(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@6.0.5)': - dependencies: - react-native: 0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@6.0.5) - transitivePeerDependencies: - - '@babel/core' - - '@babel/preset-env' - - bufferutil - - encoding - - react - - supports-color - - utf-8-validate - '@types/react-router-dom@5.3.3': dependencies: '@types/history': 4.7.11 @@ -21020,21 +22038,6 @@ snapshots: - supports-color - utf-8-validate - '@types/rebass@4.0.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@6.0.5)': - dependencies: - '@types/react': 18.2.67 - '@types/styled-components': 5.1.3(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@6.0.5) - '@types/styled-system': 5.1.22 - '@types/styled-system__css': 5.0.21 - transitivePeerDependencies: - - '@babel/core' - - '@babel/preset-env' - - bufferutil - - encoding - - react - - supports-color - - utf-8-validate - '@types/responselike@1.0.3': dependencies: '@types/node': 22.9.3 @@ -21062,21 +22065,6 @@ snapshots: - supports-color - utf-8-validate - '@types/styled-components@5.1.3(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@6.0.5)': - dependencies: - '@types/hoist-non-react-statics': 3.3.5 - '@types/react': 18.2.67 - '@types/react-native': 0.73.0(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@6.0.5) - csstype: 3.1.3 - transitivePeerDependencies: - - '@babel/core' - - '@babel/preset-env' - - bufferutil - - encoding - - react - - supports-color - - utf-8-validate - '@types/styled-system@5.1.22': dependencies: csstype: 3.1.3 @@ -21226,16 +22214,16 @@ snapshots: loupe: 3.1.2 tinyrainbow: 1.2.0 - '@wagmi/connectors@4.1.26(@react-native-async-storage/async-storage@1.23.1(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@5.0.10)))(@swc/core@1.4.8)(@types/react@18.2.67)(@wagmi/core@2.6.17(@tanstack/query-core@5.29.0)(@types/react@18.2.67)(bufferutil@4.0.8)(immer@10.1.1)(react@18.2.0)(typescript@5.5.4)(utf-8-validate@5.0.10)(viem@2.21.50(bufferutil@4.0.8)(typescript@5.5.4)(utf-8-validate@5.0.10)(zod@3.23.8))(zod@3.23.8))(bufferutil@4.0.8)(react-dom@18.2.0(react@18.2.0))(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@5.0.10))(react@18.2.0)(rollup@4.13.0)(typescript@5.5.4)(utf-8-validate@5.0.10)(viem@2.21.50(bufferutil@4.0.8)(typescript@5.5.4)(utf-8-validate@5.0.10)(zod@3.23.8))(zod@3.23.8)': + '@wagmi/connectors@4.1.26(@react-native-async-storage/async-storage@1.23.1(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@6.0.5)))(@swc/core@1.4.8)(@types/react@18.2.67)(@wagmi/core@2.6.17(@tanstack/query-core@5.29.0)(@types/react@18.2.67)(bufferutil@4.0.8)(immer@10.1.1)(react@18.2.0)(typescript@5.5.4)(utf-8-validate@6.0.5)(viem@2.21.50(bufferutil@4.0.8)(typescript@5.5.4)(utf-8-validate@6.0.5)(zod@3.23.8))(zod@3.23.8))(bufferutil@4.0.8)(esbuild@0.19.12)(react-dom@18.2.0(react@18.2.0))(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@6.0.5))(react@18.2.0)(rollup@4.13.0)(typescript@5.5.4)(utf-8-validate@6.0.5)(viem@2.21.50(bufferutil@4.0.8)(typescript@5.5.4)(utf-8-validate@6.0.5)(zod@3.23.8))(zod@3.23.8)': dependencies: '@coinbase/wallet-sdk': 3.9.1 - '@metamask/sdk': 0.14.3(@swc/core@1.4.8)(@types/react@18.2.67)(bufferutil@4.0.8)(react-dom@18.2.0(react@18.2.0))(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@5.0.10))(react@18.2.0)(rollup@4.13.0)(utf-8-validate@5.0.10) - '@safe-global/safe-apps-provider': 0.18.1(bufferutil@4.0.8)(typescript@5.5.4)(utf-8-validate@5.0.10)(zod@3.23.8) - '@safe-global/safe-apps-sdk': 8.1.0(bufferutil@4.0.8)(typescript@5.5.4)(utf-8-validate@5.0.10)(zod@3.23.8) - '@wagmi/core': 2.6.17(@tanstack/query-core@5.29.0)(@types/react@18.2.67)(bufferutil@4.0.8)(immer@10.1.1)(react@18.2.0)(typescript@5.5.4)(utf-8-validate@5.0.10)(viem@2.21.50(bufferutil@4.0.8)(typescript@5.5.4)(utf-8-validate@5.0.10)(zod@3.23.8))(zod@3.23.8) - '@walletconnect/ethereum-provider': 2.11.2(@react-native-async-storage/async-storage@1.23.1(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@5.0.10)))(@types/react@18.2.67)(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@5.0.10) + '@metamask/sdk': 0.14.3(@swc/core@1.4.8)(@types/react@18.2.67)(bufferutil@4.0.8)(esbuild@0.19.12)(react-dom@18.2.0(react@18.2.0))(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@6.0.5))(react@18.2.0)(rollup@4.13.0)(utf-8-validate@6.0.5) + '@safe-global/safe-apps-provider': 0.18.1(bufferutil@4.0.8)(typescript@5.5.4)(utf-8-validate@6.0.5)(zod@3.23.8) + '@safe-global/safe-apps-sdk': 8.1.0(bufferutil@4.0.8)(typescript@5.5.4)(utf-8-validate@6.0.5)(zod@3.23.8) + '@wagmi/core': 2.6.17(@tanstack/query-core@5.29.0)(@types/react@18.2.67)(bufferutil@4.0.8)(immer@10.1.1)(react@18.2.0)(typescript@5.5.4)(utf-8-validate@6.0.5)(viem@2.21.50(bufferutil@4.0.8)(typescript@5.5.4)(utf-8-validate@6.0.5)(zod@3.23.8))(zod@3.23.8) + '@walletconnect/ethereum-provider': 2.11.2(@react-native-async-storage/async-storage@1.23.1(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@6.0.5)))(@types/react@18.2.67)(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@6.0.5) '@walletconnect/modal': 2.6.2(@types/react@18.2.67)(react@18.2.0) - viem: 2.21.50(bufferutil@4.0.8)(typescript@5.5.4)(utf-8-validate@5.0.10)(zod@3.23.8) + viem: 2.21.50(bufferutil@4.0.8)(typescript@5.5.4)(utf-8-validate@6.0.5)(zod@3.23.8) optionalDependencies: typescript: 5.5.4 transitivePeerDependencies: @@ -21326,11 +22314,11 @@ snapshots: - react - use-sync-external-store - '@wagmi/core@2.6.17(@tanstack/query-core@5.29.0)(@types/react@18.2.67)(bufferutil@4.0.8)(immer@10.1.1)(react@18.2.0)(typescript@5.5.4)(utf-8-validate@5.0.10)(viem@2.21.50(bufferutil@4.0.8)(typescript@5.5.4)(utf-8-validate@5.0.10)(zod@3.23.8))(zod@3.23.8)': + '@wagmi/core@2.6.17(@tanstack/query-core@5.29.0)(@types/react@18.2.67)(bufferutil@4.0.8)(immer@10.1.1)(react@18.2.0)(typescript@5.5.4)(utf-8-validate@6.0.5)(viem@2.21.50(bufferutil@4.0.8)(typescript@5.5.4)(utf-8-validate@6.0.5)(zod@3.23.8))(zod@3.23.8)': dependencies: eventemitter3: 5.0.1 - mipd: 0.0.5(bufferutil@4.0.8)(typescript@5.5.4)(utf-8-validate@5.0.10)(zod@3.23.8) - viem: 2.21.50(bufferutil@4.0.8)(typescript@5.5.4)(utf-8-validate@5.0.10)(zod@3.23.8) + mipd: 0.0.5(bufferutil@4.0.8)(typescript@5.5.4)(utf-8-validate@6.0.5)(zod@3.23.8) + viem: 2.21.50(bufferutil@4.0.8)(typescript@5.5.4)(utf-8-validate@6.0.5)(zod@3.23.8) zustand: 4.4.1(@types/react@18.2.67)(immer@10.1.1)(react@18.2.0) optionalDependencies: '@tanstack/query-core': 5.29.0 @@ -21372,21 +22360,21 @@ snapshots: '@walletconnect/window-metadata': 1.0.0 detect-browser: 5.2.0 - '@walletconnect/core@2.11.2(@react-native-async-storage/async-storage@1.23.1(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@5.0.10)))(bufferutil@4.0.8)(utf-8-validate@5.0.10)': + '@walletconnect/core@2.11.2(@react-native-async-storage/async-storage@1.23.1(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@6.0.5)))(bufferutil@4.0.8)(utf-8-validate@6.0.5)': dependencies: '@walletconnect/heartbeat': 1.2.1 '@walletconnect/jsonrpc-provider': 1.0.13 '@walletconnect/jsonrpc-types': 1.0.3 '@walletconnect/jsonrpc-utils': 1.0.8 - '@walletconnect/jsonrpc-ws-connection': 1.0.14(bufferutil@4.0.8)(utf-8-validate@5.0.10) - '@walletconnect/keyvaluestorage': 1.1.1(@react-native-async-storage/async-storage@1.23.1(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@5.0.10))) + '@walletconnect/jsonrpc-ws-connection': 1.0.14(bufferutil@4.0.8)(utf-8-validate@6.0.5) + '@walletconnect/keyvaluestorage': 1.1.1(@react-native-async-storage/async-storage@1.23.1(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@6.0.5))) '@walletconnect/logger': 2.1.2 '@walletconnect/relay-api': 1.0.11 '@walletconnect/relay-auth': 1.0.4 '@walletconnect/safe-json': 1.0.2 '@walletconnect/time': 1.0.2 - '@walletconnect/types': 2.11.2(@react-native-async-storage/async-storage@1.23.1(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@5.0.10))) - '@walletconnect/utils': 2.11.2(@react-native-async-storage/async-storage@1.23.1(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@5.0.10))) + '@walletconnect/types': 2.11.2(@react-native-async-storage/async-storage@1.23.1(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@6.0.5))) + '@walletconnect/utils': 2.11.2(@react-native-async-storage/async-storage@1.23.1(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@6.0.5))) events: 3.3.0 isomorphic-unfetch: 3.1.0 lodash.isequal: 4.5.0 @@ -21446,21 +22434,57 @@ snapshots: - uWebSockets.js - utf-8-validate + '@walletconnect/core@2.17.0(@react-native-async-storage/async-storage@1.23.1(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@6.0.5)))(bufferutil@4.0.8)(utf-8-validate@6.0.5)': + dependencies: + '@walletconnect/heartbeat': 1.2.2 + '@walletconnect/jsonrpc-provider': 1.0.14 + '@walletconnect/jsonrpc-types': 1.0.4 + '@walletconnect/jsonrpc-utils': 1.0.8 + '@walletconnect/jsonrpc-ws-connection': 1.0.14(bufferutil@4.0.8)(utf-8-validate@6.0.5) + '@walletconnect/keyvaluestorage': 1.1.1(@react-native-async-storage/async-storage@1.23.1(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@6.0.5))) + '@walletconnect/logger': 2.1.2 + '@walletconnect/relay-api': 1.0.11 + '@walletconnect/relay-auth': 1.0.4 + '@walletconnect/safe-json': 1.0.2 + '@walletconnect/time': 1.0.2 + '@walletconnect/types': 2.17.0(@react-native-async-storage/async-storage@1.23.1(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@6.0.5))) + '@walletconnect/utils': 2.17.0(@react-native-async-storage/async-storage@1.23.1(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@6.0.5))) + events: 3.3.0 + lodash.isequal: 4.5.0 + uint8arrays: 3.1.0 + transitivePeerDependencies: + - '@azure/app-configuration' + - '@azure/cosmos' + - '@azure/data-tables' + - '@azure/identity' + - '@azure/keyvault-secrets' + - '@azure/storage-blob' + - '@capacitor/preferences' + - '@netlify/blobs' + - '@planetscale/database' + - '@react-native-async-storage/async-storage' + - '@upstash/redis' + - '@vercel/kv' + - bufferutil + - ioredis + - uWebSockets.js + - utf-8-validate + '@walletconnect/environment@1.0.1': dependencies: tslib: 1.14.1 - '@walletconnect/ethereum-provider@2.11.2(@react-native-async-storage/async-storage@1.23.1(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@5.0.10)))(@types/react@18.2.67)(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@5.0.10)': + '@walletconnect/ethereum-provider@2.11.2(@react-native-async-storage/async-storage@1.23.1(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@6.0.5)))(@types/react@18.2.67)(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@6.0.5)': dependencies: '@walletconnect/jsonrpc-http-connection': 1.0.8 '@walletconnect/jsonrpc-provider': 1.0.14 '@walletconnect/jsonrpc-types': 1.0.4 '@walletconnect/jsonrpc-utils': 1.0.8 '@walletconnect/modal': 2.7.0(@types/react@18.2.67)(react@18.2.0) - '@walletconnect/sign-client': 2.11.2(@react-native-async-storage/async-storage@1.23.1(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@5.0.10)))(bufferutil@4.0.8)(utf-8-validate@5.0.10) - '@walletconnect/types': 2.11.2(@react-native-async-storage/async-storage@1.23.1(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@5.0.10))) - '@walletconnect/universal-provider': 2.11.2(@react-native-async-storage/async-storage@1.23.1(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@5.0.10)))(bufferutil@4.0.8)(utf-8-validate@5.0.10) - '@walletconnect/utils': 2.11.2(@react-native-async-storage/async-storage@1.23.1(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@5.0.10))) + '@walletconnect/sign-client': 2.11.2(@react-native-async-storage/async-storage@1.23.1(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@6.0.5)))(bufferutil@4.0.8)(utf-8-validate@6.0.5) + '@walletconnect/types': 2.11.2(@react-native-async-storage/async-storage@1.23.1(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@6.0.5))) + '@walletconnect/universal-provider': 2.11.2(@react-native-async-storage/async-storage@1.23.1(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@6.0.5)))(bufferutil@4.0.8)(utf-8-validate@6.0.5) + '@walletconnect/utils': 2.11.2(@react-native-async-storage/async-storage@1.23.1(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@6.0.5))) events: 3.3.0 transitivePeerDependencies: - '@azure/app-configuration' @@ -21516,6 +22540,39 @@ snapshots: - uWebSockets.js - utf-8-validate + '@walletconnect/ethereum-provider@2.17.0(@react-native-async-storage/async-storage@1.23.1(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@6.0.5)))(@types/react@18.2.67)(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@6.0.5)': + dependencies: + '@walletconnect/jsonrpc-http-connection': 1.0.8 + '@walletconnect/jsonrpc-provider': 1.0.14 + '@walletconnect/jsonrpc-types': 1.0.4 + '@walletconnect/jsonrpc-utils': 1.0.8 + '@walletconnect/modal': 2.7.0(@types/react@18.2.67)(react@18.2.0) + '@walletconnect/sign-client': 2.17.0(@react-native-async-storage/async-storage@1.23.1(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@6.0.5)))(bufferutil@4.0.8)(utf-8-validate@6.0.5) + '@walletconnect/types': 2.17.0(@react-native-async-storage/async-storage@1.23.1(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@6.0.5))) + '@walletconnect/universal-provider': 2.17.0(@react-native-async-storage/async-storage@1.23.1(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@6.0.5)))(bufferutil@4.0.8)(utf-8-validate@6.0.5) + '@walletconnect/utils': 2.17.0(@react-native-async-storage/async-storage@1.23.1(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@6.0.5))) + events: 3.3.0 + transitivePeerDependencies: + - '@azure/app-configuration' + - '@azure/cosmos' + - '@azure/data-tables' + - '@azure/identity' + - '@azure/keyvault-secrets' + - '@azure/storage-blob' + - '@capacitor/preferences' + - '@netlify/blobs' + - '@planetscale/database' + - '@react-native-async-storage/async-storage' + - '@types/react' + - '@upstash/redis' + - '@vercel/kv' + - bufferutil + - encoding + - ioredis + - react + - uWebSockets.js + - utf-8-validate + '@walletconnect/events@1.0.1': dependencies: keyvaluestorage-interface: 1.0.0 @@ -21580,6 +22637,16 @@ snapshots: - bufferutil - utf-8-validate + '@walletconnect/jsonrpc-ws-connection@1.0.14(bufferutil@4.0.8)(utf-8-validate@6.0.5)': + dependencies: + '@walletconnect/jsonrpc-utils': 1.0.8 + '@walletconnect/safe-json': 1.0.2 + events: 3.3.0 + ws: 7.5.10(bufferutil@4.0.8)(utf-8-validate@6.0.5) + transitivePeerDependencies: + - bufferutil + - utf-8-validate + '@walletconnect/keyvaluestorage@1.1.1(@react-native-async-storage/async-storage@1.23.1(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@5.0.10)))': dependencies: '@walletconnect/safe-json': 1.0.2 @@ -21602,6 +22669,28 @@ snapshots: - ioredis - uWebSockets.js + '@walletconnect/keyvaluestorage@1.1.1(@react-native-async-storage/async-storage@1.23.1(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@6.0.5)))': + dependencies: + '@walletconnect/safe-json': 1.0.2 + idb-keyval: 6.2.1 + unstorage: 1.10.2(idb-keyval@6.2.1) + optionalDependencies: + '@react-native-async-storage/async-storage': 1.23.1(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@6.0.5)) + transitivePeerDependencies: + - '@azure/app-configuration' + - '@azure/cosmos' + - '@azure/data-tables' + - '@azure/identity' + - '@azure/keyvault-secrets' + - '@azure/storage-blob' + - '@capacitor/preferences' + - '@netlify/blobs' + - '@planetscale/database' + - '@upstash/redis' + - '@vercel/kv' + - ioredis + - uWebSockets.js + '@walletconnect/logger@2.1.2': dependencies: '@walletconnect/safe-json': 1.0.2 @@ -21687,16 +22776,16 @@ snapshots: dependencies: tslib: 1.14.1 - '@walletconnect/sign-client@2.11.2(@react-native-async-storage/async-storage@1.23.1(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@5.0.10)))(bufferutil@4.0.8)(utf-8-validate@5.0.10)': + '@walletconnect/sign-client@2.11.2(@react-native-async-storage/async-storage@1.23.1(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@6.0.5)))(bufferutil@4.0.8)(utf-8-validate@6.0.5)': dependencies: - '@walletconnect/core': 2.11.2(@react-native-async-storage/async-storage@1.23.1(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@5.0.10)))(bufferutil@4.0.8)(utf-8-validate@5.0.10) + '@walletconnect/core': 2.11.2(@react-native-async-storage/async-storage@1.23.1(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@6.0.5)))(bufferutil@4.0.8)(utf-8-validate@6.0.5) '@walletconnect/events': 1.0.1 '@walletconnect/heartbeat': 1.2.1 '@walletconnect/jsonrpc-utils': 1.0.8 '@walletconnect/logger': 2.1.2 '@walletconnect/time': 1.0.2 - '@walletconnect/types': 2.11.2(@react-native-async-storage/async-storage@1.23.1(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@5.0.10))) - '@walletconnect/utils': 2.11.2(@react-native-async-storage/async-storage@1.23.1(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@5.0.10))) + '@walletconnect/types': 2.11.2(@react-native-async-storage/async-storage@1.23.1(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@6.0.5))) + '@walletconnect/utils': 2.11.2(@react-native-async-storage/async-storage@1.23.1(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@6.0.5))) events: 3.3.0 transitivePeerDependencies: - '@azure/app-configuration' @@ -21746,18 +22835,47 @@ snapshots: - uWebSockets.js - utf-8-validate + '@walletconnect/sign-client@2.17.0(@react-native-async-storage/async-storage@1.23.1(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@6.0.5)))(bufferutil@4.0.8)(utf-8-validate@6.0.5)': + dependencies: + '@walletconnect/core': 2.17.0(@react-native-async-storage/async-storage@1.23.1(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@6.0.5)))(bufferutil@4.0.8)(utf-8-validate@6.0.5) + '@walletconnect/events': 1.0.1 + '@walletconnect/heartbeat': 1.2.2 + '@walletconnect/jsonrpc-utils': 1.0.8 + '@walletconnect/logger': 2.1.2 + '@walletconnect/time': 1.0.2 + '@walletconnect/types': 2.17.0(@react-native-async-storage/async-storage@1.23.1(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@6.0.5))) + '@walletconnect/utils': 2.17.0(@react-native-async-storage/async-storage@1.23.1(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@6.0.5))) + events: 3.3.0 + transitivePeerDependencies: + - '@azure/app-configuration' + - '@azure/cosmos' + - '@azure/data-tables' + - '@azure/identity' + - '@azure/keyvault-secrets' + - '@azure/storage-blob' + - '@capacitor/preferences' + - '@netlify/blobs' + - '@planetscale/database' + - '@react-native-async-storage/async-storage' + - '@upstash/redis' + - '@vercel/kv' + - bufferutil + - ioredis + - uWebSockets.js + - utf-8-validate + '@walletconnect/time@1.0.2': dependencies: tslib: 1.14.1 '@walletconnect/types@1.8.0': {} - '@walletconnect/types@2.11.2(@react-native-async-storage/async-storage@1.23.1(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@5.0.10)))': + '@walletconnect/types@2.11.2(@react-native-async-storage/async-storage@1.23.1(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@6.0.5)))': dependencies: '@walletconnect/events': 1.0.1 '@walletconnect/heartbeat': 1.2.1 '@walletconnect/jsonrpc-types': 1.0.3 - '@walletconnect/keyvaluestorage': 1.1.1(@react-native-async-storage/async-storage@1.23.1(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@5.0.10))) + '@walletconnect/keyvaluestorage': 1.1.1(@react-native-async-storage/async-storage@1.23.1(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@6.0.5))) '@walletconnect/logger': 2.1.2 events: 3.3.0 transitivePeerDependencies: @@ -21800,16 +22918,70 @@ snapshots: - ioredis - uWebSockets.js - '@walletconnect/universal-provider@2.11.2(@react-native-async-storage/async-storage@1.23.1(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@5.0.10)))(bufferutil@4.0.8)(utf-8-validate@5.0.10)': + '@walletconnect/types@2.17.0(@react-native-async-storage/async-storage@1.23.1(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@6.0.5)))': + dependencies: + '@walletconnect/events': 1.0.1 + '@walletconnect/heartbeat': 1.2.2 + '@walletconnect/jsonrpc-types': 1.0.4 + '@walletconnect/keyvaluestorage': 1.1.1(@react-native-async-storage/async-storage@1.23.1(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@6.0.5))) + '@walletconnect/logger': 2.1.2 + events: 3.3.0 + transitivePeerDependencies: + - '@azure/app-configuration' + - '@azure/cosmos' + - '@azure/data-tables' + - '@azure/identity' + - '@azure/keyvault-secrets' + - '@azure/storage-blob' + - '@capacitor/preferences' + - '@netlify/blobs' + - '@planetscale/database' + - '@react-native-async-storage/async-storage' + - '@upstash/redis' + - '@vercel/kv' + - ioredis + - uWebSockets.js + + '@walletconnect/universal-provider@2.11.2(@react-native-async-storage/async-storage@1.23.1(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@6.0.5)))(bufferutil@4.0.8)(utf-8-validate@6.0.5)': + dependencies: + '@walletconnect/jsonrpc-http-connection': 1.0.8 + '@walletconnect/jsonrpc-provider': 1.0.13 + '@walletconnect/jsonrpc-types': 1.0.4 + '@walletconnect/jsonrpc-utils': 1.0.8 + '@walletconnect/logger': 2.1.2 + '@walletconnect/sign-client': 2.11.2(@react-native-async-storage/async-storage@1.23.1(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@6.0.5)))(bufferutil@4.0.8)(utf-8-validate@6.0.5) + '@walletconnect/types': 2.11.2(@react-native-async-storage/async-storage@1.23.1(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@6.0.5))) + '@walletconnect/utils': 2.11.2(@react-native-async-storage/async-storage@1.23.1(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@6.0.5))) + events: 3.3.0 + transitivePeerDependencies: + - '@azure/app-configuration' + - '@azure/cosmos' + - '@azure/data-tables' + - '@azure/identity' + - '@azure/keyvault-secrets' + - '@azure/storage-blob' + - '@capacitor/preferences' + - '@netlify/blobs' + - '@planetscale/database' + - '@react-native-async-storage/async-storage' + - '@upstash/redis' + - '@vercel/kv' + - bufferutil + - encoding + - ioredis + - uWebSockets.js + - utf-8-validate + + '@walletconnect/universal-provider@2.17.0(@react-native-async-storage/async-storage@1.23.1(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@5.0.10)))(bufferutil@4.0.8)(utf-8-validate@5.0.10)': dependencies: '@walletconnect/jsonrpc-http-connection': 1.0.8 - '@walletconnect/jsonrpc-provider': 1.0.13 + '@walletconnect/jsonrpc-provider': 1.0.14 '@walletconnect/jsonrpc-types': 1.0.4 '@walletconnect/jsonrpc-utils': 1.0.8 '@walletconnect/logger': 2.1.2 - '@walletconnect/sign-client': 2.11.2(@react-native-async-storage/async-storage@1.23.1(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@5.0.10)))(bufferutil@4.0.8)(utf-8-validate@5.0.10) - '@walletconnect/types': 2.11.2(@react-native-async-storage/async-storage@1.23.1(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@5.0.10))) - '@walletconnect/utils': 2.11.2(@react-native-async-storage/async-storage@1.23.1(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@5.0.10))) + '@walletconnect/sign-client': 2.17.0(@react-native-async-storage/async-storage@1.23.1(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@5.0.10)))(bufferutil@4.0.8)(utf-8-validate@5.0.10) + '@walletconnect/types': 2.17.0(@react-native-async-storage/async-storage@1.23.1(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@5.0.10))) + '@walletconnect/utils': 2.17.0(@react-native-async-storage/async-storage@1.23.1(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@5.0.10))) events: 3.3.0 transitivePeerDependencies: - '@azure/app-configuration' @@ -21830,16 +23002,16 @@ snapshots: - uWebSockets.js - utf-8-validate - '@walletconnect/universal-provider@2.17.0(@react-native-async-storage/async-storage@1.23.1(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@5.0.10)))(bufferutil@4.0.8)(utf-8-validate@5.0.10)': + '@walletconnect/universal-provider@2.17.0(@react-native-async-storage/async-storage@1.23.1(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@6.0.5)))(bufferutil@4.0.8)(utf-8-validate@6.0.5)': dependencies: '@walletconnect/jsonrpc-http-connection': 1.0.8 '@walletconnect/jsonrpc-provider': 1.0.14 '@walletconnect/jsonrpc-types': 1.0.4 '@walletconnect/jsonrpc-utils': 1.0.8 '@walletconnect/logger': 2.1.2 - '@walletconnect/sign-client': 2.17.0(@react-native-async-storage/async-storage@1.23.1(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@5.0.10)))(bufferutil@4.0.8)(utf-8-validate@5.0.10) - '@walletconnect/types': 2.17.0(@react-native-async-storage/async-storage@1.23.1(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@5.0.10))) - '@walletconnect/utils': 2.17.0(@react-native-async-storage/async-storage@1.23.1(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@5.0.10))) + '@walletconnect/sign-client': 2.17.0(@react-native-async-storage/async-storage@1.23.1(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@6.0.5)))(bufferutil@4.0.8)(utf-8-validate@6.0.5) + '@walletconnect/types': 2.17.0(@react-native-async-storage/async-storage@1.23.1(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@6.0.5))) + '@walletconnect/utils': 2.17.0(@react-native-async-storage/async-storage@1.23.1(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@6.0.5))) events: 3.3.0 transitivePeerDependencies: - '@azure/app-configuration' @@ -21860,7 +23032,7 @@ snapshots: - uWebSockets.js - utf-8-validate - '@walletconnect/utils@2.11.2(@react-native-async-storage/async-storage@1.23.1(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@5.0.10)))': + '@walletconnect/utils@2.11.2(@react-native-async-storage/async-storage@1.23.1(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@6.0.5)))': dependencies: '@stablelib/chacha20poly1305': 1.0.1 '@stablelib/hkdf': 1.0.1 @@ -21870,7 +23042,7 @@ snapshots: '@walletconnect/relay-api': 1.0.11 '@walletconnect/safe-json': 1.0.2 '@walletconnect/time': 1.0.2 - '@walletconnect/types': 2.11.2(@react-native-async-storage/async-storage@1.23.1(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@5.0.10))) + '@walletconnect/types': 2.11.2(@react-native-async-storage/async-storage@1.23.1(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@6.0.5))) '@walletconnect/window-getters': 1.0.1 '@walletconnect/window-metadata': 1.0.1 detect-browser: 5.3.0 @@ -21926,6 +23098,40 @@ snapshots: - ioredis - uWebSockets.js + '@walletconnect/utils@2.17.0(@react-native-async-storage/async-storage@1.23.1(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@6.0.5)))': + dependencies: + '@stablelib/chacha20poly1305': 1.0.1 + '@stablelib/hkdf': 1.0.1 + '@stablelib/random': 1.0.2 + '@stablelib/sha256': 1.0.1 + '@stablelib/x25519': 1.0.3 + '@walletconnect/relay-api': 1.0.11 + '@walletconnect/relay-auth': 1.0.4 + '@walletconnect/safe-json': 1.0.2 + '@walletconnect/time': 1.0.2 + '@walletconnect/types': 2.17.0(@react-native-async-storage/async-storage@1.23.1(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@6.0.5))) + '@walletconnect/window-getters': 1.0.1 + '@walletconnect/window-metadata': 1.0.1 + detect-browser: 5.3.0 + elliptic: 6.6.1 + query-string: 7.1.3 + uint8arrays: 3.1.0 + transitivePeerDependencies: + - '@azure/app-configuration' + - '@azure/cosmos' + - '@azure/data-tables' + - '@azure/identity' + - '@azure/keyvault-secrets' + - '@azure/storage-blob' + - '@capacitor/preferences' + - '@netlify/blobs' + - '@planetscale/database' + - '@react-native-async-storage/async-storage' + - '@upstash/redis' + - '@vercel/kv' + - ioredis + - uWebSockets.js + '@walletconnect/window-getters@1.0.0': {} '@walletconnect/window-getters@1.0.1': @@ -22017,19 +23223,19 @@ snapshots: '@webassemblyjs/ast': 1.12.1 '@xtuc/long': 4.2.2 - '@webpack-cli/configtest@2.1.1(webpack-cli@5.1.4(webpack@5.91.0))(webpack@5.91.0(@swc/core@1.4.8)(webpack-cli@5.1.4))': + '@webpack-cli/configtest@2.1.1(webpack-cli@5.1.4(webpack@5.91.0))(webpack@5.91.0(@swc/core@1.4.8)(esbuild@0.19.12)(webpack-cli@5.1.4))': dependencies: - webpack: 5.91.0(@swc/core@1.4.8)(webpack-cli@5.1.4) + webpack: 5.91.0(@swc/core@1.4.8)(esbuild@0.19.12)(webpack-cli@5.1.4) webpack-cli: 5.1.4(webpack@5.91.0) - '@webpack-cli/info@2.0.2(webpack-cli@5.1.4(webpack@5.91.0))(webpack@5.91.0(@swc/core@1.4.8)(webpack-cli@5.1.4))': + '@webpack-cli/info@2.0.2(webpack-cli@5.1.4(webpack@5.91.0))(webpack@5.91.0(@swc/core@1.4.8)(esbuild@0.19.12)(webpack-cli@5.1.4))': dependencies: - webpack: 5.91.0(@swc/core@1.4.8)(webpack-cli@5.1.4) + webpack: 5.91.0(@swc/core@1.4.8)(esbuild@0.19.12)(webpack-cli@5.1.4) webpack-cli: 5.1.4(webpack@5.91.0) - '@webpack-cli/serve@2.0.5(webpack-cli@5.1.4(webpack@5.91.0))(webpack@5.91.0(@swc/core@1.4.8)(webpack-cli@5.1.4))': + '@webpack-cli/serve@2.0.5(webpack-cli@5.1.4(webpack@5.91.0))(webpack@5.91.0(@swc/core@1.4.8)(esbuild@0.19.12)(webpack-cli@5.1.4))': dependencies: - webpack: 5.91.0(@swc/core@1.4.8)(webpack-cli@5.1.4) + webpack: 5.91.0(@swc/core@1.4.8)(esbuild@0.19.12)(webpack-cli@5.1.4) webpack-cli: 5.1.4(webpack@5.91.0) '@wry/caches@1.0.1': @@ -22224,6 +23430,28 @@ snapshots: - supports-color - utf-8-validate + alchemy-sdk@2.12.0(bufferutil@4.0.8)(utf-8-validate@6.0.5): + dependencies: + '@ethersproject/abi': 5.7.0 + '@ethersproject/abstract-provider': 5.7.0 + '@ethersproject/bignumber': 5.7.0 + '@ethersproject/bytes': 5.7.0 + '@ethersproject/contracts': 5.7.0 + '@ethersproject/hash': 5.7.0 + '@ethersproject/networks': 5.7.1 + '@ethersproject/providers': 5.7.2(bufferutil@4.0.8)(utf-8-validate@6.0.5) + '@ethersproject/units': 5.7.0 + '@ethersproject/wallet': 5.7.0 + '@ethersproject/web': 5.7.1 + axios: 0.26.1 + sturdy-websocket: 0.2.1 + websocket: 1.0.35 + transitivePeerDependencies: + - bufferutil + - debug + - supports-color + - utf-8-validate + anser@1.4.10: {} ansi-align@2.0.0: @@ -23794,6 +25022,14 @@ snapshots: - debug - utf-8-validate + eip1193-provider@1.0.1(bufferutil@4.0.8)(utf-8-validate@6.0.5): + dependencies: + '@json-rpc-tools/provider': 1.7.6(bufferutil@4.0.8)(utf-8-validate@6.0.5) + transitivePeerDependencies: + - bufferutil + - debug + - utf-8-validate + eip55@2.1.1: dependencies: keccak: 3.0.4 @@ -24263,6 +25499,42 @@ snapshots: - bufferutil - utf-8-validate + ethers@5.6.1(bufferutil@4.0.8)(utf-8-validate@6.0.5): + dependencies: + '@ethersproject/abi': 5.6.0 + '@ethersproject/abstract-provider': 5.6.0 + '@ethersproject/abstract-signer': 5.6.0 + '@ethersproject/address': 5.6.0 + '@ethersproject/base64': 5.6.0 + '@ethersproject/basex': 5.6.0 + '@ethersproject/bignumber': 5.6.0 + '@ethersproject/bytes': 5.6.0 + '@ethersproject/constants': 5.6.0 + '@ethersproject/contracts': 5.6.0 + '@ethersproject/hash': 5.6.0 + '@ethersproject/hdnode': 5.6.0 + '@ethersproject/json-wallets': 5.6.0 + '@ethersproject/keccak256': 5.6.0 + '@ethersproject/logger': 5.6.0 + '@ethersproject/networks': 5.6.0 + '@ethersproject/pbkdf2': 5.6.0 + '@ethersproject/properties': 5.6.0 + '@ethersproject/providers': 5.6.1(bufferutil@4.0.8)(utf-8-validate@6.0.5) + '@ethersproject/random': 5.6.0 + '@ethersproject/rlp': 5.6.0 + '@ethersproject/sha2': 5.6.0 + '@ethersproject/signing-key': 5.6.0 + '@ethersproject/solidity': 5.6.0 + '@ethersproject/strings': 5.6.0 + '@ethersproject/transactions': 5.6.0 + '@ethersproject/units': 5.6.0 + '@ethersproject/wallet': 5.6.0 + '@ethersproject/web': 5.6.0 + '@ethersproject/wordlists': 5.6.0 + transitivePeerDependencies: + - bufferutil + - utf-8-validate + ethers@5.7.2(bufferutil@4.0.8)(utf-8-validate@5.0.10): dependencies: '@ethersproject/abi': 5.7.0 @@ -24299,6 +25571,42 @@ snapshots: - bufferutil - utf-8-validate + ethers@5.7.2(bufferutil@4.0.8)(utf-8-validate@6.0.5): + dependencies: + '@ethersproject/abi': 5.7.0 + '@ethersproject/abstract-provider': 5.7.0 + '@ethersproject/abstract-signer': 5.7.0 + '@ethersproject/address': 5.7.0 + '@ethersproject/base64': 5.7.0 + '@ethersproject/basex': 5.7.0 + '@ethersproject/bignumber': 5.7.0 + '@ethersproject/bytes': 5.7.0 + '@ethersproject/constants': 5.7.0 + '@ethersproject/contracts': 5.7.0 + '@ethersproject/hash': 5.7.0 + '@ethersproject/hdnode': 5.7.0 + '@ethersproject/json-wallets': 5.7.0 + '@ethersproject/keccak256': 5.7.0 + '@ethersproject/logger': 5.7.0 + '@ethersproject/networks': 5.7.1 + '@ethersproject/pbkdf2': 5.7.0 + '@ethersproject/properties': 5.7.0 + '@ethersproject/providers': 5.7.2(bufferutil@4.0.8)(utf-8-validate@6.0.5) + '@ethersproject/random': 5.7.0 + '@ethersproject/rlp': 5.7.0 + '@ethersproject/sha2': 5.7.0 + '@ethersproject/signing-key': 5.7.0 + '@ethersproject/solidity': 5.7.0 + '@ethersproject/strings': 5.7.0 + '@ethersproject/transactions': 5.7.0 + '@ethersproject/units': 5.7.0 + '@ethersproject/wallet': 5.7.0 + '@ethersproject/web': 5.7.1 + '@ethersproject/wordlists': 5.7.0 + transitivePeerDependencies: + - bufferutil + - utf-8-validate + ethers@6.13.2(bufferutil@4.0.8)(utf-8-validate@5.0.10): dependencies: '@adraffy/ens-normalize': 1.10.1 @@ -24312,6 +25620,19 @@ snapshots: - bufferutil - utf-8-validate + ethers@6.13.2(bufferutil@4.0.8)(utf-8-validate@6.0.5): + dependencies: + '@adraffy/ens-normalize': 1.10.1 + '@noble/curves': 1.2.0 + '@noble/hashes': 1.3.2 + '@types/node': 18.15.13 + aes-js: 4.0.0-beta.5 + tslib: 2.4.0 + ws: 8.17.1(bufferutil@4.0.8)(utf-8-validate@6.0.5) + transitivePeerDependencies: + - bufferutil + - utf-8-validate + ethjs-util@0.1.6: dependencies: is-hex-prefixed: 1.0.0 @@ -24442,6 +25763,15 @@ snapshots: transitivePeerDependencies: - supports-color + expo-asset@10.0.10(expo@51.0.29(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(utf-8-validate@6.0.5)): + dependencies: + expo: 51.0.29(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(utf-8-validate@6.0.5) + expo-constants: 16.0.2(expo@51.0.29(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(utf-8-validate@6.0.5)) + invariant: 2.2.4 + md5-file: 3.2.3 + transitivePeerDependencies: + - supports-color + expo-constants@15.4.5(expo@51.0.29(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(utf-8-validate@5.0.10)): dependencies: '@expo/config': 8.5.6 @@ -24449,6 +25779,13 @@ snapshots: transitivePeerDependencies: - supports-color + expo-constants@15.4.5(expo@51.0.29(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(utf-8-validate@6.0.5)): + dependencies: + '@expo/config': 8.5.6 + expo: 51.0.29(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(utf-8-validate@6.0.5) + transitivePeerDependencies: + - supports-color + expo-constants@16.0.2(expo@51.0.29(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(utf-8-validate@5.0.10)): dependencies: '@expo/config': 9.0.3 @@ -24457,19 +25794,40 @@ snapshots: transitivePeerDependencies: - supports-color + expo-constants@16.0.2(expo@51.0.29(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(utf-8-validate@6.0.5)): + dependencies: + '@expo/config': 9.0.3 + '@expo/env': 0.3.0 + expo: 51.0.29(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(utf-8-validate@6.0.5) + transitivePeerDependencies: + - supports-color + expo-file-system@17.0.1(expo@51.0.29(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(utf-8-validate@5.0.10)): dependencies: expo: 51.0.29(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(utf-8-validate@5.0.10) + expo-file-system@17.0.1(expo@51.0.29(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(utf-8-validate@6.0.5)): + dependencies: + expo: 51.0.29(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(utf-8-validate@6.0.5) + expo-font@12.0.9(expo@51.0.29(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(utf-8-validate@5.0.10)): dependencies: expo: 51.0.29(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(utf-8-validate@5.0.10) fontfaceobserver: 2.3.0 + expo-font@12.0.9(expo@51.0.29(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(utf-8-validate@6.0.5)): + dependencies: + expo: 51.0.29(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(utf-8-validate@6.0.5) + fontfaceobserver: 2.3.0 + expo-keep-awake@13.0.2(expo@51.0.29(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(utf-8-validate@5.0.10)): dependencies: expo: 51.0.29(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(utf-8-validate@5.0.10) + expo-keep-awake@13.0.2(expo@51.0.29(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(utf-8-validate@6.0.5)): + dependencies: + expo: 51.0.29(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(utf-8-validate@6.0.5) + expo-modules-autolinking@1.11.2: dependencies: chalk: 4.1.0 @@ -24509,6 +25867,31 @@ snapshots: - supports-color - utf-8-validate + expo@51.0.29(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(utf-8-validate@6.0.5): + dependencies: + '@babel/runtime': 7.26.0 + '@expo/cli': 0.18.29(bufferutil@4.0.8)(expo-modules-autolinking@1.11.2)(utf-8-validate@6.0.5) + '@expo/config': 9.0.3 + '@expo/config-plugins': 8.0.8 + '@expo/metro-config': 0.18.11 + '@expo/vector-icons': 14.0.2 + babel-preset-expo: 11.0.14(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0)) + expo-asset: 10.0.10(expo@51.0.29(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(utf-8-validate@6.0.5)) + expo-file-system: 17.0.1(expo@51.0.29(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(utf-8-validate@6.0.5)) + expo-font: 12.0.9(expo@51.0.29(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(utf-8-validate@6.0.5)) + expo-keep-awake: 13.0.2(expo@51.0.29(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(utf-8-validate@6.0.5)) + expo-modules-autolinking: 1.11.2 + expo-modules-core: 1.12.21 + fbemitter: 3.0.0 + whatwg-url-without-unicode: 8.0.0-3 + transitivePeerDependencies: + - '@babel/core' + - '@babel/preset-env' + - bufferutil + - encoding + - supports-color + - utf-8-validate + ext-list@2.2.2: dependencies: mime-db: 1.52.0 @@ -24535,9 +25918,9 @@ snapshots: extendable-error@0.1.7: {} - extension-port-stream@2.1.1(@swc/core@1.4.8): + extension-port-stream@2.1.1(@swc/core@1.4.8)(esbuild@0.19.12): dependencies: - webextension-polyfill: 0.11.0(@swc/core@1.4.8) + webextension-polyfill: 0.11.0(@swc/core@1.4.8)(esbuild@0.19.12) transitivePeerDependencies: - '@swc/core' - '@webpack-cli/generators' @@ -25732,9 +27115,13 @@ snapshots: dependencies: ws: 7.5.10(bufferutil@4.0.8)(utf-8-validate@5.0.10) - isows@1.0.3(ws@8.13.0(bufferutil@4.0.8)(utf-8-validate@5.0.10)): + isomorphic-ws@4.0.1(ws@7.5.10(bufferutil@4.0.8)(utf-8-validate@6.0.5)): + dependencies: + ws: 7.5.10(bufferutil@4.0.8)(utf-8-validate@6.0.5) + + isows@1.0.3(ws@8.13.0(bufferutil@4.0.8)(utf-8-validate@6.0.5)): dependencies: - ws: 8.13.0(bufferutil@4.0.8)(utf-8-validate@5.0.10) + ws: 8.13.0(bufferutil@4.0.8)(utf-8-validate@6.0.5) isows@1.0.6(ws@8.18.0(bufferutil@4.0.8)(utf-8-validate@5.0.10)): dependencies: @@ -25774,6 +27161,24 @@ snapshots: - bufferutil - utf-8-validate + jayson@4.1.1(bufferutil@4.0.8)(utf-8-validate@6.0.5): + dependencies: + '@types/connect': 3.4.38 + '@types/node': 12.20.55 + '@types/ws': 7.4.7 + JSONStream: 1.3.5 + commander: 2.20.3 + delay: 5.0.0 + es6-promisify: 5.0.0 + eyes: 0.1.8 + isomorphic-ws: 4.0.1(ws@7.5.10(bufferutil@4.0.8)(utf-8-validate@6.0.5)) + json-stringify-safe: 5.0.1 + uuid: 8.3.2 + ws: 7.5.10(bufferutil@4.0.8)(utf-8-validate@6.0.5) + transitivePeerDependencies: + - bufferutil + - utf-8-validate + jest-environment-node@29.7.0: dependencies: '@jest/environment': 29.7.0 @@ -26645,7 +28050,7 @@ snapshots: metro-babel-transformer: 0.80.8 metro-cache: 0.80.8 metro-cache-key: 0.80.8 - metro-config: 0.80.8(bufferutil@4.0.8)(utf-8-validate@5.0.10) + metro-config: 0.80.8(bufferutil@4.0.8)(utf-8-validate@6.0.5) metro-core: 0.80.8 metro-file-map: 0.80.8 metro-resolver: 0.80.8 @@ -26838,9 +28243,9 @@ snapshots: minipass: 3.3.6 yallist: 4.0.0 - mipd@0.0.5(bufferutil@4.0.8)(typescript@5.5.4)(utf-8-validate@5.0.10)(zod@3.23.8): + mipd@0.0.5(bufferutil@4.0.8)(typescript@5.5.4)(utf-8-validate@6.0.5)(zod@3.23.8): dependencies: - viem: 1.21.4(bufferutil@4.0.8)(typescript@5.5.4)(utf-8-validate@5.0.10)(zod@3.23.8) + viem: 1.21.4(bufferutil@4.0.8)(typescript@5.5.4)(utf-8-validate@6.0.5)(zod@3.23.8) optionalDependencies: typescript: 5.5.4 transitivePeerDependencies: @@ -27958,7 +29363,7 @@ snapshots: i18next: 19.7.0 react: 18.2.0 - react-i18next@13.5.0(i18next@22.5.1)(react-dom@18.2.0(react@18.2.0))(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@5.0.10))(react@18.2.0): + react-i18next@13.5.0(i18next@22.5.1)(react-dom@18.2.0(react@18.2.0))(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@6.0.5))(react@18.2.0): dependencies: '@babel/runtime': 7.26.0 html-parse-stringify: 3.0.1 @@ -27966,7 +29371,7 @@ snapshots: react: 18.2.0 optionalDependencies: react-dom: 18.2.0(react@18.2.0) - react-native: 0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@5.0.10) + react-native: 0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@6.0.5) react-is@16.13.1: {} @@ -27985,12 +29390,12 @@ snapshots: react-lifecycles-compat: 3.0.4 warning: 4.0.3 - react-native-webview@11.26.1(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@5.0.10))(react@18.2.0): + react-native-webview@11.26.1(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@6.0.5))(react@18.2.0): dependencies: escape-string-regexp: 2.0.0 invariant: 2.2.4 react: 18.2.0 - react-native: 0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@5.0.10) + react-native: 0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@6.0.5) react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@5.0.10): dependencies: @@ -28612,6 +30017,24 @@ snapshots: - supports-color - utf-8-validate + ripple-lib@1.10.1(bufferutil@4.0.8)(utf-8-validate@6.0.5): + dependencies: + '@types/lodash': 4.14.168 + '@types/ws': 7.4.7 + bignumber.js: 9.0.1 + https-proxy-agent: 5.0.1 + jsonschema: 1.2.2 + lodash: 4.17.21 + ripple-address-codec: 4.3.1 + ripple-binary-codec: 1.11.0 + ripple-keypairs: 1.3.1 + ripple-lib-transactionparser: 0.8.2 + ws: 7.5.10(bufferutil@4.0.8)(utf-8-validate@6.0.5) + transitivePeerDependencies: + - bufferutil + - supports-color + - utf-8-validate + rlp@2.2.7: dependencies: bn.js: 5.2.1 @@ -28714,6 +30137,12 @@ snapshots: '@solana/web3.js': 1.95.4(bufferutil@4.0.8)(utf-8-validate@5.0.10) eventemitter3: 4.0.7 + salmon-adapter-sdk@1.1.1(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5)): + dependencies: + '@project-serum/sol-wallet-adapter': 0.2.6(@solana/web3.js@1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5)) + '@solana/web3.js': 1.95.4(bufferutil@4.0.8)(utf-8-validate@6.0.5) + eventemitter3: 4.0.7 + sanitize.css@12.0.1: {} sax@1.4.1: {} @@ -29561,16 +30990,17 @@ snapshots: ansi-escapes: 4.3.2 supports-hyperlinks: 2.3.0 - terser-webpack-plugin@5.3.10(@swc/core@1.4.8)(webpack@5.91.0(@swc/core@1.4.8)(webpack-cli@5.1.4)): + terser-webpack-plugin@5.3.10(@swc/core@1.4.8)(esbuild@0.19.12)(webpack@5.91.0(@swc/core@1.4.8)(esbuild@0.19.12)(webpack-cli@5.1.4)): dependencies: '@jridgewell/trace-mapping': 0.3.25 jest-worker: 27.5.1 schema-utils: 3.3.0 serialize-javascript: 6.0.2 terser: 5.30.3 - webpack: 5.91.0(@swc/core@1.4.8)(webpack-cli@5.1.4) + webpack: 5.91.0(@swc/core@1.4.8)(esbuild@0.19.12)(webpack-cli@5.1.4) optionalDependencies: '@swc/core': 1.4.8(@swc/helpers@0.5.12) + esbuild: 0.19.12 terser-webpack-plugin@5.3.10(webpack@5.91.0(webpack-cli@5.1.4)): dependencies: @@ -29750,7 +31180,7 @@ snapshots: tslib@2.6.2: {} - tsup@8.0.2(@swc/core@1.4.8)(postcss@8.4.41)(typescript@5.5.4): + tsup@8.0.2(@swc/core@1.4.8(@swc/helpers@0.5.12))(postcss@8.4.41)(typescript@5.7.2): dependencies: bundle-require: 4.0.2(esbuild@0.19.12) cac: 6.7.14 @@ -29769,12 +31199,12 @@ snapshots: optionalDependencies: '@swc/core': 1.4.8(@swc/helpers@0.5.12) postcss: 8.4.41 - typescript: 5.5.4 + typescript: 5.7.2 transitivePeerDependencies: - supports-color - ts-node - tsup@8.0.2(@swc/core@1.4.8)(postcss@8.4.41)(typescript@5.7.2): + tsup@8.0.2(@swc/core@1.4.8)(postcss@8.4.41)(typescript@5.5.4): dependencies: bundle-require: 4.0.2(esbuild@0.19.12) cac: 6.7.14 @@ -29793,7 +31223,7 @@ snapshots: optionalDependencies: '@swc/core': 1.4.8(@swc/helpers@0.5.12) postcss: 8.4.41 - typescript: 5.7.2 + typescript: 5.5.4 transitivePeerDependencies: - supports-color - ts-node @@ -30198,7 +31628,7 @@ snapshots: d3-time: 3.1.0 d3-timer: 3.0.1 - viem@1.21.4(bufferutil@4.0.8)(typescript@5.5.4)(utf-8-validate@5.0.10)(zod@3.23.8): + viem@1.21.4(bufferutil@4.0.8)(typescript@5.5.4)(utf-8-validate@6.0.5)(zod@3.23.8): dependencies: '@adraffy/ens-normalize': 1.10.0 '@noble/curves': 1.2.0 @@ -30206,8 +31636,8 @@ snapshots: '@scure/bip32': 1.3.2 '@scure/bip39': 1.2.1 abitype: 0.9.8(typescript@5.5.4)(zod@3.23.8) - isows: 1.0.3(ws@8.13.0(bufferutil@4.0.8)(utf-8-validate@5.0.10)) - ws: 8.13.0(bufferutil@4.0.8)(utf-8-validate@5.0.10) + isows: 1.0.3(ws@8.13.0(bufferutil@4.0.8)(utf-8-validate@6.0.5)) + ws: 8.13.0(bufferutil@4.0.8)(utf-8-validate@6.0.5) optionalDependencies: typescript: 5.5.4 transitivePeerDependencies: @@ -30487,14 +31917,14 @@ snapshots: - webpack-dev-server - zod - wagmi@2.5.20(@react-native-async-storage/async-storage@1.23.1(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@5.0.10)))(@swc/core@1.4.8)(@tanstack/query-core@5.29.0)(@tanstack/react-query@5.29.2(react@18.2.0))(@types/react@18.2.67)(bufferutil@4.0.8)(immer@10.1.1)(react-dom@18.2.0(react@18.2.0))(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@5.0.10))(react@18.2.0)(rollup@4.13.0)(typescript@5.5.4)(utf-8-validate@5.0.10)(viem@2.21.50(bufferutil@4.0.8)(typescript@5.5.4)(utf-8-validate@5.0.10)(zod@3.23.8))(zod@3.23.8): + wagmi@2.5.20(@react-native-async-storage/async-storage@1.23.1(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@6.0.5)))(@swc/core@1.4.8)(@tanstack/query-core@5.29.0)(@tanstack/react-query@5.29.2(react@18.2.0))(@types/react@18.2.67)(bufferutil@4.0.8)(esbuild@0.19.12)(immer@10.1.1)(react-dom@18.2.0(react@18.2.0))(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@6.0.5))(react@18.2.0)(rollup@4.13.0)(typescript@5.5.4)(utf-8-validate@6.0.5)(viem@2.21.50(bufferutil@4.0.8)(typescript@5.5.4)(utf-8-validate@6.0.5)(zod@3.23.8))(zod@3.23.8): dependencies: '@tanstack/react-query': 5.29.2(react@18.2.0) - '@wagmi/connectors': 4.1.26(@react-native-async-storage/async-storage@1.23.1(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@5.0.10)))(@swc/core@1.4.8)(@types/react@18.2.67)(@wagmi/core@2.6.17(@tanstack/query-core@5.29.0)(@types/react@18.2.67)(bufferutil@4.0.8)(immer@10.1.1)(react@18.2.0)(typescript@5.5.4)(utf-8-validate@5.0.10)(viem@2.21.50(bufferutil@4.0.8)(typescript@5.5.4)(utf-8-validate@5.0.10)(zod@3.23.8))(zod@3.23.8))(bufferutil@4.0.8)(react-dom@18.2.0(react@18.2.0))(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@5.0.10))(react@18.2.0)(rollup@4.13.0)(typescript@5.5.4)(utf-8-validate@5.0.10)(viem@2.21.50(bufferutil@4.0.8)(typescript@5.5.4)(utf-8-validate@5.0.10)(zod@3.23.8))(zod@3.23.8) - '@wagmi/core': 2.6.17(@tanstack/query-core@5.29.0)(@types/react@18.2.67)(bufferutil@4.0.8)(immer@10.1.1)(react@18.2.0)(typescript@5.5.4)(utf-8-validate@5.0.10)(viem@2.21.50(bufferutil@4.0.8)(typescript@5.5.4)(utf-8-validate@5.0.10)(zod@3.23.8))(zod@3.23.8) + '@wagmi/connectors': 4.1.26(@react-native-async-storage/async-storage@1.23.1(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@6.0.5)))(@swc/core@1.4.8)(@types/react@18.2.67)(@wagmi/core@2.6.17(@tanstack/query-core@5.29.0)(@types/react@18.2.67)(bufferutil@4.0.8)(immer@10.1.1)(react@18.2.0)(typescript@5.5.4)(utf-8-validate@6.0.5)(viem@2.21.50(bufferutil@4.0.8)(typescript@5.5.4)(utf-8-validate@6.0.5)(zod@3.23.8))(zod@3.23.8))(bufferutil@4.0.8)(esbuild@0.19.12)(react-dom@18.2.0(react@18.2.0))(react-native@0.73.7(@babel/core@7.24.0)(@babel/preset-env@7.24.4(@babel/core@7.24.0))(bufferutil@4.0.8)(react@18.2.0)(utf-8-validate@6.0.5))(react@18.2.0)(rollup@4.13.0)(typescript@5.5.4)(utf-8-validate@6.0.5)(viem@2.21.50(bufferutil@4.0.8)(typescript@5.5.4)(utf-8-validate@6.0.5)(zod@3.23.8))(zod@3.23.8) + '@wagmi/core': 2.6.17(@tanstack/query-core@5.29.0)(@types/react@18.2.67)(bufferutil@4.0.8)(immer@10.1.1)(react@18.2.0)(typescript@5.5.4)(utf-8-validate@6.0.5)(viem@2.21.50(bufferutil@4.0.8)(typescript@5.5.4)(utf-8-validate@6.0.5)(zod@3.23.8))(zod@3.23.8) react: 18.2.0 use-sync-external-store: 1.2.0(react@18.2.0) - viem: 2.21.50(bufferutil@4.0.8)(typescript@5.5.4)(utf-8-validate@5.0.10)(zod@3.23.8) + viem: 2.21.50(bufferutil@4.0.8)(typescript@5.5.4)(utf-8-validate@6.0.5)(zod@3.23.8) optionalDependencies: typescript: 5.5.4 transitivePeerDependencies: @@ -30570,9 +32000,9 @@ snapshots: - webpack-bundle-analyzer - webpack-dev-server - webextension-polyfill@0.11.0(@swc/core@1.4.8): + webextension-polyfill@0.11.0(@swc/core@1.4.8)(esbuild@0.19.12): dependencies: - webpack: 5.91.0(@swc/core@1.4.8)(webpack-cli@5.1.4) + webpack: 5.91.0(@swc/core@1.4.8)(esbuild@0.19.12)(webpack-cli@5.1.4) webpack-cli: 5.1.4(webpack@5.91.0) transitivePeerDependencies: - '@swc/core' @@ -30593,9 +32023,9 @@ snapshots: webpack-cli@5.1.4(webpack@5.91.0): dependencies: '@discoveryjs/json-ext': 0.5.7 - '@webpack-cli/configtest': 2.1.1(webpack-cli@5.1.4(webpack@5.91.0))(webpack@5.91.0(@swc/core@1.4.8)(webpack-cli@5.1.4)) - '@webpack-cli/info': 2.0.2(webpack-cli@5.1.4(webpack@5.91.0))(webpack@5.91.0(@swc/core@1.4.8)(webpack-cli@5.1.4)) - '@webpack-cli/serve': 2.0.5(webpack-cli@5.1.4(webpack@5.91.0))(webpack@5.91.0(@swc/core@1.4.8)(webpack-cli@5.1.4)) + '@webpack-cli/configtest': 2.1.1(webpack-cli@5.1.4(webpack@5.91.0))(webpack@5.91.0(@swc/core@1.4.8)(esbuild@0.19.12)(webpack-cli@5.1.4)) + '@webpack-cli/info': 2.0.2(webpack-cli@5.1.4(webpack@5.91.0))(webpack@5.91.0(@swc/core@1.4.8)(esbuild@0.19.12)(webpack-cli@5.1.4)) + '@webpack-cli/serve': 2.0.5(webpack-cli@5.1.4(webpack@5.91.0))(webpack@5.91.0(@swc/core@1.4.8)(esbuild@0.19.12)(webpack-cli@5.1.4)) colorette: 2.0.20 commander: 10.0.1 cross-spawn: 7.0.6 @@ -30604,7 +32034,7 @@ snapshots: import-local: 3.1.0 interpret: 3.1.1 rechoir: 0.8.0 - webpack: 5.91.0(@swc/core@1.4.8)(webpack-cli@5.1.4) + webpack: 5.91.0(@swc/core@1.4.8)(esbuild@0.19.12)(webpack-cli@5.1.4) webpack-merge: 5.10.0 webpack-merge@5.10.0: @@ -30615,7 +32045,7 @@ snapshots: webpack-sources@3.2.3: {} - webpack@5.91.0(@swc/core@1.4.8)(webpack-cli@5.1.4): + webpack@5.91.0(@swc/core@1.4.8)(esbuild@0.19.12)(webpack-cli@5.1.4): dependencies: '@types/eslint-scope': 3.7.7 '@types/estree': 1.0.5 @@ -30638,7 +32068,7 @@ snapshots: neo-async: 2.6.2 schema-utils: 3.3.0 tapable: 2.2.1 - terser-webpack-plugin: 5.3.10(@swc/core@1.4.8)(webpack@5.91.0(@swc/core@1.4.8)(webpack-cli@5.1.4)) + terser-webpack-plugin: 5.3.10(@swc/core@1.4.8)(esbuild@0.19.12)(webpack@5.91.0(@swc/core@1.4.8)(esbuild@0.19.12)(webpack-cli@5.1.4)) watchpack: 2.4.1 webpack-sources: 3.2.3 optionalDependencies: @@ -30829,6 +32259,11 @@ snapshots: bufferutil: 4.0.8 utf-8-validate: 5.0.10 + ws@7.4.6(bufferutil@4.0.8)(utf-8-validate@6.0.5): + optionalDependencies: + bufferutil: 4.0.8 + utf-8-validate: 6.0.5 + ws@7.5.10(bufferutil@4.0.8)(utf-8-validate@5.0.10): optionalDependencies: bufferutil: 4.0.8 @@ -30849,16 +32284,21 @@ snapshots: bufferutil: 4.0.8 utf-8-validate: 6.0.5 - ws@8.13.0(bufferutil@4.0.8)(utf-8-validate@5.0.10): + ws@8.13.0(bufferutil@4.0.8)(utf-8-validate@6.0.5): optionalDependencies: bufferutil: 4.0.8 - utf-8-validate: 5.0.10 + utf-8-validate: 6.0.5 ws@8.17.1(bufferutil@4.0.8)(utf-8-validate@5.0.10): optionalDependencies: bufferutil: 4.0.8 utf-8-validate: 5.0.10 + ws@8.17.1(bufferutil@4.0.8)(utf-8-validate@6.0.5): + optionalDependencies: + bufferutil: 4.0.8 + utf-8-validate: 6.0.5 + ws@8.18.0(bufferutil@4.0.8)(utf-8-validate@5.0.10): optionalDependencies: bufferutil: 4.0.8 From 17b6f807ba4cc18ee102263766a1ba4d38abf9b8 Mon Sep 17 00:00:00 2001 From: swiftcc624 Date: Fri, 10 Jan 2025 10:10:01 +0800 Subject: [PATCH 12/33] implement lp functions in IconXWalletClient --- .../components/WalletModal/HistoryItem.tsx | 4 +- .../xswap/_components/AdvancedSwapDetails.tsx | 4 +- .../trade/xswap/_components/XSwapModal.tsx | 4 +- apps/hswap/src/hooks/useSendXTransaction.ts | 3 +- .../xwagmi/src/hooks/useSendXTransaction.ts | 31 +++++----- packages/xwagmi/src/utils/index.ts | 4 ++ .../src/xcall/zustand/useTransactionStore.tsx | 9 +-- .../src/xchains/icon/IconXWalletClient.ts | 62 +++++++++++++++++-- 8 files changed, 90 insertions(+), 31 deletions(-) diff --git a/apps/hswap/src/app/components/WalletModal/HistoryItem.tsx b/apps/hswap/src/app/components/WalletModal/HistoryItem.tsx index 58bd693b8..6b1d05e00 100644 --- a/apps/hswap/src/app/components/WalletModal/HistoryItem.tsx +++ b/apps/hswap/src/app/components/WalletModal/HistoryItem.tsx @@ -3,7 +3,7 @@ import { ExclamationIcon } from '@/app/components2/Icons'; import { Separator } from '@/components/ui/separator'; import { cn } from '@/lib/utils'; import { formatBalance } from '@/utils/formatter'; -import { getNetworkDisplayName, getTrackerLink } from '@balancednetwork/xwagmi'; +import { getNetworkDisplayName, getTrackerLink, isIconTransaction } from '@balancednetwork/xwagmi'; import { XTransaction, XTransactionStatus, XTransactionType } from '@balancednetwork/xwagmi'; import { xMessageActions } from '@balancednetwork/xwagmi'; import { CheckIcon, ExternalLink, Loader2Icon, XIcon } from 'lucide-react'; @@ -89,7 +89,7 @@ const HistoryItem = ({ xTransaction }: HistoryItemProps) => { - {xTransactionType !== XTransactionType.SWAP_ON_ICON && ( + {!isIconTransaction(direction.from, direction.to) && (
Bridge Fee diff --git a/apps/hswap/src/app/pages/trade/xswap/_components/XSwapModal.tsx b/apps/hswap/src/app/pages/trade/xswap/_components/XSwapModal.tsx index dadb19d19..385acc17c 100644 --- a/apps/hswap/src/app/pages/trade/xswap/_components/XSwapModal.tsx +++ b/apps/hswap/src/app/pages/trade/xswap/_components/XSwapModal.tsx @@ -11,7 +11,7 @@ import { ApprovalState } from '@/hooks/useApproveCallback'; import { useEvmSwitchChain } from '@/hooks/useEvmSwitchChain'; import { Field } from '@/store/swap/reducer'; import { formatBigNumber } from '@/utils'; -import { xChainMap } from '@balancednetwork/xwagmi'; +import { isIconTransaction, xChainMap } from '@balancednetwork/xwagmi'; import { XToken } from '@balancednetwork/xwagmi'; import { useXCallFee } from '@balancednetwork/xwagmi'; import { XTransactionInput, XTransactionStatus, XTransactionType } from '@balancednetwork/xwagmi'; @@ -164,7 +164,7 @@ const XSwapModal = ({
)} - {xTransactionType !== XTransactionType.SWAP_ON_ICON && ( + {!isIconTransaction(currentXTransaction?.sourceChainId, currentXTransaction?.finalDestinationChainId) && (
Bridge Fee {formattedXCallFee} diff --git a/apps/hswap/src/hooks/useSendXTransaction.ts b/apps/hswap/src/hooks/useSendXTransaction.ts index c0b3fb7b4..f3c7230b5 100644 --- a/apps/hswap/src/hooks/useSendXTransaction.ts +++ b/apps/hswap/src/hooks/useSendXTransaction.ts @@ -10,6 +10,7 @@ import { XTransactionType, allXTokens, getXWalletClient, + isIconTransaction, transactionActions, useSignTransaction, xChainHeightActions, @@ -98,7 +99,7 @@ const sendXTransaction = async (xTransactionInput: XTransactionInput, options: a }; xTransactionActions.add(xTransaction); - if (xTransactionInput.type !== XTransactionType.SWAP_ON_ICON) { + if (!isIconTransaction(sourceChainId, finalDestinationChainId)) { const xMessage: XMessage = { id: `${sourceChainId}/${sourceTransactionHash}`, xTransactionId: xTransaction.id, diff --git a/packages/xwagmi/src/hooks/useSendXTransaction.ts b/packages/xwagmi/src/hooks/useSendXTransaction.ts index cb7a3fab1..b1685a034 100644 --- a/packages/xwagmi/src/hooks/useSendXTransaction.ts +++ b/packages/xwagmi/src/hooks/useSendXTransaction.ts @@ -1,5 +1,6 @@ import { getXWalletClient } from '@/actions'; import { ICON_XCALL_NETWORK_ID, xChainMap } from '@/constants'; +import { isIconTransaction } from '@/utils'; import { transactionActions, xChainHeightActions, xMessageActions, xTransactionActions } from '@/xcall'; import { XMessage, XMessageStatus, XTransaction, XTransactionInput, XTransactionStatus } from '@/xcall/types'; import { useSignTransaction } from '@mysten/dapp-kit'; @@ -51,20 +52,22 @@ const sendXTransaction = async (xTransactionInput: XTransactionInput, options: a }; xTransactionActions.add(xTransaction); - const xMessage: XMessage = { - id: `${sourceChainId}/${sourceTransactionHash}`, - xTransactionId: xTransaction.id, - sourceChainId: sourceChainId, - destinationChainId: primaryDestinationChainId, - sourceTransactionHash, - status: XMessageStatus.REQUESTED, - events: {}, - destinationChainInitialBlockHeight: primaryDestinationChainInitialBlockHeight, - isPrimary: true, - createdAt: now, - useXCallScanner: xChainMap[primaryDestinationChainId].useXCallScanner || xChainMap[sourceChainId].useXCallScanner, - }; - xMessageActions.add(xMessage); + if (!isIconTransaction(sourceChainId, finalDestinationChainId)) { + const xMessage: XMessage = { + id: `${sourceChainId}/${sourceTransactionHash}`, + xTransactionId: xTransaction.id, + sourceChainId: sourceChainId, + destinationChainId: primaryDestinationChainId, + sourceTransactionHash, + status: XMessageStatus.REQUESTED, + events: {}, + destinationChainInitialBlockHeight: primaryDestinationChainInitialBlockHeight, + isPrimary: true, + createdAt: now, + useXCallScanner: xChainMap[primaryDestinationChainId].useXCallScanner || xChainMap[sourceChainId].useXCallScanner, + }; + xMessageActions.add(xMessage); + } return xTransaction.id; }; diff --git a/packages/xwagmi/src/utils/index.ts b/packages/xwagmi/src/utils/index.ts index 483b91454..f087cadee 100644 --- a/packages/xwagmi/src/utils/index.ts +++ b/packages/xwagmi/src/utils/index.ts @@ -204,3 +204,7 @@ export async function validateAddress(address: string, chainId: XChainId): Promi return await isSolanaWalletAddress(address); } } + +export function isIconTransaction(from: XChainId | undefined, to: XChainId | undefined): boolean { + return from === '0x1.icon' || to === '0x1.icon'; +} diff --git a/packages/xwagmi/src/xcall/zustand/useTransactionStore.tsx b/packages/xwagmi/src/xcall/zustand/useTransactionStore.tsx index c5390301c..46ed4a3c6 100644 --- a/packages/xwagmi/src/xcall/zustand/useTransactionStore.tsx +++ b/packages/xwagmi/src/xcall/zustand/useTransactionStore.tsx @@ -11,6 +11,7 @@ import { getXPublicClient } from '@/actions'; // NotificationSuccess, // } from '@/app/components/Notification/TransactionNotification'; import { XChainId } from '@/types'; +import { isIconTransaction } from '@/utils'; import { Transaction, TransactionStatus, XTransactionType } from '@/xcall/types'; import { persist } from 'zustand/middleware'; import { xTransactionActions } from './useXTransactionStore'; @@ -102,8 +103,8 @@ export const transactionActions = { if (_transaction) { if (status === TransactionStatus.success) { const xTransaction = xTransactionActions.get(`${xChainId}/${_transaction.hash}`); - if (xTransaction?.type === XTransactionType.SWAP_ON_ICON) { - xTransactionActions.success(xTransaction.id); + if (isIconTransaction(xTransaction?.sourceChainId, xTransaction?.finalDestinationChainId)) { + xTransaction && xTransactionActions.success(xTransaction.id); } const toastProps = { onClick: () => window.open(getTrackerLink(xChainId, _transaction.hash, 'transaction'), '_blank'), @@ -125,8 +126,8 @@ export const transactionActions = { if (status === TransactionStatus.failure) { const xTransaction = xTransactionActions.get(`${xChainId}/${_transaction.hash}`); - if (xTransaction?.type === XTransactionType.SWAP_ON_ICON) { - xTransactionActions.fail(xTransaction.id); + if (isIconTransaction(xTransaction?.sourceChainId, xTransaction?.finalDestinationChainId)) { + xTransaction && xTransactionActions.fail(xTransaction.id); } const toastProps = { diff --git a/packages/xwagmi/src/xchains/icon/IconXWalletClient.ts b/packages/xwagmi/src/xchains/icon/IconXWalletClient.ts index ff94968a2..452cd24d8 100644 --- a/packages/xwagmi/src/xchains/icon/IconXWalletClient.ts +++ b/packages/xwagmi/src/xchains/icon/IconXWalletClient.ts @@ -180,24 +180,74 @@ export class IconXWalletClient extends XWalletClient { } async depositXToken(xTransactionInput: XTransactionInput): Promise { - throw new Error('Method not implemented.'); + const { account, inputAmount } = xTransactionInput; + + const res: any = await bnJs + .inject({ account }) + .getContract(inputAmount.currency.address) + .deposit(toDec(inputAmount)); + + return res.result; } async withdrawXToken(xTransactionInput: XTransactionInput): Promise { - throw new Error('Method not implemented.'); + const { account, inputAmount } = xTransactionInput; + + const res: any = await bnJs.inject({ account }).Dex.withdraw(inputAmount.currency.address, toDec(inputAmount)); + + return res.result; } async addLiquidity(xTransactionInput: XTransactionInput): Promise { - throw new Error('Method not implemented.'); + const DEFAULT_SLIPPAGE_LP = 200; + const { account, inputAmount, outputAmount } = xTransactionInput; + + if (!outputAmount) { + throw new Error('outputAmount is required'); + } + + const baseToken = inputAmount.currency; + const quoteToken = outputAmount?.currency; + const res: any = await bnJs + .inject({ account }) + .Dex.add(baseToken.address, quoteToken.address, toDec(inputAmount), toDec(outputAmount), DEFAULT_SLIPPAGE_LP); + + return res.result; } + async removeLiquidity(xTransactionInput: XTransactionInput): Promise { - throw new Error('Method not implemented.'); + const { account, inputAmount, poolId } = xTransactionInput; + + if (!poolId) { + throw new Error('poolId is required'); + } + + const res: any = await bnJs.inject({ account }).Dex.remove(poolId, toDec(inputAmount)); + + return res.result; } + async stake(xTransactionInput: XTransactionInput): Promise { - throw new Error('Method not implemented.'); + const { account, inputAmount, poolId } = xTransactionInput; + + if (!poolId) { + throw new Error('poolId is required'); + } + + const res: any = await bnJs.inject({ account: account }).Dex.stake(poolId, toDec(inputAmount)); + return res.result; } async unstake(xTransactionInput: XTransactionInput): Promise { - throw new Error('Method not implemented.'); + const { account, inputAmount, poolId } = xTransactionInput; + + if (!poolId) { + throw new Error('poolId is required'); + } + + const res: any = await bnJs.inject({ account: account }).StakedLP.unstake(poolId, toDec(inputAmount)); + return res.result; } + async claimRewards(xTransactionInput: XTransactionInput): Promise { + // TODO: implement throw new Error('Method not implemented.'); } } From f6727b274f7d49cc8eadef23727418718c639b95 Mon Sep 17 00:00:00 2001 From: swiftcc624 Date: Fri, 10 Jan 2025 10:21:14 +0800 Subject: [PATCH 13/33] fix useHasLiquidity --- .../supply/_components/LiquidityDetails/shared.tsx | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/apps/web/src/app/pages/trade/supply/_components/LiquidityDetails/shared.tsx b/apps/web/src/app/pages/trade/supply/_components/LiquidityDetails/shared.tsx index f66d509e6..3e08701ea 100644 --- a/apps/web/src/app/pages/trade/supply/_components/LiquidityDetails/shared.tsx +++ b/apps/web/src/app/pages/trade/supply/_components/LiquidityDetails/shared.tsx @@ -4,15 +4,13 @@ import ArrowDownIcon from '@/assets/icons/arrow-line.svg'; import { MINIMUM_B_BALANCE_TO_SHOW_POOL } from '@/constants/index'; import { BIGINT_ZERO } from '@/constants/misc'; import { BalancedJs } from '@balancednetwork/balanced-js'; -import { omit } from 'lodash-es'; import { Flex } from 'rebass/styled-components'; import styled from 'styled-components'; import { usePoolPanelContext } from '../PoolPanelContext'; export const useHasLiquidity = (): boolean => { // fetch the reserves for all V2 pools - const { pairs, balances } = usePoolPanelContext(); - + const { pairs, balances, pools } = usePoolPanelContext(); const queuePair = pairs[BalancedJs.utils.POOL_IDS.sICXICX]; const queueBalance = balances[BalancedJs.utils.POOL_IDS.sICXICX]; @@ -22,12 +20,10 @@ export const useHasLiquidity = (): boolean => { (queueBalance.balance.quotient > BIGINT_ZERO || (queueBalance.balance1 && queueBalance.balance1.quotient > BIGINT_ZERO)); - const pairsWithoutQ = omit(pairs, [BalancedJs.utils.POOL_IDS.sICXICX]); - const userPools = Object.keys(pairsWithoutQ).filter( - poolId => - balances[poolId] && - (Number(balances[poolId].balance.toFixed()) > MINIMUM_B_BALANCE_TO_SHOW_POOL || - Number(balances[poolId].stakedLPBalance.toFixed()) > MINIMUM_B_BALANCE_TO_SHOW_POOL), + const userPools = pools.filter( + pool => + Number(pool.balance.toFixed()) > MINIMUM_B_BALANCE_TO_SHOW_POOL || + Number(pool.stakedLPBalance?.toFixed()) > MINIMUM_B_BALANCE_TO_SHOW_POOL, ); return !!shouldShowQueue || !!userPools.length; From d725c385f4cc895a36f8f9d81cd93e14d267ed98 Mon Sep 17 00:00:00 2001 From: swiftcc624 Date: Fri, 10 Jan 2025 10:39:15 +0800 Subject: [PATCH 14/33] fix liquidity pool list --- .../supply/_components/LiquidityDetails.tsx | 37 +++++++++---------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/apps/web/src/app/pages/trade/supply/_components/LiquidityDetails.tsx b/apps/web/src/app/pages/trade/supply/_components/LiquidityDetails.tsx index a6989fc1b..59894a9fa 100644 --- a/apps/web/src/app/pages/trade/supply/_components/LiquidityDetails.tsx +++ b/apps/web/src/app/pages/trade/supply/_components/LiquidityDetails.tsx @@ -62,14 +62,11 @@ export default function LiquidityDetails() { const pairsWithoutQ = omit(pairs, [BalancedJs.utils.POOL_IDS.sICXICX]); const balancesWithoutQ = omit(balances, [BalancedJs.utils.POOL_IDS.sICXICX]); - const userPools = pools?.filter(x => x.balance.greaterThan(0) || x.stakedLPBalance?.greaterThan(0)) || []; - - // const userPools = Object.keys(pairsWithoutQ).filter( - // poolId => - // balances[poolId] && - // (Number(balances[poolId].balance.toFixed()) > MINIMUM_B_BALANCE_TO_SHOW_POOL || - // Number(balances[poolId].stakedLPBalance.toFixed()) > MINIMUM_B_BALANCE_TO_SHOW_POOL), - // ); + const userPools = pools.filter( + pool => + Number(pool.balance.toFixed()) > MINIMUM_B_BALANCE_TO_SHOW_POOL || + Number(pool.stakedLPBalance?.toFixed()) > MINIMUM_B_BALANCE_TO_SHOW_POOL, + ); // const sortedPairs: { [key: string]: Pair } = userPools // .map(poolId => { @@ -175,28 +172,30 @@ export default function LiquidityDetails() { )} {balancesWithoutQ && - userPools.map(({ poolId }, index) => ( - + userPools.map((pool, index) => ( + setIsHided(false)}> x.poolId === poolId)!} - pair={pairs[poolId]} - pairData={allPairs && allPairs[poolId]} + poolId={pool.poolId} + pool={pool} + pair={pairs[pool.poolId]} + pairData={allPairs && allPairs[pool.poolId]} //hotfix due to the fact that sICX/BTCB pair has wrong name on contract side totalReward={ - allPairs && allPairs[poolId] - ? rewards[allPairs[poolId].name === 'sICX/BTCB' ? 'BTCB/sICX' : allPairs[poolId].name] + allPairs && allPairs[pool.poolId] + ? rewards[ + allPairs[pool.poolId].name === 'sICX/BTCB' ? 'BTCB/sICX' : allPairs[pool.poolId].name + ] : new BigNumber(0) } boostData={sources} - apy={allPairs && allPairs[poolId] ? allPairs[poolId].balnApy : 0} + apy={allPairs && allPairs[pool.poolId] ? allPairs[pool.poolId].balnApy : 0} /> From 5bd625d1e5dde72b7665f95f2b65e246104a0945 Mon Sep 17 00:00:00 2001 From: swiftcc624 Date: Fri, 10 Jan 2025 11:10:11 +0800 Subject: [PATCH 15/33] supply modal ui --- .../supply/_components/SendRemoveXToken.tsx | 2 - .../_components/SupplyLiquidityModal.tsx | 58 +++++++++++++------ apps/web/src/hooks/useV2Pairs.ts | 2 +- 3 files changed, 40 insertions(+), 22 deletions(-) diff --git a/apps/web/src/app/pages/trade/supply/_components/SendRemoveXToken.tsx b/apps/web/src/app/pages/trade/supply/_components/SendRemoveXToken.tsx index 828f00a38..f863fde8b 100644 --- a/apps/web/src/app/pages/trade/supply/_components/SendRemoveXToken.tsx +++ b/apps/web/src/app/pages/trade/supply/_components/SendRemoveXToken.tsx @@ -71,8 +71,6 @@ export function SendRemoveXToken({ field, currencies, parsedAmounts }: SendRemov console.error('error', error); setIsPending(false); } - - // setIsPending(false); }; const handleRemove = async () => { diff --git a/apps/web/src/app/pages/trade/supply/_components/SupplyLiquidityModal.tsx b/apps/web/src/app/pages/trade/supply/_components/SupplyLiquidityModal.tsx index 5c43f84c8..e4c03e80e 100644 --- a/apps/web/src/app/pages/trade/supply/_components/SupplyLiquidityModal.tsx +++ b/apps/web/src/app/pages/trade/supply/_components/SupplyLiquidityModal.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import React, { useEffect } from 'react'; import { useIconReact } from '@/packages/icon-react'; import { Currency, CurrencyAmount, Token } from '@balancednetwork/sdk-core'; @@ -19,12 +19,15 @@ import { toDec } from '@/utils'; import { showMessageOnBeforeUnload } from '@/utils/messages'; import { XToken, + XTransactionStatus, bnJs, getXChainType, useXAccount, useXAddLiquidity, useXTokenDepositAmount, + useXTransactionStore, } from '@balancednetwork/xwagmi'; +import { useQueryClient } from '@tanstack/react-query'; import { SendRemoveXToken } from './SendRemoveXToken'; import { supplyMessage } from './utils'; @@ -41,11 +44,26 @@ const getPairName = (currencies: { [field in Field]?: Currency }) => { }; export default function SupplyLiquidityModal({ isOpen, onClose, parsedAmounts, currencies }: ModalProps) { - const addTransaction = useTransactionAdder(); - + const queryClient = useQueryClient(); const { pair } = useDerivedMintInfo(); - const [confirmTx, setConfirmTx] = React.useState(''); + const [isPending, setIsPending] = React.useState(false); + const [pendingTx, setPendingTx] = React.useState(''); + const currentXTransaction = useXTransactionStore(state => state.transactions[pendingTx]); + + useEffect(() => { + if (currentXTransaction?.status === XTransactionStatus.success) { + onClose(); + queryClient.invalidateQueries({ queryKey: ['pools'] }); + } + + if ( + currentXTransaction?.status === XTransactionStatus.success || + currentXTransaction?.status === XTransactionStatus.failure + ) { + setIsPending(false); + } + }, [currentXTransaction, onClose, queryClient]); const xAccount = useXAccount(getXChainType(currencies[Field.CURRENCY_A]?.xChainId)); const { data: depositAmountA } = useXTokenDepositAmount(xAccount.address, currencies[Field.CURRENCY_A]); @@ -56,10 +74,18 @@ export default function SupplyLiquidityModal({ isOpen, onClose, parsedAmounts, c const handleSupplyConfirm = async () => { window.addEventListener('beforeunload', showMessageOnBeforeUnload); - if (depositAmountA && depositAmountB) { - await xAddLiquidity(xAccount.address, depositAmountA, depositAmountB); + try { + if (depositAmountA && depositAmountB) { + setIsPending(true); + + const txHash = await xAddLiquidity(xAccount.address, depositAmountA, depositAmountB); + if (txHash) setPendingTx(txHash); + else setIsPending(false); + } + } catch (error) { + console.error('error', error); + setIsPending(false); } - window.removeEventListener('beforeunload', showMessageOnBeforeUnload); // { @@ -94,18 +120,12 @@ export default function SupplyLiquidityModal({ isOpen, onClose, parsedAmounts, c // } }; - const confirmTxStatus = useTransactionStatus(confirmTx); - React.useEffect(() => { - if (confirmTx && confirmTxStatus === TransactionStatus.success) { - onClose(); - } - }, [confirmTx, confirmTxStatus, onClose]); - // refresh Modal UI // biome-ignore lint/correctness/useExhaustiveDependencies: React.useEffect(() => { if (!isOpen) { - setConfirmTx(''); + setIsPending(false); + setPendingTx(''); setHasErrorMessage(false); } }, [isOpen, pair]); @@ -167,12 +187,12 @@ export default function SupplyLiquidityModal({ isOpen, onClose, parsedAmounts, c {pair ? ( - ) : ( - )} diff --git a/apps/web/src/hooks/useV2Pairs.ts b/apps/web/src/hooks/useV2Pairs.ts index aa49720c0..de613db2a 100644 --- a/apps/web/src/hooks/useV2Pairs.ts +++ b/apps/web/src/hooks/useV2Pairs.ts @@ -342,7 +342,7 @@ export interface Pool { export function usePools(pairs: { [poolId: number]: Pair }, accounts: string[]): Pool[] | undefined { const { data: balances } = useQuery({ - queryKey: ['lpBalances', pairs, accounts], + queryKey: ['pools', pairs, accounts], queryFn: async (): Promise => { if (!accounts.length) return []; From cd32349e2b9ba3958c6c1f92d2d32e36b7b1aa93 Mon Sep 17 00:00:00 2001 From: swiftcc624 Date: Fri, 10 Jan 2025 16:58:34 +0800 Subject: [PATCH 16/33] use all signed accounts to get pools --- apps/web/src/app/pages/trade/supply/page.tsx | 11 ++++--- .../src/xchains/evm/EvmXWalletClient.ts | 30 ++++++------------- 2 files changed, 16 insertions(+), 25 deletions(-) diff --git a/apps/web/src/app/pages/trade/supply/page.tsx b/apps/web/src/app/pages/trade/supply/page.tsx index 2e67e1ab7..55d0fbb8d 100644 --- a/apps/web/src/app/pages/trade/supply/page.tsx +++ b/apps/web/src/app/pages/trade/supply/page.tsx @@ -7,6 +7,7 @@ import LiquidityPoolsPanel from './_components/LiquidityPoolsPanel'; import { PoolPanelContext } from './_components/PoolPanelContext'; import { useAvailablePairs, useBalances, usePools } from '@/hooks/useV2Pairs'; +import { useSignedInWallets } from '@/hooks/useWallets'; import { useTrackedTokenPairs } from '@/store/user/hooks'; export function SupplyPage() { @@ -20,10 +21,12 @@ export function SupplyPage() { // fetch the user's balances of all tracked V2 LP tokens const balances = useBalances(account, pairs); - const pools = usePools(pairs, [ - `0x1.icon/hxe25ae17a21883803185291baddac0120493ff706`, - `0xa4b1.arbitrum/0x6C5F91FD68Dd7b3A1aedB0F09946659272f523a4`, - ]); + const signedWallets = useSignedInWallets(); + const accounts = useMemo( + () => signedWallets.filter(wallet => wallet.address).map(wallet => `${wallet.xChainId}/${wallet.address}`), + [signedWallets], + ); + const pools = usePools(pairs, accounts); const data = useMemo( () => ({ diff --git a/packages/xwagmi/src/xchains/evm/EvmXWalletClient.ts b/packages/xwagmi/src/xchains/evm/EvmXWalletClient.ts index f175d5d3b..7c3df2457 100644 --- a/packages/xwagmi/src/xchains/evm/EvmXWalletClient.ts +++ b/packages/xwagmi/src/xchains/evm/EvmXWalletClient.ts @@ -384,27 +384,15 @@ export class EvmXWalletClient extends XWalletClient { ]), ); - const _isSpokeToken = isSpokeToken(inputAmount.currency); - const isNative = inputAmount.currency.isNativeToken; - - let hash; - if (_isSpokeToken) { - const res = await publicClient.simulateContract({ - account: account as Address, - address: xChainMap[this.xChainId].contracts.xCall as Address, - abi: xCallContractAbi, - functionName: 'sendCall', - args: [destination, envelope], - value: xCallFee.rollback, - }); - hash = await walletClient.writeContract(res.request); - } else { - if (!isNative) { - throw new Error('not implemented'); - } else { - throw new Error('not implemented'); - } - } + const res = await publicClient.simulateContract({ + account: account as Address, + address: xChainMap[this.xChainId].contracts.xCall as Address, + abi: xCallContractAbi, + functionName: 'sendCall', + args: [destination, envelope], + value: xCallFee.rollback, + }); + const hash = await walletClient.writeContract(res.request); return hash; } From 9c6b25f086f8908788cf838a2b1a7d0061190c10 Mon Sep 17 00:00:00 2001 From: swiftcc624 Date: Fri, 10 Jan 2025 18:43:46 +0800 Subject: [PATCH 17/33] orverride lessThan, equalTo, greaterThan in CurrencyAmount class for comparing 2 instances with different decimalScale --- .../src/entities/fractions/currencyAmount.ts | 33 ++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/packages/sdk-core/src/entities/fractions/currencyAmount.ts b/packages/sdk-core/src/entities/fractions/currencyAmount.ts index fdb420da0..c77642eeb 100644 --- a/packages/sdk-core/src/entities/fractions/currencyAmount.ts +++ b/packages/sdk-core/src/entities/fractions/currencyAmount.ts @@ -2,7 +2,7 @@ import _Big from 'big.js'; import invariant from 'tiny-invariant'; import toFormat from 'toformat'; -import { BigintIsh, Rounding, MaxUint256 } from '../../constants'; +import { BigintIsh, MaxUint256, Rounding } from '../../constants'; import { Currency } from '../currency'; import { Token } from '../token'; import { Fraction } from './fraction'; @@ -91,4 +91,35 @@ export class CurrencyAmount extends Fraction { if (this.currency.isToken) return this as CurrencyAmount; return CurrencyAmount.fromFractionalAmount(this.currency.wrapped, this.numerator, this.denominator); } + + //override the following methods from Fraction + public lessThan(other: Fraction | BigintIsh): boolean { + if (other instanceof CurrencyAmount) { + const thisFraction = new Fraction(this.numerator, this.denominator).divide(this.decimalScale); + const otherFraction = new Fraction(other.numerator, other.denominator).divide(other.decimalScale); + return thisFraction.lessThan(otherFraction); + } else { + return super.lessThan(other); + } + } + + public equalTo(other: Fraction | BigintIsh): boolean { + if (other instanceof CurrencyAmount) { + const thisFraction = new Fraction(this.numerator, this.denominator).divide(this.decimalScale); + const otherFraction = new Fraction(other.numerator, other.denominator).divide(other.decimalScale); + return thisFraction.equalTo(otherFraction); + } else { + return super.equalTo(other); + } + } + + public greaterThan(other: Fraction | BigintIsh): boolean { + if (other instanceof CurrencyAmount) { + const thisFraction = new Fraction(this.numerator, this.denominator).divide(this.decimalScale); + const otherFraction = new Fraction(other.numerator, other.denominator).divide(other.decimalScale); + return thisFraction.greaterThan(otherFraction); + } else { + return super.greaterThan(other); + } + } } From ad69868d1b302c9286b56171e71b02d825c9810c Mon Sep 17 00:00:00 2001 From: swiftcc624 Date: Fri, 10 Jan 2025 18:58:26 +0800 Subject: [PATCH 18/33] fix LPPanel --- .../app/pages/trade/supply/_components/LPPanel.tsx | 13 ++++++++++++- apps/web/src/utils/index.ts | 14 +++++++------- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/apps/web/src/app/pages/trade/supply/_components/LPPanel.tsx b/apps/web/src/app/pages/trade/supply/_components/LPPanel.tsx index ed2124171..86c81fa6a 100644 --- a/apps/web/src/app/pages/trade/supply/_components/LPPanel.tsx +++ b/apps/web/src/app/pages/trade/supply/_components/LPPanel.tsx @@ -39,7 +39,18 @@ function subtract( ): CurrencyAmount | undefined { if (!amountA) return undefined; if (!amountB) return amountA; - const diff = new Fraction(`${amountA.quotient}`).subtract(new Fraction(`${amountB.quotient}`)); + + let diff; + if (amountA.decimalScale !== amountB.decimalScale) { + // TODO: use the defined function in utils + const amountBConverted = CurrencyAmount.fromRawAmount( + amountA.currency, + new BigNumber(amountB.toFixed()).times((10n ** BigInt(amountA.currency.decimals)).toString()).toFixed(0), + ); + diff = new Fraction(amountA.numerator).subtract(amountBConverted); + } else { + diff = new Fraction(`${amountA.quotient}`).subtract(new Fraction(`${amountB.quotient}`)); + } return CurrencyAmount.fromRawAmount(amountA.currency, diff.quotient); } diff --git a/apps/web/src/utils/index.ts b/apps/web/src/utils/index.ts index faaffd794..5c7e55eb8 100644 --- a/apps/web/src/utils/index.ts +++ b/apps/web/src/utils/index.ts @@ -11,7 +11,7 @@ import { COMBINED_TOKENS_LIST } from '@/constants/tokens'; import { PairData, PairState } from '@/hooks/useV2Pairs'; import { Field } from '@/store/swap/reducer'; import { PairInfo } from '@/types'; -import { xChainMap } from '@balancednetwork/xwagmi'; +import { XToken, xChainMap } from '@balancednetwork/xwagmi'; import { XChainId } from '@balancednetwork/xwagmi'; import { Validator } from 'icon-sdk-js'; @@ -94,13 +94,12 @@ export function maxAmountSpend( ): CurrencyAmount | undefined { if (!currencyAmount) return undefined; - let minCurrencyGas: CurrencyAmount = CurrencyAmount.fromRawAmount(currencyAmount?.currency, 0); + if (currencyAmount.currency instanceof XToken) { + xChainId = currencyAmount.currency.xChainId; + } - if ( - (xChainId === '0x1.icon' && currencyAmount.currency.symbol === 'ICX') || - (xChainId === 'archway-1' && currencyAmount.currency.symbol === 'ARCH') || - currencyAmount.currency.isNativeToken - ) { + let minCurrencyGas: CurrencyAmount = CurrencyAmount.fromRawAmount(currencyAmount?.currency, 0); + if (currencyAmount.currency.isNativeToken) { minCurrencyGas = CurrencyAmount.fromRawAmount( currencyAmount.currency, new BigNumber(xChainMap[xChainId].gasThreshold) @@ -109,6 +108,7 @@ export function maxAmountSpend( .toString(), ); } + return currencyAmount.subtract(minCurrencyGas).greaterThan(0) ? currencyAmount.subtract(minCurrencyGas) : CurrencyAmount.fromRawAmount(currencyAmount.currency, 0n); From 4b2ace507c9638829954bcab7de5890a6572b09c Mon Sep 17 00:00:00 2001 From: swiftcc624 Date: Fri, 10 Jan 2025 23:47:12 +0800 Subject: [PATCH 19/33] crosschain lp - SuiXWalletClient --- .../xwagmi/src/hooks/useSendXTransaction.ts | 15 +- packages/xwagmi/src/utils/index.ts | 2 +- .../src/xchains/evm/EvmXWalletClient.ts | 9 +- packages/xwagmi/src/xchains/evm/utils.ts | 18 +- .../src/xchains/sui/SuiXWalletClient.ts | 563 +++++++----------- 5 files changed, 231 insertions(+), 376 deletions(-) diff --git a/packages/xwagmi/src/hooks/useSendXTransaction.ts b/packages/xwagmi/src/hooks/useSendXTransaction.ts index b1685a034..1881e4bc2 100644 --- a/packages/xwagmi/src/hooks/useSendXTransaction.ts +++ b/packages/xwagmi/src/hooks/useSendXTransaction.ts @@ -3,10 +3,9 @@ import { ICON_XCALL_NETWORK_ID, xChainMap } from '@/constants'; import { isIconTransaction } from '@/utils'; import { transactionActions, xChainHeightActions, xMessageActions, xTransactionActions } from '@/xcall'; import { XMessage, XMessageStatus, XTransaction, XTransactionInput, XTransactionStatus } from '@/xcall/types'; -import { useSignTransaction } from '@mysten/dapp-kit'; import { useMemo } from 'react'; -const sendXTransaction = async (xTransactionInput: XTransactionInput, options: any) => { +const sendXTransaction = async (xTransactionInput: XTransactionInput) => { const { direction } = xTransactionInput; const sourceChainId = direction.from; @@ -17,7 +16,7 @@ const sendXTransaction = async (xTransactionInput: XTransactionInput, options: a console.log('xTransactionInput', xTransactionInput); - const sourceTransactionHash = await srcXWalletClient.executeTransaction(xTransactionInput, options); + const sourceTransactionHash = await srcXWalletClient.executeTransaction(xTransactionInput); if (!sourceTransactionHash) { return; } @@ -73,13 +72,5 @@ const sendXTransaction = async (xTransactionInput: XTransactionInput, options: a }; export const useSendXTransaction = () => { - const { mutateAsync: signTransaction } = useSignTransaction(); - - return useMemo( - () => ({ - sendXTransaction: (xTransactionInput: XTransactionInput) => - sendXTransaction(xTransactionInput, { signTransaction }), - }), - [signTransaction], - ); + return useMemo(() => ({ sendXTransaction }), []); }; diff --git a/packages/xwagmi/src/utils/index.ts b/packages/xwagmi/src/utils/index.ts index f087cadee..329208e25 100644 --- a/packages/xwagmi/src/utils/index.ts +++ b/packages/xwagmi/src/utils/index.ts @@ -206,5 +206,5 @@ export async function validateAddress(address: string, chainId: XChainId): Promi } export function isIconTransaction(from: XChainId | undefined, to: XChainId | undefined): boolean { - return from === '0x1.icon' || to === '0x1.icon'; + return from === '0x1.icon' && to === '0x1.icon'; } diff --git a/packages/xwagmi/src/xchains/evm/EvmXWalletClient.ts b/packages/xwagmi/src/xchains/evm/EvmXWalletClient.ts index 7c3df2457..e43577b1d 100644 --- a/packages/xwagmi/src/xchains/evm/EvmXWalletClient.ts +++ b/packages/xwagmi/src/xchains/evm/EvmXWalletClient.ts @@ -15,7 +15,7 @@ import { EvmXService } from './EvmXService'; import { assetManagerContractAbi } from './abis/assetManagerContractAbi'; import { bnUSDContractAbi } from './abis/bnUSDContractAbi'; import { xCallContractAbi } from './abis/xCallContractAbi'; -import { getStakeData, getUnStakeData, getXRemoveData } from './utils'; +import { getStakeData, getUnStakeData, getXRemoveData, tokenData } from './utils'; export class EvmXWalletClient extends XWalletClient { getXService(): EvmXService { @@ -326,12 +326,7 @@ export class EvmXWalletClient extends XWalletClient { const destination = `${ICON_XCALL_NETWORK_ID}/${bnJs.Dex.address}`; const amount = BigInt(inputAmount.quotient.toString()); - const data = toHex( - JSON.stringify({ - method: '_deposit', - params: {}, - }), - ); + const data = toHex(tokenData('_deposit', {})); const _isSpokeToken = isSpokeToken(inputAmount.currency); const isNative = inputAmount.currency.isNativeToken; diff --git a/packages/xwagmi/src/xchains/evm/utils.ts b/packages/xwagmi/src/xchains/evm/utils.ts index b0c88044f..b2a410145 100644 --- a/packages/xwagmi/src/xchains/evm/utils.ts +++ b/packages/xwagmi/src/xchains/evm/utils.ts @@ -1,6 +1,15 @@ import { uintToBytes } from '@/utils'; import { RLP } from '@ethereumjs/rlp'; +export function tokenData(method: string, params: Record): string { + const map = { + method: method, + params: params, + }; + + return JSON.stringify(map); +} + // // add liquidity // function getAddLPData( // baseToken: string, @@ -43,8 +52,7 @@ export function getXRemoveData(poolId: number, lpTokenBalance: bigint, withdraw: return RLP.encode(['xremove', poolId, uintToBytes(lpTokenBalance), withdraw ? uintToBytes(1n) : uintToBytes(0n)]); } -// // withdraw the deposited amount -// function getWithdrawData(token: string, amount: number): Uint8Array { -// let rlpInput: rlp.Input = ['xwithdraw', token, amount]; -// return rlp.encode(rlpInput); -// } +// withdraw the deposited amount +export function getWithdrawData(token: string, amount: bigint): Uint8Array { + return RLP.encode(['xwithdraw', token, amount]); +} diff --git a/packages/xwagmi/src/xchains/sui/SuiXWalletClient.ts b/packages/xwagmi/src/xchains/sui/SuiXWalletClient.ts index 6c58d113c..f91aea942 100644 --- a/packages/xwagmi/src/xchains/sui/SuiXWalletClient.ts +++ b/packages/xwagmi/src/xchains/sui/SuiXWalletClient.ts @@ -1,10 +1,11 @@ -import { Percent } from '@balancednetwork/sdk-core'; +import { Percent, XChainId } from '@balancednetwork/sdk-core'; import bnJs from '../icon/bnJs'; -import { ICON_XCALL_NETWORK_ID, xTokenMap } from '@/constants'; +import { ICON_XCALL_NETWORK_ID, xTokenMap, xTokenMapBySymbol } from '@/constants'; import { FROM_SOURCES, TO_SOURCES, sui } from '@/constants/xChains'; import { XWalletClient } from '@/core/XWalletClient'; +import { XToken } from '@/types'; import { uintToBytes } from '@/utils'; import { RLP } from '@ethereumjs/rlp'; import { bcs } from '@mysten/sui/bcs'; @@ -13,6 +14,8 @@ import { signTransaction } from '@mysten/wallet-standard'; import { toBytes, toHex } from 'viem'; import { XTransactionInput, XTransactionType } from '../../xcall/types'; import { getRlpEncodedSwapData, toICONDecimals } from '../../xcall/utils'; +import { isSpokeToken } from '../archway'; +import { getWithdrawData, tokenData } from '../evm/utils'; import { SuiXService } from './SuiXService'; const addressesMainnet = { @@ -38,6 +41,172 @@ export class SuiXWalletClient extends XWalletClient { return Promise.resolve(undefined); } + private async _signAndExecuteTransactionBlock(txb: Transaction): Promise { + const { bytes, signature } = await signTransaction(this.getXService().suiWallet, { + transaction: txb, + account: this.getXService().suiAccount, + chain: this.getXService().suiAccount.chains[0], + }); + + const txResult = await this.getXService().suiClient.executeTransactionBlock({ + transactionBlock: bytes, + signature, + options: { + showRawEffects: true, + }, + }); + + const { digest: hash } = txResult || {}; + return hash; + } + + private async _deposit({ + amount, + account, + xToken, + destination, + data, + }: { + amount: bigint; + account: string; + xToken: XToken; + destination: string; + data: Uint8Array; + }) { + const coinType = xToken.isNativeToken ? '0x2::sui::SUI' : xToken.address; + + const txb = new Transaction(); + let depositCoin, feeCoin; + + if (xToken.isNativeToken) { + [depositCoin, feeCoin] = txb.splitCoins(txb.gas, [amount, XCALL_FEE_AMOUNT]); + } else { + const coins = ( + await this.getXService().suiClient.getCoins({ + owner: account, + coinType, + }) + )?.data; + if (!coins || coins.length === 0) { + throw new Error('No coins found'); + } else if (coins.length > 1) { + await txb.mergeCoins( + coins[0].coinObjectId, + coins.slice(1).map(coin => coin.coinObjectId), + ); + } + + [depositCoin] = txb.splitCoins(coins[0].coinObjectId, [amount]); + [feeCoin] = txb.splitCoins(txb.gas, [XCALL_FEE_AMOUNT]); + } + + txb.moveCall({ + target: `${addressesMainnet['Balanced Package Id']}::asset_manager::deposit`, + arguments: [ + txb.object(addressesMainnet['Asset Manager Storage']), + txb.object(addressesMainnet['xCall Storage']), + txb.object(addressesMainnet['xCall Manager Storage']), + feeCoin, + depositCoin, + txb.pure(bcs.vector(bcs.string()).serialize([destination])), + txb.pure(bcs.vector(bcs.vector(bcs.u8())).serialize([data])), + ], + typeArguments: [coinType], + }); + + return await this._signAndExecuteTransactionBlock(txb); + } + + private async _crossTransfer({ + amount, + account, + xToken, + destination, + data, + }: { + amount: bigint; + account: string; + xToken: XToken; + destination: string; + data: Uint8Array; + }) { + const coinType = xToken.address; + + const coins = ( + await this.getXService().suiClient.getCoins({ + owner: account, + coinType, + }) + )?.data; + + const txb = new Transaction(); + + if (!coins || coins.length === 0) { + throw new Error('No coins found'); + } else if (coins.length > 1) { + await txb.mergeCoins( + coins[0].coinObjectId, + coins.slice(1).map(coin => coin.coinObjectId), + ); + } + + const [depositCoin] = txb.splitCoins(coins[0].coinObjectId, [amount]); + const [feeCoin] = txb.splitCoins(txb.gas, [XCALL_FEE_AMOUNT]); + + txb.moveCall({ + target: `${addressesMainnet['Balanced Package Id']}::balanced_dollar_crosschain::cross_transfer`, + arguments: [ + txb.object(addressesMainnet['bnUSD Storage']), + txb.object(addressesMainnet['xCall Storage']), + txb.object(addressesMainnet['xCall Manager Storage']), + feeCoin, + depositCoin, + txb.pure(bcs.string().serialize(destination)), + txb.pure(bcs.vector(bcs.vector(bcs.u8())).serialize([data])), + ], + // typeArguments: [], + }); + + return await this._signAndExecuteTransactionBlock(txb); + } + + private async _sendCall({ + sourceChainId, + destinationChainId, + destination, + data, + }: { + sourceChainId: XChainId; + destinationChainId: XChainId; + destination: string; + data: any; + }) { + const envelope = toBytes( + toHex( + RLP.encode([ + Buffer.from([0]), + data, + FROM_SOURCES[sourceChainId]?.map(Buffer.from), + TO_SOURCES[destinationChainId]?.map(Buffer.from), + ]), + ), + ); + + const txb = new Transaction(); + const [feeCoin] = txb.splitCoins(txb.gas, [XCALL_FEE_AMOUNT]); + txb.moveCall({ + target: `${addressesMainnet['xCall Package Id']}::main::send_call_ua`, + arguments: [ + txb.object(addressesMainnet['xCall Storage']), + feeCoin, + txb.pure(bcs.string().serialize(destination)), + txb.pure(bcs.vector(bcs.u8()).serialize(envelope)), + ], + }); + + return await this._signAndExecuteTransactionBlock(txb); + } + async executeSwapOrBridge(xTransactionInput: XTransactionInput) { if (!signTransaction) { throw new Error('signTransaction is required'); @@ -48,6 +217,7 @@ export class SuiXWalletClient extends XWalletClient { const destination = `${ICON_XCALL_NETWORK_ID}/${bnJs.Router.address}`; const receiver = `${direction.to}/${recipient}`; + const amount = BigInt(inputAmount.quotient.toString()); let data; if (type === XTransactionType.SWAP) { @@ -73,147 +243,10 @@ export class SuiXWalletClient extends XWalletClient { throw new Error('Invalid XTransactionType'); } - const isNative = inputAmount.currency.isNativeToken; - const isBnUSD = inputAmount.currency.symbol === 'bnUSD'; - const amount = BigInt(inputAmount.quotient.toString()); - - let txResult; - if (isNative) { - const txb = new Transaction(); - - const [depositCoin, feeCoin] = txb.splitCoins(txb.gas, [amount, XCALL_FEE_AMOUNT]); - txb.moveCall({ - target: `${addressesMainnet['Balanced Package Id']}::asset_manager::deposit`, - arguments: [ - txb.object(addressesMainnet['Asset Manager Storage']), - txb.object(addressesMainnet['xCall Storage']), - txb.object(addressesMainnet['xCall Manager Storage']), - feeCoin, - depositCoin, - txb.pure(bcs.vector(bcs.string()).serialize([destination])), - txb.pure(bcs.vector(bcs.vector(bcs.u8())).serialize([data])), - ], - typeArguments: ['0x2::sui::SUI'], - }); - - const { bytes, signature } = await signTransaction(this.getXService().suiWallet, { - transaction: txb, - account: this.getXService().suiAccount, - chain: this.getXService().suiAccount.chains[0], - }); - - txResult = await this.getXService().suiClient.executeTransactionBlock({ - transactionBlock: bytes, - signature, - options: { - showRawEffects: true, - }, - }); - } else if (isBnUSD) { - const coins = ( - await this.getXService().suiClient.getCoins({ - owner: account, - coinType: inputAmount.currency.wrapped.address, - }) - )?.data; - - const txb = new Transaction(); - - if (!coins || coins.length === 0) { - throw new Error('No coins found'); - } else if (coins.length > 1) { - await txb.mergeCoins( - coins[0].coinObjectId, - coins.slice(1).map(coin => coin.coinObjectId), - ); - } - - const [depositCoin] = txb.splitCoins(coins[0].coinObjectId, [amount]); - const [feeCoin] = txb.splitCoins(txb.gas, [XCALL_FEE_AMOUNT]); - - txb.moveCall({ - target: `${addressesMainnet['Balanced Package Id']}::balanced_dollar_crosschain::cross_transfer`, - arguments: [ - txb.object(addressesMainnet['bnUSD Storage']), - txb.object(addressesMainnet['xCall Storage']), - txb.object(addressesMainnet['xCall Manager Storage']), - feeCoin, - depositCoin, - txb.pure(bcs.string().serialize(destination)), - txb.pure(bcs.vector(bcs.vector(bcs.u8())).serialize([data])), - ], - // typeArguments: [], - }); - - const { bytes, signature } = await signTransaction(this.getXService().suiWallet, { - transaction: txb, - account: this.getXService().suiAccount, - chain: this.getXService().suiAccount.chains[0], - }); - - txResult = await this.getXService().suiClient.executeTransactionBlock({ - transactionBlock: bytes, - signature, - options: { - showRawEffects: true, - }, - }); + if (isSpokeToken(inputAmount.currency)) { + return await this._crossTransfer({ amount, account, xToken: inputAmount.currency, destination, data }); } else { - // USDC - const coins = ( - await this.getXService().suiClient.getCoins({ - owner: account, - coinType: inputAmount.currency.wrapped.address, - }) - )?.data; - - const txb = new Transaction(); - - if (!coins || coins.length === 0) { - throw new Error('No coins found'); - } else if (coins.length > 1) { - await txb.mergeCoins( - coins[0].coinObjectId, - coins.slice(1).map(coin => coin.coinObjectId), - ); - } - - const [depositCoin] = txb.splitCoins(coins[0].coinObjectId, [amount]); - const [feeCoin] = txb.splitCoins(txb.gas, [XCALL_FEE_AMOUNT]); - - txb.moveCall({ - target: `${addressesMainnet['Balanced Package Id']}::asset_manager::deposit`, - arguments: [ - txb.object(addressesMainnet['Asset Manager Storage']), - txb.object(addressesMainnet['xCall Storage']), - txb.object(addressesMainnet['xCall Manager Storage']), - feeCoin, - depositCoin, - txb.pure(bcs.vector(bcs.string()).serialize([destination])), - txb.pure(bcs.vector(bcs.vector(bcs.u8())).serialize([data])), - ], - typeArguments: [inputAmount.currency.wrapped.address], - }); - - const { bytes, signature } = await signTransaction(this.getXService().suiWallet, { - transaction: txb, - account: this.getXService().suiAccount, - chain: this.getXService().suiAccount.chains[0], - }); - - txResult = await this.getXService().suiClient.executeTransactionBlock({ - transactionBlock: bytes, - signature, - options: { - showRawEffects: true, - }, - }); - } - - const { digest: hash } = txResult || {}; - - if (hash) { - return hash; + return await this._deposit({ amount, account, xToken: inputAmount.currency, destination, data }); } } @@ -224,107 +257,11 @@ export class SuiXWalletClient extends XWalletClient { return; } - const isNative = inputAmount.currency.isNativeToken; const amount = BigInt(inputAmount.quotient.toString()); const destination = `${ICON_XCALL_NETWORK_ID}/${bnJs.Loans.address}`; const data = toBytes(JSON.stringify({})); - let txResult; - if (isNative) { - const txb = new Transaction(); - - const [depositCoin, feeCoin] = txb.splitCoins(txb.gas, [amount, XCALL_FEE_AMOUNT]); - txb.moveCall({ - target: `${addressesMainnet['Balanced Package Id']}::asset_manager::deposit`, - arguments: [ - txb.object(addressesMainnet['Asset Manager Storage']), - txb.object(addressesMainnet['xCall Storage']), - txb.object(addressesMainnet['xCall Manager Storage']), - feeCoin, - depositCoin, - txb.pure(bcs.vector(bcs.string()).serialize([destination])), - txb.pure(bcs.vector(bcs.vector(bcs.u8())).serialize([data])), - ], - typeArguments: ['0x2::sui::SUI'], - }); - - const { bytes, signature } = await signTransaction(this.getXService().suiWallet, { - transaction: txb, - account: this.getXService().suiAccount, - chain: this.getXService().suiAccount.chains[0], - }); - - txResult = await this.getXService().suiClient.executeTransactionBlock({ - transactionBlock: bytes, - signature, - options: { - showRawEffects: true, - }, - }); - - // Always report transaction effects to the wallet after execution - // @ts-ignore - reportTransactionEffects(txResult.rawEffects!); - } else { - // VSUI, HASUI, AFSUI - const coins = ( - await this.getXService().suiClient.getCoins({ - owner: account, - coinType: inputAmount.currency.wrapped.address, - }) - )?.data; - - const txb = new Transaction(); - - if (!coins || coins.length === 0) { - throw new Error('No coins found'); - } else if (coins.length > 1) { - await txb.mergeCoins( - coins[0].coinObjectId, - coins.slice(1).map(coin => coin.coinObjectId), - ); - } - - const [depositCoin] = txb.splitCoins(coins[0].coinObjectId, [amount]); - const [feeCoin] = txb.splitCoins(txb.gas, [XCALL_FEE_AMOUNT]); - txb.moveCall({ - target: `${addressesMainnet['Balanced Package Id']}::asset_manager::deposit`, - arguments: [ - txb.object(addressesMainnet['Asset Manager Storage']), - txb.object(addressesMainnet['xCall Storage']), - txb.object(addressesMainnet['xCall Manager Storage']), - feeCoin, - depositCoin, - txb.pure(bcs.vector(bcs.string()).serialize([destination])), - txb.pure(bcs.vector(bcs.vector(bcs.u8())).serialize([data])), - ], - typeArguments: [inputAmount.currency.wrapped.address], - }); - - const { bytes, signature } = await signTransaction(this.getXService().suiWallet, { - transaction: txb, - account: this.getXService().suiAccount, - chain: this.getXService().suiAccount.chains[0], - }); - - txResult = await this.getXService().suiClient.executeTransactionBlock({ - transactionBlock: bytes, - signature, - options: { - showRawEffects: true, - }, - }); - - // Always report transaction effects to the wallet after execution - // @ts-ignore - reportTransactionEffects(txResult.rawEffects!); - } - - const { digest: hash } = txResult || {}; - - if (hash) { - return hash; - } + return await this._deposit({ amount, account, xToken: inputAmount.currency, destination, data }); } async executeWithdrawCollateral(xTransactionInput: XTransactionInput) { @@ -337,52 +274,13 @@ export class SuiXWalletClient extends XWalletClient { const amount = toICONDecimals(inputAmount.multiply(-1)); const destination = `${ICON_XCALL_NETWORK_ID}/${bnJs.Loans.address}`; const data = toHex(RLP.encode(['xWithdraw', uintToBytes(amount), usedCollateral])); - const envelope = toBytes( - toHex( - RLP.encode([ - Buffer.from([0]), - data, - FROM_SOURCES[direction.from]?.map(Buffer.from), - TO_SOURCES[direction.from]?.map(Buffer.from), - ]), - ), - ); - - const txb = new Transaction(); - - console.log("addressesMainnet['xCall Storage']", addressesMainnet['xCall Storage']); - - const [feeCoin] = txb.splitCoins(txb.gas, [XCALL_FEE_AMOUNT]); - txb.moveCall({ - target: `${addressesMainnet['xCall Package Id']}::main::send_call_ua`, - arguments: [ - txb.object(addressesMainnet['xCall Storage']), - feeCoin, - txb.pure(bcs.string().serialize(destination)), - txb.pure(bcs.vector(bcs.u8()).serialize(envelope)), - ], - // typeArguments: ['0x2::sui::SUI'], - }); - const { bytes, signature } = await signTransaction(this.getXService().suiWallet, { - transaction: txb, - account: this.getXService().suiAccount, - chain: this.getXService().suiAccount.chains[0], + return await this._sendCall({ + sourceChainId: direction.from, + destinationChainId: direction.to, + destination, + data, }); - - const txResult = await this.getXService().suiClient.executeTransactionBlock({ - transactionBlock: bytes, - signature, - options: { - showRawEffects: true, - }, - }); - - const { digest: hash } = txResult || {}; - - if (hash) { - return hash; - } } async executeBorrow(xTransactionInput: XTransactionInput) { @@ -401,53 +299,15 @@ export class SuiXWalletClient extends XWalletClient { : ['xBorrow', usedCollateral, uintToBytes(amount)], ), ); - const envelope = toBytes( - toHex( - RLP.encode([ - Buffer.from([0]), - data, - FROM_SOURCES[direction.from]?.map(Buffer.from), - TO_SOURCES[direction.from]?.map(Buffer.from), - ]), - ), - ); - - const txb = new Transaction(); - console.log("addressesMainnet['xCall Storage']", addressesMainnet['xCall Storage']); - - const [feeCoin] = txb.splitCoins(txb.gas, [XCALL_FEE_AMOUNT]); - txb.moveCall({ - target: `${addressesMainnet['xCall Package Id']}::main::send_call_ua`, - arguments: [ - txb.object(addressesMainnet['xCall Storage']), - feeCoin, - txb.pure(bcs.string().serialize(destination)), - txb.pure(bcs.vector(bcs.u8()).serialize(envelope)), - ], - // typeArguments: ['0x2::sui::SUI'], + return await this._sendCall({ + sourceChainId: direction.from, + destinationChainId: direction.to, + destination, + data, }); - - const { bytes, signature } = await signTransaction(this.getXService().suiWallet, { - transaction: txb, - account: this.getXService().suiAccount, - chain: this.getXService().suiAccount.chains[0], - }); - - const txResult = await this.getXService().suiClient.executeTransactionBlock({ - transactionBlock: bytes, - signature, - options: { - showRawEffects: true, - }, - }); - - const { digest: hash } = txResult || {}; - - if (hash) { - return hash; - } } + async executeRepay(xTransactionInput: XTransactionInput) { const { inputAmount, account, xCallFee, usedCollateral, recipient, direction } = xTransactionInput; @@ -468,15 +328,14 @@ export class SuiXWalletClient extends XWalletClient { JSON.stringify(recipient ? { _collateral: usedCollateral, _to: recipient } : { _collateral: usedCollateral }), ); + const txb = new Transaction(); + const coins = ( await this.getXService().suiClient.getCoins({ owner: account, coinType: bnUSD.address, }) )?.data; - - const txb = new Transaction(); - if (!coins || coins.length === 0) { throw new Error('No coins found'); } else if (coins.length > 1) { @@ -507,32 +366,34 @@ export class SuiXWalletClient extends XWalletClient { // typeArguments: [], }); - const { bytes, signature } = await signTransaction(this.getXService().suiWallet, { - transaction: txb, - account: this.getXService().suiAccount, - chain: this.getXService().suiAccount.chains[0], - }); - - const txResult = await this.getXService().suiClient.executeTransactionBlock({ - transactionBlock: bytes, - signature, - options: { - showRawEffects: true, - }, - }); - - const { digest: hash } = txResult || {}; - - if (hash) { - return hash; - } + return await this._signAndExecuteTransactionBlock(txb); } async depositXToken(xTransactionInput: XTransactionInput): Promise { - throw new Error('Method not implemented.'); + const { account, inputAmount, xCallFee } = xTransactionInput; + const destination = `${ICON_XCALL_NETWORK_ID}/${bnJs.Dex.address}`; + const amount = BigInt(inputAmount.quotient.toString()); + const data = toBytes(tokenData('_deposit', {})); + + if (isSpokeToken(inputAmount.currency)) { + return await this._crossTransfer({ amount, account, xToken: inputAmount.currency, destination, data }); + } else { + return await this._deposit({ amount, account, xToken: inputAmount.currency, destination, data }); + } } async withdrawXToken(xTransactionInput: XTransactionInput): Promise { - throw new Error('Method not implemented.'); + const { account, inputAmount, xCallFee, direction } = xTransactionInput; + + const destination = `${ICON_XCALL_NETWORK_ID}/${bnJs.Dex.address}`; + const amount = BigInt(inputAmount.quotient.toString()); + const xTokenOnIcon = xTokenMapBySymbol[ICON_XCALL_NETWORK_ID][inputAmount.currency.symbol]; + const data = getWithdrawData(xTokenOnIcon.address, amount); + return await this._sendCall({ + sourceChainId: direction.from, + destinationChainId: direction.to, + destination, + data, + }); } async addLiquidity(xTransactionInput: XTransactionInput): Promise { throw new Error('Method not implemented.'); From 529068c1b76cc0ceee7bdb074f0b55b489352ab9 Mon Sep 17 00:00:00 2001 From: swiftcc624 Date: Sat, 11 Jan 2025 00:22:07 +0800 Subject: [PATCH 20/33] rewrite EvmXWalletClient --- .../src/xchains/evm/EvmXWalletClient.ts | 511 +++++++----------- packages/xwagmi/src/xchains/evm/utils.ts | 53 +- 2 files changed, 231 insertions(+), 333 deletions(-) diff --git a/packages/xwagmi/src/xchains/evm/EvmXWalletClient.ts b/packages/xwagmi/src/xchains/evm/EvmXWalletClient.ts index e43577b1d..d7e7ed249 100644 --- a/packages/xwagmi/src/xchains/evm/EvmXWalletClient.ts +++ b/packages/xwagmi/src/xchains/evm/EvmXWalletClient.ts @@ -1,9 +1,9 @@ -import { CurrencyAmount, MaxUint256, Percent } from '@balancednetwork/sdk-core'; +import { CurrencyAmount, MaxUint256, Percent, XChainId } from '@balancednetwork/sdk-core'; import { RLP } from '@ethereumjs/rlp'; -import { Address, PublicClient, WalletClient, WriteContractParameters, erc20Abi, getContract, toHex } from 'viem'; +import { Address, PublicClient, WalletClient, erc20Abi, getContract, toHex } from 'viem'; import bnJs from '../icon/bnJs'; -import { ICON_XCALL_NETWORK_ID, xTokenMap, xTokenMapBySymbol } from '@/constants'; +import { ICON_XCALL_NETWORK_ID, xTokenMapBySymbol } from '@/constants'; import { FROM_SOURCES, TO_SOURCES, xChainMap } from '@/constants/xChains'; import { XWalletClient } from '@/core/XWalletClient'; import { XToken } from '@/types'; @@ -15,7 +15,7 @@ import { EvmXService } from './EvmXService'; import { assetManagerContractAbi } from './abis/assetManagerContractAbi'; import { bnUSDContractAbi } from './abis/bnUSDContractAbi'; import { xCallContractAbi } from './abis/xCallContractAbi'; -import { getStakeData, getUnStakeData, getXRemoveData, tokenData } from './utils'; +import { getAddLPData, getStakeData, getUnStakeData, getWithdrawData, getXRemoveData, tokenData } from './utils'; export class EvmXWalletClient extends XWalletClient { getXService(): EvmXService { @@ -64,14 +64,118 @@ export class EvmXWalletClient extends XWalletClient { return hash; } + private async _deposit({ + amount, + account, + xToken, + destination, + data, + fee, + }: { + amount: bigint; + account: string; + xToken: XToken; + destination: string; + data: `0x${string}`; + fee: bigint; + }) { + const walletClient = await this.getWalletClient(); + + if (!xToken.isNativeToken) { + const res = await this.getPublicClient().simulateContract({ + account: account as Address, + address: xChainMap[xToken.xChainId].contracts.assetManager as Address, + abi: assetManagerContractAbi, + functionName: 'deposit', + args: [xToken.address as Address, amount, destination, data], + value: fee, + }); + const hash = await walletClient.writeContract(res.request); + return hash; + } else { + const res = await this.getPublicClient().simulateContract({ + account: account as Address, + address: xChainMap[xToken.xChainId].contracts.assetManager as Address, + abi: assetManagerContractAbi, + functionName: 'depositNative', + args: [amount, destination, data], + value: fee + amount, + }); + const hash = await walletClient.writeContract(res.request); + return hash; + } + } + + private async _crossTransfer({ + amount, + account, + xToken, + destination, + data, + fee, + }: { + amount: bigint; + account: string; + xToken: XToken; + destination: string; + data: `0x${string}`; + fee: bigint; + }) { + const walletClient = await this.getWalletClient(); + + const res = await this.getPublicClient().simulateContract({ + account: account as Address, + address: xToken.address as Address, + abi: bnUSDContractAbi, + functionName: 'crossTransfer', + args: [destination, amount, data], + value: fee, + }); + const hash = await walletClient.writeContract(res.request); + return hash; + } + + private async _sendCall({ + account, + sourceChainId, + destination, + data, + fee, + }: { + account: string; + sourceChainId: XChainId; + destination: string; + data: any; + fee: bigint; + }) { + const envelope = toHex( + RLP.encode([ + Buffer.from([0]), + data, + FROM_SOURCES[sourceChainId]?.map(Buffer.from), + TO_SOURCES[sourceChainId]?.map(Buffer.from), + ]), + ); + + const res = await this.getPublicClient().simulateContract({ + account: account as Address, + address: xChainMap[sourceChainId].contracts.xCall as Address, + abi: xCallContractAbi, + functionName: 'sendCall', + args: [destination, envelope], + value: fee, + }); + + const walletClient = await this.getWalletClient(); + const hash = await walletClient.writeContract(res.request); + return hash; + } + async executeSwapOrBridge(xTransactionInput: XTransactionInput) { const { type, direction, inputAmount, recipient, account, xCallFee, executionTrade, slippageTolerance } = xTransactionInput; - console.log('type', type); - const receiver = `${direction.to}/${recipient}`; - const tokenAddress = inputAmount.wrapped.currency.address; const amount = BigInt(inputAmount.quotient.toString()); const destination = `${ICON_XCALL_NETWORK_ID}/${bnJs.Router.address}`; @@ -101,54 +205,25 @@ export class EvmXWalletClient extends XWalletClient { throw new Error('Invalid XTransactionType'); } - const publicClient = this.getPublicClient(); - const walletClient = await this.getWalletClient(); - - const _isSpokeToken = isSpokeToken(inputAmount.currency); - const isNative = inputAmount.currency.isNativeToken; - - let request: WriteContractParameters; - if (_isSpokeToken) { - const tokenAddr = xTokenMap[direction.from].find(token => token.symbol === inputAmount.currency.symbol)?.address; - const res = await this.getPublicClient().simulateContract({ - account: account as Address, - address: tokenAddr as Address, - abi: bnUSDContractAbi, - functionName: 'crossTransfer', - args: [destination, amount, data], - value: xCallFee.rollback, + if (isSpokeToken(inputAmount.currency)) { + return await this._crossTransfer({ + amount, + account, + xToken: inputAmount.currency, + destination, + data, + fee: xCallFee.rollback, }); - request = res.request; } else { - if (!isNative) { - const res = await this.getPublicClient().simulateContract({ - account: account as Address, - address: xChainMap[direction.from].contracts.assetManager as Address, - abi: assetManagerContractAbi, - functionName: 'deposit', - args: [tokenAddress as Address, amount, destination, data], - value: xCallFee.rollback, - }); - request = res.request; - } else { - const res = await this.getPublicClient().simulateContract({ - account: account as Address, - address: xChainMap[direction.from].contracts.assetManager as Address, - abi: assetManagerContractAbi, - functionName: 'depositNative', - args: [amount, destination, data], - value: xCallFee.rollback + amount, - }); - request = res.request; - } - } - - const hash = await walletClient.writeContract(request); - - if (hash) { - return hash; + return await this._deposit({ + amount, + account, + xToken: inputAmount.currency, + destination, + data, + fee: xCallFee.rollback, + }); } - return undefined; } async executeDepositCollateral(xTransactionInput: XTransactionInput) { @@ -158,43 +233,18 @@ export class EvmXWalletClient extends XWalletClient { return; } - const tokenAddress = inputAmount.wrapped.currency.address; const amount = BigInt(inputAmount.quotient.toString()); const destination = `${ICON_XCALL_NETWORK_ID}/${bnJs.Loans.address}`; const data = toHex(JSON.stringify({})); - const isNative = inputAmount.currency.isNativeToken; - - let request: WriteContractParameters; - if (!isNative) { - const res = await this.getPublicClient().simulateContract({ - account: account as Address, - address: xChainMap[direction.from].contracts.assetManager as Address, - abi: assetManagerContractAbi, - functionName: 'deposit', - args: [tokenAddress as Address, amount, destination, data], - value: xCallFee.rollback, - }); - request = res.request; - } else { - const res = await this.getPublicClient().simulateContract({ - account: account as Address, - address: xChainMap[direction.from].contracts.assetManager as Address, - abi: assetManagerContractAbi, - functionName: 'depositNative', - args: [amount, destination, data], - value: xCallFee.rollback + amount, - }); - request = res.request; - } - - const walletClient = await this.getWalletClient(); - const hash = await walletClient.writeContract(request); - - if (hash) { - return hash; - } - return undefined; + return await this._deposit({ + amount, + account, + xToken: inputAmount.currency, + destination, + data, + fee: xCallFee.rollback, + }); } async executeWithdrawCollateral(xTransactionInput: XTransactionInput) { @@ -207,35 +257,14 @@ export class EvmXWalletClient extends XWalletClient { const amount = toICONDecimals(inputAmount.multiply(-1)); const destination = `${ICON_XCALL_NETWORK_ID}/${bnJs.Loans.address}`; const data = toHex(RLP.encode(['xWithdraw', uintToBytes(amount), usedCollateral])); - const envelope = toHex( - RLP.encode([ - Buffer.from([0]), - data, - FROM_SOURCES[direction.from]?.map(Buffer.from), - TO_SOURCES[direction.from]?.map(Buffer.from), - ]), - ); - const res = await this.getPublicClient().simulateContract({ - account: account as Address, - address: xChainMap[direction.from].contracts.xCall as Address, - abi: xCallContractAbi, - functionName: 'sendCall', - args: [destination, envelope], - //todo - //? rollback or not - value: xCallFee.noRollback, + return await this._sendCall({ + account, + sourceChainId: direction.from, + destination, + data, + fee: xCallFee.rollback, }); - - const request: WriteContractParameters = res.request; - - const walletClient = await this.getWalletClient(); - const hash = await walletClient.writeContract(request); - - if (hash) { - return hash; - } - return undefined; } async executeBorrow(xTransactionInput: XTransactionInput) { @@ -254,35 +283,14 @@ export class EvmXWalletClient extends XWalletClient { : ['xBorrow', usedCollateral, uintToBytes(amount)], ), ); - const envelope = toHex( - RLP.encode([ - Buffer.from([0]), - data, - FROM_SOURCES[direction.from]?.map(Buffer.from), - TO_SOURCES[direction.from]?.map(Buffer.from), - ]), - ); - const res = await this.getPublicClient().simulateContract({ - account: account as Address, - address: xChainMap[direction.from].contracts.xCall as Address, - abi: xCallContractAbi, - functionName: 'sendCall', - args: [destination, envelope], - //todo - //? rollback or not - value: xCallFee.noRollback, + return await this._sendCall({ + account, + sourceChainId: direction.from, + destination, + data, + fee: xCallFee.rollback, }); - - const request: WriteContractParameters = res.request; - - const walletClient = await this.getWalletClient(); - const hash = await walletClient.writeContract(request); - - if (hash) { - return hash; - } - return undefined; } async executeRepay(xTransactionInput: XTransactionInput) { @@ -298,56 +306,43 @@ export class EvmXWalletClient extends XWalletClient { JSON.stringify(recipient ? { _collateral: usedCollateral, _to: recipient } : { _collateral: usedCollateral }), ); - const res = await this.getPublicClient().simulateContract({ - account: account as Address, - address: xChainMap[direction.from].contracts.bnUSD as Address, - abi: bnUSDContractAbi, - functionName: 'crossTransfer', - args: [destination, amount, data], - value: xCallFee.rollback, + return await this._crossTransfer({ + amount, + account, + xToken: inputAmount.currency, + destination, + data, + fee: xCallFee.rollback, }); - - const request: WriteContractParameters = res.request; - const walletClient = await this.getWalletClient(); - const hash = await walletClient.writeContract(request); - - if (hash) { - return hash; - } - return undefined; } // liquidity related async depositXToken(xTransactionInput: XTransactionInput) { const { account, inputAmount, xCallFee } = xTransactionInput; - const publicClient = this.getPublicClient(); - const walletClient = await this.getWalletClient(); - const destination = `${ICON_XCALL_NETWORK_ID}/${bnJs.Dex.address}`; const amount = BigInt(inputAmount.quotient.toString()); const data = toHex(tokenData('_deposit', {})); - const _isSpokeToken = isSpokeToken(inputAmount.currency); - const isNative = inputAmount.currency.isNativeToken; - let hash; - if (_isSpokeToken) { - const res = await publicClient.simulateContract({ - account: account as Address, - address: xTokenMapBySymbol[this.xChainId][inputAmount.currency.symbol].address as Address, - abi: bnUSDContractAbi, - functionName: 'crossTransfer', - args: [destination, amount, data], - value: xCallFee.rollback, + if (isSpokeToken(inputAmount.currency)) { + hash = await this._crossTransfer({ + amount, + account, + xToken: inputAmount.currency, + destination, + data, + fee: xCallFee.rollback, }); - hash = await walletClient.writeContract(res.request); } else { - if (!isNative) { - throw new Error('not implemented'); - } else { - throw new Error('not implemented'); - } + hash = await this._deposit({ + amount, + account, + xToken: inputAmount.currency, + destination, + data, + fee: xCallFee.rollback, + }); } return hash; @@ -356,40 +351,18 @@ export class EvmXWalletClient extends XWalletClient { async withdrawXToken(xTransactionInput: XTransactionInput) { const { account, inputAmount, xCallFee } = xTransactionInput; - const publicClient = this.getPublicClient(); - const walletClient = await this.getWalletClient(); - const destination = `${ICON_XCALL_NETWORK_ID}/${bnJs.Dex.address}`; const amount = BigInt(inputAmount.quotient.toString()); const xTokenOnIcon = xTokenMapBySymbol[ICON_XCALL_NETWORK_ID][inputAmount.currency.symbol]; - const data = toHex( - RLP.encode([ - 'xWithdraw', - xTokenOnIcon.address, // - uintToBytes(amount), - ]), - ); - - const envelope = toHex( - RLP.encode([ - Buffer.from([0]), - data, - FROM_SOURCES[this.xChainId]?.map(Buffer.from), - TO_SOURCES[this.xChainId]?.map(Buffer.from), - ]), - ); - - const res = await publicClient.simulateContract({ - account: account as Address, - address: xChainMap[this.xChainId].contracts.xCall as Address, - abi: xCallContractAbi, - functionName: 'sendCall', - args: [destination, envelope], - value: xCallFee.rollback, + const data = toHex(getWithdrawData(xTokenOnIcon.address, amount)); + + return await this._sendCall({ + account, + sourceChainId: inputAmount.currency.xChainId, + destination, + data, + fee: xCallFee.rollback, }); - const hash = await walletClient.writeContract(res.request); - - return hash; } async addLiquidity(xTransactionInput: XTransactionInput) { @@ -399,46 +372,20 @@ export class EvmXWalletClient extends XWalletClient { throw new Error('outputAmount is required'); } - const publicClient = this.getPublicClient(); - const walletClient = await this.getWalletClient(); - const destination = `${ICON_XCALL_NETWORK_ID}/${bnJs.Dex.address}`; const amountA = BigInt(inputAmount.quotient.toString()); const amountB = BigInt(outputAmount.quotient.toString()); const xTokenAOnIcon = xTokenMapBySymbol[ICON_XCALL_NETWORK_ID][inputAmount.currency.symbol]; const xTokenBOnIcon = xTokenMapBySymbol[ICON_XCALL_NETWORK_ID][outputAmount.currency.symbol]; - const data = toHex( - RLP.encode([ - 'xAdd', - xTokenAOnIcon.address, - xTokenBOnIcon.address, - uintToBytes(amountA), - uintToBytes(amountB), - uintToBytes(1n), - uintToBytes(1_000n), - ]), - ); - - const envelope = toHex( - RLP.encode([ - Buffer.from([0]), - data, - FROM_SOURCES[this.xChainId]?.map(Buffer.from), - TO_SOURCES[this.xChainId]?.map(Buffer.from), - ]), - ); - - const res = await publicClient.simulateContract({ - account: account as Address, - address: xChainMap[this.xChainId].contracts.xCall as Address, - abi: xCallContractAbi, - functionName: 'sendCall', - args: [destination, envelope], - value: xCallFee.rollback, + const data = toHex(getAddLPData(xTokenAOnIcon.address, xTokenBOnIcon.address, amountA, amountB, true, 1_000n)); + + return await this._sendCall({ + account, + sourceChainId: inputAmount.currency.xChainId, + destination, + data, + fee: xCallFee.rollback, }); - - const hash = await walletClient.writeContract(res.request); - return hash; } async removeLiquidity(xTransactionInput: XTransactionInput) { @@ -448,33 +395,17 @@ export class EvmXWalletClient extends XWalletClient { throw new Error('poolId is required'); } - const publicClient = this.getPublicClient(); - const walletClient = await this.getWalletClient(); - const destination = `${ICON_XCALL_NETWORK_ID}/${bnJs.Dex.address}`; const amount = BigInt(inputAmount.quotient.toString()); const data = toHex(getXRemoveData(poolId, amount, true)); - const envelope = toHex( - RLP.encode([ - Buffer.from([0]), - data, - FROM_SOURCES[this.xChainId]?.map(Buffer.from), - TO_SOURCES[this.xChainId]?.map(Buffer.from), - ]), - ); - - const res = await publicClient.simulateContract({ - account: account as Address, - address: xChainMap[this.xChainId].contracts.xCall as Address, - abi: xCallContractAbi, - functionName: 'sendCall', - args: [destination, envelope], - value: xCallFee.rollback, + return await this._sendCall({ + account, + sourceChainId: inputAmount.currency.xChainId, + destination, + data, + fee: xCallFee.rollback, }); - - const hash = await walletClient.writeContract(res.request); - return hash; } async stake(xTransactionInput: XTransactionInput) { @@ -484,70 +415,38 @@ export class EvmXWalletClient extends XWalletClient { throw new Error('poolId is required'); } - const publicClient = this.getPublicClient(); - const walletClient = await this.getWalletClient(); - const destination = `${ICON_XCALL_NETWORK_ID}/${bnJs.Dex.address}`; const amount = BigInt(inputAmount.quotient.toString()); const data = toHex(getStakeData(`${ICON_XCALL_NETWORK_ID}/${bnJs.StakedLP.address}`, poolId, amount)); - const envelope = toHex( - RLP.encode([ - Buffer.from([0]), - data, - FROM_SOURCES[this.xChainId]?.map(Buffer.from), - TO_SOURCES[this.xChainId]?.map(Buffer.from), - ]), - ); - - const res = await publicClient.simulateContract({ - account: account as Address, - address: xChainMap[this.xChainId].contracts.xCall as Address, - abi: xCallContractAbi, - functionName: 'sendCall', - args: [destination, envelope], - value: xCallFee.rollback, + return await this._sendCall({ + account, + sourceChainId: inputAmount.currency.xChainId, + destination, + data, + fee: xCallFee.rollback, }); - - const hash = await walletClient.writeContract(res.request); - return hash; } async unstake(xTransactionInput: XTransactionInput) { - const { account, inputAmount, poolId, xCallFee } = xTransactionInput; + const { account, inputAmount, poolId, xCallFee, direction } = xTransactionInput; if (!poolId) { throw new Error('poolId is required'); } - const publicClient = this.getPublicClient(); - const walletClient = await this.getWalletClient(); - const destination = `${ICON_XCALL_NETWORK_ID}/${bnJs.StakedLP.address}`; const amount = BigInt(inputAmount.quotient.toString()); const data = toHex(getUnStakeData(poolId, amount)); - const envelope = toHex( - RLP.encode([ - Buffer.from([0]), - data, - FROM_SOURCES[this.xChainId]?.map(Buffer.from), - TO_SOURCES[this.xChainId]?.map(Buffer.from), - ]), - ); - - const res = await publicClient.simulateContract({ - account: account as Address, - address: xChainMap[this.xChainId].contracts.xCall as Address, - abi: xCallContractAbi, - functionName: 'sendCall', - args: [destination, envelope], - value: xCallFee.rollback, + return await this._sendCall({ + account, + sourceChainId: inputAmount.currency.xChainId, + destination, + data, + fee: xCallFee.rollback, }); - - const hash = await walletClient.writeContract(res.request); - return hash; } async claimRewards(xTransactionInput: XTransactionInput): Promise { diff --git a/packages/xwagmi/src/xchains/evm/utils.ts b/packages/xwagmi/src/xchains/evm/utils.ts index b2a410145..a3d001b97 100644 --- a/packages/xwagmi/src/xchains/evm/utils.ts +++ b/packages/xwagmi/src/xchains/evm/utils.ts @@ -10,38 +10,31 @@ export function tokenData(method: string, params: Record): string { return JSON.stringify(map); } -// // add liquidity -// function getAddLPData( -// baseToken: string, -// quoteToken: string, -// baseValue: number, -// quoteValue: number, -// withdrawUnused: boolean, -// slippagePercentage: number, -// ): Uint8Array { -// let rlpInput: rlp.Input = [ -// 'xAdd', -// baseToken, -// quoteToken, -// baseValue, -// quoteValue, -// withdrawUnused ? 1 : 0, -// slippagePercentage, -// ]; -// return rlp.encode(rlpInput); -// } +// add liquidity +export function getAddLPData( + baseToken: string, + quoteToken: string, + baseValue: bigint, + quoteValue: bigint, + withdrawUnused: boolean, + slippagePercentage: bigint, +): Uint8Array { + return RLP.encode([ + 'xAdd', + baseToken, + quoteToken, + uintToBytes(baseValue), + uintToBytes(quoteValue), + withdrawUnused ? uintToBytes(1n) : uintToBytes(0n), + uintToBytes(slippagePercentage), + ]); +} // stake export function getStakeData(to: string, poolId: number, amount: bigint): Uint8Array { return RLP.encode(['xhubtransfer', Buffer.from(to, 'utf-8'), uintToBytes(amount), poolId, Buffer.alloc(0)]); } -// // claim rewards -// function getClaimRewardData(to: string, sources: string[]): Uint8Array { -// let rlpInput: rlp.Input = ['xclaimrewards', to, sources]; -// return rlp.encode(rlpInput); -// } - // unstake export function getUnStakeData(poolId: number, amount: bigint): Uint8Array { return RLP.encode(['xunstake', poolId, uintToBytes(amount)]); @@ -54,5 +47,11 @@ export function getXRemoveData(poolId: number, lpTokenBalance: bigint, withdraw: // withdraw the deposited amount export function getWithdrawData(token: string, amount: bigint): Uint8Array { - return RLP.encode(['xwithdraw', token, amount]); + return RLP.encode(['xwithdraw', token, uintToBytes(amount)]); } + +// // claim rewards +// function getClaimRewardData(to: string, sources: string[]): Uint8Array { +// let rlpInput: rlp.Input = ['xclaimrewards', to, sources]; +// return rlp.encode(rlpInput); +// } From 88dc63997900c1edc969cdc2646114ed068c9e20 Mon Sep 17 00:00:00 2001 From: swiftcc624 Date: Sat, 11 Jan 2025 00:28:53 +0800 Subject: [PATCH 21/33] rewrite SuiXWalletClient --- packages/xwagmi/src/xchains/sui/SuiXWalletClient.ts | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/packages/xwagmi/src/xchains/sui/SuiXWalletClient.ts b/packages/xwagmi/src/xchains/sui/SuiXWalletClient.ts index f91aea942..8700f1652 100644 --- a/packages/xwagmi/src/xchains/sui/SuiXWalletClient.ts +++ b/packages/xwagmi/src/xchains/sui/SuiXWalletClient.ts @@ -172,12 +172,10 @@ export class SuiXWalletClient extends XWalletClient { private async _sendCall({ sourceChainId, - destinationChainId, destination, data, }: { sourceChainId: XChainId; - destinationChainId: XChainId; destination: string; data: any; }) { @@ -187,7 +185,7 @@ export class SuiXWalletClient extends XWalletClient { Buffer.from([0]), data, FROM_SOURCES[sourceChainId]?.map(Buffer.from), - TO_SOURCES[destinationChainId]?.map(Buffer.from), + TO_SOURCES[sourceChainId]?.map(Buffer.from), ]), ), ); @@ -277,7 +275,6 @@ export class SuiXWalletClient extends XWalletClient { return await this._sendCall({ sourceChainId: direction.from, - destinationChainId: direction.to, destination, data, }); @@ -302,7 +299,6 @@ export class SuiXWalletClient extends XWalletClient { return await this._sendCall({ sourceChainId: direction.from, - destinationChainId: direction.to, destination, data, }); @@ -390,7 +386,6 @@ export class SuiXWalletClient extends XWalletClient { const data = getWithdrawData(xTokenOnIcon.address, amount); return await this._sendCall({ sourceChainId: direction.from, - destinationChainId: direction.to, destination, data, }); From cf0f7697c290f3e478c81ae96c6e6d9ed10adf03 Mon Sep 17 00:00:00 2001 From: swiftcc624 Date: Sat, 11 Jan 2025 00:50:18 +0800 Subject: [PATCH 22/33] refactor SolanaXWalletClient --- .../src/xchains/solana/SolanaXWalletClient.ts | 484 +++++++----------- 1 file changed, 178 insertions(+), 306 deletions(-) diff --git a/packages/xwagmi/src/xchains/solana/SolanaXWalletClient.ts b/packages/xwagmi/src/xchains/solana/SolanaXWalletClient.ts index dbf04e27b..e6b069bec 100644 --- a/packages/xwagmi/src/xchains/solana/SolanaXWalletClient.ts +++ b/packages/xwagmi/src/xchains/solana/SolanaXWalletClient.ts @@ -1,8 +1,9 @@ import { ICON_XCALL_NETWORK_ID } from '@/constants'; import { FROM_SOURCES, TO_SOURCES, solana } from '@/constants/xChains'; import { XWalletClient } from '@/core/XWalletClient'; +import { XToken } from '@/types'; import { uintToBytes } from '@/utils'; -import { Percent } from '@balancednetwork/sdk-core'; +import { CurrencyAmount, Percent, XChainId } from '@balancednetwork/sdk-core'; import { Program } from '@coral-xyz/anchor'; import * as anchor from '@coral-xyz/anchor'; import { SYSTEM_PROGRAM_ID } from '@coral-xyz/anchor/dist/cjs/native/system'; @@ -17,6 +18,7 @@ import * as rlp from 'rlp'; import { toBytes } from 'viem'; import { XTransactionInput, XTransactionType } from '../../xcall/types'; import { getRlpEncodedSwapData, toICONDecimals } from '../../xcall/utils'; +import { isSpokeToken } from '../archway'; import bnJs from '../icon/bnJs'; import { SolanaXService } from './SolanaXService'; import assetManagerIdl from './idls/assetManager.json'; @@ -45,50 +47,30 @@ export class SolanaXWalletClient extends XWalletClient { return Promise.resolve(undefined); } - async executeSwapOrBridge(xTransactionInput: XTransactionInput) { + private async _deposit({ + account, + inputAmount, + destination, + data, + fee, // not used, just for compatibility + }: { + account: string; + inputAmount: CurrencyAmount; + destination: string; + data: any; + fee: bigint; + }) { const wallet = this.getXService().wallet; const connection = this.getXService().connection; const provider = this.getXService().provider; - const { type, executionTrade, account, direction, inputAmount, recipient, slippageTolerance, xCallFee } = - xTransactionInput; - - const destination = `${ICON_XCALL_NETWORK_ID}/${bnJs.Router.address}`; - const receiver = `${direction.to}/${recipient}`; - - let data; - if (type === XTransactionType.SWAP) { - if (!executionTrade || !slippageTolerance) { - return; - } - - const minReceived = executionTrade.minimumAmountOut(new Percent(slippageTolerance, 10_000)); - - const rlpEncodedData = getRlpEncodedSwapData(executionTrade, '_swap', receiver, minReceived); - data = rlpEncodedData; - } else if (type === XTransactionType.BRIDGE) { - data = toBytes( - JSON.stringify({ - method: '_swap', - params: { - path: [], - receiver: receiver, - }, - }), - ); - } else { - throw new Error('Invalid XTransactionType'); - } - const isNative = inputAmount.currency.isNativeToken; - const isBnUSD = inputAmount.currency.symbol === 'bnUSD'; let txSignature; const assetManagerId = new PublicKey(solana.contracts.assetManager); const xCallId = new PublicKey(solana.contracts.xCall); const xCallManagerId = new PublicKey(solana.contracts.xCallManager!); - const bnUSDId = new PublicKey(solana.contracts.bnUSD!); if (isNative) { const amount = inputAmount.quotient.toString(); @@ -135,47 +117,6 @@ export class SolanaXWalletClient extends XWalletClient { tx.add(instruction); - txSignature = await wallet.sendTransaction(tx, connection); - } else if (isBnUSD) { - const amount = inputAmount.quotient * 1_000_000_000n + ''; - - // @ts-ignore - const bnUSDProgram = new Program(bnUSDIdl, provider); - - const mintToken = await fetchMintToken(bnUSDId, provider); - - const statePda = await findPda(['state'], bnUSDId); - const xcallManagerStatePda = await findPda(['state'], xCallManagerId); - const xcallConfigPda = await findPda(['config'], xCallId); - const xcallAuthorityPda = await findPda(['dapp_authority'], bnUSDId); - - const xCallAccounts = await getXCallAccounts(xCallId, provider); - const connectionAccounts = await getConnectionAccounts('0x1.icon', xCallManagerId, provider); - - const associatedTokenAcc = getAssociatedTokenAddressSync(mintToken, new PublicKey(account)); - - const computeBudgetIx = ComputeBudgetProgram.setComputeUnitLimit({ units: COMPUTE_UNIT_LIMIT }); - const tx = new Transaction().add(computeBudgetIx); - - const crossTransferTx = await bnUSDProgram.methods - .crossTransfer(destination, new anchor.BN(amount), Buffer.from(data, 'hex')) - .accounts({ - from: associatedTokenAcc, - mint: mintToken, - fromAuthority: new PublicKey(account), - state: statePda, - xcallManagerState: xcallManagerStatePda, - xcallConfig: xcallConfigPda, - xcall: xCallId, - tokenProgram: TOKEN_PROGRAM_ID, - systemProgram: SystemProgram.programId, - xcallAuthority: xcallAuthorityPda, - }) - .remainingAccounts([...xCallAccounts, ...connectionAccounts]) - .instruction(); - - tx.add(crossTransferTx); - txSignature = await wallet.sendTransaction(tx, connection); } else { const assetToken = new PublicKey(inputAmount.currency.address); @@ -240,164 +181,94 @@ export class SolanaXWalletClient extends XWalletClient { txSignature = await wallet.sendTransaction(tx, connection); } - if (txSignature) { - return txSignature; - } + return txSignature; } - async executeDepositCollateral(xTransactionInput: XTransactionInput) { + private async _crossTransfer({ + account, + inputAmount, + destination, + data, + fee, // not used, just for compatibility + }: { + account: string; + inputAmount: CurrencyAmount; + destination: string; + data: any; + fee: bigint; + }) { const wallet = this.getXService().wallet; const connection = this.getXService().connection; const provider = this.getXService().provider; - const { account, inputAmount } = xTransactionInput; - - const destination = `${ICON_XCALL_NETWORK_ID}/${bnJs.Loans.address}`; - const data: any = toBytes(JSON.stringify({})); - - const isNative = inputAmount.currency.isNativeToken; - const isBnUSD = inputAmount.currency.symbol === 'bnUSD'; - - let txSignature; - - const assetManagerId = new PublicKey(solana.contracts.assetManager); const xCallId = new PublicKey(solana.contracts.xCall); const xCallManagerId = new PublicKey(solana.contracts.xCallManager!); + const bnUSDId = new PublicKey(solana.contracts.bnUSD!); + const amount = inputAmount.quotient * 1_000_000_000n + ''; - if (isNative) { - const amount = inputAmount.quotient.toString(); - - // @ts-ignore - const assetManagerProgram = new Program(assetManagerIdl, provider); - - const vaultNativePda = await findPda(['vault_native'], assetManagerId); - const statePda = await findPda(['state'], assetManagerId); - const xCallManagerStatePda = await findPda(['state'], xCallManagerId); - const xCallConfigPda = await findPda(['config'], xCallId); - const xCallAuthorityPda = await findPda(['dapp_authority'], assetManagerId); - - const xCallAccounts = await getXCallAccounts(xCallId, provider); - const connectionAccounts = await getConnectionAccounts('0x1.icon', xCallManagerId, provider); - - const computeBudgetIx = ComputeBudgetProgram.setComputeUnitLimit({ units: COMPUTE_UNIT_LIMIT }); - const tx = new Transaction().add(computeBudgetIx); - - // @ts-ignore - const instruction = await assetManagerProgram.methods - .depositNative(new anchor.BN(amount), destination, Buffer.from(data, 'hex')) - .accounts({ - // @ts-ignore - from: null, - fromAuthority: new PublicKey(account), - // @ts-ignore - vaultTokenAccount: null, - // @ts-ignore - valultAuthority: null, // Ensure this PDA is correct - vaultNativeAccount: vaultNativePda, - state: statePda, - xcallManagerState: xCallManagerStatePda, - xcallConfig: xCallConfigPda, - xcall: xCallId, - xcallManager: xCallManagerId, - // @ts-ignore - tokenProgram: null, - systemProgram: SystemProgram.programId, - xcallAuthority: xCallAuthorityPda, - }) - .remainingAccounts([...xCallAccounts, ...connectionAccounts]) - .instruction(); - - tx.add(instruction); - - txSignature = await wallet.sendTransaction(tx, connection); - } else if (!isBnUSD) { - // JITOSOL - const amount = inputAmount.quotient.toString(); - - const assetToken = new PublicKey(inputAmount.currency.address); - - // @ts-ignore - const assetManagerProgram = new Program(assetManagerIdl, provider); - - const vaultPda = await findPda(['vault', assetToken], assetManagerId); - const statePda = await findPda(['state'], assetManagerId); - const xCallManagerStatePda = await findPda(['state'], xCallManagerId); - const xCallConfigPda = await findPda(['config'], xCallId); - const xCallAuthorityPda = await findPda(['dapp_authority'], assetManagerId); + // @ts-ignore + const bnUSDProgram = new Program(bnUSDIdl, provider); - const xCallAccounts = await getXCallAccounts(xCallId, provider); - const connectionAccounts = await getConnectionAccounts('0x1.icon', xCallManagerId, provider); + const mintToken = await fetchMintToken(bnUSDId, provider); - const depositorTokenAccount = getAssociatedTokenAddressSync(assetToken, new PublicKey(account), true); - const vaultTokenAccount = getAssociatedTokenAddressSync(assetToken, vaultPda, true); + const statePda = await findPda(['state'], bnUSDId); + const xcallManagerStatePda = await findPda(['state'], xCallManagerId); + const xcallConfigPda = await findPda(['config'], xCallId); + const xcallAuthorityPda = await findPda(['dapp_authority'], bnUSDId); - const computeBudgetIx = ComputeBudgetProgram.setComputeUnitLimit({ units: COMPUTE_UNIT_LIMIT }); - const tx = new Transaction().add(computeBudgetIx); + const xCallAccounts = await getXCallAccounts(xCallId, provider); + const connectionAccounts = await getConnectionAccounts('0x1.icon', xCallManagerId, provider); - if (!(await checkIfAccountInitialized(connection, vaultTokenAccount))) { - tx.add( - createAssociatedTokenAccountInstruction( - new PublicKey(account), // payer.publicKey, - vaultTokenAccount, - new PublicKey(vaultPda), // owner, - assetToken, - TOKEN_PROGRAM_ID, - ASSOCIATED_TOKEN_PROGRAM_ID, - ), - ); - } + const associatedTokenAcc = getAssociatedTokenAddressSync(mintToken, new PublicKey(account)); - // @ts-ignore - const instruction = await assetManagerProgram.methods - .depositToken(new anchor.BN(amount), destination, Buffer.from(data, 'hex')) - .accounts({ - from: depositorTokenAccount, - fromAuthority: new PublicKey(account), - vaultTokenAccount: vaultTokenAccount, - valultAuthority: vaultPda, // Ensure this PDA is correct - // @ts-ignore - vaultNativeAccount: null, - state: statePda, - xcallManagerState: xCallManagerStatePda, - xcallConfig: xCallConfigPda, - xcall: xCallId, - xcallManager: xCallManagerId, - tokenProgram: TOKEN_PROGRAM_ID, - systemProgram: SystemProgram.programId, - xcallAuthority: xCallAuthorityPda, - }) - .remainingAccounts([...xCallAccounts, ...connectionAccounts]) - .instruction(); + const computeBudgetIx = ComputeBudgetProgram.setComputeUnitLimit({ units: COMPUTE_UNIT_LIMIT }); + const tx = new Transaction().add(computeBudgetIx); - tx.add(instruction); + const crossTransferTx = await bnUSDProgram.methods + .crossTransfer(destination, new anchor.BN(amount), Buffer.from(data, 'hex')) + .accounts({ + from: associatedTokenAcc, + mint: mintToken, + fromAuthority: new PublicKey(account), + state: statePda, + xcallManagerState: xcallManagerStatePda, + xcallConfig: xcallConfigPda, + xcall: xCallId, + tokenProgram: TOKEN_PROGRAM_ID, + systemProgram: SystemProgram.programId, + xcallAuthority: xcallAuthorityPda, + }) + .remainingAccounts([...xCallAccounts, ...connectionAccounts]) + .instruction(); - txSignature = await wallet.sendTransaction(tx, connection); - } + tx.add(crossTransferTx); - if (txSignature) { - return txSignature; - } + const txSignature = await wallet.sendTransaction(tx, connection); + return txSignature; } - async executeWithdrawCollateral(xTransactionInput: XTransactionInput) { + private async _sendCall({ + account, + sourceChainId, + destination, + data, + fee, // not used, just for compatibility + }: { + account: string; + sourceChainId: XChainId; + destination: string; + data: any; + fee: bigint; + }) { const wallet = this.getXService().wallet; const connection = this.getXService().connection; const provider = this.getXService().provider; - const { inputAmount, account, usedCollateral, direction } = xTransactionInput; - - if (!inputAmount || !usedCollateral) { - return; - } - const amount = toICONDecimals(inputAmount.multiply(-1)); - const destination = `${ICON_XCALL_NETWORK_ID}/${bnJs.Loans.address}`; - - const data = rlp.encode(['xWithdraw', uintToBytes(amount), usedCollateral]); const envelope = new Envelope( MessageType.CallMessage, new CallMessage(data).encode(), - FROM_SOURCES[direction.from]!, - TO_SOURCES[direction.from]!, + FROM_SOURCES[sourceChainId]!, + TO_SOURCES[sourceChainId]!, ).encode(); const xCallId = new PublicKey(solana.contracts.xCall); @@ -432,15 +303,96 @@ export class SolanaXWalletClient extends XWalletClient { tx.add(instruction); const txSignature = await wallet.sendTransaction(tx, connection); - if (txSignature) { - return txSignature; + return txSignature; + } + + async executeSwapOrBridge(xTransactionInput: XTransactionInput) { + const { type, executionTrade, account, direction, inputAmount, recipient, slippageTolerance, xCallFee } = + xTransactionInput; + + const destination = `${ICON_XCALL_NETWORK_ID}/${bnJs.Router.address}`; + const receiver = `${direction.to}/${recipient}`; + + let data; + if (type === XTransactionType.SWAP) { + if (!executionTrade || !slippageTolerance) { + return; + } + + const minReceived = executionTrade.minimumAmountOut(new Percent(slippageTolerance, 10_000)); + + const rlpEncodedData = getRlpEncodedSwapData(executionTrade, '_swap', receiver, minReceived); + data = rlpEncodedData; + } else if (type === XTransactionType.BRIDGE) { + data = toBytes( + JSON.stringify({ + method: '_swap', + params: { + path: [], + receiver: receiver, + }, + }), + ); + } else { + throw new Error('Invalid XTransactionType'); + } + + if (isSpokeToken(inputAmount.currency)) { + return await this._crossTransfer({ + account, + inputAmount, + destination, + data, + fee: 0n, + }); + } else { + return await this._deposit({ + account, + inputAmount, + destination, + data, + fee: 0n, + }); + } + } + + async executeDepositCollateral(xTransactionInput: XTransactionInput) { + const { account, inputAmount } = xTransactionInput; + + const destination = `${ICON_XCALL_NETWORK_ID}/${bnJs.Loans.address}`; + const data: any = toBytes(JSON.stringify({})); + + return await this._deposit({ + account, + inputAmount, + destination, + data, + fee: 0n, + }); + } + + async executeWithdrawCollateral(xTransactionInput: XTransactionInput) { + const { inputAmount, account, usedCollateral, direction } = xTransactionInput; + + if (!inputAmount || !usedCollateral) { + return; } + + const amount = toICONDecimals(inputAmount.multiply(-1)); + const destination = `${ICON_XCALL_NETWORK_ID}/${bnJs.Loans.address}`; + + const data = rlp.encode(['xWithdraw', uintToBytes(amount), usedCollateral]); + + return await this._sendCall({ + account, + sourceChainId: direction.from, + destination, + data, + fee: 0n, + }); } async executeBorrow(xTransactionInput: XTransactionInput) { - const wallet = this.getXService().wallet; - const connection = this.getXService().connection; - const provider = this.getXService().provider; const { inputAmount, account, usedCollateral, direction, recipient } = xTransactionInput; if (!inputAmount || !usedCollateral) { @@ -455,114 +407,34 @@ export class SolanaXWalletClient extends XWalletClient { ? ['xBorrow', usedCollateral, uintToBytes(amount), Buffer.from(recipient)] : ['xBorrow', usedCollateral, uintToBytes(amount)], ); - const envelope = new Envelope( - MessageType.CallMessage, - new CallMessage(data).encode(), - FROM_SOURCES[direction.from]!, - TO_SOURCES[direction.from]!, - ).encode(); - - const xCallId = new PublicKey(solana.contracts.xCall); - const xCallManagerId = new PublicKey(solana.contracts.xCallManager!); - - // @ts-ignore - const xCallProgram = new Program(xCallIdl, provider); - - const xCallConfigPda = await findPda(['config'], xCallId); - const xCallConfigAccount = await fetchXCallConfig(xCallId, provider); - const connectionAccounts = await getConnectionAccounts('0x1.icon', xCallManagerId, provider); - - const computeBudgetIx = ComputeBudgetProgram.setComputeUnitLimit({ units: COMPUTE_UNIT_LIMIT }); - const tx = new Transaction().add(computeBudgetIx); - - // @ts-ignore - const instruction = await xCallProgram.methods - .sendCall(Buffer.from(envelope), { '0': destination }) - .accountsStrict({ - systemProgram: SYSTEM_PROGRAM_ID, - config: xCallConfigPda, - signer: new PublicKey(account), - dappAuthority: xCallId, - // @ts-ignore - rollbackAccount: null, - instructionSysvar: SYSVAR_INSTRUCTIONS_ID, - feeHandler: new PublicKey(xCallConfigAccount.feeHandler), - }) - .remainingAccounts([...connectionAccounts]) - .instruction(); - - tx.add(instruction); - const txSignature = await wallet.sendTransaction(tx, connection); - if (txSignature) { - return txSignature; - } + return await this._sendCall({ + account, + sourceChainId: direction.from, + destination, + data, + fee: 0n, + }); } async executeRepay(xTransactionInput: XTransactionInput) { - const wallet = this.getXService().wallet; - const connection = this.getXService().connection; - const provider = this.getXService().provider; - const { account, inputAmount, recipient, usedCollateral } = xTransactionInput; if (!inputAmount || !usedCollateral) { return; } - const amount = inputAmount.multiply(-1).quotient.toString(); const destination = `${ICON_XCALL_NETWORK_ID}/${bnJs.Loans.address}`; const data: any = toBytes( JSON.stringify(recipient ? { _collateral: usedCollateral, _to: recipient } : { _collateral: usedCollateral }), ); - let txSignature; - - const xCallId = new PublicKey(solana.contracts.xCall); - const xCallManagerId = new PublicKey(solana.contracts.xCallManager!); - const bnUSDId = new PublicKey(solana.contracts.bnUSD!); - - // @ts-ignore - const bnUSDProgram = new Program(bnUSDIdl, provider); - - const mintToken = await fetchMintToken(bnUSDId, provider); - - const statePda = await findPda(['state'], bnUSDId); - const xcallManagerStatePda = await findPda(['state'], xCallManagerId); - const xcallConfigPda = await findPda(['config'], xCallId); - const xcallAuthorityPda = await findPda(['dapp_authority'], bnUSDId); - - const xCallAccounts = await getXCallAccounts(xCallId, provider); - const connectionAccounts = await getConnectionAccounts('0x1.icon', xCallManagerId, provider); - - const associatedTokenAcc = getAssociatedTokenAddressSync(mintToken, new PublicKey(account)); - - const computeBudgetIx = ComputeBudgetProgram.setComputeUnitLimit({ units: COMPUTE_UNIT_LIMIT }); - const tx = new Transaction().add(computeBudgetIx); - - const crossTransferTx = await bnUSDProgram.methods - .crossTransfer(destination, new anchor.BN(amount), Buffer.from(data, 'hex')) - .accounts({ - from: associatedTokenAcc, - mint: mintToken, - fromAuthority: new PublicKey(account), - state: statePda, - xcallManagerState: xcallManagerStatePda, - xcallConfig: xcallConfigPda, - xcall: xCallId, - tokenProgram: TOKEN_PROGRAM_ID, - systemProgram: SystemProgram.programId, - xcallAuthority: xcallAuthorityPda, - }) - .remainingAccounts([...xCallAccounts, ...connectionAccounts]) - .instruction(); - - tx.add(crossTransferTx); - - txSignature = await wallet.sendTransaction(tx, connection); - - if (txSignature) { - return txSignature; - } + return await this._crossTransfer({ + account, + inputAmount: inputAmount.multiply(-1), + destination, + data, + fee: 0n, + }); } async depositXToken(xTransactionInput: XTransactionInput): Promise { From 4a6001800132f4e97c68cdeb70f5f0132b049ba9 Mon Sep 17 00:00:00 2001 From: swiftcc624 Date: Sat, 11 Jan 2025 00:56:15 +0800 Subject: [PATCH 23/33] refactor EvmXWalletClient --- .../src/xchains/evm/EvmXWalletClient.ts | 52 ++++++++----------- 1 file changed, 21 insertions(+), 31 deletions(-) diff --git a/packages/xwagmi/src/xchains/evm/EvmXWalletClient.ts b/packages/xwagmi/src/xchains/evm/EvmXWalletClient.ts index d7e7ed249..09b953c48 100644 --- a/packages/xwagmi/src/xchains/evm/EvmXWalletClient.ts +++ b/packages/xwagmi/src/xchains/evm/EvmXWalletClient.ts @@ -65,29 +65,29 @@ export class EvmXWalletClient extends XWalletClient { } private async _deposit({ - amount, account, - xToken, + inputAmount, destination, data, fee, }: { - amount: bigint; account: string; - xToken: XToken; + inputAmount: CurrencyAmount; destination: string; - data: `0x${string}`; + data: any; fee: bigint; }) { const walletClient = await this.getWalletClient(); - if (!xToken.isNativeToken) { + const amount = BigInt(inputAmount.quotient.toString()); + + if (!inputAmount.currency.isNativeToken) { const res = await this.getPublicClient().simulateContract({ account: account as Address, - address: xChainMap[xToken.xChainId].contracts.assetManager as Address, + address: xChainMap[inputAmount.currency.xChainId].contracts.assetManager as Address, abi: assetManagerContractAbi, functionName: 'deposit', - args: [xToken.address as Address, amount, destination, data], + args: [inputAmount.currency.address as Address, amount, destination, data], value: fee, }); const hash = await walletClient.writeContract(res.request); @@ -95,7 +95,7 @@ export class EvmXWalletClient extends XWalletClient { } else { const res = await this.getPublicClient().simulateContract({ account: account as Address, - address: xChainMap[xToken.xChainId].contracts.assetManager as Address, + address: xChainMap[inputAmount.currency.xChainId].contracts.assetManager as Address, abi: assetManagerContractAbi, functionName: 'depositNative', args: [amount, destination, data], @@ -107,25 +107,25 @@ export class EvmXWalletClient extends XWalletClient { } private async _crossTransfer({ - amount, account, - xToken, + inputAmount, destination, data, fee, }: { - amount: bigint; account: string; - xToken: XToken; + inputAmount: CurrencyAmount; destination: string; - data: `0x${string}`; + data: any; fee: bigint; }) { const walletClient = await this.getWalletClient(); + const amount = BigInt(inputAmount.quotient.toString()); + const res = await this.getPublicClient().simulateContract({ account: account as Address, - address: xToken.address as Address, + address: inputAmount.currency.address as Address, abi: bnUSDContractAbi, functionName: 'crossTransfer', args: [destination, amount, data], @@ -176,7 +176,6 @@ export class EvmXWalletClient extends XWalletClient { xTransactionInput; const receiver = `${direction.to}/${recipient}`; - const amount = BigInt(inputAmount.quotient.toString()); const destination = `${ICON_XCALL_NETWORK_ID}/${bnJs.Router.address}`; let data: Address; @@ -207,18 +206,16 @@ export class EvmXWalletClient extends XWalletClient { if (isSpokeToken(inputAmount.currency)) { return await this._crossTransfer({ - amount, account, - xToken: inputAmount.currency, + inputAmount, destination, data, fee: xCallFee.rollback, }); } else { return await this._deposit({ - amount, account, - xToken: inputAmount.currency, + inputAmount, destination, data, fee: xCallFee.rollback, @@ -233,14 +230,12 @@ export class EvmXWalletClient extends XWalletClient { return; } - const amount = BigInt(inputAmount.quotient.toString()); const destination = `${ICON_XCALL_NETWORK_ID}/${bnJs.Loans.address}`; const data = toHex(JSON.stringify({})); return await this._deposit({ - amount, + inputAmount, account, - xToken: inputAmount.currency, destination, data, fee: xCallFee.rollback, @@ -300,16 +295,14 @@ export class EvmXWalletClient extends XWalletClient { return; } - const amount = BigInt(inputAmount.multiply(-1).quotient.toString()); const destination = `${ICON_XCALL_NETWORK_ID}/${bnJs.Loans.address}`; const data = toHex( JSON.stringify(recipient ? { _collateral: usedCollateral, _to: recipient } : { _collateral: usedCollateral }), ); return await this._crossTransfer({ - amount, account, - xToken: inputAmount.currency, + inputAmount: inputAmount.multiply(-1), destination, data, fee: xCallFee.rollback, @@ -321,24 +314,21 @@ export class EvmXWalletClient extends XWalletClient { const { account, inputAmount, xCallFee } = xTransactionInput; const destination = `${ICON_XCALL_NETWORK_ID}/${bnJs.Dex.address}`; - const amount = BigInt(inputAmount.quotient.toString()); const data = toHex(tokenData('_deposit', {})); let hash; if (isSpokeToken(inputAmount.currency)) { hash = await this._crossTransfer({ - amount, account, - xToken: inputAmount.currency, + inputAmount, destination, data, fee: xCallFee.rollback, }); } else { hash = await this._deposit({ - amount, account, - xToken: inputAmount.currency, + inputAmount, destination, data, fee: xCallFee.rollback, From 3d9e8b129f58717e1de5d58f93132240617f0e47 Mon Sep 17 00:00:00 2001 From: swiftcc624 Date: Sat, 11 Jan 2025 01:17:37 +0800 Subject: [PATCH 24/33] refactor HavahXWalletClient --- .../src/xchains/havah/HavahXWalletClient.ts | 106 ++++++++++++------ 1 file changed, 73 insertions(+), 33 deletions(-) diff --git a/packages/xwagmi/src/xchains/havah/HavahXWalletClient.ts b/packages/xwagmi/src/xchains/havah/HavahXWalletClient.ts index 1b8e92d3e..09f752369 100644 --- a/packages/xwagmi/src/xchains/havah/HavahXWalletClient.ts +++ b/packages/xwagmi/src/xchains/havah/HavahXWalletClient.ts @@ -1,12 +1,14 @@ -import { Percent } from '@balancednetwork/sdk-core'; +import { CurrencyAmount, Percent, XChainId } from '@balancednetwork/sdk-core'; import bnJs from '../icon/bnJs'; import { ICON_XCALL_NETWORK_ID } from '@/constants'; import { XWalletClient } from '@/core/XWalletClient'; +import { XToken } from '@/types'; import { showMessageOnBeforeUnload, toDec } from '@/utils'; import { toHex } from 'viem'; import { XTransactionInput, XTransactionType } from '../../xcall/types'; import { getRlpEncodedSwapData } from '../../xcall/utils'; +import { isSpokeToken } from '../archway'; import { HavahXService } from './HavahXService'; export class HavahXWalletClient extends XWalletClient { @@ -18,6 +20,66 @@ export class HavahXWalletClient extends XWalletClient { return Promise.resolve(undefined); } + private async _deposit({ + account, + inputAmount, + destination, + data, + fee, + }: { + account: string; + inputAmount: CurrencyAmount; + destination: string; + data: any; + fee: bigint; + }) { + const isNative = inputAmount.currency.isNativeToken; + if (!isNative) { + throw new Error('Only native token and bnUSD are supported'); + } + const txResult = await this.getXService() + .walletClient.inject({ account }) + .AssetManager['deposit'](parseFloat(inputAmount.toExact()), destination, data, fee.toString()); + const { txHash: hash } = txResult || {}; + return hash; + } + + private async _crossTransfer({ + account, + inputAmount, + destination, + data, + fee, + }: { + account: string; + inputAmount: CurrencyAmount; + destination: string; + data: any; + fee: bigint; + }) { + const txResult = await this.getXService() + .walletClient.inject({ account }) + .bnUSD['crossTransferV2'](destination, toDec(inputAmount), data, fee); + const { txHash: hash } = txResult || {}; + return hash; + } + + private async _sendCall({ + account, + sourceChainId, + destination, + data, + fee, + }: { + account: string; + sourceChainId: XChainId; + destination: string; + data: any; + fee: bigint; + }) { + throw new Error('Method not implemented.'); + } + async executeSwapOrBridge(xTransactionInput: XTransactionInput) { const { type, executionTrade, account, direction, inputAmount, recipient, slippageTolerance, xCallFee } = xTransactionInput; @@ -50,28 +112,10 @@ export class HavahXWalletClient extends XWalletClient { throw new Error('Invalid XTransactionType'); } - const isNative = inputAmount.currency.isNativeToken; - const isBnUSD = inputAmount.currency.symbol === 'bnUSD'; - - let txResult; - if (isBnUSD) { - txResult = await this.getXService() - .walletClient.inject({ account }) - .bnUSD['crossTransferV2'](destination, toDec(inputAmount), data, xCallFee.rollback.toString()); + if (isSpokeToken(inputAmount.currency)) { + return await this._crossTransfer({ account, inputAmount, destination, data, fee: xCallFee.rollback }); } else { - if (!isNative) { - throw new Error('Only native token and bnUSD are supported'); - } else { - console.log('isNative'); - txResult = await this.getXService() - .walletClient.inject({ account }) - .AssetManager['deposit'](parseFloat(inputAmount.toExact()), destination, data, xCallFee.rollback.toString()); - } - } - const { txHash: hash } = txResult || {}; - - if (hash) { - return hash; + return await this._deposit({ account, inputAmount, destination, data, fee: xCallFee.rollback }); } } @@ -94,22 +138,18 @@ export class HavahXWalletClient extends XWalletClient { return; } - const amount = toDec(inputAmount.multiply(-1)); const destination = `${ICON_XCALL_NETWORK_ID}/${bnJs.Loans.address}`; const data = toHex( JSON.stringify(recipient ? { _collateral: usedCollateral, _to: recipient } : { _collateral: usedCollateral }), ); - const txResult = await this.getXService() - .walletClient.inject({ account }) - .bnUSD['crossTransferV2'](destination, amount, data, xCallFee.rollback.toString()); - - // @ts-ignore - const { txHash: hash } = txResult || {}; - - if (hash) { - return hash; - } + return await this._crossTransfer({ + account, + inputAmount: inputAmount.multiply(-1), + destination, + data, + fee: xCallFee.rollback, + }); } async depositXToken(xTransactionInput: XTransactionInput): Promise { From d8dd141b3361f08481b613d6f37ce26694e36d8e Mon Sep 17 00:00:00 2001 From: swiftcc624 Date: Sat, 11 Jan 2025 01:33:11 +0800 Subject: [PATCH 25/33] refactor ArchwyXWalletClient --- .../xchains/archway/ArchwayXWalletClient.ts | 214 +++++++++++------- 1 file changed, 130 insertions(+), 84 deletions(-) diff --git a/packages/xwagmi/src/xchains/archway/ArchwayXWalletClient.ts b/packages/xwagmi/src/xchains/archway/ArchwayXWalletClient.ts index 6b5fc49e5..932876cfe 100644 --- a/packages/xwagmi/src/xchains/archway/ArchwayXWalletClient.ts +++ b/packages/xwagmi/src/xchains/archway/ArchwayXWalletClient.ts @@ -1,4 +1,4 @@ -import { Percent } from '@balancednetwork/sdk-core'; +import { Percent, XChainId } from '@balancednetwork/sdk-core'; import bnJs from '../icon/bnJs'; import { ICON_XCALL_NETWORK_ID } from '@/constants'; @@ -6,7 +6,7 @@ import { archway } from '@/constants/xChains'; import { XWalletClient } from '@/core/XWalletClient'; import { XToken } from '@/types'; import { XSigningArchwayClient } from '@/xchains/archway/XSigningArchwayClient'; -import { getFeeParam, isDenomAsset } from '@/xchains/archway/utils'; +import { getFeeParam, isDenomAsset, isSpokeToken } from '@/xchains/archway/utils'; import { CurrencyAmount, MaxUint256 } from '@balancednetwork/sdk-core'; import { XTransactionInput, XTransactionType } from '../../xcall/types'; import { getBytesFromString, getRlpEncodedSwapData } from '../../xcall/utils'; @@ -43,11 +43,116 @@ export class ArchwayXWalletClient extends XWalletClient { } } + private async _deposit({ + account, + inputAmount, + destination, + data, + fee, + }: { + account: string; + inputAmount: CurrencyAmount; + destination: string; + data: any; + fee: bigint; + }) { + const isDenom = inputAmount && inputAmount.currency instanceof XToken ? isDenomAsset(inputAmount.currency) : false; + + if (isDenom) { + const msg = { + deposit_denom: { + denom: inputAmount.currency.address, + to: destination, + data, + }, + }; + + const hash = await this.getWalletClient().executeSync( + account, + archway.contracts.assetManager, + msg, + getFeeParam(1200000), + undefined, + [ + { amount: fee.toString(), denom: ARCHWAY_FEE_TOKEN_SYMBOL }, + { amount: `${inputAmount.quotient}`, denom: inputAmount.currency.address }, + ], + ); + return hash; + } else { + const msg = { + deposit: { + token_address: inputAmount.currency.address, + amount: inputAmount.quotient.toString(), + to: destination, + data, + }, + }; + + const hash = await this.getWalletClient().executeSync( + account, + archway.contracts.assetManager, + msg, + 'auto', + undefined, + [{ amount: fee.toString(), denom: ARCHWAY_FEE_TOKEN_SYMBOL }], + ); + return hash; + } + } + + private async _crossTransfer({ + account, + inputAmount, + destination, + data, + fee, + }: { + account: string; + inputAmount: CurrencyAmount; + destination: string; + data: any; + fee: bigint; + }) { + const msg = { + cross_transfer: { + amount: inputAmount.quotient.toString(), + to: destination, + data, + }, + }; + + const hash = await this.getWalletClient().executeSync( + account, // + archway.contracts.bnUSD!, + msg, + 'auto', + undefined, + [{ amount: fee.toString(), denom: ARCHWAY_FEE_TOKEN_SYMBOL }], + ); + return hash; + } + + private async _sendCall({ + account, + sourceChainId, + destination, + data, + fee, + }: { + account: string; + sourceChainId: XChainId; + destination: string; + data: any; + fee: bigint; + }) { + throw new Error('Method not implemented.'); + } + async executeSwapOrBridge(xTransactionInput: XTransactionInput) { const { type, direction, inputAmount, executionTrade, account, recipient, xCallFee, slippageTolerance } = xTransactionInput; - const token = inputAmount.currency.wrapped; const receiver = `${direction.to}/${recipient}`; let data; @@ -73,70 +178,22 @@ export class ArchwayXWalletClient extends XWalletClient { throw new Error('Invalid XTransactionType'); } - const isDenom = inputAmount && inputAmount.currency instanceof XToken ? isDenomAsset(inputAmount.currency) : false; - const isBnUSD = inputAmount.currency?.symbol === 'bnUSD'; - - if (isBnUSD) { - //handle icon native tokens vs spoke assets - const msg = { - cross_transfer: { - amount: inputAmount.quotient.toString(), - to: `${ICON_XCALL_NETWORK_ID}/${bnJs.Router.address}`, - data, - }, - }; - - const hash = await this.getWalletClient().executeSync( - account, // - archway.contracts.bnUSD!, - msg, - 'auto', - undefined, - [{ amount: xCallFee?.rollback.toString(), denom: ARCHWAY_FEE_TOKEN_SYMBOL }], - ); - return hash; + if (isSpokeToken(inputAmount.currency)) { + return await this._crossTransfer({ + account, + inputAmount, + destination: `${ICON_XCALL_NETWORK_ID}/${bnJs.Router.address}`, + data, + fee: xCallFee.rollback, + }); } else { - if (isDenom) { - const msg = { - deposit_denom: { - denom: token.address, - to: `${ICON_XCALL_NETWORK_ID}/${bnJs.Router.address}`, - data, - }, - }; - - const hash = await this.getWalletClient().executeSync( - account, - archway.contracts.assetManager, - msg, - getFeeParam(1200000), - undefined, - [ - { amount: xCallFee.rollback.toString(), denom: ARCHWAY_FEE_TOKEN_SYMBOL }, - { amount: `${inputAmount.quotient}`, denom: token.address }, - ], - ); - return hash; - } else { - const msg = { - deposit: { - token_address: token.address, - amount: inputAmount.quotient.toString(), - to: `${ICON_XCALL_NETWORK_ID}/${bnJs.Router.address}`, - data, - }, - }; - - const hash = await this.getWalletClient().executeSync( - account, - archway.contracts.assetManager, - msg, - 'auto', - undefined, - [{ amount: xCallFee.rollback.toString(), denom: ARCHWAY_FEE_TOKEN_SYMBOL }], - ); - return hash; - } + return await this._deposit({ + account, + inputAmount, + destination: `${ICON_XCALL_NETWORK_ID}/${bnJs.Router.address}`, + data, + fee: xCallFee.rollback, + }); } } @@ -159,29 +216,18 @@ export class ArchwayXWalletClient extends XWalletClient { return; } - const amount = inputAmount.multiply(-1).quotient.toString(); const destination = `${ICON_XCALL_NETWORK_ID}/${bnJs.Loans.address}`; const data = getBytesFromString( JSON.stringify(recipient ? { _collateral: usedCollateral, _to: recipient } : { _collateral: usedCollateral }), ); - const msg = { - cross_transfer: { - amount, - to: destination, - data, - }, - }; - - const hash = await this.getWalletClient().executeSync( - account, // - archway.contracts.bnUSD!, - msg, - 'auto', - undefined, - [{ amount: xCallFee?.rollback.toString(), denom: ARCHWAY_FEE_TOKEN_SYMBOL }], - ); - return hash; + return await this._crossTransfer({ + account, + inputAmount: inputAmount.multiply(-1), + destination, + data, + fee: xCallFee.rollback, + }); } async depositXToken(xTransactionInput: XTransactionInput): Promise { From d0010a054c89c1967edc4dab406f00c91a4d73d2 Mon Sep 17 00:00:00 2001 From: swiftcc624 Date: Sat, 11 Jan 2025 02:09:24 +0800 Subject: [PATCH 26/33] refactor InjectiveXWalletClient --- .../injective/InjectiveXWalletClient.ts | 377 +++++++++--------- 1 file changed, 187 insertions(+), 190 deletions(-) diff --git a/packages/xwagmi/src/xchains/injective/InjectiveXWalletClient.ts b/packages/xwagmi/src/xchains/injective/InjectiveXWalletClient.ts index 04a922b95..f532e0d23 100644 --- a/packages/xwagmi/src/xchains/injective/InjectiveXWalletClient.ts +++ b/packages/xwagmi/src/xchains/injective/InjectiveXWalletClient.ts @@ -1,11 +1,10 @@ -import { Percent } from '@balancednetwork/sdk-core'; +import { CurrencyAmount, Percent, XChainId } from '@balancednetwork/sdk-core'; import bnJs from '../icon/bnJs'; import { ICON_XCALL_NETWORK_ID } from '@/constants'; import { getBytesFromString, getRlpEncodedSwapData, toICONDecimals } from '@/xcall/utils'; import { FROM_SOURCES, TO_SOURCES, injective } from '@/constants/xChains'; -import { xTokenMap } from '@/constants/xTokens'; import { XWalletClient } from '@/core'; import { XToken } from '@/types'; import { uintToBytes } from '@/utils'; @@ -24,188 +23,98 @@ export class InjectiveXWalletClient extends XWalletClient { return Promise.resolve(undefined); } - async executeSwapOrBridge(xTransactionInput: XTransactionInput) { - const { type, direction, inputAmount, executionTrade, account, recipient, xCallFee, slippageTolerance } = - xTransactionInput; - - const token = inputAmount.currency.wrapped; - const receiver = `${direction.to}/${recipient}`; - - let data; - if (type === XTransactionType.SWAP) { - if (!executionTrade || !slippageTolerance) { - return; - } - - const minReceived = executionTrade.minimumAmountOut(new Percent(slippageTolerance, 10_000)); - const rlpEncodedData = getRlpEncodedSwapData(executionTrade, '_swap', receiver, minReceived); - data = Array.from(rlpEncodedData); - } else if (type === XTransactionType.BRIDGE) { - data = getBytesFromString( - JSON.stringify({ - method: '_swap', - params: { - path: [], - receiver: receiver, - }, - }), - ); - } else { - throw new Error('Invalid XTransactionType'); - } - - const _isSpokeToken = isSpokeToken(inputAmount.currency); + private async _deposit({ + account, + inputAmount, + destination, + data, + fee, + }: { + account: string; + inputAmount: CurrencyAmount; + destination: string; + data: any; + fee: bigint; + }) { + let msg; const isDenom = inputAmount && inputAmount.currency instanceof XToken ? isDenomAsset(inputAmount.currency) : false; - - if (_isSpokeToken) { - const amount = inputAmount.quotient.toString(); - const msg = MsgExecuteContractCompat.fromJSON({ - contractAddress: injective.contracts.bnUSD!, + if (isDenom) { + msg = MsgExecuteContractCompat.fromJSON({ + contractAddress: injective.contracts.assetManager, sender: account, msg: { - cross_transfer: { - amount, - to: `${ICON_XCALL_NETWORK_ID}/${bnJs.Router.address}`, + deposit_denom: { + denom: inputAmount.currency.address, + to: destination, data, }, }, funds: [ { denom: 'inj', - amount: xCallFee.rollback.toString(), + amount: BigInt(fee).toString(), }, - { denom: token.address, amount }, + { denom: inputAmount.currency.address, amount: `${inputAmount.quotient}` }, ], }); - - const txResult = await this.getXService().msgBroadcastClient.broadcastWithFeeDelegation({ - msgs: msg, - injectiveAddress: account, - }); - - return txResult.txHash; } else { - let msg; - if (isDenom) { - msg = MsgExecuteContractCompat.fromJSON({ - contractAddress: injective.contracts.assetManager, - sender: account, - msg: { - deposit_denom: { - denom: token.address, - to: `${ICON_XCALL_NETWORK_ID}/${bnJs.Router.address}`, - data, - }, - }, - funds: [ - { - denom: 'inj', - amount: BigInt(xCallFee.rollback).toString(), - }, - { denom: token.address, amount: `${inputAmount.quotient}` }, - ], - }); - } else { - msg = MsgExecuteContractCompat.fromJSON({ - contractAddress: injective.contracts.assetManager, - sender: account, - msg: { - deposit_denom: { - denom: 'inj', - to: `${ICON_XCALL_NETWORK_ID}/${bnJs.Router.address}`, - data, - }, - }, - funds: [ - { - denom: 'inj', - amount: BigInt(inputAmount.quotient + xCallFee.rollback).toString(), - }, - ], - }); - } - - const txResult = await this.getXService().msgBroadcastClient.broadcastWithFeeDelegation({ - msgs: msg, - injectiveAddress: account, - }); - - return txResult.txHash; - } - } - - async executeDepositCollateral(xTransactionInput: XTransactionInput) { - const { inputAmount, account, xCallFee } = xTransactionInput; - - if (!inputAmount) { - return; - } - - const data = getBytesFromString(JSON.stringify({})); - - if (inputAmount.currency.isNativeToken) { - const msg = MsgExecuteContractCompat.fromJSON({ + msg = MsgExecuteContractCompat.fromJSON({ contractAddress: injective.contracts.assetManager, sender: account, msg: { deposit_denom: { denom: 'inj', - to: `${ICON_XCALL_NETWORK_ID}/${bnJs.Loans.address}`, + to: destination, data, }, }, funds: [ { denom: 'inj', - amount: BigInt(inputAmount.quotient + xCallFee.rollback).toString(), + amount: BigInt(inputAmount.quotient + fee).toString(), }, ], }); - - const txResult = await this.getXService().msgBroadcastClient.broadcastWithFeeDelegation({ - msgs: msg, - injectiveAddress: account, - }); - - return txResult.txHash; - } else { - throw new Error('Injective tokens not supported yet'); - } - } - - async executeWithdrawCollateral(xTransactionInput: XTransactionInput) { - const { inputAmount, account, xCallFee, usedCollateral } = xTransactionInput; - - if (!inputAmount || !usedCollateral) { - return; } - const amount = toICONDecimals(inputAmount.multiply(-1)); + const txResult = await this.getXService().msgBroadcastClient.broadcastWithFeeDelegation({ + msgs: msg, + injectiveAddress: account, + }); - const envelope = { - message: { - call_message: { - data: Array.from(RLP.encode(['xWithdraw', uintToBytes(amount), usedCollateral])), - }, - }, - sources: FROM_SOURCES[this.xChainId], - destinations: TO_SOURCES[this.xChainId], - }; + return txResult.txHash; + } + private async _crossTransfer({ + account, + inputAmount, + destination, + data, + fee, + }: { + account: string; + inputAmount: CurrencyAmount; + destination: string; + data: any; + fee: bigint; + }) { + const amount = inputAmount.quotient.toString(); const msg = MsgExecuteContractCompat.fromJSON({ - contractAddress: injective.contracts.xCall, + contractAddress: injective.contracts.bnUSD!, sender: account, msg: { - send_call: { - to: `${ICON_XCALL_NETWORK_ID}/${bnJs.Loans.address}`, - envelope, + cross_transfer: { + amount, + to: destination, + data, }, }, funds: [ { denom: 'inj', - amount: xCallFee.rollback.toString(), + amount: fee.toString(), }, + { denom: inputAmount.currency.address, amount }, ], }); @@ -217,28 +126,27 @@ export class InjectiveXWalletClient extends XWalletClient { return txResult.txHash; } - async executeBorrow(xTransactionInput: XTransactionInput) { - const { inputAmount, account, xCallFee, usedCollateral, recipient } = xTransactionInput; - - if (!inputAmount || !usedCollateral) { - return; - } - const amount = BigInt(inputAmount.quotient.toString()); - + private async _sendCall({ + account, + sourceChainId, + destination, + data, + fee, + }: { + account: string; + sourceChainId: XChainId; + destination: string; + data: any; + fee: bigint; + }) { const envelope = { message: { call_message: { - data: Array.from( - RLP.encode( - recipient - ? ['xBorrow', usedCollateral, uintToBytes(amount), Buffer.from(recipient)] - : ['xBorrow', usedCollateral, uintToBytes(amount)], - ), - ), + data, }, }, - sources: FROM_SOURCES[this.xChainId], - destinations: TO_SOURCES[this.xChainId], + sources: FROM_SOURCES[sourceChainId], + destinations: TO_SOURCES[sourceChainId], }; const msg = MsgExecuteContractCompat.fromJSON({ @@ -246,14 +154,14 @@ export class InjectiveXWalletClient extends XWalletClient { sender: account, msg: { send_call: { - to: `${ICON_XCALL_NETWORK_ID}/${bnJs.Loans.address}`, + to: destination, envelope, }, }, funds: [ { denom: 'inj', - amount: xCallFee.rollback.toString(), + amount: fee.toString(), }, ], }); @@ -266,11 +174,119 @@ export class InjectiveXWalletClient extends XWalletClient { return txResult.txHash; } + async executeSwapOrBridge(xTransactionInput: XTransactionInput) { + const { type, direction, inputAmount, executionTrade, account, recipient, xCallFee, slippageTolerance } = + xTransactionInput; + + const receiver = `${direction.to}/${recipient}`; + + let data; + if (type === XTransactionType.SWAP) { + if (!executionTrade || !slippageTolerance) { + return; + } + + const minReceived = executionTrade.minimumAmountOut(new Percent(slippageTolerance, 10_000)); + const rlpEncodedData = getRlpEncodedSwapData(executionTrade, '_swap', receiver, minReceived); + data = Array.from(rlpEncodedData); + } else if (type === XTransactionType.BRIDGE) { + data = getBytesFromString( + JSON.stringify({ + method: '_swap', + params: { + path: [], + receiver: receiver, + }, + }), + ); + } else { + throw new Error('Invalid XTransactionType'); + } + + if (isSpokeToken(inputAmount.currency)) { + return await this._crossTransfer({ + account, + inputAmount, + destination: `${ICON_XCALL_NETWORK_ID}/${bnJs.Router.address}`, + data, + fee: xCallFee.rollback, + }); + } else { + return await this._deposit({ + account, + inputAmount, + destination: `${ICON_XCALL_NETWORK_ID}/${bnJs.Router.address}`, + data, + fee: xCallFee.rollback, + }); + } + } + + async executeDepositCollateral(xTransactionInput: XTransactionInput) { + const { inputAmount, account, xCallFee } = xTransactionInput; + + if (!inputAmount) { + return; + } + + const data = getBytesFromString(JSON.stringify({})); + + return await this._deposit({ + account, + inputAmount, + destination: `${ICON_XCALL_NETWORK_ID}/${bnJs.Loans.address}`, + data, + fee: xCallFee.rollback, + }); + } + + async executeWithdrawCollateral(xTransactionInput: XTransactionInput) { + const { inputAmount, account, xCallFee, usedCollateral } = xTransactionInput; + + if (!inputAmount || !usedCollateral) { + return; + } + + const amount = toICONDecimals(inputAmount.multiply(-1)); + const data = Array.from(RLP.encode(['xWithdraw', uintToBytes(amount), usedCollateral])); + + return await this._sendCall({ + account, + sourceChainId: this.xChainId, + destination: `${ICON_XCALL_NETWORK_ID}/${bnJs.Loans.address}`, + data, + fee: xCallFee.rollback, + }); + } + + async executeBorrow(xTransactionInput: XTransactionInput) { + const { inputAmount, account, xCallFee, usedCollateral, recipient } = xTransactionInput; + + if (!inputAmount || !usedCollateral) { + return; + } + const amount = BigInt(inputAmount.quotient.toString()); + const data = Array.from( + RLP.encode( + recipient + ? ['xBorrow', usedCollateral, uintToBytes(amount), Buffer.from(recipient)] + : ['xBorrow', usedCollateral, uintToBytes(amount)], + ), + ); + + return await this._sendCall({ + account, + sourceChainId: this.xChainId, + destination: `${ICON_XCALL_NETWORK_ID}/${bnJs.Loans.address}`, + data, + fee: xCallFee.rollback, + }); + } + async executeRepay(xTransactionInput: XTransactionInput) { const { inputAmount, account, xCallFee, usedCollateral, recipient } = xTransactionInput; - const bnUSD = xTokenMap['injective-1'].find(xToken => xToken.symbol === 'bnUSD'); - if (!inputAmount || !usedCollateral || !bnUSD) { + if (!inputAmount || !usedCollateral) { return; } @@ -278,33 +294,14 @@ export class InjectiveXWalletClient extends XWalletClient { const data = getBytesFromString( JSON.stringify(recipient ? { _collateral: usedCollateral, _to: recipient } : { _collateral: usedCollateral }), ); - const amount = inputAmount.multiply(-1).quotient.toString(); - const msg = MsgExecuteContractCompat.fromJSON({ - contractAddress: injective.contracts.bnUSD!, - sender: account, - msg: { - cross_transfer: { - amount, - to: destination, - data, - }, - }, - funds: [ - { - denom: 'inj', - amount: xCallFee.rollback.toString(), - }, - { denom: bnUSD.address, amount }, - ], + return await this._crossTransfer({ + account, + inputAmount: inputAmount.multiply(-1), + destination, + data, + fee: xCallFee.rollback, }); - - const txResult = await this.getXService().msgBroadcastClient.broadcastWithFeeDelegation({ - msgs: msg, - injectiveAddress: account, - }); - - return txResult.txHash; } async depositXToken(xTransactionInput: XTransactionInput): Promise { From c7e2d00af8609f6e3bdb00e03da8784363f09dde Mon Sep 17 00:00:00 2001 From: swiftcc624 Date: Sat, 11 Jan 2025 02:29:52 +0800 Subject: [PATCH 27/33] refactor SuiXWalletClient --- .../src/xchains/sui/SuiXWalletClient.ts | 54 +++++++++++-------- 1 file changed, 33 insertions(+), 21 deletions(-) diff --git a/packages/xwagmi/src/xchains/sui/SuiXWalletClient.ts b/packages/xwagmi/src/xchains/sui/SuiXWalletClient.ts index 8700f1652..c84398a92 100644 --- a/packages/xwagmi/src/xchains/sui/SuiXWalletClient.ts +++ b/packages/xwagmi/src/xchains/sui/SuiXWalletClient.ts @@ -1,4 +1,4 @@ -import { Percent, XChainId } from '@balancednetwork/sdk-core'; +import { CurrencyAmount, Percent, XChainId } from '@balancednetwork/sdk-core'; import bnJs from '../icon/bnJs'; import { ICON_XCALL_NETWORK_ID, xTokenMap, xTokenMapBySymbol } from '@/constants'; @@ -61,24 +61,26 @@ export class SuiXWalletClient extends XWalletClient { } private async _deposit({ - amount, account, - xToken, + inputAmount, destination, data, + fee, // not used, just for compatibility }: { - amount: bigint; account: string; - xToken: XToken; + inputAmount: CurrencyAmount; destination: string; - data: Uint8Array; + data: any; + fee: bigint; }) { - const coinType = xToken.isNativeToken ? '0x2::sui::SUI' : xToken.address; + const amount = BigInt(inputAmount.quotient.toString()); + + const coinType = inputAmount.currency.isNativeToken ? '0x2::sui::SUI' : inputAmount.currency.address; const txb = new Transaction(); let depositCoin, feeCoin; - if (xToken.isNativeToken) { + if (inputAmount.currency.isNativeToken) { [depositCoin, feeCoin] = txb.splitCoins(txb.gas, [amount, XCALL_FEE_AMOUNT]); } else { const coins = ( @@ -118,19 +120,21 @@ export class SuiXWalletClient extends XWalletClient { } private async _crossTransfer({ - amount, account, - xToken, + inputAmount, destination, data, + fee, // not used, just for compatibility }: { - amount: bigint; account: string; - xToken: XToken; + inputAmount: CurrencyAmount; destination: string; - data: Uint8Array; + data: any; + fee: bigint; }) { - const coinType = xToken.address; + const amount = BigInt(inputAmount.quotient.toString()); + + const coinType = inputAmount.currency.address; const coins = ( await this.getXService().suiClient.getCoins({ @@ -171,13 +175,17 @@ export class SuiXWalletClient extends XWalletClient { } private async _sendCall({ + account, // not used, just for compatibility sourceChainId, destination, data, + fee, // not used, just for compatibility }: { + account: string; sourceChainId: XChainId; destination: string; data: any; + fee: bigint; }) { const envelope = toBytes( toHex( @@ -242,9 +250,9 @@ export class SuiXWalletClient extends XWalletClient { } if (isSpokeToken(inputAmount.currency)) { - return await this._crossTransfer({ amount, account, xToken: inputAmount.currency, destination, data }); + return await this._crossTransfer({ inputAmount, account, destination, data, fee: 0n }); } else { - return await this._deposit({ amount, account, xToken: inputAmount.currency, destination, data }); + return await this._deposit({ inputAmount, account, destination, data, fee: 0n }); } } @@ -255,11 +263,10 @@ export class SuiXWalletClient extends XWalletClient { return; } - const amount = BigInt(inputAmount.quotient.toString()); const destination = `${ICON_XCALL_NETWORK_ID}/${bnJs.Loans.address}`; const data = toBytes(JSON.stringify({})); - return await this._deposit({ amount, account, xToken: inputAmount.currency, destination, data }); + return await this._deposit({ inputAmount, account, destination, data, fee: 0n }); } async executeWithdrawCollateral(xTransactionInput: XTransactionInput) { @@ -274,9 +281,11 @@ export class SuiXWalletClient extends XWalletClient { const data = toHex(RLP.encode(['xWithdraw', uintToBytes(amount), usedCollateral])); return await this._sendCall({ + account, sourceChainId: direction.from, destination, data, + fee: 0n, }); } @@ -298,9 +307,11 @@ export class SuiXWalletClient extends XWalletClient { ); return await this._sendCall({ + account, sourceChainId: direction.from, destination, data, + fee: 0n, }); } @@ -368,13 +379,12 @@ export class SuiXWalletClient extends XWalletClient { async depositXToken(xTransactionInput: XTransactionInput): Promise { const { account, inputAmount, xCallFee } = xTransactionInput; const destination = `${ICON_XCALL_NETWORK_ID}/${bnJs.Dex.address}`; - const amount = BigInt(inputAmount.quotient.toString()); const data = toBytes(tokenData('_deposit', {})); if (isSpokeToken(inputAmount.currency)) { - return await this._crossTransfer({ amount, account, xToken: inputAmount.currency, destination, data }); + return await this._crossTransfer({ inputAmount, account, destination, data, fee: 0n }); } else { - return await this._deposit({ amount, account, xToken: inputAmount.currency, destination, data }); + return await this._deposit({ inputAmount, account, destination, data, fee: 0n }); } } async withdrawXToken(xTransactionInput: XTransactionInput): Promise { @@ -385,9 +395,11 @@ export class SuiXWalletClient extends XWalletClient { const xTokenOnIcon = xTokenMapBySymbol[ICON_XCALL_NETWORK_ID][inputAmount.currency.symbol]; const data = getWithdrawData(xTokenOnIcon.address, amount); return await this._sendCall({ + account, sourceChainId: direction.from, destination, data, + fee: 0n, }); } async addLiquidity(xTransactionInput: XTransactionInput): Promise { From 4a39e53441dc6442fd3b92a973ba13cb0cedf5f3 Mon Sep 17 00:00:00 2001 From: swiftcc624 Date: Sat, 11 Jan 2025 13:25:24 +0800 Subject: [PATCH 28/33] refactor StellarXWalletClient --- .../xchains/stellar/StellarXWalletClient.ts | 357 +++++++----------- 1 file changed, 131 insertions(+), 226 deletions(-) diff --git a/packages/xwagmi/src/xchains/stellar/StellarXWalletClient.ts b/packages/xwagmi/src/xchains/stellar/StellarXWalletClient.ts index 093456ad9..047dd8229 100644 --- a/packages/xwagmi/src/xchains/stellar/StellarXWalletClient.ts +++ b/packages/xwagmi/src/xchains/stellar/StellarXWalletClient.ts @@ -1,17 +1,16 @@ -import { Percent } from '@balancednetwork/sdk-core'; +import { CurrencyAmount, Percent, XChainId } from '@balancednetwork/sdk-core'; import bnJs from '../icon/bnJs'; import { ICON_XCALL_NETWORK_ID } from '@/constants'; import { FROM_SOURCES, TO_SOURCES, stellar } from '@/constants/xChains'; import { XWalletClient } from '@/core'; +import { XToken } from '@/types'; import { uintToBytes } from '@/utils'; import { XTransactionInput, XTransactionType } from '@/xcall/types'; import { getRlpEncodedSwapData, toICONDecimals } from '@/xcall/utils'; -import { StellarWalletsKit } from '@creit.tech/stellar-wallets-kit'; import { RLP } from '@ethereumjs/rlp'; import { BASE_FEE, Networks, TransactionBuilder, nativeToScVal } from '@stellar/stellar-sdk'; import { isSpokeToken } from '../archway/utils'; -import CustomSorobanServer from './CustomSorobanServer'; import { StellarXService } from './StellarXService'; import { STELLAR_RLP_DATA_TYPE, @@ -31,105 +30,136 @@ export class StellarXWalletClient extends XWalletClient { return Promise.resolve(undefined); } - async executeTransaction(xTransactionInput: XTransactionInput) { - const { type, account } = xTransactionInput; + private async _deposit({ + account, + inputAmount, + destination, + data, + fee, + }: { + account: string; + inputAmount: CurrencyAmount; + destination: string; + data: any; + fee: bigint; + }) { const stellarAccount = await this.getXService().server.loadAccount(account); - const sorobanServer = this.getXService().sorobanServer; - const walletsKit = this.getXService().walletsKit; - const simulateTxBuilder = new TransactionBuilder(stellarAccount, { + const server = this.getXService().sorobanServer; + const kit = this.getXService().walletsKit; + const txBuilder = new TransactionBuilder(stellarAccount, { fee: BASE_FEE, networkPassphrase: Networks.PUBLIC, }); - try { - switch (type) { - case XTransactionType.BRIDGE: - return await this.handleBridgeTransaction(xTransactionInput, simulateTxBuilder, sorobanServer, walletsKit); - case XTransactionType.SWAP: - return await this.handleSwapTransaction(xTransactionInput, simulateTxBuilder, sorobanServer, walletsKit); - case XTransactionType.DEPOSIT: - return await this.handleDepositCollateralTransaction( - xTransactionInput, - simulateTxBuilder, - sorobanServer, - walletsKit, - ); - case XTransactionType.WITHDRAW: - return await this.handleWithdrawCollateralTransaction( - xTransactionInput, - simulateTxBuilder, - sorobanServer, - walletsKit, - ); - case XTransactionType.BORROW: - return await this.handleBorrowTransaction(xTransactionInput, simulateTxBuilder, sorobanServer, walletsKit); - case XTransactionType.REPAY: - return await this.handleRepayLoanTransaction(xTransactionInput, simulateTxBuilder, sorobanServer, walletsKit); - default: - throw new Error('Unsupported transaction type'); - } - } catch (error) { - console.error('Error executing Stellar transaction:', error); - throw new Error(`Error executing Stellar transaction: ${error}`); + const params = [ + accountToScVal(account), + nativeToScVal(XLM_CONTRACT_ADDRESS, { type: 'address' }), + nativeToScVal(inputAmount.quotient, { type: 'u128' }), + nativeToScVal(destination), + nativeToScVal(data, { type: 'bytes' }), + ]; + + const hash = await sendTX(stellar.contracts.assetManager, 'deposit', params, txBuilder, server, kit); + return hash; + } + + private async _crossTransfer({ + account, + inputAmount, + destination, + data, + fee, + }: { + account: string; + inputAmount: CurrencyAmount; + destination: string; + data: any; + fee: bigint; + }) { + const stellarAccount = await this.getXService().server.loadAccount(account); + const server = this.getXService().sorobanServer; + const kit = this.getXService().walletsKit; + const txBuilder = new TransactionBuilder(stellarAccount, { + fee: BASE_FEE, + networkPassphrase: Networks.PUBLIC, + }); + + const params = [ + accountToScVal(account), + nativeToScVal(inputAmount.quotient, { type: 'u128' }), + nativeToScVal(destination), + nativeToScVal(data, { type: 'bytes' }), + ]; + + const hash = await sendTX(inputAmount.currency.wrapped.address, 'cross_transfer', params, txBuilder, server, kit); + return hash; + } + + private async _sendCall({ + account, + sourceChainId, + destination, + data, + fee, + }: { + account: string; + sourceChainId: XChainId; + destination: string; + data: any; + fee: bigint; + }) { + const stellarAccount = await this.getXService().server.loadAccount(account); + const server = this.getXService().sorobanServer; + const kit = this.getXService().walletsKit; + const txBuilder = new TransactionBuilder(stellarAccount, { + fee: BASE_FEE, + networkPassphrase: Networks.PUBLIC, + }); + + const envelope = { + destinations: TO_SOURCES[sourceChainId], + sources: FROM_SOURCES[sourceChainId], + message: [nativeToScVal('CallMessage', STELLAR_RLP_MSG_TYPE), nativeToScVal({ data }, STELLAR_RLP_DATA_TYPE)], + }; + + // send_call(tx_origin: address, sender: address, envelope: Envelope, to: string) + const params = [ + accountToScVal(account), + accountToScVal(account), + nativeToScVal(envelope, STELLAR_RLP_ENVELOPE_TYPE), + nativeToScVal(destination), + ]; + + const hash = await sendTX(stellar.contracts.xCall, 'send_call', params, txBuilder, server, kit); + return hash; + } + + async executeSwapOrBridge(xTransactionInput: XTransactionInput): Promise { + if (xTransactionInput.type === XTransactionType.BRIDGE) { + return await this.handleBridgeTransaction(xTransactionInput); + } else if (xTransactionInput.type === XTransactionType.SWAP) { + return await this.handleSwapTransaction(xTransactionInput); + } else { + throw new Error('Invalid XTransactionType'); } } - private async handleBridgeTransaction( - xTransactionInput: XTransactionInput, - txBuilder: TransactionBuilder, - server: CustomSorobanServer, - kit: StellarWalletsKit, - ): Promise { + private async handleBridgeTransaction(xTransactionInput: XTransactionInput): Promise { const { account, inputAmount, recipient, direction } = xTransactionInput; const receiver = `${direction.to}/${recipient}`; const destination = `${ICON_XCALL_NETWORK_ID}/${bnJs.Router.address}`; - const dataObj = { - method: '_swap', - params: { - path: [], - receiver, - }, - }; + const dataObj = { method: '_swap', params: { path: [], receiver } }; const encoder = new TextEncoder(); - const uint8Array = encoder.encode(JSON.stringify(dataObj)); - - const isNative = inputAmount.currency.symbol === 'XLM'; - const _isSpokeToken = isSpokeToken(inputAmount.currency); + const data = encoder.encode(JSON.stringify(dataObj)); - if (isNative) { - //deposit(from: address, token: address, amount: u128, to: option, data: option) - const params = [ - accountToScVal(account), - nativeToScVal(XLM_CONTRACT_ADDRESS, { type: 'address' }), - nativeToScVal(inputAmount.quotient, { type: 'u128' }), - nativeToScVal(destination), - nativeToScVal(uint8Array, { type: 'bytes' }), - ]; - - const hash = await sendTX(stellar.contracts.assetManager, 'deposit', params, txBuilder, server, kit); - return hash; - } else if (_isSpokeToken) { - //cross_transfer(from: address, amount: u128, to: string, data: option) - const params = [ - accountToScVal(account), - nativeToScVal(inputAmount.quotient, { type: 'u128' }), - nativeToScVal(destination), - nativeToScVal(uint8Array, { type: 'bytes' }), - ]; - - const hash = await sendTX(inputAmount.currency.wrapped.address, 'cross_transfer', params, txBuilder, server, kit); - return hash; + if (isSpokeToken(inputAmount.currency)) { + return await this._crossTransfer({ account, inputAmount, destination, data, fee: 0n }); } else { - throw new Error('Invalid currency for Stellar bridge'); + return await this._deposit({ account, inputAmount, destination, data, fee: 0n }); } } - private async handleSwapTransaction( - xTransactionInput: XTransactionInput, - txBuilder: TransactionBuilder, - server: CustomSorobanServer, - kit: StellarWalletsKit, - ): Promise { + private async handleSwapTransaction(xTransactionInput: XTransactionInput): Promise { const { inputAmount, executionTrade, account, recipient, direction, slippageTolerance } = xTransactionInput; const receiver = `${direction.to}/${recipient}`; @@ -140,77 +170,29 @@ export class StellarXWalletClient extends XWalletClient { const minReceived = executionTrade.minimumAmountOut(new Percent(slippageTolerance, 10_000)); const destination = `${ICON_XCALL_NETWORK_ID}/${bnJs.Router.address}`; const rlpEncodedData = getRlpEncodedSwapData(executionTrade, '_swap', receiver, minReceived); - const uint8Array = new Uint8Array(rlpEncodedData); - - const isNative = inputAmount.currency.symbol === 'XLM'; - const _isSpokeToken = isSpokeToken(inputAmount.currency); + const data = new Uint8Array(rlpEncodedData); - if (isNative) { - //deposit(from: address, token: address, amount: u128, to: option, data: option) - const params = [ - accountToScVal(account), - nativeToScVal(XLM_CONTRACT_ADDRESS, { type: 'address' }), - nativeToScVal(inputAmount.quotient, { type: 'u128' }), - nativeToScVal(destination), - nativeToScVal(uint8Array, { type: 'bytes' }), - ]; - - const hash = await sendTX(stellar.contracts.assetManager, 'deposit', params, txBuilder, server, kit); - return hash; - } else if (_isSpokeToken) { - //cross_transfer(from: address, amount: u128, to: string, data: option) - const params = [ - accountToScVal(account), - nativeToScVal(inputAmount.quotient, { type: 'u128' }), - nativeToScVal(destination), - nativeToScVal(uint8Array, { type: 'bytes' }), - ]; - - const hash = await sendTX(inputAmount.currency.wrapped.address, 'cross_transfer', params, txBuilder, server, kit); - return hash; + if (isSpokeToken(inputAmount.currency)) { + return await this._crossTransfer({ account, inputAmount, destination, data, fee: 0n }); } else { - throw new Error('Invalid currency for Stellar swap'); + return await this._deposit({ account, inputAmount, destination, data, fee: 0n }); } } - private async handleDepositCollateralTransaction( - xTransactionInput: XTransactionInput, - txBuilder: TransactionBuilder, - server: CustomSorobanServer, - kit: StellarWalletsKit, - ): Promise { + async executeDepositCollateral(xTransactionInput: XTransactionInput): Promise { const { inputAmount, account } = xTransactionInput; if (!inputAmount) { - return; + throw new Error('Invalid input amount'); } const destination = `${ICON_XCALL_NETWORK_ID}/${bnJs.Loans.address}`; const encoder = new TextEncoder(); - const uint8Array = encoder.encode(JSON.stringify({})); + const data = encoder.encode(JSON.stringify({})); - if (inputAmount.currency.symbol === 'XLM') { - //deposit(from: address, token: address, amount: u128, to: option, data: option) - const params = [ - accountToScVal(account), - nativeToScVal(XLM_CONTRACT_ADDRESS, { type: 'address' }), - nativeToScVal(inputAmount.quotient, { type: 'u128' }), - nativeToScVal(destination), - nativeToScVal(uint8Array, { type: 'bytes' }), - ]; - - const hash = await sendTX(stellar.contracts.assetManager, 'deposit', params, txBuilder, server, kit); - return hash; - } else { - throw new Error('Invalid currency for Stellar swap'); - } + return await this._deposit({ account, inputAmount, destination, data, fee: 0n }); } - private async handleWithdrawCollateralTransaction( - xTransactionInput: XTransactionInput, - txBuilder: TransactionBuilder, - server: CustomSorobanServer, - kit: StellarWalletsKit, - ): Promise { + async executeWithdrawCollateral(xTransactionInput: XTransactionInput): Promise { const { inputAmount, account, direction, usedCollateral } = xTransactionInput; if (!inputAmount || !usedCollateral) { return; @@ -218,33 +200,11 @@ export class StellarXWalletClient extends XWalletClient { const destination = `${ICON_XCALL_NETWORK_ID}/${bnJs.Loans.address}`; const amount = toICONDecimals(inputAmount.multiply(-1)); - const envelope = { - destinations: TO_SOURCES[direction.from], - sources: FROM_SOURCES[direction.from], - message: [ - nativeToScVal('CallMessage', STELLAR_RLP_MSG_TYPE), - nativeToScVal({ data: RLP.encode(['xWithdraw', uintToBytes(amount), usedCollateral]) }, STELLAR_RLP_DATA_TYPE), - ], - }; - - // send_call(tx_origin: address, sender: address, envelope: Envelope, to: string) - const params = [ - accountToScVal(account), - accountToScVal(account), - nativeToScVal(envelope, STELLAR_RLP_ENVELOPE_TYPE), - nativeToScVal(destination), - ]; - - const hash = await sendTX(stellar.contracts.xCall, 'send_call', params, txBuilder, server, kit); - return hash; + const data = RLP.encode(['xWithdraw', uintToBytes(amount), usedCollateral]); + return await this._sendCall({ account, sourceChainId: direction.from, destination, data, fee: 0n }); } - private async handleBorrowTransaction( - xTransactionInput: XTransactionInput, - txBuilder: TransactionBuilder, - server: CustomSorobanServer, - kit: StellarWalletsKit, - ): Promise { + async executeBorrow(xTransactionInput: XTransactionInput): Promise { const { inputAmount, account, direction, usedCollateral, recipient } = xTransactionInput; if (!inputAmount || !usedCollateral) { return; @@ -257,74 +217,19 @@ export class StellarXWalletClient extends XWalletClient { ? ['xBorrow', usedCollateral, uintToBytes(amount), Buffer.from(recipient)] : ['xBorrow', usedCollateral, uintToBytes(amount)], ); - const envelope = { - destinations: TO_SOURCES[direction.from], - sources: FROM_SOURCES[direction.from], - message: [nativeToScVal('CallMessage', STELLAR_RLP_MSG_TYPE), nativeToScVal({ data }, STELLAR_RLP_DATA_TYPE)], - }; - - // send_call(tx_origin: address, sender: address, envelope: Envelope, to: string) - const params = [ - accountToScVal(account), - accountToScVal(account), - nativeToScVal(envelope, STELLAR_RLP_ENVELOPE_TYPE), - nativeToScVal(destination), - ]; - - const hash = await sendTX(stellar.contracts.xCall, 'send_call', params, txBuilder, server, kit); - return hash; + return await this._sendCall({ account, sourceChainId: direction.from, destination, data, fee: 0n }); } - private async handleRepayLoanTransaction( - xTransactionInput: XTransactionInput, - txBuilder: TransactionBuilder, - server: CustomSorobanServer, - kit: StellarWalletsKit, - ): Promise { + async executeRepay(xTransactionInput: XTransactionInput): Promise { const { inputAmount, account, usedCollateral, recipient } = xTransactionInput; if (!inputAmount || !usedCollateral) { return; } const destination = `${ICON_XCALL_NETWORK_ID}/${bnJs.Loans.address}`; const dataObj = recipient ? { _collateral: usedCollateral, _to: recipient } : { _collateral: usedCollateral }; - const encoder = new TextEncoder(); - const uint8Array = encoder.encode(JSON.stringify(dataObj)); - - if (inputAmount.currency.symbol === 'bnUSD') { - //cross_transfer(from: address, amount: u128, to: string, data: option) - const params = [ - accountToScVal(account), - nativeToScVal(inputAmount.multiply(-1).quotient, { type: 'u128' }), - nativeToScVal(destination), - nativeToScVal(uint8Array, { type: 'bytes' }), - ]; - - const hash = await sendTX(stellar.contracts.bnUSD!, 'cross_transfer', params, txBuilder, server, kit); - return hash; - } else { - throw new Error('Invalid currency for Stellar repay loan'); - } - } - - async executeSwapOrBridge(xTransactionInput: XTransactionInput): Promise { - throw new Error('Method not implemented.'); - } - - async executeDepositCollateral(xTransactionInput: XTransactionInput): Promise { - throw new Error('Method not implemented.'); - } - - async executeWithdrawCollateral(xTransactionInput: XTransactionInput): Promise { - throw new Error('Method not implemented.'); - } - - async executeBorrow(xTransactionInput: XTransactionInput): Promise { - throw new Error('Method not implemented.'); - } - - async executeRepay(xTransactionInput: XTransactionInput): Promise { - throw new Error('Method not implemented.'); + const data = encoder.encode(JSON.stringify(dataObj)); + return await this._crossTransfer({ account, inputAmount: inputAmount.multiply(-1), destination, data, fee: 0n }); } async depositXToken(xTransactionInput: XTransactionInput): Promise { From 1f7e3f73c38f8850b675aff187cc6c65a1bac173 Mon Sep 17 00:00:00 2001 From: swiftcc624 Date: Sat, 11 Jan 2025 13:37:35 +0800 Subject: [PATCH 29/33] refactor XWalletClient classes --- .../src/xchains/evm/EvmXWalletClient.ts | 115 +++--------------- .../injective/InjectiveXWalletClient.ts | 45 ++----- .../src/xchains/solana/SolanaXWalletClient.ts | 48 +------- .../src/xchains/sui/SuiXWalletClient.ts | 24 +--- 4 files changed, 37 insertions(+), 195 deletions(-) diff --git a/packages/xwagmi/src/xchains/evm/EvmXWalletClient.ts b/packages/xwagmi/src/xchains/evm/EvmXWalletClient.ts index 09b953c48..af8479326 100644 --- a/packages/xwagmi/src/xchains/evm/EvmXWalletClient.ts +++ b/packages/xwagmi/src/xchains/evm/EvmXWalletClient.ts @@ -205,21 +205,9 @@ export class EvmXWalletClient extends XWalletClient { } if (isSpokeToken(inputAmount.currency)) { - return await this._crossTransfer({ - account, - inputAmount, - destination, - data, - fee: xCallFee.rollback, - }); + return await this._crossTransfer({ account, inputAmount, destination, data, fee: xCallFee.rollback }); } else { - return await this._deposit({ - account, - inputAmount, - destination, - data, - fee: xCallFee.rollback, - }); + return await this._deposit({ account, inputAmount, destination, data, fee: xCallFee.rollback }); } } @@ -233,13 +221,7 @@ export class EvmXWalletClient extends XWalletClient { const destination = `${ICON_XCALL_NETWORK_ID}/${bnJs.Loans.address}`; const data = toHex(JSON.stringify({})); - return await this._deposit({ - inputAmount, - account, - destination, - data, - fee: xCallFee.rollback, - }); + return await this._deposit({ inputAmount, account, destination, data, fee: xCallFee.rollback }); } async executeWithdrawCollateral(xTransactionInput: XTransactionInput) { @@ -253,13 +235,7 @@ export class EvmXWalletClient extends XWalletClient { const destination = `${ICON_XCALL_NETWORK_ID}/${bnJs.Loans.address}`; const data = toHex(RLP.encode(['xWithdraw', uintToBytes(amount), usedCollateral])); - return await this._sendCall({ - account, - sourceChainId: direction.from, - destination, - data, - fee: xCallFee.rollback, - }); + return await this._sendCall({ account, sourceChainId: direction.from, destination, data, fee: xCallFee.rollback }); } async executeBorrow(xTransactionInput: XTransactionInput) { @@ -279,13 +255,7 @@ export class EvmXWalletClient extends XWalletClient { ), ); - return await this._sendCall({ - account, - sourceChainId: direction.from, - destination, - data, - fee: xCallFee.rollback, - }); + return await this._sendCall({ account, sourceChainId: direction.from, destination, data, fee: xCallFee.rollback }); } async executeRepay(xTransactionInput: XTransactionInput) { @@ -299,14 +269,8 @@ export class EvmXWalletClient extends XWalletClient { const data = toHex( JSON.stringify(recipient ? { _collateral: usedCollateral, _to: recipient } : { _collateral: usedCollateral }), ); - - return await this._crossTransfer({ - account, - inputAmount: inputAmount.multiply(-1), - destination, - data, - fee: xCallFee.rollback, - }); + const _inputAmount = inputAmount.multiply(-1); + return await this._crossTransfer({ account, inputAmount: _inputAmount, destination, data, fee: xCallFee.rollback }); } // liquidity related @@ -318,45 +282,27 @@ export class EvmXWalletClient extends XWalletClient { let hash; if (isSpokeToken(inputAmount.currency)) { - hash = await this._crossTransfer({ - account, - inputAmount, - destination, - data, - fee: xCallFee.rollback, - }); + hash = await this._crossTransfer({ account, inputAmount, destination, data, fee: xCallFee.rollback }); } else { - hash = await this._deposit({ - account, - inputAmount, - destination, - data, - fee: xCallFee.rollback, - }); + hash = await this._deposit({ account, inputAmount, destination, data, fee: xCallFee.rollback }); } return hash; } async withdrawXToken(xTransactionInput: XTransactionInput) { - const { account, inputAmount, xCallFee } = xTransactionInput; + const { account, inputAmount, xCallFee, direction } = xTransactionInput; const destination = `${ICON_XCALL_NETWORK_ID}/${bnJs.Dex.address}`; const amount = BigInt(inputAmount.quotient.toString()); const xTokenOnIcon = xTokenMapBySymbol[ICON_XCALL_NETWORK_ID][inputAmount.currency.symbol]; const data = toHex(getWithdrawData(xTokenOnIcon.address, amount)); - return await this._sendCall({ - account, - sourceChainId: inputAmount.currency.xChainId, - destination, - data, - fee: xCallFee.rollback, - }); + return await this._sendCall({ account, sourceChainId: direction.from, destination, data, fee: xCallFee.rollback }); } async addLiquidity(xTransactionInput: XTransactionInput) { - const { account, inputAmount, outputAmount, xCallFee } = xTransactionInput; + const { account, inputAmount, outputAmount, xCallFee, direction } = xTransactionInput; if (!outputAmount) { throw new Error('outputAmount is required'); @@ -369,17 +315,11 @@ export class EvmXWalletClient extends XWalletClient { const xTokenBOnIcon = xTokenMapBySymbol[ICON_XCALL_NETWORK_ID][outputAmount.currency.symbol]; const data = toHex(getAddLPData(xTokenAOnIcon.address, xTokenBOnIcon.address, amountA, amountB, true, 1_000n)); - return await this._sendCall({ - account, - sourceChainId: inputAmount.currency.xChainId, - destination, - data, - fee: xCallFee.rollback, - }); + return await this._sendCall({ account, sourceChainId: direction.from, destination, data, fee: xCallFee.rollback }); } async removeLiquidity(xTransactionInput: XTransactionInput) { - const { account, inputAmount, poolId, xCallFee } = xTransactionInput; + const { account, inputAmount, poolId, xCallFee, direction } = xTransactionInput; if (!poolId) { throw new Error('poolId is required'); @@ -389,17 +329,11 @@ export class EvmXWalletClient extends XWalletClient { const amount = BigInt(inputAmount.quotient.toString()); const data = toHex(getXRemoveData(poolId, amount, true)); - return await this._sendCall({ - account, - sourceChainId: inputAmount.currency.xChainId, - destination, - data, - fee: xCallFee.rollback, - }); + return await this._sendCall({ account, sourceChainId: direction.from, destination, data, fee: xCallFee.rollback }); } async stake(xTransactionInput: XTransactionInput) { - const { account, inputAmount, poolId, xCallFee } = xTransactionInput; + const { account, inputAmount, poolId, xCallFee, direction } = xTransactionInput; if (!poolId) { throw new Error('poolId is required'); @@ -407,16 +341,9 @@ export class EvmXWalletClient extends XWalletClient { const destination = `${ICON_XCALL_NETWORK_ID}/${bnJs.Dex.address}`; const amount = BigInt(inputAmount.quotient.toString()); - const data = toHex(getStakeData(`${ICON_XCALL_NETWORK_ID}/${bnJs.StakedLP.address}`, poolId, amount)); - return await this._sendCall({ - account, - sourceChainId: inputAmount.currency.xChainId, - destination, - data, - fee: xCallFee.rollback, - }); + return await this._sendCall({ account, sourceChainId: direction.from, destination, data, fee: xCallFee.rollback }); } async unstake(xTransactionInput: XTransactionInput) { @@ -430,13 +357,7 @@ export class EvmXWalletClient extends XWalletClient { const amount = BigInt(inputAmount.quotient.toString()); const data = toHex(getUnStakeData(poolId, amount)); - return await this._sendCall({ - account, - sourceChainId: inputAmount.currency.xChainId, - destination, - data, - fee: xCallFee.rollback, - }); + return await this._sendCall({ account, sourceChainId: direction.from, destination, data, fee: xCallFee.rollback }); } async claimRewards(xTransactionInput: XTransactionInput): Promise { diff --git a/packages/xwagmi/src/xchains/injective/InjectiveXWalletClient.ts b/packages/xwagmi/src/xchains/injective/InjectiveXWalletClient.ts index f532e0d23..aeb3d1e75 100644 --- a/packages/xwagmi/src/xchains/injective/InjectiveXWalletClient.ts +++ b/packages/xwagmi/src/xchains/injective/InjectiveXWalletClient.ts @@ -178,6 +178,7 @@ export class InjectiveXWalletClient extends XWalletClient { const { type, direction, inputAmount, executionTrade, account, recipient, xCallFee, slippageTolerance } = xTransactionInput; + const destination = `${ICON_XCALL_NETWORK_ID}/${bnJs.Router.address}`; const receiver = `${direction.to}/${recipient}`; let data; @@ -204,21 +205,9 @@ export class InjectiveXWalletClient extends XWalletClient { } if (isSpokeToken(inputAmount.currency)) { - return await this._crossTransfer({ - account, - inputAmount, - destination: `${ICON_XCALL_NETWORK_ID}/${bnJs.Router.address}`, - data, - fee: xCallFee.rollback, - }); + return await this._crossTransfer({ account, inputAmount, destination, data, fee: xCallFee.rollback }); } else { - return await this._deposit({ - account, - inputAmount, - destination: `${ICON_XCALL_NETWORK_ID}/${bnJs.Router.address}`, - data, - fee: xCallFee.rollback, - }); + return await this._deposit({ account, inputAmount, destination, data, fee: xCallFee.rollback }); } } @@ -229,15 +218,10 @@ export class InjectiveXWalletClient extends XWalletClient { return; } + const destination = `${ICON_XCALL_NETWORK_ID}/${bnJs.Loans.address}`; const data = getBytesFromString(JSON.stringify({})); - return await this._deposit({ - account, - inputAmount, - destination: `${ICON_XCALL_NETWORK_ID}/${bnJs.Loans.address}`, - data, - fee: xCallFee.rollback, - }); + return await this._deposit({ account, inputAmount, destination, data, fee: xCallFee.rollback }); } async executeWithdrawCollateral(xTransactionInput: XTransactionInput) { @@ -247,16 +231,11 @@ export class InjectiveXWalletClient extends XWalletClient { return; } + const destination = `${ICON_XCALL_NETWORK_ID}/${bnJs.Loans.address}`; const amount = toICONDecimals(inputAmount.multiply(-1)); const data = Array.from(RLP.encode(['xWithdraw', uintToBytes(amount), usedCollateral])); - return await this._sendCall({ - account, - sourceChainId: this.xChainId, - destination: `${ICON_XCALL_NETWORK_ID}/${bnJs.Loans.address}`, - data, - fee: xCallFee.rollback, - }); + return await this._sendCall({ account, sourceChainId: this.xChainId, destination, data, fee: xCallFee.rollback }); } async executeBorrow(xTransactionInput: XTransactionInput) { @@ -265,6 +244,8 @@ export class InjectiveXWalletClient extends XWalletClient { if (!inputAmount || !usedCollateral) { return; } + + const destination = `${ICON_XCALL_NETWORK_ID}/${bnJs.Loans.address}`; const amount = BigInt(inputAmount.quotient.toString()); const data = Array.from( RLP.encode( @@ -274,13 +255,7 @@ export class InjectiveXWalletClient extends XWalletClient { ), ); - return await this._sendCall({ - account, - sourceChainId: this.xChainId, - destination: `${ICON_XCALL_NETWORK_ID}/${bnJs.Loans.address}`, - data, - fee: xCallFee.rollback, - }); + return await this._sendCall({ account, sourceChainId: this.xChainId, destination, data, fee: xCallFee.rollback }); } async executeRepay(xTransactionInput: XTransactionInput) { diff --git a/packages/xwagmi/src/xchains/solana/SolanaXWalletClient.ts b/packages/xwagmi/src/xchains/solana/SolanaXWalletClient.ts index e6b069bec..f673ee5bb 100644 --- a/packages/xwagmi/src/xchains/solana/SolanaXWalletClient.ts +++ b/packages/xwagmi/src/xchains/solana/SolanaXWalletClient.ts @@ -338,21 +338,9 @@ export class SolanaXWalletClient extends XWalletClient { } if (isSpokeToken(inputAmount.currency)) { - return await this._crossTransfer({ - account, - inputAmount, - destination, - data, - fee: 0n, - }); + return await this._crossTransfer({ account, inputAmount, destination, data, fee: 0n }); } else { - return await this._deposit({ - account, - inputAmount, - destination, - data, - fee: 0n, - }); + return await this._deposit({ account, inputAmount, destination, data, fee: 0n }); } } @@ -362,13 +350,7 @@ export class SolanaXWalletClient extends XWalletClient { const destination = `${ICON_XCALL_NETWORK_ID}/${bnJs.Loans.address}`; const data: any = toBytes(JSON.stringify({})); - return await this._deposit({ - account, - inputAmount, - destination, - data, - fee: 0n, - }); + return await this._deposit({ account, inputAmount, destination, data, fee: 0n }); } async executeWithdrawCollateral(xTransactionInput: XTransactionInput) { @@ -383,13 +365,7 @@ export class SolanaXWalletClient extends XWalletClient { const data = rlp.encode(['xWithdraw', uintToBytes(amount), usedCollateral]); - return await this._sendCall({ - account, - sourceChainId: direction.from, - destination, - data, - fee: 0n, - }); + return await this._sendCall({ account, sourceChainId: direction.from, destination, data, fee: 0n }); } async executeBorrow(xTransactionInput: XTransactionInput) { @@ -408,13 +384,7 @@ export class SolanaXWalletClient extends XWalletClient { : ['xBorrow', usedCollateral, uintToBytes(amount)], ); - return await this._sendCall({ - account, - sourceChainId: direction.from, - destination, - data, - fee: 0n, - }); + return await this._sendCall({ account, sourceChainId: direction.from, destination, data, fee: 0n }); } async executeRepay(xTransactionInput: XTransactionInput) { @@ -428,13 +398,7 @@ export class SolanaXWalletClient extends XWalletClient { const data: any = toBytes( JSON.stringify(recipient ? { _collateral: usedCollateral, _to: recipient } : { _collateral: usedCollateral }), ); - return await this._crossTransfer({ - account, - inputAmount: inputAmount.multiply(-1), - destination, - data, - fee: 0n, - }); + return await this._crossTransfer({ account, inputAmount: inputAmount.multiply(-1), destination, data, fee: 0n }); } async depositXToken(xTransactionInput: XTransactionInput): Promise { diff --git a/packages/xwagmi/src/xchains/sui/SuiXWalletClient.ts b/packages/xwagmi/src/xchains/sui/SuiXWalletClient.ts index c84398a92..884e62f48 100644 --- a/packages/xwagmi/src/xchains/sui/SuiXWalletClient.ts +++ b/packages/xwagmi/src/xchains/sui/SuiXWalletClient.ts @@ -280,13 +280,7 @@ export class SuiXWalletClient extends XWalletClient { const destination = `${ICON_XCALL_NETWORK_ID}/${bnJs.Loans.address}`; const data = toHex(RLP.encode(['xWithdraw', uintToBytes(amount), usedCollateral])); - return await this._sendCall({ - account, - sourceChainId: direction.from, - destination, - data, - fee: 0n, - }); + return await this._sendCall({ account, sourceChainId: direction.from, destination, data, fee: 0n }); } async executeBorrow(xTransactionInput: XTransactionInput) { @@ -306,13 +300,7 @@ export class SuiXWalletClient extends XWalletClient { ), ); - return await this._sendCall({ - account, - sourceChainId: direction.from, - destination, - data, - fee: 0n, - }); + return await this._sendCall({ account, sourceChainId: direction.from, destination, data, fee: 0n }); } async executeRepay(xTransactionInput: XTransactionInput) { @@ -394,13 +382,7 @@ export class SuiXWalletClient extends XWalletClient { const amount = BigInt(inputAmount.quotient.toString()); const xTokenOnIcon = xTokenMapBySymbol[ICON_XCALL_NETWORK_ID][inputAmount.currency.symbol]; const data = getWithdrawData(xTokenOnIcon.address, amount); - return await this._sendCall({ - account, - sourceChainId: direction.from, - destination, - data, - fee: 0n, - }); + return await this._sendCall({ account, sourceChainId: direction.from, destination, data, fee: 0n }); } async addLiquidity(xTransactionInput: XTransactionInput): Promise { throw new Error('Method not implemented.'); From 3315ef2e5633484cb0eb3b3619d6e576a6999c7e Mon Sep 17 00:00:00 2001 From: swiftcc624 Date: Sat, 11 Jan 2025 15:46:19 +0800 Subject: [PATCH 30/33] refactor XWalletClient --- packages/xwagmi/src/core/XWalletClient.ts | 225 +++++++++++++++- .../xwagmi/src/{xchains/evm => core}/utils.ts | 0 .../xchains/archway/ArchwayXWalletClient.ts | 66 +---- .../src/xchains/evm/EvmXWalletClient.ts | 254 +----------------- .../src/xchains/havah/HavahXWalletClient.ts | 66 +---- .../src/xchains/icon/IconXWalletClient.ts | 12 +- .../injective/InjectiveXWalletClient.ts | 65 +---- .../src/xchains/solana/SolanaXWalletClient.ts | 66 +---- .../xchains/stellar/StellarXWalletClient.ts | 72 +---- .../src/xchains/sui/SuiXWalletClient.ts | 89 +----- 10 files changed, 260 insertions(+), 655 deletions(-) rename packages/xwagmi/src/{xchains/evm => core}/utils.ts (100%) diff --git a/packages/xwagmi/src/core/XWalletClient.ts b/packages/xwagmi/src/core/XWalletClient.ts index 0c58b2fd8..cc3cf7f9f 100644 --- a/packages/xwagmi/src/core/XWalletClient.ts +++ b/packages/xwagmi/src/core/XWalletClient.ts @@ -1,6 +1,28 @@ +import { ICON_XCALL_NETWORK_ID, xTokenMapBySymbol } from '@/constants'; +import { uintToBytes } from '@/utils'; +import { getRlpEncodedSwapData, toICONDecimals } from '@/xcall'; import { XTransactionInput, XTransactionType } from '@/xcall/types'; -import { CurrencyAmount } from '@balancednetwork/sdk-core'; +import { isSpokeToken } from '@/xchains/archway'; +import { bnJs } from '@/xchains/icon'; +import { CurrencyAmount, Percent } from '@balancednetwork/sdk-core'; +import { RLP } from '@ethereumjs/rlp'; import { XChainId, XToken } from '../types'; +import { getAddLPData, getStakeData, getUnStakeData, getWithdrawData, getXRemoveData, tokenData } from './utils'; + +export interface DepositParams { + account: string; + inputAmount: CurrencyAmount; + destination: string; + data: any; + fee: bigint; +} +export interface SendCallParams { + account: string; + sourceChainId: XChainId; + destination: string; + data: any; + fee: bigint; +} export abstract class XWalletClient { public xChainId: XChainId; @@ -14,6 +36,10 @@ export abstract class XWalletClient { owner: string, ): Promise; + abstract _deposit({ account, inputAmount, destination, data, fee }: DepositParams): Promise; + abstract _crossTransfer({ account, inputAmount, destination, data, fee }: DepositParams): Promise; + abstract _sendCall({ account, sourceChainId, destination, data, fee }: SendCallParams): Promise; + async executeTransaction(xTransactionInput: XTransactionInput, options?: any): Promise { const { type } = xTransactionInput; switch (type) { @@ -50,17 +76,188 @@ export abstract class XWalletClient { } } - abstract executeSwapOrBridge(xTransactionInput: XTransactionInput): Promise; - abstract executeDepositCollateral(xTransactionInput: XTransactionInput): Promise; - abstract executeWithdrawCollateral(xTransactionInput: XTransactionInput): Promise; - abstract executeBorrow(xTransactionInput: XTransactionInput): Promise; - abstract executeRepay(xTransactionInput: XTransactionInput): Promise; - - abstract depositXToken(xTransactionInput: XTransactionInput): Promise; - abstract withdrawXToken(xTransactionInput: XTransactionInput): Promise; - abstract addLiquidity(xTransactionInput: XTransactionInput): Promise; - abstract removeLiquidity(xTransactionInput: XTransactionInput): Promise; - abstract stake(xTransactionInput: XTransactionInput): Promise; - abstract unstake(xTransactionInput: XTransactionInput): Promise; - abstract claimRewards(xTransactionInput: XTransactionInput): Promise; + async executeSwapOrBridge(xTransactionInput: XTransactionInput): Promise { + const { type, direction, inputAmount, recipient, account, xCallFee, executionTrade, slippageTolerance } = + xTransactionInput; + + const receiver = `${direction.to}/${recipient}`; + const destination = `${ICON_XCALL_NETWORK_ID}/${bnJs.Router.address}`; + + let data; + if (type === XTransactionType.SWAP) { + if (!executionTrade || !slippageTolerance) { + throw new Error('executionTrade and slippageTolerance are required'); + } + const minReceived = executionTrade.minimumAmountOut(new Percent(slippageTolerance, 10_000)); + data = getRlpEncodedSwapData(executionTrade, '_swap', receiver, minReceived); + } else if (type === XTransactionType.BRIDGE) { + data = JSON.stringify({ + method: '_swap', + params: { + path: [], + receiver: receiver, + }, + }); + } else { + throw new Error('Invalid XTransactionType'); + } + + if (isSpokeToken(inputAmount.currency)) { + return await this._crossTransfer({ account, inputAmount, destination, data, fee: xCallFee.rollback }); + } else { + return await this._deposit({ account, inputAmount, destination, data, fee: xCallFee.rollback }); + } + } + + async executeDepositCollateral(xTransactionInput: XTransactionInput): Promise { + const { inputAmount, account, xCallFee } = xTransactionInput; + + if (!inputAmount) { + throw new Error('inputAmount is required'); + } + + const destination = `${ICON_XCALL_NETWORK_ID}/${bnJs.Loans.address}`; + const data = JSON.stringify({}); + + return await this._deposit({ inputAmount, account, destination, data, fee: xCallFee.rollback }); + } + + async executeWithdrawCollateral(xTransactionInput: XTransactionInput): Promise { + const { inputAmount, account, xCallFee, usedCollateral, direction } = xTransactionInput; + + if (!inputAmount || !usedCollateral) { + throw new Error('inputAmount and usedCollateral are required'); + } + + const amount = toICONDecimals(inputAmount.multiply(-1)); + const destination = `${ICON_XCALL_NETWORK_ID}/${bnJs.Loans.address}`; + const data = RLP.encode(['xWithdraw', uintToBytes(amount), usedCollateral]); + + return await this._sendCall({ account, sourceChainId: direction.from, destination, data, fee: xCallFee.rollback }); + } + + async executeBorrow(xTransactionInput: XTransactionInput): Promise { + const { inputAmount, account, xCallFee, usedCollateral, recipient, direction } = xTransactionInput; + + if (!inputAmount || !usedCollateral) { + throw new Error('inputAmount and usedCollateral are required'); + } + + const amount = BigInt(inputAmount.quotient.toString()); + const destination = `${ICON_XCALL_NETWORK_ID}/${bnJs.Loans.address}`; + const data = RLP.encode( + recipient + ? ['xBorrow', usedCollateral, uintToBytes(amount), Buffer.from(recipient)] + : ['xBorrow', usedCollateral, uintToBytes(amount)], + ); + + return await this._sendCall({ account, sourceChainId: direction.from, destination, data, fee: xCallFee.rollback }); + } + + async executeRepay(xTransactionInput: XTransactionInput): Promise { + const { inputAmount, account, xCallFee, usedCollateral, recipient, direction } = xTransactionInput; + + if (!inputAmount || !usedCollateral) { + throw new Error('inputAmount and usedCollateral are required'); + } + + const destination = `${ICON_XCALL_NETWORK_ID}/${bnJs.Loans.address}`; + const data = JSON.stringify( + recipient ? { _collateral: usedCollateral, _to: recipient } : { _collateral: usedCollateral }, + ); + + const _inputAmount = inputAmount.multiply(-1); + return await this._crossTransfer({ account, inputAmount: _inputAmount, destination, data, fee: xCallFee.rollback }); + } + + // liquidity related + async depositXToken(xTransactionInput: XTransactionInput): Promise { + const { account, inputAmount, xCallFee } = xTransactionInput; + + const destination = `${ICON_XCALL_NETWORK_ID}/${bnJs.Dex.address}`; + const data = tokenData('_deposit', {}); + + let hash; + if (isSpokeToken(inputAmount.currency)) { + hash = await this._crossTransfer({ account, inputAmount, destination, data, fee: xCallFee.rollback }); + } else { + hash = await this._deposit({ account, inputAmount, destination, data, fee: xCallFee.rollback }); + } + + return hash; + } + + async withdrawXToken(xTransactionInput: XTransactionInput): Promise { + const { account, inputAmount, xCallFee, direction } = xTransactionInput; + + const destination = `${ICON_XCALL_NETWORK_ID}/${bnJs.Dex.address}`; + const amount = BigInt(inputAmount.quotient.toString()); + const xTokenOnIcon = xTokenMapBySymbol[ICON_XCALL_NETWORK_ID][inputAmount.currency.symbol]; + const data = getWithdrawData(xTokenOnIcon.address, amount); + + return await this._sendCall({ account, sourceChainId: direction.from, destination, data, fee: xCallFee.rollback }); + } + + async addLiquidity(xTransactionInput: XTransactionInput): Promise { + const { account, inputAmount, outputAmount, xCallFee, direction } = xTransactionInput; + + if (!outputAmount) { + throw new Error('outputAmount is required'); + } + + const destination = `${ICON_XCALL_NETWORK_ID}/${bnJs.Dex.address}`; + const amountA = BigInt(inputAmount.quotient.toString()); + const amountB = BigInt(outputAmount.quotient.toString()); + const xTokenAOnIcon = xTokenMapBySymbol[ICON_XCALL_NETWORK_ID][inputAmount.currency.symbol]; + const xTokenBOnIcon = xTokenMapBySymbol[ICON_XCALL_NETWORK_ID][outputAmount.currency.symbol]; + const data = getAddLPData(xTokenAOnIcon.address, xTokenBOnIcon.address, amountA, amountB, true, 1_000n); + + return await this._sendCall({ account, sourceChainId: direction.from, destination, data, fee: xCallFee.rollback }); + } + + async removeLiquidity(xTransactionInput: XTransactionInput): Promise { + const { account, inputAmount, poolId, xCallFee, direction } = xTransactionInput; + + if (!poolId) { + throw new Error('poolId is required'); + } + + const destination = `${ICON_XCALL_NETWORK_ID}/${bnJs.Dex.address}`; + const amount = BigInt(inputAmount.quotient.toString()); + const data = getXRemoveData(poolId, amount, true); + + return await this._sendCall({ account, sourceChainId: direction.from, destination, data, fee: xCallFee.rollback }); + } + + async stake(xTransactionInput: XTransactionInput): Promise { + const { account, inputAmount, poolId, xCallFee, direction } = xTransactionInput; + + if (!poolId) { + throw new Error('poolId is required'); + } + + const destination = `${ICON_XCALL_NETWORK_ID}/${bnJs.Dex.address}`; + const amount = BigInt(inputAmount.quotient.toString()); + const data = getStakeData(`${ICON_XCALL_NETWORK_ID}/${bnJs.StakedLP.address}`, poolId, amount); + + return await this._sendCall({ account, sourceChainId: direction.from, destination, data, fee: xCallFee.rollback }); + } + + async unstake(xTransactionInput: XTransactionInput): Promise { + const { account, inputAmount, poolId, xCallFee, direction } = xTransactionInput; + + if (!poolId) { + throw new Error('poolId is required'); + } + + const destination = `${ICON_XCALL_NETWORK_ID}/${bnJs.StakedLP.address}`; + const amount = BigInt(inputAmount.quotient.toString()); + const data = getUnStakeData(poolId, amount); + + return await this._sendCall({ account, sourceChainId: direction.from, destination, data, fee: xCallFee.rollback }); + } + + async claimRewards(xTransactionInput: XTransactionInput): Promise { + throw new Error('Method not implemented.'); + } } diff --git a/packages/xwagmi/src/xchains/evm/utils.ts b/packages/xwagmi/src/core/utils.ts similarity index 100% rename from packages/xwagmi/src/xchains/evm/utils.ts rename to packages/xwagmi/src/core/utils.ts diff --git a/packages/xwagmi/src/xchains/archway/ArchwayXWalletClient.ts b/packages/xwagmi/src/xchains/archway/ArchwayXWalletClient.ts index 932876cfe..3ec044a1a 100644 --- a/packages/xwagmi/src/xchains/archway/ArchwayXWalletClient.ts +++ b/packages/xwagmi/src/xchains/archway/ArchwayXWalletClient.ts @@ -3,7 +3,7 @@ import bnJs from '../icon/bnJs'; import { ICON_XCALL_NETWORK_ID } from '@/constants'; import { archway } from '@/constants/xChains'; -import { XWalletClient } from '@/core/XWalletClient'; +import { DepositParams, SendCallParams, XWalletClient } from '@/core/XWalletClient'; import { XToken } from '@/types'; import { XSigningArchwayClient } from '@/xchains/archway/XSigningArchwayClient'; import { getFeeParam, isDenomAsset, isSpokeToken } from '@/xchains/archway/utils'; @@ -43,19 +43,7 @@ export class ArchwayXWalletClient extends XWalletClient { } } - private async _deposit({ - account, - inputAmount, - destination, - data, - fee, - }: { - account: string; - inputAmount: CurrencyAmount; - destination: string; - data: any; - fee: bigint; - }) { + async _deposit({ account, inputAmount, destination, data, fee }: DepositParams) { const isDenom = inputAmount && inputAmount.currency instanceof XToken ? isDenomAsset(inputAmount.currency) : false; if (isDenom) { @@ -101,19 +89,7 @@ export class ArchwayXWalletClient extends XWalletClient { } } - private async _crossTransfer({ - account, - inputAmount, - destination, - data, - fee, - }: { - account: string; - inputAmount: CurrencyAmount; - destination: string; - data: any; - fee: bigint; - }) { + async _crossTransfer({ account, inputAmount, destination, data, fee }: DepositParams) { const msg = { cross_transfer: { amount: inputAmount.quotient.toString(), @@ -133,19 +109,7 @@ export class ArchwayXWalletClient extends XWalletClient { return hash; } - private async _sendCall({ - account, - sourceChainId, - destination, - data, - fee, - }: { - account: string; - sourceChainId: XChainId; - destination: string; - data: any; - fee: bigint; - }) { + async _sendCall({ account, sourceChainId, destination, data, fee }: SendCallParams): Promise { throw new Error('Method not implemented.'); } @@ -229,26 +193,4 @@ export class ArchwayXWalletClient extends XWalletClient { fee: xCallFee.rollback, }); } - - async depositXToken(xTransactionInput: XTransactionInput): Promise { - throw new Error('Method not implemented.'); - } - async withdrawXToken(xTransactionInput: XTransactionInput): Promise { - throw new Error('Method not implemented.'); - } - async addLiquidity(xTransactionInput: XTransactionInput): Promise { - throw new Error('Method not implemented.'); - } - async removeLiquidity(xTransactionInput: XTransactionInput): Promise { - throw new Error('Method not implemented.'); - } - async stake(xTransactionInput: XTransactionInput): Promise { - throw new Error('Method not implemented.'); - } - async unstake(xTransactionInput: XTransactionInput): Promise { - throw new Error('Method not implemented.'); - } - async claimRewards(xTransactionInput: XTransactionInput): Promise { - throw new Error('Method not implemented.'); - } } diff --git a/packages/xwagmi/src/xchains/evm/EvmXWalletClient.ts b/packages/xwagmi/src/xchains/evm/EvmXWalletClient.ts index af8479326..202879242 100644 --- a/packages/xwagmi/src/xchains/evm/EvmXWalletClient.ts +++ b/packages/xwagmi/src/xchains/evm/EvmXWalletClient.ts @@ -1,21 +1,14 @@ -import { CurrencyAmount, MaxUint256, Percent, XChainId } from '@balancednetwork/sdk-core'; +import { CurrencyAmount, MaxUint256 } from '@balancednetwork/sdk-core'; import { RLP } from '@ethereumjs/rlp'; import { Address, PublicClient, WalletClient, erc20Abi, getContract, toHex } from 'viem'; -import bnJs from '../icon/bnJs'; -import { ICON_XCALL_NETWORK_ID, xTokenMapBySymbol } from '@/constants'; import { FROM_SOURCES, TO_SOURCES, xChainMap } from '@/constants/xChains'; -import { XWalletClient } from '@/core/XWalletClient'; +import { DepositParams, SendCallParams, XWalletClient } from '@/core/XWalletClient'; import { XToken } from '@/types'; -import { uintToBytes } from '@/utils'; -import { XTransactionInput, XTransactionType } from '../../xcall/types'; -import { getRlpEncodedSwapData, toICONDecimals } from '../../xcall/utils'; -import { isSpokeToken } from '../archway/utils'; import { EvmXService } from './EvmXService'; import { assetManagerContractAbi } from './abis/assetManagerContractAbi'; import { bnUSDContractAbi } from './abis/bnUSDContractAbi'; import { xCallContractAbi } from './abis/xCallContractAbi'; -import { getAddLPData, getStakeData, getUnStakeData, getWithdrawData, getXRemoveData, tokenData } from './utils'; export class EvmXWalletClient extends XWalletClient { getXService(): EvmXService { @@ -64,19 +57,7 @@ export class EvmXWalletClient extends XWalletClient { return hash; } - private async _deposit({ - account, - inputAmount, - destination, - data, - fee, - }: { - account: string; - inputAmount: CurrencyAmount; - destination: string; - data: any; - fee: bigint; - }) { + async _deposit({ account, inputAmount, destination, data, fee }: DepositParams) { const walletClient = await this.getWalletClient(); const amount = BigInt(inputAmount.quotient.toString()); @@ -87,7 +68,7 @@ export class EvmXWalletClient extends XWalletClient { address: xChainMap[inputAmount.currency.xChainId].contracts.assetManager as Address, abi: assetManagerContractAbi, functionName: 'deposit', - args: [inputAmount.currency.address as Address, amount, destination, data], + args: [inputAmount.currency.address as Address, amount, destination, toHex(data)], value: fee, }); const hash = await walletClient.writeContract(res.request); @@ -98,7 +79,7 @@ export class EvmXWalletClient extends XWalletClient { address: xChainMap[inputAmount.currency.xChainId].contracts.assetManager as Address, abi: assetManagerContractAbi, functionName: 'depositNative', - args: [amount, destination, data], + args: [amount, destination, toHex(data)], value: fee + amount, }); const hash = await walletClient.writeContract(res.request); @@ -106,19 +87,7 @@ export class EvmXWalletClient extends XWalletClient { } } - private async _crossTransfer({ - account, - inputAmount, - destination, - data, - fee, - }: { - account: string; - inputAmount: CurrencyAmount; - destination: string; - data: any; - fee: bigint; - }) { + async _crossTransfer({ account, inputAmount, destination, data, fee }: DepositParams) { const walletClient = await this.getWalletClient(); const amount = BigInt(inputAmount.quotient.toString()); @@ -128,30 +97,18 @@ export class EvmXWalletClient extends XWalletClient { address: inputAmount.currency.address as Address, abi: bnUSDContractAbi, functionName: 'crossTransfer', - args: [destination, amount, data], + args: [destination, amount, toHex(data)], value: fee, }); const hash = await walletClient.writeContract(res.request); return hash; } - private async _sendCall({ - account, - sourceChainId, - destination, - data, - fee, - }: { - account: string; - sourceChainId: XChainId; - destination: string; - data: any; - fee: bigint; - }) { + async _sendCall({ account, sourceChainId, destination, data, fee }: SendCallParams) { const envelope = toHex( RLP.encode([ Buffer.from([0]), - data, + toHex(data), FROM_SOURCES[sourceChainId]?.map(Buffer.from), TO_SOURCES[sourceChainId]?.map(Buffer.from), ]), @@ -170,197 +127,4 @@ export class EvmXWalletClient extends XWalletClient { const hash = await walletClient.writeContract(res.request); return hash; } - - async executeSwapOrBridge(xTransactionInput: XTransactionInput) { - const { type, direction, inputAmount, recipient, account, xCallFee, executionTrade, slippageTolerance } = - xTransactionInput; - - const receiver = `${direction.to}/${recipient}`; - const destination = `${ICON_XCALL_NETWORK_ID}/${bnJs.Router.address}`; - - let data: Address; - switch (type) { - case XTransactionType.SWAP: { - if (!executionTrade || !slippageTolerance) { - return; - } - const minReceived = executionTrade.minimumAmountOut(new Percent(slippageTolerance, 10_000)); - const rlpEncodedData = getRlpEncodedSwapData(executionTrade, '_swap', receiver, minReceived).toString('hex'); - data = `0x${rlpEncodedData}`; - break; - } - case XTransactionType.BRIDGE: - data = toHex( - JSON.stringify({ - method: '_swap', - params: { - path: [], - receiver: receiver, - }, - }), - ); - break; - default: - throw new Error('Invalid XTransactionType'); - } - - if (isSpokeToken(inputAmount.currency)) { - return await this._crossTransfer({ account, inputAmount, destination, data, fee: xCallFee.rollback }); - } else { - return await this._deposit({ account, inputAmount, destination, data, fee: xCallFee.rollback }); - } - } - - async executeDepositCollateral(xTransactionInput: XTransactionInput) { - const { inputAmount, account, xCallFee, direction } = xTransactionInput; - - if (!inputAmount) { - return; - } - - const destination = `${ICON_XCALL_NETWORK_ID}/${bnJs.Loans.address}`; - const data = toHex(JSON.stringify({})); - - return await this._deposit({ inputAmount, account, destination, data, fee: xCallFee.rollback }); - } - - async executeWithdrawCollateral(xTransactionInput: XTransactionInput) { - const { inputAmount, account, xCallFee, usedCollateral, direction } = xTransactionInput; - - if (!inputAmount || !usedCollateral) { - return; - } - - const amount = toICONDecimals(inputAmount.multiply(-1)); - const destination = `${ICON_XCALL_NETWORK_ID}/${bnJs.Loans.address}`; - const data = toHex(RLP.encode(['xWithdraw', uintToBytes(amount), usedCollateral])); - - return await this._sendCall({ account, sourceChainId: direction.from, destination, data, fee: xCallFee.rollback }); - } - - async executeBorrow(xTransactionInput: XTransactionInput) { - const { inputAmount, account, xCallFee, usedCollateral, recipient, direction } = xTransactionInput; - - if (!inputAmount || !usedCollateral) { - return; - } - - const amount = BigInt(inputAmount.quotient.toString()); - const destination = `${ICON_XCALL_NETWORK_ID}/${bnJs.Loans.address}`; - const data = toHex( - RLP.encode( - recipient - ? ['xBorrow', usedCollateral, uintToBytes(amount), Buffer.from(recipient)] - : ['xBorrow', usedCollateral, uintToBytes(amount)], - ), - ); - - return await this._sendCall({ account, sourceChainId: direction.from, destination, data, fee: xCallFee.rollback }); - } - - async executeRepay(xTransactionInput: XTransactionInput) { - const { inputAmount, account, xCallFee, usedCollateral, recipient, direction } = xTransactionInput; - - if (!inputAmount || !usedCollateral) { - return; - } - - const destination = `${ICON_XCALL_NETWORK_ID}/${bnJs.Loans.address}`; - const data = toHex( - JSON.stringify(recipient ? { _collateral: usedCollateral, _to: recipient } : { _collateral: usedCollateral }), - ); - const _inputAmount = inputAmount.multiply(-1); - return await this._crossTransfer({ account, inputAmount: _inputAmount, destination, data, fee: xCallFee.rollback }); - } - - // liquidity related - async depositXToken(xTransactionInput: XTransactionInput) { - const { account, inputAmount, xCallFee } = xTransactionInput; - - const destination = `${ICON_XCALL_NETWORK_ID}/${bnJs.Dex.address}`; - const data = toHex(tokenData('_deposit', {})); - - let hash; - if (isSpokeToken(inputAmount.currency)) { - hash = await this._crossTransfer({ account, inputAmount, destination, data, fee: xCallFee.rollback }); - } else { - hash = await this._deposit({ account, inputAmount, destination, data, fee: xCallFee.rollback }); - } - - return hash; - } - - async withdrawXToken(xTransactionInput: XTransactionInput) { - const { account, inputAmount, xCallFee, direction } = xTransactionInput; - - const destination = `${ICON_XCALL_NETWORK_ID}/${bnJs.Dex.address}`; - const amount = BigInt(inputAmount.quotient.toString()); - const xTokenOnIcon = xTokenMapBySymbol[ICON_XCALL_NETWORK_ID][inputAmount.currency.symbol]; - const data = toHex(getWithdrawData(xTokenOnIcon.address, amount)); - - return await this._sendCall({ account, sourceChainId: direction.from, destination, data, fee: xCallFee.rollback }); - } - - async addLiquidity(xTransactionInput: XTransactionInput) { - const { account, inputAmount, outputAmount, xCallFee, direction } = xTransactionInput; - - if (!outputAmount) { - throw new Error('outputAmount is required'); - } - - const destination = `${ICON_XCALL_NETWORK_ID}/${bnJs.Dex.address}`; - const amountA = BigInt(inputAmount.quotient.toString()); - const amountB = BigInt(outputAmount.quotient.toString()); - const xTokenAOnIcon = xTokenMapBySymbol[ICON_XCALL_NETWORK_ID][inputAmount.currency.symbol]; - const xTokenBOnIcon = xTokenMapBySymbol[ICON_XCALL_NETWORK_ID][outputAmount.currency.symbol]; - const data = toHex(getAddLPData(xTokenAOnIcon.address, xTokenBOnIcon.address, amountA, amountB, true, 1_000n)); - - return await this._sendCall({ account, sourceChainId: direction.from, destination, data, fee: xCallFee.rollback }); - } - - async removeLiquidity(xTransactionInput: XTransactionInput) { - const { account, inputAmount, poolId, xCallFee, direction } = xTransactionInput; - - if (!poolId) { - throw new Error('poolId is required'); - } - - const destination = `${ICON_XCALL_NETWORK_ID}/${bnJs.Dex.address}`; - const amount = BigInt(inputAmount.quotient.toString()); - const data = toHex(getXRemoveData(poolId, amount, true)); - - return await this._sendCall({ account, sourceChainId: direction.from, destination, data, fee: xCallFee.rollback }); - } - - async stake(xTransactionInput: XTransactionInput) { - const { account, inputAmount, poolId, xCallFee, direction } = xTransactionInput; - - if (!poolId) { - throw new Error('poolId is required'); - } - - const destination = `${ICON_XCALL_NETWORK_ID}/${bnJs.Dex.address}`; - const amount = BigInt(inputAmount.quotient.toString()); - const data = toHex(getStakeData(`${ICON_XCALL_NETWORK_ID}/${bnJs.StakedLP.address}`, poolId, amount)); - - return await this._sendCall({ account, sourceChainId: direction.from, destination, data, fee: xCallFee.rollback }); - } - - async unstake(xTransactionInput: XTransactionInput) { - const { account, inputAmount, poolId, xCallFee, direction } = xTransactionInput; - - if (!poolId) { - throw new Error('poolId is required'); - } - - const destination = `${ICON_XCALL_NETWORK_ID}/${bnJs.StakedLP.address}`; - const amount = BigInt(inputAmount.quotient.toString()); - const data = toHex(getUnStakeData(poolId, amount)); - - return await this._sendCall({ account, sourceChainId: direction.from, destination, data, fee: xCallFee.rollback }); - } - - async claimRewards(xTransactionInput: XTransactionInput): Promise { - throw new Error('Method not implemented.'); - } } diff --git a/packages/xwagmi/src/xchains/havah/HavahXWalletClient.ts b/packages/xwagmi/src/xchains/havah/HavahXWalletClient.ts index 09f752369..b5f6c9fb4 100644 --- a/packages/xwagmi/src/xchains/havah/HavahXWalletClient.ts +++ b/packages/xwagmi/src/xchains/havah/HavahXWalletClient.ts @@ -2,7 +2,7 @@ import { CurrencyAmount, Percent, XChainId } from '@balancednetwork/sdk-core'; import bnJs from '../icon/bnJs'; import { ICON_XCALL_NETWORK_ID } from '@/constants'; -import { XWalletClient } from '@/core/XWalletClient'; +import { DepositParams, SendCallParams, XWalletClient } from '@/core/XWalletClient'; import { XToken } from '@/types'; import { showMessageOnBeforeUnload, toDec } from '@/utils'; import { toHex } from 'viem'; @@ -20,19 +20,7 @@ export class HavahXWalletClient extends XWalletClient { return Promise.resolve(undefined); } - private async _deposit({ - account, - inputAmount, - destination, - data, - fee, - }: { - account: string; - inputAmount: CurrencyAmount; - destination: string; - data: any; - fee: bigint; - }) { + async _deposit({ account, inputAmount, destination, data, fee }: DepositParams) { const isNative = inputAmount.currency.isNativeToken; if (!isNative) { throw new Error('Only native token and bnUSD are supported'); @@ -44,19 +32,7 @@ export class HavahXWalletClient extends XWalletClient { return hash; } - private async _crossTransfer({ - account, - inputAmount, - destination, - data, - fee, - }: { - account: string; - inputAmount: CurrencyAmount; - destination: string; - data: any; - fee: bigint; - }) { + async _crossTransfer({ account, inputAmount, destination, data, fee }: DepositParams) { const txResult = await this.getXService() .walletClient.inject({ account }) .bnUSD['crossTransferV2'](destination, toDec(inputAmount), data, fee); @@ -64,19 +40,7 @@ export class HavahXWalletClient extends XWalletClient { return hash; } - private async _sendCall({ - account, - sourceChainId, - destination, - data, - fee, - }: { - account: string; - sourceChainId: XChainId; - destination: string; - data: any; - fee: bigint; - }) { + async _sendCall({ account, sourceChainId, destination, data, fee }: SendCallParams): Promise { throw new Error('Method not implemented.'); } @@ -151,26 +115,4 @@ export class HavahXWalletClient extends XWalletClient { fee: xCallFee.rollback, }); } - - async depositXToken(xTransactionInput: XTransactionInput): Promise { - throw new Error('Method not implemented.'); - } - async withdrawXToken(xTransactionInput: XTransactionInput): Promise { - throw new Error('Method not implemented.'); - } - async addLiquidity(xTransactionInput: XTransactionInput): Promise { - throw new Error('Method not implemented.'); - } - async removeLiquidity(xTransactionInput: XTransactionInput): Promise { - throw new Error('Method not implemented.'); - } - async stake(xTransactionInput: XTransactionInput): Promise { - throw new Error('Method not implemented.'); - } - async unstake(xTransactionInput: XTransactionInput): Promise { - throw new Error('Method not implemented.'); - } - async claimRewards(xTransactionInput: XTransactionInput): Promise { - throw new Error('Method not implemented.'); - } } diff --git a/packages/xwagmi/src/xchains/icon/IconXWalletClient.ts b/packages/xwagmi/src/xchains/icon/IconXWalletClient.ts index 452cd24d8..c674ff870 100644 --- a/packages/xwagmi/src/xchains/icon/IconXWalletClient.ts +++ b/packages/xwagmi/src/xchains/icon/IconXWalletClient.ts @@ -1,7 +1,7 @@ import { Percent } from '@balancednetwork/sdk-core'; import bnJs from './bnJs'; -import { XWalletClient } from '@/core/XWalletClient'; +import { DepositParams, SendCallParams, XWalletClient } from '@/core/XWalletClient'; import { showMessageOnBeforeUnload, toDec } from '@/utils'; import { XTransactionInput, XTransactionType } from '../../xcall/types'; import { getRlpEncodedSwapData } from '../../xcall/utils'; @@ -21,6 +21,16 @@ export class IconXWalletClient extends XWalletClient { return Promise.resolve(undefined); } + async _deposit({ account, inputAmount, destination, data, fee }: DepositParams): Promise { + throw new Error('Method not implemented.'); + } + async _crossTransfer({ account, inputAmount, destination, data, fee }: DepositParams): Promise { + throw new Error('Method not implemented.'); + } + async _sendCall({ account, sourceChainId, destination, data, fee }: SendCallParams): Promise { + throw new Error('Method not implemented.'); + } + async _executeBridge(xTransactionInput: XTransactionInput) { const { direction, diff --git a/packages/xwagmi/src/xchains/injective/InjectiveXWalletClient.ts b/packages/xwagmi/src/xchains/injective/InjectiveXWalletClient.ts index aeb3d1e75..fb22fe56b 100644 --- a/packages/xwagmi/src/xchains/injective/InjectiveXWalletClient.ts +++ b/packages/xwagmi/src/xchains/injective/InjectiveXWalletClient.ts @@ -6,6 +6,7 @@ import { getBytesFromString, getRlpEncodedSwapData, toICONDecimals } from '@/xca import { FROM_SOURCES, TO_SOURCES, injective } from '@/constants/xChains'; import { XWalletClient } from '@/core'; +import { DepositParams, SendCallParams } from '@/core/XWalletClient'; import { XToken } from '@/types'; import { uintToBytes } from '@/utils'; import { XTransactionInput, XTransactionType } from '@/xcall/types'; @@ -23,19 +24,7 @@ export class InjectiveXWalletClient extends XWalletClient { return Promise.resolve(undefined); } - private async _deposit({ - account, - inputAmount, - destination, - data, - fee, - }: { - account: string; - inputAmount: CurrencyAmount; - destination: string; - data: any; - fee: bigint; - }) { + async _deposit({ account, inputAmount, destination, data, fee }: DepositParams) { let msg; const isDenom = inputAmount && inputAmount.currency instanceof XToken ? isDenomAsset(inputAmount.currency) : false; if (isDenom) { @@ -85,19 +74,7 @@ export class InjectiveXWalletClient extends XWalletClient { return txResult.txHash; } - private async _crossTransfer({ - account, - inputAmount, - destination, - data, - fee, - }: { - account: string; - inputAmount: CurrencyAmount; - destination: string; - data: any; - fee: bigint; - }) { + async _crossTransfer({ account, inputAmount, destination, data, fee }: DepositParams) { const amount = inputAmount.quotient.toString(); const msg = MsgExecuteContractCompat.fromJSON({ contractAddress: injective.contracts.bnUSD!, @@ -126,19 +103,7 @@ export class InjectiveXWalletClient extends XWalletClient { return txResult.txHash; } - private async _sendCall({ - account, - sourceChainId, - destination, - data, - fee, - }: { - account: string; - sourceChainId: XChainId; - destination: string; - data: any; - fee: bigint; - }) { + async _sendCall({ account, sourceChainId, destination, data, fee }: SendCallParams) { const envelope = { message: { call_message: { @@ -278,26 +243,4 @@ export class InjectiveXWalletClient extends XWalletClient { fee: xCallFee.rollback, }); } - - async depositXToken(xTransactionInput: XTransactionInput): Promise { - throw new Error('Method not implemented.'); - } - async withdrawXToken(xTransactionInput: XTransactionInput): Promise { - throw new Error('Method not implemented.'); - } - async addLiquidity(xTransactionInput: XTransactionInput): Promise { - throw new Error('Method not implemented.'); - } - async removeLiquidity(xTransactionInput: XTransactionInput): Promise { - throw new Error('Method not implemented.'); - } - async stake(xTransactionInput: XTransactionInput): Promise { - throw new Error('Method not implemented.'); - } - async unstake(xTransactionInput: XTransactionInput): Promise { - throw new Error('Method not implemented.'); - } - async claimRewards(xTransactionInput: XTransactionInput): Promise { - throw new Error('Method not implemented.'); - } } diff --git a/packages/xwagmi/src/xchains/solana/SolanaXWalletClient.ts b/packages/xwagmi/src/xchains/solana/SolanaXWalletClient.ts index f673ee5bb..8b5bc521b 100644 --- a/packages/xwagmi/src/xchains/solana/SolanaXWalletClient.ts +++ b/packages/xwagmi/src/xchains/solana/SolanaXWalletClient.ts @@ -1,6 +1,6 @@ import { ICON_XCALL_NETWORK_ID } from '@/constants'; import { FROM_SOURCES, TO_SOURCES, solana } from '@/constants/xChains'; -import { XWalletClient } from '@/core/XWalletClient'; +import { DepositParams, SendCallParams, XWalletClient } from '@/core/XWalletClient'; import { XToken } from '@/types'; import { uintToBytes } from '@/utils'; import { CurrencyAmount, Percent, XChainId } from '@balancednetwork/sdk-core'; @@ -47,19 +47,7 @@ export class SolanaXWalletClient extends XWalletClient { return Promise.resolve(undefined); } - private async _deposit({ - account, - inputAmount, - destination, - data, - fee, // not used, just for compatibility - }: { - account: string; - inputAmount: CurrencyAmount; - destination: string; - data: any; - fee: bigint; - }) { + async _deposit({ account, inputAmount, destination, data, fee }: DepositParams) { const wallet = this.getXService().wallet; const connection = this.getXService().connection; const provider = this.getXService().provider; @@ -184,19 +172,7 @@ export class SolanaXWalletClient extends XWalletClient { return txSignature; } - private async _crossTransfer({ - account, - inputAmount, - destination, - data, - fee, // not used, just for compatibility - }: { - account: string; - inputAmount: CurrencyAmount; - destination: string; - data: any; - fee: bigint; - }) { + async _crossTransfer({ account, inputAmount, destination, data, fee }: DepositParams) { const wallet = this.getXService().wallet; const connection = this.getXService().connection; const provider = this.getXService().provider; @@ -247,19 +223,7 @@ export class SolanaXWalletClient extends XWalletClient { return txSignature; } - private async _sendCall({ - account, - sourceChainId, - destination, - data, - fee, // not used, just for compatibility - }: { - account: string; - sourceChainId: XChainId; - destination: string; - data: any; - fee: bigint; - }) { + async _sendCall({ account, sourceChainId, destination, data, fee }: SendCallParams) { const wallet = this.getXService().wallet; const connection = this.getXService().connection; const provider = this.getXService().provider; @@ -400,26 +364,4 @@ export class SolanaXWalletClient extends XWalletClient { ); return await this._crossTransfer({ account, inputAmount: inputAmount.multiply(-1), destination, data, fee: 0n }); } - - async depositXToken(xTransactionInput: XTransactionInput): Promise { - throw new Error('Method not implemented.'); - } - async withdrawXToken(xTransactionInput: XTransactionInput): Promise { - throw new Error('Method not implemented.'); - } - async addLiquidity(xTransactionInput: XTransactionInput): Promise { - throw new Error('Method not implemented.'); - } - async removeLiquidity(xTransactionInput: XTransactionInput): Promise { - throw new Error('Method not implemented.'); - } - async stake(xTransactionInput: XTransactionInput): Promise { - throw new Error('Method not implemented.'); - } - async unstake(xTransactionInput: XTransactionInput): Promise { - throw new Error('Method not implemented.'); - } - async claimRewards(xTransactionInput: XTransactionInput): Promise { - throw new Error('Method not implemented.'); - } } diff --git a/packages/xwagmi/src/xchains/stellar/StellarXWalletClient.ts b/packages/xwagmi/src/xchains/stellar/StellarXWalletClient.ts index 047dd8229..cb38d05ce 100644 --- a/packages/xwagmi/src/xchains/stellar/StellarXWalletClient.ts +++ b/packages/xwagmi/src/xchains/stellar/StellarXWalletClient.ts @@ -1,10 +1,10 @@ -import { CurrencyAmount, Percent, XChainId } from '@balancednetwork/sdk-core'; +import { Percent } from '@balancednetwork/sdk-core'; import bnJs from '../icon/bnJs'; import { ICON_XCALL_NETWORK_ID } from '@/constants'; import { FROM_SOURCES, TO_SOURCES, stellar } from '@/constants/xChains'; import { XWalletClient } from '@/core'; -import { XToken } from '@/types'; +import { DepositParams, SendCallParams } from '@/core/XWalletClient'; import { uintToBytes } from '@/utils'; import { XTransactionInput, XTransactionType } from '@/xcall/types'; import { getRlpEncodedSwapData, toICONDecimals } from '@/xcall/utils'; @@ -30,19 +30,7 @@ export class StellarXWalletClient extends XWalletClient { return Promise.resolve(undefined); } - private async _deposit({ - account, - inputAmount, - destination, - data, - fee, - }: { - account: string; - inputAmount: CurrencyAmount; - destination: string; - data: any; - fee: bigint; - }) { + async _deposit({ account, inputAmount, destination, data, fee }: DepositParams) { const stellarAccount = await this.getXService().server.loadAccount(account); const server = this.getXService().sorobanServer; const kit = this.getXService().walletsKit; @@ -63,19 +51,7 @@ export class StellarXWalletClient extends XWalletClient { return hash; } - private async _crossTransfer({ - account, - inputAmount, - destination, - data, - fee, - }: { - account: string; - inputAmount: CurrencyAmount; - destination: string; - data: any; - fee: bigint; - }) { + async _crossTransfer({ account, inputAmount, destination, data, fee }: DepositParams) { const stellarAccount = await this.getXService().server.loadAccount(account); const server = this.getXService().sorobanServer; const kit = this.getXService().walletsKit; @@ -95,19 +71,7 @@ export class StellarXWalletClient extends XWalletClient { return hash; } - private async _sendCall({ - account, - sourceChainId, - destination, - data, - fee, - }: { - account: string; - sourceChainId: XChainId; - destination: string; - data: any; - fee: bigint; - }) { + async _sendCall({ account, sourceChainId, destination, data, fee }: SendCallParams) { const stellarAccount = await this.getXService().server.loadAccount(account); const server = this.getXService().sorobanServer; const kit = this.getXService().walletsKit; @@ -144,7 +108,7 @@ export class StellarXWalletClient extends XWalletClient { } } - private async handleBridgeTransaction(xTransactionInput: XTransactionInput): Promise { + async handleBridgeTransaction(xTransactionInput: XTransactionInput): Promise { const { account, inputAmount, recipient, direction } = xTransactionInput; const receiver = `${direction.to}/${recipient}`; const destination = `${ICON_XCALL_NETWORK_ID}/${bnJs.Router.address}`; @@ -159,7 +123,7 @@ export class StellarXWalletClient extends XWalletClient { } } - private async handleSwapTransaction(xTransactionInput: XTransactionInput): Promise { + async handleSwapTransaction(xTransactionInput: XTransactionInput): Promise { const { inputAmount, executionTrade, account, recipient, direction, slippageTolerance } = xTransactionInput; const receiver = `${direction.to}/${recipient}`; @@ -231,26 +195,4 @@ export class StellarXWalletClient extends XWalletClient { const data = encoder.encode(JSON.stringify(dataObj)); return await this._crossTransfer({ account, inputAmount: inputAmount.multiply(-1), destination, data, fee: 0n }); } - - async depositXToken(xTransactionInput: XTransactionInput): Promise { - throw new Error('Method not implemented.'); - } - async withdrawXToken(xTransactionInput: XTransactionInput): Promise { - throw new Error('Method not implemented.'); - } - async addLiquidity(xTransactionInput: XTransactionInput): Promise { - throw new Error('Method not implemented.'); - } - async removeLiquidity(xTransactionInput: XTransactionInput): Promise { - throw new Error('Method not implemented.'); - } - async stake(xTransactionInput: XTransactionInput): Promise { - throw new Error('Method not implemented.'); - } - async unstake(xTransactionInput: XTransactionInput): Promise { - throw new Error('Method not implemented.'); - } - async claimRewards(xTransactionInput: XTransactionInput): Promise { - throw new Error('Method not implemented.'); - } } diff --git a/packages/xwagmi/src/xchains/sui/SuiXWalletClient.ts b/packages/xwagmi/src/xchains/sui/SuiXWalletClient.ts index 884e62f48..f80b55876 100644 --- a/packages/xwagmi/src/xchains/sui/SuiXWalletClient.ts +++ b/packages/xwagmi/src/xchains/sui/SuiXWalletClient.ts @@ -4,7 +4,7 @@ import bnJs from '../icon/bnJs'; import { ICON_XCALL_NETWORK_ID, xTokenMap, xTokenMapBySymbol } from '@/constants'; import { FROM_SOURCES, TO_SOURCES, sui } from '@/constants/xChains'; -import { XWalletClient } from '@/core/XWalletClient'; +import { DepositParams, SendCallParams, XWalletClient } from '@/core/XWalletClient'; import { XToken } from '@/types'; import { uintToBytes } from '@/utils'; import { RLP } from '@ethereumjs/rlp'; @@ -12,10 +12,10 @@ import { bcs } from '@mysten/sui/bcs'; import { Transaction } from '@mysten/sui/transactions'; import { signTransaction } from '@mysten/wallet-standard'; import { toBytes, toHex } from 'viem'; +import { getWithdrawData, tokenData } from '../../core/utils'; import { XTransactionInput, XTransactionType } from '../../xcall/types'; import { getRlpEncodedSwapData, toICONDecimals } from '../../xcall/utils'; import { isSpokeToken } from '../archway'; -import { getWithdrawData, tokenData } from '../evm/utils'; import { SuiXService } from './SuiXService'; const addressesMainnet = { @@ -41,7 +41,7 @@ export class SuiXWalletClient extends XWalletClient { return Promise.resolve(undefined); } - private async _signAndExecuteTransactionBlock(txb: Transaction): Promise { + async _signAndExecuteTransactionBlock(txb: Transaction): Promise { const { bytes, signature } = await signTransaction(this.getXService().suiWallet, { transaction: txb, account: this.getXService().suiAccount, @@ -60,19 +60,7 @@ export class SuiXWalletClient extends XWalletClient { return hash; } - private async _deposit({ - account, - inputAmount, - destination, - data, - fee, // not used, just for compatibility - }: { - account: string; - inputAmount: CurrencyAmount; - destination: string; - data: any; - fee: bigint; - }) { + async _deposit({ account, inputAmount, destination, data, fee }: DepositParams) { const amount = BigInt(inputAmount.quotient.toString()); const coinType = inputAmount.currency.isNativeToken ? '0x2::sui::SUI' : inputAmount.currency.address; @@ -119,19 +107,7 @@ export class SuiXWalletClient extends XWalletClient { return await this._signAndExecuteTransactionBlock(txb); } - private async _crossTransfer({ - account, - inputAmount, - destination, - data, - fee, // not used, just for compatibility - }: { - account: string; - inputAmount: CurrencyAmount; - destination: string; - data: any; - fee: bigint; - }) { + async _crossTransfer({ account, inputAmount, destination, data, fee }: DepositParams) { const amount = BigInt(inputAmount.quotient.toString()); const coinType = inputAmount.currency.address; @@ -174,19 +150,7 @@ export class SuiXWalletClient extends XWalletClient { return await this._signAndExecuteTransactionBlock(txb); } - private async _sendCall({ - account, // not used, just for compatibility - sourceChainId, - destination, - data, - fee, // not used, just for compatibility - }: { - account: string; - sourceChainId: XChainId; - destination: string; - data: any; - fee: bigint; - }) { + async _sendCall({ account, sourceChainId, destination, data, fee }: SendCallParams) { const envelope = toBytes( toHex( RLP.encode([ @@ -214,16 +178,11 @@ export class SuiXWalletClient extends XWalletClient { } async executeSwapOrBridge(xTransactionInput: XTransactionInput) { - if (!signTransaction) { - throw new Error('signTransaction is required'); - } - const { type, executionTrade, account, direction, inputAmount, recipient, slippageTolerance, xCallFee } = xTransactionInput; const destination = `${ICON_XCALL_NETWORK_ID}/${bnJs.Router.address}`; const receiver = `${direction.to}/${recipient}`; - const amount = BigInt(inputAmount.quotient.toString()); let data; if (type === XTransactionType.SWAP) { @@ -363,40 +322,4 @@ export class SuiXWalletClient extends XWalletClient { return await this._signAndExecuteTransactionBlock(txb); } - - async depositXToken(xTransactionInput: XTransactionInput): Promise { - const { account, inputAmount, xCallFee } = xTransactionInput; - const destination = `${ICON_XCALL_NETWORK_ID}/${bnJs.Dex.address}`; - const data = toBytes(tokenData('_deposit', {})); - - if (isSpokeToken(inputAmount.currency)) { - return await this._crossTransfer({ inputAmount, account, destination, data, fee: 0n }); - } else { - return await this._deposit({ inputAmount, account, destination, data, fee: 0n }); - } - } - async withdrawXToken(xTransactionInput: XTransactionInput): Promise { - const { account, inputAmount, xCallFee, direction } = xTransactionInput; - - const destination = `${ICON_XCALL_NETWORK_ID}/${bnJs.Dex.address}`; - const amount = BigInt(inputAmount.quotient.toString()); - const xTokenOnIcon = xTokenMapBySymbol[ICON_XCALL_NETWORK_ID][inputAmount.currency.symbol]; - const data = getWithdrawData(xTokenOnIcon.address, amount); - return await this._sendCall({ account, sourceChainId: direction.from, destination, data, fee: 0n }); - } - async addLiquidity(xTransactionInput: XTransactionInput): Promise { - throw new Error('Method not implemented.'); - } - async removeLiquidity(xTransactionInput: XTransactionInput): Promise { - throw new Error('Method not implemented.'); - } - async stake(xTransactionInput: XTransactionInput): Promise { - throw new Error('Method not implemented.'); - } - async unstake(xTransactionInput: XTransactionInput): Promise { - throw new Error('Method not implemented.'); - } - async claimRewards(xTransactionInput: XTransactionInput): Promise { - throw new Error('Method not implemented.'); - } } From fac6b1c87c925e875a2912459115d3f2c0787d5b Mon Sep 17 00:00:00 2001 From: swiftcc624 Date: Sat, 11 Jan 2025 15:48:08 +0800 Subject: [PATCH 31/33] refactor XWalletClient --- packages/xwagmi/src/xchains/archway/ArchwayXWalletClient.ts | 2 +- packages/xwagmi/src/xchains/havah/HavahXWalletClient.ts | 3 +-- .../xwagmi/src/xchains/injective/InjectiveXWalletClient.ts | 2 +- packages/xwagmi/src/xchains/solana/SolanaXWalletClient.ts | 3 +-- packages/xwagmi/src/xchains/sui/SuiXWalletClient.ts | 6 ++---- 5 files changed, 6 insertions(+), 10 deletions(-) diff --git a/packages/xwagmi/src/xchains/archway/ArchwayXWalletClient.ts b/packages/xwagmi/src/xchains/archway/ArchwayXWalletClient.ts index 3ec044a1a..f19e44890 100644 --- a/packages/xwagmi/src/xchains/archway/ArchwayXWalletClient.ts +++ b/packages/xwagmi/src/xchains/archway/ArchwayXWalletClient.ts @@ -1,4 +1,4 @@ -import { Percent, XChainId } from '@balancednetwork/sdk-core'; +import { Percent } from '@balancednetwork/sdk-core'; import bnJs from '../icon/bnJs'; import { ICON_XCALL_NETWORK_ID } from '@/constants'; diff --git a/packages/xwagmi/src/xchains/havah/HavahXWalletClient.ts b/packages/xwagmi/src/xchains/havah/HavahXWalletClient.ts index b5f6c9fb4..d29146f6b 100644 --- a/packages/xwagmi/src/xchains/havah/HavahXWalletClient.ts +++ b/packages/xwagmi/src/xchains/havah/HavahXWalletClient.ts @@ -1,9 +1,8 @@ -import { CurrencyAmount, Percent, XChainId } from '@balancednetwork/sdk-core'; +import { Percent } from '@balancednetwork/sdk-core'; import bnJs from '../icon/bnJs'; import { ICON_XCALL_NETWORK_ID } from '@/constants'; import { DepositParams, SendCallParams, XWalletClient } from '@/core/XWalletClient'; -import { XToken } from '@/types'; import { showMessageOnBeforeUnload, toDec } from '@/utils'; import { toHex } from 'viem'; import { XTransactionInput, XTransactionType } from '../../xcall/types'; diff --git a/packages/xwagmi/src/xchains/injective/InjectiveXWalletClient.ts b/packages/xwagmi/src/xchains/injective/InjectiveXWalletClient.ts index fb22fe56b..b07ceedbf 100644 --- a/packages/xwagmi/src/xchains/injective/InjectiveXWalletClient.ts +++ b/packages/xwagmi/src/xchains/injective/InjectiveXWalletClient.ts @@ -1,4 +1,4 @@ -import { CurrencyAmount, Percent, XChainId } from '@balancednetwork/sdk-core'; +import { Percent } from '@balancednetwork/sdk-core'; import bnJs from '../icon/bnJs'; import { ICON_XCALL_NETWORK_ID } from '@/constants'; diff --git a/packages/xwagmi/src/xchains/solana/SolanaXWalletClient.ts b/packages/xwagmi/src/xchains/solana/SolanaXWalletClient.ts index 8b5bc521b..87df18d49 100644 --- a/packages/xwagmi/src/xchains/solana/SolanaXWalletClient.ts +++ b/packages/xwagmi/src/xchains/solana/SolanaXWalletClient.ts @@ -1,9 +1,8 @@ import { ICON_XCALL_NETWORK_ID } from '@/constants'; import { FROM_SOURCES, TO_SOURCES, solana } from '@/constants/xChains'; import { DepositParams, SendCallParams, XWalletClient } from '@/core/XWalletClient'; -import { XToken } from '@/types'; import { uintToBytes } from '@/utils'; -import { CurrencyAmount, Percent, XChainId } from '@balancednetwork/sdk-core'; +import { Percent } from '@balancednetwork/sdk-core'; import { Program } from '@coral-xyz/anchor'; import * as anchor from '@coral-xyz/anchor'; import { SYSTEM_PROGRAM_ID } from '@coral-xyz/anchor/dist/cjs/native/system'; diff --git a/packages/xwagmi/src/xchains/sui/SuiXWalletClient.ts b/packages/xwagmi/src/xchains/sui/SuiXWalletClient.ts index f80b55876..30ee630c8 100644 --- a/packages/xwagmi/src/xchains/sui/SuiXWalletClient.ts +++ b/packages/xwagmi/src/xchains/sui/SuiXWalletClient.ts @@ -1,18 +1,16 @@ -import { CurrencyAmount, Percent, XChainId } from '@balancednetwork/sdk-core'; +import { Percent } from '@balancednetwork/sdk-core'; import bnJs from '../icon/bnJs'; -import { ICON_XCALL_NETWORK_ID, xTokenMap, xTokenMapBySymbol } from '@/constants'; +import { ICON_XCALL_NETWORK_ID, xTokenMap } from '@/constants'; import { FROM_SOURCES, TO_SOURCES, sui } from '@/constants/xChains'; import { DepositParams, SendCallParams, XWalletClient } from '@/core/XWalletClient'; -import { XToken } from '@/types'; import { uintToBytes } from '@/utils'; import { RLP } from '@ethereumjs/rlp'; import { bcs } from '@mysten/sui/bcs'; import { Transaction } from '@mysten/sui/transactions'; import { signTransaction } from '@mysten/wallet-standard'; import { toBytes, toHex } from 'viem'; -import { getWithdrawData, tokenData } from '../../core/utils'; import { XTransactionInput, XTransactionType } from '../../xcall/types'; import { getRlpEncodedSwapData, toICONDecimals } from '../../xcall/utils'; import { isSpokeToken } from '../archway'; From d6a7752b46f74c47251a57441279b909520cb773 Mon Sep 17 00:00:00 2001 From: swiftcc624 Date: Sat, 11 Jan 2025 16:12:54 +0800 Subject: [PATCH 32/33] refactor XWalletClient --- .../xchains/archway/ArchwayXWalletClient.ts | 91 ++----------- .../src/xchains/havah/HavahXWalletClient.ts | 80 +---------- .../injective/InjectiveXWalletClient.ts | 125 +----------------- .../src/xchains/solana/SolanaXWalletClient.ts | 104 --------------- .../xchains/stellar/StellarXWalletClient.ts | 115 +--------------- .../src/xchains/sui/SuiXWalletClient.ts | 103 +-------------- 6 files changed, 35 insertions(+), 583 deletions(-) diff --git a/packages/xwagmi/src/xchains/archway/ArchwayXWalletClient.ts b/packages/xwagmi/src/xchains/archway/ArchwayXWalletClient.ts index f19e44890..cba39e316 100644 --- a/packages/xwagmi/src/xchains/archway/ArchwayXWalletClient.ts +++ b/packages/xwagmi/src/xchains/archway/ArchwayXWalletClient.ts @@ -1,15 +1,11 @@ -import { Percent } from '@balancednetwork/sdk-core'; -import bnJs from '../icon/bnJs'; - -import { ICON_XCALL_NETWORK_ID } from '@/constants'; import { archway } from '@/constants/xChains'; import { DepositParams, SendCallParams, XWalletClient } from '@/core/XWalletClient'; import { XToken } from '@/types'; import { XSigningArchwayClient } from '@/xchains/archway/XSigningArchwayClient'; -import { getFeeParam, isDenomAsset, isSpokeToken } from '@/xchains/archway/utils'; +import { getFeeParam, isDenomAsset } from '@/xchains/archway/utils'; import { CurrencyAmount, MaxUint256 } from '@balancednetwork/sdk-core'; -import { XTransactionInput, XTransactionType } from '../../xcall/types'; -import { getBytesFromString, getRlpEncodedSwapData } from '../../xcall/utils'; +import { XTransactionInput } from '../../xcall/types'; +import { getBytesFromString } from '../../xcall/utils'; import { ArchwayXService } from './ArchwayXService'; import { ARCHWAY_FEE_TOKEN_SYMBOL } from './constants'; @@ -51,7 +47,7 @@ export class ArchwayXWalletClient extends XWalletClient { deposit_denom: { denom: inputAmount.currency.address, to: destination, - data, + data: getBytesFromString(data), }, }; @@ -73,7 +69,7 @@ export class ArchwayXWalletClient extends XWalletClient { token_address: inputAmount.currency.address, amount: inputAmount.quotient.toString(), to: destination, - data, + data: getBytesFromString(data), }, }; @@ -94,7 +90,7 @@ export class ArchwayXWalletClient extends XWalletClient { cross_transfer: { amount: inputAmount.quotient.toString(), to: destination, - data, + data: getBytesFromString(data), }, }; @@ -113,84 +109,15 @@ export class ArchwayXWalletClient extends XWalletClient { throw new Error('Method not implemented.'); } - async executeSwapOrBridge(xTransactionInput: XTransactionInput) { - const { type, direction, inputAmount, executionTrade, account, recipient, xCallFee, slippageTolerance } = - xTransactionInput; - - const receiver = `${direction.to}/${recipient}`; - - let data; - if (type === XTransactionType.SWAP) { - if (!executionTrade || !slippageTolerance) { - return; - } - - const minReceived = executionTrade.minimumAmountOut(new Percent(slippageTolerance, 10_000)); - const rlpEncodedData = getRlpEncodedSwapData(executionTrade, '_swap', receiver, minReceived); - data = Array.from(rlpEncodedData); - } else if (type === XTransactionType.BRIDGE) { - data = getBytesFromString( - JSON.stringify({ - method: '_swap', - params: { - path: [], - receiver: receiver, - }, - }), - ); - } else { - throw new Error('Invalid XTransactionType'); - } - - if (isSpokeToken(inputAmount.currency)) { - return await this._crossTransfer({ - account, - inputAmount, - destination: `${ICON_XCALL_NETWORK_ID}/${bnJs.Router.address}`, - data, - fee: xCallFee.rollback, - }); - } else { - return await this._deposit({ - account, - inputAmount, - destination: `${ICON_XCALL_NETWORK_ID}/${bnJs.Router.address}`, - data, - fee: xCallFee.rollback, - }); - } - } - async executeDepositCollateral(xTransactionInput: XTransactionInput): Promise { - throw new Error('Method not implemented.'); + throw new Error('Not supported.'); } async executeWithdrawCollateral(xTransactionInput: XTransactionInput): Promise { - throw new Error('Method not implemented.'); + throw new Error('Not supported.'); } async executeBorrow(xTransactionInput: XTransactionInput): Promise { - throw new Error('Method not implemented.'); - } - - async executeRepay(xTransactionInput: XTransactionInput) { - const { account, inputAmount, recipient, xCallFee, usedCollateral } = xTransactionInput; - - if (!inputAmount || !usedCollateral) { - return; - } - - const destination = `${ICON_XCALL_NETWORK_ID}/${bnJs.Loans.address}`; - const data = getBytesFromString( - JSON.stringify(recipient ? { _collateral: usedCollateral, _to: recipient } : { _collateral: usedCollateral }), - ); - - return await this._crossTransfer({ - account, - inputAmount: inputAmount.multiply(-1), - destination, - data, - fee: xCallFee.rollback, - }); + throw new Error('Not supported.'); } } diff --git a/packages/xwagmi/src/xchains/havah/HavahXWalletClient.ts b/packages/xwagmi/src/xchains/havah/HavahXWalletClient.ts index d29146f6b..6969ac42d 100644 --- a/packages/xwagmi/src/xchains/havah/HavahXWalletClient.ts +++ b/packages/xwagmi/src/xchains/havah/HavahXWalletClient.ts @@ -1,13 +1,7 @@ -import { Percent } from '@balancednetwork/sdk-core'; -import bnJs from '../icon/bnJs'; - -import { ICON_XCALL_NETWORK_ID } from '@/constants'; import { DepositParams, SendCallParams, XWalletClient } from '@/core/XWalletClient'; -import { showMessageOnBeforeUnload, toDec } from '@/utils'; +import { toDec } from '@/utils'; import { toHex } from 'viem'; -import { XTransactionInput, XTransactionType } from '../../xcall/types'; -import { getRlpEncodedSwapData } from '../../xcall/utils'; -import { isSpokeToken } from '../archway'; +import { XTransactionInput } from '../../xcall/types'; import { HavahXService } from './HavahXService'; export class HavahXWalletClient extends XWalletClient { @@ -26,7 +20,7 @@ export class HavahXWalletClient extends XWalletClient { } const txResult = await this.getXService() .walletClient.inject({ account }) - .AssetManager['deposit'](parseFloat(inputAmount.toExact()), destination, data, fee.toString()); + .AssetManager['deposit'](parseFloat(inputAmount.toExact()), destination, toHex(data), fee.toString()); const { txHash: hash } = txResult || {}; return hash; } @@ -34,7 +28,7 @@ export class HavahXWalletClient extends XWalletClient { async _crossTransfer({ account, inputAmount, destination, data, fee }: DepositParams) { const txResult = await this.getXService() .walletClient.inject({ account }) - .bnUSD['crossTransferV2'](destination, toDec(inputAmount), data, fee); + .bnUSD['crossTransferV2'](destination, toDec(inputAmount), toHex(data), fee); const { txHash: hash } = txResult || {}; return hash; } @@ -43,75 +37,15 @@ export class HavahXWalletClient extends XWalletClient { throw new Error('Method not implemented.'); } - async executeSwapOrBridge(xTransactionInput: XTransactionInput) { - const { type, executionTrade, account, direction, inputAmount, recipient, slippageTolerance, xCallFee } = - xTransactionInput; - - const destination = `${ICON_XCALL_NETWORK_ID}/${bnJs.Router.address}`; - const receiver = `${direction.to}/${recipient}`; - - window.addEventListener('beforeunload', showMessageOnBeforeUnload); - - let data; - if (type === XTransactionType.SWAP) { - if (!executionTrade || !slippageTolerance) { - return; - } - - const minReceived = executionTrade.minimumAmountOut(new Percent(slippageTolerance, 10_000)); - const rlpEncodedData = getRlpEncodedSwapData(executionTrade, '_swap', receiver, minReceived).toString('hex'); - data = `0x${rlpEncodedData}`; - } else if (type === XTransactionType.BRIDGE) { - data = toHex( - JSON.stringify({ - method: '_swap', - params: { - path: [], - receiver: receiver, - }, - }), - ); - } else { - throw new Error('Invalid XTransactionType'); - } - - if (isSpokeToken(inputAmount.currency)) { - return await this._crossTransfer({ account, inputAmount, destination, data, fee: xCallFee.rollback }); - } else { - return await this._deposit({ account, inputAmount, destination, data, fee: xCallFee.rollback }); - } - } - async executeDepositCollateral(xTransactionInput: XTransactionInput): Promise { - throw new Error('Method not implemented.'); + throw new Error('Not supported.'); } async executeWithdrawCollateral(xTransactionInput: XTransactionInput): Promise { - throw new Error('Method not implemented.'); + throw new Error('Not supported.'); } async executeBorrow(xTransactionInput: XTransactionInput): Promise { - throw new Error('Method not implemented.'); - } - - async executeRepay(xTransactionInput: XTransactionInput) { - const { account, inputAmount, recipient, xCallFee, usedCollateral } = xTransactionInput; - - if (!inputAmount || !usedCollateral) { - return; - } - - const destination = `${ICON_XCALL_NETWORK_ID}/${bnJs.Loans.address}`; - const data = toHex( - JSON.stringify(recipient ? { _collateral: usedCollateral, _to: recipient } : { _collateral: usedCollateral }), - ); - - return await this._crossTransfer({ - account, - inputAmount: inputAmount.multiply(-1), - destination, - data, - fee: xCallFee.rollback, - }); + throw new Error('Not supported.'); } } diff --git a/packages/xwagmi/src/xchains/injective/InjectiveXWalletClient.ts b/packages/xwagmi/src/xchains/injective/InjectiveXWalletClient.ts index b07ceedbf..1292db68f 100644 --- a/packages/xwagmi/src/xchains/injective/InjectiveXWalletClient.ts +++ b/packages/xwagmi/src/xchains/injective/InjectiveXWalletClient.ts @@ -1,18 +1,10 @@ -import { Percent } from '@balancednetwork/sdk-core'; -import bnJs from '../icon/bnJs'; - -import { ICON_XCALL_NETWORK_ID } from '@/constants'; -import { getBytesFromString, getRlpEncodedSwapData, toICONDecimals } from '@/xcall/utils'; - import { FROM_SOURCES, TO_SOURCES, injective } from '@/constants/xChains'; import { XWalletClient } from '@/core'; import { DepositParams, SendCallParams } from '@/core/XWalletClient'; import { XToken } from '@/types'; -import { uintToBytes } from '@/utils'; -import { XTransactionInput, XTransactionType } from '@/xcall/types'; -import { RLP } from '@ethereumjs/rlp'; +import { getBytesFromString } from '@/xcall/utils'; import { MsgExecuteContractCompat } from '@injectivelabs/sdk-ts'; -import { isDenomAsset, isSpokeToken } from '../archway/utils'; +import { isDenomAsset } from '../archway/utils'; import { InjectiveXService } from './InjectiveXService'; export class InjectiveXWalletClient extends XWalletClient { @@ -35,7 +27,7 @@ export class InjectiveXWalletClient extends XWalletClient { deposit_denom: { denom: inputAmount.currency.address, to: destination, - data, + data: getBytesFromString(data), }, }, funds: [ @@ -54,7 +46,7 @@ export class InjectiveXWalletClient extends XWalletClient { deposit_denom: { denom: 'inj', to: destination, - data, + data: getBytesFromString(data), }, }, funds: [ @@ -83,7 +75,7 @@ export class InjectiveXWalletClient extends XWalletClient { cross_transfer: { amount, to: destination, - data, + data: getBytesFromString(data), }, }, funds: [ @@ -107,7 +99,7 @@ export class InjectiveXWalletClient extends XWalletClient { const envelope = { message: { call_message: { - data, + data: getBytesFromString(data), }, }, sources: FROM_SOURCES[sourceChainId], @@ -138,109 +130,4 @@ export class InjectiveXWalletClient extends XWalletClient { return txResult.txHash; } - - async executeSwapOrBridge(xTransactionInput: XTransactionInput) { - const { type, direction, inputAmount, executionTrade, account, recipient, xCallFee, slippageTolerance } = - xTransactionInput; - - const destination = `${ICON_XCALL_NETWORK_ID}/${bnJs.Router.address}`; - const receiver = `${direction.to}/${recipient}`; - - let data; - if (type === XTransactionType.SWAP) { - if (!executionTrade || !slippageTolerance) { - return; - } - - const minReceived = executionTrade.minimumAmountOut(new Percent(slippageTolerance, 10_000)); - const rlpEncodedData = getRlpEncodedSwapData(executionTrade, '_swap', receiver, minReceived); - data = Array.from(rlpEncodedData); - } else if (type === XTransactionType.BRIDGE) { - data = getBytesFromString( - JSON.stringify({ - method: '_swap', - params: { - path: [], - receiver: receiver, - }, - }), - ); - } else { - throw new Error('Invalid XTransactionType'); - } - - if (isSpokeToken(inputAmount.currency)) { - return await this._crossTransfer({ account, inputAmount, destination, data, fee: xCallFee.rollback }); - } else { - return await this._deposit({ account, inputAmount, destination, data, fee: xCallFee.rollback }); - } - } - - async executeDepositCollateral(xTransactionInput: XTransactionInput) { - const { inputAmount, account, xCallFee } = xTransactionInput; - - if (!inputAmount) { - return; - } - - const destination = `${ICON_XCALL_NETWORK_ID}/${bnJs.Loans.address}`; - const data = getBytesFromString(JSON.stringify({})); - - return await this._deposit({ account, inputAmount, destination, data, fee: xCallFee.rollback }); - } - - async executeWithdrawCollateral(xTransactionInput: XTransactionInput) { - const { inputAmount, account, xCallFee, usedCollateral } = xTransactionInput; - - if (!inputAmount || !usedCollateral) { - return; - } - - const destination = `${ICON_XCALL_NETWORK_ID}/${bnJs.Loans.address}`; - const amount = toICONDecimals(inputAmount.multiply(-1)); - const data = Array.from(RLP.encode(['xWithdraw', uintToBytes(amount), usedCollateral])); - - return await this._sendCall({ account, sourceChainId: this.xChainId, destination, data, fee: xCallFee.rollback }); - } - - async executeBorrow(xTransactionInput: XTransactionInput) { - const { inputAmount, account, xCallFee, usedCollateral, recipient } = xTransactionInput; - - if (!inputAmount || !usedCollateral) { - return; - } - - const destination = `${ICON_XCALL_NETWORK_ID}/${bnJs.Loans.address}`; - const amount = BigInt(inputAmount.quotient.toString()); - const data = Array.from( - RLP.encode( - recipient - ? ['xBorrow', usedCollateral, uintToBytes(amount), Buffer.from(recipient)] - : ['xBorrow', usedCollateral, uintToBytes(amount)], - ), - ); - - return await this._sendCall({ account, sourceChainId: this.xChainId, destination, data, fee: xCallFee.rollback }); - } - - async executeRepay(xTransactionInput: XTransactionInput) { - const { inputAmount, account, xCallFee, usedCollateral, recipient } = xTransactionInput; - - if (!inputAmount || !usedCollateral) { - return; - } - - const destination = `${ICON_XCALL_NETWORK_ID}/${bnJs.Loans.address}`; - const data = getBytesFromString( - JSON.stringify(recipient ? { _collateral: usedCollateral, _to: recipient } : { _collateral: usedCollateral }), - ); - - return await this._crossTransfer({ - account, - inputAmount: inputAmount.multiply(-1), - destination, - data, - fee: xCallFee.rollback, - }); - } } diff --git a/packages/xwagmi/src/xchains/solana/SolanaXWalletClient.ts b/packages/xwagmi/src/xchains/solana/SolanaXWalletClient.ts index 87df18d49..e9fdbdff6 100644 --- a/packages/xwagmi/src/xchains/solana/SolanaXWalletClient.ts +++ b/packages/xwagmi/src/xchains/solana/SolanaXWalletClient.ts @@ -1,8 +1,5 @@ -import { ICON_XCALL_NETWORK_ID } from '@/constants'; import { FROM_SOURCES, TO_SOURCES, solana } from '@/constants/xChains'; import { DepositParams, SendCallParams, XWalletClient } from '@/core/XWalletClient'; -import { uintToBytes } from '@/utils'; -import { Percent } from '@balancednetwork/sdk-core'; import { Program } from '@coral-xyz/anchor'; import * as anchor from '@coral-xyz/anchor'; import { SYSTEM_PROGRAM_ID } from '@coral-xyz/anchor/dist/cjs/native/system'; @@ -13,12 +10,6 @@ import { getAssociatedTokenAddressSync, } from '@solana/spl-token'; import { ComputeBudgetProgram, PublicKey, SystemProgram, Transaction } from '@solana/web3.js'; -import * as rlp from 'rlp'; -import { toBytes } from 'viem'; -import { XTransactionInput, XTransactionType } from '../../xcall/types'; -import { getRlpEncodedSwapData, toICONDecimals } from '../../xcall/utils'; -import { isSpokeToken } from '../archway'; -import bnJs from '../icon/bnJs'; import { SolanaXService } from './SolanaXService'; import assetManagerIdl from './idls/assetManager.json'; import bnUSDIdl from './idls/bnUSD.json'; @@ -268,99 +259,4 @@ export class SolanaXWalletClient extends XWalletClient { const txSignature = await wallet.sendTransaction(tx, connection); return txSignature; } - - async executeSwapOrBridge(xTransactionInput: XTransactionInput) { - const { type, executionTrade, account, direction, inputAmount, recipient, slippageTolerance, xCallFee } = - xTransactionInput; - - const destination = `${ICON_XCALL_NETWORK_ID}/${bnJs.Router.address}`; - const receiver = `${direction.to}/${recipient}`; - - let data; - if (type === XTransactionType.SWAP) { - if (!executionTrade || !slippageTolerance) { - return; - } - - const minReceived = executionTrade.minimumAmountOut(new Percent(slippageTolerance, 10_000)); - - const rlpEncodedData = getRlpEncodedSwapData(executionTrade, '_swap', receiver, minReceived); - data = rlpEncodedData; - } else if (type === XTransactionType.BRIDGE) { - data = toBytes( - JSON.stringify({ - method: '_swap', - params: { - path: [], - receiver: receiver, - }, - }), - ); - } else { - throw new Error('Invalid XTransactionType'); - } - - if (isSpokeToken(inputAmount.currency)) { - return await this._crossTransfer({ account, inputAmount, destination, data, fee: 0n }); - } else { - return await this._deposit({ account, inputAmount, destination, data, fee: 0n }); - } - } - - async executeDepositCollateral(xTransactionInput: XTransactionInput) { - const { account, inputAmount } = xTransactionInput; - - const destination = `${ICON_XCALL_NETWORK_ID}/${bnJs.Loans.address}`; - const data: any = toBytes(JSON.stringify({})); - - return await this._deposit({ account, inputAmount, destination, data, fee: 0n }); - } - - async executeWithdrawCollateral(xTransactionInput: XTransactionInput) { - const { inputAmount, account, usedCollateral, direction } = xTransactionInput; - - if (!inputAmount || !usedCollateral) { - return; - } - - const amount = toICONDecimals(inputAmount.multiply(-1)); - const destination = `${ICON_XCALL_NETWORK_ID}/${bnJs.Loans.address}`; - - const data = rlp.encode(['xWithdraw', uintToBytes(amount), usedCollateral]); - - return await this._sendCall({ account, sourceChainId: direction.from, destination, data, fee: 0n }); - } - - async executeBorrow(xTransactionInput: XTransactionInput) { - const { inputAmount, account, usedCollateral, direction, recipient } = xTransactionInput; - - if (!inputAmount || !usedCollateral) { - return; - } - - const amount = BigInt(inputAmount.quotient.toString()); - const destination = `${ICON_XCALL_NETWORK_ID}/${bnJs.Loans.address}`; - - const data = rlp.encode( - recipient - ? ['xBorrow', usedCollateral, uintToBytes(amount), Buffer.from(recipient)] - : ['xBorrow', usedCollateral, uintToBytes(amount)], - ); - - return await this._sendCall({ account, sourceChainId: direction.from, destination, data, fee: 0n }); - } - - async executeRepay(xTransactionInput: XTransactionInput) { - const { account, inputAmount, recipient, usedCollateral } = xTransactionInput; - - if (!inputAmount || !usedCollateral) { - return; - } - - const destination = `${ICON_XCALL_NETWORK_ID}/${bnJs.Loans.address}`; - const data: any = toBytes( - JSON.stringify(recipient ? { _collateral: usedCollateral, _to: recipient } : { _collateral: usedCollateral }), - ); - return await this._crossTransfer({ account, inputAmount: inputAmount.multiply(-1), destination, data, fee: 0n }); - } } diff --git a/packages/xwagmi/src/xchains/stellar/StellarXWalletClient.ts b/packages/xwagmi/src/xchains/stellar/StellarXWalletClient.ts index cb38d05ce..bfe8bd02d 100644 --- a/packages/xwagmi/src/xchains/stellar/StellarXWalletClient.ts +++ b/packages/xwagmi/src/xchains/stellar/StellarXWalletClient.ts @@ -1,16 +1,7 @@ -import { Percent } from '@balancednetwork/sdk-core'; -import bnJs from '../icon/bnJs'; - -import { ICON_XCALL_NETWORK_ID } from '@/constants'; import { FROM_SOURCES, TO_SOURCES, stellar } from '@/constants/xChains'; import { XWalletClient } from '@/core'; import { DepositParams, SendCallParams } from '@/core/XWalletClient'; -import { uintToBytes } from '@/utils'; -import { XTransactionInput, XTransactionType } from '@/xcall/types'; -import { getRlpEncodedSwapData, toICONDecimals } from '@/xcall/utils'; -import { RLP } from '@ethereumjs/rlp'; import { BASE_FEE, Networks, TransactionBuilder, nativeToScVal } from '@stellar/stellar-sdk'; -import { isSpokeToken } from '../archway/utils'; import { StellarXService } from './StellarXService'; import { STELLAR_RLP_DATA_TYPE, @@ -39,12 +30,14 @@ export class StellarXWalletClient extends XWalletClient { networkPassphrase: Networks.PUBLIC, }); + const encoder = new TextEncoder(); + const params = [ accountToScVal(account), nativeToScVal(XLM_CONTRACT_ADDRESS, { type: 'address' }), nativeToScVal(inputAmount.quotient, { type: 'u128' }), nativeToScVal(destination), - nativeToScVal(data, { type: 'bytes' }), + nativeToScVal(encoder.encode(data), { type: 'bytes' }), ]; const hash = await sendTX(stellar.contracts.assetManager, 'deposit', params, txBuilder, server, kit); @@ -60,11 +53,13 @@ export class StellarXWalletClient extends XWalletClient { networkPassphrase: Networks.PUBLIC, }); + const encoder = new TextEncoder(); + const params = [ accountToScVal(account), nativeToScVal(inputAmount.quotient, { type: 'u128' }), nativeToScVal(destination), - nativeToScVal(data, { type: 'bytes' }), + nativeToScVal(encoder.encode(data), { type: 'bytes' }), ]; const hash = await sendTX(inputAmount.currency.wrapped.address, 'cross_transfer', params, txBuilder, server, kit); @@ -97,102 +92,4 @@ export class StellarXWalletClient extends XWalletClient { const hash = await sendTX(stellar.contracts.xCall, 'send_call', params, txBuilder, server, kit); return hash; } - - async executeSwapOrBridge(xTransactionInput: XTransactionInput): Promise { - if (xTransactionInput.type === XTransactionType.BRIDGE) { - return await this.handleBridgeTransaction(xTransactionInput); - } else if (xTransactionInput.type === XTransactionType.SWAP) { - return await this.handleSwapTransaction(xTransactionInput); - } else { - throw new Error('Invalid XTransactionType'); - } - } - - async handleBridgeTransaction(xTransactionInput: XTransactionInput): Promise { - const { account, inputAmount, recipient, direction } = xTransactionInput; - const receiver = `${direction.to}/${recipient}`; - const destination = `${ICON_XCALL_NETWORK_ID}/${bnJs.Router.address}`; - const dataObj = { method: '_swap', params: { path: [], receiver } }; - const encoder = new TextEncoder(); - const data = encoder.encode(JSON.stringify(dataObj)); - - if (isSpokeToken(inputAmount.currency)) { - return await this._crossTransfer({ account, inputAmount, destination, data, fee: 0n }); - } else { - return await this._deposit({ account, inputAmount, destination, data, fee: 0n }); - } - } - - async handleSwapTransaction(xTransactionInput: XTransactionInput): Promise { - const { inputAmount, executionTrade, account, recipient, direction, slippageTolerance } = xTransactionInput; - const receiver = `${direction.to}/${recipient}`; - - if (!executionTrade || !slippageTolerance) { - return; - } - - const minReceived = executionTrade.minimumAmountOut(new Percent(slippageTolerance, 10_000)); - const destination = `${ICON_XCALL_NETWORK_ID}/${bnJs.Router.address}`; - const rlpEncodedData = getRlpEncodedSwapData(executionTrade, '_swap', receiver, minReceived); - const data = new Uint8Array(rlpEncodedData); - - if (isSpokeToken(inputAmount.currency)) { - return await this._crossTransfer({ account, inputAmount, destination, data, fee: 0n }); - } else { - return await this._deposit({ account, inputAmount, destination, data, fee: 0n }); - } - } - - async executeDepositCollateral(xTransactionInput: XTransactionInput): Promise { - const { inputAmount, account } = xTransactionInput; - if (!inputAmount) { - throw new Error('Invalid input amount'); - } - - const destination = `${ICON_XCALL_NETWORK_ID}/${bnJs.Loans.address}`; - const encoder = new TextEncoder(); - const data = encoder.encode(JSON.stringify({})); - - return await this._deposit({ account, inputAmount, destination, data, fee: 0n }); - } - - async executeWithdrawCollateral(xTransactionInput: XTransactionInput): Promise { - const { inputAmount, account, direction, usedCollateral } = xTransactionInput; - if (!inputAmount || !usedCollateral) { - return; - } - - const destination = `${ICON_XCALL_NETWORK_ID}/${bnJs.Loans.address}`; - const amount = toICONDecimals(inputAmount.multiply(-1)); - const data = RLP.encode(['xWithdraw', uintToBytes(amount), usedCollateral]); - return await this._sendCall({ account, sourceChainId: direction.from, destination, data, fee: 0n }); - } - - async executeBorrow(xTransactionInput: XTransactionInput): Promise { - const { inputAmount, account, direction, usedCollateral, recipient } = xTransactionInput; - if (!inputAmount || !usedCollateral) { - return; - } - - const destination = `${ICON_XCALL_NETWORK_ID}/${bnJs.Loans.address}`; - const amount = BigInt(inputAmount.quotient.toString()); - const data = RLP.encode( - recipient - ? ['xBorrow', usedCollateral, uintToBytes(amount), Buffer.from(recipient)] - : ['xBorrow', usedCollateral, uintToBytes(amount)], - ); - return await this._sendCall({ account, sourceChainId: direction.from, destination, data, fee: 0n }); - } - - async executeRepay(xTransactionInput: XTransactionInput): Promise { - const { inputAmount, account, usedCollateral, recipient } = xTransactionInput; - if (!inputAmount || !usedCollateral) { - return; - } - const destination = `${ICON_XCALL_NETWORK_ID}/${bnJs.Loans.address}`; - const dataObj = recipient ? { _collateral: usedCollateral, _to: recipient } : { _collateral: usedCollateral }; - const encoder = new TextEncoder(); - const data = encoder.encode(JSON.stringify(dataObj)); - return await this._crossTransfer({ account, inputAmount: inputAmount.multiply(-1), destination, data, fee: 0n }); - } } diff --git a/packages/xwagmi/src/xchains/sui/SuiXWalletClient.ts b/packages/xwagmi/src/xchains/sui/SuiXWalletClient.ts index 30ee630c8..fff0207a5 100644 --- a/packages/xwagmi/src/xchains/sui/SuiXWalletClient.ts +++ b/packages/xwagmi/src/xchains/sui/SuiXWalletClient.ts @@ -1,19 +1,13 @@ -import { Percent } from '@balancednetwork/sdk-core'; -import bnJs from '../icon/bnJs'; - import { ICON_XCALL_NETWORK_ID, xTokenMap } from '@/constants'; - import { FROM_SOURCES, TO_SOURCES, sui } from '@/constants/xChains'; import { DepositParams, SendCallParams, XWalletClient } from '@/core/XWalletClient'; -import { uintToBytes } from '@/utils'; import { RLP } from '@ethereumjs/rlp'; import { bcs } from '@mysten/sui/bcs'; import { Transaction } from '@mysten/sui/transactions'; import { signTransaction } from '@mysten/wallet-standard'; import { toBytes, toHex } from 'viem'; -import { XTransactionInput, XTransactionType } from '../../xcall/types'; -import { getRlpEncodedSwapData, toICONDecimals } from '../../xcall/utils'; -import { isSpokeToken } from '../archway'; +import { XTransactionInput } from '../../xcall/types'; +import bnJs from '../icon/bnJs'; import { SuiXService } from './SuiXService'; const addressesMainnet = { @@ -97,7 +91,7 @@ export class SuiXWalletClient extends XWalletClient { feeCoin, depositCoin, txb.pure(bcs.vector(bcs.string()).serialize([destination])), - txb.pure(bcs.vector(bcs.vector(bcs.u8())).serialize([data])), + txb.pure(bcs.vector(bcs.vector(bcs.u8())).serialize([toBytes(data)])), ], typeArguments: [coinType], }); @@ -140,7 +134,7 @@ export class SuiXWalletClient extends XWalletClient { feeCoin, depositCoin, txb.pure(bcs.string().serialize(destination)), - txb.pure(bcs.vector(bcs.vector(bcs.u8())).serialize([data])), + txb.pure(bcs.vector(bcs.vector(bcs.u8())).serialize([toBytes(data)])), ], // typeArguments: [], }); @@ -153,7 +147,7 @@ export class SuiXWalletClient extends XWalletClient { toHex( RLP.encode([ Buffer.from([0]), - data, + toHex(data), FROM_SOURCES[sourceChainId]?.map(Buffer.from), TO_SOURCES[sourceChainId]?.map(Buffer.from), ]), @@ -175,91 +169,6 @@ export class SuiXWalletClient extends XWalletClient { return await this._signAndExecuteTransactionBlock(txb); } - async executeSwapOrBridge(xTransactionInput: XTransactionInput) { - const { type, executionTrade, account, direction, inputAmount, recipient, slippageTolerance, xCallFee } = - xTransactionInput; - - const destination = `${ICON_XCALL_NETWORK_ID}/${bnJs.Router.address}`; - const receiver = `${direction.to}/${recipient}`; - - let data; - if (type === XTransactionType.SWAP) { - if (!executionTrade || !slippageTolerance) { - return; - } - - const minReceived = executionTrade.minimumAmountOut(new Percent(slippageTolerance, 10_000)); - - const rlpEncodedData = getRlpEncodedSwapData(executionTrade, '_swap', receiver, minReceived); - data = rlpEncodedData; - } else if (type === XTransactionType.BRIDGE) { - data = toBytes( - JSON.stringify({ - method: '_swap', - params: { - path: [], - receiver: receiver, - }, - }), - ); - } else { - throw new Error('Invalid XTransactionType'); - } - - if (isSpokeToken(inputAmount.currency)) { - return await this._crossTransfer({ inputAmount, account, destination, data, fee: 0n }); - } else { - return await this._deposit({ inputAmount, account, destination, data, fee: 0n }); - } - } - - async executeDepositCollateral(xTransactionInput: XTransactionInput) { - const { inputAmount, account, xCallFee } = xTransactionInput; - - if (!inputAmount) { - return; - } - - const destination = `${ICON_XCALL_NETWORK_ID}/${bnJs.Loans.address}`; - const data = toBytes(JSON.stringify({})); - - return await this._deposit({ inputAmount, account, destination, data, fee: 0n }); - } - - async executeWithdrawCollateral(xTransactionInput: XTransactionInput) { - const { inputAmount, account, xCallFee, usedCollateral, direction } = xTransactionInput; - - if (!inputAmount || !usedCollateral) { - return; - } - - const amount = toICONDecimals(inputAmount.multiply(-1)); - const destination = `${ICON_XCALL_NETWORK_ID}/${bnJs.Loans.address}`; - const data = toHex(RLP.encode(['xWithdraw', uintToBytes(amount), usedCollateral])); - - return await this._sendCall({ account, sourceChainId: direction.from, destination, data, fee: 0n }); - } - - async executeBorrow(xTransactionInput: XTransactionInput) { - const { inputAmount, account, xCallFee, usedCollateral, recipient, direction } = xTransactionInput; - - if (!inputAmount || !usedCollateral) { - return; - } - - const amount = BigInt(inputAmount.quotient.toString()); - const destination = `${ICON_XCALL_NETWORK_ID}/${bnJs.Loans.address}`; - const data = toHex( - RLP.encode( - recipient - ? ['xBorrow', usedCollateral, uintToBytes(amount), Buffer.from(recipient)] - : ['xBorrow', usedCollateral, uintToBytes(amount)], - ), - ); - - return await this._sendCall({ account, sourceChainId: direction.from, destination, data, fee: 0n }); - } - async executeRepay(xTransactionInput: XTransactionInput) { const { inputAmount, account, xCallFee, usedCollateral, recipient, direction } = xTransactionInput; @@ -321,3 +230,5 @@ export class SuiXWalletClient extends XWalletClient { return await this._signAndExecuteTransactionBlock(txb); } } + +// TODO: toBytes vs toHex? From 25c9ab9b358f5e64f17f0a9bc87afe073d7bf231 Mon Sep 17 00:00:00 2001 From: swiftcc624 Date: Sat, 11 Jan 2025 19:37:45 +0800 Subject: [PATCH 33/33] fix circular imports in xwagmi --- packages/xwagmi/src/core/XWalletClient.ts | 5 ++--- packages/xwagmi/src/utils/index.ts | 6 +++++- packages/xwagmi/src/xchains/archway/utils.ts | 4 ---- packages/xwagmi/src/xchains/icon/IconXWalletClient.ts | 2 +- 4 files changed, 8 insertions(+), 9 deletions(-) diff --git a/packages/xwagmi/src/core/XWalletClient.ts b/packages/xwagmi/src/core/XWalletClient.ts index cc3cf7f9f..775dd0784 100644 --- a/packages/xwagmi/src/core/XWalletClient.ts +++ b/packages/xwagmi/src/core/XWalletClient.ts @@ -1,9 +1,8 @@ import { ICON_XCALL_NETWORK_ID, xTokenMapBySymbol } from '@/constants'; -import { uintToBytes } from '@/utils'; +import { isSpokeToken, uintToBytes } from '@/utils'; import { getRlpEncodedSwapData, toICONDecimals } from '@/xcall'; import { XTransactionInput, XTransactionType } from '@/xcall/types'; -import { isSpokeToken } from '@/xchains/archway'; -import { bnJs } from '@/xchains/icon'; +import { bnJs } from '@/xchains/icon/bnJs'; import { CurrencyAmount, Percent } from '@balancednetwork/sdk-core'; import { RLP } from '@ethereumjs/rlp'; import { XChainId, XToken } from '../types'; diff --git a/packages/xwagmi/src/utils/index.ts b/packages/xwagmi/src/utils/index.ts index 329208e25..35c120d65 100644 --- a/packages/xwagmi/src/utils/index.ts +++ b/packages/xwagmi/src/utils/index.ts @@ -7,7 +7,7 @@ import { bech32 } from 'bech32'; import BigNumber from 'bignumber.js'; import { ethers } from 'ethers'; import { Validator } from 'icon-sdk-js'; -import { XChainId } from '../types'; +import { XChainId, XToken } from '../types'; import { SolanaXService } from '../xchains/solana'; import { isStellarAddress } from '../xchains/stellar/utils'; @@ -208,3 +208,7 @@ export async function validateAddress(address: string, chainId: XChainId): Promi export function isIconTransaction(from: XChainId | undefined, to: XChainId | undefined): boolean { return from === '0x1.icon' && to === '0x1.icon'; } + +export function isSpokeToken(token: XToken): boolean { + return ['bnUSD', 'sICX', 'BALN'].includes(token.symbol); +} diff --git a/packages/xwagmi/src/xchains/archway/utils.ts b/packages/xwagmi/src/xchains/archway/utils.ts index 03efc4123..951ef37e9 100644 --- a/packages/xwagmi/src/xchains/archway/utils.ts +++ b/packages/xwagmi/src/xchains/archway/utils.ts @@ -10,7 +10,3 @@ export function getFeeParam(fee: number): StdFee | 'auto' { export function isDenomAsset(token: XToken | Token): boolean { return token.address.startsWith('ibc/'); } - -export function isSpokeToken(token: XToken): boolean { - return ['bnUSD', 'sICX', 'BALN'].includes(token.symbol); -} diff --git a/packages/xwagmi/src/xchains/icon/IconXWalletClient.ts b/packages/xwagmi/src/xchains/icon/IconXWalletClient.ts index c674ff870..3d17b8e75 100644 --- a/packages/xwagmi/src/xchains/icon/IconXWalletClient.ts +++ b/packages/xwagmi/src/xchains/icon/IconXWalletClient.ts @@ -2,10 +2,10 @@ import { Percent } from '@balancednetwork/sdk-core'; import bnJs from './bnJs'; import { DepositParams, SendCallParams, XWalletClient } from '@/core/XWalletClient'; +import { isSpokeToken } from '@/utils'; import { showMessageOnBeforeUnload, toDec } from '@/utils'; import { XTransactionInput, XTransactionType } from '../../xcall/types'; import { getRlpEncodedSwapData } from '../../xcall/utils'; -import { isSpokeToken } from '../archway/utils'; import { IconXService } from './IconXService'; export class IconXWalletClient extends XWalletClient {