Skip to content

Commit

Permalink
SOV-3560: disable permit functionality (#705)
Browse files Browse the repository at this point in the history
* feat: remoeve permits from MOC integration smart route

* Revert "feat: remoeve permits from MOC integration smart route"

This reverts commit f17de1b.

* feat: disable eip 2612

* fix: allow borrowing dllr

* fix: debt token

* fix: remove unsuded props

* chore: add changeset

---------

Co-authored-by: soulBit <[email protected]>
  • Loading branch information
creed-victor and soulBit authored Dec 12, 2023
1 parent 1d44cce commit 4b90146
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 26 deletions.
5 changes: 5 additions & 0 deletions .changeset/healthy-cougars-help.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"frontend": patch
---

SOV-3560: disable permit functionality for DLLR
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export const CloseCreditLine: FC<CloseCreditLineProps> = ({
}) => {
const { isRecoveryMode } = useZeroData(rbtcPrice);
const [creditToken, setCreditToken] = useState<SupportedTokens>(
SupportedTokens.dllr,
SupportedTokens.zusd,
);

const { checkMaintenance, States } = useMaintenance();
Expand Down Expand Up @@ -89,7 +89,7 @@ export const CloseCreditLine: FC<CloseCreditLineProps> = ({

const tokenOptions = useMemo(
() =>
[SupportedTokens.zusd, SupportedTokens.dllr].map(token => ({
[SupportedTokens.zusd /*, SupportedTokens.dllr*/].map(token => ({
value: token,
label: (
<AssetRenderer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { SupportedTokens } from '@sovryn/contracts';
import { ErrorLevel } from '@sovryn/ui';
import { Decimal } from '@sovryn/utils';

import { BORROW_ASSETS } from '../../../5_pages/ZeroPage/constants';
import { useLiquityBaseParams } from '../../../5_pages/ZeroPage/hooks/useLiquityBaseParams';
import {
BITCOIN,
Expand Down Expand Up @@ -62,7 +61,9 @@ export const AdjustCreditLine: FC<AdjustCreditLineProps> = ({
const [collateralAmountInput, setCollateralAmount, collateralAmount] =
useAmountInput('');
const [debtAmountInput, setDebtAmount, debtAmount] = useAmountInput('');
const [debtToken, setDebtToken] = useState<SupportedTokens>(BORROW_ASSETS[0]);
const [debtToken, setDebtToken] = useState<SupportedTokens>(
SupportedTokens.zusd,
);
const [maxOriginationFeeRate, setMaxOriginationFeeRate] = useState('0');

const debtSize = useMemo(() => decimalic(debtAmount), [debtAmount]);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useCallback, useMemo, FC, useState } from 'react';
import React, { useCallback, useMemo, FC, useState, useEffect } from 'react';

import { t } from 'i18next';
import { Trans } from 'react-i18next';
Expand Down Expand Up @@ -26,7 +26,10 @@ import { Decimal } from '@sovryn/utils';
import { AdvancedSettings } from '../../../2_molecules/AdvancedSettings/AdvancedSettings';
import { AmountRenderer } from '../../../2_molecules/AmountRenderer/AmountRenderer';
import { AssetRenderer } from '../../../2_molecules/AssetRenderer/AssetRenderer';
import { BORROW_ASSETS } from '../../../5_pages/ZeroPage/constants';
import {
BORROW_ASSETS,
REPAYMENT_ASSETS,
} from '../../../5_pages/ZeroPage/constants';
import { useLiquityBaseParams } from '../../../5_pages/ZeroPage/hooks/useLiquityBaseParams';
import {
BITCOIN,
Expand Down Expand Up @@ -345,7 +348,10 @@ export const FormContent: FC<FormContentProps> = props => {

const tokenOptions = useMemo(
() =>
BORROW_ASSETS.map(token => ({
(props.hasTrove && props.debtType === AmountType.Remove
? REPAYMENT_ASSETS
: BORROW_ASSETS
).map(token => ({
value: token,
label: (
<AssetRenderer
Expand All @@ -355,9 +361,15 @@ export const FormContent: FC<FormContentProps> = props => {
/>
),
})),
[],
[props],
);

useEffect(() => {
if (props.hasTrove && props.debtType === AmountType.Remove) {
props.onDebtTokenChange(REPAYMENT_ASSETS[0]);
}
}, [props]);

return (
<div className="w-full">
{props.hasTrove && (
Expand Down
11 changes: 9 additions & 2 deletions apps/frontend/src/app/5_pages/ConvertPage/ConvertPage.types.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
import { SupportedTokens } from '@sovryn/contracts';
import { getProvider } from '@sovryn/ethers-provider';
import { DEFAULT_SWAP_ROUTES, SmartRouter } from '@sovryn/sdk';
import { SmartRouter, smartRoutes } from '@sovryn/sdk';

const provider = getProvider();

export const smartRouter = new SmartRouter(provider, DEFAULT_SWAP_ROUTES);
const SWAP_ROUTES = [
smartRoutes.ammSwapRoute,
smartRoutes.myntBassetRoute,
smartRoutes.myntFixedRateRoute,
// smartRoutes.mocIntegrationSwapRoute,
];

export const smartRouter = new SmartRouter(provider, SWAP_ROUTES);

export const stableCoins = [
SupportedTokens.zusd,
Expand Down
31 changes: 16 additions & 15 deletions apps/frontend/src/app/5_pages/EarnPage/EarnPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ const EarnPage: FC = () => {
const [poolBalance, setPoolBalance] = useState(Decimal.ZERO);
const [ZUSDInStabilityPool, setZUSDInStabilityPool] = useState(Decimal.ZERO);
const [rewardsAmount, setRewardsAmount] = useState(Decimal.ZERO);
const [token, setToken] = useState<SupportedTokens>(SupportedTokens.dllr);
const [token, setToken] = useState<SupportedTokens>(SupportedTokens.zusd);
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const [isLoading, setIsLoading] = useState(false);
const { apy } = useGetSubsidiesAPR();

Expand Down Expand Up @@ -176,20 +177,20 @@ const EarnPage: FC = () => {
[setAmount],
);

const { weiBalance: zusdWeiBalance } = useAssetBalance(SupportedTokens.zusd);
const { weiBalance: dllrWeiBalance } = useAssetBalance(SupportedTokens.dllr);

useEffect(() => {
if (
isDeposit &&
Number(zusdWeiBalance) > 0 &&
Number(dllrWeiBalance) === 0
) {
setToken(SupportedTokens.zusd);
} else {
setToken(SupportedTokens.dllr);
}
}, [dllrWeiBalance, zusdWeiBalance, isDeposit, isLoading]);
// const { weiBalance: zusdWeiBalance } = useAssetBalance(SupportedTokens.zusd);
// const { weiBalance: dllrWeiBalance } = useAssetBalance(SupportedTokens.dllr);

// useEffect(() => {
// if (
// isDeposit &&
// Number(zusdWeiBalance) > 0 &&
// Number(dllrWeiBalance) === 0
// ) {
// setToken(SupportedTokens.zusd);
// } else {
// setToken(SupportedTokens.dllr);
// }
// }, [dllrWeiBalance, zusdWeiBalance, isDeposit, isLoading]);

const getAssetRenderer = useCallback(
(token: SupportedTokens) => (
Expand Down
2 changes: 1 addition & 1 deletion apps/frontend/src/app/5_pages/EarnPage/EarnPage.types.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { TokenBaseInfo } from '@sovryn/contracts';
import { SupportedTokenList, SupportedTokens } from '@sovryn/contracts';

const allowedTokens = [SupportedTokens.zusd, SupportedTokens.dllr];
const allowedTokens = [SupportedTokens.zusd /*, SupportedTokens.dllr*/];

export const tokenList: TokenBaseInfo[] = SupportedTokenList.filter(item =>
allowedTokens.includes(item.symbol),
Expand Down
1 change: 1 addition & 0 deletions apps/frontend/src/app/5_pages/ZeroPage/constants.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { SupportedTokens } from '@sovryn/contracts';

export const BORROW_ASSETS = [SupportedTokens.dllr, SupportedTokens.zusd];
export const REPAYMENT_ASSETS = [SupportedTokens.zusd];

0 comments on commit 4b90146

Please sign in to comment.