diff --git a/apps/vaults-v3/components/details/VaultActionsTabsWrapper.tsx b/apps/vaults-v3/components/details/VaultActionsTabsWrapper.tsx index b4419563..288de13f 100755 --- a/apps/vaults-v3/components/details/VaultActionsTabsWrapper.tsx +++ b/apps/vaults-v3/components/details/VaultActionsTabsWrapper.tsx @@ -361,14 +361,26 @@ export function VaultActionsTabsWrapper({currentVault}: {currentVault: TYDaemonV } }, [currentVault?.migration?.available, currentVault?.info?.isRetired, actionParams.isReady, hasStakingRewards]); + /************************************************************************************************ + * This effect manages the auto-staking feature based on staking rewards availability. + * It disables auto-staking if there are no staking rewards and the last reward ended over a week ago. + * Otherwise, it enables auto-staking. + * + * The check for rewards ending over a week ago helps prevent unnecessary auto-staking + * for vaults with expired or long-inactive staking programs. + ************************************************************************************************/ useEffect(() => { - const finishedAt = 1729022801; // temporary value - if (!hasStakingRewardsLive && Math.floor(Date.now() / 1000) - finishedAt > 60 * 60 * 24 * 7) { + if ( + !hasStakingRewards && + currentVault.staking.rewards?.some( + el => Math.floor(Date.now() / 1000) - (el.finishedAt ?? 0) > 60 * 60 * 24 * 7 + ) + ) { set_isAutoStakingEnabled(false); return; } set_isAutoStakingEnabled(true); - }, [hasStakingRewardsLive, set_isAutoStakingEnabled]); + }, [currentVault.staking.rewards, hasStakingRewards, hasStakingRewardsLive, set_isAutoStakingEnabled]); const isSonneRetiredVault = toAddress(currentVault.address) === toAddress(`0x5b977577eb8a480f63e11fc615d6753adb8652ae`) || diff --git a/bun.lockb b/bun.lockb new file mode 100755 index 00000000..57ae2875 Binary files /dev/null and b/bun.lockb differ diff --git a/package.json b/package.json index 36962006..b8691e36 100644 --- a/package.json +++ b/package.json @@ -1,87 +1,87 @@ { - "name": "yearnfi", - "version": "0.3.7", - "scripts": { - "dev": "next", - "inspect": "NODE_OPTIONS='--inspect' next", - "dev:ts": "tsc --watch", - "start": "tsc && next build && next start", - "build": "tsc && next build", - "export": "tsc && next build && next export -o ipfs", - "lint": "eslint . --ext .js,.jsx,.ts,.tsx", - "prettier": "prettier --check \"./**/**/*.{json,js,ts,tsx,scss}\"", - "prettier-format": "prettier --config .prettierrc \"./**/**/*.{json,js,ts,tsx,scss,md}\" --write", - "tslint": "tsc -p tsconfig.json --noEmit", - "bump": "bump", - "test": "vitest run" - }, - "dependencies": { - "@builtbymom/web3": "0.0.202", - "@cowprotocol/cow-sdk": "2.1.0", - "@headlessui/react": "^2.0.4", - "@rainbow-me/rainbowkit": "2.1.3", - "@tailwindcss/typography": "^0.5.13", - "@tanstack/react-query": "^5.51.11", - "@wagmi/core": "^2.11.7", - "@yearn-finance/web-lib": "^4.1.3", - "axios": "^1.7.2", - "ethers": "5.7.2", - "framer-motion": "^11.2.10", - "graphql": "^16.8.2", - "graphql-request": "^7.0.1", - "next": "^14.2.5", - "next-plausible": "^3.12.0", - "next-pwa": "^5.6.0", - "nprogress": "^0.2.0", - "react": "^18.3.1", - "react-dom": "^18.3.1", - "react-paginate": "^8.2.0", - "recharts": "^2.12.7", - "swr": "^2.2.5", - "viem": "2.17.3", - "vite": "^5.2.13", - "wagmi": "2.10.10", - "xxhashjs": "^0.2.2", - "zod": "^3.23.8" - }, - "devDependencies": { - "@next/bundle-analyzer": "^14.2.4", - "@next/eslint-plugin-next": "^14.2.4", - "@testing-library/react": "^16.0.0", - "@types/node": "^20.14.2", - "@types/react": "^18.3.3", - "@types/react-dom": "^18.3.0", - "@typescript-eslint/eslint-plugin": "^7.13.0", - "@typescript-eslint/parser": "^7.13.0", - "@vitejs/plugin-react": "^4.3.1", - "autoprefixer": "^10.4.19", - "babel-loader": "^9.1.3", - "bump": "^0.2.5", - "eslint": "^8.57.0", - "eslint-config-next": "^14.2.4", - "eslint-config-prettier": "^9.1.0", - "eslint-import-resolver-typescript": "^3.6.1", - "eslint-plugin-brackets": "^0.1.3", - "eslint-plugin-import": "^2.29.1", - "eslint-plugin-react": "^7.34.2", - "eslint-plugin-react-hooks": "^4.6.2", - "eslint-plugin-simple-import-sort": "^12.1.0", - "eslint-plugin-tailwindcss": "^3.17.3", - "eslint-plugin-unused-imports": "^4.0.0", - "husky": "^9.0.11", - "lint-staged": "^15.2.7", - "next-transpile-modules": "^10.0.1", - "postcss": "^8.4.38", - "postcss-import": "^16.1.0", - "postcss-nesting": "^12.1.5", - "prettier": "^3.3.2", - "sass": "^1.77.5", - "stylelint": "^16.6.1", - "stylelint-config-standard": "^36.0.0", - "tailwindcss": "^3.4.4", - "ts-loader": "^9.5.1", - "typescript": "^5.5.3", - "vitest": "^1.6.0", - "webpack": "^5.92.1" - } + "name": "yearnfi", + "version": "0.3.7", + "scripts": { + "dev": "next", + "inspect": "NODE_OPTIONS='--inspect' next", + "dev:ts": "tsc --watch", + "start": "tsc && next build && next start", + "build": "tsc && next build", + "export": "tsc && next build && next export -o ipfs", + "lint": "eslint . --ext .js,.jsx,.ts,.tsx", + "prettier": "prettier --check \"./**/**/*.{json,js,ts,tsx,scss}\"", + "prettier-format": "prettier --config .prettierrc \"./**/**/*.{json,js,ts,tsx,scss,md}\" --write", + "tslint": "tsc -p tsconfig.json --noEmit", + "bump": "bump", + "test": "vitest run" + }, + "dependencies": { + "@builtbymom/web3": "0.0.202", + "@cowprotocol/cow-sdk": "2.1.0", + "@headlessui/react": "^2.0.4", + "@rainbow-me/rainbowkit": "2.1.3", + "@tailwindcss/typography": "^0.5.13", + "@tanstack/react-query": "^5.51.11", + "@wagmi/core": "^2.11.7", + "@yearn-finance/web-lib": "^4.1.4", + "axios": "^1.7.2", + "ethers": "5.7.2", + "framer-motion": "^11.2.10", + "graphql": "^16.8.2", + "graphql-request": "^7.0.1", + "next": "^14.2.5", + "next-plausible": "^3.12.0", + "next-pwa": "^5.6.0", + "nprogress": "^0.2.0", + "react": "^18.3.1", + "react-dom": "^18.3.1", + "react-paginate": "^8.2.0", + "recharts": "^2.12.7", + "swr": "^2.2.5", + "viem": "2.17.3", + "vite": "^5.2.13", + "wagmi": "2.10.10", + "xxhashjs": "^0.2.2", + "zod": "^3.23.8" + }, + "devDependencies": { + "@next/bundle-analyzer": "^14.2.4", + "@next/eslint-plugin-next": "^14.2.4", + "@testing-library/react": "^16.0.0", + "@types/node": "^20.14.2", + "@types/react": "^18.3.3", + "@types/react-dom": "^18.3.0", + "@typescript-eslint/eslint-plugin": "^7.13.0", + "@typescript-eslint/parser": "^7.13.0", + "@vitejs/plugin-react": "^4.3.1", + "autoprefixer": "^10.4.19", + "babel-loader": "^9.1.3", + "bump": "^0.2.5", + "eslint": "^8.57.0", + "eslint-config-next": "^14.2.4", + "eslint-config-prettier": "^9.1.0", + "eslint-import-resolver-typescript": "^3.6.1", + "eslint-plugin-brackets": "^0.1.3", + "eslint-plugin-import": "^2.29.1", + "eslint-plugin-react": "^7.34.2", + "eslint-plugin-react-hooks": "^4.6.2", + "eslint-plugin-simple-import-sort": "^12.1.0", + "eslint-plugin-tailwindcss": "^3.17.3", + "eslint-plugin-unused-imports": "^4.0.0", + "husky": "^9.0.11", + "lint-staged": "^15.2.7", + "next-transpile-modules": "^10.0.1", + "postcss": "^8.4.38", + "postcss-import": "^16.1.0", + "postcss-nesting": "^12.1.5", + "prettier": "^3.3.2", + "sass": "^1.77.5", + "stylelint": "^16.6.1", + "stylelint-config-standard": "^36.0.0", + "tailwindcss": "^3.4.4", + "ts-loader": "^9.5.1", + "typescript": "^5.5.3", + "vitest": "^1.6.0", + "webpack": "^5.92.1" + } }