Skip to content

Commit

Permalink
Merge branch 'develop' into feature/si-1557-rewards-history-with-addr…
Browse files Browse the repository at this point in the history
…ess-input-back
  • Loading branch information
solidovic authored Aug 20, 2024
2 parents f998796 + 33f9b8f commit b6cc5bd
Show file tree
Hide file tree
Showing 22 changed files with 284 additions and 49 deletions.
1 change: 1 addition & 0 deletions assets/dvv-banner/dvv-banner-lido-logo-dark.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions assets/dvv-banner/dvv-banner-lido-logo-light.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions assets/dvv-banner/dvv-banner-partners-logo-dark.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions assets/dvv-banner/dvv-banner-partners-logo-light.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 2 additions & 3 deletions config/groups/stake.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { BigNumber } from 'ethers';
import { parseEther } from '@ethersproject/units';
import { AddressZero } from '@ethersproject/constants';

import { StakeSwapDiscountIntegrationKey } from 'features/stake/swap-discount-banner';

Expand All @@ -26,11 +25,11 @@ export const STAKE_GASLIMIT_FALLBACK = BigNumber.from(
),
);

export const STAKE_WIDGET_METRIC_SUFFIX = '01';
export const LIDO_ADDRESS = '0x11D00000000000000000000000000000000011D0';

export const STAKE_FALLBACK_REFERRAL_ADDRESS = preConfig.ipfsMode
? IPFS_REFERRAL_ADDRESS
: AddressZero;
: LIDO_ADDRESS;

export const STAKE_SWAP_INTEGRATION: StakeSwapDiscountIntegrationKey =
'one-inch';
18 changes: 18 additions & 0 deletions consts/matomo-click-events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ export const enum MATOMO_CLICK_EVENTS_TYPES {
lidoOnLidoMultichainOpportunities = 'lidoOnLidoMultichainOpportunities',
vaultsBannerLearnMore = 'vaultsBannerLearnMore',
vaultsBannerExploreAll = 'vaultsBannerExploreAll',
obolBannerProceed = 'obolBannerProceed',
obolBannerDVVLink = 'obolBannerDVVLink',
exploreAllStrategiesAfterStake = 'exploreAllStrategiesAfterStake',
// FAQ
faqSafeWorkWithLidoAudits = 'faqSafeWorkWithLidoAudits',
faqLidoEthAprEthLandingPage = 'faqLidoEthAprEthLandingPage',
Expand Down Expand Up @@ -129,6 +132,21 @@ export const MATOMO_CLICK_EVENTS: Record<
'Push "Explore all strategies"',
'eth_widget_explore_all_strategies',
],
[MATOMO_CLICK_EVENTS_TYPES.obolBannerProceed]: [
'Ethereum_Staking_Widget',
'Push "Proceed" Obol SSV',
'eth_widget_proceed_obol_ssv',
],
[MATOMO_CLICK_EVENTS_TYPES.obolBannerDVVLink]: [
'Ethereum_Staking_Widget',
'Push "the DVV Vault" link on Obol SSV banner',
'eth_widget_the_dvv_vault_link_obol_ssv',
],
[MATOMO_CLICK_EVENTS_TYPES.exploreAllStrategiesAfterStake]: [
'Ethereum_Staking_Widget',
'Push "Explore all strategies" after staking',
'eth_widget_explore_all_strategies_after_staking',
],
// FAQ
[MATOMO_CLICK_EVENTS_TYPES.faqSafeWorkWithLidoAudits]: [
'Ethereum_Staking_Widget',
Expand Down
25 changes: 25 additions & 0 deletions features/stake/stake-form/hooks/use-tx-modal-stages-stake.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,17 @@ import {
} from 'shared/transaction-modal/hooks/use-transaction-modal-stage';
import { getGeneralTransactionModalStages } from 'shared/transaction-modal/hooks/get-general-transaction-modal-stages';

import { Button, Link } from '@lidofinance/lido-ui';
import { VaultsBannerInfo } from 'shared/banners/vaults-banner-info';
import { TxStageSignOperationAmount } from 'shared/transaction-modal/tx-stages-composed/tx-stage-amount-operation';
import { TxStageOperationSucceedBalanceShown } from 'shared/transaction-modal/tx-stages-composed/tx-stage-operation-succeed-balance-shown';

import type { BigNumber } from 'ethers';
import { trackEvent } from '@lidofinance/analytics-matomo';
import { MATOMO_CLICK_EVENTS } from 'consts/matomo-click-events';

const LINK_EXPLORE_STRATEGIES =
'https://lido.fi/?pk_vid=6c467e14095d5ea11723712888b1fe5f#defi-strategies';

const STAGE_OPERATION_ARGS = {
token: 'ETH',
Expand Down Expand Up @@ -45,6 +52,24 @@ const getTxModalStagesStake = (transitStage: TransactionModalTransitStage) => ({
balance={balance}
balanceToken={'stETH'}
operationText={'Staking'}
footer={
<>
<VaultsBannerInfo isTitleCompact showLearnMoreButton={false} />
<br />
<Link
href={LINK_EXPLORE_STRATEGIES}
onClick={() =>
trackEvent(
...MATOMO_CLICK_EVENTS.exploreAllStrategiesAfterStake,
)
}
>
<Button fullwidth size="sm">
Explore strategies
</Button>
</Link>
</>
}
/>,
{
isClosableOnLedger: true,
Expand Down
4 changes: 2 additions & 2 deletions features/stake/stake-form/stake-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { StakeSubmitButton } from './controls/stake-submit-button';
import { StakeFormInfo } from './stake-form-info';
import { SwapDiscountBanner } from '../swap-discount-banner';
import { StakeBlock, FormControllerStyled } from './styles';
import { VaultsBannerInfo } from 'shared/banners/vaults-banner-info';
import { DVVBanner } from 'shared/banners/dvv-banner';

export const StakeForm: FC = memo(() => {
return (
Expand All @@ -19,7 +19,7 @@ export const StakeForm: FC = memo(() => {
<StakeAmountInput />
<StakeSubmitButton />
<SwapDiscountBanner>
<VaultsBannerInfo />
<DVVBanner />
</SwapDiscountBanner>
</FormControllerStyled>
<StakeFormInfo />
Expand Down
13 changes: 2 additions & 11 deletions features/stake/stake-form/use-stake.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,7 @@ import { useCurrentStaticRpcProvider } from 'shared/hooks/use-current-static-rpc
import { isContract } from 'utils/isContract';
import { runWithTransactionLogger } from 'utils';

import {
MockLimitReachedError,
getAddress,
applyCalldataSuffix,
} from './utils';
import { MockLimitReachedError, getAddress } from './utils';
import { useTxModalStagesStake } from './hooks/use-tx-modal-stages-stake';

import { sendTx } from 'utils/send-tx';
Expand All @@ -41,9 +37,6 @@ export const useStake = ({ onConfirm, onRetry }: StakeOptions) => {
const { providerWeb3 } = useSDK();
const { txModalStages } = useTxModalStagesStake();

// temporary disable until Ledger is fixed
const shouldApplyCalldataSuffix = false;

return useCallback(
async ({ amount, referral }: StakeArguments): Promise<boolean> => {
try {
Expand Down Expand Up @@ -77,14 +70,13 @@ export const useStake = ({ onConfirm, onRetry }: StakeOptions) => {
},
);

if (shouldApplyCalldataSuffix) applyCalldataSuffix(tx);

return sendTx({
tx,
isMultisig,
staticProvider: staticRpcProvider,
walletProvider: providerWeb3,
shouldApplyGasLimitRatio: true,
shouldRoundUpGasLimit: true,
});
};

Expand Down Expand Up @@ -128,7 +120,6 @@ export const useStake = ({ onConfirm, onRetry }: StakeOptions) => {
staticRpcProvider,
stethContract,
onConfirm,
shouldApplyCalldataSuffix,
onRetry,
],
);
Expand Down
13 changes: 0 additions & 13 deletions features/stake/stake-form/utils.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
import type { PopulatedTransaction } from 'ethers';
import { isAddress } from 'ethers/lib/utils';
import type { BaseProvider } from '@ethersproject/providers';

import { config } from 'config';
import invariant from 'tiny-invariant';

export const getAddress = async (
input: string,
providerRpc: BaseProvider,
Expand All @@ -20,15 +16,6 @@ export const getAddress = async (
throw new ReferralAddressError();
};

// adds metrics indicator for widget tx
export const applyCalldataSuffix = (tx: PopulatedTransaction) => {
if (!config.ipfsMode) {
invariant(tx.data, 'transaction must have calldata');
tx.data = tx.data + config.STAKE_WIDGET_METRIC_SUFFIX;
}
return tx;
};

export class ReferralAddressError extends Error {
reason: string;
constructor() {
Expand Down
2 changes: 2 additions & 0 deletions features/wsteth/unwrap/hooks/use-tx-modal-stages-unwrap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
} from 'shared/transaction-modal/hooks/use-transaction-modal-stage';
import { getGeneralTransactionModalStages } from 'shared/transaction-modal/hooks/get-general-transaction-modal-stages';

import { VaultsBannerStrategies } from 'shared/banners/vaults-banner-strategies';
import { TxStageSignOperationAmount } from 'shared/transaction-modal/tx-stages-composed/tx-stage-amount-operation';
import { TxStageOperationSucceedBalanceShown } from 'shared/transaction-modal/tx-stages-composed/tx-stage-operation-succeed-balance-shown';

Expand Down Expand Up @@ -47,6 +48,7 @@ const getTxModalStagesUnwrap = (
balance={balance}
balanceToken={STAGE_OPERATION_ARGS.willReceiveToken}
operationText={'Unwrapping'}
footer={<VaultsBannerStrategies />}
/>,
{
isClosableOnLedger: true,
Expand Down
Loading

0 comments on commit b6cc5bd

Please sign in to comment.