Skip to content

Commit

Permalink
Merge branch 'main' into feat/token-wrapping
Browse files Browse the repository at this point in the history
  • Loading branch information
grothem committed Feb 23, 2024
2 parents c5bd0c9 + f53c47c commit 4598b7d
Show file tree
Hide file tree
Showing 40 changed files with 403 additions and 288 deletions.
2 changes: 1 addition & 1 deletion cypress/e2e/4-gho-ethereum/gho-modal.gho-v3.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const testData = {

let minApy: number;
let maxApy: number;
//skip while borrow limit

describe.skip(`GHO MODAL APY TESTING`, () => {
configEnvWithTenderlyAEthereumV3Fork({
v3: true,
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
"graphql-request": "^6.1.0",
"gray-matter": "^4.0.3",
"immer": "^9.0.15",
"micro-memoize": "^4.1.2",
"mixpanel-browser": "^2.45.0",
"next": "12.1.1",
"react": "latest",
Expand Down
16 changes: 8 additions & 8 deletions pages/_app.page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,10 @@ export default function MyApp(props: MyAppProps) {
<AddressBlocked>
<PermissionProvider>
<ModalContextProvider>
<BackgroundDataProvider>
<AppDataProvider>
<GasStationProvider>
<SharedDependenciesProvider>
<SharedDependenciesProvider>
<BackgroundDataProvider>
<AppDataProvider>
<GasStationProvider>
{getLayout(<Component {...pageProps} />)}
<SupplyModal />
<WithdrawModal />
Expand All @@ -165,10 +165,10 @@ export default function MyApp(props: MyAppProps) {
<TransactionEventHandler />
<SwitchModal />
<StakingMigrateModal />
</SharedDependenciesProvider>
</GasStationProvider>
</AppDataProvider>
</BackgroundDataProvider>
</GasStationProvider>
</AppDataProvider>
</BackgroundDataProvider>
</SharedDependenciesProvider>
</ModalContextProvider>
</PermissionProvider>
</AddressBlocked>
Expand Down
2 changes: 1 addition & 1 deletion public/icons/networks/metis.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion public/icons/tokens/metis.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions src/components/transactions/Borrow/BorrowActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export const BorrowActions = React.memo(
setLoadingTxns,
setApprovalTxState,
} = useModalContext();
const { refetchPoolData, refetchIncentiveData, refetchGhoData } = useBackgroundDataProvider();
const { refetchPoolData, refetchIncentiveData } = useBackgroundDataProvider();
const { sendTx } = useWeb3Context();
const [requiresApproval, setRequiresApproval] = useState<boolean>(false);
const [approvedAmount, setApprovedAmount] = useState<ApproveDelegationType | undefined>();
Expand Down Expand Up @@ -135,9 +135,9 @@ export const BorrowActions = React.memo(
});

queryClient.invalidateQueries({ queryKey: queryKeysFactory.pool });
queryClient.invalidateQueries({ queryKey: queryKeysFactory.gho });
refetchPoolData && refetchPoolData();
refetchIncentiveData && refetchIncentiveData();
refetchGhoData && refetchGhoData();
} catch (error) {
const parsedError = getErrorTextFromError(error, TxAction.GAS_ESTIMATION, false);
setTxError(parsedError);
Expand Down
3 changes: 2 additions & 1 deletion src/components/transactions/Borrow/BorrowModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import React, { useState } from 'react';
import { ModalContextType, ModalType, useModalContext } from 'src/hooks/useModal';
import { useProtocolDataContext } from 'src/hooks/useProtocolDataContext';
import { useRootStore } from 'src/store/root';
import { displayGho } from 'src/utils/ghoUtilities';
import { GENERAL } from 'src/utils/mixPanelEvents';

import { BasicModal } from '../../primitives/BasicModal';
Expand All @@ -18,7 +19,7 @@ export const BorrowModal = () => {
const { currentMarket } = useProtocolDataContext();

const [borrowUnWrapped, setBorrowUnWrapped] = useState(true);
const [trackEvent, displayGho] = useRootStore((store) => [store.trackEvent, store.displayGho]);
const [trackEvent] = useRootStore((store) => [store.trackEvent]);

const handleBorrowUnwrapped = (borrowUnWrapped: boolean) => {
trackEvent(GENERAL.OPEN_MODAL, {
Expand Down
19 changes: 12 additions & 7 deletions src/components/transactions/Borrow/GhoBorrowModalContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,14 @@ import { Row } from 'src/components/primitives/Row';
import { StyledTxModalToggleButton } from 'src/components/StyledToggleButton';
import { StyledTxModalToggleGroup } from 'src/components/StyledToggleButtonGroup';
import { useAppDataContext } from 'src/hooks/app-data-provider/useAppDataProvider';
import { useGhoPoolReserve } from 'src/hooks/pool/useGhoPoolReserve';
import { useUserGhoPoolReserve } from 'src/hooks/pool/useUserGhoPoolReserve';
import { useAssetCaps } from 'src/hooks/useAssetCaps';
import { useModalContext } from 'src/hooks/useModal';
import { useProtocolDataContext } from 'src/hooks/useProtocolDataContext';
import { useRootStore } from 'src/store/root';
import { CustomMarket } from 'src/ui-config/marketsConfig';
import { getMaxGhoMintAmount } from 'src/utils/getMaxAmountAvailableToBorrow';
import { weightedAverageAPY } from 'src/utils/ghoUtilities';
import { ghoUserQualifiesForDiscount, weightedAverageAPY } from 'src/utils/ghoUtilities';
import { roundToTokenDecimals } from 'src/utils/utils';

import { CapType } from '../../caps/helper';
Expand Down Expand Up @@ -113,13 +114,14 @@ export const GhoBorrowModalContent = ({
symbol,
}: ModalWrapperProps) => {
const { mainTxState: borrowTxState, gasLimit, txError, close: closeModal } = useModalContext();
const currentMarketData = useRootStore((state) => state.currentMarketData);
const currentMarket = useRootStore((state) => state.currentMarket);
const { user, marketReferencePriceInUsd, ghoReserveData, ghoUserData, ghoLoadingData } =
useAppDataContext();
const ghoUserQualifiesForDiscount = useRootStore((state) => state.ghoUserQualifiesForDiscount);
const { data: _ghoUserData } = useUserGhoPoolReserve(currentMarketData);
const { data: _ghoReserveData } = useGhoPoolReserve(currentMarketData);
const { borrowCap } = useAssetCaps();

const { currentMarket: customMarket } = useProtocolDataContext();

const [interestRateMode, setInterestRateMode] = useState<InterestRate>(InterestRate.Variable);
const [amount, setAmount] = useState('');
const [riskCheckboxAccepted, setRiskCheckboxAccepted] = useState(false);
Expand All @@ -128,7 +130,10 @@ export const GhoBorrowModalContent = ({
// Check if user can borrow at a discount
const hasGhoBorrowPositions = ghoUserData.userGhoBorrowBalance > 0;
const userStakedAaveBalance: number = ghoUserData.userDiscountTokenBalance;
const discountAvailable = ghoUserQualifiesForDiscount(amount);
const discountAvailable =
_ghoUserData && _ghoReserveData
? ghoUserQualifiesForDiscount(_ghoReserveData, _ghoUserData, amount)
: false;

// amount calculations
let maxAmountToBorrow = getMaxGhoMintAmount(user, poolReserve);
Expand Down Expand Up @@ -298,7 +303,7 @@ export const GhoBorrowModalContent = ({
discountAvailable={discountAvailable}
userDiscountTokenBalance={ghoUserData.userDiscountTokenBalance}
underlyingAsset={underlyingAsset}
customMarket={customMarket}
customMarket={currentMarket}
currentBorrowAPY={currentBorrowAPY}
futureBorrowAPY={futureBorrowAPY}
onDetailsClick={() => closeModal()}
Expand Down
4 changes: 2 additions & 2 deletions src/components/transactions/DebtSwitch/DebtSwitchActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ export const DebtSwitchActions = ({
setApprovalTxState,
} = useModalContext();
const { sendTx, signTxData } = useWeb3Context();
const { refetchPoolData, refetchIncentiveData, refetchGhoData } = useBackgroundDataProvider();
const { refetchPoolData, refetchIncentiveData } = useBackgroundDataProvider();
const [requiresApproval, setRequiresApproval] = useState<boolean>(false);
const [approvedAmount, setApprovedAmount] = useState<ApproveDelegationType | undefined>();
const [useSignature, setUseSignature] = useState(false);
Expand Down Expand Up @@ -202,7 +202,7 @@ export const DebtSwitchActions = ({
});

queryClient.invalidateQueries({ queryKey: queryKeysFactory.pool });
refetchGhoData && refetchGhoData();
queryClient.invalidateQueries({ queryKey: queryKeysFactory.gho });
refetchPoolData && refetchPoolData();
refetchIncentiveData && refetchIncentiveData();
} catch (error) {
Expand Down
Loading

0 comments on commit 4598b7d

Please sign in to comment.