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, which includes the subgraph URL, price feed URL, rewards URL, and ContractAddresses (see examples below).
Example 1: SDKConfig on Ethereum mainnet
Initiate SDKConfig with the addresses of the smart contracts that orchestrate main on-chain functions:
SmartVaultFactory is used for deploying new smart vaults (Yelay partners can also apply to be eligible to deploy vaults with performance fee up to 90%; in that case a different address for SmartVaultFactory should be used*)
StrategyRegistry is used for managing and keeping the list of strategies
DepositManager is used to process deposits
DepositSwap is used for wrapping and swapping assets while depositing
RewardManager is used to process rewards
SpoolLens is a helper contract that provides easier access to certain vault and user data points. It also allows us to simulate the events of certain processes like DoHardWork and flushes.
The following are also required for SDKConfig setup:
Link to Subgraph
Link to Price feeds service
Link to the Rewards Manager service
Link to the Fast Withdrawal service
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