Skip to content

Commit cac5e24

Browse files
committed
Gemini wallet
1 parent 815a85d commit cac5e24

File tree

22 files changed

+2429
-150
lines changed

22 files changed

+2429
-150
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
"@floating-ui/dom": "1.6.7",
3939
"@floating-ui/react": "0.26.19",
4040
"@gelatonetwork/relay-sdk": "5.6.0",
41+
"@gemini-wallet/rainbow": "0.2.0",
4142
"@headlessui/react": "1.7.19",
4243
"@lingui/core": "4.10.0",
4344
"@lingui/macro": "4.11.3",

sdk/src/types/subsquid.ts

Lines changed: 44 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,13 @@ export interface AccountStatsConnection {
325325
totalCount: Scalars["Int"]["output"];
326326
}
327327

328+
export interface AnnualizedPerformanceObject {
329+
__typename?: "AnnualizedPerformanceObject";
330+
address: Scalars["String"]["output"];
331+
entity: Scalars["String"]["output"];
332+
performance: Scalars["BigInt"]["output"];
333+
}
334+
328335
export interface AprSnapshot {
329336
__typename?: "AprSnapshot";
330337
address: Scalars["String"]["output"];
@@ -1542,7 +1549,7 @@ export interface Distribution {
15421549
receiver: Scalars["String"]["output"];
15431550
tokens: Array<Scalars["String"]["output"]>;
15441551
transaction: Transaction;
1545-
typeId: Scalars["Int"]["output"];
1552+
typeId: Scalars["BigInt"]["output"];
15461553
}
15471554

15481555
export interface DistributionEdge {
@@ -1665,15 +1672,15 @@ export interface DistributionWhereInput {
16651672
tokens_isNull?: InputMaybe<Scalars["Boolean"]["input"]>;
16661673
transaction?: InputMaybe<TransactionWhereInput>;
16671674
transaction_isNull?: InputMaybe<Scalars["Boolean"]["input"]>;
1668-
typeId_eq?: InputMaybe<Scalars["Int"]["input"]>;
1669-
typeId_gt?: InputMaybe<Scalars["Int"]["input"]>;
1670-
typeId_gte?: InputMaybe<Scalars["Int"]["input"]>;
1671-
typeId_in?: InputMaybe<Array<Scalars["Int"]["input"]>>;
1675+
typeId_eq?: InputMaybe<Scalars["BigInt"]["input"]>;
1676+
typeId_gt?: InputMaybe<Scalars["BigInt"]["input"]>;
1677+
typeId_gte?: InputMaybe<Scalars["BigInt"]["input"]>;
1678+
typeId_in?: InputMaybe<Array<Scalars["BigInt"]["input"]>>;
16721679
typeId_isNull?: InputMaybe<Scalars["Boolean"]["input"]>;
1673-
typeId_lt?: InputMaybe<Scalars["Int"]["input"]>;
1674-
typeId_lte?: InputMaybe<Scalars["Int"]["input"]>;
1675-
typeId_not_eq?: InputMaybe<Scalars["Int"]["input"]>;
1676-
typeId_not_in?: InputMaybe<Array<Scalars["Int"]["input"]>>;
1680+
typeId_lt?: InputMaybe<Scalars["BigInt"]["input"]>;
1681+
typeId_lte?: InputMaybe<Scalars["BigInt"]["input"]>;
1682+
typeId_not_eq?: InputMaybe<Scalars["BigInt"]["input"]>;
1683+
typeId_not_in?: InputMaybe<Array<Scalars["BigInt"]["input"]>>;
16771684
}
16781685

16791686
export interface DistributionsConnection {
@@ -4301,6 +4308,24 @@ export interface PageInfo {
43014308
startCursor: Scalars["String"]["output"];
43024309
}
43034310

4311+
export interface PerformanceSnapshotObject {
4312+
__typename?: "PerformanceSnapshotObject";
4313+
performance: Scalars["String"]["output"];
4314+
snapshotTimestamp: Scalars["String"]["output"];
4315+
}
4316+
4317+
export interface PerformanceSnapshots {
4318+
__typename?: "PerformanceSnapshots";
4319+
address: Scalars["String"]["output"];
4320+
entity: Scalars["String"]["output"];
4321+
snapshots: Array<PerformanceSnapshotObject>;
4322+
}
4323+
4324+
export interface PerformanceWhereInput {
4325+
addresses?: InputMaybe<Array<Scalars["String"]["input"]>>;
4326+
period: Scalars["String"]["input"];
4327+
}
4328+
43044329
export interface PeriodAccountStatObject {
43054330
__typename?: "PeriodAccountStatObject";
43064331
closedCount: Scalars["Float"]["output"];
@@ -6000,6 +6025,7 @@ export interface Query {
60006025
accountStatById?: Maybe<AccountStat>;
60016026
accountStats: Array<AccountStat>;
60026027
accountStatsConnection: AccountStatsConnection;
6028+
annualizedPerformance: Array<AnnualizedPerformanceObject>;
60036029
aprSnapshotById?: Maybe<AprSnapshot>;
60046030
aprSnapshots: Array<AprSnapshot>;
60056031
aprSnapshotsConnection: AprSnapshotsConnection;
@@ -6046,6 +6072,7 @@ export interface Query {
60466072
orderById?: Maybe<Order>;
60476073
orders: Array<Order>;
60486074
ordersConnection: OrdersConnection;
6075+
performanceSnapshots: Array<PerformanceSnapshots>;
60496076
periodAccountStats: Array<PeriodAccountStatObject>;
60506077
pnlAprSnapshotById?: Maybe<PnlAprSnapshot>;
60516078
pnlAprSnapshots: Array<PnlAprSnapshot>;
@@ -6108,6 +6135,10 @@ export interface QueryaccountStatsConnectionArgs {
61086135
where?: InputMaybe<AccountStatWhereInput>;
61096136
}
61106137

6138+
export interface QueryannualizedPerformanceArgs {
6139+
where?: InputMaybe<PerformanceWhereInput>;
6140+
}
6141+
61116142
export interface QueryaprSnapshotByIdArgs {
61126143
id: Scalars["String"]["input"];
61136144
}
@@ -6376,6 +6407,10 @@ export interface QueryordersConnectionArgs {
63766407
where?: InputMaybe<OrderWhereInput>;
63776408
}
63786409

6410+
export interface QueryperformanceSnapshotsArgs {
6411+
where?: InputMaybe<PerformanceWhereInput>;
6412+
}
6413+
63796414
export interface QueryperiodAccountStatsArgs {
63806415
limit?: InputMaybe<Scalars["Float"]["input"]>;
63816416
offset?: InputMaybe<Scalars["Float"]["input"]>;

src/components/OneClickPromoBanner/OneClickPromoBanner.tsx

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { getOneClickTradingPromoHiddenKey } from "config/localStorage";
77
import { useSettings } from "context/SettingsContext/SettingsContextProvider";
88
import { useIsOutOfGasPaymentBalance } from "domain/synthetics/express/useIsOutOfGasPaymentBalance";
99
import { useChainId } from "lib/chains";
10+
import { useIsGeminiWallet } from "lib/wallets/useIsGeminiWallet";
1011

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

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

24+
const isGeminiWallet = useIsGeminiWallet();
2325
const isOutOfGasPaymentBalance = useIsOutOfGasPaymentBalance();
2426

25-
const shouldShow = getIsFlagEnabled("testOneClickPromo") && !isOneClickPromoHidden && !expressOrdersEnabled;
27+
const shouldShow =
28+
getIsFlagEnabled("testOneClickPromo") && !isOneClickPromoHidden && !expressOrdersEnabled && !isGeminiWallet;
2629

2730
const onClickEnable = useCallback(() => {
2831
openSettings();
29-
if (!isOutOfGasPaymentBalance) {
30-
setTimeout(() => {
31-
setExpressOrdersEnabled(true);
32-
setIsOneClickPromoHidden(true);
33-
}, 500);
32+
33+
if (isOutOfGasPaymentBalance || isGeminiWallet) {
34+
return;
3435
}
35-
}, [isOutOfGasPaymentBalance, openSettings, setExpressOrdersEnabled, setIsOneClickPromoHidden]);
36+
37+
setTimeout(() => {
38+
setExpressOrdersEnabled(true);
39+
setIsOneClickPromoHidden(true);
40+
}, 500);
41+
}, [isGeminiWallet, isOutOfGasPaymentBalance, openSettings, setExpressOrdersEnabled, setIsOneClickPromoHidden]);
3642

3743
if (!shouldShow) {
3844
return null;

src/components/SettingsModal/SettingsModal.tsx

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,11 @@ import { helperToast } from "lib/helperToast";
1616
import { roundToTwoDecimals } from "lib/numbers";
1717
import { EMPTY_ARRAY } from "lib/objects";
1818
import { mustNeverExist } from "lib/types";
19+
import { useIsGeminiWallet } from "lib/wallets/useIsGeminiWallet";
1920
import { MAX_TWAP_NUMBER_OF_PARTS, MIN_TWAP_NUMBER_OF_PARTS } from "sdk/configs/twap";
2021

2122
import { AbFlagSettings } from "components/AbFlagsSettings/AbFlagsSettings";
23+
import { ColorfulBanner } from "components/ColorfulBanner/ColorfulBanner";
2224
import { DebugSwapsSettings } from "components/DebugSwapsSettings/DebugSwapsSettings";
2325
import { ExpressTradingOutOfGasBanner } from "components/ExpressTradingOutOfGasBanner.ts/ExpressTradingOutOfGasBanner";
2426
import ExternalLink from "components/ExternalLink/ExternalLink";
@@ -55,7 +57,7 @@ export function SettingsModal({
5557
const subaccountState = useSubaccountContext();
5658

5759
const [tradingMode, setTradingMode] = useState<TradingMode | undefined>(undefined);
58-
const [isTradningModeChanging, setIsTradningModeChanging] = useState(false);
60+
const [isTradingModeChanging, setIsTradingModeChanging] = useState(false);
5961

6062
const [numberOfParts, setNumberOfParts] = useState<number>();
6163
const isOutOfGasPaymentBalance = useIsOutOfGasPaymentBalance();
@@ -143,10 +145,12 @@ export function SettingsModal({
143145
setIsSettingsVisible(false);
144146
}, [setIsSettingsVisible]);
145147

148+
const isGeminiWallet = useIsGeminiWallet();
149+
146150
const handleTradingModeChange = useCallback(
147151
async (mode: TradingMode) => {
148152
const prevMode = tradingMode;
149-
setIsTradningModeChanging(true);
153+
setIsTradingModeChanging(true);
150154
setTradingMode(mode);
151155

152156
switch (mode) {
@@ -156,13 +160,13 @@ export function SettingsModal({
156160

157161
if (!isSubaccountDeactivated) {
158162
setTradingMode(prevMode);
159-
setIsTradningModeChanging(false);
163+
setIsTradingModeChanging(false);
160164
return;
161165
}
162166
}
163167

164168
settings.setExpressOrdersEnabled(false);
165-
setIsTradningModeChanging(false);
169+
setIsTradingModeChanging(false);
166170
break;
167171
}
168172
case TradingMode.Express: {
@@ -171,26 +175,26 @@ export function SettingsModal({
171175

172176
if (!isSubaccountDeactivated) {
173177
setTradingMode(prevMode);
174-
setIsTradningModeChanging(false);
178+
setIsTradingModeChanging(false);
175179
return;
176180
}
177181
}
178182

179183
settings.setExpressOrdersEnabled(true);
180-
setIsTradningModeChanging(false);
184+
setIsTradingModeChanging(false);
181185
break;
182186
}
183187
case TradingMode.Express1CT: {
184188
const isSubaccountActivated = await subaccountState.tryEnableSubaccount();
185189

186190
if (!isSubaccountActivated) {
187191
setTradingMode(prevMode);
188-
setIsTradningModeChanging(false);
192+
setIsTradingModeChanging(false);
189193
return;
190194
}
191195

192196
settings.setExpressOrdersEnabled(true);
193-
setIsTradningModeChanging(false);
197+
setIsTradingModeChanging(false);
194198
break;
195199
}
196200
default: {
@@ -204,7 +208,7 @@ export function SettingsModal({
204208

205209
useEffect(
206210
function defineTradingMode() {
207-
if (isTradningModeChanging) {
211+
if (isTradingModeChanging) {
208212
return;
209213
}
210214

@@ -222,9 +226,11 @@ export function SettingsModal({
222226
setTradingMode(nextTradingMode);
223227
}
224228
},
225-
[isTradningModeChanging, settings.expressOrdersEnabled, subaccountState.subaccount, tradingMode]
229+
[isTradingModeChanging, settings.expressOrdersEnabled, subaccountState.subaccount, tradingMode]
226230
);
227231

232+
const isExpressTradingDisabled = isOutOfGasPaymentBalance || isGeminiWallet;
233+
228234
return (
229235
<SlideModal
230236
isVisible={isSettingsVisible}
@@ -270,7 +276,7 @@ export function SettingsModal({
270276
</Trans>
271277
}
272278
icon={<ExpressIcon />}
273-
disabled={isOutOfGasPaymentBalance}
279+
disabled={isExpressTradingDisabled}
274280
chip={
275281
<Chip color="gray">
276282
<Trans>Optimal</Trans>
@@ -284,7 +290,7 @@ export function SettingsModal({
284290
title="Express + One-Click"
285291
description="CEX-like experience with Express reliability"
286292
icon={<OneClickIcon />}
287-
disabled={isOutOfGasPaymentBalance}
293+
disabled={isExpressTradingDisabled}
288294
info={
289295
<Trans>
290296
Your wallet, your keys. GMX executes transactions for you without individual signing, providing a
@@ -303,6 +309,14 @@ export function SettingsModal({
303309

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

312+
{isGeminiWallet && (
313+
<ColorfulBanner color="slate" icon={<ExpressIcon className="-mt-6" />}>
314+
<div className="text-body-small mr-8 pl-8">
315+
<Trans>Gemini Wallet is not supported for Express or One-Click trading.</Trans>
316+
</div>
317+
</ColorfulBanner>
318+
)}
319+
306320
<OldSubaccountWithdraw />
307321

308322
{Boolean(subaccountState.subaccount && getIsSubaccountActive(subaccountState.subaccount)) && (

src/lib/wallets/rainbowKitConfig.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { geminiRainbowKitConnector } from "@gemini-wallet/rainbow";
12
import { getDefaultConfig, WalletList } from "@rainbow-me/rainbowkit";
23
import {
34
coinbaseWallet,
@@ -34,6 +35,7 @@ const popularWalletList: WalletList = [
3435
injectedWallet,
3536
// The Safe option will only appear in the Safe Wallet browser environment.
3637
safeWallet,
38+
geminiRainbowKitConnector,
3739
],
3840
},
3941
];

src/lib/wallets/useIsGeminiWallet.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { useAccount } from "wagmi";
2+
3+
const GEMINI_WALLET_ID = "gemini";
4+
5+
export function useIsGeminiWallet() {
6+
const { connector } = useAccount();
7+
8+
return connector?.id === GEMINI_WALLET_ID;
9+
}

src/locales/de/messages.po

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -486,10 +486,6 @@ msgstr "Swappe {0} gegen {1} auf 1inch"
486486
msgid "No pools matched."
487487
msgstr ""
488488

489-
#: src/components/Synthetics/TradeBox/hooks/useTradeButtonState.tsx
490-
#~ msgid "No swap path available. <0>Swap {0} to {swapToTokenSymbol}</0>, then to {1}"
491-
#~ msgstr ""
492-
493489
#: src/components/Exchange/PositionsList.jsx
494490
#: src/components/Synthetics/PositionItem/PositionItem.tsx
495491
#: src/pages/AccountDashboard/HistoricalLists.tsx
@@ -8516,6 +8512,10 @@ msgstr "Preis ist über Mark Preis"
85168512
msgid "This position could be liquidated, excluding any price movement, due to funding and borrowing fee rates reducing the position's collateral over time."
85178513
msgstr ""
85188514

8515+
#: src/components/SettingsModal/SettingsModal.tsx
8516+
msgid "Gemini Wallet is not supported for Express or One-Click trading."
8517+
msgstr ""
8518+
85198519
#: src/components/SettingsModal/SettingsModal.tsx
85208520
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."
85218521
msgstr ""

src/locales/en/messages.po

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -486,10 +486,6 @@ msgstr "Swap {0} to {1} on 1inch"
486486
msgid "No pools matched."
487487
msgstr "No pools matched."
488488

489-
#: src/components/Synthetics/TradeBox/hooks/useTradeButtonState.tsx
490-
#~ msgid "No swap path available. <0>Swap {0} to {swapToTokenSymbol}</0>, then to {1}"
491-
#~ msgstr "No swap path available. <0>Swap {0} to {swapToTokenSymbol}</0>, then to {1}"
492-
493489
#: src/components/Exchange/PositionsList.jsx
494490
#: src/components/Synthetics/PositionItem/PositionItem.tsx
495491
#: src/pages/AccountDashboard/HistoricalLists.tsx
@@ -8522,6 +8518,10 @@ msgstr "Price is above Mark Price"
85228518
msgid "This position could be liquidated, excluding any price movement, due to funding and borrowing fee rates reducing the position's collateral over time."
85238519
msgstr "This position could be liquidated, excluding any price movement, due to funding and borrowing fee rates reducing the position's collateral over time."
85248520

8521+
#: src/components/SettingsModal/SettingsModal.tsx
8522+
msgid "Gemini Wallet is not supported for Express or One-Click trading."
8523+
msgstr "Gemini Wallet is not supported for Express or One-Click trading."
8524+
85258525
#: src/components/SettingsModal/SettingsModal.tsx
85268526
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."
85278527
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."

src/locales/es/messages.po

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -486,10 +486,6 @@ msgstr "Intercambiar {0} a {1} en 1inch"
486486
msgid "No pools matched."
487487
msgstr ""
488488

489-
#: src/components/Synthetics/TradeBox/hooks/useTradeButtonState.tsx
490-
#~ msgid "No swap path available. <0>Swap {0} to {swapToTokenSymbol}</0>, then to {1}"
491-
#~ msgstr ""
492-
493489
#: src/components/Exchange/PositionsList.jsx
494490
#: src/components/Synthetics/PositionItem/PositionItem.tsx
495491
#: src/pages/AccountDashboard/HistoricalLists.tsx
@@ -8516,6 +8512,10 @@ msgstr "El precio se encuentra por encima del precio de referencia"
85168512
msgid "This position could be liquidated, excluding any price movement, due to funding and borrowing fee rates reducing the position's collateral over time."
85178513
msgstr ""
85188514

8515+
#: src/components/SettingsModal/SettingsModal.tsx
8516+
msgid "Gemini Wallet is not supported for Express or One-Click trading."
8517+
msgstr ""
8518+
85198519
#: src/components/SettingsModal/SettingsModal.tsx
85208520
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."
85218521
msgstr ""

0 commit comments

Comments
 (0)