Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"@floating-ui/dom": "1.6.7",
"@floating-ui/react": "0.26.19",
"@gelatonetwork/relay-sdk": "5.6.0",
"@gemini-wallet/rainbow": "0.2.0",
"@headlessui/react": "1.7.19",
"@lingui/core": "4.10.0",
"@lingui/macro": "4.11.3",
Expand Down
53 changes: 44 additions & 9 deletions sdk/src/types/subsquid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,13 @@ export interface AccountStatsConnection {
totalCount: Scalars["Int"]["output"];
}

export interface AnnualizedPerformanceObject {
__typename?: "AnnualizedPerformanceObject";
address: Scalars["String"]["output"];
entity: Scalars["String"]["output"];
performance: Scalars["BigInt"]["output"];
}

export interface AprSnapshot {
__typename?: "AprSnapshot";
address: Scalars["String"]["output"];
Expand Down Expand Up @@ -1542,7 +1549,7 @@ export interface Distribution {
receiver: Scalars["String"]["output"];
tokens: Array<Scalars["String"]["output"]>;
transaction: Transaction;
typeId: Scalars["Int"]["output"];
typeId: Scalars["BigInt"]["output"];
}

export interface DistributionEdge {
Expand Down Expand Up @@ -1665,15 +1672,15 @@ export interface DistributionWhereInput {
tokens_isNull?: InputMaybe<Scalars["Boolean"]["input"]>;
transaction?: InputMaybe<TransactionWhereInput>;
transaction_isNull?: InputMaybe<Scalars["Boolean"]["input"]>;
typeId_eq?: InputMaybe<Scalars["Int"]["input"]>;
typeId_gt?: InputMaybe<Scalars["Int"]["input"]>;
typeId_gte?: InputMaybe<Scalars["Int"]["input"]>;
typeId_in?: InputMaybe<Array<Scalars["Int"]["input"]>>;
typeId_eq?: InputMaybe<Scalars["BigInt"]["input"]>;
typeId_gt?: InputMaybe<Scalars["BigInt"]["input"]>;
typeId_gte?: InputMaybe<Scalars["BigInt"]["input"]>;
typeId_in?: InputMaybe<Array<Scalars["BigInt"]["input"]>>;
typeId_isNull?: InputMaybe<Scalars["Boolean"]["input"]>;
typeId_lt?: InputMaybe<Scalars["Int"]["input"]>;
typeId_lte?: InputMaybe<Scalars["Int"]["input"]>;
typeId_not_eq?: InputMaybe<Scalars["Int"]["input"]>;
typeId_not_in?: InputMaybe<Array<Scalars["Int"]["input"]>>;
typeId_lt?: InputMaybe<Scalars["BigInt"]["input"]>;
typeId_lte?: InputMaybe<Scalars["BigInt"]["input"]>;
typeId_not_eq?: InputMaybe<Scalars["BigInt"]["input"]>;
typeId_not_in?: InputMaybe<Array<Scalars["BigInt"]["input"]>>;
}

export interface DistributionsConnection {
Expand Down Expand Up @@ -4301,6 +4308,24 @@ export interface PageInfo {
startCursor: Scalars["String"]["output"];
}

export interface PerformanceSnapshotObject {
__typename?: "PerformanceSnapshotObject";
performance: Scalars["String"]["output"];
snapshotTimestamp: Scalars["String"]["output"];
}

export interface PerformanceSnapshots {
__typename?: "PerformanceSnapshots";
address: Scalars["String"]["output"];
entity: Scalars["String"]["output"];
snapshots: Array<PerformanceSnapshotObject>;
}

export interface PerformanceWhereInput {
addresses?: InputMaybe<Array<Scalars["String"]["input"]>>;
period: Scalars["String"]["input"];
}

export interface PeriodAccountStatObject {
__typename?: "PeriodAccountStatObject";
closedCount: Scalars["Float"]["output"];
Expand Down Expand Up @@ -6000,6 +6025,7 @@ export interface Query {
accountStatById?: Maybe<AccountStat>;
accountStats: Array<AccountStat>;
accountStatsConnection: AccountStatsConnection;
annualizedPerformance: Array<AnnualizedPerformanceObject>;
aprSnapshotById?: Maybe<AprSnapshot>;
aprSnapshots: Array<AprSnapshot>;
aprSnapshotsConnection: AprSnapshotsConnection;
Expand Down Expand Up @@ -6046,6 +6072,7 @@ export interface Query {
orderById?: Maybe<Order>;
orders: Array<Order>;
ordersConnection: OrdersConnection;
performanceSnapshots: Array<PerformanceSnapshots>;
periodAccountStats: Array<PeriodAccountStatObject>;
pnlAprSnapshotById?: Maybe<PnlAprSnapshot>;
pnlAprSnapshots: Array<PnlAprSnapshot>;
Expand Down Expand Up @@ -6108,6 +6135,10 @@ export interface QueryaccountStatsConnectionArgs {
where?: InputMaybe<AccountStatWhereInput>;
}

export interface QueryannualizedPerformanceArgs {
where?: InputMaybe<PerformanceWhereInput>;
}

export interface QueryaprSnapshotByIdArgs {
id: Scalars["String"]["input"];
}
Expand Down Expand Up @@ -6376,6 +6407,10 @@ export interface QueryordersConnectionArgs {
where?: InputMaybe<OrderWhereInput>;
}

export interface QueryperformanceSnapshotsArgs {
where?: InputMaybe<PerformanceWhereInput>;
}

export interface QueryperiodAccountStatsArgs {
limit?: InputMaybe<Scalars["Float"]["input"]>;
offset?: InputMaybe<Scalars["Float"]["input"]>;
Expand Down
20 changes: 13 additions & 7 deletions src/components/OneClickPromoBanner/OneClickPromoBanner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { getOneClickTradingPromoHiddenKey } from "config/localStorage";
import { useSettings } from "context/SettingsContext/SettingsContextProvider";
import { useIsOutOfGasPaymentBalance } from "domain/synthetics/express/useIsOutOfGasPaymentBalance";
import { useChainId } from "lib/chains";
import { useIsGeminiWallet } from "lib/wallets/useIsGeminiWallet";

import { ColorfulBanner } from "components/ColorfulBanner/ColorfulBanner";

Expand All @@ -20,19 +21,24 @@ export function OneClickPromoBanner({ openSettings, isShort }: { openSettings: (
false
);

const isGeminiWallet = useIsGeminiWallet();
const isOutOfGasPaymentBalance = useIsOutOfGasPaymentBalance();

const shouldShow = getIsFlagEnabled("testOneClickPromo") && !isOneClickPromoHidden && !expressOrdersEnabled;
const shouldShow =
getIsFlagEnabled("testOneClickPromo") && !isOneClickPromoHidden && !expressOrdersEnabled && !isGeminiWallet;

const onClickEnable = useCallback(() => {
openSettings();
if (!isOutOfGasPaymentBalance) {
setTimeout(() => {
setExpressOrdersEnabled(true);
setIsOneClickPromoHidden(true);
}, 500);

if (isOutOfGasPaymentBalance || isGeminiWallet) {
return;
}
}, [isOutOfGasPaymentBalance, openSettings, setExpressOrdersEnabled, setIsOneClickPromoHidden]);

setTimeout(() => {
setExpressOrdersEnabled(true);
setIsOneClickPromoHidden(true);
}, 500);
}, [isGeminiWallet, isOutOfGasPaymentBalance, openSettings, setExpressOrdersEnabled, setIsOneClickPromoHidden]);

if (!shouldShow) {
return null;
Expand Down
38 changes: 26 additions & 12 deletions src/components/SettingsModal/SettingsModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@ import { helperToast } from "lib/helperToast";
import { roundToTwoDecimals } from "lib/numbers";
import { EMPTY_ARRAY } from "lib/objects";
import { mustNeverExist } from "lib/types";
import { useIsGeminiWallet } from "lib/wallets/useIsGeminiWallet";
import { MAX_TWAP_NUMBER_OF_PARTS, MIN_TWAP_NUMBER_OF_PARTS } from "sdk/configs/twap";

import { AbFlagSettings } from "components/AbFlagsSettings/AbFlagsSettings";
import { ColorfulBanner } from "components/ColorfulBanner/ColorfulBanner";
import { DebugSwapsSettings } from "components/DebugSwapsSettings/DebugSwapsSettings";
import { ExpressTradingOutOfGasBanner } from "components/ExpressTradingOutOfGasBanner.ts/ExpressTradingOutOfGasBanner";
import ExternalLink from "components/ExternalLink/ExternalLink";
Expand Down Expand Up @@ -55,7 +57,7 @@ export function SettingsModal({
const subaccountState = useSubaccountContext();

const [tradingMode, setTradingMode] = useState<TradingMode | undefined>(undefined);
const [isTradningModeChanging, setIsTradningModeChanging] = useState(false);
const [isTradingModeChanging, setIsTradingModeChanging] = useState(false);

const [numberOfParts, setNumberOfParts] = useState<number>();
const isOutOfGasPaymentBalance = useIsOutOfGasPaymentBalance();
Expand Down Expand Up @@ -143,10 +145,12 @@ export function SettingsModal({
setIsSettingsVisible(false);
}, [setIsSettingsVisible]);

const isGeminiWallet = useIsGeminiWallet();

const handleTradingModeChange = useCallback(
async (mode: TradingMode) => {
const prevMode = tradingMode;
setIsTradningModeChanging(true);
setIsTradingModeChanging(true);
setTradingMode(mode);

switch (mode) {
Expand All @@ -156,13 +160,13 @@ export function SettingsModal({

if (!isSubaccountDeactivated) {
setTradingMode(prevMode);
setIsTradningModeChanging(false);
setIsTradingModeChanging(false);
return;
}
}

settings.setExpressOrdersEnabled(false);
setIsTradningModeChanging(false);
setIsTradingModeChanging(false);
break;
}
case TradingMode.Express: {
Expand All @@ -171,26 +175,26 @@ export function SettingsModal({

if (!isSubaccountDeactivated) {
setTradingMode(prevMode);
setIsTradningModeChanging(false);
setIsTradingModeChanging(false);
return;
}
}

settings.setExpressOrdersEnabled(true);
setIsTradningModeChanging(false);
setIsTradingModeChanging(false);
break;
}
case TradingMode.Express1CT: {
const isSubaccountActivated = await subaccountState.tryEnableSubaccount();

if (!isSubaccountActivated) {
setTradingMode(prevMode);
setIsTradningModeChanging(false);
setIsTradingModeChanging(false);
return;
}

settings.setExpressOrdersEnabled(true);
setIsTradningModeChanging(false);
setIsTradingModeChanging(false);
break;
}
default: {
Expand All @@ -204,7 +208,7 @@ export function SettingsModal({

useEffect(
function defineTradingMode() {
if (isTradningModeChanging) {
if (isTradingModeChanging) {
return;
}

Expand All @@ -222,9 +226,11 @@ export function SettingsModal({
setTradingMode(nextTradingMode);
}
},
[isTradningModeChanging, settings.expressOrdersEnabled, subaccountState.subaccount, tradingMode]
[isTradingModeChanging, settings.expressOrdersEnabled, subaccountState.subaccount, tradingMode]
);

const isExpressTradingDisabled = isOutOfGasPaymentBalance || isGeminiWallet;

return (
<SlideModal
isVisible={isSettingsVisible}
Expand Down Expand Up @@ -270,7 +276,7 @@ export function SettingsModal({
</Trans>
}
icon={<ExpressIcon />}
disabled={isOutOfGasPaymentBalance}
disabled={isExpressTradingDisabled}
chip={
<Chip color="gray">
<Trans>Optimal</Trans>
Expand All @@ -284,7 +290,7 @@ export function SettingsModal({
title="Express + One-Click"
description="CEX-like experience with Express reliability"
icon={<OneClickIcon />}
disabled={isOutOfGasPaymentBalance}
disabled={isExpressTradingDisabled}
info={
<Trans>
Your wallet, your keys. GMX executes transactions for you without individual signing, providing a
Expand All @@ -303,6 +309,14 @@ export function SettingsModal({

{isOutOfGasPaymentBalance && <ExpressTradingOutOfGasBanner onClose={onClose} />}

{isGeminiWallet && (
<ColorfulBanner color="slate" icon={<ExpressIcon className="-mt-6" />}>
<div className="text-body-small mr-8 pl-8">
<Trans>Gemini Wallet is not supported for Express or One-Click trading.</Trans>
</div>
</ColorfulBanner>
)}

<OldSubaccountWithdraw />

{Boolean(subaccountState.subaccount && getIsSubaccountActive(subaccountState.subaccount)) && (
Expand Down
2 changes: 2 additions & 0 deletions src/lib/wallets/rainbowKitConfig.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { geminiRainbowKitConnector } from "@gemini-wallet/rainbow";
import { getDefaultConfig, WalletList } from "@rainbow-me/rainbowkit";
import {
coinbaseWallet,
Expand Down Expand Up @@ -34,6 +35,7 @@ const popularWalletList: WalletList = [
injectedWallet,
// The Safe option will only appear in the Safe Wallet browser environment.
safeWallet,
geminiRainbowKitConnector,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doc says it should be wrapped into a function,
would be good to understand, why
https://www.npmjs.com/package/@gemini-wallet/rainbow
image

],
},
];
Expand Down
9 changes: 9 additions & 0 deletions src/lib/wallets/useIsGeminiWallet.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { useAccount } from "wagmi";

const GEMINI_WALLET_ID = "gemini";

export function useIsGeminiWallet() {
const { connector } = useAccount();

return connector?.id === GEMINI_WALLET_ID;
}
8 changes: 4 additions & 4 deletions src/locales/de/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -486,10 +486,6 @@ msgstr "Swappe {0} gegen {1} auf 1inch"
msgid "No pools matched."
msgstr ""

#: src/components/Synthetics/TradeBox/hooks/useTradeButtonState.tsx
#~ msgid "No swap path available. <0>Swap {0} to {swapToTokenSymbol}</0>, then to {1}"
#~ msgstr ""

#: src/components/Exchange/PositionsList.jsx
#: src/components/Synthetics/PositionItem/PositionItem.tsx
#: src/pages/AccountDashboard/HistoricalLists.tsx
Expand Down Expand Up @@ -8516,6 +8512,10 @@ msgstr "Preis ist über Mark Preis"
msgid "This position could be liquidated, excluding any price movement, due to funding and borrowing fee rates reducing the position's collateral over time."
msgstr ""

#: src/components/SettingsModal/SettingsModal.tsx
msgid "Gemini Wallet is not supported for Express or One-Click trading."
msgstr ""

#: src/components/SettingsModal/SettingsModal.tsx
msgid "Your wallet, your keys. You sign each transaction off-chain. Trades use GMX-sponsored premium RPCs for reliability, even during network congestion. Gas payments in USDC or WETH."
msgstr ""
Expand Down
8 changes: 4 additions & 4 deletions src/locales/en/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -486,10 +486,6 @@ msgstr "Swap {0} to {1} on 1inch"
msgid "No pools matched."
msgstr "No pools matched."

#: src/components/Synthetics/TradeBox/hooks/useTradeButtonState.tsx
#~ msgid "No swap path available. <0>Swap {0} to {swapToTokenSymbol}</0>, then to {1}"
#~ msgstr "No swap path available. <0>Swap {0} to {swapToTokenSymbol}</0>, then to {1}"

#: src/components/Exchange/PositionsList.jsx
#: src/components/Synthetics/PositionItem/PositionItem.tsx
#: src/pages/AccountDashboard/HistoricalLists.tsx
Expand Down Expand Up @@ -8522,6 +8518,10 @@ msgstr "Price is above Mark Price"
msgid "This position could be liquidated, excluding any price movement, due to funding and borrowing fee rates reducing the position's collateral over time."
msgstr "This position could be liquidated, excluding any price movement, due to funding and borrowing fee rates reducing the position's collateral over time."

#: src/components/SettingsModal/SettingsModal.tsx
msgid "Gemini Wallet is not supported for Express or One-Click trading."
msgstr "Gemini Wallet is not supported for Express or One-Click trading."

#: src/components/SettingsModal/SettingsModal.tsx
msgid "Your wallet, your keys. You sign each transaction off-chain. Trades use GMX-sponsored premium RPCs for reliability, even during network congestion. Gas payments in USDC or WETH."
msgstr "Your wallet, your keys. You sign each transaction off-chain. Trades use GMX-sponsored premium RPCs for reliability, even during network congestion. Gas payments in USDC or WETH."
Expand Down
8 changes: 4 additions & 4 deletions src/locales/es/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -486,10 +486,6 @@ msgstr "Intercambiar {0} a {1} en 1inch"
msgid "No pools matched."
msgstr ""

#: src/components/Synthetics/TradeBox/hooks/useTradeButtonState.tsx
#~ msgid "No swap path available. <0>Swap {0} to {swapToTokenSymbol}</0>, then to {1}"
#~ msgstr ""

#: src/components/Exchange/PositionsList.jsx
#: src/components/Synthetics/PositionItem/PositionItem.tsx
#: src/pages/AccountDashboard/HistoricalLists.tsx
Expand Down Expand Up @@ -8516,6 +8512,10 @@ msgstr "El precio se encuentra por encima del precio de referencia"
msgid "This position could be liquidated, excluding any price movement, due to funding and borrowing fee rates reducing the position's collateral over time."
msgstr ""

#: src/components/SettingsModal/SettingsModal.tsx
msgid "Gemini Wallet is not supported for Express or One-Click trading."
msgstr ""

#: src/components/SettingsModal/SettingsModal.tsx
msgid "Your wallet, your keys. You sign each transaction off-chain. Trades use GMX-sponsored premium RPCs for reliability, even during network congestion. Gas payments in USDC or WETH."
msgstr ""
Expand Down
Loading
Loading