From 9ecc5690f54f891cc86569dfd6ef2a9c58a18620 Mon Sep 17 00:00:00 2001 From: engn33r Date: Sat, 27 Dec 2025 00:00:00 +0000 Subject: [PATCH] Remove subgraph links, add kong and ydaemon docs --- docs/contributing/contribute.md | 10 +- docs/developers/building-on-yearn.md | 12 +- docs/developers/data-services/entities.md | 447 ------------------ docs/developers/data-services/kong.md | 125 +++++ docs/developers/data-services/queries.md | 144 ------ .../developers/data-services/subgraph-info.md | 74 --- docs/developers/data-services/ydaemon.md | 412 ++++++++++++++++ docs/developers/data-services/yearn-data.md | 27 +- docs/developers/data-services/yearn-stack.md | 10 +- docs/developers/v2/getting-started.md | 2 +- docs/developers/v2/hacking-with-yearn.md | 25 - sidebars/sidebarsDeveloperDocs.js | 11 +- sidebars/sidebarsUserDocs.js | 2 +- 13 files changed, 555 insertions(+), 746 deletions(-) delete mode 100644 docs/developers/data-services/entities.md create mode 100644 docs/developers/data-services/kong.md delete mode 100644 docs/developers/data-services/queries.md delete mode 100644 docs/developers/data-services/subgraph-info.md create mode 100644 docs/developers/data-services/ydaemon.md diff --git a/docs/contributing/contribute.md b/docs/contributing/contribute.md index cf544d25c7..cae2e3f1cb 100644 --- a/docs/contributing/contribute.md +++ b/docs/contributing/contribute.md @@ -92,14 +92,12 @@ This is complementary to the above, but it's not directly related to creating st - [Yearn Governance Forum](https://gov.yearn.fi/) - [Yearn Snapshot Governance Voting](https://snapshot.box/#/s:veyfi.eth) -#### List of Yearn Tools +#### List of Yearn Data Tools -- Yearn Subgraphs, [Ethereum](https://thegraph.com/explorer/subgraph?id=0xf50b705e4eaba269dfe954f10c65bd34e6351e0c-0&version=0xf50b705e4eaba269dfe954f10c65bd34e6351e0c-0-0&view=Overview), [Fantom](https://thegraph.com/hosted-service/subgraph/yearn/yearn-vaults-v2-fantom), [GitHub](https://github.com/yearn/yearn-vaults-v2-subgraph) -- Yearn SDK, [GitHub](https://github.com/yearn/yearn-sdk) -- Yearn API, [GitHub](https://github.com/yearn/kong) -- Yearn Discord FAQ Bot, [GitHub](https://github.com/danijelthales/yfi-faq-bot) +- yDaemon API, [GitHub](https://github.com/yearn/ydaemon) +- Kong API, [GitHub](https://github.com/yearn/kong) -### Legacy Products and Websites +### Old Legacy Products and Websites - Former list of [open GitHub issues here](https://contribute.yearn.rocks/). - [v1 yearn.fi](https://v1.yearn.fi), [GitHub](https://github.com/yearn/iearn-finance) diff --git a/docs/developers/building-on-yearn.md b/docs/developers/building-on-yearn.md index 4399d20b9a..9ef5d5a29c 100644 --- a/docs/developers/building-on-yearn.md +++ b/docs/developers/building-on-yearn.md @@ -37,21 +37,19 @@ V2 and V3 vaults implement strategies differently, so it is important to get fam ### Frontend Integrations -Yearn uses a JavaScript SDK for formatting protocol data and generating transactions for reading/writing protocol data. Yearn SDK integrates several components, both on-chain and off-chain. - -[The repository here](https://github.com/turtlemoji/yearn-sdk-examples) contains a live preview and example usage of the Yearn SDK. Explore this codebase to learn how to start interacting with the Yearn protocol in your own app. +Yearn uses Kong and yDaemon as frontend data sources. Old Yearn SDKs existed, but as of late 2025, only yDaemon and Kong are actively used. Check out the [Frontend Integrations](front-end-development) section of this documentation for more information about Frontend Integrations. ### Data Sources -[**yDaemon**](https://ydaemon.yearn.fi/) is a public API for a broad range of Vault data. +[**Kong**](https://kong.yearn.fi/api/gql) is an API to submit graphql queries for Yearn data. -- Learn more about yDaemon in the [README](https://github.com/yearn/ydaemon) +- Learn more about kong [here](/developers/data-services/kong) and in the [README](https://github.com/yearn/kong). -**The Graph** - Query contract data with GQL using the Yearn subgraphs +[**yDaemon**](https://ydaemon.yearn.fi/) is a public API for a broad range of Vault data. -- Learn more about the Graph and Subgraphs that Yearn provides [here](./data-services/subgraph-info). +- Learn more about yDaemon [here](/developers/data-services/ydaemon) and in the [README](https://github.com/yearn/ydaemon) ## Data Analysis diff --git a/docs/developers/data-services/entities.md b/docs/developers/data-services/entities.md deleted file mode 100644 index c7bff739d8..0000000000 --- a/docs/developers/data-services/entities.md +++ /dev/null @@ -1,447 +0,0 @@ - - -# Subgraph Entities - -- [`Transaction`](#transaction) -- [`Token`](#token) -- [`TokenFee`](#tokenfee) -- [`VaultRelease`](#vaultrelease) -- [`Registry`](#registry) -- [`Vault`](#vault) -- [`VaultUpdate`](#vaultupdate) -- [`HealthCheck`](#healthcheck) -- [`Account`](#account) -- [`Deposit`](#deposit) -- [`Withdrawal`](#withdrawal) -- [`Transfer`](#transfer) -- [`AccountVaultPosition`](#accountvaultposition) -- [`AccountVaultPositionUpdate`](#accountvaultpositionupdate) -- [`Strategy`](#strategy) -- [`StrategyReport`](#strategyreport) -- [`StrategyReportResult`](#strategyreportresult) -- [`Harvest`](#harvest) -- [`VaultDayData`](#vaultdaydata) -- [`Yearn`](#yearn) - -
- -# SCHEMA GUIDELINES - -### Naming Conventions - -#### Certain prefixes may be used to indicate a particular type of value. - -#### \* total - indicates this is a cumulative value (e.g. totalSharesMinted, totalGrossReturns) - -#### \* balance - indicates this is a spot balance (e.g. balanceTokensIdle) - -#### \* delta - indicates this value is the difference between the prior state and the current state (e.g. deltaPricePerShare) - -#### \* current - used exclusively in Update entities. Similar to balance, current indicates the state of a field or value at the time of the update. These values are populated in every update whether they changed or not. - -#### \* new - used exclusively in Update entities. Fields with this prefix will only be populated if they have changed since the last Update. If there has been no change, the value will be null. - -#### Use plurals when referring to Tokens or Shares (e.g. totalShares, balanceTokens) - -
-
- -## Transaction - -Description: get specific details of the transaction - -| Field | Type | Description | -| ------------- | ------- | --------------------------------------------------------------------------- | -| id | ID! | Transaction hash + Log Index | -| logIndex | BigInt! | Log index related to the event. A Transaction might contain multiple events | -| event | String! | The event name / call stacktrace | -| from | Bytes! | The transaction sender | -| gasPrice | BigInt! | Gas price used in the transaction | -| gasLimit | BigInt! | Gas limit used in the transaction | -| hash | Bytes! | Transaction hash | -| index | BigInt! | The transaction index | -| to | Bytes! | Address that received the transaction | -| value | BigInt! | Ether value sent in the transaction | -| timestamp | BigInt! | Timestamp when the transaction was executed | -| blockGasLimit | BigInt! | Gas limit used in the current block | -| blockNumber | BigInt! | Block number | - -## Token - -Description: get specific details of the token - -| Field | Type | Description | -| -------- | ------- | --------------------------------- | -| id | ID! | Token address | -| decimals | Int! | Number of decimals for this Token | -| name | String! | Name of the Token | -| symbol | String! | Symbol of the Token | - -## TokenFee - -Description: get specific details of the token fee - -| Field | Type | Description | -| ------------------------ | ------- | --------------------------------------------------------------------------------------------------------------------------------------------------------- | -| id | ID! | Token address | -| vault | Vault! | Vault this fee is for | -| token | Token! | The token which the fees are denominated in. Equivalent to vault.token. | -| totalTreasuryFees | BigInt! | All time fees paid using this token to the treasury. Denominated in the vault's want token. | -| totalStrategyFees | BigInt! | All time fees paid using this token to strategists. Denominated in the vault's want token. | -| totalFees | BigInt! | All time fees paid using this token to strategists and the treasury. Denominated in the vault's want token. | -| unrecognizedTreasuryFees | BigInt! | Internal field used by VaultUpdate. The amount of treasury fees paid using this token that has yet to be recognized by the subgraph's accounting logic. | -| unrecognizedStrategyFees | BigInt! | Internal field used by VaultUpdate. The amount of strategist fees paid using this token that has yet to be recognized by the subgraph's accounting logic. | - -## VaultRelease - -Description: get specific details of the Vault Release - -| Field | Type | Description | -| ----------- | ------------------ | ----------------------------------------- | -| id | ID! | Release index in Registry contract | -| version | String! | Version string | -| contract | Bytes! | Contract address | -| vaults | [`Vault!`](#vault) | Vault deployments of this release version | -| timestamp | BigInt! | Timestamp of Release | -| blockNumber | BigInt! | Block number of Release | -| transaction | Transaction! | Ethereum Transaction | - -## Registry - -Description: get specific details of the Registry - -| Field | Type | Description | -| ----------- | ------------------ | --------------------------------- | -| id | ID! | Registry address | -| timestamp | BigInt! | Transaction timestamp | -| blockNumber | BigInt! | Transaction/Block Block number | -| transaction | Transaction! | Ethereum Transaction | -| vaults | [`Vault!`](#vault) | Vaults registered in the registry | - -## Vault - -Description: get specific details of the Vault - -| Field | Type | Description | -| --------------------- | -------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------- | -| id | ID! | Vault address | -| transaction | Transaction! | Ethereum Transaction | -| registry | Registry! | The registry address | -| token | Token! | Token this Vault will accrue | -| shareToken | Token! | Token representing Shares in the Vault | -| status | VaultStatus! | Vault status | -| classification | VaultClassification! | Vault classification | -| release | VaultRelease! | Release Information | -| latestUpdate | VaultUpdate | Latest Vault Update | -| vaultDayData | [`VaultDayData!`](#vaultdaydata) | All Vault Updates | -| historicalUpdates | [`VaultUpdate!`](#vaultupdate) | All Vault Updates | -| strategies | [`Strategy!`](#strategy) | Strategies for this Vault | -| strategyIds | [Strategy!]! | Strategy Ids for this vault | -| deposits | [`Deposit!`](#deposit) | Token deposits into the Vault | -| withdrawals | [`Withdrawal!`](#withdrawal) | Token withdrawals from the Vault | -| withdrawalQueue | [Strategy!]! | withdrawl queue of strategies | -| transfers | [`Transfer!`](#transfer) | Transfers of Vault Shares | -| tags | [String!]! | Tags attached to the Vault | -| balanceTokens | BigInt! | Balance of Tokens in the Vault and its Strategies | -| balanceTokensIdle | BigInt! | Current idle Token balance | -| sharesSupply | BigInt! | Current supply of Shares | -| managementFeeBps | Int! | Management fee in basis points | -| performanceFeeBps | Int! | Performance fee in basis points | -| rewards | Bytes! | The address where management fees are paid to | -| isTemplateListening | Boolean! | This technical field defines whether this vault is a custom item (created by a custom handler) or not (created by the registry dynamically) | -| activation | BigInt! | Creation timestamp | -| apiVersion | String! | The API version | -| healthCheck | HealthCheck | The vault's health check contract | -| guardian | Bytes! | The address authorized for guardian interactions in the new Vault | -| management | Bytes! | The management address of the Vault to assert privileged functions that can only be called by management | -| governance | Bytes! | The governance address of the Vault to assert privileged functions that can only be called by governance | -| availableDepositLimit | BigInt! | The maximum amount of underlying that can be deposited | -| depositLimit | BigInt! | The maximum amount of tokens that can be deposited in this Vault | -| emergencyShutdown | Boolean! | Is vault in emergency shutdown | -| activationBlockNumber | BigInt! | Block.timestamp of contract deployment | - -## VaultUpdate - -Description: get specific details of Vault Update - -| Field | Type | Description | -| --------------------- | ------------ | -------------------------------------------------------------------------------------------------------------------------------------------- | -| id | ID! | Vault-Transaction-Log | -| timestamp | BigInt! | Timestamp of update | -| blockNumber | BigInt! | Block number of update | -| transaction | Transaction! | Ethereum Transaction | -| vault | Vault! | Vault this update is for | -| tokensDeposited | BigInt! | Sum of tokens deposited | -| tokensWithdrawn | BigInt! | Sum of tokens withdrawn | -| sharesMinted | BigInt! | Sum of Shares minted over all time | -| sharesBurnt | BigInt! | Sum of Shares burnt over all time | -| balancePosition | BigInt! | The current balance position defined as: (vault.totalAssets() \* (vault.pricePerShare() / 10\*\*vault.decimals())). | -| returnsGenerated | BigInt! | Returns generated in Tokens | -| totalFees | BigInt! | Total fees accrued over the lifetime of the vault. Denominated in want tokens. | -| pricePerShare | BigInt! | Price per full share at the time of the update. Denominated in want tokens. | -| currentBalanceTokens | BigInt! | Balance of Tokens in the Vault and its Strategies at the time of update. | -| newManagementFee | BigInt | Management fee at time of update, in basis points. If this value has not been changed since the last VaultEvent, it will be null. | -| newPerformanceFee | BigInt | New Performance fee at time of update, in basis points. If this value has not been changed since the last VaultEvent, it will be null. | -| newRewards | Bytes | The new Rewards address that management fees will be paid to. If this value has not been changed since the last VaultEvent, it will be null. | -| newHealthCheck | HealthCheck | The vault's new health check contract. If this value has not been changed since the last VaultEvent, it will be null. | -| availableDepositLimit | BigInt! | The maximum amount of underlying that can be deposited | -| depositLimit | BigInt! | The maximum amount of tokens that can be deposited in this Vault | -| guardian | Bytes! | The address authorized for guardian interactions in the new Vault | -| management | Bytes! | The management address of the Vault to assert privileged functions that can only be called by management | -| governance | Bytes! | The governance address of the Vault to assert privileged functions that can only be called by governance | - -## Healthcheck - -Description: get healthcheck - -| Field | Type | Description | -| ------ | ------------------ | ------------------------------------------ | -| id | ID! | Health check address | -| vaults | [`Vault!`](#vault) | Vaults that use this health check contract | - -## Account - -Description: get specific details of the Account - -| Field | Type | Description | -| -------------- | ------------------------------------------------ | ------------------------ | -| id | ID! | Account address | -| deposits | [`Deposit!`](#deposit) | Vault deposits | -| withdrawals | [`Withdrawal!`](#withdrawal) | Vault withdrawals | -| vaultPositions | [`AccountVaultPosition!`](#accountvaultposition) | Vault positions | -| sharesReceived | [`Transfer!`](#transfer) | Incoming share transfers | -| sharesSent | [`Transfer!`](#transfer) | Outgoing share transfers | - -## Deposit - -Description: get specific details of the Deposit - -| Field | Type | Description | -| ------------ | ------------ | ------------------------------------- | -| id | ID! | Transaction-Log | -| timestamp | BigInt! | Timestamp of update | -| blockNumber | BigInt! | Block number of update | -| account | Account! | Account making Deposit | -| vault | Vault! | Vault deposited into | -| tokenAmount | BigInt! | Number of Tokens deposited into Vault | -| sharesMinted | BigInt! | Number of new Vault Shares minted | -| transaction | Transaction! | Ethereum Transaction | -| vaultUpdate | VaultUpdate! | Vault Update | - -## Withdrawal - -Description: get specific details of the Withdrawal - -| Field | Type | Description | -| ----------- | ------------ | ------------------------------------- | -| id | ID! | Transaction-Log | -| timestamp | BigInt! | Timestamp of update | -| blockNumber | BigInt! | Block number of update | -| account | Account! | Account making withdraw | -| vault | Vault! | Vault withdrawn from | -| tokenAmount | BigInt! | Number of Tokens withdrawn from Vault | -| sharesBurnt | BigInt! | Number of Vault Shares burnt | -| transaction | Transaction! | Ethereum Transaction | -| vaultUpdate | VaultUpdate! | Vault Update | - -## Transfer - -Description: get specific details of the Transfer - -| Field | Type | Description | -| --------------- | ------------ | ----------------------------------------------------------------------------------------- | -| id | ID! | Transaction-Log | -| vault | Vault! | Vault | -| from | Account! | Sender | -| to | Account! | Receiver | -| shareToken | Token! | Vault Share Token | -| shareAmount | BigInt! | Number of Vault Shares transferred | -| token | Token! | Vault Token | -| tokenAmount | BigInt! | Number of Tokens redeemable for shares transferred | -| tokenAmountUsdc | BigInt! | Token Amount in USDC, 0 if the transaction was before the oracle was deployed at 12198044 | -| timestamp | BigInt! | Timestamp of Transfer | -| blockNumber | BigInt! | Block number of Transfer | -| transaction | Transaction! | Ethereum Transaction | -| isFeeToTreasury | Boolean! | Whether the transfer was used to pay a fee to the vault's rewards address | -| isFeeToStrategy | Boolean! | Whether the transfer was used to pay a fee to a strategy | - -## AccountVaultPosition - -Description: get specific details of the Account Vault positions - -| Field | Type | Description | -| --------------- | ------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------- | -| id | ID! | Account-Vault | -| vault | Vault! | Vault | -| account | Account! | Account | -| token | Token! | Vault token | -| shareToken | Token! | Vault share token | -| transaction | Transaction! | Created in transaction | -| latestUpdate | AccountVaultPositionUpdate! | Latest account update for this Vault | -| updates | [`AccountVaultPositionUpdate!`](#accountvaultpositionupdate) | Account updates over time | -| balanceShares | BigInt! | Share balance | -| balanceTokens | BigInt! | The current balance of tokens defined as: sum(deposits) - sum(withdrawals) + sum(received transfers) - sum(sent transfers). | -| balancePosition | BigInt! | The current balance position defined as: (vault.balanceOf(account) \* (vault.pricePerShare() / 10\*\*vault.decimals())). | -| balanceProfit | BigInt! | The accumulated profit balance for the account/vault. It is only calculated when the user withdraws all the shares. | - -## AccountVaultPositionUpdate - -Description: get specific details of the Account Vault positions - -| Field | Type | Description | -| -------------------- | --------------------- | ------------------------------------------------------ | -| id | ID! | Account-Vault-Order | -| order | BigInt! | Incremental value for the same account/vault. | -| timestamp | BigInt! | Timestamp | -| blockNumber | BigInt! | Block number | -| account | Account! | Account that owns position update | -| accountVaultPosition | AccountVaultPosition! | The account vault position that this update applies to | -| transaction | Transaction! | Ethereum Transaction | -| deposits | BigInt! | Sum of token deposits | -| withdrawals | BigInt! | Sum of token withdrawals | -| sharesMinted | BigInt! | Sum of share tokens minted | -| sharesBurnt | BigInt! | Sum of share tokens burnt | -| tokensSent | BigInt! | Tokens sent | -| tokensReceived | BigInt! | Tokens received | -| sharesSent | BigInt! | Share tokens sent | -| sharesReceived | BigInt! | Share tokens received | -| balanceShares | BigInt! | The balance of shares | -| balancePosition | BigInt! | The balance position. | -| vaultUpdate | VaultUpdate! | Vault Update | - -## Strategy - -Description: get specific details of the Strategy - -| Field | Type | Description | -| -------------------- | ------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| id | ID! | Strategy address | -| name | String! | Strategy name. | -| timestamp | BigInt! | Timestamp the vault information was most recently updated. | -| blockNumber | BigInt! | Blocknumber the vault information was most recently updated. | -| transaction | Transaction! | Ethereum Transaction | -| address | Bytes! | The Strategy address. | -| healthCheck | Bytes | The health check contract address. | -| doHealthCheck | Boolean! | Defines whether the strategy will call the health check or not. | -| inQueue | Boolean! | Defines whether this strategy is within the vault queue | -| vault | Vault! | The Vault | -| clonedFrom | Strategy | Strategy reference used to clone this strategy. | -| debtLimit | BigInt! | Defines the maximum borrow amount. In strategies \ 0 + +hideAlways (boolean) + +- Default: false +- Valid values: true/false (or 1/0, yes/no) +- Hides vaults marked as hidden or retired +- Incompatible with migrable=true + +migrable (string) + +- Default: 'none' +- Valid values: + - none - Don't include migrable vaults if hideAlways/retired + - all - Include all migrable vaults + - nodust - Include migrable vaults with TVL > $100 + - ignore - Completely ignore vaults with migrations available +- Incompatible with hideAlways=true + +chainIDs (string) + +- Default: All supported chains +- Valid values: Comma-separated chain IDs: 1, 10, 137, 250, 8453, 42161 +- Example: "1,137,42161" +- Supported chains: + - 1 = Ethereum + - 10 = Optimism + - 137 = Polygon + - 250 = Fantom + - 8453 = Base + - 42161 = Arbitrum + +humanized (boolean) + +- Default: false +- Valid values: true/false +- Used in: Price endpoints +- Returns floating-point prices instead of raw big integers + +- `?skip=N` - Skip N vaults from the query (default: 0) +- `?first=N` - Limit results to N vaults + +### Strategy Endpoints + +``` +GET /{chainID}/strategies/all # All strategies for chain +GET /{chainID}/strategies/{address} # Specific strategy details +GET /{chainID}/strategy/{address} # Same as above +GET /{chainID}/reports/{address} # Harvest reports for strategy +``` + +### Harvest & User Earnings Endpoints + +``` +GET /{chainID}/vaults/harvests/{addresses} # Harvest history for vaults +GET /{chainID}/earned/{address}/{vaults} # Earnings per vault per user +GET /{chainID}/earned/{address} # All earnings for user on chain +GET /earned/{address} # All earnings for user (all chains) +``` + +### Token Endpoints + +``` +GET /tokens/all # All tokens (all chains) +GET /{chainID}/tokens/all # All tokens for chain +``` + +### Price Endpoints + +``` +GET /prices/all # All prices (all chains) +GET /{chainID}/prices/all # All prices for chain +GET /{chainID}/prices/{address} # Price for specific token +GET /{chainID}/prices/some/{addresses} # Prices for multiple tokens +GET /{chainID}/prices/all/details # All prices with metadata +GET /prices/some/{addresses} # Prices across chains +POST /prices/some # POST body with addresses array +``` + +**Price Format:** Returns price in USD with 6 decimal precision (e.g., "999727" = $0.999727) + +### Info/Utility Endpoints + +``` +GET / # Welcome message +GET /health # Health check with timestamp +GET /info/chains # Supported chains configuration +GET /info/vaults/blacklisted # Blacklisted vault addresses +GET /{chainID}/status # Chain indexing status +``` + +### Custom Integration Endpoints + +``` +GET /rotki/list/vaults # Vaults formatted for Rotki +GET /rotki/count/vaults # Vault count for Rotki +``` + +## Risk Score System + +The `riskScore` array in vault data contains 11 risk factors (scored 0-5 each): + +| Index | Risk Factor | +|-------|-------------| +| 0 | Code review quality | +| 1 | Testing coverage and quality | +| 2 | Code complexity | +| 3 | Market risk exposure | +| 4 | Protocol integration complexity | +| 5 | Centralization risk | +| 6 | External protocol audit status | +| 7 | External protocol centralization | +| 8 | External protocol TVL size | +| 9 | External protocol longevity | +| 10 | External protocol type risk | + +**Overall Risk Level:** +- -1: Not assessed +- 1: Safest +- 5: Riskiest + +## Vault Categories + +### Vault Types +- "Yearn Vault" - Yearn V2 vaults +- "Automated Yearn Vault" - Yearn V3 vaults +- Various integration-specific types + +### Vault Kinds +- "Legacy" - Older vault versions +- "Single Strategy" - One strategy per vault +- "Multi Strategy" - Multiple strategies (V3) + +## Architecture Overview + +### Data Sources + +yDaemon aggregates data from multiple sources: + +1. **Yearn Subgraph**: Base data source for vault and strategy information +2. **Yearn Meta**: Configuration and metadata (risk scores, descriptions, icons) +3. **Yearn Lens Oracle**: On-chain price data for tokens and vaults +4. **Blockchain RPC**: Direct chain queries via Tenderly and other providers +5. **Curve API**: Pool and gauge information for Curve vaults +6. **External Price Feeds**: Gamma, Pendle, and other protocol-specific data + +### Caching Strategy + +- **Vault Data**: 5-minute cache TTL +- **Price Data**: 1-minute cache TTL +- **Token Data**: 5-minute cache TTL +- Background daemons refresh data continuously + +## Performance & Features + +- Handles multiple chains simultaneously +- Websocket support for real-time updates (where available) +- Batch operations via multicall contracts +- Optimized block range queries per chain +- CORS enabled for all origins +- gzip compression enabled + +## Code Examples + +### Fetch All Vaults on Ethereum + +```bash +curl https://ydaemon.yearn.fi/1/vaults/all +``` + +```javascript +// JavaScript/TypeScript +const response = await fetch('https://ydaemon.yearn.fi/1/vaults/all'); +const vaults = await response.json(); + +console.log(`Found ${vaults.length} vaults`); +vaults.forEach(vault => { + console.log(`${vault.name}: TVL $${vault.tvl.tvl.toLocaleString()}`); +}); +``` + +```python +# Python +import requests + +response = requests.get('https://ydaemon.yearn.fi/1/vaults/all') +vaults = response.json() + +for vault in vaults: + print(f"{vault['name']}: TVL ${vault['tvl']['tvl']:,.2f}") +``` + +### Get Specific Vault Details + +```bash +# Get yvDAI vault details +curl https://ydaemon.yearn.fi/1/vaults/0xdA816459F1AB5631232FE5e97a05BBBb94970c95 +``` + +```typescript +// TypeScript with type safety +interface VaultResponse { + address: string; + name: string; + symbol: string; + tvl: { + totalAssets: string; + tvl: number; + price: number; + }; + apr: { + netAPR: number; + fees: { + performance: number; + management: number; + }; + }; +} + +const getVaultDetails = async (chainId: number, vaultAddress: string): Promise => { + const response = await fetch(`https://ydaemon.yearn.fi/${chainId}/vaults/${vaultAddress}`); + return await response.json(); +}; + +const vault = await getVaultDetails(1, '0xdA816459F1AB5631232FE5e97a05BBBb94970c95'); +console.log(`APR: ${(vault.apr.netAPR * 100).toFixed(2)}%`); +``` + +### Get Token Prices + +```bash +# Get DAI price +curl https://ydaemon.yearn.fi/1/prices/0x6B175474E89094C44Da98b954EedeAC495271d0F +# Returns: "999727" (meaning $0.999727) +``` + +```javascript +// Get multiple token prices +const tokens = [ + '0x6B175474E89094C44Da98b954EedeAC495271d0F', // DAI + '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48', // USDC +]; + +const addresses = tokens.join(','); +const response = await fetch(`https://ydaemon.yearn.fi/1/prices/some/${addresses}`); +const prices = await response.json(); + +// Convert from 6-decimal format to standard price +Object.entries(prices).forEach(([address, price]) => { + console.log(`Token ${address}: $${(price / 1e6).toFixed(6)}`); +}); +``` + +### Get User Earnings + +```bash +# Get earnings for a user across all vaults on Ethereum +curl https://ydaemon.yearn.fi/1/earned/0x742d35Cc6634C0532925a3b844Bc454e4438f44e +``` + +### Pagination Example + +```javascript +// Fetch vaults in batches +const BATCH_SIZE = 100; +let allVaults = []; +let skip = 0; + +while (true) { + const response = await fetch( + `https://ydaemon.yearn.fi/1/vaults/all?first=${BATCH_SIZE}&skip=${skip}` + ); + const vaults = await response.json(); + + if (vaults.length === 0) break; + + allVaults = allVaults.concat(vaults); + skip += BATCH_SIZE; + + if (vaults.length < BATCH_SIZE) break; // Last page +} + +console.log(`Total vaults: ${allVaults.length}`); +``` diff --git a/docs/developers/data-services/yearn-data.md b/docs/developers/data-services/yearn-data.md index 7751202c75..b642ec68ed 100644 --- a/docs/developers/data-services/yearn-data.md +++ b/docs/developers/data-services/yearn-data.md @@ -2,14 +2,6 @@ If you want to programmatically interact with Yearn data, or need to fetch large amounts of it then you have a few options: -## yDaemon - -yDaemon is a RESTful API that hydrates subgraph responses with more data, like APY calculations. yDaemon is the best source for current yearn Vault data and is what is used by the production Yearn frontends. - -- **Live API:** https://ydaemon.yearn.fi/1/vaults/all -- **Source:** https://github.com/yearn/ydaemon -- **Guide:** https://medium.com/iearn/ydaemon-one-api-to-unify-all-yearn-data-4fc74dc9a33b - ## Kong [Kong](https://kong.yearn.fi/) is an integrated set of services and tools that make it easy to index EVM logs and state, enrich your data with custom hooks, query your data over graphql. Kong is designed to be cheap, reliable, easy to maintain, and simplify the process of updating your index. @@ -27,24 +19,13 @@ Kong can be run locally or a hosted version run by Yearn can be queried with the - **Live API:** https://kong.yearn.fi/api/gql - **Source:** https://github.com/yearn/kong -- **Docs:** Under Construction 🚧 - -## Subgraph -:::info - -Currently only subgraphs for V2 vaults are available and some subgraphs have not been migrated to the new service. We recommend using Kong or yDaemon for your data needs. - -::: - -The subgraph is a GraphQL interface to query raw historical data. For current data it is recommended to check yDaemon before using the subgraph directly. - -- **Docs:** https://docs.yearn.fi/developers/data-services/subgraph-info +## yDaemon -### V2 Vaults +yDaemon is a RESTful API used by some Yearn frontends. While Kong is generally preferred to yDaemon when possible for the areas of overlap, yDaemon is the best source for current Yearn Vault data and is what is used by the production Yearn frontends. -- **Mainnet Live API:** https://thegraph.com/explorer/subgraphs/FDLuaz69DbMADuBjJDEcLnTuPnjhZqNbFVrkNiBLGkEg?view=Query&chain=arbitrum-one -- **Arbitrum Live API:** https://thegraph.com/explorer/subgraphs/G3JZhmKKHC4mydRzD6kSz5fCWve5WDYYCyTFSJyv3SD5?view=Query&chain=arbitrum-one +- **Live API:** https://ydaemon.yearn.fi/1/vaults/all +- **Source:** https://github.com/yearn/ydaemon ## Yearn Lens diff --git a/docs/developers/data-services/yearn-stack.md b/docs/developers/data-services/yearn-stack.md index c96e740b63..d3a2eb7069 100644 --- a/docs/developers/data-services/yearn-stack.md +++ b/docs/developers/data-services/yearn-stack.md @@ -33,11 +33,7 @@ Yearn SDK integrates several components, both on-chain and off-chain. ### Off Chain -- Yearn Exporter: stores (and displays) stats about yearn assets, exposing: - - historical TVL - - historical APY -- Yearn Subgraph: stores all historical data for users -- Zapper Integration +- yDaemon and Kong: stores historical data for vaults ## Backend features @@ -67,10 +63,6 @@ Yearn SDK integrates several components, both on-chain and off-chain. - Read methods will seamlessly integrate with all datasources, while keeping coherent datastructures. - Write methods talk directly to assets on chain. Execution of write transactions will trigger refresh events so data freshness of frontend (or other integration platforms) will still be preserved. -### Historical User Earnings - -- Yearn Subgraph leverages thegraph to store historical user data that can be aggregated to display historical earnings. - ### Metadata - New way to store all the information that would generally be hard coded directly in the frontend. diff --git a/docs/developers/v2/getting-started.md b/docs/developers/v2/getting-started.md index 1a29d2cf28..69eab593e2 100644 --- a/docs/developers/v2/getting-started.md +++ b/docs/developers/v2/getting-started.md @@ -36,7 +36,7 @@ When the strategy has more than 3M-10M in TVL, it should improve it's risk score [Risk-score](/developers/security/risks/risk-score) dimension: 1=best, 5=worst. 1. Improve risk score in dimensions like external audit, additional security reviews -[Internal Risk Dashboard](https://yearn.watch/risk) +[Internal Risk Dashboard](https://seafood.yearn.watch/risk) 2. A required way to improve team knowledge score is to create a committee of 3 people with deep knowledge monitoring the strategy 24/7 When it's passed 50M in TVL diff --git a/docs/developers/v2/hacking-with-yearn.md b/docs/developers/v2/hacking-with-yearn.md index 3509002130..849ffc0f47 100644 --- a/docs/developers/v2/hacking-with-yearn.md +++ b/docs/developers/v2/hacking-with-yearn.md @@ -100,31 +100,6 @@ By having a strategy, users only need to deposit single assets and let the strat Yearn aims to provide more insights into our products to our customers and partners through analyzing the on-chain and off-chain data. Given that all Yearn protocol data is publicly stored on-chain, there are lots of insights to be gained from analyzing these transactions. -Two common tools for on-chain data analysis are: -1. **Dune Analytics**- Query contract data and generate dashboards with SQL -- [Current Dashboards](https://dune.com/projects/yearn ) - - Here's a list of all the new things you can query for: - - harvests - - deployments - - transactions - - contract_tokens - - contract_strategy - - v2_deployments - -Fiddle with them all at https://dune.com/queries/625814 - -2. **The Graph**- Query contract data with GQL using the Yearn subgraphs - -The Graph is a decentralized protocol for indexing and querying data from blockchains, starting with Ethereum. It is an easier way to retrieve specific data from the blockchain, within the ethos of web3, with the advantages of decentralization and reliability. - -GraphQL is the underlying query language used in The Graph. - -What is the difference between standard RESTFUL API calls and GraphQL calls? The difference is that traditional APIs require the developers to create specific endpoints for users that return specific data. If the user requires more information, they may need to make multiple API calls, sometimes hundreds of API calls, to get the information they require. With The Graph (which uses GraphQL), only one call is needed to a subgraph, as long as the developer has created a flexible schema. - - - https://thegraph.com/hosted-service/subgraph/rareweasel/yearn-vaults-v2-mainnet - - https://api.thegraph.com/subgraphs/name/rareweasel/yearn-vaults-v2-mainnet/graphql - ## Some of the research questions that we are interested in: * Screening profitable liquidity pools for our strategies * Assessing the impact of TVL on the impermanent loss diff --git a/sidebars/sidebarsDeveloperDocs.js b/sidebars/sidebarsDeveloperDocs.js index b4a4b4a7f7..875d69eba0 100644 --- a/sidebars/sidebarsDeveloperDocs.js +++ b/sidebars/sidebarsDeveloperDocs.js @@ -81,15 +81,8 @@ export default { id: 'data-services/yearn-data', }, items: [ - { - type: 'category', - label: 'Subgraph', - link: { - type: 'doc', - id: 'data-services/subgraph-info', - }, - items: ['data-services/entities', 'data-services/queries'], - }, + 'data-services/kong', + 'data-services/ydaemon', 'data-services/yearn-lens', ], }, diff --git a/sidebars/sidebarsUserDocs.js b/sidebars/sidebarsUserDocs.js index 9455abed5d..5e02f35048 100644 --- a/sidebars/sidebarsUserDocs.js +++ b/sidebars/sidebarsUserDocs.js @@ -116,7 +116,7 @@ module.exports = { { type: 'link', label: 'yYB Contract Addresses →', - href: '/developers/addresses/yYB-contracts', + href: '/developers/addresses/yyb-contracts', }, { type: 'link',