Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Add the 'useNetwork' hook of wagmi #224

Merged
merged 2 commits into from
Jul 27, 2023
Merged

Conversation

Itzabelli
Copy link
Collaborator

Description

The purpose of this PR is to follow up recommendations made by the team. Where it is suggested to use the useNetwork hook available in wagmi instead the local hook.

Related Issue

Requested changes:
#214 (review)

Motivation and Context

The motivation to apply this change on top of reducing the code, is to seize the utilities available in wagmi.

How Has This Been Tested?

After making the changes I ran yarn dev and confirmed that everything appeared as expected.

Resources:

N/A

@vercel
Copy link

vercel bot commented Jul 27, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
ape-tax ❌ Failed (Inspect) Jul 27, 2023 9:47am

@Itzabelli Itzabelli requested a review from 0xMirim July 27, 2023 01:12
Feel like lint rules might not be being properly enforced...made note to check
Copy link
Contributor

@0xMirim 0xMirim left a comment

Choose a reason for hiding this comment

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

Nice work! I made a few minor adjustments...these should have been caught by our linting...so I will check if that is still working properly.

@0xMirim 0xMirim merged commit 2b643ce into feat/v3-new Jul 27, 2023
1 check passed
@0xMirim 0xMirim deleted the import-wagmi-hook branch July 27, 2023 09:49
0xMirim added a commit that referenced this pull request Aug 28, 2023
* feat: Add necessary env vars for V3 integration

* feat: Expand envs to include avalanche

* refactor: Add allowanceYRouter attr to TVaultData

* feat: Add V3 ABIs (router and vaults)

* feat: expand network specific logic to include avalanche

* feat: Add experimental V3 vault

* fix: pass metamask configuredChains to solve connector issues

* chore: Update web-lib

Allows us to remove IFrameEthereum connector without error

* refactor: Remove unnecessary connector now that web-lib allows it

* feat: Update VaultWrapper to handle V3 vaults

while remaining backwards compatible with v2

* refactor: Improve logic and error handling for fetching stategies

* chore: remove env used for testing

* feat: Begin V3 actions implementation (withdrawWithPermit)

* feat: Begin VaultActions UI implementation

* feat: V3 actions - depositERC20

* feat: VaultActions UI - VaultActionsApeIn

* fix: Adjust function order to properly separate V2 and V3 flows

* chore: Remove testing values

* chore: add address for testing YRouter on locally chain fork

* feat: Add V3 USDC vault - polygon

* fix: Add missing arg to balanceOf call

* fix: Remove avalanche config

* chore: Update web-lib version

Bringing changes to improve ape tax dev experience

* feat: VaultAction V3 migration progress

Updated UI and logic

* feat: Finish VaultActions V3 migration

* refactor: Bring back ape function...for the culture... eliminate unnecessary functions

* feat: Add statusHandlers to allow updates to UI during vault actions

* fix: Adjust condition to exclude removed env var

* chore: Add the 'useNetwork' hook of wagmi (#224)

* chore: Add the 'useNetwork' hook of wagmi

* refactor: Add semicolons, remove unnecessary spaces

Feel like lint rules might not be being properly enforced...made note to check

---------

Co-authored-by: 0xMirim <95051992+0xMirim@users.noreply.github.com>

* chore: remove comment

* refactor: Remove unnecessary file

No longer required after removal of local useChain hook

* feat: Moving chain specific details to new wagmiChains file (#225)

* refactor: Remove isApproving in favor of statusHandler

* fix: Adding allowanceYRouter data to vault data for proper UI update

* feat: Progress on withdrawWithPermitERC20

* refactor: Add no connector check, remove comment

* fix: Resolve linting issues by updating related dependencies

* fix: linting issues solved by running lintfix

* feat: Progress on V3 deposit and withdraw functions

* fix: Resolve lint errors in withdrawERC20WithPermit

* fix: Resolve deposit bug by handle case of extra approve on first vault interaction

* feat: Add zod for better type validation

* feat: Add zod schema

* refactor: Remove unused type

* refactor: Comment unused function, removed older commented function

* feat: Add fetch util and hook for improved data fetching

* refactor: Update block timestamp util to use zod and new fetch util

* refactor: Update calls to fetchBlockTimestamp util after changes

* refactor: Increase readability of api endpoint using URLSearchParams object

* fix: strategies not populating correctly due to call to meta yearn api (down)

* fix: Add accurate types to resolve "any" type errors

* refactor: Removed unnecessary function, comment currently unused function

This should resurrect the build

* feat: Upgrade web-lib

* fix: Fix issues related to web-lib upgrade

web-lib logic was adjusted requiring client adjustments

* fix: Revive the build by solving errors caused by recent web-lib upgrade

* refactor: Update to use latest stable version of yearn router

* chore: Update yRouter ABI to match latest stable deployment

* feat: Update wagmi and viem

* fix: Update to latest yVault ABI

https://polygonscan.com/address/0xcaa17796bb3d4a71005cebd817cfeebf85d581b7#code

* fix: Resolve issue by updating dev script in package.json

* refactor: Add specific type to arrays containing wagmi calls (#229)

* fix: Include the 'as const' syntax

* refactor: Add specific type to arrays containing wagmi calls

* refactor: Comment unused types (#230)

* refactor: Standardize the structure of the conditionals using the ‘URLSearchParams' object (#231)

* refactor: Adjust file extension to .ts (#232)

* fix: Correct visibility condition for vault deposit

Incorrect condition led to deposits not being available when they should be

* feat: Add ability to specify fork chainId for local dev

Allows correct display of chain native currency instead of default ETH

* refactor: Remove lesser used scripts in package json

Idea is to keep code clean and concise, removing what isn't used / useful

* fix: Fix failing calls to V3 vaults due to function name changes

* fix: Remove unnecessary args causing call failures

* refactor: Use viem hexToSignature to derive v,r,s

* fix: Resolve deposit error by adding 1% errorTolerance on minOut from previewDeposit

* feat: Add new V3 strategies

* refactor: Update to latest V3 Vault ABI

* refactor: adjust v3 metadata to differentiate vaults and strategies

useful in the rare cases they need to be handled in distinct ways

* fix: Resolve issue causing v3 strategy deposits to be incorrectly disabled

Strategies don't have deposit_limit which caused it to understood as 0 and deposits disabled

* refactor: Hide UI for attributes that aren't available on V3 strategies when viewing a V3 strat

* fix: resolve deposit issue caused by incorrect conditional statements

* fix: Resolve approval incorrectly being requested on every deposit tx

* fix: Resolve issues with approval and allowance during withdraws

* refactor: Remove Polygon V2 vaults

replaced by v3 vaults and strategies, with more to come

* fix: Adjusting withdraw conditon check so redeem is correctly used

* fix: Correct setting of allowance state

* fix: Add TokenizedStrategy ABI, required for apiVersion calls on strats

* fix: Resolve bug with self permit signature caused by apiVersion being undefined

apiVersion was undefined becuase wrong ABI was being called for V3 strat

* fix: Correct block explorer overrides during local development

* fix: Resolve v3 call failures by adjusting ABI and functions called

V3 apiVersion for strats required calling TokenizedStrategy ABI, also used maxDeposit in place of depositLimit and availableDepositLimit

* fix: Adjust UI to properly display API version

* fix: Correct display of deposit limits when the limit is maxUint256

Extra: swap out web-lib MAX_UINT_256 for viem equivalent (bigger)

* refactor: Remove unnecessary condition

since apiVersion is now correctly displayed

* refactor: Hide deposit progess bar when limits are max uint 256

* fix: Locally calculate deposit limit for correct display in UI, handle edge case

Limit is really sum of maxDeposit plus current assets

* fix: Fix off by 1 error with maxUint256 from viem

We need to minus 1 to leave a position for zero

* fix: Resolve state update issue causing deposit option to disappear after first deposit

* fix: Call proper apiVersion on withdraw (v3 vault vs  v3 strategy)

* fix: Adding necessary condition for redeem as well as explanation to prevent adjustment

* fix: Avoid repetitive self permits by approving max

* refactor: Update contract address for compound strategy to lastest deployment

* fix: Resolve issue with V3 vault withdraw by allowing direct withdraw using maxLoss arg

* refactor: Remove BSC vaults

Not a chain currently supported by UI

* feat: Add APR Oracle ABI (for v3 apy snapshots)

* feat: Add APY Oracle addresses per chain

* feat: add apy oracle call, display snapshot for V3 vaults and strategies

* refactor: Simplify styles and remove unnecessary ones (#233)

Co-authored-by: 0xMirim <95051992+0xMirim@users.noreply.github.com>

* Update hooks/useFetch.ts

Co-authored-by: Major <90963895+Majorfi@users.noreply.github.com>

* Apply suggestions from code review

Co-authored-by: Major <90963895+Majorfi@users.noreply.github.com>

* Apply suggestions from code review

Co-authored-by: Major <90963895+Majorfi@users.noreply.github.com>

* Update utils/ABI/yAPROracleV3.abi.ts

Co-authored-by: Major <90963895+Majorfi@users.noreply.github.com>

* refactor: Replace unnecessary chain overrides  with viem defaults

* chore: Update env.example

* fix: Correct name of Polygon RPC env variable

* refactor: Remove currently used environment vars

* refactor: Replace wagmi useNetwork with web-lib getNetwork for network name usage

---------

Co-authored-by: Itzabelli <104786213+Itzabelli@users.noreply.github.com>
Co-authored-by: Major <90963895+Majorfi@users.noreply.github.com>
0xMirim added a commit that referenced this pull request Aug 29, 2023
* refactor: Nuke new vault logic

Not necessary for now may will re-evaluate in the future

* fix: Add missing ABI

VaultFactory ABI is needed to solve error

* fix: resolve compile error by importing and using correct ABIs

* feat: replace ethers contract call with wagmi multicall

migrated function for finding user deposits into inactive vaults

* fix:

* feat: migrate getCommunityVaults to use wagmi

* refactor: Cast to more accurate type

* feat: Migrate API function to wagmi

migrate function that fetches community vault details for apy calculations

* fix: Add required ABI

Needed for calls in api/specificApy endpoint

* feat: Migrate api/specificApy endpoint to wagmi

* feat: Migrate api/tvl endpoint to wagmi

* refactor: Fix big zero check

* feat: migrate VaultStrategies to wagmi

* feat: Migrate vaultAction component to use wagmi

* chore: Update to more accurate extension

* refactor: Improve BIG_ZERO equality check

Following yearn fi reference implementation

* refactor: Update to more accurate file extensions

* feat: Add assert utility function

Will be expanded to use sentry eventually

* feat: migrate apeInVault function to wagmi

* feat: migrate apeOutVault function to wagmi

* feat: migrate harvestStrategy function to wagmi

remove seemingly unnecessary code

* fix: remove useless assert file

* fix: multicall api

* fix: Solve dependency warning (#215)

Remove @next/font

* refactor: replace useEffect with useCallback for findInactiveDeposits

* chore: re-add newVault to be re-written later

* Update components/VaultStrategies.tsx

Co-authored-by: Major <90963895+Majorfi@users.noreply.github.com>

* refactor: Replace ethers bigint with native bigint

Use web-lib decodeAsBigInt for more concise code

* fix: Solve compiler warning (#216)

* feat: migrate actions to wagmi

* feat: migrate VaultActions to wagmi

* fix: Update onSwitchChain params to match latest web-lib requirements

* refactor: fix lint error, improve big int decoding

* fix: Re-add onUpdateVaultData to VaultStrategies, improve decoding

* feat: migrate VaultWrapper to wagmi

* fix: Adjust code to use wagmi / web-lib ABIs

ethers contacts could have string [] of function names which isn't possible with wagmi

* refactor: Removed unnecessary connector asserts

* fix: resolve invalid type issue in api routes, improve big int decoding

* chore: bump web-lib version

* refactor: Adjust formatting of ABI

* fix: Add missing ABI for harvestStrategy call

* fix: Use exported ABI for harvestStrategy

* fix: resurrect the build

added some logs for debugging

* chore: remove debug logs

* fix: Disable wagmi autoConnect to resolve undefined provider errors

autoconnect true resulted in default state for some attributes like onSwitchChain and provider to be returned from web-lib useWeb3 context

* chore: comment out unused code

* feat: debugging

* refactor: disable workbox logging

* fix: test with web-lib Header

* fix: test adjusted provider order

* chore: bump web-lib version

* fix: Return to original Navbar afters isolating bug

* refactor: Remove unnecessary web3 options after web-lib adjusted TWeb3Options

yearn/web-lib@b9c9085

* chore: Remove logs used for debugging and reverse non-relevant changes

* refactor: Re-add disabled workbox logs in dev mode

logs are lame

* feat: Upgrade to latest web-lib, adjust config options

* fix: Update WalletConnect config to solve error

* fix: Adjust button conditions to correctly disable when vault balance is 0

* fix: Pass correct amount for withdrawAll vault action to avoid error

* refactor: Replace onSwitchNetworks with web-lib equivalent

* refactor: remove unnecessary file

* refactor: combine vault actions functions into single file

* refactor: Update calls to renamed vault action functions

* chore: Update web-lib dependency

* fix: Correct contract for reading allowance post approval

Reading from wrong contract lead to UI no updating properly

* feat: Add AVAX details to configured chains

* refactor: Add AVAX and Improve approach to supported chains (#217)

* refactor: Improve approach to displaying supported networks

This change makes it easier to show or exclude networks from UI

* fix: resolve link warning by updating import order

* refactor: burn it

can easily unburn later if neccessary

* refactor: Adjust how to fetch supported chains

Follow Majors advice

* refactor: Remove unnecessary connector

* refactor: Add more specific type

* refactor: Relocate supportedNetworks to parent and expand attributes it returns

* refactor: Replace web-lib CHAINS usage on home page

Using local solution to show network label

* refactor: Favor local solutions to retrieving network details for display

* feat: Create local chains util (with AVAX)

web-lib version will be removed, this is temporary solution until better one is available

* feat: Bring useChain hook local, to use local chains util (with AVAX)

temp solution until better one is available

* refactor: utilize useChains to display network label on home page

* refactor: utilize useChain hook to display chainCoin on vault page

* refactor: utilize useChain hook to display blockExplorer on vault page

* fix: Resolve spacing issue

* chore: Adjust import ordering

* refactor: Update imports to use 'useWindowInFocus' hook of web-lib (#219)

* fix: Adjust connectors to solve wallet connection bug

strange behavior occurs without IFrameEthereumConnector

* chore: Adjust condition to Deposit Limit in the vault details section (#222)

Show ∞ when limit of the vault is the greater possible

* feat/v3 (#221)

* feat: Add necessary env vars for V3 integration

* feat: Expand envs to include avalanche

* refactor: Add allowanceYRouter attr to TVaultData

* feat: Add V3 ABIs (router and vaults)

* feat: expand network specific logic to include avalanche

* feat: Add experimental V3 vault

* fix: pass metamask configuredChains to solve connector issues

* chore: Update web-lib

Allows us to remove IFrameEthereum connector without error

* refactor: Remove unnecessary connector now that web-lib allows it

* feat: Update VaultWrapper to handle V3 vaults

while remaining backwards compatible with v2

* refactor: Improve logic and error handling for fetching stategies

* chore: remove env used for testing

* feat: Begin V3 actions implementation (withdrawWithPermit)

* feat: Begin VaultActions UI implementation

* feat: V3 actions - depositERC20

* feat: VaultActions UI - VaultActionsApeIn

* fix: Adjust function order to properly separate V2 and V3 flows

* chore: Remove testing values

* chore: add address for testing YRouter on locally chain fork

* feat: Add V3 USDC vault - polygon

* fix: Add missing arg to balanceOf call

* fix: Remove avalanche config

* chore: Update web-lib version

Bringing changes to improve ape tax dev experience

* feat: VaultAction V3 migration progress

Updated UI and logic

* feat: Finish VaultActions V3 migration

* refactor: Bring back ape function...for the culture... eliminate unnecessary functions

* feat: Add statusHandlers to allow updates to UI during vault actions

* fix: Adjust condition to exclude removed env var

* chore: Add the 'useNetwork' hook of wagmi (#224)

* chore: Add the 'useNetwork' hook of wagmi

* refactor: Add semicolons, remove unnecessary spaces

Feel like lint rules might not be being properly enforced...made note to check

---------

Co-authored-by: 0xMirim <95051992+0xMirim@users.noreply.github.com>

* chore: remove comment

* refactor: Remove unnecessary file

No longer required after removal of local useChain hook

* feat: Moving chain specific details to new wagmiChains file (#225)

* refactor: Remove isApproving in favor of statusHandler

* fix: Adding allowanceYRouter data to vault data for proper UI update

* feat: Progress on withdrawWithPermitERC20

* refactor: Add no connector check, remove comment

* fix: Resolve linting issues by updating related dependencies

* fix: linting issues solved by running lintfix

* feat: Progress on V3 deposit and withdraw functions

* fix: Resolve lint errors in withdrawERC20WithPermit

* fix: Resolve deposit bug by handle case of extra approve on first vault interaction

* feat: Add zod for better type validation

* feat: Add zod schema

* refactor: Remove unused type

* refactor: Comment unused function, removed older commented function

* feat: Add fetch util and hook for improved data fetching

* refactor: Update block timestamp util to use zod and new fetch util

* refactor: Update calls to fetchBlockTimestamp util after changes

* refactor: Increase readability of api endpoint using URLSearchParams object

* fix: strategies not populating correctly due to call to meta yearn api (down)

* fix: Add accurate types to resolve "any" type errors

* refactor: Removed unnecessary function, comment currently unused function

This should resurrect the build

* feat: Upgrade web-lib

* fix: Fix issues related to web-lib upgrade

web-lib logic was adjusted requiring client adjustments

* fix: Revive the build by solving errors caused by recent web-lib upgrade

* refactor: Update to use latest stable version of yearn router

* chore: Update yRouter ABI to match latest stable deployment

* feat: Update wagmi and viem

* fix: Update to latest yVault ABI

https://polygonscan.com/address/0xcaa17796bb3d4a71005cebd817cfeebf85d581b7#code

* fix: Resolve issue by updating dev script in package.json

* refactor: Add specific type to arrays containing wagmi calls (#229)

* fix: Include the 'as const' syntax

* refactor: Add specific type to arrays containing wagmi calls

* refactor: Comment unused types (#230)

* refactor: Standardize the structure of the conditionals using the ‘URLSearchParams' object (#231)

* refactor: Adjust file extension to .ts (#232)

* fix: Correct visibility condition for vault deposit

Incorrect condition led to deposits not being available when they should be

* feat: Add ability to specify fork chainId for local dev

Allows correct display of chain native currency instead of default ETH

* refactor: Remove lesser used scripts in package json

Idea is to keep code clean and concise, removing what isn't used / useful

* fix: Fix failing calls to V3 vaults due to function name changes

* fix: Remove unnecessary args causing call failures

* refactor: Use viem hexToSignature to derive v,r,s

* fix: Resolve deposit error by adding 1% errorTolerance on minOut from previewDeposit

* feat: Add new V3 strategies

* refactor: Update to latest V3 Vault ABI

* refactor: adjust v3 metadata to differentiate vaults and strategies

useful in the rare cases they need to be handled in distinct ways

* fix: Resolve issue causing v3 strategy deposits to be incorrectly disabled

Strategies don't have deposit_limit which caused it to understood as 0 and deposits disabled

* refactor: Hide UI for attributes that aren't available on V3 strategies when viewing a V3 strat

* fix: resolve deposit issue caused by incorrect conditional statements

* fix: Resolve approval incorrectly being requested on every deposit tx

* fix: Resolve issues with approval and allowance during withdraws

* refactor: Remove Polygon V2 vaults

replaced by v3 vaults and strategies, with more to come

* fix: Adjusting withdraw conditon check so redeem is correctly used

* fix: Correct setting of allowance state

* fix: Add TokenizedStrategy ABI, required for apiVersion calls on strats

* fix: Resolve bug with self permit signature caused by apiVersion being undefined

apiVersion was undefined becuase wrong ABI was being called for V3 strat

* fix: Correct block explorer overrides during local development

* fix: Resolve v3 call failures by adjusting ABI and functions called

V3 apiVersion for strats required calling TokenizedStrategy ABI, also used maxDeposit in place of depositLimit and availableDepositLimit

* fix: Adjust UI to properly display API version

* fix: Correct display of deposit limits when the limit is maxUint256

Extra: swap out web-lib MAX_UINT_256 for viem equivalent (bigger)

* refactor: Remove unnecessary condition

since apiVersion is now correctly displayed

* refactor: Hide deposit progess bar when limits are max uint 256

* fix: Locally calculate deposit limit for correct display in UI, handle edge case

Limit is really sum of maxDeposit plus current assets

* fix: Fix off by 1 error with maxUint256 from viem

We need to minus 1 to leave a position for zero

* fix: Resolve state update issue causing deposit option to disappear after first deposit

* fix: Call proper apiVersion on withdraw (v3 vault vs  v3 strategy)

* fix: Adding necessary condition for redeem as well as explanation to prevent adjustment

* fix: Avoid repetitive self permits by approving max

* refactor: Update contract address for compound strategy to lastest deployment

* fix: Resolve issue with V3 vault withdraw by allowing direct withdraw using maxLoss arg

* refactor: Remove BSC vaults

Not a chain currently supported by UI

* feat: Add APR Oracle ABI (for v3 apy snapshots)

* feat: Add APY Oracle addresses per chain

* feat: add apy oracle call, display snapshot for V3 vaults and strategies

* refactor: Simplify styles and remove unnecessary ones (#233)

Co-authored-by: 0xMirim <95051992+0xMirim@users.noreply.github.com>

* Update hooks/useFetch.ts

Co-authored-by: Major <90963895+Majorfi@users.noreply.github.com>

* Apply suggestions from code review

Co-authored-by: Major <90963895+Majorfi@users.noreply.github.com>

* Apply suggestions from code review

Co-authored-by: Major <90963895+Majorfi@users.noreply.github.com>

* Update utils/ABI/yAPROracleV3.abi.ts

Co-authored-by: Major <90963895+Majorfi@users.noreply.github.com>

* refactor: Replace unnecessary chain overrides  with viem defaults

* chore: Update env.example

* fix: Correct name of Polygon RPC env variable

* refactor: Remove currently used environment vars

* refactor: Replace wagmi useNetwork with web-lib getNetwork for network name usage

---------

Co-authored-by: Itzabelli <104786213+Itzabelli@users.noreply.github.com>
Co-authored-by: Major <90963895+Majorfi@users.noreply.github.com>

---------

Co-authored-by: Major <major@ycorpo.com>
Co-authored-by: Itzabelli <104786213+Itzabelli@users.noreply.github.com>
Co-authored-by: Major <90963895+Majorfi@users.noreply.github.com>
Majorfi added a commit that referenced this pull request Aug 30, 2023
* WIP: wagmi migrations

* Feat/wagmi (#214)

* refactor: Nuke new vault logic

Not necessary for now may will re-evaluate in the future

* fix: Add missing ABI

VaultFactory ABI is needed to solve error

* fix: resolve compile error by importing and using correct ABIs

* feat: replace ethers contract call with wagmi multicall

migrated function for finding user deposits into inactive vaults

* fix:

* feat: migrate getCommunityVaults to use wagmi

* refactor: Cast to more accurate type

* feat: Migrate API function to wagmi

migrate function that fetches community vault details for apy calculations

* fix: Add required ABI

Needed for calls in api/specificApy endpoint

* feat: Migrate api/specificApy endpoint to wagmi

* feat: Migrate api/tvl endpoint to wagmi

* refactor: Fix big zero check

* feat: migrate VaultStrategies to wagmi

* feat: Migrate vaultAction component to use wagmi

* chore: Update to more accurate extension

* refactor: Improve BIG_ZERO equality check

Following yearn fi reference implementation

* refactor: Update to more accurate file extensions

* feat: Add assert utility function

Will be expanded to use sentry eventually

* feat: migrate apeInVault function to wagmi

* feat: migrate apeOutVault function to wagmi

* feat: migrate harvestStrategy function to wagmi

remove seemingly unnecessary code

* fix: remove useless assert file

* fix: multicall api

* fix: Solve dependency warning (#215)

Remove @next/font

* refactor: replace useEffect with useCallback for findInactiveDeposits

* chore: re-add newVault to be re-written later

* Update components/VaultStrategies.tsx

Co-authored-by: Major <90963895+Majorfi@users.noreply.github.com>

* refactor: Replace ethers bigint with native bigint

Use web-lib decodeAsBigInt for more concise code

* fix: Solve compiler warning (#216)

* feat: migrate actions to wagmi

* feat: migrate VaultActions to wagmi

* fix: Update onSwitchChain params to match latest web-lib requirements

* refactor: fix lint error, improve big int decoding

* fix: Re-add onUpdateVaultData to VaultStrategies, improve decoding

* feat: migrate VaultWrapper to wagmi

* fix: Adjust code to use wagmi / web-lib ABIs

ethers contacts could have string [] of function names which isn't possible with wagmi

* refactor: Removed unnecessary connector asserts

* fix: resolve invalid type issue in api routes, improve big int decoding

* chore: bump web-lib version

* refactor: Adjust formatting of ABI

* fix: Add missing ABI for harvestStrategy call

* fix: Use exported ABI for harvestStrategy

* fix: resurrect the build

added some logs for debugging

* chore: remove debug logs

* fix: Disable wagmi autoConnect to resolve undefined provider errors

autoconnect true resulted in default state for some attributes like onSwitchChain and provider to be returned from web-lib useWeb3 context

* chore: comment out unused code

* feat: debugging

* refactor: disable workbox logging

* fix: test with web-lib Header

* fix: test adjusted provider order

* chore: bump web-lib version

* fix: Return to original Navbar afters isolating bug

* refactor: Remove unnecessary web3 options after web-lib adjusted TWeb3Options

yearn/web-lib@b9c9085

* chore: Remove logs used for debugging and reverse non-relevant changes

* refactor: Re-add disabled workbox logs in dev mode

logs are lame

* feat: Upgrade to latest web-lib, adjust config options

* fix: Update WalletConnect config to solve error

* fix: Adjust button conditions to correctly disable when vault balance is 0

* fix: Pass correct amount for withdrawAll vault action to avoid error

* refactor: Replace onSwitchNetworks with web-lib equivalent

* refactor: remove unnecessary file

* refactor: combine vault actions functions into single file

* refactor: Update calls to renamed vault action functions

* chore: Update web-lib dependency

* fix: Correct contract for reading allowance post approval

Reading from wrong contract lead to UI no updating properly

* feat: Add AVAX details to configured chains

* refactor: Add AVAX and Improve approach to supported chains (#217)

* refactor: Improve approach to displaying supported networks

This change makes it easier to show or exclude networks from UI

* fix: resolve link warning by updating import order

* refactor: burn it

can easily unburn later if neccessary

* refactor: Adjust how to fetch supported chains

Follow Majors advice

* refactor: Remove unnecessary connector

* refactor: Add more specific type

* refactor: Relocate supportedNetworks to parent and expand attributes it returns

* refactor: Replace web-lib CHAINS usage on home page

Using local solution to show network label

* refactor: Favor local solutions to retrieving network details for display

* feat: Create local chains util (with AVAX)

web-lib version will be removed, this is temporary solution until better one is available

* feat: Bring useChain hook local, to use local chains util (with AVAX)

temp solution until better one is available

* refactor: utilize useChains to display network label on home page

* refactor: utilize useChain hook to display chainCoin on vault page

* refactor: utilize useChain hook to display blockExplorer on vault page

* fix: Resolve spacing issue

* chore: Adjust import ordering

* refactor: Update imports to use 'useWindowInFocus' hook of web-lib (#219)

* fix: Adjust connectors to solve wallet connection bug

strange behavior occurs without IFrameEthereumConnector

* chore: Adjust condition to Deposit Limit in the vault details section (#222)

Show ∞ when limit of the vault is the greater possible

* feat/v3 (#221)

* feat: Add necessary env vars for V3 integration

* feat: Expand envs to include avalanche

* refactor: Add allowanceYRouter attr to TVaultData

* feat: Add V3 ABIs (router and vaults)

* feat: expand network specific logic to include avalanche

* feat: Add experimental V3 vault

* fix: pass metamask configuredChains to solve connector issues

* chore: Update web-lib

Allows us to remove IFrameEthereum connector without error

* refactor: Remove unnecessary connector now that web-lib allows it

* feat: Update VaultWrapper to handle V3 vaults

while remaining backwards compatible with v2

* refactor: Improve logic and error handling for fetching stategies

* chore: remove env used for testing

* feat: Begin V3 actions implementation (withdrawWithPermit)

* feat: Begin VaultActions UI implementation

* feat: V3 actions - depositERC20

* feat: VaultActions UI - VaultActionsApeIn

* fix: Adjust function order to properly separate V2 and V3 flows

* chore: Remove testing values

* chore: add address for testing YRouter on locally chain fork

* feat: Add V3 USDC vault - polygon

* fix: Add missing arg to balanceOf call

* fix: Remove avalanche config

* chore: Update web-lib version

Bringing changes to improve ape tax dev experience

* feat: VaultAction V3 migration progress

Updated UI and logic

* feat: Finish VaultActions V3 migration

* refactor: Bring back ape function...for the culture... eliminate unnecessary functions

* feat: Add statusHandlers to allow updates to UI during vault actions

* fix: Adjust condition to exclude removed env var

* chore: Add the 'useNetwork' hook of wagmi (#224)

* chore: Add the 'useNetwork' hook of wagmi

* refactor: Add semicolons, remove unnecessary spaces

Feel like lint rules might not be being properly enforced...made note to check

---------

Co-authored-by: 0xMirim <95051992+0xMirim@users.noreply.github.com>

* chore: remove comment

* refactor: Remove unnecessary file

No longer required after removal of local useChain hook

* feat: Moving chain specific details to new wagmiChains file (#225)

* refactor: Remove isApproving in favor of statusHandler

* fix: Adding allowanceYRouter data to vault data for proper UI update

* feat: Progress on withdrawWithPermitERC20

* refactor: Add no connector check, remove comment

* fix: Resolve linting issues by updating related dependencies

* fix: linting issues solved by running lintfix

* feat: Progress on V3 deposit and withdraw functions

* fix: Resolve lint errors in withdrawERC20WithPermit

* fix: Resolve deposit bug by handle case of extra approve on first vault interaction

* feat: Add zod for better type validation

* feat: Add zod schema

* refactor: Remove unused type

* refactor: Comment unused function, removed older commented function

* feat: Add fetch util and hook for improved data fetching

* refactor: Update block timestamp util to use zod and new fetch util

* refactor: Update calls to fetchBlockTimestamp util after changes

* refactor: Increase readability of api endpoint using URLSearchParams object

* fix: strategies not populating correctly due to call to meta yearn api (down)

* fix: Add accurate types to resolve "any" type errors

* refactor: Removed unnecessary function, comment currently unused function

This should resurrect the build

* feat: Upgrade web-lib

* fix: Fix issues related to web-lib upgrade

web-lib logic was adjusted requiring client adjustments

* fix: Revive the build by solving errors caused by recent web-lib upgrade

* refactor: Update to use latest stable version of yearn router

* chore: Update yRouter ABI to match latest stable deployment

* feat: Update wagmi and viem

* fix: Update to latest yVault ABI

https://polygonscan.com/address/0xcaa17796bb3d4a71005cebd817cfeebf85d581b7#code

* fix: Resolve issue by updating dev script in package.json

* refactor: Add specific type to arrays containing wagmi calls (#229)

* fix: Include the 'as const' syntax

* refactor: Add specific type to arrays containing wagmi calls

* refactor: Comment unused types (#230)

* refactor: Standardize the structure of the conditionals using the ‘URLSearchParams' object (#231)

* refactor: Adjust file extension to .ts (#232)

* fix: Correct visibility condition for vault deposit

Incorrect condition led to deposits not being available when they should be

* feat: Add ability to specify fork chainId for local dev

Allows correct display of chain native currency instead of default ETH

* refactor: Remove lesser used scripts in package json

Idea is to keep code clean and concise, removing what isn't used / useful

* fix: Fix failing calls to V3 vaults due to function name changes

* fix: Remove unnecessary args causing call failures

* refactor: Use viem hexToSignature to derive v,r,s

* fix: Resolve deposit error by adding 1% errorTolerance on minOut from previewDeposit

* feat: Add new V3 strategies

* refactor: Update to latest V3 Vault ABI

* refactor: adjust v3 metadata to differentiate vaults and strategies

useful in the rare cases they need to be handled in distinct ways

* fix: Resolve issue causing v3 strategy deposits to be incorrectly disabled

Strategies don't have deposit_limit which caused it to understood as 0 and deposits disabled

* refactor: Hide UI for attributes that aren't available on V3 strategies when viewing a V3 strat

* fix: resolve deposit issue caused by incorrect conditional statements

* fix: Resolve approval incorrectly being requested on every deposit tx

* fix: Resolve issues with approval and allowance during withdraws

* refactor: Remove Polygon V2 vaults

replaced by v3 vaults and strategies, with more to come

* fix: Adjusting withdraw conditon check so redeem is correctly used

* fix: Correct setting of allowance state

* fix: Add TokenizedStrategy ABI, required for apiVersion calls on strats

* fix: Resolve bug with self permit signature caused by apiVersion being undefined

apiVersion was undefined becuase wrong ABI was being called for V3 strat

* fix: Correct block explorer overrides during local development

* fix: Resolve v3 call failures by adjusting ABI and functions called

V3 apiVersion for strats required calling TokenizedStrategy ABI, also used maxDeposit in place of depositLimit and availableDepositLimit

* fix: Adjust UI to properly display API version

* fix: Correct display of deposit limits when the limit is maxUint256

Extra: swap out web-lib MAX_UINT_256 for viem equivalent (bigger)

* refactor: Remove unnecessary condition

since apiVersion is now correctly displayed

* refactor: Hide deposit progess bar when limits are max uint 256

* fix: Locally calculate deposit limit for correct display in UI, handle edge case

Limit is really sum of maxDeposit plus current assets

* fix: Fix off by 1 error with maxUint256 from viem

We need to minus 1 to leave a position for zero

* fix: Resolve state update issue causing deposit option to disappear after first deposit

* fix: Call proper apiVersion on withdraw (v3 vault vs  v3 strategy)

* fix: Adding necessary condition for redeem as well as explanation to prevent adjustment

* fix: Avoid repetitive self permits by approving max

* refactor: Update contract address for compound strategy to lastest deployment

* fix: Resolve issue with V3 vault withdraw by allowing direct withdraw using maxLoss arg

* refactor: Remove BSC vaults

Not a chain currently supported by UI

* feat: Add APR Oracle ABI (for v3 apy snapshots)

* feat: Add APY Oracle addresses per chain

* feat: add apy oracle call, display snapshot for V3 vaults and strategies

* refactor: Simplify styles and remove unnecessary ones (#233)

Co-authored-by: 0xMirim <95051992+0xMirim@users.noreply.github.com>

* Update hooks/useFetch.ts

Co-authored-by: Major <90963895+Majorfi@users.noreply.github.com>

* Apply suggestions from code review

Co-authored-by: Major <90963895+Majorfi@users.noreply.github.com>

* Apply suggestions from code review

Co-authored-by: Major <90963895+Majorfi@users.noreply.github.com>

* Update utils/ABI/yAPROracleV3.abi.ts

Co-authored-by: Major <90963895+Majorfi@users.noreply.github.com>

* refactor: Replace unnecessary chain overrides  with viem defaults

* chore: Update env.example

* fix: Correct name of Polygon RPC env variable

* refactor: Remove currently used environment vars

* refactor: Replace wagmi useNetwork with web-lib getNetwork for network name usage

---------

Co-authored-by: Itzabelli <104786213+Itzabelli@users.noreply.github.com>
Co-authored-by: Major <90963895+Majorfi@users.noreply.github.com>

---------

Co-authored-by: Major <major@ycorpo.com>
Co-authored-by: Itzabelli <104786213+Itzabelli@users.noreply.github.com>
Co-authored-by: Major <90963895+Majorfi@users.noreply.github.com>

* fix: Attempt to fix tvl calculation bug

* chore: Add logs to assist with debug

---------

Co-authored-by: Major <major@ycorpo.com>
Co-authored-by: Itzabelli <104786213+Itzabelli@users.noreply.github.com>
Co-authored-by: Major <90963895+Majorfi@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants