Code Monkey home page Code Monkey logo

seafood's Introduction

Seafood

Seafood is a public vault monitoring dashboard that lets you simulate operations like harvests and allocation changes while tracking asset flows and APY changes.

mechafish-md

Dev environment setup

First get node installed. For an easy way to install a particular node version in your dev environment, or multiple node versions on the same system, try Node Version Manager (NVM). See https://github.com/nvm-sh/nvm#install--update-script for install instructions.

1 - With NVM installed, install node 16 (or higher) and yarn

nvm install 16 # or later
npm install -g yarn

2 - Clone this repo, install dependencies

git clone [email protected]:yearn/seafood.git
cd seafood
(yarn && cd api && yarn)

3 - Configure local environment variables

cp env.example .env
  • For data
Setup and run [kong](https://github.com/murderteeth/kong) in your local environment, then in seafood's .env use:

REACT_APP_KONG_API_URL=http://localhost:3001/api/gql


- To run vault and strategy simulations, set a token for tenderly, explorer urls, and rps urls for each supported chain:

TENDERLY_ACCESS_TOKEN= EXPLORER_API_FOR_1= EXPLORER_API_FOR_250= EXPLORER_API_FOR_10= EXPLORER_API_FOR_42161= RPC_URI_FOR_1= RPC_URI_FOR_250= RPC_URI_FOR_10= RPC_URI_FOR_42161=

To get a token, first create an account on https://tenderly.co. Then from your tenderly dashboard go to Settings, Authorization, Generate Access Token. Your tenderly account also needs access to yearn's tenderly organization account. To get access, ask someone at yearn for an invite.

You can use your own explorer and rpc urls, but without premium access you'll likely get rate limit errors in seafood. You can also ask someone at yearn for access to internal explorer and rpc urls.


4 - Run the app
```console
cd ~/git/seafood # or wherever you cloned it
yarn start

Open a browser at http://localhost:3000

Project structure

backend

/api - Resources for serving Seafood's backend api
/api/routes/vision - Facades over Yearn's vision api
/api/routes/abi - Smart contract abis
/api/routes/getVaults - Vault and strategy related data. (obsoleting)
/api/routes/github - Generate GitHub bearer tokens for Seafood users
/api/routes/tenderly - Generate Tenderly simulation forks
/api/routes/tradeables - List tradeable erc20s for a given trade handler

frontend

/public - Static files
/scripts - Help scripts used in dev
/src - Resources for building Seafood's frontend
/src/abi - Some static abis that are needed by Seafood and some that..aren't ๐Ÿ‘€
/src/math - Logic for computing APY and APR on demand
/src/components - Most of Seafood's React components go here
/src/components/controls - Specifically, common UI controls live here
/src/context - Seafood's React hooks live here. So why call it context?
/src/ethereum - Various utilities for querying RPCs. (obsoleting)
/src/utils - Various utilities that seemed happiest in a folder called utils ๐Ÿ˜
/src/config.json - This was a more convenient way to configure previous versions of Seafood. It moves to envars eventually

Tests

Seafood uses Jest for testing. Some tests require rpc integration, so first set this envar:

TEST_RPC=<eg, your infura mainnet url>

Infura not required, but you'll need a premium rpc or your own node to test.

Run tests like this:

yarn test

Contributing

  • To contribute: fork, branch from main, make changes, pull request.
  • Use Typescript instead of Javascript for anything new.
  • This project is configured to automatically enforce linting and style rules.
  • CSS. For frontend layout and styling Seafood uses Tailwinds and follows their utility-first principle.
  • Tests. For now, Seafood only requires tests for domain logic and doesn't cover frontend\UI logic. So if your work requires complex domain logic, like computing APY, include tests for it. If you're just adding some buttons, no worries, amigo ๐Ÿ˜Ž
  • Documentation, minimal. We have GPT now for crying out loud ๐Ÿค–

><(((*> - Onward!

seafood's People

Contributors

0xbasically avatar flashfish0x avatar majorfi avatar murderteeth avatar rishav1707 avatar saltyfacu avatar udhaykumarbala avatar wavey0x avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

seafood's Issues

Feat: Add v2 Simple APY calculation

โš  According to yDaemon, the only vault using the v2 Simple calculation is yvUSDC 0.30. Adding this apy is not a priority,

Chore: Cleanup backend API code

  • Teardown unused routes (include dependencies that are no longer needed)
  • The API contains two entry points, one for production and one for testing. Both enumerate their own routing configuration. Only one routing config is needed though, so refactor those into one routing config.

Refactor for more chains

Right now the frontend mostly hardcodes the distinction between the ethereum and fantom chains.
Eg: #76 (comment)

Instead, let's have a simple way of adding new chains as we go.

  • Review existing hardcoded multichain logic (code and css)
  • Refactor so that chains are managed from a json file

Chore: Move TVL chart rendering to backend

Currently seafood's vault TVL charts are rendered in the browser. This is OK, but drags both the loading and scrolling performance of seafood's main vaults list. Instead, render and cache these charts in the backend. This way the browser can handle the charts as simple images instead of canvas objects.

image

Load TVL sparklines with real data

Vault cards currently feature sparklines with fake TVL data:

image

  • What's the best way to get TVL series for each vault given we want to load all of this data when the dashboard first loads? One suggestion, per Marius:

prod is still down but you can query staging to get the TVL for FTM and ETH, you can also adjust the expr and specify the network dimension.

curl 'https://staging.yearn.vision/api/ds/query' -H 'Accept: application/json, text/plain, */*' -H 'content-type: application/json' --data-raw '{"queries":[{"datasource":{"uid":"PBFE396EC0B189D67","type":"prometheus"},"exemplar":false,"expr":"(avg(yearn{network=\"ETH\", param=\"vecrv balance\"}) * avg(yearn{network=\"ETH\", param=\"crv price\"}) or vector(0)) + (sum(yearn{network=\"ETH\", param=\"tvl\"}) or vector(0)) + (sum(yearn_vault{network=\"ETH\", param=\"tvl\"}) or vector(0)) + (sum(yearn_vault{network=\"FTM\", param=\"tvl\"}) or vector(0)) + (sum(iearn{network=\"ETH\", param=\"tvl\"}) or vector(0)) - (sum((yearn_strategy{network=\"ETH\", param=\"delegatedAssets\"} / 1000000000000000000 > 0) * on(vault, version) group_left yearn_vault{network=\"ETH\", param=\"token price\"}) or vector(0))  - (sum((yearn_strategy{network=\"FTM\", param=\"delegatedAssets\"} / 1000000000000000000 > 0) * on(vault, version) group_left yearn_vault{network=\"FTM\", param=\"token price\"}) or vector(0))","utcOffsetSec":0,"datasourceId":1}],"from":"1652658600000","to":"1652659200000"}'
  • Seafood's vault card design has some empty space. We can fill it with anything, doesn't have to be TVL or a sparkline for that matter. Are there other suggestions?

Chore: Review useVaults worker multicalls for data available in yDaemon

The web worker for the useVaults hook currently uses multicalls to get data not yet available in the yDaemon api. The multicalls were written against an older version of yDaemon, some may not be needed anymore. Review those multicalls and remove any that are no longer required and can be merged from the latest yDaemon data instead.

This improves the performance of seafood's data sync.

Add block dialog fails when adding manual strategy function

When I use the dialog's Manual mode I can use a vault address, choose a function, and successfully create a new block. But if I use a strategy address, I get an error in the console and the block is not created.

TypeError: Cannot read properties of null (reading 'address')

To reproduce:

  • Sandbox
  • Add block
  • Manual
  • Enter a strategy address (eg, 0x0A5157244e4F82F100A461CA65C7b05C8dACf835)
  • Chose any function
  • Click Add block

image

Feat: Create PRs to the sms repo from Sandbox

from @flashfish0x

A functionality I always wanted to add was integration with github. For instance on the sandbox page when you get the code snippet, or on the single vault page when you do an adjust ration. We use that code snippet to do a multisig transaction on ethereym or fantom. That is done by pasting that code into a github repository and then opening a pull request at which point a bot takes over to simulate the transaction and push it to the chain. Being able to go straight from seafood to the github pull request without copy and pasting would be great.

requires #71

Here's an example of how to PR the sms repo:
https://github.com/yearn/dashboard_ui/blob/208a9fdf9bb3a48406dbec58646a8a7991069e10/src/components/Vault/Code.js#L147

Add block dialog fails to show strategies and functions

The add block dialog fails to show strategies and functions after I've been using it for several minutes. I noticed the same thing happening on the vault harvest page. After the app's been open a bit, I start getting websocket errors in the console:

WebSocket is already in CLOSING or CLOSED state.

To reproduce:

  • Sandbox
  • Add block
  • Wait several minutes
  • Select any vault

image

Bug: Order debt ratio updates in ascending order

from @flashfish0x

the debt ratio changes need to be ordered down then up. So all changes that are a decrease need to go first, then afterwards the increases.. basically it should be ordered by delta

image

for example this would fail because the increases happen before the decreases

Feat: Tag and filter experimental vaults

Seafood's vault data set includes both endorsed and experimental vaults, but currently you can't tell the difference in the UI.

  • Add a tag (or some kind of indicator) to experimental vaults
  • Add an "Experimental Vaults" filter to the vault dash that is off by default. When off, do not include experimental vaults in the dash results. When on, include experimental vaults.

image

To tag and filter vaults, use the new endorsed field that was introduced here:
7b333bd

If a vault is endorsed, it is not experimental. If a vault is not endorsed, it is experimental.

Bug: Vault dash filter UI overflows on laptop screens

  • For laptop screens (~1440 pixels wide), filter UI on the vault dash overflows as you toggle more settings.
  • Also shrinks text filter to the point of being unusable

image

tasks

Update the toolbar to use fixed widths for its different components and use ellipsis to truncate text overflow. Here's a template:
image

Bug: Stick simulator status on error (mobile)

For mobile, seafood hides the simulator status bar until the sim is running then hides it again when the sim is complete. This is OK, but it also hides if there's a sim error. This means the sim fails without giving the user a clear indiciation.

Vault and Strategy Favorites

As a strategist, I want to keep a list of my favorite vaults and strategies, so that:

  • I can find what I want faster in the vault browser
  • Adding blocks to the sandbox is faster

Tasks:

  • Toggle favorite status from vault and strategy tiles
  • Toggle favorites filtering when listing vaults and strategies
    • Vaults browser
    • Add blocks dialog

seafood favorites

Remodel vault details page

  • The vault page needs a layout that fits the rest of the site. For example, here's a wireframe from months back when the project first started:

image

  • Review vault page data model (eg from @flashfish0x : I havent [used ethcall] on the individual vault pages yet which is why they can be a bit slow loading.)

Get strategy abis from block explorer

from @flashfish0x

One thing on the simulations that needs to be improved. When we click on a strategy it shows functions from an ABI which is currently just stored in json. But all strategies are different so we need to get the ABI from etherscan/ftmscan to give the user the correct choice of functions.

Add Github login

Adding a github login lets Seafood know who's logged in and enables features like: automating vault\strat sms PRs, saving favorites and other user settings outside the browser.

Review shared vault/strategy data model

On startup Seafood loads coarse grained data on all vaults and strategies and makes this data available through a context at the top of its component hierarchy. This is very useful, but we'd like to improve it like this:

  • Optimize data loading for UI responsiveness (eg minimize blocking, make component available JIT)
  • Add UI indicators for loading status and freshness
  • Maybe add some browser caching (eg, using a service worker)

Chore: Factor vaultRpc out of v2 Average APY calculation

The current apy code has vaultRpc passed into the compute function, then calls pricePerShare at different historic points, for example:
https://github.com/yearn/dashboard_ui/blob/208a9fdf9bb3a48406dbec58646a8a7991069e10/src/apy/v2/averaged.ts#L19

Better would be to make those pps calls ahead of computation, passing in an array of historic pps instead of vaultRpc. This way the pps history is available for other methods of computing APY and makes the compute function more testable.

Feat: Redash (Dash design review)

Review seafood's current dashboard design with these goals:

  • Keep navigation elements on screen when scrolling while maximizing dash real estate
  • Remove background gradients. Bg gradients are OK for product\landing pages. But when a page contains a lot of components, especially rendered components like charts, gradients create more gpu\redraw pressure which interferes with smooth scrolling and page transitions.
  • Streamline vault tile design. Emphasize and create more space for vault info, de-emphasize controls\buttons
  • Factor out "scroll overpass" components. These look nice, but are complicated to maintain\debug.

Here's the current dash:
image

The redash looks something like this:
image

With the vault tile redesign like this:
image

Feat: Filter by vault token name or symbol

The current text filter searches vaults by vault name only. But I would also like to filter by a vault's token name or symbol. For example, if I filter by ycrv I currently get no results, but should see all curve vaults.
image

Bug: Fix tiny token amounts

When showing token amounts Seafood currently rounds out tokens that are very small against usd. For example Seafood shows 0.00 assets for this USDR vault when the correct value us 0.00000806.

https://seafood.yearn.watch/vault/0x531fDb1C8429F404116932226D487db94471C4b7
image

Update Seafood to work like this instead:
image

Tasks

  • Update formatNumber to include compact forms for numbers less than zero using greek si units for milli, micro, nano, and pico. For numbers greater than zero change the logic to use an uppercase unit. For numbers less than zero use lowercase. Here's formatNumber:

    function formatNumber(number, decimals = 2, nonFinite = 'โˆž', compact = false) {

  • Add tests here to demonstrate the new formats work:
    https://github.com/yearn/seafood/blob/main/src/utils/utils.test.js

  • Update the Tokens component to support hover and click features. Use a localstorage value to store the user's current preference (unclicked vs clicked, ie compact vs expanded):

    export function Tokens(

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.