Setting up the SDK
To install the Yelay SDK, use the following npm command:
To use the Yelay SDK, you need to create an instance of the SpoolSdk class. To accomplish this, call the following function with these parameters:
The first parameter is the SDKConfig, where you can select the appropriate config from the set of predefined configs, each made for one of the supported chains (see examples below).
Example 1: SDKConfig on Ethereum mainnet
Initiate SDKConfig by calling the predefined config getMainnetConfig
and passing in the URL to your Subgraph.
Decentralized subgraph option
In order to access public Yelay subgraph used by the SDK, follow these instructions:
First you must create an API key:
go to https://thegraph.com/studio/apikeys
connect an Ethereum address
sign the message to log in (Doesn't cost any Ether)
create API key
API key name:
spool-v2
copy key as API_KEY
you can now query the Yelay subgraph for:
mainnet: https://gateway-arbitrum.network.thegraph.com/api/$API_KEY/subgraphs/id/41A5vZJ2fypeqtD8o5rD1HB7GjVkvP55NR3EeZDXkk2s (it says arbitrum in the URL but the data is just published on arbitrum, it's indexing mainnet)
sepolia: 'https://gateway-testnet-arbitrum.network.thegraph.com/api/$API_KEY/subgraphs/id/J5s1Q5ECEuvcyr8hfCVJxdebmwiQTGWbNGXu8GLfnSBj'
This will give you 100k queries for free every month.
Beyond that, payment is necessary. you can upgrade your plan here: https://thegraph.com/studio/billing/upgrade/ costs are about 4$ per 100k queries.
Alternatively, you may use a third party subgraph hosting service, such as Alchemy: https://www.alchemy.com/pricing.
Note that deployment of the subgraph to a third party hosting service must be completed for the Yelay subgraph to work there. The code is hosted here: https://github.com/spoolfi/spool-v2-core-subgraph/. There are detailed instructions in the README.
Example 2: test Yelay integration on Sepolia testnet
Yelay UI on Sepolia: https://sepolia.dev.spool.fi/sep/smart-vaults
SDKConfig:
Important! On Sepolia, each integrator could initiate running DoHardWork by themselves. Please, reach out to your respective Yelay's technical account manager or the Yelay team on Discord in order to whitelist your account if you want to run DHW on Sepolia.
Please follow these instructions: https://github.com/SpoolFi/spool-v2-testnet-utils/
Sepolia setup has been equipped with 4 ‘mock’ strategies for each asset group:
Example 3: SDKConfig on Arbitrum
Ethers Provider and Signer
If you intend to use only the view-only functions, only the Provider
object can be used.
If you are planning to call state-changing transactions, you will require a Signer
to sign transactions.
Creating an instance of Provider
Creating an instance of Signer
Please replace the placeholder values with the actual values required for your use case.
Last updated