Skip to content

Commit

Permalink
fix: v3 deposit vanilla
Browse files Browse the repository at this point in the history
  • Loading branch information
Majorfi committed Jan 15, 2024
1 parent ed50daa commit 21cd0bc
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 62 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# 0.3.7

- Fix: Disable the partnerContract for V3 vaults deposits. (15/01/2024)
- Feat: Add info tab in the vault details page. (11/01/2024)
- Fix: APR display on details for V3. (04/01/2024)
- Feat: Adding boosted property handling. (04/01/2024)
Expand Down
57 changes: 0 additions & 57 deletions apps/vaults-v3/components/details/actions/QuickActionsButtons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,9 @@ import {useWeb3} from '@yearn-finance/web-lib/contexts/useWeb3';
import {toAddress} from '@yearn-finance/web-lib/utils/address';
import {ETH_TOKEN_ADDRESS, MAX_UINT_256} from '@yearn-finance/web-lib/utils/constants';
import {toBigInt, toNormalizedBN} from '@yearn-finance/web-lib/utils/format.bigNumber';
import {isEth} from '@yearn-finance/web-lib/utils/isEth';
import {isZero} from '@yearn-finance/web-lib/utils/isZero';
import {defaultTxStatus} from '@yearn-finance/web-lib/utils/web3/transaction';
import {useWallet} from '@common/contexts/useWallet';
import {useYearn} from '@common/contexts/useYearn';
import {useAsyncTrigger} from '@common/hooks/useAsyncEffect';
import {Solver} from '@common/schemas/yDaemonTokenListBalances';

Expand All @@ -21,7 +19,6 @@ import type {TYDaemonVault} from '@common/schemas/yDaemonVaultsSchemas';
export function VaultDetailsQuickActionsButtons({currentVault}: {currentVault: TYDaemonVault}): ReactElement {
const {refresh} = useWallet();
const {address, provider} = useWeb3();
const {isStakingOpBoostedVaults} = useYearn();
const [txStatusApprove, set_txStatusApprove] = useState(defaultTxStatus);
const [txStatusExecuteDeposit, set_txStatusExecuteDeposit] = useState(defaultTxStatus);
const [txStatusExecuteWithdraw, set_txStatusExecuteWithdraw] = useState(defaultTxStatus);
Expand All @@ -37,7 +34,6 @@ export function VaultDetailsQuickActionsButtons({currentVault}: {currentVault: T
isLoadingExpectedOut,
hash
} = useSolver();
const isWithdrawing = !isDepositing;

/* 🔵 - Yearn Finance **************************************************************************
** SWR hook to get the expected out for a given in/out pair with a specific amount. This hook is
Expand Down Expand Up @@ -114,43 +110,6 @@ export function VaultDetailsQuickActionsButtons({currentVault}: {currentVault: T
** Wrapper to decide if we should use the partner contract or not
**************************************************************************/
const isAboveAllowance = toBigInt(actionParams.amount.raw) > toBigInt(allowanceFrom?.raw);

if (
isWithdrawing && //If user is withdrawing ...
currentSolver === Solver.enum.ChainCoin && // ... and the solver is ChainCoin ...
isEth(actionParams?.selectedOptionTo?.value) && // ... and the output is ETH ...
isAboveAllowance // ... and the amount is above the allowance
) {
// ... then we need to approve the ChainCoin contract
return (
<Button
variant={'v3'}
className={'w-full'}
isBusy={txStatusApprove.pending}
isDisabled={isButtonDisabled || isZero(expectedOut.raw)}
onClick={onApproveFrom}>
{'Approve'}
</Button>
);
}

if (
isDepositing && //If user is depositing ...
currentSolver === Solver.enum.ChainCoin // ... and the solver is ChainCoin ...
) {
// ... then we can deposit without approval
return (
<Button
variant={'v3'}
onClick={async (): Promise<void> => onExecuteDeposit(set_txStatusExecuteDeposit, onSuccess)}
className={'w-full'}
isBusy={txStatusExecuteDeposit.pending}
isDisabled={isButtonDisabled}>
{'Deposit'}
</Button>
);
}

if (
(txStatusApprove.pending || isAboveAllowance) && //If the button is busy or the amount is above the allowance ...
((isDepositing && currentSolver === Solver.enum.Vanilla) || // ... and the user is depositing with Vanilla ...
Expand All @@ -173,22 +132,6 @@ export function VaultDetailsQuickActionsButtons({currentVault}: {currentVault: T
}

if (isDepositing || currentSolver === Solver.enum.InternalMigration) {
if (currentSolver === Solver.enum.OptimismBooster && isStakingOpBoostedVaults) {
return (
<Button
variant={'v3'}
onClick={async (): Promise<void> => onExecuteDeposit(set_txStatusExecuteDeposit, onSuccess)}
className={'w-full whitespace-nowrap'}
isBusy={txStatusExecuteDeposit.pending}
isDisabled={
(!address && !provider) ||
isZero(actionParams.amount.raw) ||
toBigInt(actionParams.amount.raw) > toBigInt(maxDepositPossible.raw)
}>
{'Deposit and Stake'}
</Button>
);
}
return (
<Button
variant={'v3'}
Expand Down
10 changes: 6 additions & 4 deletions apps/vaults/contexts/useActionFlow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@ export function ActionFlowContextApp({
return Solver.enum.OptimismBooster;
}

const isV3 = currentVault?.version.split('.')?.[0] === '3';
const isInputTokenEth = isEth(actionParams?.selectedOptionFrom?.value);
const isOutputTokenEth = isEth(actionParams?.selectedOptionTo?.value);
const isVaultTokenWrappedCoin =
Expand All @@ -277,7 +278,7 @@ export function ActionFlowContextApp({
if (!isDepositing && (actionParams?.selectedOptionTo?.solveVia?.length || 0) > 0) {
return zapProvider;
}
if (isDepositing && isUsingPartnerContract) {
if (isDepositing && isUsingPartnerContract && !isV3) {
return Solver.enum.PartnerContract;
}
return Solver.enum.Vanilla;
Expand All @@ -287,11 +288,12 @@ export function ActionFlowContextApp({
actionParams?.selectedOptionTo?.value,
actionParams?.selectedOptionTo?.solveVia?.length,
currentVault.token.address,
currentVault.staking.available,
currentVault?.version,
currentVault.chainID,
currentVault.address,
currentVault.migration?.available,
currentVault.migration?.address,
currentVault.staking.available,
currentVault?.migration?.available,
currentVault?.migration?.address,
isStakingOpBoostedVaults,
isDepositing,
isUsingPartnerContract,
Expand Down
1 change: 0 additions & 1 deletion apps/vaults/contexts/useSolver.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,6 @@ export function WithSolverContextApp({children}: {children: React.ReactElement})
};

const solverPriority = [Solver.enum.Cowswap, Solver.enum.Portals, Solver.enum.None];

const newSolverPriority = [
currentSolver,
...solverPriority.filter((solver): boolean => solver !== currentSolver)
Expand Down

1 comment on commit 21cd0bc

@vercel
Copy link

@vercel vercel bot commented on 21cd0bc Jan 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.