From 072bd191760854705bb463e3ad40e3b221fe2cf6 Mon Sep 17 00:00:00 2001 From: Alex <71931113+af-afk@users.noreply.github.com> Date: Fri, 19 Apr 2024 19:19:24 +0930 Subject: [PATCH] Lint (#2627) Co-authored-by: user --- .../components/FLYClaimSubmitModal/index.tsx | 638 +++-- .../components/FLYStakingStatsModal/index.tsx | 1061 +++++--- .../app/components/Fluidify/FluidifyForm.tsx | 8 +- .../app/components/MobileModal.tsx | 11 +- .../app/queries/addReferral.ts | 6 +- .../app/queries/addReferralCode.ts | 12 +- .../app/queries/requestProof.ts | 5 +- .../app/queries/useReferralCode.ts | 8 +- .../app/queries/useReferralCount.ts | 52 +- .../app/queries/useReferrals.ts | 29 +- web/app.fluidity.money/app/root.tsx | 6 +- .../app/routes/$network/dashboard.tsx | 43 +- .../$network/dashboard/airdrop/common.tsx | 276 +- .../$network/dashboard/airdrop/index.tsx | 187 +- .../$network/query/dashboard/airdrop.tsx | 3 +- .../query/dashboard/airdropLeaderboard.tsx | 8 +- .../routes/$network/query/referralBottles.tsx | 6 +- .../routes/$network/query/referralCode.tsx | 12 +- .../app/routes/$network/query/referrals.tsx | 18 +- .../app/styles/dashboard.css | 30 +- .../app/styles/dashboard/airdrop.css | 100 +- .../app/styles/dashboard/airdrop.scss | 156 +- .../app/styles/transfer.css | 15 +- .../util/chainUtils/ethereum/FLYStaking.json | 438 +-- .../MerkleDistributorWithDeadline.json | 554 ++-- .../app/util/chainUtils/ethereum/Staking.json | 1106 ++++---- .../app/util/chainUtils/ethereum/Token.json | 2394 ++++++++--------- .../util/chainUtils/ethereum/transaction.ts | 94 +- .../app/util/chainUtils/tokens.ts | 11 +- .../contexts/EthereumProvider.tsx | 42 +- .../contexts/FluidityFacade.tsx | 14 +- web/app.fluidity.money/server.ts | 39 +- 32 files changed, 4018 insertions(+), 3364 deletions(-) diff --git a/web/app.fluidity.money/app/components/FLYClaimSubmitModal/index.tsx b/web/app.fluidity.money/app/components/FLYClaimSubmitModal/index.tsx index 38b418bc2..abaa867b3 100644 --- a/web/app.fluidity.money/app/components/FLYClaimSubmitModal/index.tsx +++ b/web/app.fluidity.money/app/components/FLYClaimSubmitModal/index.tsx @@ -1,4 +1,3 @@ - import { useContext, useState, useEffect, useCallback } from "react"; import BN from "bn.js"; @@ -7,22 +6,32 @@ import FluidityFacadeContext from "contexts/FluidityFacade"; import { FlyStakingContext } from "contexts/FlyStakingProvider"; import { requestProof } from "~/queries/requestProof"; -import { Heading, GeneralButton, Text, trimAddress, LinkButton, Modal, WarningIcon } from "@fluidity-money/surfing"; +import { + Heading, + GeneralButton, + Text, + trimAddress, + LinkButton, + Modal, + WarningIcon, +} from "@fluidity-money/surfing"; import styles from "~/styles/dashboard/airdrop.css"; import { createPortal } from "react-dom"; -export const FLYClaimSubmitModalLinks = () => [{ rel: "stylesheet", href: styles }]; +export const FLYClaimSubmitModalLinks = () => [ + { rel: "stylesheet", href: styles }, +]; type IFLYClaimSubmitModal = { visible: boolean; flyAmount: number; accumulatedPoints: number; - mode: 'stake' | 'claim'; + mode: "stake" | "claim"; close: () => void; showConnectWalletModal: () => void; onStakingComplete: (amountStaked: BN) => void; - onClaimComplete: (amountClaimed: BN) => void + onClaimComplete: (amountClaimed: BN) => void; }; enum State { @@ -31,7 +40,7 @@ enum State { HasSigned, HasClaimed, HasStaked, - InError + InError, } const BlobData = `By completing the transaction of this Airdrop you acknowledge that @@ -63,9 +72,8 @@ const FLYClaimSubmitModal = ({ showConnectWalletModal, close, accumulatedPoints, - mode + mode, }: IFLYClaimSubmitModal) => { - const { address, signBuffer, @@ -91,45 +99,47 @@ const FLYClaimSubmitModal = ({ const flyAmountFirstTranche = flyAmount / 4; - const [currentMode, setCurrentMode] = useState(mode) - const [finalState, setFinalState] = useState(currentMode === 'claim' ? State.HasClaimed : State.HasStaked) + const [currentMode, setCurrentMode] = useState(mode); + const [finalState, setFinalState] = useState( + currentMode === "claim" ? State.HasClaimed : State.HasStaked + ); useEffect(() => { - setFinalState(currentMode === 'claim' ? State.HasClaimed : State.HasStaked) - }, [finalState]) + setFinalState(currentMode === "claim" ? State.HasClaimed : State.HasStaked); + }, [finalState]); const [modal, setModal] = useState(null); const [currentStatus, setCurrentStatus] = useState(State.Disconnected); - const [showTermsModal, setShowTermsModal] = useState(false) - const [confirmingClaim, setConfirmingClaim] = useState(mode === 'claim') + const [showTermsModal, setShowTermsModal] = useState(false); + const [confirmingClaim, setConfirmingClaim] = useState(mode === "claim"); useEffect(() => { - if (address && (currentStatus === State.Disconnected)) + if (address && currentStatus === State.Disconnected) setCurrentStatus(State.IsConnected); }, [address]); - const [currentAction, setCurrentAction] = useState("Connect") + const [currentAction, setCurrentAction] = useState("Connect"); useEffect(() => { switch (currentStatus) { case State.Disconnected: - setCurrentAction("Connect") + setCurrentAction("Connect"); break; case State.IsConnected: - setCurrentAction("Sign") + setCurrentAction("Sign"); break; case State.HasSigned: - setCurrentAction(currentMode === "claim" ? "Claim" : "Stake") + setCurrentAction(currentMode === "claim" ? "Claim" : "Stake"); break; case State.HasClaimed: - setCurrentAction(currentMode === "claim" ? "Claimed!" : "Stake") + setCurrentAction(currentMode === "claim" ? "Claimed!" : "Stake"); break; case State.HasStaked: - setCurrentAction("Staked!") + setCurrentAction("Staked!"); break; } - }, [currentStatus]) + }, [currentStatus]); // needed for the signature effect hook const [signature, setSignature] = useState(""); @@ -141,7 +151,11 @@ const FLYClaimSubmitModal = ({ // needed to request the claim onchain, the amount to request const [errorMessage, setErrorMessage] = useState(""); - const triggerMerkleClaim = async (index: number, amount_: string, proofs: string[]) => { + const triggerMerkleClaim = async ( + index: number, + amount_: string, + proofs: string[] + ) => { if (!address) throw new Error("no address"); const amount = new BN(amount_.replace(/^0x/, ""), 16); switch (currentMode) { @@ -171,10 +185,8 @@ const FLYClaimSubmitModal = ({ }; useEffect(() => { - if (!signBuffer) - throw new Error("couldn't sign"); - if (!requestSignature) - return; + if (!signBuffer) throw new Error("couldn't sign"); + if (!requestSignature) return; (async () => { const sig = await signBuffer(BlobData); if (!sig) throw new Error("couldn't bubble up sig"); @@ -189,20 +201,22 @@ const FLYClaimSubmitModal = ({ if (!merkleDistributorWithDeadlineIsClaimed) return; (async () => { try { - const { - index, - amount, - proofs, - error - } = await requestProof(address, signature); + const { index, amount, proofs, error } = await requestProof( + address, + signature + ); // get the amount into a big number, but slice off the 0x at the start const amountBn = new BN(amount.slice(2), 16); - const alreadyClaimed = await merkleDistributorWithDeadlineIsClaimed(index); + const alreadyClaimed = await merkleDistributorWithDeadlineIsClaimed( + index + ); if (alreadyClaimed) { - setCurrentStatus(currentMode === "stake" ? State.HasStaked : State.HasClaimed); + setCurrentStatus( + currentMode === "stake" ? State.HasStaked : State.HasClaimed + ); onClaimComplete(amountBn); shouldUpdateBalance?.(); return; @@ -251,7 +265,7 @@ const FLYClaimSubmitModal = ({ switch (currentStatus) { case State.Disconnected: // prompt wallet connection - showConnectWalletModal() + showConnectWalletModal(); break; case State.IsConnected: // time to sign! @@ -286,162 +300,246 @@ const FLYClaimSubmitModal = ({ createPortal( <>
-
-
-
-
- {currentMode === 'claim' ? "Claiming" : "Staking"} $FLY Tokens - - - +
+
+
+
+ + {currentMode === "claim" ? "Claiming" : "Staking"} $FLY + Tokens + + + + +
+ {confirmingClaim ? ( +
+
+ + + Caution. Claiming $FLY will cease your points. + +
+
+ + You have accumulated {accumulatedPoints} points. In + order to retain your accumulated points, you must + initially stake your $FLY. Otherwise, you may claim your + $FLY and stake it at a later stage without the + accumulated points. + +
+ + Do you wish to continue claiming? +
- {confirmingClaim ? -
-
- - Caution. Claiming $FLY will cease your points. -
-
- You have accumulated {accumulatedPoints} points. In order to retain your accumulated points, you must initially stake your $FLY. Otherwise, you may claim your $FLY and stake it at a later stage without the accumulated points. + ) : ( +
+
+ {currentStatus === State.Disconnected ? ( + + ) : ( + + )} +
+ + Connect your Arbitrum wallet + + {State.IsConnected && address && ( + + Connected {trimAddress(address)} + + )}
- Do you wish to continue claiming? -
: -
-
- {currentStatus === State.Disconnected - ? : } -
- Connect your Arbitrum wallet - {State.IsConnected && address && Connected {trimAddress(address)}} -
+
+
+ {currentStatus === State.Disconnected ? ( + + ) : currentStatus === State.IsConnected ? ( + + ) : ( + + )} +
+ + Sign Terms and Conditions + + + Read{" "} + setShowTermsModal(true)} + > + Terms and Conditions + +
+
+ {currentMode === "claim" && (
- {currentStatus === State.Disconnected ? - : - currentStatus === State.IsConnected ? - : - - } + {currentStatus < State.HasStaked ? ( + + ) : currentStatus === State.HasStaked ? ( + + ) : ( + + )}
- Sign Terms and Conditions - Read{" "} - setShowTermsModal(true)} - > - Terms and Conditions - + + Claim $FLY {flyAmountFirstTranche} -
-
- {currentMode === "claim" &&
- {currentStatus < State.HasStaked ? - : - currentStatus === State.HasStaked ? - : - - } -
- Claim $FLY {flyAmountFirstTranche} - {currentStatus >= State.HasClaimed && + {currentStatus >= State.HasClaimed && ( { addToken?.("FLY") }} + handleClick={() => { + addToken?.("FLY"); + }} > Add $FLY to My Wallet - } + )}
-
} - {currentMode === 'stake' &&
- {currentStatus < State.HasClaimed ? - : - currentStatus === State.HasClaimed ? - : - - } +
+ )} + {currentMode === "stake" && ( +
+ {currentStatus < State.HasClaimed ? ( + + ) : currentStatus === State.HasClaimed ? ( + + ) : ( + + )}
- Stake $FLY - Earn rewards & [REDACTED] on SPN + + Stake $FLY + + + Earn rewards & [REDACTED] on SPN +
- } -
+ )} +
+ )} + - { errorMessage } - -
- {confirmingClaim ? -
- setConfirmingClaim(false)} - className="fly-claim-stake-choice-button" - - > - - Continue Claiming - - - { - setConfirmingClaim(false); - setCurrentMode('stake') - }} - className="fly-claim-stake-choice-button" - + > + {errorMessage} + +
+ {confirmingClaim ? ( +
+ setConfirmingClaim(false)} + className="fly-claim-stake-choice-button" + > + - - Stake Your $FLY - - -
- : - <> - + + { + setConfirmingClaim(false); + setCurrentMode("stake"); + }} + className="fly-claim-stake-choice-button" + > + - - {currentAction} - {currentStatus === finalState && } - - - - } - - By signing the following transactions, you agree to Fluidity Money'services{" "} - + +
+ ) : ( + <> + - Terms of Service - {" "} - and acknowledge that you have read and understand the{" "} - Disclaimer - - setShowTermsModal(false)} /> -
+ + {currentAction} + {currentStatus === finalState && ( + + )} + + + + )} + + By signing the following transactions, you agree to Fluidity + Money'services{" "} + + Terms of Service + {" "} + and acknowledge that you have read and understand the{" "} + Disclaimer + + setShowTermsModal(false)} + />
+
, document.body @@ -453,102 +551,128 @@ const FLYClaimSubmitModal = ({ }; export const Checked = ({ size = 36 }: { size?: number }) => { - return copy -} + return ( + copy + ); +}; export const BaseCircle = () => { - return
- - - -
- -} + return ( +
+ + + +
+ ); +}; export const NextCircle = () => { - return
- - - -
- -} + return ( +
+ + + +
+ ); +}; type TermsModalProps = { - visible: boolean - close: () => void -} + visible: boolean; + close: () => void; +}; export const TermsModal = ({ visible, close }: TermsModalProps) => { - - return -
-
-
- - Close - + return ( + +
+
+
+ + Close + +
+

+ 1. Description We may offer you the opportunity to receive some + digital assets at no cost (**Airdrop**), subject to the terms + described in this section. The Airdrop is delivered by us to you, + but may be manufactured, offered and supported by the network + creator or developer, if any, and not by us. +

+

+ 1. Terms of Airdrop Program 2.1 No Purchase Necessary There is no + purchase necessary to receive the Airdrop. However, you must have + wallets recognised and accepted by us. Although we do not charge a + fee for participation in the Airdrop Program, we reserve the right + to do so in the future and shall provide prior notice to you in such + case. +

+

+ 2.2 Timing Each Airdrop may be subject to any additional terms and + conditions and where applicable such terms and conditions shall be + displayed and marked with an asterisk (*) or other similar notation. +

+

+ 2.3 Limited Supply An offer to receive the digital assets in an + Airdrop is only available to you while supplies last. Once the + amount of digital asset offered by us in an Airdrop is exhausted, + any party who has either been placed on a waitlist, or has completed + certain additional steps, but not yet received notice of award of + the asset in such Airdrop, shall no longer be eligible to receive + the said digital assets in that Airdrop. We reserve the right, in + our sole discretion, to modify or suspend any Airdrop requirements + at any time without notice, including the amount previously + advertised as available. +

+

+ 2.4 Eligibility You may not be eligible to receive the digital + assets or a select class and type of digital assets from an Airdrop + in your jurisdiction. To the best of our understanding, below is a + list of countries that does not recognise digital assets; + *Afghanistan, Algeria, Egypt, Bangladesh, Bolivia, Burundi, + Cameroon, Chad, China, Republic of Congo, Ethiopia, Gabon, Iraq, + Lesotho, Libya, Macedonia, Morocco, Myanmar, Nepal, Qatar, Sierra + Leone, Tunisia ** Kindly be advised that this list is for reference + only and you are advised to seek independent legal advise as to your + eligibility to receive the assets through Airdrop. **source - + Library of Congress, Atlantic Council, Techopedia, Finder, Triple-A, + Chainalysis* +

+

+ 2.5 Notice of Award In the event you are selected to receive the + digital asset in an Airdrop, we shall notify you of the pending + delivery of such asset. Eligibility may be limited as to time. We + are not liable to you for failure to receive any notice associated + with the Airdrop Program. +

+

+ 3 Risk Disclosures Relating to Airdrop Program You are solely + responsible for researching and understanding the Fluid Assets token + and it’s related utility and/or network subject to the Airdrop. +

-

- 1. Description - - We may offer you the opportunity to receive some digital assets at no cost (**Airdrop**), subject to the terms described in this section. The Airdrop is delivered by us to you, but may be manufactured, offered and supported by the network creator or developer, if any, and not by us. -

-

- 1. Terms of Airdrop Program - - 2.1 No Purchase Necessary - - There is no purchase necessary to receive the Airdrop. However, you must have - wallets recognised and accepted by us. Although we do not charge a fee for participation in the Airdrop Program, we reserve the right to do so in the future and shall provide prior notice to you in such case. -

-

- 2.2 Timing - - Each Airdrop may be subject to any additional terms and conditions and where applicable such terms and conditions shall be displayed and marked with an asterisk (*) or other similar notation. -

-

- 2.3 Limited Supply - - An offer to receive the digital assets in an Airdrop is only available to you while supplies last. Once the amount of digital asset offered by us in an Airdrop is exhausted, any party who - has either been placed on a waitlist, or has completed certain additional steps, but not yet received notice of award of the asset in such Airdrop, shall no longer be eligible to receive the said digital assets in that Airdrop. We reserve the right, in our sole discretion, to modify or - suspend any Airdrop requirements at any time without notice, including the amount previously - advertised as available. -

-

- 2.4 Eligibility - - You may not be eligible to receive the digital assets or a select class and type of digital assets from an Airdrop in your jurisdiction. - - To the best of our understanding, below is a list of countries that does not recognise digital assets; - - *Afghanistan, Algeria, Egypt, Bangladesh, Bolivia, Burundi, Cameroon, Chad, China, Republic of Congo, Ethiopia, Gabon, Iraq, Lesotho, Libya, Macedonia, Morocco, Myanmar, Nepal, Qatar, Sierra Leone, Tunisia ** - - Kindly be advised that this list is for reference only and you are advised to seek independent legal advise as to your eligibility to receive the assets through Airdrop. - - **source - Library of Congress, Atlantic Council, Techopedia, Finder, Triple-A, Chainalysis* -

-

- - 2.5 Notice of Award - - In the event you are selected to receive the digital asset in an Airdrop, we shall notify you of the pending delivery of such asset. Eligibility may be limited as to time. - We are not liable to you for failure to receive any notice associated with the Airdrop Program. -

-

- - 3 Risk Disclosures Relating to Airdrop Program - - You are solely responsible for researching and understanding the Fluid Assets token and it’s related utility and/or network subject to the Airdrop. -

-
- -} + + ); +}; export default FLYClaimSubmitModal; diff --git a/web/app.fluidity.money/app/components/FLYStakingStatsModal/index.tsx b/web/app.fluidity.money/app/components/FLYStakingStatsModal/index.tsx index 1655008d0..426f4bd39 100644 --- a/web/app.fluidity.money/app/components/FLYStakingStatsModal/index.tsx +++ b/web/app.fluidity.money/app/components/FLYStakingStatsModal/index.tsx @@ -1,4 +1,17 @@ -import { Card, FlyIcon, GeneralButton, Heading, Hoverable, InfoCircle, LinkButton, StakeIcon, Text, trimAddress, UnstakeIcon, WarningIcon } from "@fluidity-money/surfing"; +import { + Card, + FlyIcon, + GeneralButton, + Heading, + Hoverable, + InfoCircle, + LinkButton, + StakeIcon, + Text, + trimAddress, + UnstakeIcon, + WarningIcon, +} from "@fluidity-money/surfing"; import { BigNumber } from "ethers"; import BN from "bn.js"; import { FlyToken } from "contexts/EthereumProvider"; @@ -6,13 +19,20 @@ import FluidityFacadeContext from "contexts/FluidityFacade"; import { ReactNode, useCallback, useContext, useEffect, useState } from "react"; import { createPortal } from "react-dom"; import styles from "~/styles/dashboard/airdrop.css"; -import { BaseCircle, Checked, NextCircle, TermsModal } from "../FLYClaimSubmitModal"; +import { + BaseCircle, + Checked, + NextCircle, + TermsModal, +} from "../FLYClaimSubmitModal"; import { addDecimalToBn, snapToValidValue } from "~/util/chainUtils/tokens"; -export const FlyStakingStatsModalLinks = () => [{ rel: "stylesheet", href: styles }]; +export const FlyStakingStatsModalLinks = () => [ + { rel: "stylesheet", href: styles }, +]; interface FlyStakingStatsModalProps { - visible: boolean + visible: boolean; showConnectWalletModal: () => void; close: () => void; // true for staking, false for unstaking @@ -32,25 +52,30 @@ enum State { // Finished HasStaked, // Error occured - InError + InError, } const getValueFromFlyAmount = (amount: BN) => { const x = amount.toString(); switch (true) { - case (x.length > 6): - return (() => { - const leftSide = x.slice(0, x.length - 6); - const rightSide = x.slice(x.length - 6).slice(0, 3); - return `${leftSide}.${rightSide}`; - })(); - case (x.length <= 6): - return `0.${x}`; + case x.length > 6: + return (() => { + const leftSide = x.slice(0, x.length - 6); + const rightSide = x.slice(x.length - 6).slice(0, 3); + return `${leftSide}.${rightSide}`; + })(); + case x.length <= 6: + return `0.${x}`; } }; -const FlyStakingStatsModal = ({ visible, close, showConnectWalletModal, shouldUpdateFlyBalance, staking = true }: FlyStakingStatsModalProps) => { - +const FlyStakingStatsModal = ({ + visible, + close, + showConnectWalletModal, + shouldUpdateFlyBalance, + staking = true, +}: FlyStakingStatsModalProps) => { const [modal, setModal] = useState(null); const { @@ -63,7 +88,7 @@ const FlyStakingStatsModal = ({ visible, close, showConnectWalletModal, shouldUp flyStakingAmountUnstaking, flyStakingFinaliseUnstake, flyStakingSecondsUntilSoonestUnstake, - } = useContext(FluidityFacadeContext) + } = useContext(FluidityFacadeContext); const [flyBalance, setFlyBalance] = useState(new BN(0)); @@ -139,50 +164,48 @@ const FlyStakingStatsModal = ({ visible, close, showConnectWalletModal, shouldUp }, [address, flyStakingAmountUnstaking]); const [flyUnstakable, setFlyUnstakable] = useState(new BN(0)); - const [flyUnstaked, setFlyUnstaked] = useState(false) + const [flyUnstaked, setFlyUnstaked] = useState(false); - const finaliseUnstake = async() => { - const unstaked = await flyStakingFinaliseUnstake?.() - setFlyUnstaked(unstaked?.gt(new BN(0)) || false) - } + const finaliseUnstake = async () => { + const unstaked = await flyStakingFinaliseUnstake?.(); + setFlyUnstaked(unstaked?.gt(new BN(0)) || false); + }; useEffect(() => { - (async() => { + (async () => { if (!address) return; - const seconds = await flyStakingSecondsUntilSoonestUnstake?.(address) - if (!seconds || seconds.eq(new BN(0))) - setFlyUnstakable(flyUnstaking) - })() - }, [flyUnstaking, flyStakingSecondsUntilSoonestUnstake]) + const seconds = await flyStakingSecondsUntilSoonestUnstake?.(address); + if (!seconds || seconds.eq(new BN(0))) setFlyUnstakable(flyUnstaking); + })(); + }, [flyUnstaking, flyStakingSecondsUntilSoonestUnstake]); - const [isStaking, setIsStaking] = useState(staking) - const [currentAction, setCurrentAction] = useState("Connect") - const [showTermsModal, setShowTermsModal] = useState(false) + const [isStaking, setIsStaking] = useState(staking); + const [currentAction, setCurrentAction] = useState("Connect"); + const [showTermsModal, setShowTermsModal] = useState(false); useEffect(() => { - if (address && (currentStatus === State.AmountEntered)) + if (address && currentStatus === State.AmountEntered) setCurrentStatus(State.IsConnected); }, [address, currentStatus]); useEffect(() => { switch (currentStatus) { case State.Stats: - setCurrentAction("") + setCurrentAction(""); break; case State.StakingDetails: - setCurrentAction(isStaking ? "Stake" : "Unstake") + setCurrentAction(isStaking ? "Stake" : "Unstake"); break; case State.AmountEntered: - setCurrentAction("Connect") + setCurrentAction("Connect"); break; case State.IsConnected: - setCurrentAction(isStaking ? "Stake" : "Unstake") + setCurrentAction(isStaking ? "Stake" : "Unstake"); break; case State.HasStaked: - setCurrentAction(isStaking ? "Staked!" : "Unstaked") + setCurrentAction(isStaking ? "Staked!" : "Unstaked"); break; } - }, [currentStatus]); const handleClose = () => { @@ -202,7 +225,7 @@ const FlyStakingStatsModal = ({ visible, close, showConnectWalletModal, shouldUp break; case State.AmountEntered: setIsStaking(staking); - showConnectWalletModal() + showConnectWalletModal(); break; case State.IsConnected: setIsStaking(staking); @@ -211,17 +234,13 @@ const FlyStakingStatsModal = ({ visible, close, showConnectWalletModal, shouldUp case State.HasStaked: break; } - } + }; const setMaxBalance = () => { if (isStaking) { setSwapInput( addDecimalToBn( - snapToValidValue( - flyBalance.toString(), - FlyToken, - flyBalance, - ), + snapToValidValue(flyBalance.toString(), FlyToken, flyBalance), FlyToken.decimals ) ); @@ -243,7 +262,11 @@ const FlyStakingStatsModal = ({ visible, close, showConnectWalletModal, shouldUp const stakeAmount: BN = snapToValidValue(swapInput, FlyToken, flyBalance); - const unstakeAmount: BN = snapToValidValue(swapInput, FlyToken, new BN(flyStaked.toString())); + const unstakeAmount: BN = snapToValidValue( + swapInput, + FlyToken, + new BN(flyStaked.toString()) + ); // kicks off the interaction to begin the staking via the contract const [beginStaking, setBeginStaking] = useState(false); @@ -257,14 +280,14 @@ const FlyStakingStatsModal = ({ visible, close, showConnectWalletModal, shouldUp (async () => { try { console.log("begin unstaking", unstakeAmount.toString()); - isStaking ? - await flyStakingStake(stakeAmount) : - await flyStakingBeginUnstake?.(unstakeAmount); + isStaking + ? await flyStakingStake(stakeAmount) + : await flyStakingBeginUnstake?.(unstakeAmount); setCurrentStatus(State.HasStaked); // if the user is staking, add to their staked amount, if not, take - isStaking ? - setFlyStaked(flyStaked.add(stakeAmount.toString())) : - setFlyStaked(flyStaked.sub(stakeAmount.toString())); + isStaking + ? setFlyStaked(flyStaked.add(stakeAmount.toString())) + : setFlyStaked(flyStaked.sub(stakeAmount.toString())); setFlyBalance(flyBalance.sub(stakeAmount)); } catch (err) { console.error("error fly staking", err); @@ -278,8 +301,10 @@ const FlyStakingStatsModal = ({ visible, close, showConnectWalletModal, shouldUp setBeginStaking(true); }; - const handleChangeSwapInput: React.ChangeEventHandler = (e) => { - const tokenDecimals = 6 + const handleChangeSwapInput: React.ChangeEventHandler = ( + e + ) => { + const tokenDecimals = 6; // if (/^\d*\.?\d*$/.test(e.currentTarget.value)) // setSwapInput(e.target.value); const numericChars = e.target.value.replace(/[^0-9.]+/, ""); @@ -302,412 +327,582 @@ const FlyStakingStatsModal = ({ visible, close, showConnectWalletModal, shouldUp createPortal( <>
-
-
-
-
- - {currentStatus === State.Stats ? - "Your Staking Stats" : - currentStatus === State.StakingDetails ? - `${isStaking ? "Staking" : "Unstaking"} details` : - `${isStaking ? "Staking" : "Unstaking"} $FLY Tokens` - } - - - - -
-
- {currentStatus === State.Stats ? - <> -
- {points.toString()} - - } - > -
- Your Cumulative Points - +
+
+
+
+ + {currentStatus === State.Stats + ? "Your Staking Stats" + : currentStatus === State.StakingDetails + ? `${isStaking ? "Staking" : "Unstaking"} details` + : `${isStaking ? "Staking" : "Unstaking"} $FLY Tokens`} + + + + +
+
+ {currentStatus === State.Stats ? ( + <> +
+ + {points.toString()} + + - -
-
-
- - - πŸ’Έ Stake your $FLY to earn Airdrop Rewards and [REDACTED] in Superposition (SPN) 🐱 - - + } + > +
+ Your Cumulative Points + +
+
-
+
+
+ + + πŸ’Έ Stake your $FLY to earn Airdrop Rewards and + [REDACTED] in Superposition (SPN) 🐱 + + +
+
- -
- -
- - πŸ˜” No Tier - - - {"0 ≀ No Tier < 5000"} - -
-
- - 🦐 Shrimp - - - {"5,000 ≀ Shrimp 30,000"} - -
-
- - 🐬 Dolphin - - - {"30,000 ≀ Dolphin < 80,000"} - -
-
- - πŸ„β€β™‚οΈ Surfer - - - {"80,000 ≀ Surfer < 250,000"} - -
-
- - πŸ—Ώ Tiki Warrior - - - {"250,000 ≀ Tiki < 1,000,000"} - -
-
- - 🌌 Super Surfer - - - {"1,000,000 ≀ Super Surfer"} - -
-
- } - > -
-
- {tierText(flyStaked.toString())} - -
-
- -
- - + +
- - The amount of $FLY Token you have claimed. - +
+
+ + πŸ˜” No Tier + + + {"0 ≀ No Tier < 5000"} + +
+
+ + 🦐 Shrimp + + + {"5,000 ≀ Shrimp 30,000"} + +
+
+ + 🐬 Dolphin + + + {"30,000 ≀ Dolphin < 80,000"} + +
+
+ + πŸ„β€β™‚οΈ Surfer + + + {"80,000 ≀ Surfer < 250,000"} + +
+
+ + πŸ—Ώ Tiki Warrior + + + {"250,000 ≀ Tiki < 1,000,000"} + +
+
+ + 🌌 Super Surfer + + + {"1,000,000 ≀ Super Surfer"} + +
} >
- - {getValueFromFlyAmount(flyBalance)?.toString()} -
-
- $FLY Balance - -
-
-
- - - - - The amount of $FLY Token you have staked from your total $FLY Balance. + + {tierText(flyStaked.toString())} -
- } - > -
- { - (() => { - const s = getValueFromFlyAmount(new BN(flyStaked.toString()))?.toString(); - if (!s) return flyStaked.toString(); - return s; - })() } -
- Staked
-
- - - - The amount of $FLY Tokens you have unstaked from your total Staked $FLY Balance. Includes unbonding amount. - -
- } - > +
+ + + + + The amount of $FLY Token you have claimed. + +
+ } + > +
+
+ - {getValueFromFlyAmount(flyUnstaking) ?? flyUnstaking.toString()} + {getValueFromFlyAmount( + flyBalance + )?.toString()} -
- Unstaking - -
- - - -
-
- {getValueFromFlyAmount(flyUnstakable)?.toString()} -
- Claimable Unstaked $FLY -
+
+ $FLY Balance +
- - - {flyUnstaked ? "Claimed" : "Claim"} - - -
- -
-
- - : - currentStatus === State.StakingDetails ? -
- {isStaking ? -
- Staking will lock up your funds for 7 Days. - } - body={ - To have access to your staked funds once again, you must go through the process of unstaking - - } /> -
- : - <> -
- Access to the tokens will be granted in 7 Days. - } - body={ - During this period, you will be unable to receive staking rewards and terminate the un-bonding process. - - } /> -
-
- Unstaking will result in the loss of some points. - } - body={ - You will lose the equivalent percentage of unstaked $FLY from your accumulative points. (i.e: Unstaking 50% of $FLY will result in 50% Loss of points) - - } />
- - } -
-
- AMOUNT OF $FLY TO {isStaking ? "STAKE" : "UNSTAKE"} -
- - + + + + + + The amount of $FLY Token you have staked + from your total $FLY Balance. + +
+ } + > +
+ + {(() => { + const s = getValueFromFlyAmount( + new BN(flyStaked.toString()) + )?.toString(); + if (!s) return flyStaked.toString(); + return s; + })()} + +
+ Staked + +
-
- {isStaking ? - `${getValueFromFlyAmount(flyBalance.sub(stakeAmount))} $FLY remaining` : - `${getValueFromFlyAmount(new BN(flyStaked.toString()).sub(unstakeAmount))} $FLY staked remaining`} -
- {isStaking ? - Staking {getValueFromFlyAmount(stakeAmount)} $FLY : - Unstaking {getValueFromFlyAmount(unstakeAmount)} $FLY} -
- Max -
+ + + + + + The amount of $FLY Tokens you have unstaked + from your total Staked $FLY Balance. + Includes unbonding amount. + +
+ } + > +
+ + {getValueFromFlyAmount(flyUnstaking) ?? + flyUnstaking.toString()} + +
+ Unstaking +
-
-
- Once approved, transactions cannot be reverted. By pressing send you agree to our {" "} - { setShowTermsModal(true) }} + + + + : - - -
- {currentStatus <= State.IsConnected &&
-
-
- πŸ„πŸΌβ€β™‚οΈ - Staking $FLY will reward you points. +
+ + {getValueFromFlyAmount( + flyUnstakable + )?.toString()} + +
+ Claimable Unstaked $FLY +
+ + + {flyUnstaked ? "Claimed" : "Claim"} + +
-
- } + +
+
+ + ) : currentStatus === State.StakingDetails ? ( +
+ {isStaking ? ( +
+ + Staking will lock up your funds for{" "} + 7 Days. + + } + body={ + + To have access to your staked funds once again, + you must go through the process of unstaking + + } + /> +
+ ) : ( + <>
- {currentStatus <= State.AmountEntered - ? : } -
- Connect your Arbitrum wallet - {State.IsConnected && address && Connected {trimAddress(address)}} -
+ + Access to the tokens will be{" "} + + granted in 7 Days + + . + + } + body={ + + During this period, you will be unable to + receive staking rewards and terminate the + un-bonding process. + + } + />
- {currentStatus < State.HasStaked ? : } -
- {isStaking ? `Stake $FLY ${getValueFromFlyAmount(stakeAmount)}`: `Unstake $FLY ${getValueFromFlyAmount(unstakeAmount)}`} - { - currentStatus >= State.HasStaked && ( - isStaking ? - Earn rewards & [REDACTED] on SPN : - { addToken?.("FLY") }} - > - Add $FLY to My Wallet - - ) + + Unstaking will result in the loss of some + points. + + } + body={ + + You will lose the equivalent percentage of + unstaked $FLY from your accumulative points.{" "} + + (i.e: Unstaking 50% of $FLY will result in + 50% Loss of points) + + } + /> +
+ + )} +
+
+ + AMOUNT OF $FLY TO {isStaking ? "STAKE" : "UNSTAKE"} + +
+ + +
+
+ {isStaking + ? `${getValueFromFlyAmount( + flyBalance.sub(stakeAmount) + )} $FLY remaining` + : `${getValueFromFlyAmount( + new BN(flyStaked.toString()).sub( + unstakeAmount + ) + )} $FLY staked remaining`} +
+ {isStaking ? ( + + Staking {getValueFromFlyAmount(stakeAmount)}{" "} + $FLY + + ) : ( + + Unstaking{" "} + {getValueFromFlyAmount(unstakeAmount)} $FLY + + )} +
+ + Max + +
- } -
- { errorMessage } -
-
- {currentStatus === State.Stats ? - <> - handleClick(true)} - className={`fly-staking-stats-action-button`} - > - - - Stake +
+ + Once approved, transactions cannot be reverted. By + pressing send you agree to our{" "} + { + setShowTermsModal(true); + }} + > + staking terms and conditions + + . + +
+ ) : ( +
+ {currentStatus <= State.IsConnected && ( +
+
+
+ + πŸ„πŸΌβ€β™‚οΈ + + + Staking $FLY will reward you points. + +
+
+
+ )} +
+ {currentStatus <= State.AmountEntered ? ( + + ) : ( + + )} +
+ + Connect your Arbitrum wallet + + {State.IsConnected && address && ( + + Connected {trimAddress(address)} - - handleClick(false)} - className={`fly-staking-stats-action-button`} + )} +
+
+
+ {currentStatus < State.HasStaked ? ( + + ) : ( + + )} +
+ + {isStaking + ? `Stake $FLY ${getValueFromFlyAmount( + stakeAmount + )}` + : `Unstake $FLY ${getValueFromFlyAmount( + unstakeAmount + )}`} + + {currentStatus >= State.HasStaked && + (isStaking ? ( + + Earn rewards & [REDACTED] on SPN + + ) : ( + { + addToken?.("FLY"); + }} + > + Add $FLY to My Wallet + + ))} +
+
+
+ )} +
+ + {errorMessage} + +
+
+ {currentStatus === State.Stats ? ( + <> + handleClick(true)} + className={`fly-staking-stats-action-button`} + > + - - - Unstake - - - : + + Stake + + handleClick(isStaking)} - className={`fly-staking-stats-action-button ${currentStatus === State.HasStaked - 1 ? "rainbow" : ""} ${currentStatus === State.HasStaked ? "claim-button-staked" : ""} ${currentStatus === State.InError ? "claim-button-error" : ""}`} - + handleClick={() => handleClick(false)} + className={`fly-staking-stats-action-button`} > - - {currentAction} - {currentStatus === State.HasStaked && } + + + Unstake - - } -
- + + ) : ( + handleClick(isStaking)} + className={`fly-staking-stats-action-button ${ + currentStatus === State.HasStaked - 1 ? "rainbow" : "" + } ${ + currentStatus === State.HasStaked + ? "claim-button-staked" + : "" + } ${ + currentStatus === State.InError + ? "claim-button-error" + : "" + }`} + > + + {currentAction} + {currentStatus === State.HasStaked && ( + + )} + + + )}
- - By signing the following transactions, you agree to Fluidity Money'services{" "} - - Terms of Service - {" "} - and acknowledge that you have read and understand the{" "} - Disclaimer - - setShowTermsModal(false)} />
+ + By signing the following transactions, you agree to Fluidity + Money'services{" "} + + Terms of Service + {" "} + and acknowledge that you have read and understand the{" "} + Disclaimer + + setShowTermsModal(false)} + />
+
, document.body ) ); - }, [ visible, currentStatus, @@ -716,40 +911,46 @@ const FlyStakingStatsModal = ({ visible, close, showConnectWalletModal, shouldUp showTermsModal, points, flyUnstaking, - swapInput - ]) + swapInput, + ]); return modal; -} +}; const tierText = (flyStakedUnscaled: string): JSX.Element => { - const flyStaked = Number(getValueFromFlyAmount(new BN(flyStakedUnscaled))) + const flyStaked = Number(getValueFromFlyAmount(new BN(flyStakedUnscaled))); switch (true) { case flyStaked < 5000: - return <>πŸ˜” No Tier; + return <>πŸ˜” No Tier; case flyStaked < 30000: - return <>🦐 Shrimp Tier; + return <>🦐 Shrimp Tier; case flyStaked < 80000: - return <>🐬 Dolphin Tier; + return <>🐬 Dolphin Tier; case flyStaked < 250000: - return <>πŸ„β€β™‚οΈ Surfer Tier; + return <>πŸ„β€β™‚οΈ Surfer Tier; case flyStaked < 1000000: - return <>πŸ—Ώ Tiki Warrior Tier; + return <>πŸ—Ώ Tiki Warrior Tier; default: - return <>🌌 Super Surfer Tier; - } -} + return <>🌌 Super Surfer Tier; + } +}; -const StakingWarning = ({ header, body }: { header: ReactNode, body: ReactNode }) => { - return -
- - {header} -
- {body} -
-} +const StakingWarning = ({ + header, + body, +}: { + header: ReactNode; + body: ReactNode; +}) => { + return ( + +
+ + {header} +
+ {body} +
+ ); +}; -export { - FlyStakingStatsModal -} +export { FlyStakingStatsModal }; diff --git a/web/app.fluidity.money/app/components/Fluidify/FluidifyForm.tsx b/web/app.fluidity.money/app/components/Fluidify/FluidifyForm.tsx index 8c9d685b3..28283fe66 100644 --- a/web/app.fluidity.money/app/components/Fluidify/FluidifyForm.tsx +++ b/web/app.fluidity.money/app/components/Fluidify/FluidifyForm.tsx @@ -33,7 +33,11 @@ export const FluidifyForm = ({ const [swapInput, setSwapInput] = useState(""); - const swapAmount: BN = snapToValidValue(swapInput, assetToken, assetToken.userTokenBalance); + const swapAmount: BN = snapToValidValue( + swapInput, + assetToken, + assetToken.userTokenBalance + ); const assertCanSwap = connected && @@ -72,7 +76,7 @@ export const FluidifyForm = ({ snapToValidValue( assetToken.userTokenBalance.toString(), assetToken, - assetToken.userTokenBalance, + assetToken.userTokenBalance ), assetToken.decimals ) diff --git a/web/app.fluidity.money/app/components/MobileModal.tsx b/web/app.fluidity.money/app/components/MobileModal.tsx index 14ea7e094..f0025a950 100644 --- a/web/app.fluidity.money/app/components/MobileModal.tsx +++ b/web/app.fluidity.money/app/components/MobileModal.tsx @@ -24,7 +24,9 @@ type IMobileModal = { path: (network: string) => string; icon: JSX.Element; }>; - nonNavigationEntries?: Array, HTMLElement>>; + nonNavigationEntries?: Array< + React.DetailedHTMLProps, HTMLElement> + >; activeIndex: number; chains: Record; unclaimedFluid: number; @@ -209,8 +211,7 @@ export default function MobileModal({ {/* Navigation between pages */}
    <> - {navigationMap - .map((obj, index) => { + {navigationMap.map((obj, index) => { const key = Object.values(obj)[0]; const { name, icon, path } = obj; const active = index === activeIndex; @@ -241,8 +242,8 @@ export default function MobileModal({ ); })} - {...(nonNavigationEntries || [])} - + {...nonNavigationEntries || []} +
{/* Navigation at bottom of modal */} diff --git a/web/app.fluidity.money/app/queries/addReferral.ts b/web/app.fluidity.money/app/queries/addReferral.ts index 1609fdbf2..834a2a7c6 100644 --- a/web/app.fluidity.money/app/queries/addReferral.ts +++ b/web/app.fluidity.money/app/queries/addReferral.ts @@ -1,7 +1,11 @@ import { gql, jsonPost } from "~/util"; const mutation = gql` - mutation addReferral($referrer: String!, $referee: String!, $epoch: lootbox_epoch!) { + mutation addReferral( + $referrer: String! + $referee: String! + $epoch: lootbox_epoch! + ) { insert_lootbox_referrals_one( object: { referrer: $referrer, referee: $referee, epoch: $epoch } ) { diff --git a/web/app.fluidity.money/app/queries/addReferralCode.ts b/web/app.fluidity.money/app/queries/addReferralCode.ts index 2e86a60e2..2e31a66ed 100644 --- a/web/app.fluidity.money/app/queries/addReferralCode.ts +++ b/web/app.fluidity.money/app/queries/addReferralCode.ts @@ -1,9 +1,17 @@ import { gql, jsonPost } from "~/util"; const mutation = gql` - mutation addReferral($address: String!, $referral_code: String!, $epoch: lootbox_epoch!) { + mutation addReferral( + $address: String! + $referral_code: String! + $epoch: lootbox_epoch! + ) { insert_lootbox_referral_codes_one( - object: { address: $address, referral_code: $referral_code, epoch: $epoch} + object: { + address: $address + referral_code: $referral_code + epoch: $epoch + } ) { address referral_code diff --git a/web/app.fluidity.money/app/queries/requestProof.ts b/web/app.fluidity.money/app/queries/requestProof.ts index d3ee519d5..a5311049d 100644 --- a/web/app.fluidity.money/app/queries/requestProof.ts +++ b/web/app.fluidity.money/app/queries/requestProof.ts @@ -15,9 +15,10 @@ export type RequestProofRes = { }; export const requestProof = (address: string, signature: string) => { - const body = {address, signature}; + const body = { address, signature }; - const url = "https://lyqieipytnj32qqga7mpgdpn7q0pxmlw.lambda-url.ap-southeast-2.on.aws/"; + const url = + "https://lyqieipytnj32qqga7mpgdpn7q0pxmlw.lambda-url.ap-southeast-2.on.aws/"; return jsonPost(url, body, {}); }; diff --git a/web/app.fluidity.money/app/queries/useReferralCode.ts b/web/app.fluidity.money/app/queries/useReferralCode.ts index 9a4432696..f3e8072a7 100644 --- a/web/app.fluidity.money/app/queries/useReferralCode.ts +++ b/web/app.fluidity.money/app/queries/useReferralCode.ts @@ -2,7 +2,9 @@ import { gql, jsonPost } from "~/util"; const queryByAddress = gql` query getReferralCodeByAddress($address: String!, $epoch: lootbox_epoch!) { - lootbox_referral_codes(where: { address: { _eq: $address }, epoch: { _eq: $epoch } }) { + lootbox_referral_codes( + where: { address: { _eq: $address }, epoch: { _eq: $epoch } } + ) { address referral_code epoch @@ -12,7 +14,9 @@ const queryByAddress = gql` const queryByCode = gql` query getReferralCodeByCode($code: String!, $epoch: lootbox_epoch!) { - lootbox_referral_codes(where: { referral_code: { _eq: $code }, epoch: { _eq: $epoch } }) { + lootbox_referral_codes( + where: { referral_code: { _eq: $code }, epoch: { _eq: $epoch } } + ) { address referral_code epoch diff --git a/web/app.fluidity.money/app/queries/useReferralCount.ts b/web/app.fluidity.money/app/queries/useReferralCount.ts index 6b2106d7d..307274981 100644 --- a/web/app.fluidity.money/app/queries/useReferralCount.ts +++ b/web/app.fluidity.money/app/queries/useReferralCount.ts @@ -1,9 +1,16 @@ import { gql, jsonPost } from "~/util"; const queryActiveByReferrerAddress = gql` - query getClaimedReferrerReferralCount($address: String!, $epoch: lootbox_epoch!) { - lootbox_referrals_aggregate ( - where: { referrer: { _eq: $address }, active: { _eq: true }, epoch: { _eq: $epoch } } + query getClaimedReferrerReferralCount( + $address: String! + $epoch: lootbox_epoch! + ) { + lootbox_referrals_aggregate( + where: { + referrer: { _eq: $address } + active: { _eq: true } + epoch: { _eq: $epoch } + } ) { aggregate { count @@ -13,9 +20,16 @@ const queryActiveByReferrerAddress = gql` `; const queryActiveByRefereeAddress = gql` - query getClaimedReferreeReferralCount($address: String!, $epoch: lootbox_epoch!) { + query getClaimedReferreeReferralCount( + $address: String! + $epoch: lootbox_epoch! + ) { lootbox_referrals_aggregate( - where: { referee: { _eq: $address }, active: { _eq: true }, epoch: { _eq: $epoch } } + where: { + referee: { _eq: $address } + active: { _eq: true } + epoch: { _eq: $epoch } + } ) { aggregate { count @@ -25,9 +39,16 @@ const queryActiveByRefereeAddress = gql` `; const queryInactiveByRefereeAddress = gql` - query getClaimedReferrerReferralCount($address: String!, $epoch: lootbox_epoch!) { + query getClaimedReferrerReferralCount( + $address: String! + $epoch: lootbox_epoch! + ) { lootbox_referrals_aggregate( - where: { referee: { _eq: $address }, active: { _eq: false }, epoch: { _eq: $epoch } } + where: { + referee: { _eq: $address } + active: { _eq: false } + epoch: { _eq: $epoch } + } ) { aggregate { count @@ -55,10 +76,13 @@ type ReferralCountRes = { errors?: unknown; }; -const useActiveReferralCountByReferrerAddress = (address: string, epoch: string) => { +const useActiveReferralCountByReferrerAddress = ( + address: string, + epoch: string +) => { const variables = { address, - epoch + epoch, }; const body = { @@ -79,7 +103,10 @@ const useActiveReferralCountByReferrerAddress = (address: string, epoch: string) ); }; -const useActiveReferralCountByRefereeAddress = (address: string, epoch: string) => { +const useActiveReferralCountByRefereeAddress = ( + address: string, + epoch: string +) => { const variables = { address, epoch, @@ -103,7 +130,10 @@ const useActiveReferralCountByRefereeAddress = (address: string, epoch: string) ); }; -const useInactiveReferralCountByRefereeAddress = (address: string, epoch: string) => { +const useInactiveReferralCountByRefereeAddress = ( + address: string, + epoch: string +) => { const variables = { address, epoch, diff --git a/web/app.fluidity.money/app/queries/useReferrals.ts b/web/app.fluidity.money/app/queries/useReferrals.ts index 9d8a2059f..ba15ea8c6 100644 --- a/web/app.fluidity.money/app/queries/useReferrals.ts +++ b/web/app.fluidity.money/app/queries/useReferrals.ts @@ -10,9 +10,17 @@ export type Referral = { }; const QUERY_BY_ADDRESS = gql` - query getReferralByAddress($referrer: String!, $referee: String!, $epoch: lootbox_epoch!) { + query getReferralByAddress( + $referrer: String! + $referee: String! + $epoch: lootbox_epoch! + ) { lootbox_referrals( - where: { referrer: { _eq: $referrer }, referee: { _eq: $referee }, epoch: { _eq: $epoch } } + where: { + referrer: { _eq: $referrer } + referee: { _eq: $referee } + epoch: { _eq: $epoch } + } ) { active createdTime: created_time @@ -25,9 +33,16 @@ const QUERY_BY_ADDRESS = gql` `; const QUERY_INACTIVE_BY_ADDRESS = gql` - query getInactiveReferralByAddress($address: String!, $epoch: lootbox_epoch!) { + query getInactiveReferralByAddress( + $address: String! + $epoch: lootbox_epoch! + ) { lootbox_referrals( - where: { referee: { _eq: $address }, active: { _eq: false }, epoch: { _eq: $epoch } } + where: { + referee: { _eq: $address } + active: { _eq: false } + epoch: { _eq: $epoch } + } order_by: { created_time: asc } limit: 1 ) { @@ -65,7 +80,11 @@ type ReferralsRes = { errors?: unknown; }; -const useReferralByAddress = (referrer: string, referee: string, epoch: string) => { +const useReferralByAddress = ( + referrer: string, + referee: string, + epoch: string +) => { const variables = { referrer, referee, diff --git a/web/app.fluidity.money/app/root.tsx b/web/app.fluidity.money/app/root.tsx index 30d8e0e26..2a24f523c 100644 --- a/web/app.fluidity.money/app/root.tsx +++ b/web/app.fluidity.money/app/root.tsx @@ -15,7 +15,11 @@ import { withSentry } from "@sentry/remix"; import globalStylesheetUrl from "./global-styles.css"; import surfingStylesheetUrl from "@fluidity-money/surfing/dist/style.css"; -import { JoeFarmlandsOrCamelotKingdomLinks, ToolTipLinks, FLYClaimSubmitModalLinks } from "./components"; +import { + JoeFarmlandsOrCamelotKingdomLinks, + ToolTipLinks, + FLYClaimSubmitModalLinks, +} from "./components"; import { ToolProvider } from "./components/ToolTip"; import CacheProvider from "contexts/CacheProvider"; import { useEffect, useState } from "react"; diff --git a/web/app.fluidity.money/app/routes/$network/dashboard.tsx b/web/app.fluidity.money/app/routes/$network/dashboard.tsx index 2ba41fbe1..e5b7d1da1 100644 --- a/web/app.fluidity.money/app/routes/$network/dashboard.tsx +++ b/web/app.fluidity.money/app/routes/$network/dashboard.tsx @@ -415,16 +415,17 @@ export default function Dashboard() { const [hoverModal, setHoverModal] = useState(false); const [showModal, setShowModal] = useState(false); - const [stakingStatsModalVisibility, setStakingStatsModalVisibility] = useState(false); + const [stakingStatsModalVisibility, setStakingStatsModalVisibility] = + useState(false); // every change to this number asks flystakingmodal to look up the new balance const [shouldUpdateFlyBalance, setShouldUpdateFlyBalance] = useState(0); const otherModalOpen = openMobModal || - walletModalVisibility || - connectedWalletModalVisibility || - chainModalVisibility + walletModalVisibility || + connectedWalletModalVisibility || + chainModalVisibility ? true : false; @@ -500,8 +501,9 @@ export default function Dashboard() { {/* Fluidify Money button, in a portal with z-index above tooltip if another modal isn't open */} navigate("../fluidify")} @@ -572,8 +574,13 @@ export default function Dashboard() { })}
  • @@ -759,7 +766,9 @@ export default function Dashboard() { {/* FLY Staking Stats Modal */} { setStakingStatsModalVisibility(false) }} + close={() => { + setStakingStatsModalVisibility(false); + }} showConnectWalletModal={() => setWalletModalVisibility(true)} visible={stakingStatsModalVisibility} shouldUpdateFlyBalance={shouldUpdateFlyBalance} @@ -767,12 +776,13 @@ export default function Dashboard() { setShouldUpdateFlyBalance((v) => v + 1) + shouldUpdateBalance: () => setShouldUpdateFlyBalance((v) => v + 1), }} > setWalletModalVisibility((v) => !v), + toggleConnectWalletModal: () => + setWalletModalVisibility((v) => !v), }} > @@ -911,8 +921,13 @@ export default function Dashboard() { nonNavigationEntries={[
  • ,
  • @@ -927,7 +942,7 @@ export default function Dashboard() { GET FLY -
  • + , ]} activeIndex={activeIndex} chains={chainNameMap} diff --git a/web/app.fluidity.money/app/routes/$network/dashboard/airdrop/common.tsx b/web/app.fluidity.money/app/routes/$network/dashboard/airdrop/common.tsx index 1045bad07..aab91338c 100644 --- a/web/app.fluidity.money/app/routes/$network/dashboard/airdrop/common.tsx +++ b/web/app.fluidity.money/app/routes/$network/dashboard/airdrop/common.tsx @@ -120,19 +120,19 @@ const BottleDistribution = ({ style={ numberPosition === "absolute" ? { - position: "absolute", - bottom: "100px", - zIndex: "5", - ...(showBottleNumbers - ? highlightBottle - ? { - fontSize: "2.5em", - } - : {} - : highlightBottle + position: "absolute", + bottom: "100px", + zIndex: "5", + ...(showBottleNumbers + ? highlightBottle + ? { + fontSize: "2.5em", + } + : {} + : highlightBottle ? { fontSize: "2.5em" } : { display: "none" }), - } + } : { fontSize: "1em" } } > @@ -670,8 +670,8 @@ export const stakingLiquidityMultiplierEq = ( Math.min( 1, (396 / 11315 - (396 * totalStakedDays) / 4129975) * stakedDays + - (396 * totalStakedDays) / 133225 - - 31 / 365 + (396 * totalStakedDays) / 133225 - + 31 / 365 ) ); @@ -724,12 +724,12 @@ const StakeNowModal = ({ const ratio = !tokenRatios ? 0 : calculateRatioFromProportion( - (baseToken.symbol === "USDC" - ? tokenRatios.fusdcUsdcRatio.toNumber() - - tokenRatios.fusdcUsdcSpread.toNumber() / 2 - : tokenRatios.fusdcWethRatio.toNumber() - - tokenRatios.fusdcWethSpread.toNumber() / 2) / 1e12 - ); + (baseToken.symbol === "USDC" + ? tokenRatios.fusdcUsdcRatio.toNumber() - + tokenRatios.fusdcUsdcSpread.toNumber() / 2 + : tokenRatios.fusdcWethRatio.toNumber() - + tokenRatios.fusdcWethSpread.toNumber() / 2) / 1e12 + ); // usdMultiplier x tokenAmount = USD const fluidUsdMultiplier = usdcPrice; @@ -792,31 +792,31 @@ const StakeNowModal = ({ setOtherInput: (token: StakingAugmentedToken) => void, conversionRatio: number ): React.ChangeEventHandler => - (e) => { - const numericChars = e.target.value.replace(/[^0-9.]+/, ""); + (e) => { + const numericChars = e.target.value.replace(/[^0-9.]+/, ""); - const [whole, dec] = numericChars.split("."); + const [whole, dec] = numericChars.split("."); - const tokenAmtStr = - dec !== undefined - ? [whole, dec.slice(0 - token.decimals)].join(".") - : whole ?? "0"; + const tokenAmtStr = + dec !== undefined + ? [whole, dec.slice(0 - token.decimals)].join(".") + : whole ?? "0"; - setInput({ - ...token, - amount: tokenAmtStr, - }); + setInput({ + ...token, + amount: tokenAmtStr, + }); - if (!ratio) return; - if (!(whole || dec)) return; + if (!ratio) return; + if (!(whole || dec)) return; - const otherTokenAmt = parseFloat(tokenAmtStr) * conversionRatio; + const otherTokenAmt = parseFloat(tokenAmtStr) * conversionRatio; - setOtherInput({ - ...otherToken, - amount: otherTokenAmt.toFixed(otherToken.decimals).replace(/\.0+$/, ""), - }); - }; + setOtherInput({ + ...otherToken, + amount: otherTokenAmt.toFixed(otherToken.decimals).replace(/\.0+$/, ""), + }); + }; const fluidTokenAmount = useMemo( () => parseSwapInputToTokenAmount(fluidToken.amount, fluidToken), @@ -1040,8 +1040,9 @@ const StakeNowModal = ({ )}
    {/* Staking Amount */}
    @@ -1333,7 +1334,7 @@ const StakeNowModal = ({ baseToken.decimals, baseUsdMultiplier ) || 0)) * - stakingLiquidityMultiplierEq(0, stakingDuration), + stakingLiquidityMultiplierEq(0, stakingDuration), 1 )} @@ -1384,7 +1385,7 @@ const StakeNowModal = ({ baseToken.decimals, baseUsdMultiplier ) || 0)) * - stakingLiquidityMultiplierEq(MAX_EPOCH_DAYS, stakingDuration), + stakingLiquidityMultiplierEq(MAX_EPOCH_DAYS, stakingDuration), 1 )} @@ -1469,7 +1470,11 @@ const tutorialContent: { desc: ( <> - You can increase your chances of receiving Loot Bottles by doing the following: Staking $FLY on the Fluidity Webapp β€’ LPing on the incentivised Trader Joe & Camelot LPs β€’ Contributing volume (specially through $FLY) β€’ Use our supported DEXs to receive a 12x multiplier for transacting + You can increase your chances of receiving Loot Bottles by doing the + following: Staking $FLY on the Fluidity Webapp β€’ LPing on the + incentivised Trader Joe & Camelot LPs β€’ Contributing volume (specially + through $FLY) β€’ Use our supported DEXs to receive a 12x multiplier for + transacting
    @@ -1684,15 +1690,18 @@ const RecapModal = ({ }, }: IRecapModal) => { const providerLinks: { provider: Provider; link: string }[] = [ - { provider: "Uniswap", link: "https://app.uniswap.org/swap?outputCurrency=0x000F1720A263f96532D1ac2bb9CDC12b72C6f386&chain=arbitrum" }, + { + provider: "Uniswap", + link: "https://app.uniswap.org/swap?outputCurrency=0x000F1720A263f96532D1ac2bb9CDC12b72C6f386&chain=arbitrum", + }, { provider: "Trader Joe", - link: "https://traderjoexyz.com/arbitrum/trade?outputCurrency=0x000F1720A263f96532D1ac2bb9CDC12b72C6f386" + link: "https://traderjoexyz.com/arbitrum/trade?outputCurrency=0x000F1720A263f96532D1ac2bb9CDC12b72C6f386", }, { provider: "Camelot", link: "https://app.camelot.exchange/" }, { provider: "Ramses", - link: "https://app.ramses.exchange/liquidity/v2/0x000F1720A263f96532D1ac2bb9CDC12b72C6f386" + link: "https://app.ramses.exchange/liquidity/v2/0x000F1720A263f96532D1ac2bb9CDC12b72C6f386", }, { provider: "Jumper", link: "https://jumper.exchange/" }, ]; @@ -1760,15 +1769,16 @@ const RecapModal = ({ const { address } = useContext(FluidityFacadeContext); - const { - toggleVisibility: flyStakingModalToggleVisibility - } = useContext(FlyStakingContext); + const { toggleVisibility: flyStakingModalToggleVisibility } = + useContext(FlyStakingContext); const videoHeight = isMobile ? 500 : 700; const videoWidth = isMobile ? 500 : 1500; const [walletModalVisibility, setWalletModalVisibility] = useState(false); - const [flyClaimModalState, setFlyClaimModalState] = useState<'none' | 'claim' | 'stake'>('none'); + const [flyClaimModalState, setFlyClaimModalState] = useState< + "none" | "claim" | "stake" + >("none"); const [flyAmountOwed, setFLYAmountOwed] = useState(0); @@ -1850,17 +1860,20 @@ const RecapModal = ({ ); }; - const handleClaimYourFly = (type: 'claim' |'stake') => { - setFlyClaimModalState(type) + const handleClaimYourFly = (type: "claim" | "stake") => { + setFlyClaimModalState(type); // Get the user's address.by }; - const [termsAndConditionsModalVis, setTermsAndConditionsModalVis] = useState(false); + const [termsAndConditionsModalVis, setTermsAndConditionsModalVis] = + useState(false); // needed for the terms and conditions const closeWithEsc = useCallback( (event: { key: string }) => { - event.key === "Escape" && setTermsAndConditionsModalVis && setTermsAndConditionsModalVis(false); + event.key === "Escape" && + setTermsAndConditionsModalVis && + setTermsAndConditionsModalVis(false); }, [termsAndConditionsModalVis, setTermsAndConditionsModalVis] ); @@ -1891,30 +1904,39 @@ const RecapModal = ({ return () => clearTimeout(timerId); }, []); - const ClaimButtonsSpread = () => + const ClaimButtonsSpread = () => (
    - handleClaimYourFly('claim')}> + handleClaimYourFly("claim")} + > Claim your FLY - handleClaimYourFly('stake')}> + handleClaimYourFly("stake")} + > Stake your $FLY airdrop -
    ; +
    + ); // whether the popup staking modal was completed in a staking state - const [completedClaimStakeModal, setCompletedClaimStakeModal] = useState(false); + const [completedClaimStakeModal, setCompletedClaimStakeModal] = + useState(false); // called when someone completes the staking modal with a claim complete state. const handleClaimStakingModalComplete = () => { setCompletedClaimStakeModal(true); }; - const StakingStatsButton = () => + const StakingStatsButton = () => (
    - flyStakingModalToggleVisibility?.(true) }> + flyStakingModalToggleVisibility?.(true)}> Staking stats -
    ; +
    + ); const ButtonsSpread = () => completedClaimStakeModal ? : ; @@ -1924,16 +1946,23 @@ const RecapModal = ({
    - Congratulations! You are eligible to claim 25% of your tokens at TGE! + Congratulations! You are eligible to claim 25% of your tokens at + TGE! - $FLY {flyAmountOwed == 996699 ? "" : numberToCommaSeparated(flyAmountOwed)} + + $FLY{" "} + {flyAmountOwed == 996699 + ? "" + : numberToCommaSeparated(flyAmountOwed)} +
    @@ -2011,10 +2041,7 @@ const RecapModal = ({ return ( <> - +
    @@ -2026,66 +2053,76 @@ const RecapModal = ({

    - 1. Description - - We may offer you the opportunity to receive some digital assets at no cost (**Airdrop**), subject to the terms described in this section. The Airdrop is delivered by us to you, but may be manufactured, offered and supported by the network creator or developer, if any, and not by us. + 1. Description We may offer you the opportunity to receive some + digital assets at no cost (**Airdrop**), subject to the terms + described in this section. The Airdrop is delivered by us to you, + but may be manufactured, offered and supported by the network + creator or developer, if any, and not by us.

    - 1. Terms of Airdrop Program - - 2.1 No Purchase Necessary - - There is no purchase necessary to receive the Airdrop. However, you must have - wallets recognised and accepted by us. Although we do not charge a fee for participation in the Airdrop Program, we reserve the right to do so in the future and shall provide prior notice to you in such case. + 1. Terms of Airdrop Program 2.1 No Purchase Necessary There is no + purchase necessary to receive the Airdrop. However, you must have + wallets recognised and accepted by us. Although we do not charge a + fee for participation in the Airdrop Program, we reserve the right + to do so in the future and shall provide prior notice to you in + such case.

    - 2.2 Timing - - Each Airdrop may be subject to any additional terms and conditions and where applicable such terms and conditions shall be displayed and marked with an asterisk (*) or other similar notation. + 2.2 Timing Each Airdrop may be subject to any additional terms and + conditions and where applicable such terms and conditions shall be + displayed and marked with an asterisk (*) or other similar + notation.

    - 2.3Β Limited Supply - - An offer to receive the digital assets in an Airdrop is only available to you while supplies last. Once the amount of digital asset offered by us in an Airdrop is exhausted, any party who - has either been placed on a waitlist, or has completed certain additional steps, but not yet received notice of award of the asset in such Airdrop, shall no longer be eligible to receive the said digital assets in that Airdrop. We reserve the right, in our sole discretion, to modify or - suspend any Airdrop requirements at any time without notice, including the amount previously - advertised as available. + 2.3Β Limited Supply An offer to receive the digital assets in an + Airdrop is only available to you while supplies last. Once the + amount of digital asset offered by us in an Airdrop is exhausted, + any party who has either been placed on a waitlist, or has + completed certain additional steps, but not yet received notice of + award of the asset in such Airdrop, shall no longer be eligible to + receive the said digital assets in that Airdrop. We reserve the + right, in our sole discretion, to modify or suspend any Airdrop + requirements at any time without notice, including the amount + previously advertised as available.

    - 2.4Β Eligibility - - You may not be eligible to receive the digital assets or a select class and type of digital assets from an Airdrop in your jurisdiction. - - To the best of our understanding, below is a list of countries that does not recognise digital assets; - - *Afghanistan, Algeria, Egypt, Bangladesh, Bolivia, Burundi, Cameroon, Chad, China, Republic of Congo, Ethiopia, Gabon, Iraq, Lesotho, Libya, Macedonia, Morocco, Myanmar, Nepal, Qatar, Sierra Leone, Tunisia ** - - Kindly be advised that this list is for reference only and you are advised to seek independent legal advise as to your eligibility to receive the assets through Airdrop. - - **source - Library of Congress, Atlantic Council, Techopedia, Finder, Triple-A, Chainalysis* + 2.4Β Eligibility You may not be eligible to receive the digital + assets or a select class and type of digital assets from an + Airdrop in your jurisdiction. To the best of our understanding, + below is a list of countries that does not recognise digital + assets; *Afghanistan, Algeria, Egypt, Bangladesh, Bolivia, + Burundi, Cameroon, Chad, China, Republic of Congo, Ethiopia, + Gabon, Iraq, Lesotho, Libya, Macedonia, Morocco, Myanmar, Nepal, + Qatar, Sierra Leone, Tunisia ** Kindly be advised that this list + is for reference only and you are advised to seek independent + legal advise as to your eligibility to receive the assets through + Airdrop. **source - Library of Congress, Atlantic Council, + Techopedia, Finder, Triple-A, Chainalysis*

    - 2.5Β Notice of Award - - In the event you are selected to receive the digital asset in an Airdrop, we shall notify you of the pending delivery of such asset. Eligibility may be limited as to time. - We are not liable to you for failure to receive any notice associated with the Airdrop Program. + 2.5Β Notice of Award In the event you are selected to receive the + digital asset in an Airdrop, we shall notify you of the pending + delivery of such asset. Eligibility may be limited as to time. We + are not liable to you for failure to receive any notice associated + with the Airdrop Program.

    - 3 Risk Disclosures Relating to Airdrop Program - - You are solely responsible for researching and understanding the Fluid Assets token and it’s related utility and/or network subject to the Airdrop. + 3 Risk Disclosures Relating to Airdrop Program You are solely + responsible for researching and understanding the Fluid Assets + token and it’s related utility and/or network subject to the + Airdrop.

    - + setWalletModalVisibility(true)} flyAmount={flyAmountOwed} - visible={flyClaimModalState !== 'none'} - mode={flyClaimModalState === 'none' ? 'claim' : flyClaimModalState} + visible={flyClaimModalState !== "none"} + mode={flyClaimModalState === "none" ? "claim" : flyClaimModalState} accumulatedPoints={day1Points} - close={() => setFlyClaimModalState('none')} + close={() => setFlyClaimModalState("none")} onStakingComplete={handleClaimStakingModalComplete} onClaimComplete={handleClaimStakingModalComplete} /> @@ -2166,8 +2203,9 @@ const RecapModal = ({ {/* Animation */} {currentVideo === 0 ? (