yearn / yearn-sdk

🦧 SDK for the yearn.finance platform. WIP
https://npm.im/@yfi/sdk
MIT License
53 stars 56 forks source link

feat: Supported Zap Vaults [WEB-1424] #276

Closed karelianpie closed 2 years ago

karelianpie commented 2 years ago

Description

Provide information if a vault is supported to zap in/out

Metadata properties added in the following PR https://github.com/yearn/yearn-meta/pull/235

Related Issue

https://linear.app/yearn/issue/WEB-1424/supported-zap-vaults

Motivation and Context

We should get the if a vault is supported by zapper from https://api.zapper.fi/v1/protocols/yearn/token-market-data rather than assume it's supported

How Has This Been Tested?

Added tests:

Tested locally with the frontend running the yalc'ed sdk

Screenshots:

Frontend running locally, you can see that we have all the old/new zapper props (i.e. allowZapIn, allowZapOut, zapInWith, zapOutWith) set correctly for a "zappable" vault:

Screen Shot 2022-04-06 at 1 09 26 pm
linear[bot] commented 2 years ago
WEB-1424 Supported Zap Vaults

### Elevator Pitch: **SDK should provide information if a vault is supported to zap in/out** ### Customer Value: **Frontends can display just the supported tokens for a given vault** ### Agreed upon Acceptance Criteria (definition of Done): * Refactor VaultMetadata interface to: ``` export interface VaultMetadata { ... allowZapIn?: boolean; // to be deprecated in a later version allowZapOut?: boolean; // to be deprecated in a later version zapInWith?: string; // This is a zapIn contract alias zapOutWith?: string; // This is a zapOut contract alias } ``` \*Also refactor yearn-meta schema accordingly [https://github.com/yearn/yearn-meta/blob/master/schema/vault.json](https://github.com/yearn/yearn-meta/blob/master/schema/vault.json) ### Design Approach: Hardcode in SDK all available zap contract addresses by alias. Use zappers api [~https://docs.zapper.fi/zapper-api/api-guides/vault-stats~](https://docs.zapper.fi/zapper-api/api-guides/vault-stats) [https://api.zapper.fi/v1/protocols/yearn/token-market-data?network=ethereum&type=vault](https://api.zapper.fi/v1/protocols/yearn/token-market-data?network=ethereum&type=vault) to set `zapInWith === 'zapperZapIn' and zapOutWith === 'zapperZapOut'` for supported vaults on eth mainnet. Override from yearn-meta to sdk for all vaults. ### Design review: xgambitox

github-actions[bot] commented 2 years ago

size-limit report 📦

Path Size
dist/sdk.cjs.production.min.js 44.29 KB (+0.66% 🔺)
dist/sdk.esm.js 44.65 KB (+0.65% 🔺)